UNPKG

@speedy-js/mono

Version:

Monorepo development & continuous integration tooling.

75 lines 2.9 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.bootstrapCli = void 0; /** * Module dependencies */ const cac_1 = __importDefault(require("cac")); const chalk_1 = __importDefault(require("chalk")); const index_1 = require("./index"); async function wrapCommand(command, cliFlags) { cliFlags.cwd = cliFlags.cwd || process.cwd(); try { await command(cliFlags); } catch (e) { // console.log(e); console.log(); process.exitCode = 1; console.log(chalk_1.default.red(e.message)); console.log(); } } /** * Bootstrap mono cli. */ function bootstrapCli() { const cli = (0, cac_1.default)(); const pkg = require("../package.json"); cli.option("--cwd <cwd>", "Current working directory."); cli .command("d", `Quickly launch on-demand development build for monorepo.`) .alias("dev") .action((opts) => { return wrapCommand(index_1.dev, opts); }); cli .command("r", `Release your monorepo.`) .option("--changelog", "Whether to generate changelog.") .option("--runInBand", "Whether to publish package in series.") .option("--build [build]", "Execute custom build script before release.") .option("--ignore-scripts", "Ignore npm scripts under release and patch process.") .alias("release") .action((opts) => { return wrapCommand(index_1.release, opts); }); cli .command("p", `Patch the failure of lerna release.`) .option("--version <version>", "Version (e.g. 1.0.0, 2.0.0-alpha.9)") .option("--tag <tag>", "Tag (e.g. latest、next、beta)") .option("--runInBand", "Whether to publish package in series.") .option("--ignore-scripts", "Ignore npm scripts under patch process.") .alias("patch") .action((opts) => { return wrapCommand(index_1.patch, opts); }); cli .command("changelog", "Create changelog") .option("--version <version>", 'Version (e.g. 1.0.0, 2.0.0-alpha.9), defaults to version in "lerna.json"') .option("--beautify", "beautify changelog or not, defaults to false") .option("--commit", "create git commit or not, defaults to false") .option("--gitPush", "execute git push or not, defaults to false") .option("--attachAuthor", "add author or not, defaults to false") .option("--authorNameType", "type of author name, available options: `name`, `email`, defaults to `name`") .action((opts) => { return wrapCommand(index_1.changelog, opts); }); cli.version(pkg.version); cli.help(); cli.parse(); } exports.bootstrapCli = bootstrapCli; //# sourceMappingURL=cli.js.map