@nestjs/cli 9.1.5 → 9.1.6
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 +3 -3
- package/actions/build.action.js +0 -1
- package/actions/new.action.js +18 -23
- package/commands/new.command.js +2 -2
- package/commands/start.command.js +8 -1
- package/lib/compiler/assets-manager.d.ts +0 -7
- package/lib/compiler/assets-manager.js +4 -21
- package/package.json +21 -21
- package/test/lib/compiler/hooks/__snapshots__/tsconfig-paths.hook.spec.ts.snap +20 -20
package/.circleci/config.yml
CHANGED
|
@@ -21,12 +21,12 @@ jobs:
|
|
|
21
21
|
build:
|
|
22
22
|
working_directory: ~/nest
|
|
23
23
|
docker:
|
|
24
|
-
- image: cimg/node:
|
|
24
|
+
- image: cimg/node:19.3
|
|
25
25
|
steps:
|
|
26
26
|
- checkout
|
|
27
27
|
- run:
|
|
28
28
|
name: Update NPM version
|
|
29
|
-
command: npm install -g npm@latest
|
|
29
|
+
command: sudo npm install -g npm@latest
|
|
30
30
|
- restore_cache:
|
|
31
31
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
32
32
|
- run:
|
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
unit_tests:
|
|
44
44
|
working_directory: ~/nest
|
|
45
45
|
docker:
|
|
46
|
-
- image: cimg/node:
|
|
46
|
+
- image: cimg/node:19.3
|
|
47
47
|
steps:
|
|
48
48
|
- checkout
|
|
49
49
|
- *restore-cache
|
package/actions/build.action.js
CHANGED
package/actions/new.action.js
CHANGED
|
@@ -30,7 +30,7 @@ class NewAction extends abstract_action_1.AbstractAction {
|
|
|
30
30
|
const directoryOption = options.find((option) => option.name === 'directory');
|
|
31
31
|
const dryRunOption = options.find((option) => option.name === 'dry-run');
|
|
32
32
|
const isDryRunEnabled = dryRunOption && dryRunOption.value;
|
|
33
|
-
yield askForMissingInformation(inputs);
|
|
33
|
+
yield askForMissingInformation(inputs, options);
|
|
34
34
|
yield generateApplicationFiles(inputs, options).catch(exports.exit);
|
|
35
35
|
const shouldSkipInstall = options.some((option) => option.name === 'skip-install' && option.value === true);
|
|
36
36
|
const shouldSkipGit = options.some((option) => option.name === 'skip-git' && option.value === true);
|
|
@@ -51,11 +51,12 @@ class NewAction extends abstract_action_1.AbstractAction {
|
|
|
51
51
|
}
|
|
52
52
|
exports.NewAction = NewAction;
|
|
53
53
|
const getApplicationNameInput = (inputs) => inputs.find((input) => input.name === 'name');
|
|
54
|
+
const getPackageManagerInput = (inputs) => inputs.find((options) => options.name === 'packageManager');
|
|
54
55
|
const getProjectDirectory = (applicationName, directoryOption) => {
|
|
55
56
|
return ((directoryOption && directoryOption.value) ||
|
|
56
57
|
(0, formatting_1.normalizeToKebabOrSnakeCase)(applicationName.value));
|
|
57
58
|
};
|
|
58
|
-
const askForMissingInformation = (inputs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
const askForMissingInformation = (inputs, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
60
|
console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
|
|
60
61
|
console.info();
|
|
61
62
|
const prompt = inquirer.createPromptModule();
|
|
@@ -66,6 +67,11 @@ const askForMissingInformation = (inputs) => __awaiter(void 0, void 0, void 0, f
|
|
|
66
67
|
const answers = yield prompt(questions);
|
|
67
68
|
replaceInputMissingInformation(inputs, answers);
|
|
68
69
|
}
|
|
70
|
+
const packageManagerInput = getPackageManagerInput(options);
|
|
71
|
+
if (!packageManagerInput.value) {
|
|
72
|
+
const answers = yield askForPackageManager();
|
|
73
|
+
replaceInputMissingInformation(options, answers);
|
|
74
|
+
}
|
|
69
75
|
});
|
|
70
76
|
const replaceInputMissingInformation = (inputs, answers) => {
|
|
71
77
|
return inputs.map((input) => (input.value =
|
|
@@ -80,15 +86,14 @@ const generateApplicationFiles = (args, options) => __awaiter(void 0, void 0, vo
|
|
|
80
86
|
});
|
|
81
87
|
const mapSchematicOptions = (options) => {
|
|
82
88
|
return options.reduce((schematicOptions, option) => {
|
|
83
|
-
if (option.name !== 'skip-install'
|
|
84
|
-
option.value !== 'package-manager') {
|
|
89
|
+
if (option.name !== 'skip-install') {
|
|
85
90
|
schematicOptions.push(new schematics_1.SchematicOption(option.name, option.value));
|
|
86
91
|
}
|
|
87
92
|
return schematicOptions;
|
|
88
93
|
}, []);
|
|
89
94
|
};
|
|
90
95
|
const installPackages = (options, dryRunMode, installDirectory) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
const inputPackageManager = options
|
|
96
|
+
const inputPackageManager = getPackageManagerInput(options).value;
|
|
92
97
|
let packageManager;
|
|
93
98
|
if (dryRunMode) {
|
|
94
99
|
console.info();
|
|
@@ -96,29 +101,19 @@ const installPackages = (options, dryRunMode, installDirectory) => __awaiter(voi
|
|
|
96
101
|
console.info();
|
|
97
102
|
return;
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
yield packageManager.install(installDirectory, inputPackageManager);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
if (error && error.message) {
|
|
106
|
-
console.error(chalk.red(error.message));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
104
|
+
try {
|
|
105
|
+
packageManager = package_managers_1.PackageManagerFactory.create(inputPackageManager);
|
|
106
|
+
yield packageManager.install(installDirectory, inputPackageManager);
|
|
109
107
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error && error.message) {
|
|
110
|
+
console.error(chalk.red(error.message));
|
|
111
|
+
}
|
|
113
112
|
}
|
|
114
113
|
});
|
|
115
|
-
const selectPackageManager = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
-
const answers = yield askForPackageManager();
|
|
117
|
-
return package_managers_1.PackageManagerFactory.create(answers['package-manager']);
|
|
118
|
-
});
|
|
119
114
|
const askForPackageManager = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
115
|
const questions = [
|
|
121
|
-
(0, questions_1.generateSelect)('
|
|
116
|
+
(0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
|
|
122
117
|
package_managers_1.PackageManager.NPM,
|
|
123
118
|
package_managers_1.PackageManager.YARN,
|
|
124
119
|
package_managers_1.PackageManager.PNPM,
|
package/commands/new.command.js
CHANGED
|
@@ -22,7 +22,7 @@ class NewCommand extends abstract_command_1.AbstractCommand {
|
|
|
22
22
|
.option('-d, --dry-run', 'Report actions that would be performed without writing out results.', false)
|
|
23
23
|
.option('-g, --skip-git', 'Skip git repository initialization.', false)
|
|
24
24
|
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
25
|
-
.option('-p, --package-manager [
|
|
25
|
+
.option('-p, --package-manager [packageManager]', 'Specify package manager.')
|
|
26
26
|
.option('-l, --language [language]', 'Programming language to be used (TypeScript or JavaScript)', 'TypeScript')
|
|
27
27
|
.option('-c, --collection [collectionName]', 'Schematics collection to use', schematics_1.Collection.NESTJS)
|
|
28
28
|
.option('--strict', 'Enables strict mode in TypeScript.', false)
|
|
@@ -35,7 +35,7 @@ class NewCommand extends abstract_command_1.AbstractCommand {
|
|
|
35
35
|
options.push({ name: 'skip-install', value: command.skipInstall });
|
|
36
36
|
options.push({ name: 'strict', value: command.strict });
|
|
37
37
|
options.push({
|
|
38
|
-
name: '
|
|
38
|
+
name: 'packageManager',
|
|
39
39
|
value: command.packageManager,
|
|
40
40
|
});
|
|
41
41
|
options.push({ name: 'collection', value: command.collection });
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StartCommand = void 0;
|
|
13
|
+
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
13
14
|
const abstract_command_1 = require("./abstract.command");
|
|
14
15
|
class StartCommand extends abstract_command_1.AbstractCommand {
|
|
15
16
|
load(program) {
|
|
@@ -67,7 +68,13 @@ class StartCommand extends abstract_command_1.AbstractCommand {
|
|
|
67
68
|
});
|
|
68
69
|
const inputs = [];
|
|
69
70
|
inputs.push({ name: 'app', value: app });
|
|
70
|
-
|
|
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
|
+
}
|
|
71
78
|
}));
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -2,13 +2,6 @@ import { Configuration } from '../configuration';
|
|
|
2
2
|
export declare class AssetsManager {
|
|
3
3
|
private watchAssetsKeyValue;
|
|
4
4
|
private watchers;
|
|
5
|
-
private actionInProgress;
|
|
6
|
-
/**
|
|
7
|
-
* Using on `nest build` to close file watch or the build process will not end
|
|
8
|
-
* Interval like process
|
|
9
|
-
* If no action has been taken recently close watchers
|
|
10
|
-
* If action has been taken recently flag and try again
|
|
11
|
-
*/
|
|
12
5
|
closeWatchers(): void;
|
|
13
6
|
copyAssets(configuration: Required<Configuration>, appName: string, outDir: string, watchAssetsMode: boolean): void;
|
|
14
7
|
private actionOnFile;
|
|
@@ -10,27 +10,9 @@ class AssetsManager {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
this.watchAssetsKeyValue = {};
|
|
12
12
|
this.watchers = [];
|
|
13
|
-
this.actionInProgress = false;
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Using on `nest build` to close file watch or the build process will not end
|
|
17
|
-
* Interval like process
|
|
18
|
-
* If no action has been taken recently close watchers
|
|
19
|
-
* If action has been taken recently flag and try again
|
|
20
|
-
*/
|
|
21
14
|
closeWatchers() {
|
|
22
|
-
|
|
23
|
-
const timeoutMs = 500;
|
|
24
|
-
const closeFn = () => {
|
|
25
|
-
if (this.actionInProgress) {
|
|
26
|
-
this.actionInProgress = false;
|
|
27
|
-
setTimeout(closeFn, timeoutMs);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
this.watchers.forEach((watcher) => watcher.close());
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
setTimeout(closeFn, timeoutMs);
|
|
15
|
+
this.watchers.forEach((watcher) => watcher.close());
|
|
34
16
|
}
|
|
35
17
|
copyAssets(configuration, appName, outDir, watchAssetsMode) {
|
|
36
18
|
const assets = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.assets', appName) || [];
|
|
@@ -70,6 +52,9 @@ class AssetsManager {
|
|
|
70
52
|
.on('add', (path) => this.actionOnFile(Object.assign(Object.assign({}, option), { path, action: 'change' })))
|
|
71
53
|
.on('change', (path) => this.actionOnFile(Object.assign(Object.assign({}, option), { path, action: 'change' })))
|
|
72
54
|
.on('unlink', (path) => this.actionOnFile(Object.assign(Object.assign({}, option), { path, action: 'unlink' })));
|
|
55
|
+
if (!isWatchEnabled) {
|
|
56
|
+
watcher.on('ready', () => watcher.close());
|
|
57
|
+
}
|
|
73
58
|
this.watchers.push(watcher);
|
|
74
59
|
}
|
|
75
60
|
}
|
|
@@ -86,8 +71,6 @@ class AssetsManager {
|
|
|
86
71
|
}
|
|
87
72
|
// Set path value to true for watching the first time
|
|
88
73
|
this.watchAssetsKeyValue[path] = true;
|
|
89
|
-
// Set action to true to avoid watches getting cutoff
|
|
90
|
-
this.actionInProgress = true;
|
|
91
74
|
const dest = (0, copy_path_resolve_1.copyPathResolve)(path, item.outDir, sourceRoot.split(path_1.sep).length);
|
|
92
75
|
// Copy to output dir if file is changed or added
|
|
93
76
|
if (action === 'change') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/cli",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.6",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@cli)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/nestjs/nest-cli#readme",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@angular-devkit/core": "14.2.
|
|
42
|
-
"@angular-devkit/schematics": "14.2.
|
|
43
|
-
"@angular-devkit/schematics-cli": "14.2.
|
|
41
|
+
"@angular-devkit/core": "14.2.10",
|
|
42
|
+
"@angular-devkit/schematics": "14.2.10",
|
|
43
|
+
"@angular-devkit/schematics-cli": "14.2.10",
|
|
44
44
|
"@nestjs/schematics": "^9.0.0",
|
|
45
45
|
"chalk": "3.0.0",
|
|
46
46
|
"chokidar": "3.5.3",
|
|
47
|
-
"cli-table3": "0.6.
|
|
47
|
+
"cli-table3": "0.6.3",
|
|
48
48
|
"commander": "4.1.1",
|
|
49
|
-
"fork-ts-checker-webpack-plugin": "7.2.
|
|
49
|
+
"fork-ts-checker-webpack-plugin": "7.2.14",
|
|
50
50
|
"inquirer": "7.3.3",
|
|
51
51
|
"node-emoji": "1.11.0",
|
|
52
52
|
"ora": "5.4.1",
|
|
@@ -55,40 +55,40 @@
|
|
|
55
55
|
"shelljs": "0.8.5",
|
|
56
56
|
"source-map-support": "0.5.21",
|
|
57
57
|
"tree-kill": "1.2.2",
|
|
58
|
-
"tsconfig-paths": "4.1.
|
|
58
|
+
"tsconfig-paths": "4.1.1",
|
|
59
59
|
"tsconfig-paths-webpack-plugin": "4.0.0",
|
|
60
60
|
"typescript": "4.8.4",
|
|
61
|
-
"webpack": "5.
|
|
61
|
+
"webpack": "5.75.0",
|
|
62
62
|
"webpack-node-externals": "3.0.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@commitlint/cli": "17.
|
|
66
|
-
"@commitlint/config-angular": "17.
|
|
65
|
+
"@commitlint/cli": "17.3.0",
|
|
66
|
+
"@commitlint/config-angular": "17.3.0",
|
|
67
67
|
"@types/copyfiles": "2.4.1",
|
|
68
|
-
"@types/inquirer": "8.2.
|
|
69
|
-
"@types/jest": "
|
|
70
|
-
"@types/node": "18.11.
|
|
68
|
+
"@types/inquirer": "8.2.5",
|
|
69
|
+
"@types/jest": "29.2.4",
|
|
70
|
+
"@types/node": "18.11.18",
|
|
71
71
|
"@types/node-emoji": "1.8.2",
|
|
72
72
|
"@types/ora": "3.2.0",
|
|
73
73
|
"@types/os-name": "3.1.0",
|
|
74
74
|
"@types/rimraf": "3.0.2",
|
|
75
75
|
"@types/shelljs": "0.8.11",
|
|
76
76
|
"@types/webpack-node-externals": "2.5.3",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
78
|
-
"@typescript-eslint/parser": "5.
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "5.42.1",
|
|
78
|
+
"@typescript-eslint/parser": "5.42.1",
|
|
79
79
|
"delete-empty": "3.0.0",
|
|
80
|
-
"eslint": "8.
|
|
80
|
+
"eslint": "8.30.0",
|
|
81
81
|
"eslint-config-prettier": "8.5.0",
|
|
82
82
|
"eslint-plugin-import": "2.26.0",
|
|
83
83
|
"gulp": "4.0.2",
|
|
84
84
|
"gulp-clean": "0.4.0",
|
|
85
|
-
"husky": "8.0.
|
|
86
|
-
"jest": "
|
|
85
|
+
"husky": "8.0.2",
|
|
86
|
+
"jest": "29.3.1",
|
|
87
87
|
"lint-staged": "13.0.3",
|
|
88
88
|
"prettier": "2.7.1",
|
|
89
|
-
"release-it": "15.5.
|
|
90
|
-
"ts-jest": "
|
|
91
|
-
"ts-loader": "9.4.
|
|
89
|
+
"release-it": "15.5.1",
|
|
90
|
+
"ts-jest": "29.0.3",
|
|
91
|
+
"ts-loader": "9.4.2",
|
|
92
92
|
"ts-node": "10.9.1"
|
|
93
93
|
},
|
|
94
94
|
"lint-staged": {
|
|
@@ -2,62 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`tsconfig paths hooks should remove unused imports 1`] = `
|
|
4
4
|
Map {
|
|
5
|
-
"dist/foo.js" => "
|
|
6
|
-
Object.defineProperty(exports,
|
|
5
|
+
"dist/foo.js" => ""use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.Foo = void 0;
|
|
8
8
|
class Foo {
|
|
9
9
|
}
|
|
10
10
|
exports.Foo = Foo;
|
|
11
11
|
",
|
|
12
|
-
"dist/bar.js" => "
|
|
13
|
-
Object.defineProperty(exports,
|
|
12
|
+
"dist/bar.js" => ""use strict";
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Bar = void 0;
|
|
15
15
|
class Bar {
|
|
16
16
|
}
|
|
17
17
|
exports.Bar = Bar;
|
|
18
18
|
",
|
|
19
|
-
"dist/main.js" => "
|
|
20
|
-
Object.defineProperty(exports,
|
|
19
|
+
"dist/main.js" => ""use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
",
|
|
22
22
|
}
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
25
|
exports[`tsconfig paths hooks should replace path of every import using a path alias by its relative path 1`] = `
|
|
26
26
|
Map {
|
|
27
|
-
"dist/foo.js" => "
|
|
28
|
-
Object.defineProperty(exports,
|
|
27
|
+
"dist/foo.js" => ""use strict";
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Foo = void 0;
|
|
30
30
|
class Foo {
|
|
31
31
|
}
|
|
32
32
|
exports.Foo = Foo;
|
|
33
33
|
",
|
|
34
|
-
"dist/bar.jsx" => "
|
|
35
|
-
Object.defineProperty(exports,
|
|
34
|
+
"dist/bar.jsx" => ""use strict";
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Bar = void 0;
|
|
37
37
|
class Bar {
|
|
38
38
|
}
|
|
39
39
|
exports.Bar = Bar;
|
|
40
40
|
",
|
|
41
|
-
"dist/baz.js" => "
|
|
42
|
-
Object.defineProperty(exports,
|
|
41
|
+
"dist/baz.js" => ""use strict";
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.Baz = void 0;
|
|
44
44
|
class Baz {
|
|
45
45
|
}
|
|
46
46
|
exports.Baz = Baz;
|
|
47
47
|
",
|
|
48
|
-
"dist/qux.jsx" => "
|
|
49
|
-
Object.defineProperty(exports,
|
|
48
|
+
"dist/qux.jsx" => ""use strict";
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.Qux = void 0;
|
|
51
51
|
class Qux {
|
|
52
52
|
}
|
|
53
53
|
exports.Qux = Qux;
|
|
54
54
|
",
|
|
55
|
-
"dist/main.js" => "
|
|
56
|
-
Object.defineProperty(exports,
|
|
57
|
-
const foo_1 = require(
|
|
58
|
-
const bar_1 = require(
|
|
59
|
-
const baz_1 = require(
|
|
60
|
-
const qux_1 = require(
|
|
55
|
+
"dist/main.js" => ""use strict";
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
const foo_1 = require("./foo");
|
|
58
|
+
const bar_1 = require("./bar");
|
|
59
|
+
const baz_1 = require("./baz");
|
|
60
|
+
const qux_1 = require("./qux");
|
|
61
61
|
// use the imports so they do not get eliminated
|
|
62
62
|
console.log(foo_1.Foo);
|
|
63
63
|
console.log(bar_1.Bar);
|