@nestjs/cli 10.0.0-next.2 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +11 -12
- package/actions/add.action.js +67 -84
- package/actions/build.action.js +44 -59
- package/actions/generate.action.js +8 -19
- package/actions/info.action.js +31 -50
- package/actions/new.action.js +36 -47
- package/actions/start.action.js +29 -40
- package/bin/nest.js +4 -13
- package/commands/add.command.js +3 -12
- package/commands/build.command.js +5 -15
- package/commands/command.loader.js +8 -19
- package/commands/generate.command.js +67 -84
- package/commands/info.command.js +3 -12
- package/commands/new.command.js +3 -12
- package/commands/start.command.js +5 -15
- package/lib/compiler/assets-manager.js +3 -3
- package/lib/compiler/hooks/tsconfig-paths.hook.js +2 -2
- package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +40 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +40 -4
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +4 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +6 -6
- package/lib/compiler/plugins/plugins-loader.js +6 -2
- package/lib/compiler/swc/forked-type-checker.js +26 -35
- package/lib/compiler/swc/swc-compiler.js +36 -43
- package/lib/compiler/swc/type-checker-host.d.ts +2 -1
- package/lib/compiler/swc/type-checker-host.js +12 -7
- package/lib/compiler/typescript-loader.js +1 -1
- package/lib/compiler/watch-compiler.js +4 -1
- package/lib/compiler/webpack-compiler.js +12 -5
- package/lib/compiler/workspace-utils.js +6 -17
- package/lib/configuration/nest-configuration.loader.js +27 -28
- package/lib/dependency-managers/nest.dependency-manager.js +21 -34
- package/lib/package-managers/abstract.package-manager.js +124 -165
- package/lib/package-managers/package-manager.factory.js +15 -26
- package/lib/package-managers/package-manager.js +1 -1
- package/lib/readers/file-system.reader.js +10 -21
- package/lib/runners/abstract.runner.js +19 -30
- package/lib/runners/runner.js +1 -1
- package/lib/runners/schematic.runner.js +1 -1
- package/lib/schematics/abstract.collection.js +4 -15
- package/lib/schematics/collection.js +1 -1
- package/lib/schematics/custom.collection.js +1 -2
- package/lib/schematics/nest.collection.js +3 -17
- package/lib/utils/load-configuration.js +3 -14
- package/lib/utils/project-utils.js +6 -17
- package/package.json +18 -18
package/actions/new.action.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.exit = exports.retrieveCols = exports.NewAction = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -24,28 +15,26 @@ const ui_1 = require("../lib/ui");
|
|
|
24
15
|
const formatting_1 = require("../lib/utils/formatting");
|
|
25
16
|
const abstract_action_1 = require("./abstract.action");
|
|
26
17
|
class NewAction extends abstract_action_1.AbstractAction {
|
|
27
|
-
handle(inputs, options) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
yield createGitIgnoreFile(projectDirectory);
|
|
44
|
-
}
|
|
45
|
-
printCollective();
|
|
18
|
+
async handle(inputs, options) {
|
|
19
|
+
const directoryOption = options.find((option) => option.name === 'directory');
|
|
20
|
+
const dryRunOption = options.find((option) => option.name === 'dry-run');
|
|
21
|
+
const isDryRunEnabled = dryRunOption && dryRunOption.value;
|
|
22
|
+
await askForMissingInformation(inputs, options);
|
|
23
|
+
await generateApplicationFiles(inputs, options).catch(exports.exit);
|
|
24
|
+
const shouldSkipInstall = options.some((option) => option.name === 'skip-install' && option.value === true);
|
|
25
|
+
const shouldSkipGit = options.some((option) => option.name === 'skip-git' && option.value === true);
|
|
26
|
+
const projectDirectory = getProjectDirectory(getApplicationNameInput(inputs), directoryOption);
|
|
27
|
+
if (!shouldSkipInstall) {
|
|
28
|
+
await installPackages(options, isDryRunEnabled, projectDirectory);
|
|
29
|
+
}
|
|
30
|
+
if (!isDryRunEnabled) {
|
|
31
|
+
if (!shouldSkipGit) {
|
|
32
|
+
await initializeGitRepository(projectDirectory);
|
|
33
|
+
await createGitIgnoreFile(projectDirectory);
|
|
46
34
|
}
|
|
47
|
-
|
|
48
|
-
}
|
|
35
|
+
printCollective();
|
|
36
|
+
}
|
|
37
|
+
process.exit(0);
|
|
49
38
|
}
|
|
50
39
|
}
|
|
51
40
|
exports.NewAction = NewAction;
|
|
@@ -55,7 +44,7 @@ const getProjectDirectory = (applicationName, directoryOption) => {
|
|
|
55
44
|
return ((directoryOption && directoryOption.value) ||
|
|
56
45
|
(0, formatting_1.normalizeToKebabOrSnakeCase)(applicationName.value));
|
|
57
46
|
};
|
|
58
|
-
const askForMissingInformation = (inputs, options) =>
|
|
47
|
+
const askForMissingInformation = async (inputs, options) => {
|
|
59
48
|
console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
|
|
60
49
|
console.info();
|
|
61
50
|
const prompt = inquirer.createPromptModule();
|
|
@@ -63,26 +52,26 @@ const askForMissingInformation = (inputs, options) => __awaiter(void 0, void 0,
|
|
|
63
52
|
if (!nameInput.value) {
|
|
64
53
|
const message = 'What name would you like to use for the new project?';
|
|
65
54
|
const questions = [(0, questions_1.generateInput)('name', message)('nest-app')];
|
|
66
|
-
const answers =
|
|
55
|
+
const answers = await prompt(questions);
|
|
67
56
|
replaceInputMissingInformation(inputs, answers);
|
|
68
57
|
}
|
|
69
58
|
const packageManagerInput = getPackageManagerInput(options);
|
|
70
59
|
if (!packageManagerInput.value) {
|
|
71
|
-
const answers =
|
|
60
|
+
const answers = await askForPackageManager();
|
|
72
61
|
replaceInputMissingInformation(options, answers);
|
|
73
62
|
}
|
|
74
|
-
}
|
|
63
|
+
};
|
|
75
64
|
const replaceInputMissingInformation = (inputs, answers) => {
|
|
76
65
|
return inputs.map((input) => (input.value =
|
|
77
66
|
input.value !== undefined ? input.value : answers[input.name]));
|
|
78
67
|
};
|
|
79
|
-
const generateApplicationFiles = (args, options) =>
|
|
68
|
+
const generateApplicationFiles = async (args, options) => {
|
|
80
69
|
const collectionName = options.find((option) => option.name === 'collection' && option.value != null).value;
|
|
81
70
|
const collection = schematics_1.CollectionFactory.create(collectionName || schematics_1.Collection.NESTJS);
|
|
82
71
|
const schematicOptions = mapSchematicOptions(args.concat(options));
|
|
83
|
-
|
|
72
|
+
await collection.execute('application', schematicOptions);
|
|
84
73
|
console.info();
|
|
85
|
-
}
|
|
74
|
+
};
|
|
86
75
|
const mapSchematicOptions = (options) => {
|
|
87
76
|
return options.reduce((schematicOptions, option) => {
|
|
88
77
|
if (option.name !== 'skip-install') {
|
|
@@ -91,7 +80,7 @@ const mapSchematicOptions = (options) => {
|
|
|
91
80
|
return schematicOptions;
|
|
92
81
|
}, []);
|
|
93
82
|
};
|
|
94
|
-
const installPackages = (options, dryRunMode, installDirectory) =>
|
|
83
|
+
const installPackages = async (options, dryRunMode, installDirectory) => {
|
|
95
84
|
const inputPackageManager = getPackageManagerInput(options).value;
|
|
96
85
|
let packageManager;
|
|
97
86
|
if (dryRunMode) {
|
|
@@ -102,15 +91,15 @@ const installPackages = (options, dryRunMode, installDirectory) => __awaiter(voi
|
|
|
102
91
|
}
|
|
103
92
|
try {
|
|
104
93
|
packageManager = package_managers_1.PackageManagerFactory.create(inputPackageManager);
|
|
105
|
-
|
|
94
|
+
await packageManager.install(installDirectory, inputPackageManager);
|
|
106
95
|
}
|
|
107
96
|
catch (error) {
|
|
108
97
|
if (error && error.message) {
|
|
109
98
|
console.error(chalk.red(error.message));
|
|
110
99
|
}
|
|
111
100
|
}
|
|
112
|
-
}
|
|
113
|
-
const askForPackageManager = () =>
|
|
101
|
+
};
|
|
102
|
+
const askForPackageManager = async () => {
|
|
114
103
|
const questions = [
|
|
115
104
|
(0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
|
|
116
105
|
package_managers_1.PackageManager.NPM,
|
|
@@ -119,14 +108,14 @@ const askForPackageManager = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
119
108
|
]),
|
|
120
109
|
];
|
|
121
110
|
const prompt = inquirer.createPromptModule();
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
const initializeGitRepository = (dir) =>
|
|
111
|
+
return await prompt(questions);
|
|
112
|
+
};
|
|
113
|
+
const initializeGitRepository = async (dir) => {
|
|
125
114
|
const runner = new git_runner_1.GitRunner();
|
|
126
|
-
|
|
115
|
+
await runner.run('init', true, (0, path_1.join)(process.cwd(), dir)).catch(() => {
|
|
127
116
|
console.error(chalk.red(ui_1.MESSAGES.GIT_INITIALIZATION_ERROR));
|
|
128
117
|
});
|
|
129
|
-
}
|
|
118
|
+
};
|
|
130
119
|
/**
|
|
131
120
|
* Write a file `.gitignore` in the root of the newly created project.
|
|
132
121
|
* `.gitignore` available in `@nestjs/schematics` cannot be published to
|
|
@@ -176,7 +165,7 @@ const retrieveCols = () => {
|
|
|
176
165
|
});
|
|
177
166
|
return parseInt(terminalCols.toString(), 10) || defaultCols;
|
|
178
167
|
}
|
|
179
|
-
catch
|
|
168
|
+
catch {
|
|
180
169
|
return defaultCols;
|
|
181
170
|
}
|
|
182
171
|
};
|
package/actions/start.action.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.StartAction = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -21,38 +12,36 @@ const defaults_1 = require("../lib/configuration/defaults");
|
|
|
21
12
|
const ui_1 = require("../lib/ui");
|
|
22
13
|
const build_action_1 = require("./build.action");
|
|
23
14
|
class StartAction extends build_action_1.BuildAction {
|
|
24
|
-
handle(inputs, options) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
15
|
+
async handle(inputs, options) {
|
|
16
|
+
try {
|
|
17
|
+
const configFileName = options.find((option) => option.name === 'config')
|
|
18
|
+
.value;
|
|
19
|
+
const configuration = await this.loader.load(configFileName);
|
|
20
|
+
const appName = inputs.find((input) => input.name === 'app')
|
|
21
|
+
.value;
|
|
22
|
+
const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
|
|
23
|
+
const debugModeOption = options.find((option) => option.name === 'debug');
|
|
24
|
+
const watchModeOption = options.find((option) => option.name === 'watch');
|
|
25
|
+
const isWatchEnabled = !!(watchModeOption && watchModeOption.value);
|
|
26
|
+
const watchAssetsModeOption = options.find((option) => option.name === 'watchAssets');
|
|
27
|
+
const isWatchAssetsEnabled = !!(watchAssetsModeOption && watchAssetsModeOption.value);
|
|
28
|
+
const debugFlag = debugModeOption && debugModeOption.value;
|
|
29
|
+
const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', options, defaults_1.defaultConfiguration.exec);
|
|
30
|
+
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
|
|
31
|
+
const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
|
|
32
|
+
const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', options, defaults_1.defaultConfiguration.entryFile);
|
|
33
|
+
const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', options, defaults_1.defaultConfiguration.sourceRoot);
|
|
34
|
+
const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun);
|
|
35
|
+
await this.runBuild(inputs, options, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (err instanceof Error) {
|
|
39
|
+
console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
console.error(`\n${chalk.red(err)}\n`);
|
|
53
|
-
}
|
|
41
|
+
else {
|
|
42
|
+
console.error(`\n${chalk.red(err)}\n`);
|
|
54
43
|
}
|
|
55
|
-
}
|
|
44
|
+
}
|
|
56
45
|
}
|
|
57
46
|
createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun) {
|
|
58
47
|
let childProcessRef;
|
|
@@ -106,7 +95,7 @@ class StartAction extends build_action_1.BuildAction {
|
|
|
106
95
|
require.resolve('source-map-support');
|
|
107
96
|
return true;
|
|
108
97
|
}
|
|
109
|
-
catch
|
|
98
|
+
catch {
|
|
110
99
|
return false;
|
|
111
100
|
}
|
|
112
101
|
}
|
package/bin/nest.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
4
|
const commander = require("commander");
|
|
14
5
|
const commands_1 = require("../commands");
|
|
15
6
|
const local_binaries_1 = require("../lib/utils/local-binaries");
|
|
16
|
-
const bootstrap = () =>
|
|
7
|
+
const bootstrap = async () => {
|
|
17
8
|
const program = commander;
|
|
18
9
|
program
|
|
19
10
|
.version(require('../package.json').version, '-v, --version', 'Output the current version.')
|
|
@@ -21,14 +12,14 @@ const bootstrap = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
21
12
|
.helpOption('-h, --help', 'Output usage information.');
|
|
22
13
|
if ((0, local_binaries_1.localBinExists)()) {
|
|
23
14
|
const localCommandLoader = (0, local_binaries_1.loadLocalBinCommandLoader)();
|
|
24
|
-
|
|
15
|
+
await localCommandLoader.load(program);
|
|
25
16
|
}
|
|
26
17
|
else {
|
|
27
|
-
|
|
18
|
+
await commands_1.CommandLoader.load(program);
|
|
28
19
|
}
|
|
29
20
|
commander.parseAsync(process.argv);
|
|
30
21
|
if (!process.argv.slice(2).length) {
|
|
31
22
|
program.outputHelp();
|
|
32
23
|
}
|
|
33
|
-
}
|
|
24
|
+
};
|
|
34
25
|
bootstrap();
|
package/commands/add.command.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AddCommand = void 0;
|
|
13
4
|
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
@@ -22,7 +13,7 @@ class AddCommand extends abstract_command_1.AbstractCommand {
|
|
|
22
13
|
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
23
14
|
.option('-p, --project [project]', 'Project in which to generate files.')
|
|
24
15
|
.usage('<library> [options] [library-specific-options]')
|
|
25
|
-
.action((library, command) =>
|
|
16
|
+
.action(async (library, command) => {
|
|
26
17
|
const options = [];
|
|
27
18
|
options.push({ name: 'dry-run', value: !!command.dryRun });
|
|
28
19
|
options.push({ name: 'skip-install', value: command.skipInstall });
|
|
@@ -34,12 +25,12 @@ class AddCommand extends abstract_command_1.AbstractCommand {
|
|
|
34
25
|
inputs.push({ name: 'library', value: library });
|
|
35
26
|
const flags = (0, remaining_flags_1.getRemainingFlags)(program);
|
|
36
27
|
try {
|
|
37
|
-
|
|
28
|
+
await this.action.handle(inputs, options, flags);
|
|
38
29
|
}
|
|
39
30
|
catch (err) {
|
|
40
31
|
process.exit(1);
|
|
41
32
|
}
|
|
42
|
-
})
|
|
33
|
+
});
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
36
|
exports.AddCommand = AddCommand;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.BuildCommand = void 0;
|
|
13
4
|
const ui_1 = require("../lib/ui");
|
|
@@ -22,12 +13,11 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
|
22
13
|
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
|
|
23
14
|
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
|
|
24
15
|
.option('--webpack', 'Use webpack for compilation (deprecated option, use --build instead).')
|
|
25
|
-
.option('--type-check', 'Enable type checking (when SWC is used).'
|
|
16
|
+
.option('--type-check', 'Enable type checking (when SWC is used).')
|
|
26
17
|
.option('--webpackPath [path]', 'Path to webpack configuration.')
|
|
27
18
|
.option('--tsc', 'Use tsc for compilation.')
|
|
28
19
|
.description('Build Nest application.')
|
|
29
|
-
.action((app, command) =>
|
|
30
|
-
var _a;
|
|
20
|
+
.action(async (app, command) => {
|
|
31
21
|
const options = [];
|
|
32
22
|
options.push({
|
|
33
23
|
name: 'config',
|
|
@@ -53,7 +43,7 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
|
53
43
|
}
|
|
54
44
|
options.push({
|
|
55
45
|
name: 'builder',
|
|
56
|
-
value:
|
|
46
|
+
value: command.builder,
|
|
57
47
|
});
|
|
58
48
|
if (command.typeCheck && command.builder !== 'swc') {
|
|
59
49
|
console.warn(ui_1.INFO_PREFIX +
|
|
@@ -65,8 +55,8 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
|
65
55
|
});
|
|
66
56
|
const inputs = [];
|
|
67
57
|
inputs.push({ name: 'app', value: app });
|
|
68
|
-
|
|
69
|
-
})
|
|
58
|
+
await this.action.handle(inputs, options);
|
|
59
|
+
});
|
|
70
60
|
}
|
|
71
61
|
}
|
|
72
62
|
exports.BuildCommand = BuildCommand;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.CommandLoader = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -20,16 +11,14 @@ const info_command_1 = require("./info.command");
|
|
|
20
11
|
const new_command_1 = require("./new.command");
|
|
21
12
|
const start_command_1 = require("./start.command");
|
|
22
13
|
class CommandLoader {
|
|
23
|
-
static load(program) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.handleInvalidCommand(program);
|
|
32
|
-
});
|
|
14
|
+
static async load(program) {
|
|
15
|
+
new new_command_1.NewCommand(new actions_1.NewAction()).load(program);
|
|
16
|
+
new build_command_1.BuildCommand(new actions_1.BuildAction()).load(program);
|
|
17
|
+
new start_command_1.StartCommand(new actions_1.StartAction()).load(program);
|
|
18
|
+
new info_command_1.InfoCommand(new actions_1.InfoAction()).load(program);
|
|
19
|
+
new add_command_1.AddCommand(new actions_1.AddAction()).load(program);
|
|
20
|
+
await new generate_command_1.GenerateCommand(new actions_1.GenerateAction()).load(program);
|
|
21
|
+
this.handleInvalidCommand(program);
|
|
33
22
|
}
|
|
34
23
|
static handleInvalidCommand(program) {
|
|
35
24
|
program.on('command:*', () => {
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.GenerateCommand = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -16,73 +7,69 @@ const schematics_1 = require("../lib/schematics");
|
|
|
16
7
|
const load_configuration_1 = require("../lib/utils/load-configuration");
|
|
17
8
|
const abstract_command_1 = require("./abstract.command");
|
|
18
9
|
class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
19
|
-
load(program) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
yield this.action.handle(inputs, options);
|
|
76
|
-
}));
|
|
10
|
+
async load(program) {
|
|
11
|
+
program
|
|
12
|
+
.command('generate <schematic> [name] [path]')
|
|
13
|
+
.alias('g')
|
|
14
|
+
.description(await this.buildDescription())
|
|
15
|
+
.option('-d, --dry-run', 'Report actions that would be taken without writing out results.')
|
|
16
|
+
.option('-p, --project [project]', 'Project in which to generate files.')
|
|
17
|
+
.option('--flat', 'Enforce flat structure of generated element.', () => true)
|
|
18
|
+
.option('--no-flat', 'Enforce that directories are generated.', () => false)
|
|
19
|
+
.option('--spec', 'Enforce spec files generation.', () => {
|
|
20
|
+
return { value: true, passedAsInput: true };
|
|
21
|
+
}, true)
|
|
22
|
+
.option('--spec-file-suffix [suffix]', 'Use a custom suffix for spec files.')
|
|
23
|
+
.option('--skip-import', 'Skip importing', () => true, false)
|
|
24
|
+
.option('--no-spec', 'Disable spec files generation.', () => {
|
|
25
|
+
return { value: false, passedAsInput: true };
|
|
26
|
+
})
|
|
27
|
+
.option('-c, --collection [collectionName]', 'Schematics collection to use.')
|
|
28
|
+
.action(async (schematic, name, path, command) => {
|
|
29
|
+
const options = [];
|
|
30
|
+
options.push({ name: 'dry-run', value: !!command.dryRun });
|
|
31
|
+
if (command.flat !== undefined) {
|
|
32
|
+
options.push({ name: 'flat', value: command.flat });
|
|
33
|
+
}
|
|
34
|
+
options.push({
|
|
35
|
+
name: 'spec',
|
|
36
|
+
value: typeof command.spec === 'boolean'
|
|
37
|
+
? command.spec
|
|
38
|
+
: command.spec.value,
|
|
39
|
+
options: {
|
|
40
|
+
passedAsInput: typeof command.spec === 'boolean'
|
|
41
|
+
? false
|
|
42
|
+
: command.spec.passedAsInput,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
options.push({
|
|
46
|
+
name: 'specFileSuffix',
|
|
47
|
+
value: command.specFileSuffix,
|
|
48
|
+
});
|
|
49
|
+
options.push({
|
|
50
|
+
name: 'collection',
|
|
51
|
+
value: command.collection,
|
|
52
|
+
});
|
|
53
|
+
options.push({
|
|
54
|
+
name: 'project',
|
|
55
|
+
value: command.project,
|
|
56
|
+
});
|
|
57
|
+
options.push({
|
|
58
|
+
name: 'skipImport',
|
|
59
|
+
value: command.skipImport,
|
|
60
|
+
});
|
|
61
|
+
const inputs = [];
|
|
62
|
+
inputs.push({ name: 'schematic', value: schematic });
|
|
63
|
+
inputs.push({ name: 'name', value: name });
|
|
64
|
+
inputs.push({ name: 'path', value: path });
|
|
65
|
+
await this.action.handle(inputs, options);
|
|
77
66
|
});
|
|
78
67
|
}
|
|
79
|
-
buildDescription() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.buildSchematicsListAsTable(yield this.getSchematics(collection)));
|
|
85
|
-
});
|
|
68
|
+
async buildDescription() {
|
|
69
|
+
const collection = await this.getCollection();
|
|
70
|
+
return ('Generate a Nest element.\n' +
|
|
71
|
+
` Schematics available on ${chalk.bold(collection)} collection:\n` +
|
|
72
|
+
this.buildSchematicsListAsTable(await this.getSchematics(collection)));
|
|
86
73
|
}
|
|
87
74
|
buildSchematicsListAsTable(schematics) {
|
|
88
75
|
const leftMargin = ' ';
|
|
@@ -108,17 +95,13 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
|
108
95
|
}
|
|
109
96
|
return table.toString();
|
|
110
97
|
}
|
|
111
|
-
getCollection() {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return configuration.collection;
|
|
115
|
-
});
|
|
98
|
+
async getCollection() {
|
|
99
|
+
const configuration = await (0, load_configuration_1.loadConfiguration)();
|
|
100
|
+
return configuration.collection;
|
|
116
101
|
}
|
|
117
|
-
getSchematics(collection) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return abstractCollection.getSchematics();
|
|
121
|
-
});
|
|
102
|
+
async getSchematics(collection) {
|
|
103
|
+
const abstractCollection = schematics_1.CollectionFactory.create(collection);
|
|
104
|
+
return abstractCollection.getSchematics();
|
|
122
105
|
}
|
|
123
106
|
}
|
|
124
107
|
exports.GenerateCommand = GenerateCommand;
|
package/commands/info.command.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.InfoCommand = void 0;
|
|
13
4
|
const abstract_command_1 = require("./abstract.command");
|
|
@@ -17,9 +8,9 @@ class InfoCommand extends abstract_command_1.AbstractCommand {
|
|
|
17
8
|
.command('info')
|
|
18
9
|
.alias('i')
|
|
19
10
|
.description('Display Nest project details.')
|
|
20
|
-
.action(() =>
|
|
21
|
-
|
|
22
|
-
})
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await this.action.handle();
|
|
13
|
+
});
|
|
23
14
|
}
|
|
24
15
|
}
|
|
25
16
|
exports.InfoCommand = InfoCommand;
|