Skip to content

Commit b02958d

Browse files
authored
chore: fix telemetry token (#236)
* chore: fix telemetry token * update * update * try again * update * update * update * update * update * update * update * fix
1 parent b443018 commit b02958d

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

.github/workflows/build-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ jobs:
6868
run: pnpm install --frozen-lockfile
6969

7070
- name: Build
71-
run: pnpm run build
71+
run: |
72+
pnpm run build
73+
pnpm tsx packages/cli/scripts/post-build.ts
7274
7375
- name: Lint
7476
run: pnpm run lint

.github/workflows/publish-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ jobs:
3636
run: pnpm install --frozen-lockfile
3737

3838
- name: Build
39-
run: pnpm run build
39+
run: |
40+
pnpm run build
41+
pnpm tsx packages/cli/scripts/post-build.ts
4042
4143
- name: Get version from package.json
4244
id: version

packages/cli/scripts/post-build.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
const token = process.env.TELEMETRY_TRACKING_TOKEN ?? '';
6+
7+
if (!token) {
8+
console.warn('TELEMETRY_TRACKING_TOKEN is not set.');
9+
}
10+
11+
const filesToProcess = ['dist/index.js', 'dist/index.cjs'];
12+
const _dirname = path.dirname(fileURLToPath(import.meta.url));
13+
14+
for (const file of filesToProcess) {
15+
console.log(`Processing ${file} for telemetry token...`);
16+
const filePath = path.join(_dirname, '..', file);
17+
const content = fs.readFileSync(filePath, 'utf-8');
18+
const updatedContent = content.replace('<TELEMETRY_TRACKING_TOKEN>', token);
19+
fs.writeFileSync(filePath, updatedContent, 'utf-8');
20+
}

packages/cli/tsup.config.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import fs from 'node:fs';
2-
import path from 'node:path';
31
import { defineConfig } from 'tsup';
42

53
export default defineConfig({
@@ -12,19 +10,4 @@ export default defineConfig({
1210
clean: true,
1311
dts: true,
1412
format: ['esm', 'cjs'],
15-
onSuccess: async () => {
16-
if (!process.env['TELEMETRY_TRACKING_TOKEN']) {
17-
return;
18-
}
19-
const filesToProcess = ['dist/index.js', 'dist/index.cjs'];
20-
for (const file of filesToProcess) {
21-
console.log(`Processing ${file} for telemetry token...`);
22-
const content = fs.readFileSync(path.join(__dirname, file), 'utf-8');
23-
const updatedContent = content.replace(
24-
'<TELEMETRY_TRACKING_TOKEN>',
25-
process.env['TELEMETRY_TRACKING_TOKEN'],
26-
);
27-
fs.writeFileSync(file, updatedContent, 'utf-8');
28-
}
29-
},
3013
});

0 commit comments

Comments
 (0)