UNPKG

2.76 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 });
12const schematics_1 = require("../lib/schematics");
13const abstract_command_1 = require("./abstract.command");
14class NewCommand extends abstract_command_1.AbstractCommand {
15 load(program) {
16 program
17 .command('new [name]')
18 .alias('n')
19 .description('Generate Nest application.')
20 .option('--directory [directory]', 'Specify the destination directory')
21 .option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
22 .option('-g, --skip-git', 'Skip git repository initialization.')
23 .option('-s, --skip-install', 'Skip package installation.')
24 .option('-p, --package-manager [package-manager]', 'Specify package manager.')
25 .option('-l, --language [language]', 'Programming language to be used (TypeScript or JavaScript).')
26 .option('-c, --collection [collectionName]', 'Schematics collection to use.')
27 .action((name, command) => __awaiter(this, void 0, void 0, function* () {
28 const options = [];
29 options.push({ name: 'directory', value: command.directory });
30 options.push({ name: 'dry-run', value: !!command.dryRun });
31 options.push({ name: 'skip-git', value: !!command.skipGit });
32 options.push({ name: 'skip-install', value: !!command.skipInstall });
33 options.push({
34 name: 'package-manager',
35 value: command.packageManager,
36 });
37 options.push({
38 name: 'language',
39 value: !!command.language ? command.language : 'ts',
40 });
41 options.push({
42 name: 'collection',
43 value: command.collection || schematics_1.Collection.NESTJS,
44 });
45 const inputs = [];
46 inputs.push({ name: 'name', value: name });
47 yield this.action.handle(inputs, options);
48 }));
49 }
50}
51exports.NewCommand = NewCommand;