diff --git a/.changeset/sweet-zoos-beam.md b/.changeset/sweet-zoos-beam.md new file mode 100644 index 0000000000..e13ebcd30d --- /dev/null +++ b/.changeset/sweet-zoos-beam.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Internal update to move `info` commands to a separate module. diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index 0609db33a2..32918caad2 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -23,8 +23,8 @@ Commands: versions:migrate [options] migrate [command] build-workspace [options] [packages...] - create-github-app info + create-github-app help [command] ``` diff --git a/packages/cli/src/alpha.ts b/packages/cli/src/alpha.ts index eff1480391..d6189a4256 100644 --- a/packages/cli/src/alpha.ts +++ b/packages/cli/src/alpha.ts @@ -24,6 +24,7 @@ import chalk from 'chalk'; ), ); const initializer = new CliInitializer(); + initializer.add(import('./modules/info/alpha')); initializer.add(import('./modules/config/alpha')); initializer.add(import('./modules/build/alpha')); initializer.add(import('./modules/migrate/alpha')); diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 93c1a60b40..a48c052f20 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -25,6 +25,7 @@ import { registerRepoCommands as registerRepoBuildCommands, registerCommands as registerBuildCommands, } from '../modules/build'; +import { registerCommands as registerInfoCommands } from '../modules/info'; import { registerCommands as registerMigrateCommand } from '../modules/migrate'; import { registerRepoCommands as registerRepoTestCommands, @@ -191,17 +192,13 @@ export function registerCommands(program: Command) { registerScriptCommand(program); registerMigrateCommand(program); registerBuildCommands(program); + registerInfoCommands(program); program .command('create-github-app ') .description('Create new GitHub App in your organization.') .action(lazy(() => import('./create-github-app'), 'default')); - program - .command('info') - .description('Show helpful information for debugging and reporting bugs') - .action(lazy(() => import('./info'), 'default')); - // Notifications for removed commands program .command('create') diff --git a/packages/cli/src/modules/config/alpha.ts b/packages/cli/src/modules/config/alpha.ts index 9ce6080a4a..8e5ff8b783 100644 --- a/packages/cli/src/modules/config/alpha.ts +++ b/packages/cli/src/modules/config/alpha.ts @@ -47,7 +47,8 @@ export default createCliPlugin({ }) .help() .parse(args); - const m = await import('./commands/docs'); + const m = + (await require('./commands/docs')) as typeof import('./commands/docs'); await m.default(argv); }, }); @@ -66,7 +67,8 @@ export default createCliPlugin({ }) .help() .parse(args); - const m = await import('./commands/print'); + const m = + (await require('./commands/print')) as typeof import('./commands/print'); await m.default(argv); }, }); @@ -90,7 +92,8 @@ export default createCliPlugin({ }) .help() .parse(args); - const m = await import('./commands/validate'); + const m = + (await require('./commands/validate')) as typeof import('./commands/validate'); await m.default(argv); }, }); diff --git a/packages/cli/src/modules/info/alpha.ts b/packages/cli/src/modules/info/alpha.ts new file mode 100644 index 0000000000..1e6f761f83 --- /dev/null +++ b/packages/cli/src/modules/info/alpha.ts @@ -0,0 +1,33 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import yargs from 'yargs'; +import { createCliPlugin } from '../../wiring/factory'; + +export default createCliPlugin({ + pluginId: 'info', + init: async reg => { + reg.addCommand({ + path: ['info'], + description: 'Show helpful information for debugging and reporting bugs', + execute: async ({ args }) => { + yargs().parse(args); + const { default: command } = + require('./commands/info') as typeof import('./commands/info'); + await command(); + }, + }); + }, +}); diff --git a/packages/cli/src/commands/info.ts b/packages/cli/src/modules/info/commands/info.ts similarity index 89% rename from packages/cli/src/commands/info.ts rename to packages/cli/src/modules/info/commands/info.ts index f3740de1a9..416c995541 100644 --- a/packages/cli/src/commands/info.ts +++ b/packages/cli/src/modules/info/commands/info.ts @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Backstage Authors + * Copyright 2025 The Backstage Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ * limitations under the License. */ -import { version as cliVersion } from '../../package.json'; +import { version as cliVersion } from '../../../../package.json'; import os from 'os'; -import { runPlain } from '../lib/run'; -import { paths } from '../lib/paths'; -import { Lockfile } from '../lib/versioning'; +import { runPlain } from '../../../lib/run'; +import { paths } from '../../../lib/paths'; +import { Lockfile } from '../../../lib/versioning'; import fs from 'fs-extra'; export default async () => { diff --git a/packages/cli/src/modules/info/index.ts b/packages/cli/src/modules/info/index.ts new file mode 100644 index 0000000000..af43af652c --- /dev/null +++ b/packages/cli/src/modules/info/index.ts @@ -0,0 +1,25 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { lazy } from '../../lib/lazy'; +import { Command } from 'commander'; + +export function registerCommands(program: Command) { + program + .command('info') + .description('Show helpful information for debugging and reporting bugs') + .action(lazy(() => import('./commands/info'), 'default')); +}