diff --git a/docs/tooling/cli/03-commands.md b/docs/tooling/cli/03-commands.md index 6ca63da44e..d176278655 100644 --- a/docs/tooling/cli/03-commands.md +++ b/docs/tooling/cli/03-commands.md @@ -78,12 +78,12 @@ Any `--config` options in the `start` script in `package.json` of the selected p Any `--require` option in the `start` script in `package.json` of the selected backend package will be picked up and used. ```text -Usage: backstage-cli repo start [options] [packageName...] +Usage: backstage-cli repo start [options] [packageNameOrPath...] Starts packages in the repo for local development Arguments: - packageName Run the specified package instead of the defaults. + packageNameOrPath Run the specified packages instead of the defaults. Options: --plugin Start the dev entry-point for any matching plugin package in the repo (default: []) diff --git a/packages/cli/cli-report.backstage-cli.md b/packages/cli/cli-report.backstage-cli.md index 3747d6acc4..ed6ae9049e 100644 --- a/packages/cli/cli-report.backstage-cli.md +++ b/packages/cli/cli-report.backstage-cli.md @@ -400,13 +400,13 @@ Options: -h, --help Commands: - start [options] [packageName...] build [options] clean fix [options] help [command] lint [options] list-deprecations [options] + start [options] [packageNameOrPath...] test [options] ``` @@ -471,15 +471,15 @@ Options: ### `backstage-cli repo start` ``` -Usage: backstage-cli repo start [options] [packageName...] +Usage: backstage-cli repo start [options] [packageNameOrPath...] Options: - --plugin --config --inspect [host] --inspect-brk [host] - --require --link + --plugin + --require -h, --help ``` diff --git a/packages/cli/src/modules/start/alpha.ts b/packages/cli/src/modules/start/alpha.ts index 0d2b6f661e..a5875df335 100644 --- a/packages/cli/src/modules/start/alpha.ts +++ b/packages/cli/src/modules/start/alpha.ts @@ -62,7 +62,7 @@ export const startPlugin = createCliPlugin({ const defaultCommand = command .argument( - '[...packageName]', + '[...packageNameOrPath]', 'Run the specified package instead of the defaults.', ) .option( diff --git a/packages/cli/src/modules/start/commands/repo/start.ts b/packages/cli/src/modules/start/commands/repo/start.ts index 7a4704ea3e..b25054bbfc 100644 --- a/packages/cli/src/modules/start/commands/repo/start.ts +++ b/packages/cli/src/modules/start/commands/repo/start.ts @@ -41,8 +41,8 @@ type CommandOptions = { link?: string; }; -export async function command(packageNames: string[], options: CommandOptions) { - const targetPackages = await findTargetPackages(packageNames, options.plugin); +export async function command(namesOrPaths: string[], options: CommandOptions) { + const targetPackages = await findTargetPackages(namesOrPaths, options.plugin); const packageOptions = await resolvePackageOptions(targetPackages, options); @@ -61,7 +61,7 @@ export async function command(packageNames: string[], options: CommandOptions) { await Promise.all(packageOptions.map(entry => startPackage(entry.options))); } -async function findTargetPackages(packageNames: string[], pluginIds: string[]) { +async function findTargetPackages(namesOrPaths: string[], pluginIds: string[]) { const targetPackages = new Array(); const packages = await PackageGraph.listTargetPackages(); @@ -87,12 +87,18 @@ async function findTargetPackages(packageNames: string[], pluginIds: string[]) { } // Next check if explicit package names are provided, use them in that case. - for (const packageName of packageNames) { - const matchingPackage = packages.find(pkg => { - return packageName === pkg.packageJson.name; - }); + for (const nameOrPath of namesOrPaths) { + let matchingPackage = packages.find( + pkg => nameOrPath === pkg.packageJson.name, + ); if (!matchingPackage) { - throw new Error(`Unable to find package by name '${packageName}'`); + const absPath = paths.resolveTargetRoot(nameOrPath); + matchingPackage = packages.find( + pkg => relativePath(pkg.dir, absPath) === '', + ); + } + if (!matchingPackage) { + throw new Error(`Unable to find package by name '${nameOrPath}'`); } targetPackages.push(matchingPackage); } diff --git a/packages/cli/src/modules/start/index.ts b/packages/cli/src/modules/start/index.ts index f1dd1eeb71..17225820f7 100644 --- a/packages/cli/src/modules/start/index.ts +++ b/packages/cli/src/modules/start/index.ts @@ -22,7 +22,7 @@ export function registerRepoCommands(command: Command) { .command('start') .description('Starts packages in the repo for local development') .argument( - '[packageName...]', + '[packageNameOrPath...]', 'Run the specified package instead of the defaults.', ) .option(