@nestjs/cli 11.0.16 → 12.0.0-alpha.1
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/actions/abstract.action.d.ts +1 -2
- package/actions/abstract.action.js +1 -5
- package/actions/add.action.d.ts +3 -4
- package/actions/add.action.js +38 -52
- package/actions/build.action.d.ts +11 -10
- package/actions/build.action.js +85 -72
- package/actions/generate.action.d.ts +3 -3
- package/actions/generate.action.js +56 -59
- package/actions/index.d.ts +7 -7
- package/actions/index.js +7 -23
- package/actions/info.action.d.ts +12 -28
- package/actions/info.action.js +47 -55
- package/actions/new.action.d.ts +3 -3
- package/actions/new.action.js +75 -105
- package/actions/start.action.d.ts +4 -7
- package/actions/start.action.js +36 -46
- package/bin/nest.js +14 -10
- package/commands/abstract.command.d.ts +3 -3
- package/commands/abstract.command.js +2 -5
- package/commands/add.command.d.ts +3 -3
- package/commands/add.command.js +13 -20
- package/commands/build.command.d.ts +3 -3
- package/commands/build.command.js +25 -54
- package/commands/command.input.js +1 -2
- package/commands/command.loader.d.ts +2 -2
- package/commands/command.loader.js +18 -22
- package/commands/context/add.context.d.ts +7 -0
- package/commands/context/add.context.js +1 -0
- package/commands/context/build.context.d.ts +13 -0
- package/commands/context/build.context.js +1 -0
- package/commands/context/generate.context.d.ts +15 -0
- package/commands/context/generate.context.js +1 -0
- package/commands/context/index.d.ts +5 -0
- package/commands/context/index.js +5 -0
- package/commands/context/new.context.d.ts +11 -0
- package/commands/context/new.context.js +1 -0
- package/commands/context/start.context.d.ts +19 -0
- package/commands/context/start.context.js +1 -0
- package/commands/generate.command.d.ts +3 -3
- package/commands/generate.command.js +26 -54
- package/commands/index.d.ts +3 -2
- package/commands/index.js +3 -18
- package/commands/info.command.d.ts +3 -3
- package/commands/info.command.js +2 -6
- package/commands/new.command.d.ts +3 -3
- package/commands/new.command.js +24 -33
- package/commands/start.command.d.ts +3 -3
- package/commands/start.command.js +34 -71
- package/lib/compiler/assets-manager.d.ts +1 -1
- package/lib/compiler/assets-manager.js +27 -33
- package/lib/compiler/base-compiler.d.ts +5 -5
- package/lib/compiler/base-compiler.js +10 -13
- package/lib/compiler/compiler.d.ts +6 -6
- package/lib/compiler/compiler.js +7 -9
- package/lib/compiler/defaults/rspack-defaults.d.ts +2 -0
- package/lib/compiler/defaults/rspack-defaults.js +138 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +1 -1
- package/lib/compiler/defaults/swc-defaults.js +1 -5
- package/lib/compiler/defaults/webpack-defaults.d.ts +3 -3
- package/lib/compiler/defaults/webpack-defaults.js +36 -18
- package/lib/compiler/helpers/append-extension.js +3 -6
- package/lib/compiler/helpers/copy-path-resolve.js +2 -5
- package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
- package/lib/compiler/helpers/delete-out-dir.js +5 -8
- package/lib/compiler/helpers/get-builder.d.ts +9 -7
- package/lib/compiler/helpers/get-builder.js +3 -6
- package/lib/compiler/helpers/get-rspack-config-path.d.ts +9 -0
- package/lib/compiler/helpers/get-rspack-config-path.js +15 -0
- package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
- package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
- package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
- package/lib/compiler/helpers/get-value-or-default.js +3 -8
- package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
- package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
- package/lib/compiler/helpers/manual-restart.js +4 -8
- package/lib/compiler/helpers/tsconfig-provider.d.ts +1 -1
- package/lib/compiler/helpers/tsconfig-provider.js +8 -11
- package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
- package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-generator.js +10 -13
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
- package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
- package/lib/compiler/plugins/plugins-loader.js +13 -13
- package/lib/compiler/rspack-compiler.d.ts +19 -0
- package/lib/compiler/rspack-compiler.js +105 -0
- package/lib/compiler/swc/constants.d.ts +0 -1
- package/lib/compiler/swc/constants.js +9 -13
- package/lib/compiler/swc/forked-type-checker.js +13 -18
- package/lib/compiler/swc/swc-compiler.d.ts +4 -4
- package/lib/compiler/swc/swc-compiler.js +41 -39
- package/lib/compiler/swc/type-checker-host.js +12 -18
- package/lib/compiler/typescript-loader.js +5 -7
- package/lib/compiler/watch-compiler.d.ts +5 -5
- package/lib/compiler/watch-compiler.js +14 -18
- package/lib/compiler/webpack-compiler.d.ts +6 -7
- package/lib/compiler/webpack-compiler.js +30 -22
- package/lib/configuration/configuration.d.ts +9 -4
- package/lib/configuration/configuration.js +1 -2
- package/lib/configuration/configuration.loader.d.ts +1 -1
- package/lib/configuration/configuration.loader.js +1 -2
- package/lib/configuration/defaults.d.ts +2 -1
- package/lib/configuration/defaults.js +8 -10
- package/lib/configuration/index.d.ts +3 -3
- package/lib/configuration/index.js +3 -19
- package/lib/configuration/nest-configuration.loader.d.ts +3 -3
- package/lib/configuration/nest-configuration.loader.js +11 -20
- package/lib/package-managers/abstract.package-manager.d.ts +4 -4
- package/lib/package-managers/abstract.package-manager.js +19 -30
- package/lib/package-managers/index.d.ts +8 -8
- package/lib/package-managers/index.js +8 -24
- package/lib/package-managers/npm.package-manager.d.ts +2 -2
- package/lib/package-managers/npm.package-manager.js +6 -10
- package/lib/package-managers/package-manager-commands.js +1 -2
- package/lib/package-managers/package-manager.factory.d.ts +2 -2
- package/lib/package-managers/package-manager.factory.js +16 -20
- package/lib/package-managers/package-manager.js +2 -5
- package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
- package/lib/package-managers/pnpm.package-manager.js +6 -10
- package/lib/package-managers/project.dependency.js +1 -2
- package/lib/package-managers/yarn.package-manager.d.ts +2 -2
- package/lib/package-managers/yarn.package-manager.js +6 -10
- package/lib/questions/questions.d.ts +5 -1
- package/lib/questions/questions.js +2 -7
- package/lib/readers/file-system.reader.d.ts +1 -1
- package/lib/readers/file-system.reader.js +6 -9
- package/lib/readers/index.d.ts +2 -2
- package/lib/readers/index.js +2 -18
- package/lib/readers/reader.js +3 -5
- package/lib/runners/abstract.runner.js +10 -12
- package/lib/runners/git.runner.d.ts +1 -1
- package/lib/runners/git.runner.js +2 -6
- package/lib/runners/index.d.ts +3 -3
- package/lib/runners/index.js +3 -19
- package/lib/runners/npm.runner.d.ts +1 -1
- package/lib/runners/npm.runner.js +2 -6
- package/lib/runners/pnpm.runner.d.ts +1 -1
- package/lib/runners/pnpm.runner.js +2 -6
- package/lib/runners/runner.factory.d.ts +6 -6
- package/lib/runners/runner.factory.js +15 -20
- package/lib/runners/runner.js +2 -5
- package/lib/runners/schematic.runner.d.ts +1 -1
- package/lib/runners/schematic.runner.js +5 -7
- package/lib/runners/yarn.runner.d.ts +1 -1
- package/lib/runners/yarn.runner.js +2 -6
- package/lib/schematics/abstract.collection.d.ts +3 -3
- package/lib/schematics/abstract.collection.js +3 -5
- package/lib/schematics/collection.factory.d.ts +2 -2
- package/lib/schematics/collection.factory.js +9 -13
- package/lib/schematics/collection.js +2 -5
- package/lib/schematics/custom.collection.d.ts +2 -2
- package/lib/schematics/custom.collection.js +4 -8
- package/lib/schematics/index.d.ts +4 -4
- package/lib/schematics/index.js +4 -20
- package/lib/schematics/nest.collection.d.ts +3 -3
- package/lib/schematics/nest.collection.js +104 -108
- package/lib/schematics/schematic.option.js +7 -9
- package/lib/ui/banner.js +1 -4
- package/lib/ui/emojis.d.ts +17 -17
- package/lib/ui/emojis.js +19 -22
- package/lib/ui/errors.js +1 -5
- package/lib/ui/index.d.ts +5 -5
- package/lib/ui/index.js +5 -21
- package/lib/ui/messages.js +15 -19
- package/lib/ui/prefixes.js +3 -6
- package/lib/utils/formatting.js +1 -4
- package/lib/utils/get-default-tsconfig-path.js +4 -7
- package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
- package/lib/utils/is-esm-project.d.ts +5 -0
- package/lib/utils/is-esm-project.js +16 -0
- package/lib/utils/is-module-available.js +3 -4
- package/lib/utils/load-configuration.d.ts +1 -1
- package/lib/utils/load-configuration.js +4 -7
- package/lib/utils/local-binaries.d.ts +1 -1
- package/lib/utils/local-binaries.js +8 -11
- package/lib/utils/os-info.utils.js +1 -4
- package/lib/utils/project-utils.d.ts +1 -3
- package/lib/utils/project-utils.js +16 -28
- package/lib/utils/remaining-flags.d.ts +2 -2
- package/lib/utils/remaining-flags.js +2 -5
- package/lib/utils/tree-kill.js +7 -10
- package/lib/utils/type-assertions.js +1 -4
- package/package.json +59 -38
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const load_configuration_1 = require("../lib/utils/load-configuration");
|
|
8
|
-
const abstract_command_1 = require("./abstract.command");
|
|
9
|
-
class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { bold, cyan, green } from 'ansis';
|
|
2
|
+
import Table from 'cli-table3';
|
|
3
|
+
import { CollectionFactory } from '../lib/schematics/index.js';
|
|
4
|
+
import { loadConfiguration } from '../lib/utils/load-configuration.js';
|
|
5
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
6
|
+
export class GenerateCommand extends AbstractCommand {
|
|
10
7
|
async load(program) {
|
|
11
8
|
program
|
|
12
9
|
.command('generate <schematic> [name] [path]')
|
|
@@ -18,57 +15,33 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
|
18
15
|
.option('--no-flat', 'Enforce that directories are generated.', () => false)
|
|
19
16
|
.option('--spec', 'Enforce spec files generation.', () => {
|
|
20
17
|
return { value: true, passedAsInput: true };
|
|
21
|
-
}, true)
|
|
18
|
+
}, { value: true, passedAsInput: false })
|
|
22
19
|
.option('--spec-file-suffix [suffix]', 'Use a custom suffix for spec files.')
|
|
23
20
|
.option('--skip-import', 'Skip importing', () => true, false)
|
|
24
21
|
.option('--no-spec', 'Disable spec files generation.', () => {
|
|
25
22
|
return { value: false, passedAsInput: true };
|
|
26
23
|
})
|
|
27
24
|
.option('-c, --collection [collectionName]', 'Schematics collection to use.')
|
|
28
|
-
.action(async (schematic, name, path,
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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);
|
|
25
|
+
.action(async (schematic, name, path, options) => {
|
|
26
|
+
const context = {
|
|
27
|
+
schematic,
|
|
28
|
+
name,
|
|
29
|
+
path,
|
|
30
|
+
dryRun: !!options.dryRun,
|
|
31
|
+
flat: options.flat,
|
|
32
|
+
spec: options.spec,
|
|
33
|
+
specFileSuffix: options.specFileSuffix,
|
|
34
|
+
collection: options.collection,
|
|
35
|
+
project: options.project,
|
|
36
|
+
skipImport: options.skipImport,
|
|
37
|
+
};
|
|
38
|
+
await this.action.handle(context);
|
|
66
39
|
});
|
|
67
40
|
}
|
|
68
41
|
async buildDescription() {
|
|
69
42
|
const collection = await this.getCollection();
|
|
70
43
|
return ('Generate a Nest element.\n' +
|
|
71
|
-
` Schematics available on ${
|
|
44
|
+
` Schematics available on ${bold(collection)} collection:\n` +
|
|
72
45
|
this.buildSchematicsListAsTable(await this.getSchematics(collection)));
|
|
73
46
|
}
|
|
74
47
|
buildSchematicsListAsTable(schematics) {
|
|
@@ -88,20 +61,19 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
|
88
61
|
const table = new Table(tableConfig);
|
|
89
62
|
for (const schematic of schematics) {
|
|
90
63
|
table.push([
|
|
91
|
-
|
|
92
|
-
|
|
64
|
+
green(schematic.name),
|
|
65
|
+
cyan(schematic.alias),
|
|
93
66
|
schematic.description,
|
|
94
67
|
]);
|
|
95
68
|
}
|
|
96
69
|
return table.toString();
|
|
97
70
|
}
|
|
98
71
|
async getCollection() {
|
|
99
|
-
const configuration = await
|
|
72
|
+
const configuration = await loadConfiguration();
|
|
100
73
|
return configuration.collection;
|
|
101
74
|
}
|
|
102
75
|
async getSchematics(collection) {
|
|
103
|
-
const abstractCollection =
|
|
76
|
+
const abstractCollection = CollectionFactory.create(collection);
|
|
104
77
|
return abstractCollection.getSchematics();
|
|
105
78
|
}
|
|
106
79
|
}
|
|
107
|
-
exports.GenerateCommand = GenerateCommand;
|
package/commands/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './command.
|
|
2
|
-
export * from './command.
|
|
1
|
+
export * from './command.input.js';
|
|
2
|
+
export * from './command.loader.js';
|
|
3
|
+
export * from './context/index.js';
|
package/commands/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./command.loader"), exports);
|
|
18
|
-
__exportStar(require("./command.input"), exports);
|
|
1
|
+
export * from './command.input.js';
|
|
2
|
+
export * from './command.loader.js';
|
|
3
|
+
export * from './context/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractCommand } from './abstract.command';
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
3
|
export declare class InfoCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): void;
|
|
5
5
|
}
|
package/commands/info.command.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.InfoCommand = void 0;
|
|
4
|
-
const abstract_command_1 = require("./abstract.command");
|
|
5
|
-
class InfoCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
2
|
+
export class InfoCommand extends AbstractCommand {
|
|
6
3
|
load(program) {
|
|
7
4
|
program
|
|
8
5
|
.command('info')
|
|
@@ -13,4 +10,3 @@ class InfoCommand extends abstract_command_1.AbstractCommand {
|
|
|
13
10
|
});
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.InfoCommand = InfoCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractCommand } from './abstract.command';
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
3
|
export declare class NewCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): void;
|
|
5
5
|
}
|
package/commands/new.command.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const schematics_1 = require("../lib/schematics");
|
|
5
|
-
const abstract_command_1 = require("./abstract.command");
|
|
6
|
-
class NewCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { Collection } from '../lib/schematics/index.js';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
|
+
export class NewCommand extends AbstractCommand {
|
|
7
4
|
load(program) {
|
|
8
5
|
program
|
|
9
6
|
.command('new [name]')
|
|
@@ -15,47 +12,41 @@ class NewCommand extends abstract_command_1.AbstractCommand {
|
|
|
15
12
|
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
16
13
|
.option('-p, --package-manager [packageManager]', 'Specify package manager.')
|
|
17
14
|
.option('-l, --language [language]', 'Programming language to be used (TypeScript or JavaScript)', 'TypeScript')
|
|
18
|
-
.option('-c, --collection [collectionName]', 'Schematics collection to use',
|
|
15
|
+
.option('-c, --collection [collectionName]', 'Schematics collection to use', Collection.NESTJS)
|
|
19
16
|
.option('--strict', 'Enables strict mode in TypeScript.', false)
|
|
20
|
-
.action(async (name,
|
|
21
|
-
const options = [];
|
|
17
|
+
.action(async (name, options) => {
|
|
22
18
|
const availableLanguages = ['js', 'ts', 'javascript', 'typescript'];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
options.push({ name: 'skip-install', value: command.skipInstall });
|
|
27
|
-
options.push({ name: 'strict', value: command.strict });
|
|
28
|
-
options.push({
|
|
29
|
-
name: 'packageManager',
|
|
30
|
-
value: command.packageManager,
|
|
31
|
-
});
|
|
32
|
-
options.push({ name: 'collection', value: command.collection });
|
|
33
|
-
if (!!command.language) {
|
|
34
|
-
const lowercasedLanguage = command.language.toLowerCase();
|
|
19
|
+
let language = options.language;
|
|
20
|
+
if (language) {
|
|
21
|
+
const lowercasedLanguage = language.toLowerCase();
|
|
35
22
|
const langMatch = availableLanguages.includes(lowercasedLanguage);
|
|
36
23
|
if (!langMatch) {
|
|
37
|
-
throw new Error(`Invalid language "${
|
|
24
|
+
throw new Error(`Invalid language "${language}" selected. Available languages are "typescript" or "javascript"`);
|
|
38
25
|
}
|
|
39
26
|
switch (lowercasedLanguage) {
|
|
40
27
|
case 'javascript':
|
|
41
|
-
|
|
28
|
+
language = 'js';
|
|
42
29
|
break;
|
|
43
30
|
case 'typescript':
|
|
44
|
-
|
|
31
|
+
language = 'ts';
|
|
45
32
|
break;
|
|
46
33
|
default:
|
|
47
|
-
|
|
34
|
+
language = lowercasedLanguage;
|
|
48
35
|
break;
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
name
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
const context = {
|
|
39
|
+
name,
|
|
40
|
+
directory: options.directory,
|
|
41
|
+
dryRun: options.dryRun,
|
|
42
|
+
skipGit: options.skipGit,
|
|
43
|
+
skipInstall: options.skipInstall,
|
|
44
|
+
packageManager: options.packageManager,
|
|
45
|
+
language,
|
|
46
|
+
collection: options.collection,
|
|
47
|
+
strict: options.strict,
|
|
48
|
+
};
|
|
49
|
+
await this.action.handle(context);
|
|
58
50
|
});
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
|
-
exports.NewCommand = NewCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractCommand } from './abstract.command';
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
3
|
export declare class StartCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): void;
|
|
5
5
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
6
|
-
const abstract_command_1 = require("./abstract.command");
|
|
7
|
-
class StartCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { ERROR_PREFIX } from '../lib/ui/index.js';
|
|
2
|
+
import { getRemainingFlags } from '../lib/utils/remaining-flags.js';
|
|
3
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
4
|
+
export class StartCommand extends AbstractCommand {
|
|
8
5
|
load(program) {
|
|
9
6
|
const collect = (value, previous) => {
|
|
10
7
|
return previous.concat([value]);
|
|
@@ -15,7 +12,7 @@ class StartCommand extends abstract_command_1.AbstractCommand {
|
|
|
15
12
|
.option('-c, --config [path]', 'Path to nest-cli configuration file.')
|
|
16
13
|
.option('-p, --path [path]', 'Path to tsconfig file.')
|
|
17
14
|
.option('-w, --watch', 'Run in watch mode (live-reload).')
|
|
18
|
-
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
|
|
15
|
+
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc, rspack).')
|
|
19
16
|
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
|
|
20
17
|
.option('-d, --debug [hostport] ', 'Run in debug mode (with --inspect flag).')
|
|
21
18
|
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).')
|
|
@@ -30,75 +27,41 @@ class StartCommand extends abstract_command_1.AbstractCommand {
|
|
|
30
27
|
.option('--no-shell', 'Do not spawn child processes within a shell.')
|
|
31
28
|
.option('--env-file [path]', 'Path to an env file (.env) to be loaded into the environment.', collect, [])
|
|
32
29
|
.description('Run Nest application.')
|
|
33
|
-
.action(async (app,
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const isWebpackEnabled = command.tsc ? false : command.webpack;
|
|
40
|
-
options.push({ name: 'webpack', value: isWebpackEnabled });
|
|
41
|
-
options.push({ name: 'debug', value: command.debug });
|
|
42
|
-
options.push({ name: 'watch', value: !!command.watch });
|
|
43
|
-
options.push({ name: 'watchAssets', value: !!command.watchAssets });
|
|
44
|
-
options.push({
|
|
45
|
-
name: 'path',
|
|
46
|
-
value: command.path,
|
|
47
|
-
});
|
|
48
|
-
options.push({
|
|
49
|
-
name: 'webpackPath',
|
|
50
|
-
value: command.webpackPath,
|
|
51
|
-
});
|
|
52
|
-
options.push({
|
|
53
|
-
name: 'exec',
|
|
54
|
-
value: command.exec,
|
|
55
|
-
});
|
|
56
|
-
options.push({
|
|
57
|
-
name: 'sourceRoot',
|
|
58
|
-
value: command.sourceRoot,
|
|
59
|
-
});
|
|
60
|
-
options.push({
|
|
61
|
-
name: 'entryFile',
|
|
62
|
-
value: command.entryFile,
|
|
63
|
-
});
|
|
64
|
-
options.push({
|
|
65
|
-
name: 'preserveWatchOutput',
|
|
66
|
-
value: !!command.preserveWatchOutput &&
|
|
67
|
-
!!command.watch &&
|
|
68
|
-
!isWebpackEnabled,
|
|
69
|
-
});
|
|
70
|
-
options.push({
|
|
71
|
-
name: 'shell',
|
|
72
|
-
value: !!command.shell,
|
|
73
|
-
});
|
|
74
|
-
options.push({
|
|
75
|
-
name: 'envFile',
|
|
76
|
-
value: command.envFile,
|
|
77
|
-
});
|
|
78
|
-
const availableBuilders = ['tsc', 'webpack', 'swc'];
|
|
79
|
-
if (command.builder && !availableBuilders.includes(command.builder)) {
|
|
80
|
-
console.error(ui_1.ERROR_PREFIX +
|
|
81
|
-
` Invalid builder option: ${command.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
30
|
+
.action(async (app, options) => {
|
|
31
|
+
const isWebpackEnabled = options.tsc ? false : options.webpack;
|
|
32
|
+
const availableBuilders = ['tsc', 'webpack', 'swc', 'rspack'];
|
|
33
|
+
if (options.builder && !availableBuilders.includes(options.builder)) {
|
|
34
|
+
console.error(ERROR_PREFIX +
|
|
35
|
+
` Invalid builder option: ${options.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
82
36
|
return;
|
|
83
37
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
38
|
+
const context = {
|
|
39
|
+
app,
|
|
40
|
+
config: options.config,
|
|
41
|
+
webpack: isWebpackEnabled,
|
|
42
|
+
watch: !!options.watch,
|
|
43
|
+
watchAssets: !!options.watchAssets,
|
|
44
|
+
path: options.path,
|
|
45
|
+
webpackPath: options.webpackPath,
|
|
46
|
+
builder: options.builder,
|
|
47
|
+
typeCheck: options.typeCheck,
|
|
48
|
+
preserveWatchOutput: !!options.preserveWatchOutput &&
|
|
49
|
+
!!options.watch &&
|
|
50
|
+
!isWebpackEnabled,
|
|
51
|
+
debug: options.debug,
|
|
52
|
+
exec: options.exec,
|
|
53
|
+
sourceRoot: options.sourceRoot,
|
|
54
|
+
entryFile: options.entryFile,
|
|
55
|
+
shell: !!options.shell,
|
|
56
|
+
envFile: options.envFile ?? [],
|
|
57
|
+
extraFlags: getRemainingFlags(program),
|
|
58
|
+
};
|
|
95
59
|
try {
|
|
96
|
-
await this.action.handle(
|
|
60
|
+
await this.action.handle(context);
|
|
97
61
|
}
|
|
98
|
-
catch
|
|
62
|
+
catch {
|
|
99
63
|
process.exit(1);
|
|
100
64
|
}
|
|
101
65
|
});
|
|
102
66
|
}
|
|
103
67
|
}
|
|
104
|
-
exports.StartCommand = StartCommand;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor() {
|
|
12
|
-
this.watchAssetsKeyValue = {};
|
|
13
|
-
this.watchers = [];
|
|
14
|
-
this.actionInProgress = false;
|
|
15
|
-
}
|
|
1
|
+
import * as chokidar from 'chokidar';
|
|
2
|
+
import { copyFileSync, mkdirSync, rmSync, statSync } from 'fs';
|
|
3
|
+
import { sync } from 'glob';
|
|
4
|
+
import { dirname, join, sep } from 'path';
|
|
5
|
+
import { copyPathResolve } from './helpers/copy-path-resolve.js';
|
|
6
|
+
import { getValueOrDefault } from './helpers/get-value-or-default.js';
|
|
7
|
+
export class AssetsManager {
|
|
8
|
+
watchAssetsKeyValue = {};
|
|
9
|
+
watchers = [];
|
|
10
|
+
actionInProgress = false;
|
|
16
11
|
/**
|
|
17
12
|
* Using on `nest build` to close file watch or the build process will not end
|
|
18
13
|
* Interval like process
|
|
@@ -34,19 +29,19 @@ class AssetsManager {
|
|
|
34
29
|
setTimeout(closeFn, timeoutMs);
|
|
35
30
|
}
|
|
36
31
|
copyAssets(configuration, appName, outDir, watchAssetsMode) {
|
|
37
|
-
const assets =
|
|
32
|
+
const assets = getValueOrDefault(configuration, 'compilerOptions.assets', appName) || [];
|
|
38
33
|
if (assets.length <= 0) {
|
|
39
34
|
return;
|
|
40
35
|
}
|
|
41
36
|
try {
|
|
42
|
-
let sourceRoot =
|
|
43
|
-
sourceRoot =
|
|
37
|
+
let sourceRoot = getValueOrDefault(configuration, 'sourceRoot', appName);
|
|
38
|
+
sourceRoot = join(process.cwd(), sourceRoot);
|
|
44
39
|
const filesToCopy = assets.map((item) => {
|
|
45
40
|
let includePath = typeof item === 'string' ? item : item.include;
|
|
46
41
|
let excludePath = typeof item !== 'string' && item.exclude ? item.exclude : undefined;
|
|
47
|
-
includePath =
|
|
42
|
+
includePath = join(sourceRoot, includePath).replace(/\\/g, '/');
|
|
48
43
|
excludePath = excludePath
|
|
49
|
-
?
|
|
44
|
+
? join(sourceRoot, excludePath).replace(/\\/g, '/')
|
|
50
45
|
: undefined;
|
|
51
46
|
return {
|
|
52
47
|
outDir: typeof item !== 'string' ? item.outDir || outDir : outDir,
|
|
@@ -56,7 +51,7 @@ class AssetsManager {
|
|
|
56
51
|
watchAssets: typeof item !== 'string' ? item.watchAssets : undefined,
|
|
57
52
|
};
|
|
58
53
|
});
|
|
59
|
-
const isWatchEnabled =
|
|
54
|
+
const isWatchEnabled = getValueOrDefault(configuration, 'compilerOptions.watchAssets', appName) || watchAssetsMode;
|
|
60
55
|
for (const item of filesToCopy) {
|
|
61
56
|
const option = {
|
|
62
57
|
action: 'change',
|
|
@@ -68,7 +63,7 @@ class AssetsManager {
|
|
|
68
63
|
if (isWatchEnabled || item.watchAssets) {
|
|
69
64
|
// prettier-ignore
|
|
70
65
|
const watcher = chokidar
|
|
71
|
-
.watch(
|
|
66
|
+
.watch(sync(item.glob, {
|
|
72
67
|
ignore: item.exclude,
|
|
73
68
|
dot: true,
|
|
74
69
|
}))
|
|
@@ -78,17 +73,17 @@ class AssetsManager {
|
|
|
78
73
|
this.watchers.push(watcher);
|
|
79
74
|
}
|
|
80
75
|
else {
|
|
81
|
-
const matchedPaths =
|
|
76
|
+
const matchedPaths = sync(item.glob, {
|
|
82
77
|
ignore: item.exclude,
|
|
83
78
|
dot: true,
|
|
84
79
|
});
|
|
85
80
|
const files = item.glob.endsWith('*')
|
|
86
|
-
? matchedPaths.filter((matched) =>
|
|
81
|
+
? matchedPaths.filter((matched) => statSync(matched).isFile())
|
|
87
82
|
: matchedPaths.flatMap((matched) => {
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
83
|
+
if (statSync(matched).isDirectory()) {
|
|
84
|
+
return sync(`${matched}/**/*`, {
|
|
90
85
|
ignore: item.exclude,
|
|
91
|
-
}).filter((file) =>
|
|
86
|
+
}).filter((file) => statSync(file).isFile());
|
|
92
87
|
}
|
|
93
88
|
return matched;
|
|
94
89
|
});
|
|
@@ -99,7 +94,7 @@ class AssetsManager {
|
|
|
99
94
|
}
|
|
100
95
|
}
|
|
101
96
|
catch (err) {
|
|
102
|
-
throw new Error(`An error occurred during the assets copying process. ${err.message}
|
|
97
|
+
throw new Error(`An error occurred during the assets copying process. ${err.message}`, { cause: err });
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
100
|
actionOnFile(option) {
|
|
@@ -114,16 +109,15 @@ class AssetsManager {
|
|
|
114
109
|
this.watchAssetsKeyValue[assetCheckKey] = true;
|
|
115
110
|
// Set action to true to avoid watches getting cutoff
|
|
116
111
|
this.actionInProgress = true;
|
|
117
|
-
const dest =
|
|
112
|
+
const dest = copyPathResolve(path, item.outDir, sourceRoot.split(sep).length);
|
|
118
113
|
// Copy to output dir if file is changed or added
|
|
119
114
|
if (action === 'change') {
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
116
|
+
copyFileSync(path, dest);
|
|
122
117
|
}
|
|
123
118
|
else if (action === 'unlink') {
|
|
124
119
|
// Remove from output dir if file is deleted
|
|
125
|
-
|
|
120
|
+
rmSync(dest, { force: true });
|
|
126
121
|
}
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
|
-
exports.AssetsManager = AssetsManager;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Configuration } from '../configuration';
|
|
2
|
-
import { PluginsLoader } from './plugins/plugins-loader';
|
|
1
|
+
import { Configuration } from '../configuration/index.js';
|
|
2
|
+
import { PluginsLoader } from './plugins/plugins-loader.js';
|
|
3
3
|
export declare abstract class BaseCompiler<T = Record<string, any>> {
|
|
4
4
|
private readonly pluginsLoader;
|
|
5
5
|
constructor(pluginsLoader: PluginsLoader);
|
|
6
|
-
abstract run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras?: T, onSuccess?: () => void):
|
|
7
|
-
loadPlugins(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined): import("./plugins/plugins-loader").MultiNestCompilerPlugins;
|
|
8
|
-
getPathToSource(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined): string;
|
|
6
|
+
abstract run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras?: T, onSuccess?: () => void): void | Promise<void>;
|
|
7
|
+
protected loadPlugins(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined): import("./plugins/plugins-loader.js").MultiNestCompilerPlugins;
|
|
8
|
+
protected getPathToSource(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined): string;
|
|
9
9
|
}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const get_value_or_default_1 = require("./helpers/get-value-or-default");
|
|
6
|
-
class BaseCompiler {
|
|
1
|
+
import { dirname, join, normalize, relative } from 'path';
|
|
2
|
+
import { getValueOrDefault } from './helpers/get-value-or-default.js';
|
|
3
|
+
export class BaseCompiler {
|
|
4
|
+
pluginsLoader;
|
|
7
5
|
constructor(pluginsLoader) {
|
|
8
6
|
this.pluginsLoader = pluginsLoader;
|
|
9
7
|
}
|
|
10
8
|
loadPlugins(configuration, tsConfigPath, appName) {
|
|
11
|
-
const pluginsConfig =
|
|
9
|
+
const pluginsConfig = getValueOrDefault(configuration, 'compilerOptions.plugins', appName);
|
|
12
10
|
const pathToSource = this.getPathToSource(configuration, tsConfigPath, appName);
|
|
13
11
|
const plugins = this.pluginsLoader.load(pluginsConfig, { pathToSource });
|
|
14
12
|
return plugins;
|
|
15
13
|
}
|
|
16
14
|
getPathToSource(configuration, tsConfigPath, appName) {
|
|
17
|
-
const sourceRoot =
|
|
15
|
+
const sourceRoot = getValueOrDefault(configuration, 'sourceRoot', appName, 'sourceRoot');
|
|
18
16
|
const cwd = process.cwd();
|
|
19
|
-
const relativeRootPath =
|
|
20
|
-
const pathToSource =
|
|
21
|
-
?
|
|
22
|
-
:
|
|
17
|
+
const relativeRootPath = dirname(relative(cwd, tsConfigPath));
|
|
18
|
+
const pathToSource = normalize(sourceRoot).indexOf(normalize(relativeRootPath)) >= 0
|
|
19
|
+
? join(cwd, sourceRoot)
|
|
20
|
+
: join(cwd, relativeRootPath, sourceRoot);
|
|
23
21
|
return pathToSource;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
exports.BaseCompiler = BaseCompiler;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Configuration } from '../configuration';
|
|
2
|
-
import { BaseCompiler } from './base-compiler';
|
|
3
|
-
import { TsConfigProvider } from './helpers/tsconfig-provider';
|
|
4
|
-
import { PluginsLoader } from './plugins/plugins-loader';
|
|
5
|
-
import { TypeScriptBinaryLoader } from './typescript-loader';
|
|
1
|
+
import { Configuration } from '../configuration/index.js';
|
|
2
|
+
import { BaseCompiler } from './base-compiler.js';
|
|
3
|
+
import { TsConfigProvider } from './helpers/tsconfig-provider.js';
|
|
4
|
+
import { PluginsLoader } from './plugins/plugins-loader.js';
|
|
5
|
+
import { TypeScriptBinaryLoader } from './typescript-loader.js';
|
|
6
6
|
export declare class Compiler extends BaseCompiler {
|
|
7
7
|
private readonly tsConfigProvider;
|
|
8
8
|
private readonly typescriptLoader;
|
|
9
9
|
constructor(pluginsLoader: PluginsLoader, tsConfigProvider: TsConfigProvider, typescriptLoader: TypeScriptBinaryLoader);
|
|
10
|
-
run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, _extras:
|
|
10
|
+
run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, _extras: unknown, onSuccess?: () => void): void;
|
|
11
11
|
private reportAfterCompilationDiagnostic;
|
|
12
12
|
}
|