Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build
run: |
pnpm run build
pnpm tsx packages/cli/scripts/post-build.ts

- name: Lint
run: pnpm run lint
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build
run: |
pnpm run build
pnpm tsx packages/cli/scripts/post-build.ts

- name: Get version from package.json
id: version
Expand Down
20 changes: 20 additions & 0 deletions packages/cli/scripts/post-build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

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

if (!token) {
console.warn('TELEMETRY_TRACKING_TOKEN is not set.');
}

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 filePath = path.join(_dirname, '..', file);
const content = fs.readFileSync(filePath, 'utf-8');
const updatedContent = content.replace('<TELEMETRY_TRACKING_TOKEN>', token);
fs.writeFileSync(filePath, 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');
}
},
});