1 | "use strict";
|
2 |
|
3 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
5 | };
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | const path_1 = __importDefault(require("path"));
|
8 | const chalk_1 = __importDefault(require("chalk"));
|
9 | const yargs_1 = __importDefault(require("yargs"));
|
10 | const core_1 = __importDefault(require("@beemo/core"));
|
11 | const checkVersion_1 = __importDefault(require("./checkVersion"));
|
12 | const parseSpecialArgv_1 = __importDefault(require("./parseSpecialArgv"));
|
13 |
|
14 | const { main, parallel } = parseSpecialArgv_1.default(process.argv.slice(2));
|
15 |
|
16 | const binName = path_1.default.basename(process.argv[1]);
|
17 | const beemo = new core_1.default(main.slice(1), binName);
|
18 | const { tool } = beemo;
|
19 | const app = yargs_1.default(main);
|
20 | const manualURL = process.env.BEEMO_MANUAL_URL || 'https://milesj.gitbook.io/beemo';
|
21 |
|
22 | beemo.bootstrapConfigModule();
|
23 |
|
24 | beemo.bootstrapCLI(app);
|
25 |
|
26 | tool.getPlugins('driver').forEach(driver => {
|
27 | const { command, metadata } = driver;
|
28 | app.command(driver.name, metadata.description || tool.msg('app:run', { title: metadata.title }), Object.assign({}, command, { concurrency: {
|
29 | description: tool.msg('app:cliOptionConcurrency'),
|
30 | number: true,
|
31 | }, live: {
|
32 | boolean: true,
|
33 | default: false,
|
34 | description: tool.msg('app:cliOptionLive'),
|
35 | }, priority: {
|
36 | boolean: true,
|
37 | description: tool.msg('app:cliOptionPriority'),
|
38 | }, workspaces: {
|
39 | description: tool.msg('app:cliOptionWorkspaces'),
|
40 | string: true,
|
41 | } }), (args) => beemo.executeDriver(args, driver.name, parallel));
|
42 | });
|
43 |
|
44 | app.command(['create-config [names..]', 'config [names..]'], tool.msg('app:cliCommandConfig'), {}, (args) => beemo.createConfigFiles(args, args.names));
|
45 | app.command(['run-script <name>', 'run <name>'], tool.msg('app:cliCommandRunScript'), {
|
46 | concurrency: {
|
47 | description: tool.msg('app:cliOptionConcurrency'),
|
48 | number: true,
|
49 | },
|
50 | priority: {
|
51 | boolean: false,
|
52 | description: tool.msg('app:cliOptionPriority'),
|
53 | },
|
54 | workspaces: {
|
55 | description: tool.msg('app:cliOptionWorkspaces'),
|
56 | string: true,
|
57 | },
|
58 | }, (args) => beemo.executeScript(args, args.name));
|
59 | app.command('scaffold <generator> <action>', tool.msg('app:cliCommandScaffold'), {
|
60 | dry: {
|
61 | boolean: true,
|
62 | default: false,
|
63 | description: tool.msg('app:cliOptionDryRun'),
|
64 | },
|
65 | }, (args) => beemo.scaffold(args, args.generator, args.action));
|
66 | app.command('*', false, {}, () => {
|
67 | console.error(chalk_1.default.red(tool.msg('errors:cliNoCommand')));
|
68 | });
|
69 |
|
70 |
|
71 | app
|
72 | .usage(`${binName} <command> [args..]`)
|
73 | .epilogue(
|
74 |
|
75 | chalk_1.default.gray([
|
76 | tool.msg('app:cliEpilogue', { manualURL }),
|
77 | tool.msg('app:poweredBy', { version: checkVersion_1.default })
|
78 | ].join('\n')))
|
79 | .demandCommand(1, chalk_1.default.red(tool.msg('errors:cliNoCommand')))
|
80 | .showHelpOnFail(true)
|
81 | .help().argv;
|