File tree Expand file tree Collapse file tree 4 files changed +26
-19
lines changed Expand file tree Collapse file tree 4 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1- import fs from 'node:fs' ;
2- import path from 'node:path' ;
31import { defineConfig } from 'tsup' ;
42
53export 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} ) ;
You can’t perform that action at this time.
0 commit comments