Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
- main
- dev

env:
TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }}
DO_NOT_TRACK: '1'

permissions:
contents: read

Expand Down Expand Up @@ -68,7 +64,9 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build
env:
TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }}
run: echo TOKEN $TELEMETRY_TRACKING_TOKEN && pnpm run build

- name: Lint
run: pnpm run lint
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"zenstack": "bin/cli"
},
"scripts": {
"build": "tsc --noEmit && tsup-node",
"build": "tsc --noEmit && tsup-node && tsx scripts/post-build.ts",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"test": "vitest run",
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/scripts/post-build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const token = process.env['TELEMETRY_TRACKING_TOKEN'] ?? '';

console.log('TELEMETRY_TRACKING_TOKEN:', token?.[0]);

const filesToProcess = ['dist/index.js', 'dist/index.cjs'];
const _dirname = path.dirname(fileURLToPath(import.meta.url));

for (const file of filesToProcess) {
console.log(`Processing ${file} for telemetry token...`);
const content = fs.readFileSync(path.join(_dirname, '..', file), 'utf-8');
const updatedContent = content.replace('<TELEMETRY_TRACKING_TOKEN>', token);
fs.writeFileSync(file, updatedContent, 'utf-8');
}
17 changes: 0 additions & 17 deletions packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fs from 'node:fs';
import path from 'node:path';
import { defineConfig } from 'tsup';

export default defineConfig({
Expand All @@ -12,19 +10,4 @@ export default defineConfig({
clean: true,
dts: true,
format: ['esm', 'cjs'],
onSuccess: async () => {
if (!process.env['TELEMETRY_TRACKING_TOKEN']) {
return;
}
const filesToProcess = ['dist/index.js', 'dist/index.cjs'];
for (const file of filesToProcess) {
console.log(`Processing ${file} for telemetry token...`);
const content = fs.readFileSync(path.join(__dirname, file), 'utf-8');
const updatedContent = content.replace(
'<TELEMETRY_TRACKING_TOKEN>',
process.env['TELEMETRY_TRACKING_TOKEN'],
);
fs.writeFileSync(file, updatedContent, 'utf-8');
}
},
});