UNPKG

4.03 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.StartCommand = void 0;
13const remaining_flags_1 = require("../lib/utils/remaining-flags");
14const abstract_command_1 = require("./abstract.command");
15class StartCommand extends abstract_command_1.AbstractCommand {
16 load(program) {
17 program
18 .command('start [app]')
19 .option('-c, --config [path]', 'Path to nest-cli configuration file.')
20 .option('-p, --path [path]', 'Path to tsconfig file.')
21 .option('-w, --watch', 'Run in watch mode (live-reload).')
22 .option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
23 .option('-d, --debug [hostport] ', 'Run in debug mode (with --inspect flag).')
24 .option('--webpack', 'Use webpack for compilation.')
25 .option('--webpackPath [path]', 'Path to webpack configuration.')
26 .option('--tsc', 'Use tsc for compilation.')
27 .option('--sourceRoot [sourceRoot]', 'Points at the root of the source code for the single project in standard mode structures, or the default project in monorepo mode structures.')
28 .option('--entryFile [entryFile]', "Path to the entry file where this command will work with. Defaults to the one defined at your Nest's CLI config file.")
29 .option('-e, --exec [binary]', 'Binary to run (default: "node").')
30 .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when tsc watch mode.')
31 .description('Run Nest application.')
32 .action((app, command) => __awaiter(this, void 0, void 0, function* () {
33 const options = [];
34 options.push({
35 name: 'config',
36 value: command.config,
37 });
38 const isWebpackEnabled = command.tsc ? false : command.webpack;
39 options.push({ name: 'webpack', value: isWebpackEnabled });
40 options.push({ name: 'debug', value: command.debug });
41 options.push({ name: 'watch', value: !!command.watch });
42 options.push({ name: 'watchAssets', value: !!command.watchAssets });
43 options.push({
44 name: 'path',
45 value: command.path,
46 });
47 options.push({
48 name: 'webpackPath',
49 value: command.webpackPath,
50 });
51 options.push({
52 name: 'exec',
53 value: command.exec,
54 });
55 options.push({
56 name: 'sourceRoot',
57 value: command.sourceRoot,
58 });
59 options.push({
60 name: 'entryFile',
61 value: command.entryFile,
62 });
63 options.push({
64 name: 'preserveWatchOutput',
65 value: !!command.preserveWatchOutput &&
66 !!command.watch &&
67 !isWebpackEnabled,
68 });
69 const inputs = [];
70 inputs.push({ name: 'app', value: app });
71 const flags = (0, remaining_flags_1.getRemainingFlags)(program);
72 try {
73 yield this.action.handle(inputs, options, flags);
74 }
75 catch (err) {
76 process.exit(1);
77 }
78 }));
79 }
80}
81exports.StartCommand = StartCommand;