@@ -61,6 +61,16 @@ export async function scaffoldMonorepo(projectNameArg, options) {
6161 initial : true
6262 } ) ;
6363 }
64+ if ( options . withActions === undefined ) {
65+ interactiveQuestions . push ( {
66+ type : 'toggle' ,
67+ name : 'withActions' ,
68+ message : 'Generate GitHub Actions CI workflow?' ,
69+ active : 'yes' ,
70+ inactive : 'no' ,
71+ initial : false
72+ } ) ;
73+ }
6474
6575 let answers = { } ;
6676 const nonInteractive = ! ! options . yes || process . env . CI === 'true' ;
@@ -81,6 +91,9 @@ export async function scaffoldMonorepo(projectNameArg, options) {
8191 case 'git' :
8292 answers . git = false ;
8393 break ;
94+ case 'withActions' :
95+ answers . withActions = false ; // default disabled in non-interactive mode
96+ break ;
8497 default :
8598 break ;
8699 }
@@ -104,6 +117,12 @@ export async function scaffoldMonorepo(projectNameArg, options) {
104117 options . preset = options . preset || answers . preset || '' ;
105118 options . packageManager = options . packageManager || answers . packageManager || 'npm' ;
106119 if ( options . git === undefined ) options . git = answers . git ;
120+ if ( options . withActions === undefined ) options . withActions = answers . withActions ;
121+ // Commander defines '--no-install' as option 'install' defaulting to true, false when flag passed.
122+ if ( Object . prototype . hasOwnProperty . call ( options , 'install' ) ) {
123+ // Normalize to legacy noInstall boolean used below.
124+ options . noInstall = options . install === false ;
125+ }
107126
108127 console . log ( chalk . cyanBright ( `\n🚀 Creating ${ projectName } monorepo...\n` ) ) ;
109128
@@ -437,7 +456,8 @@ export async function scaffoldMonorepo(projectNameArg, options) {
437456 }
438457
439458 const pm = options . packageManager || 'npm' ;
440- if ( ! options . noInstall ) {
459+ // Commander maps --no-install to options.install = false
460+ if ( options . install !== false ) {
441461 console . log ( chalk . cyan ( `\n📦 Installing root dependencies using ${ pm } ...` ) ) ;
442462 const installCmd = pm === 'yarn' ? [ 'install' ] : pm === 'pnpm' ? [ 'install' ] : pm === 'bun' ? [ 'install' ] : [ 'install' ] ;
443463 try {
@@ -447,6 +467,25 @@ export async function scaffoldMonorepo(projectNameArg, options) {
447467 }
448468 }
449469
470+ // Optionally generate GitHub Actions workflow
471+ if ( options . withActions ) {
472+ try {
473+ const wfDir = path . join ( projectDir , '.github' , 'workflows' ) ;
474+ await fs . mkdirp ( wfDir ) ;
475+ const wfPath = path . join ( wfDir , 'ci.yml' ) ;
476+ if ( ! ( await fs . pathExists ( wfPath ) ) ) {
477+ const nodeVersion = '20.x' ;
478+ const installStep = pm === 'yarn' ? 'yarn install --frozen-lockfile || yarn install' : pm === 'pnpm' ? 'pnpm install' : pm === 'bun' ? 'bun install' : 'npm ci || npm install' ;
479+ const testCmd = pm === 'yarn' ? 'yarn test' : pm === 'pnpm' ? 'pnpm test' : pm === 'bun' ? 'bun test' : 'npm test' ;
480+ const wf = `# Generated by create-polyglot CI scaffold\nname: CI\n\non:\n push:\n branches: [ main, master ]\n pull_request:\n branches: [ main, master ]\n\njobs:\n build-test:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n - name: Setup Node.js\n uses: actions/setup-node@v4\n with:\n node-version: ${ nodeVersion } \n cache: '${ pm === 'npm' ? 'npm' : pm } '\n - name: Install dependencies\n run: ${ installStep } \n - name: Run tests\n run: ${ testCmd } \n` ;
481+ await fs . writeFile ( wfPath , wf ) ;
482+ console . log ( chalk . green ( '✅ Added GitHub Actions workflow (.github/workflows/ci.yml)' ) ) ;
483+ }
484+ } catch ( e ) {
485+ console . log ( chalk . yellow ( '⚠️ Failed to create GitHub Actions workflow:' ) , e . message ) ;
486+ }
487+ }
488+
450489 // Write polyglot config
451490 const polyglotConfig = {
452491 name : projectName ,
@@ -459,10 +498,11 @@ export async function scaffoldMonorepo(projectNameArg, options) {
459498 printBoxMessage ( [
460499 '🎉 Monorepo setup complete!' ,
461500 `cd ${ projectName } ` ,
462- options . noInstall ? `${ pm } install` : '' ,
501+ options . install === false ? `${ pm } install` : '' ,
463502 `${ pm } run list:services # quick list (fancy table)` ,
464503 `${ pm } run dev # run local node/frontend services` ,
465504 'docker compose up --build# run all via docker' ,
505+ options . withActions ? 'GitHub Actions CI ready (see .github/workflows/ci.yml)' : '' ,
466506 '' ,
467507 'Happy hacking!'
468508 ] . filter ( Boolean ) ) ;
0 commit comments