From 703314d1a53c5515f960ce43bfb2a0cac0bcfff2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 23 Jan 2022 14:28:13 +0100 Subject: [PATCH] cli: move new commands into experimental sub-commands Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/index.ts | 72 ++++++++++--------- .../src/commands/migrate/packageScripts.ts | 4 +- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index ef2e5ef96a..caeee1557c 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -133,34 +133,6 @@ export function registerCommands(program: CommanderStatic) { .option('--experimental-type-build', 'Enable experimental type build') .action(lazy(() => import('./build').then(m => m.default))); - program - .command('bundle') - .description('Bundle a package for deployment') - .option(...configOption) - .option('--role ', 'Run the command with an explicit package role') - .option( - '--skip-build-dependencies', - 'Skip the automatic building of local dependencies', - ) - .option( - '--stats', - 'If bundle stats are available, write them to the output directory', - ) - .action(lazy(() => import('./bundle').then(m => m.command))); - - program - .command('start') - .description('Start a package for local development') - .option(...configOption) - .option('--role ', 'Run the command with an explicit package role') - .option('--check', 'Enable type checking and linting if available') - .option('--inspect', 'Enable debugger in Node.js environments') - .option( - '--inspect-brk', - 'Enable debugger in Node.js environments, breaking before code starts', - ) - .action(lazy(() => import('./start').then(m => m.command))); - program .command('lint') .option( @@ -233,13 +205,49 @@ export function registerCommands(program: CommanderStatic) { .description('Print configuration schema') .action(lazy(() => import('./config/schema').then(m => m.default))); - program - .command('migrate:package-role') + const script = program + .command('script [command]', { hidden: true }) + .description('Lifecycle scripts for Backstage packages [EXPERIMENTAL]'); + + script + .command('bundle') + .description('Bundle a package for deployment') + .option(...configOption) + .option('--role ', 'Run the command with an explicit package role') + .option( + '--skip-build-dependencies', + 'Skip the automatic building of local dependencies', + ) + .option( + '--stats', + 'If bundle stats are available, write them to the output directory', + ) + .action(lazy(() => import('./bundle').then(m => m.command))); + + script + .command('start') + .description('Start a package for local development') + .option(...configOption) + .option('--role ', 'Run the command with an explicit package role') + .option('--check', 'Enable type checking and linting if available') + .option('--inspect', 'Enable debugger in Node.js environments') + .option( + '--inspect-brk', + 'Enable debugger in Node.js environments, breaking before code starts', + ) + .action(lazy(() => import('./start').then(m => m.command))); + + const migrate = program + .command('migrate [command]', { hidden: true }) + .description('Migration utilities [EXPERIMENTAL]'); + + migrate + .command('package-role') .description(`Add package role field to packages that don't have it`) .action(lazy(() => import('./migrate/packageRole').then(m => m.default))); - program - .command('migrate:package-scripts') + migrate + .command('package-scripts') .description('Set package scripts according to each package role') .action( lazy(() => import('./migrate/packageScripts').then(m => m.command)), diff --git a/packages/cli/src/commands/migrate/packageScripts.ts b/packages/cli/src/commands/migrate/packageScripts.ts index 58a8481c81..ada358b56b 100644 --- a/packages/cli/src/commands/migrate/packageScripts.ts +++ b/packages/cli/src/commands/migrate/packageScripts.ts @@ -36,9 +36,9 @@ export async function command() { const isBundled = bundledRoles.includes(roleInfo.role); const expectedScripts = { - ...(hasStart && { start: 'backstage-cli start' }), + ...(hasStart && { start: 'backstage-cli script start' }), ...(isBundled - ? { bundle: 'backstage-cli bundle' } + ? { bundle: 'backstage-cli script bundle' } : { build: 'backstage-cli build' }), lint: 'backstage-cli lint', test: 'backstage-cli test',