cli: combine build and start modules
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Internal refactor to combine alpha `build` and `start` modules.
|
||||
@@ -33,7 +33,6 @@ import chalk from 'chalk';
|
||||
initializer.add(import('./modules/maintenance/alpha'));
|
||||
initializer.add(import('./modules/migrate/alpha'));
|
||||
initializer.add(import('./modules/new/alpha'));
|
||||
initializer.add(import('./modules/start/alpha'));
|
||||
initializer.add(import('./modules/test/alpha'));
|
||||
await initializer.run();
|
||||
})();
|
||||
|
||||
@@ -21,10 +21,6 @@ import {
|
||||
registerRepoCommands as registerRepoBuildCommands,
|
||||
registerCommands as registerBuildCommands,
|
||||
} from '../modules/build';
|
||||
import {
|
||||
registerPackageCommands as registerPackageStartCommands,
|
||||
registerRepoCommands as registerRepoStartCommands,
|
||||
} from '../modules/start';
|
||||
import { registerCommands as registerInfoCommands } from '../modules/info';
|
||||
import { registerCommands as registerMigrateCommand } from '../modules/migrate';
|
||||
import {
|
||||
@@ -48,7 +44,6 @@ export function registerRepoCommand(program: Command) {
|
||||
.command('repo [command]')
|
||||
.description('Command that run across an entire Backstage project');
|
||||
|
||||
registerRepoStartCommands(command);
|
||||
registerRepoBuildCommands(command);
|
||||
registerRepoTestCommands(command);
|
||||
registerRepoLintCommands(command);
|
||||
@@ -60,7 +55,6 @@ export function registerScriptCommand(program: Command) {
|
||||
.command('package [command]')
|
||||
.description('Lifecycle scripts for individual packages');
|
||||
|
||||
registerPackageStartCommands(command);
|
||||
registerPackageBuildCommands(command);
|
||||
registerPackageTestCommands(command);
|
||||
registerMaintenancePackageCommands(command);
|
||||
|
||||
@@ -18,6 +18,7 @@ import { Command, Option } from 'commander';
|
||||
import { createCliPlugin } from '../../wiring/factory';
|
||||
import { lazy } from '../../lib/lazy';
|
||||
import { registerPackageCommands } from '.';
|
||||
import { configOption } from '../config';
|
||||
|
||||
export const buildPlugin = createCliPlugin({
|
||||
pluginId: 'build',
|
||||
@@ -85,6 +86,80 @@ export const buildPlugin = createCliPlugin({
|
||||
},
|
||||
});
|
||||
|
||||
reg.addCommand({
|
||||
path: ['package', 'start'],
|
||||
description: 'Start a package for local development',
|
||||
execute: async ({ args }) => {
|
||||
const command = new Command();
|
||||
|
||||
const defaultCommand = command
|
||||
.option(...configOption)
|
||||
.option(
|
||||
'--role <name>',
|
||||
'Run the command with an explicit package role',
|
||||
)
|
||||
.option('--check', 'Enable type checking and linting if available')
|
||||
.option('--inspect [host]', 'Enable debugger in Node.js environments')
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process',
|
||||
)
|
||||
.option(
|
||||
'--link <path>',
|
||||
'Link an external workspace for module resolution',
|
||||
)
|
||||
.action(lazy(() => import('./commands/package/start'), 'command'));
|
||||
|
||||
await defaultCommand.parseAsync(args, { from: 'user' });
|
||||
},
|
||||
});
|
||||
|
||||
reg.addCommand({
|
||||
path: ['repo', 'start'],
|
||||
description: 'Starts packages in the repo for local development',
|
||||
execute: async ({ args }) => {
|
||||
const command = new Command();
|
||||
|
||||
const defaultCommand = command
|
||||
.argument(
|
||||
'[...packageNameOrPath]',
|
||||
'Run the specified package instead of the defaults.',
|
||||
)
|
||||
.option(
|
||||
'--plugin <pluginId>',
|
||||
'Start the dev entry-point for any matching plugin package in the repo',
|
||||
(opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]),
|
||||
Array<string>(),
|
||||
)
|
||||
.option(...configOption)
|
||||
.option(
|
||||
'--inspect [host]',
|
||||
'Enable debugger in Node.js environments. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--link <path>',
|
||||
'Link an external workspace for module resolution',
|
||||
)
|
||||
.action(
|
||||
lazy(() => import('../build/commands/repo/start'), 'command'),
|
||||
);
|
||||
|
||||
await defaultCommand.parseAsync(args, { from: 'user' });
|
||||
},
|
||||
});
|
||||
|
||||
reg.addCommand({
|
||||
path: ['build-workspace'],
|
||||
description:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
import { Command, Option } from 'commander';
|
||||
import { lazy } from '../../lib/lazy';
|
||||
import { configOption } from '../config';
|
||||
|
||||
export function registerRepoCommands(command: Command) {
|
||||
command
|
||||
@@ -35,6 +36,35 @@ export function registerRepoCommands(command: Command) {
|
||||
'Minify the generated code. Does not apply to app package (app is minified by default).',
|
||||
)
|
||||
.action(lazy(() => import('./commands/repo/build'), 'command'));
|
||||
|
||||
command
|
||||
.command('start')
|
||||
.description('Starts packages in the repo for local development')
|
||||
.argument(
|
||||
'[packageNameOrPath...]',
|
||||
'Run the specified package instead of the defaults.',
|
||||
)
|
||||
.option(
|
||||
'--plugin <pluginId>',
|
||||
'Start the dev entry-point for any matching plugin package in the repo',
|
||||
(opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]),
|
||||
Array<string>(),
|
||||
)
|
||||
.option(...configOption)
|
||||
.option(
|
||||
'--inspect [host]',
|
||||
'Enable debugger in Node.js environments. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process. Applies to backend package only',
|
||||
)
|
||||
.option('--link <path>', 'Link an external workspace for module resolution')
|
||||
.action(lazy(() => import('../build/commands/repo/start'), 'command'));
|
||||
}
|
||||
|
||||
export function registerPackageCommands(command: Command) {
|
||||
@@ -61,6 +91,24 @@ export function registerPackageCommands(command: Command) {
|
||||
Array<string>(),
|
||||
)
|
||||
.action(lazy(() => import('./commands/package/build'), 'command'));
|
||||
|
||||
command
|
||||
.command('start')
|
||||
.description('Start a package for local development')
|
||||
.option(...configOption)
|
||||
.option('--role <name>', 'Run the command with an explicit package role')
|
||||
.option('--check', 'Enable type checking and linting if available')
|
||||
.option('--inspect [host]', 'Enable debugger in Node.js environments')
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process',
|
||||
)
|
||||
.option('--link <path>', 'Link an external workspace for module resolution')
|
||||
.action(lazy(() => import('./commands/package/start'), 'command'));
|
||||
}
|
||||
|
||||
export function registerCommands(program: Command) {
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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 { Command } from 'commander';
|
||||
import { createCliPlugin } from '../../wiring/factory';
|
||||
import { lazy } from '../../lib/lazy';
|
||||
import { configOption } from '../config';
|
||||
|
||||
export const startPlugin = createCliPlugin({
|
||||
pluginId: 'start',
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
path: ['package', 'start'],
|
||||
description: 'Start a package for local development',
|
||||
execute: async ({ args }) => {
|
||||
const command = new Command();
|
||||
|
||||
const defaultCommand = command
|
||||
.option(...configOption)
|
||||
.option(
|
||||
'--role <name>',
|
||||
'Run the command with an explicit package role',
|
||||
)
|
||||
.option('--check', 'Enable type checking and linting if available')
|
||||
.option('--inspect [host]', 'Enable debugger in Node.js environments')
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process',
|
||||
)
|
||||
.option(
|
||||
'--link <path>',
|
||||
'Link an external workspace for module resolution',
|
||||
)
|
||||
.action(lazy(() => import('./commands/package/start'), 'command'));
|
||||
|
||||
await defaultCommand.parseAsync(args, { from: 'user' });
|
||||
},
|
||||
});
|
||||
|
||||
reg.addCommand({
|
||||
path: ['repo', 'start'],
|
||||
description: 'Starts packages in the repo for local development',
|
||||
execute: async ({ args }) => {
|
||||
const command = new Command();
|
||||
|
||||
const defaultCommand = command
|
||||
.argument(
|
||||
'[...packageNameOrPath]',
|
||||
'Run the specified package instead of the defaults.',
|
||||
)
|
||||
.option(
|
||||
'--plugin <pluginId>',
|
||||
'Start the dev entry-point for any matching plugin package in the repo',
|
||||
(opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]),
|
||||
Array<string>(),
|
||||
)
|
||||
.option(...configOption)
|
||||
.option(
|
||||
'--inspect [host]',
|
||||
'Enable debugger in Node.js environments. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--link <path>',
|
||||
'Link an external workspace for module resolution',
|
||||
)
|
||||
.action(lazy(() => import('./commands/repo/start'), 'command'));
|
||||
|
||||
await defaultCommand.parseAsync(args, { from: 'user' });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default startPlugin;
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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 { Command } from 'commander';
|
||||
import { lazy } from '../../lib/lazy';
|
||||
import { configOption } from '../config';
|
||||
|
||||
export function registerRepoCommands(command: Command) {
|
||||
command
|
||||
.command('start')
|
||||
.description('Starts packages in the repo for local development')
|
||||
.argument(
|
||||
'[packageNameOrPath...]',
|
||||
'Run the specified package instead of the defaults.',
|
||||
)
|
||||
.option(
|
||||
'--plugin <pluginId>',
|
||||
'Start the dev entry-point for any matching plugin package in the repo',
|
||||
(opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]),
|
||||
Array<string>(),
|
||||
)
|
||||
.option(...configOption)
|
||||
.option(
|
||||
'--inspect [host]',
|
||||
'Enable debugger in Node.js environments. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts. Applies to backend package only',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process. Applies to backend package only',
|
||||
)
|
||||
.option('--link <path>', 'Link an external workspace for module resolution')
|
||||
.action(lazy(() => import('./commands/repo/start'), 'command'));
|
||||
}
|
||||
|
||||
export function registerPackageCommands(command: Command) {
|
||||
command
|
||||
.command('start')
|
||||
.description('Start a package for local development')
|
||||
.option(...configOption)
|
||||
.option('--role <name>', 'Run the command with an explicit package role')
|
||||
.option('--check', 'Enable type checking and linting if available')
|
||||
.option('--inspect [host]', 'Enable debugger in Node.js environments')
|
||||
.option(
|
||||
'--inspect-brk [host]',
|
||||
'Enable debugger in Node.js environments, breaking before code starts',
|
||||
)
|
||||
.option(
|
||||
'--require <path...>',
|
||||
'Add a --require argument to the node process',
|
||||
)
|
||||
.option('--link <path>', 'Link an external workspace for module resolution')
|
||||
.action(lazy(() => import('./commands/package/start'), 'command'));
|
||||
}
|
||||
Reference in New Issue
Block a user