@backstage/cli
Version:
CLI for developing Backstage plugins and apps
151 lines (146 loc) • 6.64 kB
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var commander = require('commander');
var factory = require('../../wiring/factory.cjs.js');
var lazy = require('../../lib/lazy.cjs.js');
var index = require('../config/index.cjs.js');
function registerPackageCommands(command) {
command.command("build").description("Build a package for production deployment or publishing").option("--role <name>", "Run the command with an explicit package role").option(
"--minify",
"Minify the generated code. Does not apply to app package (app is minified by default)."
).option(
"--skip-build-dependencies",
"Skip the automatic building of local dependencies. Applies to backend packages only."
).option(
"--stats",
"If bundle stats are available, write them to the output directory. Applies to app packages only."
).option(
"--config <path>",
"Config files to load instead of app-config.yaml. Applies to app packages only.",
(opt, opts) => opts ? [...opts, opt] : [opt],
Array()
).action(lazy.lazy(() => import('./commands/package/build/index.cjs.js'), "command"));
}
const buildPlugin = factory.createCliPlugin({
pluginId: "build",
init: async (reg) => {
reg.addCommand({
path: ["package", "build"],
description: "Build a package for production deployment or publishing",
execute: async ({ args }) => {
const command = new commander.Command();
const defaultCommand = command.option(
"--role <name>",
"Run the command with an explicit package role"
).option(
"--minify",
"Minify the generated code. Does not apply to app package (app is minified by default)."
).option(
"--skip-build-dependencies",
"Skip the automatic building of local dependencies. Applies to backend packages only."
).option(
"--stats",
"If bundle stats are available, write them to the output directory. Applies to app packages only."
).option(
"--config <path>",
"Config files to load instead of app-config.yaml. Applies to app packages only.",
(opt, opts) => opts ? [...opts, opt] : [opt],
Array()
).action(lazy.lazy(() => import('./commands/package/build/index.cjs.js'), "command"));
await defaultCommand.parseAsync(args, { from: "user" });
}
});
reg.addCommand({
path: ["repo", "build"],
description: "Build packages in the project, excluding bundled app and backend packages.",
execute: async ({ args }) => {
const command = new commander.Command();
registerPackageCommands(command.command("package"));
const defaultCommand = command.option(
"--all",
"Build all packages, including bundled app and backend packages."
).option(
"--since <ref>",
"Only build packages and their dev dependents that changed since the specified ref"
).option(
"--minify",
"Minify the generated code. Does not apply to app package (app is minified by default)."
).action(lazy.lazy(() => import('./commands/repo/build.cjs.js'), "command"));
await defaultCommand.parseAsync(args, { from: "user" });
}
});
reg.addCommand({
path: ["package", "start"],
description: "Start a package for local development",
execute: async ({ args }) => {
const command = new commander.Command();
const defaultCommand = command.option(...index.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.lazy(() => import('./commands/package/start/index.cjs.js'), "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 commander.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, opts) => opts ? [...opts, opt] : [opt],
Array()
).option(...index.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.lazy(() => import('./commands/repo/start.cjs.js'), "command")
);
await defaultCommand.parseAsync(args, { from: "user" });
}
});
reg.addCommand({
path: ["build-workspace"],
description: "Builds a temporary dist workspace from the provided packages",
execute: async ({ args }) => {
const command = new commander.Command();
const defaultCommand = command.arguments("<workspace-dir> [packages...]").addOption(
new commander.Option(
"--alwaysYarnPack",
"Alias for --alwaysPack for backwards compatibility."
).implies({ alwaysPack: true }).hideHelp(true)
).option(
"--alwaysPack",
"Force workspace output to be a result of running `yarn pack` on each package (warning: very slow)"
).action(lazy.lazy(() => import('./commands/buildWorkspace.cjs.js'), "default"));
await defaultCommand.parseAsync(args, { from: "user" });
}
});
}
});
exports.buildPlugin = buildPlugin;
exports.default = buildPlugin;
exports.registerPackageCommands = registerPackageCommands;
//# sourceMappingURL=index.cjs.js.map
;