UNPKG

3.83 kBJavaScriptView Raw
1"use strict";
2/**
3 * @copyright 2017, Miles Johnson
4 * @license https://opensource.org/licenses/MIT
5 */
6var __assign = (this && this.__assign) || function () {
7 __assign = Object.assign || function(t) {
8 for (var s, i = 1, n = arguments.length; i < n; i++) {
9 s = arguments[i];
10 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11 t[p] = s[p];
12 }
13 return t;
14 };
15 return __assign.apply(this, arguments);
16};
17var __importDefault = (this && this.__importDefault) || function (mod) {
18 return (mod && mod.__esModule) ? mod : { "default": mod };
19};
20Object.defineProperty(exports, "__esModule", { value: true });
21/* eslint-disable no-console */
22var path_1 = __importDefault(require("path"));
23var chalk_1 = __importDefault(require("chalk"));
24var yargs_1 = __importDefault(require("yargs"));
25var core_1 = __importDefault(require("@beemo/core"));
26var checkVersion_1 = __importDefault(require("./checkVersion"));
27var quoteSpecialOptions_1 = __importDefault(require("./quoteSpecialOptions"));
28// 0 node, 1 beemo, 2 <driver, command>
29var argv = quoteSpecialOptions_1.default(process.argv.slice(2));
30// Initialize
31var binName = path_1.default.basename(process.argv[1]);
32var beemo = new core_1.default(argv.slice(1), binName);
33var app = yargs_1.default(argv);
34var manualURL = process.env.BEEMO_MANUAL_URL || 'https://milesj.gitbook.io/beemo';
35// Bootstrap the module
36beemo.bootstrapConfigModule();
37// Add a command for each driver
38beemo.tool.plugins.forEach(function (driver) {
39 var _a = driver, _b = _a.command, command = _b === void 0 ? {} : _b, metadata = _a.metadata;
40 app.command(driver.name, metadata.description || "Run " + metadata.title, __assign({}, command, { concurrency: {
41 description: 'Number of builds to run in parallel',
42 number: true,
43 }, parallel: {
44 array: true,
45 default: [],
46 description: 'Run parallel builds with additional flags or options',
47 }, priority: {
48 boolean: true,
49 default: false,
50 description: 'Prioritize workspace builds based on dependency graph',
51 }, workspaces: {
52 default: '',
53 description: 'Run command in each workspace (supports regex)',
54 string: true,
55 } }), function (args) { return beemo.executeDriver(driver.name, args); });
56});
57// Add Beemo commands
58app.command(['run-script <name>', 'run <name>'], 'Run custom script from configuration module', {}, function (args) { return beemo.executeScript(args.name, args); });
59app.command(['sync-dotfiles', 'sync'], 'Sync dotfiles from configuration module', {
60 filter: {
61 alias: 'f',
62 default: '',
63 description: 'Filter filenames (supports regex)',
64 string: true,
65 },
66}, function (args) { return beemo.syncDotfiles(args); });
67app.command('*', false, {}, function () {
68 console.error(chalk_1.default.red('Please select a command!'));
69});
70// Add Beemo options
71app
72 .option('debug', {
73 boolean: true,
74 default: false,
75 description: 'Show debug messages',
76})
77 .option('silent', {
78 boolean: true,
79 default: false,
80 description: "Hide " + binName + " output",
81})
82 .option('theme', {
83 default: 'default',
84 description: 'Change output colors',
85 string: true,
86})
87 .option('verbose', {
88 default: 3,
89 description: 'Control output size',
90 number: true,
91});
92// Run application
93// eslint-disable-next-line no-unused-expressions
94app
95 .usage(binName + " <command> [args..]")
96 .epilogue(chalk_1.default.gray(["For more information, view the manual: " + manualURL, "Powered by Beemo v" + checkVersion_1.default].join('\n')))
97 .demandCommand(1, chalk_1.default.red('Please select a command!'))
98 .showHelpOnFail(true)
99 .help().argv;