UNPKG

2.29 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.CommandLoader = void 0;
13const chalk = require("chalk");
14const actions_1 = require("../actions");
15const ui_1 = require("../lib/ui");
16const add_command_1 = require("./add.command");
17const build_command_1 = require("./build.command");
18const generate_command_1 = require("./generate.command");
19const info_command_1 = require("./info.command");
20const new_command_1 = require("./new.command");
21const start_command_1 = require("./start.command");
22class CommandLoader {
23 static load(program) {
24 return __awaiter(this, void 0, void 0, function* () {
25 new new_command_1.NewCommand(new actions_1.NewAction()).load(program);
26 new build_command_1.BuildCommand(new actions_1.BuildAction()).load(program);
27 new start_command_1.StartCommand(new actions_1.StartAction()).load(program);
28 new info_command_1.InfoCommand(new actions_1.InfoAction()).load(program);
29 new add_command_1.AddCommand(new actions_1.AddAction()).load(program);
30 yield new generate_command_1.GenerateCommand(new actions_1.GenerateAction()).load(program);
31 this.handleInvalidCommand(program);
32 });
33 }
34 static handleInvalidCommand(program) {
35 program.on('command:*', () => {
36 console.error(`\n${ui_1.ERROR_PREFIX} Invalid command: ${chalk.red('%s')}`, program.args.join(' '));
37 console.log(`See ${chalk.red('--help')} for a list of available commands.\n`);
38 process.exit(1);
39 });
40 }
41}
42exports.CommandLoader = CommandLoader;