@nestjs/cli 10.0.0-next.3 → 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 +3 -12
- 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 +3 -12
- package/lib/compiler/assets-manager.js +3 -3
- package/lib/compiler/hooks/tsconfig-paths.hook.js +2 -2
- 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 +3 -0
- 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 -37
- package/lib/compiler/swc/swc-compiler.js +35 -42
- package/lib/compiler/swc/type-checker-host.js +12 -9
- 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/.circleci/config.yml
CHANGED
|
@@ -3,25 +3,25 @@ version: 2
|
|
|
3
3
|
aliases:
|
|
4
4
|
- &restore-cache
|
|
5
5
|
restore_cache:
|
|
6
|
-
|
|
6
|
+
key: dependency-cache-{{ checksum "package.json" }}
|
|
7
7
|
- &install-deps
|
|
8
8
|
run:
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
name: Install dependencies
|
|
10
|
+
command: npm ci --ignore-scripts
|
|
11
11
|
- &build-packages
|
|
12
12
|
run:
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
name: Build
|
|
14
|
+
command: npm run build
|
|
15
15
|
- &run-unit-tests
|
|
16
16
|
run:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
name: Test
|
|
18
|
+
command: npm run test
|
|
19
19
|
|
|
20
20
|
jobs:
|
|
21
21
|
build:
|
|
22
22
|
working_directory: ~/nest
|
|
23
23
|
docker:
|
|
24
|
-
- image: cimg/node:20.
|
|
24
|
+
- image: cimg/node:20.3
|
|
25
25
|
steps:
|
|
26
26
|
- checkout
|
|
27
27
|
- run:
|
|
@@ -31,19 +31,19 @@ jobs:
|
|
|
31
31
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
32
32
|
- run:
|
|
33
33
|
name: Install dependencies
|
|
34
|
-
command: npm ci
|
|
34
|
+
command: npm ci --ignore-scripts
|
|
35
35
|
- save_cache:
|
|
36
36
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
37
37
|
paths:
|
|
38
38
|
- ./node_modules
|
|
39
39
|
- run:
|
|
40
40
|
name: Build
|
|
41
|
-
command: npm run build
|
|
41
|
+
command: npm run build
|
|
42
42
|
|
|
43
43
|
unit_tests:
|
|
44
44
|
working_directory: ~/nest
|
|
45
45
|
docker:
|
|
46
|
-
- image: cimg/node:20.
|
|
46
|
+
- image: cimg/node:20.3
|
|
47
47
|
steps:
|
|
48
48
|
- checkout
|
|
49
49
|
- *restore-cache
|
|
@@ -59,4 +59,3 @@ workflows:
|
|
|
59
59
|
- unit_tests:
|
|
60
60
|
requires:
|
|
61
61
|
- build
|
|
62
|
-
|
package/actions/add.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.AddAction = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -20,88 +11,80 @@ const project_utils_1 = require("../lib/utils/project-utils");
|
|
|
20
11
|
const abstract_action_1 = require("./abstract.action");
|
|
21
12
|
const schematicName = 'nest-add';
|
|
22
13
|
class AddAction extends abstract_action_1.AbstractAction {
|
|
23
|
-
handle(inputs, options, extraFlags) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
});
|
|
14
|
+
async handle(inputs, options, extraFlags) {
|
|
15
|
+
const libraryName = this.getLibraryName(inputs);
|
|
16
|
+
const packageName = this.getPackageName(libraryName);
|
|
17
|
+
const collectionName = this.getCollectionName(libraryName, packageName);
|
|
18
|
+
const tagName = this.getTagName(packageName);
|
|
19
|
+
const skipInstall = (0, project_utils_1.hasValidOptionFlag)('skip-install', options);
|
|
20
|
+
const packageInstallSuccess = skipInstall || (await this.installPackage(collectionName, tagName));
|
|
21
|
+
if (packageInstallSuccess) {
|
|
22
|
+
const sourceRootOption = await this.getSourceRoot(inputs.concat(options));
|
|
23
|
+
options.push(sourceRootOption);
|
|
24
|
+
await this.addLibrary(collectionName, options, extraFlags);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.error(chalk.red(ui_1.MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName)));
|
|
28
|
+
throw new Error(ui_1.MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName));
|
|
29
|
+
}
|
|
41
30
|
}
|
|
42
|
-
getSourceRoot(inputs) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
31
|
+
async getSourceRoot(inputs) {
|
|
32
|
+
const configuration = await (0, load_configuration_1.loadConfiguration)();
|
|
33
|
+
const configurationProjects = configuration.projects;
|
|
34
|
+
const appName = inputs.find((option) => option.name === 'project')
|
|
35
|
+
.value;
|
|
36
|
+
let sourceRoot = appName
|
|
37
|
+
? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
|
|
38
|
+
: configuration.sourceRoot;
|
|
39
|
+
const shouldAsk = (0, project_utils_1.shouldAskForProject)(schematicName, configurationProjects, appName);
|
|
40
|
+
if (shouldAsk) {
|
|
41
|
+
const defaultLabel = ' [ Default ]';
|
|
42
|
+
let defaultProjectName = configuration.sourceRoot + defaultLabel;
|
|
43
|
+
for (const property in configurationProjects) {
|
|
44
|
+
if (configurationProjects[property].sourceRoot ===
|
|
45
|
+
configuration.sourceRoot) {
|
|
46
|
+
defaultProjectName = property + defaultLabel;
|
|
47
|
+
break;
|
|
61
48
|
}
|
|
62
|
-
const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
|
|
63
|
-
const answers = yield (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.LIBRARY_PROJECT_SELECTION_QUESTION, projects);
|
|
64
|
-
const project = answers.appName.replace(defaultLabel, '');
|
|
65
|
-
if (project !== configuration.sourceRoot) {
|
|
66
|
-
sourceRoot = configurationProjects[project].sourceRoot;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return { name: 'sourceRoot', value: sourceRoot };
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
installPackage(collectionName, tagName) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const manager = yield package_managers_1.PackageManagerFactory.find();
|
|
75
|
-
tagName = tagName || 'latest';
|
|
76
|
-
let installResult = false;
|
|
77
|
-
try {
|
|
78
|
-
installResult = yield manager.addProduction([collectionName], tagName);
|
|
79
49
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
50
|
+
const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
|
|
51
|
+
const answers = await (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.LIBRARY_PROJECT_SELECTION_QUESTION, projects);
|
|
52
|
+
const project = answers.appName.replace(defaultLabel, '');
|
|
53
|
+
if (project !== configuration.sourceRoot) {
|
|
54
|
+
sourceRoot = configurationProjects[project].sourceRoot;
|
|
84
55
|
}
|
|
85
|
-
|
|
86
|
-
}
|
|
56
|
+
}
|
|
57
|
+
return { name: 'sourceRoot', value: sourceRoot };
|
|
87
58
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
59
|
+
async installPackage(collectionName, tagName) {
|
|
60
|
+
const manager = await package_managers_1.PackageManagerFactory.find();
|
|
61
|
+
tagName = tagName || 'latest';
|
|
62
|
+
let installResult = false;
|
|
63
|
+
try {
|
|
64
|
+
installResult = await manager.addProduction([collectionName], tagName);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error && error.message) {
|
|
68
|
+
console.error(chalk.red(error.message));
|
|
97
69
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
70
|
+
}
|
|
71
|
+
return installResult;
|
|
72
|
+
}
|
|
73
|
+
async addLibrary(collectionName, options, extraFlags) {
|
|
74
|
+
console.info(ui_1.MESSAGES.LIBRARY_INSTALLATION_STARTS);
|
|
75
|
+
const schematicOptions = [];
|
|
76
|
+
schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', options.find((option) => option.name === 'sourceRoot').value));
|
|
77
|
+
const extraFlagsString = extraFlags ? extraFlags.join(' ') : undefined;
|
|
78
|
+
try {
|
|
79
|
+
const collection = schematics_1.CollectionFactory.create(collectionName);
|
|
80
|
+
await collection.execute(schematicName, schematicOptions, extraFlagsString);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error && error.message) {
|
|
84
|
+
console.error(chalk.red(error.message));
|
|
85
|
+
return Promise.reject();
|
|
103
86
|
}
|
|
104
|
-
}
|
|
87
|
+
}
|
|
105
88
|
}
|
|
106
89
|
getLibraryName(inputs) {
|
|
107
90
|
const libraryInput = inputs.find((input) => input.name === 'library');
|
package/actions/build.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.BuildAction = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -38,60 +29,54 @@ class BuildAction extends abstract_action_1.AbstractAction {
|
|
|
38
29
|
this.assetsManager = new assets_manager_1.AssetsManager();
|
|
39
30
|
this.workspaceUtils = new workspace_utils_1.WorkspaceUtils();
|
|
40
31
|
}
|
|
41
|
-
handle(inputs, options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
async handle(inputs, options) {
|
|
33
|
+
try {
|
|
34
|
+
const watchModeOption = options.find((option) => option.name === 'watch');
|
|
35
|
+
const watchMode = !!(watchModeOption && watchModeOption.value);
|
|
36
|
+
const watchAssetsModeOption = options.find((option) => option.name === 'watchAssets');
|
|
37
|
+
const watchAssetsMode = !!(watchAssetsModeOption && watchAssetsModeOption.value);
|
|
38
|
+
await this.runBuild(inputs, options, watchMode, watchAssetsMode);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof Error) {
|
|
42
|
+
console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
|
|
49
43
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
console.error(`\n${chalk.red(err)}\n`);
|
|
56
|
-
}
|
|
57
|
-
process.exit(1);
|
|
44
|
+
else {
|
|
45
|
+
console.error(`\n${chalk.red(err)}\n`);
|
|
58
46
|
}
|
|
59
|
-
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
60
49
|
}
|
|
61
|
-
runBuild(inputs, options, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
});
|
|
50
|
+
async runBuild(inputs, options, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
|
|
51
|
+
const configFileName = options.find((option) => option.name === 'config')
|
|
52
|
+
.value;
|
|
53
|
+
const configuration = await this.loader.load(configFileName);
|
|
54
|
+
const appName = inputs.find((input) => input.name === 'app')
|
|
55
|
+
.value;
|
|
56
|
+
const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
|
|
57
|
+
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
|
|
58
|
+
const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
|
|
59
|
+
const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', options);
|
|
60
|
+
const builder = isWebpackEnabled
|
|
61
|
+
? 'webpack'
|
|
62
|
+
: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', options, 'tsc');
|
|
63
|
+
await this.workspaceUtils.deleteOutDirIfEnabled(configuration, appName, outDir);
|
|
64
|
+
this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
|
|
65
|
+
switch (builder) {
|
|
66
|
+
case 'tsc':
|
|
67
|
+
return this.runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess);
|
|
68
|
+
case 'webpack':
|
|
69
|
+
return this.runWebpack(configuration, appName, options, pathToTsconfig, isDebugEnabled, watchMode, onSuccess);
|
|
70
|
+
case 'swc':
|
|
71
|
+
return this.runSwc(configuration, appName, pathToTsconfig, watchMode, options, onSuccess);
|
|
72
|
+
}
|
|
86
73
|
}
|
|
87
|
-
runSwc(configuration, appName, pathToTsconfig, watchMode, options, onSuccess) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, onSuccess);
|
|
94
|
-
});
|
|
74
|
+
async runSwc(configuration, appName, pathToTsconfig, watchMode, options, onSuccess) {
|
|
75
|
+
const swc = new swc_compiler_1.SwcCompiler(this.pluginsLoader);
|
|
76
|
+
await swc.run(configuration, pathToTsconfig, appName, {
|
|
77
|
+
watch: watchMode,
|
|
78
|
+
typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
|
|
79
|
+
}, onSuccess);
|
|
95
80
|
}
|
|
96
81
|
runWebpack(configuration, appName, inputs, pathToTsconfig, debug, watchMode, onSuccess) {
|
|
97
82
|
const webpackCompiler = new webpack_compiler_1.WebpackCompiler(this.pluginsLoader);
|
|
@@ -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.GenerateAction = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -18,15 +9,13 @@ const load_configuration_1 = require("../lib/utils/load-configuration");
|
|
|
18
9
|
const project_utils_1 = require("../lib/utils/project-utils");
|
|
19
10
|
const abstract_action_1 = require("./abstract.action");
|
|
20
11
|
class GenerateAction extends abstract_action_1.AbstractAction {
|
|
21
|
-
handle(inputs, options) {
|
|
22
|
-
|
|
23
|
-
yield generateFiles(inputs.concat(options));
|
|
24
|
-
});
|
|
12
|
+
async handle(inputs, options) {
|
|
13
|
+
await generateFiles(inputs.concat(options));
|
|
25
14
|
}
|
|
26
15
|
}
|
|
27
16
|
exports.GenerateAction = GenerateAction;
|
|
28
|
-
const generateFiles = (inputs) =>
|
|
29
|
-
const configuration =
|
|
17
|
+
const generateFiles = async (inputs) => {
|
|
18
|
+
const configuration = await (0, load_configuration_1.loadConfiguration)();
|
|
30
19
|
const collectionOption = inputs.find((option) => option.name === 'collection').value;
|
|
31
20
|
const schematic = inputs.find((option) => option.name === 'schematic')
|
|
32
21
|
.value;
|
|
@@ -43,7 +32,7 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
43
32
|
? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
|
|
44
33
|
: configuration.sourceRoot;
|
|
45
34
|
const specValue = spec.value;
|
|
46
|
-
const flatValue = !!
|
|
35
|
+
const flatValue = !!flat?.value;
|
|
47
36
|
const specFileSuffixValue = specFileSuffix.value;
|
|
48
37
|
const specOptions = spec.options;
|
|
49
38
|
let generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, appName, specValue, specOptions.passedAsInput);
|
|
@@ -61,7 +50,7 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
61
50
|
}
|
|
62
51
|
}
|
|
63
52
|
const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
|
|
64
|
-
const answers =
|
|
53
|
+
const answers = await (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.PROJECT_SELECTION_QUESTION, projects);
|
|
65
54
|
const project = answers.appName.replace(defaultLabel, '');
|
|
66
55
|
if (project !== configuration.sourceRoot) {
|
|
67
56
|
sourceRoot = configurationProjects[project].sourceRoot;
|
|
@@ -82,14 +71,14 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
82
71
|
if (!schematicInput) {
|
|
83
72
|
throw new Error('Unable to find a schematic for this configuration');
|
|
84
73
|
}
|
|
85
|
-
|
|
74
|
+
await collection.execute(schematicInput.value, schematicOptions);
|
|
86
75
|
}
|
|
87
76
|
catch (error) {
|
|
88
77
|
if (error && error.message) {
|
|
89
78
|
console.error(chalk.red(error.message));
|
|
90
79
|
}
|
|
91
80
|
}
|
|
92
|
-
}
|
|
81
|
+
};
|
|
93
82
|
const mapSchematicOptions = (inputs) => {
|
|
94
83
|
const excludedInputNames = ['schematic', 'spec', 'flat', 'specFileSuffix'];
|
|
95
84
|
const options = [];
|
package/actions/info.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.InfoAction = void 0;
|
|
13
4
|
const chalk = require("chalk");
|
|
@@ -19,53 +10,43 @@ const package_managers_1 = require("../lib/package-managers");
|
|
|
19
10
|
const ui_1 = require("../lib/ui");
|
|
20
11
|
const abstract_action_1 = require("./abstract.action");
|
|
21
12
|
class InfoAction extends abstract_action_1.AbstractAction {
|
|
22
|
-
handle() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
yield this.displayNestInformation();
|
|
28
|
-
});
|
|
13
|
+
async handle() {
|
|
14
|
+
this.manager = await package_managers_1.PackageManagerFactory.find();
|
|
15
|
+
this.displayBanner();
|
|
16
|
+
await this.displaySystemInformation();
|
|
17
|
+
await this.displayNestInformation();
|
|
29
18
|
}
|
|
30
19
|
displayBanner() {
|
|
31
20
|
console.info(chalk.red(ui_1.BANNER));
|
|
32
21
|
}
|
|
33
|
-
displaySystemInformation() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
yield this.displayPackageManagerVersion();
|
|
39
|
-
});
|
|
22
|
+
async displaySystemInformation() {
|
|
23
|
+
console.info(chalk.green('[System Information]'));
|
|
24
|
+
console.info('OS Version :', chalk.blue(osName((0, os_1.platform)(), (0, os_1.release)())));
|
|
25
|
+
console.info('NodeJS Version :', chalk.blue(process.version));
|
|
26
|
+
await this.displayPackageManagerVersion();
|
|
40
27
|
}
|
|
41
|
-
displayPackageManagerVersion() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
28
|
+
async displayPackageManagerVersion() {
|
|
29
|
+
try {
|
|
30
|
+
const version = await this.manager.version();
|
|
31
|
+
console.info(`${this.manager.name} Version :`, chalk.blue(version), '\n');
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
console.error(`${this.manager.name} Version :`, chalk.red('Unknown'), '\n');
|
|
35
|
+
}
|
|
51
36
|
}
|
|
52
|
-
displayNestInformation() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
yield this.displayNestInformationFromPackage();
|
|
57
|
-
});
|
|
37
|
+
async displayNestInformation() {
|
|
38
|
+
this.displayCliVersion();
|
|
39
|
+
console.info(chalk.green('[Nest Platform Information]'));
|
|
40
|
+
await this.displayNestInformationFromPackage();
|
|
58
41
|
}
|
|
59
|
-
displayNestInformationFromPackage() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
});
|
|
42
|
+
async displayNestInformationFromPackage() {
|
|
43
|
+
try {
|
|
44
|
+
const dependencies = this.readProjectPackageDependencies();
|
|
45
|
+
this.displayNestVersions(dependencies);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.error(chalk.red(ui_1.MESSAGES.NEST_INFORMATION_PACKAGE_MANAGER_FAILED));
|
|
49
|
+
}
|
|
69
50
|
}
|
|
70
51
|
displayCliVersion() {
|
|
71
52
|
console.info(chalk.green('[Nest CLI]'));
|
|
@@ -75,7 +56,7 @@ class InfoAction extends abstract_action_1.AbstractAction {
|
|
|
75
56
|
readProjectPackageDependencies() {
|
|
76
57
|
const buffer = (0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), 'package.json'));
|
|
77
58
|
const pack = JSON.parse(buffer.toString());
|
|
78
|
-
const dependencies =
|
|
59
|
+
const dependencies = { ...pack.dependencies, ...pack.devDependencies };
|
|
79
60
|
Object.keys(dependencies).forEach((key) => {
|
|
80
61
|
dependencies[key] = {
|
|
81
62
|
version: dependencies[key],
|