@nestjs/cli 11.0.15 → 12.0.0-alpha.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/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 +117 -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 +2 -2
- package/lib/compiler/defaults/webpack-defaults.js +13 -16
- 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 +97 -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 +14 -18
- 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-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 +31 -33
package/actions/start.action.js
CHANGED
|
@@ -1,59 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const build_action_1 = require("./build.action");
|
|
15
|
-
class StartAction extends build_action_1.BuildAction {
|
|
16
|
-
async handle(commandInputs, commandOptions) {
|
|
1
|
+
import { red } from 'ansis';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path.js';
|
|
6
|
+
import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default.js';
|
|
7
|
+
import { defaultConfiguration, defaultOutDir, } from '../lib/configuration/defaults.js';
|
|
8
|
+
import { ERROR_PREFIX } from '../lib/ui/index.js';
|
|
9
|
+
import { treeKillSync as killProcessSync } from '../lib/utils/tree-kill.js';
|
|
10
|
+
import { assertNonArray } from '../lib/utils/type-assertions.js';
|
|
11
|
+
import { BuildAction } from './build.action.js';
|
|
12
|
+
export class StartAction extends BuildAction {
|
|
13
|
+
async handle(context) {
|
|
17
14
|
try {
|
|
18
|
-
const configFileName =
|
|
15
|
+
const configFileName = context.config;
|
|
19
16
|
const configuration = await this.loader.load(configFileName);
|
|
20
|
-
const appName =
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const isWatchAssetsEnabled = !!(watchAssetsModeOption && watchAssetsModeOption.value);
|
|
28
|
-
const debugFlag = debugModeOption && debugModeOption.value;
|
|
29
|
-
(0, type_assertions_1.assertNonArray)(debugFlag);
|
|
30
|
-
const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', commandOptions, defaults_1.defaultConfiguration.exec);
|
|
17
|
+
const appName = context.app;
|
|
18
|
+
const pathToTsconfig = getTscConfigPath(configuration, context, appName);
|
|
19
|
+
const isWatchEnabled = !!context.watch;
|
|
20
|
+
const isWatchAssetsEnabled = !!context.watchAssets;
|
|
21
|
+
const debugFlag = context.debug;
|
|
22
|
+
assertNonArray(debugFlag);
|
|
23
|
+
const binaryToRun = getValueOrDefault(configuration, 'exec', appName, 'exec', context, defaultConfiguration.exec);
|
|
31
24
|
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
|
|
32
|
-
const outDir = tsOptions.outDir ||
|
|
33
|
-
const entryFile =
|
|
34
|
-
const sourceRoot =
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const envFileOption = commandOptions.find((option) => option.name === 'envFile');
|
|
38
|
-
const envFile = (envFileOption?.value ?? []);
|
|
25
|
+
const outDir = tsOptions.outDir || defaultOutDir;
|
|
26
|
+
const entryFile = getValueOrDefault(configuration, 'entryFile', appName, 'entryFile', context, defaultConfiguration.entryFile);
|
|
27
|
+
const sourceRoot = getValueOrDefault(configuration, 'sourceRoot', appName, 'sourceRoot', context, defaultConfiguration.sourceRoot);
|
|
28
|
+
const useShell = !!context.shell;
|
|
29
|
+
const envFile = context.envFile ?? [];
|
|
39
30
|
const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, {
|
|
40
31
|
shell: useShell,
|
|
41
32
|
envFile,
|
|
42
33
|
});
|
|
43
|
-
await this.runBuild(
|
|
34
|
+
await this.runBuild(appName ? [appName] : [], context, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
|
|
44
35
|
}
|
|
45
36
|
catch (err) {
|
|
46
37
|
if (err instanceof Error) {
|
|
47
|
-
console.
|
|
38
|
+
console.error(`\n${ERROR_PREFIX} ${err.message}\n`);
|
|
48
39
|
}
|
|
49
40
|
else {
|
|
50
|
-
console.error(`\n${
|
|
41
|
+
console.error(`\n${red(err)}\n`);
|
|
51
42
|
}
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
45
|
createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, options) {
|
|
55
46
|
let childProcessRef;
|
|
56
|
-
process.on('exit', () => childProcessRef && (
|
|
47
|
+
process.on('exit', () => childProcessRef && killProcessSync(childProcessRef.pid));
|
|
57
48
|
return () => {
|
|
58
49
|
if (childProcessRef) {
|
|
59
50
|
childProcessRef.removeAllListeners('exit');
|
|
@@ -64,8 +55,8 @@ class StartAction extends build_action_1.BuildAction {
|
|
|
64
55
|
});
|
|
65
56
|
childProcessRef.on('exit', () => (childProcessRef = undefined));
|
|
66
57
|
});
|
|
67
|
-
childProcessRef.stdin
|
|
68
|
-
(
|
|
58
|
+
childProcessRef.stdin?.pause?.();
|
|
59
|
+
killProcessSync(childProcessRef.pid);
|
|
69
60
|
}
|
|
70
61
|
else {
|
|
71
62
|
childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
|
|
@@ -80,9 +71,9 @@ class StartAction extends build_action_1.BuildAction {
|
|
|
80
71
|
};
|
|
81
72
|
}
|
|
82
73
|
spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, options) {
|
|
83
|
-
let outputFilePath =
|
|
74
|
+
let outputFilePath = join(outDirName, sourceRoot, entryFile);
|
|
84
75
|
if (!fs.existsSync(outputFilePath + '.js')) {
|
|
85
|
-
outputFilePath =
|
|
76
|
+
outputFilePath = join(outDirName, entryFile);
|
|
86
77
|
}
|
|
87
78
|
let childProcessArgs = [];
|
|
88
79
|
const argsStartIndex = process.argv.indexOf('--');
|
|
@@ -114,9 +105,8 @@ class StartAction extends build_action_1.BuildAction {
|
|
|
114
105
|
};
|
|
115
106
|
if (options.shell) {
|
|
116
107
|
const command = [binaryToRun, ...processArgs].join(' ');
|
|
117
|
-
return
|
|
108
|
+
return spawn(command, spawnOptions);
|
|
118
109
|
}
|
|
119
|
-
return
|
|
110
|
+
return spawn(binaryToRun, processArgs, spawnOptions);
|
|
120
111
|
}
|
|
121
112
|
}
|
|
122
|
-
exports.StartAction = StartAction;
|
package/bin/nest.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { CommandLoader } from '../commands/index.js';
|
|
7
|
+
import { loadLocalBinCommandLoader, localBinExists, } from '../lib/utils/local-binaries.js';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
7
11
|
const bootstrap = async () => {
|
|
8
|
-
const program =
|
|
12
|
+
const program = new Command();
|
|
9
13
|
program
|
|
10
14
|
.version(require('../package.json').version, '-v, --version', 'Output the current version.')
|
|
11
15
|
.usage('<command> [options]')
|
|
12
16
|
.helpOption('-h, --help', 'Output usage information.');
|
|
13
|
-
if (
|
|
14
|
-
const localCommandLoader =
|
|
17
|
+
if (localBinExists()) {
|
|
18
|
+
const localCommandLoader = loadLocalBinCommandLoader();
|
|
15
19
|
await localCommandLoader.load(program);
|
|
16
20
|
}
|
|
17
21
|
else {
|
|
18
|
-
await
|
|
22
|
+
await CommandLoader.load(program);
|
|
19
23
|
}
|
|
20
|
-
await
|
|
24
|
+
await program.parseAsync(process.argv);
|
|
21
25
|
if (!process.argv.slice(2).length) {
|
|
22
26
|
program.outputHelp();
|
|
23
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractAction } from '../actions/abstract.action';
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AbstractAction } from '../actions/abstract.action.js';
|
|
3
3
|
export declare abstract class AbstractCommand {
|
|
4
4
|
protected action: AbstractAction;
|
|
5
5
|
constructor(action: AbstractAction);
|
|
6
|
-
abstract load(program:
|
|
6
|
+
abstract load(program: Command): void;
|
|
7
7
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AbstractCommand = void 0;
|
|
4
|
-
class AbstractCommand {
|
|
1
|
+
export class AbstractCommand {
|
|
2
|
+
action;
|
|
5
3
|
constructor(action) {
|
|
6
4
|
this.action = action;
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
|
-
exports.AbstractCommand = AbstractCommand;
|
|
@@ -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 AddCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): void;
|
|
5
5
|
}
|
package/commands/add.command.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
5
|
-
const abstract_command_1 = require("./abstract.command");
|
|
6
|
-
class AddCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { getRemainingFlags } from '../lib/utils/remaining-flags.js';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
|
+
export class AddCommand extends AbstractCommand {
|
|
7
4
|
load(program) {
|
|
8
5
|
program
|
|
9
6
|
.command('add <library>')
|
|
@@ -13,24 +10,20 @@ class AddCommand extends abstract_command_1.AbstractCommand {
|
|
|
13
10
|
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
14
11
|
.option('-p, --project [project]', 'Project in which to generate files.')
|
|
15
12
|
.usage('<library> [options] [library-specific-options]')
|
|
16
|
-
.action(async (library,
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
const inputs = [];
|
|
25
|
-
inputs.push({ name: 'library', value: library });
|
|
26
|
-
const flags = (0, remaining_flags_1.getRemainingFlags)(program);
|
|
13
|
+
.action(async (library, options) => {
|
|
14
|
+
const context = {
|
|
15
|
+
library,
|
|
16
|
+
dryRun: !!options.dryRun,
|
|
17
|
+
skipInstall: options.skipInstall,
|
|
18
|
+
project: options.project,
|
|
19
|
+
extraFlags: getRemainingFlags(program),
|
|
20
|
+
};
|
|
27
21
|
try {
|
|
28
|
-
await this.action.handle(
|
|
22
|
+
await this.action.handle(context);
|
|
29
23
|
}
|
|
30
|
-
catch
|
|
24
|
+
catch {
|
|
31
25
|
process.exit(1);
|
|
32
26
|
}
|
|
33
27
|
});
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
exports.AddCommand = AddCommand;
|
|
@@ -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 BuildCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): void;
|
|
5
5
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ui_1 = require("../lib/ui");
|
|
5
|
-
const abstract_command_1 = require("./abstract.command");
|
|
6
|
-
class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
1
|
+
import { ERROR_PREFIX } from '../lib/ui/index.js';
|
|
2
|
+
import { AbstractCommand } from './abstract.command.js';
|
|
3
|
+
export class BuildCommand extends AbstractCommand {
|
|
7
4
|
load(program) {
|
|
8
5
|
program
|
|
9
6
|
.command('build [apps...]')
|
|
10
7
|
.option('-c, --config [path]', 'Path to nest-cli configuration file.')
|
|
11
8
|
.option('-p, --path [path]', 'Path to tsconfig file.')
|
|
12
9
|
.option('-w, --watch', 'Run in watch mode (live-reload).')
|
|
13
|
-
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
|
|
10
|
+
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc, rspack).')
|
|
14
11
|
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
|
|
15
12
|
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).')
|
|
16
13
|
.option('--type-check', 'Enable type checking (when SWC is used).')
|
|
@@ -19,56 +16,30 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
|
19
16
|
.option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
|
|
20
17
|
.option('--all', 'Build all projects in a monorepo.')
|
|
21
18
|
.description('Build Nest application.')
|
|
22
|
-
.action(async (apps,
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const isWebpackEnabled = command.tsc ? false : command.webpack;
|
|
29
|
-
options.push({ name: 'webpack', value: isWebpackEnabled });
|
|
30
|
-
options.push({ name: 'watch', value: !!command.watch });
|
|
31
|
-
options.push({ name: 'watchAssets', value: !!command.watchAssets });
|
|
32
|
-
options.push({
|
|
33
|
-
name: 'path',
|
|
34
|
-
value: command.path,
|
|
35
|
-
});
|
|
36
|
-
options.push({
|
|
37
|
-
name: 'webpackPath',
|
|
38
|
-
value: command.webpackPath,
|
|
39
|
-
});
|
|
40
|
-
const availableBuilders = ['tsc', 'webpack', 'swc'];
|
|
41
|
-
if (command.builder && !availableBuilders.includes(command.builder)) {
|
|
42
|
-
console.error(ui_1.ERROR_PREFIX +
|
|
43
|
-
` Invalid builder option: ${command.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
19
|
+
.action(async (apps, options) => {
|
|
20
|
+
const isWebpackEnabled = options.tsc ? false : options.webpack;
|
|
21
|
+
const availableBuilders = ['tsc', 'webpack', 'swc', 'rspack'];
|
|
22
|
+
if (options.builder && !availableBuilders.includes(options.builder)) {
|
|
23
|
+
console.error(ERROR_PREFIX +
|
|
24
|
+
` Invalid builder option: ${options.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
44
25
|
return;
|
|
45
26
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
!!
|
|
27
|
+
const context = {
|
|
28
|
+
apps: apps.length > 0 ? apps : [],
|
|
29
|
+
config: options.config,
|
|
30
|
+
webpack: isWebpackEnabled,
|
|
31
|
+
watch: !!options.watch,
|
|
32
|
+
watchAssets: !!options.watchAssets,
|
|
33
|
+
path: options.path,
|
|
34
|
+
webpackPath: options.webpackPath,
|
|
35
|
+
builder: options.builder,
|
|
36
|
+
typeCheck: options.typeCheck,
|
|
37
|
+
preserveWatchOutput: !!options.preserveWatchOutput &&
|
|
38
|
+
!!options.watch &&
|
|
58
39
|
!isWebpackEnabled,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
name: 'app',
|
|
63
|
-
value: app,
|
|
64
|
-
}));
|
|
65
|
-
// Handle the default project for `nest build` with no args
|
|
66
|
-
// The action instance will pick up the default project when value is `undefined`
|
|
67
|
-
if (inputs.length === 0) {
|
|
68
|
-
inputs.push({ name: 'app', value: undefined });
|
|
69
|
-
}
|
|
70
|
-
await this.action.handle(inputs, options);
|
|
40
|
+
all: !!options.all,
|
|
41
|
+
};
|
|
42
|
+
await this.action.handle(context);
|
|
71
43
|
});
|
|
72
44
|
}
|
|
73
45
|
}
|
|
74
|
-
exports.BuildCommand = BuildCommand;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from 'commander';
|
|
2
2
|
export declare class CommandLoader {
|
|
3
|
-
static load(program:
|
|
3
|
+
static load(program: Command): Promise<void>;
|
|
4
4
|
private static handleInvalidCommand;
|
|
5
5
|
}
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const new_command_1 = require("./new.command");
|
|
12
|
-
const start_command_1 = require("./start.command");
|
|
13
|
-
class CommandLoader {
|
|
1
|
+
import { red } from 'ansis';
|
|
2
|
+
import { AddAction, BuildAction, GenerateAction, InfoAction, NewAction, StartAction, } from '../actions/index.js';
|
|
3
|
+
import { ERROR_PREFIX } from '../lib/ui/index.js';
|
|
4
|
+
import { AddCommand } from './add.command.js';
|
|
5
|
+
import { BuildCommand } from './build.command.js';
|
|
6
|
+
import { GenerateCommand } from './generate.command.js';
|
|
7
|
+
import { InfoCommand } from './info.command.js';
|
|
8
|
+
import { NewCommand } from './new.command.js';
|
|
9
|
+
import { StartCommand } from './start.command.js';
|
|
10
|
+
export class CommandLoader {
|
|
14
11
|
static async load(program) {
|
|
15
|
-
new
|
|
16
|
-
new
|
|
17
|
-
new
|
|
18
|
-
new
|
|
19
|
-
new
|
|
20
|
-
await new
|
|
12
|
+
new NewCommand(new NewAction()).load(program);
|
|
13
|
+
new BuildCommand(new BuildAction()).load(program);
|
|
14
|
+
new StartCommand(new StartAction()).load(program);
|
|
15
|
+
new InfoCommand(new InfoAction()).load(program);
|
|
16
|
+
new AddCommand(new AddAction()).load(program);
|
|
17
|
+
await new GenerateCommand(new GenerateAction()).load(program);
|
|
21
18
|
this.handleInvalidCommand(program);
|
|
22
19
|
}
|
|
23
20
|
static handleInvalidCommand(program) {
|
|
24
21
|
program.on('command:*', () => {
|
|
25
|
-
console.error(`\n${
|
|
26
|
-
console.
|
|
22
|
+
console.error(`\n${ERROR_PREFIX} Invalid command: ${red `%s`}`, program.args.join(' '));
|
|
23
|
+
console.error(`See ${red `--help`} for a list of available commands.\n`);
|
|
27
24
|
process.exit(1);
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
exports.CommandLoader = CommandLoader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BuildCommandContext {
|
|
2
|
+
apps: string[];
|
|
3
|
+
config?: string;
|
|
4
|
+
webpack?: boolean;
|
|
5
|
+
watch: boolean;
|
|
6
|
+
watchAssets: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
webpackPath?: string;
|
|
9
|
+
builder?: string;
|
|
10
|
+
typeCheck?: boolean;
|
|
11
|
+
preserveWatchOutput: boolean;
|
|
12
|
+
all: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface GenerateCommandContext {
|
|
2
|
+
schematic: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
dryRun: boolean;
|
|
6
|
+
flat?: boolean;
|
|
7
|
+
spec: boolean | {
|
|
8
|
+
value: boolean;
|
|
9
|
+
passedAsInput: boolean;
|
|
10
|
+
};
|
|
11
|
+
specFileSuffix?: string;
|
|
12
|
+
collection?: string;
|
|
13
|
+
project?: string;
|
|
14
|
+
skipImport: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface StartCommandContext {
|
|
2
|
+
app?: string;
|
|
3
|
+
config?: string;
|
|
4
|
+
webpack?: boolean;
|
|
5
|
+
watch: boolean;
|
|
6
|
+
watchAssets: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
webpackPath?: string;
|
|
9
|
+
builder?: string;
|
|
10
|
+
typeCheck?: boolean;
|
|
11
|
+
preserveWatchOutput: boolean;
|
|
12
|
+
debug?: boolean | string;
|
|
13
|
+
exec?: string;
|
|
14
|
+
sourceRoot?: string;
|
|
15
|
+
entryFile?: string;
|
|
16
|
+
shell: boolean;
|
|
17
|
+
envFile: string[];
|
|
18
|
+
extraFlags: string[];
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
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 GenerateCommand extends AbstractCommand {
|
|
4
|
-
load(program:
|
|
4
|
+
load(program: Command): Promise<void>;
|
|
5
5
|
private buildDescription;
|
|
6
6
|
private buildSchematicsListAsTable;
|
|
7
7
|
private getCollection;
|