@@ -32,7 +32,32 @@ if (!existsSync(join(root, 'node_modules'))) {
3232
3333// build all workspaces/packages
3434execSync ( 'npm run generate' , { stdio : 'inherit' , cwd : root } ) ;
35- execSync ( 'npm run build --workspaces' , { stdio : 'inherit' , cwd : root } ) ;
35+
36+ if ( process . env . CI ) {
37+ console . log ( 'CI environment detected. Building workspaces sequentially...' ) ;
38+ execSync ( 'npm run build --workspaces' , { stdio : 'inherit' , cwd : root } ) ;
39+ } else {
40+ // Build core first because everyone depends on it
41+ console . log ( 'Building @google/gemini-cli-core...' ) ;
42+ execSync ( 'npm run build -w @google/gemini-cli-core' , {
43+ stdio : 'inherit' ,
44+ cwd : root ,
45+ } ) ;
46+
47+ // Build the rest in parallel
48+ console . log ( 'Building other workspaces in parallel...' ) ;
49+ const workspaceInfo = JSON . parse (
50+ execSync ( 'npm query .workspace --json' , { cwd : root , encoding : 'utf-8' } ) ,
51+ ) ;
52+ const parallelWorkspaces = workspaceInfo
53+ . map ( ( w ) => w . name )
54+ . filter ( ( name ) => name !== '@google/gemini-cli-core' ) ;
55+
56+ execSync (
57+ `npx npm-run-all --parallel ${ parallelWorkspaces . map ( ( w ) => `"build -w ${ w } "` ) . join ( ' ' ) } ` ,
58+ { stdio : 'inherit' , cwd : root } ,
59+ ) ;
60+ }
3661
3762// also build container image if sandboxing is enabled
3863// skip (-s) npm install + build since we did that above
0 commit comments