Skip to content

Commit 01defdc

Browse files
committed
update
1 parent 4b20b3f commit 01defdc

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"zenstack": "bin/cli"
2323
},
2424
"scripts": {
25-
"build": "tsc --noEmit && tsup-node",
25+
"build": "tsc --noEmit && tsup-node && tsx scripts/post-build.ts",
2626
"watch": "tsup-node --watch",
2727
"lint": "eslint src --ext ts",
2828
"test": "vitest run",

packages/cli/scripts/post-build.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
console.log('TELEMETRY_TRACKING_TOKEN:', token);
8+
9+
const filesToProcess = ['dist/index.js', 'dist/index.cjs'];
10+
const _dirname = path.dirname(fileURLToPath(import.meta.url));
11+
12+
for (const file of filesToProcess) {
13+
console.log(`Processing ${file} for telemetry token...`);
14+
const content = fs.readFileSync(path.join(_dirname, '..', file), 'utf-8');
15+
const updatedContent = content.replace('<TELEMETRY_TRACKING_TOKEN>', token);
16+
fs.writeFileSync(file, updatedContent, 'utf-8');
17+
}

packages/cli/tsup.config.ts

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

0 commit comments

Comments
 (0)