diff --git a/.changeset/move-clean-pack-to-build.md b/.changeset/move-clean-pack-to-build.md new file mode 100644 index 0000000000..40db4df15a --- /dev/null +++ b/.changeset/move-clean-pack-to-build.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Moved the `clean` and `pack` commands from the internal maintenance module to the build module. diff --git a/packages/cli/src/modules/maintenance/commands/package/clean.ts b/packages/cli/src/modules/build/commands/package/clean.ts similarity index 100% rename from packages/cli/src/modules/maintenance/commands/package/clean.ts rename to packages/cli/src/modules/build/commands/package/clean.ts diff --git a/packages/cli/src/modules/maintenance/commands/package/pack.ts b/packages/cli/src/modules/build/commands/package/pack.ts similarity index 95% rename from packages/cli/src/modules/maintenance/commands/package/pack.ts rename to packages/cli/src/modules/build/commands/package/pack.ts index e5e176d17e..737b4b6931 100644 --- a/packages/cli/src/modules/maintenance/commands/package/pack.ts +++ b/packages/cli/src/modules/build/commands/package/pack.ts @@ -17,7 +17,7 @@ import { productionPack, revertProductionPack, -} from '../../../../modules/build/lib/packager/productionPack'; +} from '../../lib/packager/productionPack'; import { targetPaths } from '@backstage/cli-common'; import fs from 'fs-extra'; diff --git a/packages/cli/src/modules/maintenance/commands/repo/clean.ts b/packages/cli/src/modules/build/commands/repo/clean.ts similarity index 100% rename from packages/cli/src/modules/maintenance/commands/repo/clean.ts rename to packages/cli/src/modules/build/commands/repo/clean.ts diff --git a/packages/cli/src/modules/build/index.ts b/packages/cli/src/modules/build/index.ts index 9b37efaa8b..8b9f26dbcd 100644 --- a/packages/cli/src/modules/build/index.ts +++ b/packages/cli/src/modules/build/index.ts @@ -197,6 +197,58 @@ export const buildPlugin = createCliPlugin({ }, }); + reg.addCommand({ + path: ['package', 'clean'], + description: 'Delete cache directories', + execute: async ({ args }) => { + const command = new Command(); + const defaultCommand = command.action( + lazy(() => import('./commands/package/clean'), 'default'), + ); + + await defaultCommand.parseAsync(args, { from: 'user' }); + }, + }); + + reg.addCommand({ + path: ['package', 'prepack'], + description: 'Prepares a package for packaging before publishing', + execute: async ({ args }) => { + const command = new Command(); + const defaultCommand = command.action( + lazy(() => import('./commands/package/pack'), 'pre'), + ); + + await defaultCommand.parseAsync(args, { from: 'user' }); + }, + }); + + reg.addCommand({ + path: ['package', 'postpack'], + description: 'Restores the changes made by the prepack command', + execute: async ({ args }) => { + const command = new Command(); + const defaultCommand = command.action( + lazy(() => import('./commands/package/pack'), 'post'), + ); + + await defaultCommand.parseAsync(args, { from: 'user' }); + }, + }); + + reg.addCommand({ + path: ['repo', 'clean'], + description: 'Delete cache and output directories', + execute: async ({ args }) => { + const command = new Command(); + const defaultCommand = command.action( + lazy(() => import('./commands/repo/clean'), 'command'), + ); + + await defaultCommand.parseAsync(args, { from: 'user' }); + }, + }); + reg.addCommand({ path: ['build-workspace'], description: diff --git a/packages/cli/src/modules/maintenance/lib/publishing.ts b/packages/cli/src/modules/build/lib/publishing.ts similarity index 100% rename from packages/cli/src/modules/maintenance/lib/publishing.ts rename to packages/cli/src/modules/build/lib/publishing.ts diff --git a/packages/cli/src/modules/maintenance/commands/repo/fix.ts b/packages/cli/src/modules/maintenance/commands/repo/fix.ts index 073cb69ea1..cb745b9b48 100644 --- a/packages/cli/src/modules/maintenance/commands/repo/fix.ts +++ b/packages/cli/src/modules/maintenance/commands/repo/fix.ts @@ -31,7 +31,7 @@ import { } from 'node:path'; import { targetPaths } from '@backstage/cli-common'; -import { publishPreflightCheck } from '../../lib/publishing'; +import { publishPreflightCheck } from '../../../build/lib/publishing'; const SCRIPT_EXTS = ['.js', '.jsx', '.ts', '.tsx', '.json']; diff --git a/packages/cli/src/modules/maintenance/index.ts b/packages/cli/src/modules/maintenance/index.ts index 41192afdc4..93e64df3a1 100644 --- a/packages/cli/src/modules/maintenance/index.ts +++ b/packages/cli/src/modules/maintenance/index.ts @@ -20,45 +20,6 @@ import { lazy } from '../../lib/lazy'; export default createCliPlugin({ pluginId: 'maintenance', init: async reg => { - reg.addCommand({ - path: ['package', 'clean'], - description: 'Delete cache directories', - execute: async ({ args }) => { - const command = new Command(); - const defaultCommand = command.action( - lazy(() => import('./commands/package/clean'), 'default'), - ); - - await defaultCommand.parseAsync(args, { from: 'user' }); - }, - }); - - reg.addCommand({ - path: ['package', 'prepack'], - description: 'Prepares a package for packaging before publishing', - execute: async ({ args }) => { - const command = new Command(); - const defaultCommand = command.action( - lazy(() => import('./commands/package/pack'), 'pre'), - ); - - await defaultCommand.parseAsync(args, { from: 'user' }); - }, - }); - - reg.addCommand({ - path: ['package', 'postpack'], - description: 'Restores the changes made by the prepack command', - execute: async ({ args }) => { - const command = new Command(); - const defaultCommand = command.action( - lazy(() => import('./commands/package/pack'), 'post'), - ); - - await defaultCommand.parseAsync(args, { from: 'user' }); - }, - }); - reg.addCommand({ path: ['repo', 'fix'], description: 'Automatically fix packages in the project', @@ -79,19 +40,6 @@ export default createCliPlugin({ }, }); - reg.addCommand({ - path: ['repo', 'clean'], - description: 'Delete cache and output directories', - execute: async ({ args }) => { - const command = new Command(); - const defaultCommand = command.action( - lazy(() => import('./commands/repo/clean'), 'command'), - ); - - await defaultCommand.parseAsync(args, { from: 'user' }); - }, - }); - reg.addCommand({ path: ['repo', 'list-deprecations'], description: 'List deprecations',