Skip to content

Commit c44ecc2

Browse files
committed
feat: normalize install option handling in scaffoldMonorepo and update tests for init subcommand
1 parent 418086e commit c44ecc2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

bin/lib/scaffold.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ export async function scaffoldMonorepo(projectNameArg, options) {
118118
options.packageManager = options.packageManager || answers.packageManager || 'npm';
119119
if (options.git === undefined) options.git = answers.git;
120120
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+
}
121126

122127
console.log(chalk.cyanBright(`\n🚀 Creating ${projectName} monorepo...\n`));
123128

@@ -451,7 +456,8 @@ export async function scaffoldMonorepo(projectNameArg, options) {
451456
}
452457

453458
const pm = options.packageManager || 'npm';
454-
if (!options.noInstall) {
459+
// Commander maps --no-install to options.install = false
460+
if (options.install !== false) {
455461
console.log(chalk.cyan(`\n📦 Installing root dependencies using ${pm}...`));
456462
const installCmd = pm === 'yarn' ? ['install'] : pm === 'pnpm' ? ['install'] : pm === 'bun' ? ['install'] : ['install'];
457463
try {
@@ -492,7 +498,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
492498
printBoxMessage([
493499
'🎉 Monorepo setup complete!',
494500
`cd ${projectName}`,
495-
options.noInstall ? `${pm} install` : '',
501+
options.install === false ? `${pm} install` : '',
496502
`${pm} run list:services # quick list (fancy table)`,
497503
`${pm} run dev # run local node/frontend services`,
498504
'docker compose up --build# run all via docker',

tests/actions-workflow.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('GitHub Actions workflow generation', () => {
1919
it('creates a ci.yml when --with-actions passed', async () => {
2020
const repoRoot = process.cwd();
2121
const cliPath = path.join(repoRoot, 'bin/index.js');
22-
await execa('node', [cliPath, projName, '--services', 'node', '--no-install', '--with-actions', '--yes'], { cwd: tmpDir });
22+
await execa('node', [cliPath, 'init', projName, '--services', 'node', '--no-install', '--with-actions', '--yes'], { cwd: tmpDir });
2323
const wfPath = path.join(tmpDir, projName, '.github', 'workflows', 'ci.yml');
2424
expect(fs.existsSync(wfPath)).toBe(true);
2525
const content = fs.readFileSync(wfPath, 'utf-8');

tests/smoke.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('create-polyglot CLI smoke', () => {
1717
try { fs.rmSync(tmpParent, { recursive: true, force: true }); } catch {}
1818
});
1919

20-
it('scaffolds a project with a node service', async () => {
20+
it('scaffolds a project with a node service (using init subcommand)', async () => {
2121
const repoRoot = process.cwd();
2222
const cliPath = path.join(repoRoot, 'bin/index.js');
2323
await execa('node', [cliPath, 'init', projName, '--services', 'node', '--no-install', '--yes'], { cwd: tmpDir });

0 commit comments

Comments
 (0)