@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,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class TypeCheckerHost {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.typescriptLoader = new typescript_loader_1.TypeScriptBinaryLoader();
|
|
13
|
-
this.tsConfigProvider = new tsconfig_provider_1.TsConfigProvider(this.typescriptLoader);
|
|
14
|
-
}
|
|
1
|
+
import { red } from 'ansis';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
|
+
import { TsConfigProvider } from '../helpers/tsconfig-provider.js';
|
|
5
|
+
import { TypeScriptBinaryLoader } from '../typescript-loader.js';
|
|
6
|
+
import { INITIALIZING_TYPE_CHECKER, TSC_LOG_ERROR_PREFIX, TSC_NO_ERRORS_MESSAGE, } from './constants.js';
|
|
7
|
+
export class TypeCheckerHost {
|
|
8
|
+
typescriptLoader = new TypeScriptBinaryLoader();
|
|
9
|
+
tsConfigProvider = new TsConfigProvider(this.typescriptLoader);
|
|
15
10
|
run(tsconfigPath, options) {
|
|
16
11
|
if (!tsconfigPath) {
|
|
17
12
|
throw new Error('"tsconfigPath" is required when "tsProgramRef" is not provided.');
|
|
18
13
|
}
|
|
19
14
|
const tsBinary = this.typescriptLoader.load();
|
|
20
15
|
const spinner = ora({
|
|
21
|
-
text:
|
|
16
|
+
text: INITIALIZING_TYPE_CHECKER,
|
|
22
17
|
});
|
|
23
18
|
if (options.watch) {
|
|
24
19
|
console.log();
|
|
@@ -35,9 +30,9 @@ class TypeCheckerHost {
|
|
|
35
30
|
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(tsconfigPath);
|
|
36
31
|
let builderProgram = undefined;
|
|
37
32
|
const reportWatchStatusCallback = (diagnostic) => {
|
|
38
|
-
if (diagnostic.messageText !==
|
|
33
|
+
if (diagnostic.messageText !== TSC_NO_ERRORS_MESSAGE) {
|
|
39
34
|
if (diagnostic.messageText?.includes('Found')) {
|
|
40
|
-
console.
|
|
35
|
+
console.error(TSC_LOG_ERROR_PREFIX, red(diagnostic.messageText.toString()));
|
|
41
36
|
}
|
|
42
37
|
return;
|
|
43
38
|
}
|
|
@@ -87,4 +82,3 @@ class TypeCheckerHost {
|
|
|
87
82
|
return tsBinary.createWatchCompilerHost(tsConfigPath, tsOptions, tsBinary.sys, undefined, origDiagnosticReporter, reportWatchStatusCallback);
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
|
-
exports.TypeCheckerHost = TypeCheckerHost;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
export class TypeScriptBinaryLoader {
|
|
4
|
+
tsBinary;
|
|
5
5
|
load() {
|
|
6
6
|
if (this.tsBinary) {
|
|
7
7
|
return this.tsBinary;
|
|
@@ -10,7 +10,6 @@ class TypeScriptBinaryLoader {
|
|
|
10
10
|
const tsBinaryPath = require.resolve('typescript', {
|
|
11
11
|
paths: [process.cwd(), ...this.getModulePaths()],
|
|
12
12
|
});
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
13
|
const tsBinary = require(tsBinaryPath);
|
|
15
14
|
this.tsBinary = tsBinary;
|
|
16
15
|
return tsBinary;
|
|
@@ -20,7 +19,7 @@ class TypeScriptBinaryLoader {
|
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
getModulePaths() {
|
|
23
|
-
const modulePaths =
|
|
22
|
+
const modulePaths = require.resolve.paths('typescript') ?? [];
|
|
24
23
|
const packageDeps = modulePaths.slice(0, 3);
|
|
25
24
|
return [
|
|
26
25
|
...packageDeps.reverse(),
|
|
@@ -28,4 +27,3 @@ class TypeScriptBinaryLoader {
|
|
|
28
27
|
];
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
exports.TypeScriptBinaryLoader = TypeScriptBinaryLoader;
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
type TypescriptWatchCompilerExtras = {
|
|
7
7
|
/**
|
|
8
8
|
* If `undefined`, the value of 'preserveWatchOutput' option from tsconfig
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class WatchCompiler extends base_compiler_1.BaseCompiler {
|
|
1
|
+
import { CLI_ERRORS } from '../ui/errors.js';
|
|
2
|
+
import { BaseCompiler } from './base-compiler.js';
|
|
3
|
+
import { getValueOrDefault } from './helpers/get-value-or-default.js';
|
|
4
|
+
import { displayManualRestartTip, listenForManualRestart, } from './helpers/manual-restart.js';
|
|
5
|
+
import { tsconfigPathsBeforeHookFactory } from './hooks/tsconfig-paths.hook.js';
|
|
6
|
+
export class WatchCompiler extends BaseCompiler {
|
|
7
|
+
tsConfigProvider;
|
|
8
|
+
typescriptLoader;
|
|
10
9
|
constructor(pluginsLoader, tsConfigProvider, typescriptLoader) {
|
|
11
10
|
super(pluginsLoader);
|
|
12
11
|
this.tsConfigProvider = tsConfigProvider;
|
|
@@ -16,7 +15,7 @@ class WatchCompiler extends base_compiler_1.BaseCompiler {
|
|
|
16
15
|
const tsBin = this.typescriptLoader.load();
|
|
17
16
|
const configPath = tsBin.findConfigFile(process.cwd(), tsBin.sys.fileExists, tsConfigPath);
|
|
18
17
|
if (!configPath) {
|
|
19
|
-
throw new Error(
|
|
18
|
+
throw new Error(CLI_ERRORS.MISSING_TYPESCRIPT(tsConfigPath));
|
|
20
19
|
}
|
|
21
20
|
const { options, projectReferences } = this.tsConfigProvider.getByConfigFilename(tsConfigPath);
|
|
22
21
|
const createProgram = tsBin.createEmitAndSemanticDiagnosticsBuilderProgram;
|
|
@@ -26,12 +25,12 @@ class WatchCompiler extends base_compiler_1.BaseCompiler {
|
|
|
26
25
|
...options,
|
|
27
26
|
preserveWatchOutput: extras.preserveWatchOutput ?? options.preserveWatchOutput,
|
|
28
27
|
}, tsBin.sys, createProgram, this.createDiagnosticReporter(origDiagnosticReporter), this.createWatchStatusChanged(origWatchStatusReporter, onSuccess));
|
|
29
|
-
const manualRestart =
|
|
28
|
+
const manualRestart = getValueOrDefault(configuration, 'compilerOptions.manualRestart', appName);
|
|
30
29
|
const plugins = this.loadPlugins(configuration, tsConfigPath, appName);
|
|
31
30
|
this.overrideCreateProgramFn(host, manualRestart, projectReferences, plugins);
|
|
32
31
|
const watchProgram = tsBin.createWatchProgram(host);
|
|
33
32
|
if (manualRestart) {
|
|
34
|
-
|
|
33
|
+
listenForManualRestart(() => {
|
|
35
34
|
watchProgram.close();
|
|
36
35
|
this.run(configuration, tsConfigPath, appName, extras, onSuccess);
|
|
37
36
|
});
|
|
@@ -39,14 +38,12 @@ class WatchCompiler extends base_compiler_1.BaseCompiler {
|
|
|
39
38
|
}
|
|
40
39
|
overrideCreateProgramFn(host, manualRestart, projectReferences, plugins) {
|
|
41
40
|
const origCreateProgram = host.createProgram;
|
|
42
|
-
host.createProgram = (rootNames, options,
|
|
43
|
-
// tslint:disable-next-line:no-shadowed-variable
|
|
44
|
-
host, oldProgram) => {
|
|
41
|
+
host.createProgram = (rootNames, options, host, oldProgram) => {
|
|
45
42
|
if (manualRestart) {
|
|
46
|
-
|
|
43
|
+
displayManualRestartTip();
|
|
47
44
|
}
|
|
48
45
|
const tsconfigPathsPlugin = options
|
|
49
|
-
?
|
|
46
|
+
? tsconfigPathsBeforeHookFactory(options)
|
|
50
47
|
: null;
|
|
51
48
|
const program = origCreateProgram(rootNames, options, host, oldProgram, undefined, projectReferences);
|
|
52
49
|
const origProgramEmit = program.emit;
|
|
@@ -86,4 +83,3 @@ class WatchCompiler extends base_compiler_1.BaseCompiler {
|
|
|
86
83
|
};
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
|
-
exports.WatchCompiler = WatchCompiler;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import webpack = require('webpack');
|
|
1
|
+
import { Configuration } from '../configuration/index.js';
|
|
2
|
+
import { AssetsManager } from './assets-manager.js';
|
|
3
|
+
import { BaseCompiler } from './base-compiler.js';
|
|
4
|
+
import { PluginsLoader } from './plugins/plugins-loader.js';
|
|
5
|
+
import type webpack from 'webpack';
|
|
7
6
|
type WebpackConfigFactory = (config: webpack.Configuration, webpackRef: typeof webpack) => webpack.Configuration;
|
|
8
7
|
type WebpackConfigFactoryOrConfig = WebpackConfigFactory | webpack.Configuration;
|
|
9
8
|
type WebpackCompilerExtras = {
|
|
10
|
-
|
|
9
|
+
options: Record<string, any>;
|
|
11
10
|
assetsManager: AssetsManager;
|
|
12
11
|
webpackConfigFactoryOrConfig: WebpackConfigFactoryOrConfig | WebpackConfigFactoryOrConfig[];
|
|
13
12
|
debug?: boolean;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { INFO_PREFIX } from '../ui/index.js';
|
|
5
|
+
import { isEsmProject } from '../utils/is-esm-project.js';
|
|
6
|
+
import { BaseCompiler } from './base-compiler.js';
|
|
7
|
+
import { webpackDefaultsFactory } from './defaults/webpack-defaults.js';
|
|
8
|
+
import { getValueOrDefault } from './helpers/get-value-or-default.js';
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
function loadWebpack() {
|
|
11
|
+
try {
|
|
12
|
+
return require('webpack');
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error('webpack is not installed. To use the webpack compiler, install the required packages:\n\n' +
|
|
16
|
+
' npm install --save-dev webpack webpack-node-externals tsconfig-paths-webpack-plugin ts-loader\n');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class WebpackCompiler extends BaseCompiler {
|
|
12
20
|
constructor(pluginsLoader) {
|
|
13
21
|
super(pluginsLoader);
|
|
14
22
|
}
|
|
15
23
|
run(configuration, tsConfigPath, appName, extras, onSuccess) {
|
|
16
24
|
const cwd = process.cwd();
|
|
17
|
-
const configPath =
|
|
18
|
-
if (!
|
|
25
|
+
const configPath = join(cwd, tsConfigPath);
|
|
26
|
+
if (!existsSync(configPath)) {
|
|
19
27
|
throw new Error(`Could not find TypeScript configuration file "${tsConfigPath}".`);
|
|
20
28
|
}
|
|
21
29
|
const plugins = this.loadPlugins(configuration, tsConfigPath, appName);
|
|
22
30
|
const pathToSource = this.getPathToSource(configuration, tsConfigPath, appName);
|
|
23
|
-
const entryFile =
|
|
24
|
-
const entryFileRoot =
|
|
25
|
-
const defaultOptions =
|
|
31
|
+
const entryFile = getValueOrDefault(configuration, 'entryFile', appName, 'entryFile', extras.options);
|
|
32
|
+
const entryFileRoot = getValueOrDefault(configuration, 'root', appName) || '';
|
|
33
|
+
const defaultOptions = webpackDefaultsFactory(pathToSource, entryFileRoot, entryFile, extras.debug ?? false, tsConfigPath, plugins, isEsmProject());
|
|
34
|
+
const wp = loadWebpack();
|
|
26
35
|
let compiler;
|
|
27
36
|
let watchOptions;
|
|
28
37
|
let watch;
|
|
@@ -30,34 +39,34 @@ class WebpackCompiler extends base_compiler_1.BaseCompiler {
|
|
|
30
39
|
const webpackConfigurations = extras.webpackConfigFactoryOrConfig.map((configOrFactory) => {
|
|
31
40
|
const unwrappedConfig = typeof configOrFactory !== 'function'
|
|
32
41
|
? configOrFactory
|
|
33
|
-
: configOrFactory(defaultOptions,
|
|
42
|
+
: configOrFactory(defaultOptions, wp);
|
|
34
43
|
return {
|
|
35
44
|
...defaultOptions,
|
|
36
45
|
mode: extras.watchMode ? 'development' : defaultOptions.mode,
|
|
37
46
|
...unwrappedConfig,
|
|
38
47
|
};
|
|
39
48
|
});
|
|
40
|
-
compiler =
|
|
49
|
+
compiler = wp(webpackConfigurations);
|
|
41
50
|
watchOptions = webpackConfigurations.map((config) => config.watchOptions || {});
|
|
42
51
|
watch = webpackConfigurations.some((config) => config.watch);
|
|
43
52
|
}
|
|
44
53
|
else {
|
|
45
54
|
const projectWebpackOptions = typeof extras.webpackConfigFactoryOrConfig !== 'function'
|
|
46
55
|
? extras.webpackConfigFactoryOrConfig
|
|
47
|
-
: extras.webpackConfigFactoryOrConfig(defaultOptions,
|
|
56
|
+
: extras.webpackConfigFactoryOrConfig(defaultOptions, wp);
|
|
48
57
|
const webpackConfiguration = {
|
|
49
58
|
...defaultOptions,
|
|
50
59
|
mode: extras.watchMode ? 'development' : defaultOptions.mode,
|
|
51
60
|
...projectWebpackOptions,
|
|
52
61
|
};
|
|
53
|
-
compiler =
|
|
62
|
+
compiler = wp(webpackConfiguration);
|
|
54
63
|
watchOptions = webpackConfiguration.watchOptions;
|
|
55
64
|
watch = webpackConfiguration.watch;
|
|
56
65
|
}
|
|
57
66
|
const afterCallback = this.createAfterCallback(onSuccess, extras.assetsManager, extras.watchMode ?? false, watch);
|
|
58
67
|
if (extras.watchMode || watch) {
|
|
59
68
|
compiler.hooks.watchRun.tapAsync('Rebuild info', (params, callback) => {
|
|
60
|
-
console.log(`\n${
|
|
69
|
+
console.log(`\n${INFO_PREFIX} Webpack is building your sources...\n`);
|
|
61
70
|
callback();
|
|
62
71
|
});
|
|
63
72
|
compiler.watch(watchOptions || {}, afterCallback);
|
|
@@ -96,4 +105,3 @@ class WebpackCompiler extends base_compiler_1.BaseCompiler {
|
|
|
96
105
|
};
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
|
-
exports.WebpackCompiler = WebpackCompiler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Asset =
|
|
1
|
+
export type Asset = string | AssetEntry;
|
|
2
2
|
export interface AssetEntry {
|
|
3
3
|
glob: string;
|
|
4
4
|
include?: string;
|
|
@@ -27,13 +27,19 @@ export interface SwcBuilderOptions {
|
|
|
27
27
|
export interface WebpackBuilderOptions {
|
|
28
28
|
configPath?: string;
|
|
29
29
|
}
|
|
30
|
+
export interface RspackBuilderOptions {
|
|
31
|
+
configPath?: string;
|
|
32
|
+
}
|
|
30
33
|
export interface TscBuilderOptions {
|
|
31
34
|
configPath?: string;
|
|
32
35
|
}
|
|
33
|
-
export type BuilderVariant = 'tsc' | 'swc' | 'webpack';
|
|
36
|
+
export type BuilderVariant = 'tsc' | 'swc' | 'webpack' | 'rspack';
|
|
34
37
|
export type Builder = BuilderVariant | {
|
|
35
38
|
type: 'webpack';
|
|
36
39
|
options?: WebpackBuilderOptions;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'rspack';
|
|
42
|
+
options?: RspackBuilderOptions;
|
|
37
43
|
} | {
|
|
38
44
|
type: 'swc';
|
|
39
45
|
options?: SwcBuilderOptions;
|
|
@@ -59,7 +65,7 @@ export interface CompilerOptions {
|
|
|
59
65
|
}
|
|
60
66
|
export interface PluginOptions {
|
|
61
67
|
name: string;
|
|
62
|
-
options: Record<string, any
|
|
68
|
+
options: Record<string, any>;
|
|
63
69
|
}
|
|
64
70
|
export interface GenerateOptions {
|
|
65
71
|
spec?: boolean | Record<string, boolean>;
|
|
@@ -76,7 +82,6 @@ export interface ProjectConfiguration {
|
|
|
76
82
|
compilerOptions?: CompilerOptions;
|
|
77
83
|
}
|
|
78
84
|
export interface Configuration {
|
|
79
|
-
[key: string]: any;
|
|
80
85
|
language?: string;
|
|
81
86
|
collection?: string;
|
|
82
87
|
sourceRoot?: string;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Configuration } from './configuration';
|
|
1
|
+
import { Configuration } from './configuration.js';
|
|
2
2
|
export declare const defaultConfiguration: Required<Configuration>;
|
|
3
3
|
export declare const defaultTsconfigFilename: string;
|
|
4
4
|
export declare const defaultWebpackConfigFilename = "webpack.config.js";
|
|
5
|
+
export declare const defaultRspackConfigFilename = "rspack.config.js";
|
|
5
6
|
export declare const defaultOutDir = "dist";
|
|
6
7
|
export declare const defaultGitIgnore = "# compiled output\n/dist\n/node_modules\n/build\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\npnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# OS\n.DS_Store\n\n# Tests\n/coverage\n/.nyc_output\n\n# IDEs and editors\n/.idea\n.project\n.classpath\n.c9/\n*.launch\n.settings/\n*.sublime-workspace\n\n# IDE - VSCode\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json\n\n# dotenv environment variable files\n.env\n.env.development.local\n.env.test.local\n.env.production.local\n.env.local\n\n# temp directory\n.temp\n.tmp\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.defaultGitIgnore = exports.defaultOutDir = exports.defaultWebpackConfigFilename = exports.defaultTsconfigFilename = exports.defaultConfiguration = void 0;
|
|
4
|
-
const get_default_tsconfig_path_1 = require("../utils/get-default-tsconfig-path");
|
|
5
|
-
exports.defaultConfiguration = {
|
|
1
|
+
import { getDefaultTsconfigPath } from '../utils/get-default-tsconfig-path.js';
|
|
2
|
+
export const defaultConfiguration = {
|
|
6
3
|
language: 'ts',
|
|
7
4
|
sourceRoot: 'src',
|
|
8
5
|
collection: '@nestjs/schematics',
|
|
@@ -14,7 +11,7 @@ exports.defaultConfiguration = {
|
|
|
14
11
|
builder: {
|
|
15
12
|
type: 'tsc',
|
|
16
13
|
options: {
|
|
17
|
-
configPath:
|
|
14
|
+
configPath: getDefaultTsconfigPath(),
|
|
18
15
|
},
|
|
19
16
|
},
|
|
20
17
|
webpack: false,
|
|
@@ -24,10 +21,11 @@ exports.defaultConfiguration = {
|
|
|
24
21
|
},
|
|
25
22
|
generateOptions: {},
|
|
26
23
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
export const defaultTsconfigFilename = getDefaultTsconfigPath();
|
|
25
|
+
export const defaultWebpackConfigFilename = 'webpack.config.js';
|
|
26
|
+
export const defaultRspackConfigFilename = 'rspack.config.js';
|
|
27
|
+
export const defaultOutDir = 'dist';
|
|
28
|
+
export const defaultGitIgnore = `# compiled output
|
|
31
29
|
/dist
|
|
32
30
|
/node_modules
|
|
33
31
|
/build
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './configuration.loader';
|
|
2
|
-
export * from './nest-configuration.loader';
|
|
3
|
-
export * from './configuration';
|
|
1
|
+
export * from './configuration.loader.js';
|
|
2
|
+
export * from './nest-configuration.loader.js';
|
|
3
|
+
export * from './configuration.js';
|
|
@@ -1,19 +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("./configuration.loader"), exports);
|
|
18
|
-
__exportStar(require("./nest-configuration.loader"), exports);
|
|
19
|
-
__exportStar(require("./configuration"), exports);
|
|
1
|
+
export * from './configuration.loader.js';
|
|
2
|
+
export * from './nest-configuration.loader.js';
|
|
3
|
+
export * from './configuration.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Reader } from '../readers';
|
|
2
|
-
import { Configuration } from './configuration';
|
|
3
|
-
import { ConfigurationLoader } from './configuration.loader';
|
|
1
|
+
import { Reader } from '../readers/index.js';
|
|
2
|
+
import { Configuration } from './configuration.js';
|
|
3
|
+
import { ConfigurationLoader } from './configuration.loader.js';
|
|
4
4
|
export declare class NestConfigurationLoader implements ConfigurationLoader {
|
|
5
5
|
private readonly reader;
|
|
6
6
|
constructor(reader: Reader);
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NestConfigurationLoader = void 0;
|
|
4
|
-
const readers_1 = require("../readers");
|
|
5
|
-
const defaults_1 = require("./defaults");
|
|
1
|
+
import { ReaderFileLackPermissionsError } from '../readers/index.js';
|
|
2
|
+
import { defaultConfiguration } from './defaults.js';
|
|
6
3
|
/**
|
|
7
4
|
* A cache table that maps some reader (by its name along with the config path)
|
|
8
5
|
* to a loaded configuration.
|
|
9
6
|
* This was added because several commands relies on the app's config in order
|
|
10
|
-
* to generate some
|
|
7
|
+
* to generate some dynamic content prior running the command itself.
|
|
11
8
|
*/
|
|
12
9
|
const loadedConfigsCache = new Map();
|
|
13
|
-
class NestConfigurationLoader {
|
|
10
|
+
export class NestConfigurationLoader {
|
|
11
|
+
reader;
|
|
14
12
|
constructor(reader) {
|
|
15
13
|
this.reader = reader;
|
|
16
14
|
}
|
|
@@ -20,15 +18,12 @@ class NestConfigurationLoader {
|
|
|
20
18
|
if (cachedConfig) {
|
|
21
19
|
return cachedConfig;
|
|
22
20
|
}
|
|
23
|
-
let loadedConfig;
|
|
21
|
+
let loadedConfig = defaultConfiguration;
|
|
24
22
|
const contentOrError = name
|
|
25
23
|
? this.reader.read(name)
|
|
26
|
-
: this.reader.readAnyOf([
|
|
27
|
-
'nest-cli.json',
|
|
28
|
-
'.nest-cli.json',
|
|
29
|
-
]);
|
|
24
|
+
: this.reader.readAnyOf(['nest-cli.json', '.nest-cli.json']);
|
|
30
25
|
if (contentOrError) {
|
|
31
|
-
const isMissingPermissionsError = contentOrError instanceof
|
|
26
|
+
const isMissingPermissionsError = contentOrError instanceof ReaderFileLackPermissionsError;
|
|
32
27
|
if (isMissingPermissionsError) {
|
|
33
28
|
console.error(contentOrError.message);
|
|
34
29
|
process.exit(1);
|
|
@@ -36,26 +31,22 @@ class NestConfigurationLoader {
|
|
|
36
31
|
const fileConfig = JSON.parse(contentOrError);
|
|
37
32
|
if (fileConfig.compilerOptions) {
|
|
38
33
|
loadedConfig = {
|
|
39
|
-
...
|
|
34
|
+
...defaultConfiguration,
|
|
40
35
|
...fileConfig,
|
|
41
36
|
compilerOptions: {
|
|
42
|
-
...
|
|
37
|
+
...defaultConfiguration.compilerOptions,
|
|
43
38
|
...fileConfig.compilerOptions,
|
|
44
39
|
},
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
42
|
else {
|
|
48
43
|
loadedConfig = {
|
|
49
|
-
...
|
|
44
|
+
...defaultConfiguration,
|
|
50
45
|
...fileConfig,
|
|
51
46
|
};
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
|
-
else {
|
|
55
|
-
loadedConfig = defaults_1.defaultConfiguration;
|
|
56
|
-
}
|
|
57
49
|
loadedConfigsCache.set(cacheEntryKey, loadedConfig);
|
|
58
50
|
return loadedConfig;
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
|
-
exports.NestConfigurationLoader = NestConfigurationLoader;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractRunner } from '../runners/abstract.runner';
|
|
2
|
-
import { PackageManagerCommands } from './package-manager-commands';
|
|
3
|
-
import { ProjectDependency } from './project.dependency';
|
|
1
|
+
import { AbstractRunner } from '../runners/abstract.runner.js';
|
|
2
|
+
import { PackageManagerCommands } from './package-manager-commands.js';
|
|
3
|
+
import { ProjectDependency } from './project.dependency.js';
|
|
4
4
|
export declare abstract class AbstractPackageManager {
|
|
5
5
|
protected runner: AbstractRunner;
|
|
6
6
|
constructor(runner: AbstractRunner);
|
|
@@ -19,7 +19,7 @@ export declare abstract class AbstractPackageManager {
|
|
|
19
19
|
upgradeDevelopment(dependencies: string[], tag: string): Promise<void>;
|
|
20
20
|
deleteProduction(dependencies: string[]): Promise<void>;
|
|
21
21
|
deleteDevelopment(dependencies: string[]): Promise<void>;
|
|
22
|
-
delete
|
|
22
|
+
private delete;
|
|
23
23
|
abstract get name(): string;
|
|
24
24
|
abstract get cli(): PackageManagerCommands;
|
|
25
25
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const formatting_1 = require("../utils/formatting");
|
|
10
|
-
class AbstractPackageManager {
|
|
1
|
+
import { bold, gray, red } from 'ansis';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { MESSAGES } from '../ui/index.js';
|
|
6
|
+
import { normalizeToKebabOrSnakeCase } from '../utils/formatting.js';
|
|
7
|
+
export class AbstractPackageManager {
|
|
8
|
+
runner;
|
|
11
9
|
constructor(runner) {
|
|
12
10
|
this.runner = runner;
|
|
13
11
|
}
|
|
@@ -17,28 +15,28 @@ class AbstractPackageManager {
|
|
|
17
15
|
interval: 120,
|
|
18
16
|
frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
|
|
19
17
|
},
|
|
20
|
-
text:
|
|
18
|
+
text: MESSAGES.PACKAGE_MANAGER_INSTALLATION_IN_PROGRESS,
|
|
21
19
|
});
|
|
22
20
|
spinner.start();
|
|
23
21
|
try {
|
|
24
22
|
const commandArgs = `${this.cli.install} ${this.cli.silentFlag}`;
|
|
25
23
|
const collect = true;
|
|
26
|
-
const normalizedDirectory =
|
|
27
|
-
await this.runner.run(commandArgs, collect,
|
|
24
|
+
const normalizedDirectory = normalizeToKebabOrSnakeCase(directory);
|
|
25
|
+
await this.runner.run(commandArgs, collect, join(process.cwd(), normalizedDirectory));
|
|
28
26
|
spinner.succeed();
|
|
29
27
|
console.info();
|
|
30
|
-
console.info(
|
|
31
|
-
console.info(
|
|
28
|
+
console.info(MESSAGES.PACKAGE_MANAGER_INSTALLATION_SUCCEED(directory));
|
|
29
|
+
console.info(MESSAGES.GET_STARTED_INFORMATION);
|
|
32
30
|
console.info();
|
|
33
|
-
console.info(
|
|
34
|
-
console.info(
|
|
31
|
+
console.info(gray(MESSAGES.CHANGE_DIR_COMMAND(directory)));
|
|
32
|
+
console.info(gray(MESSAGES.START_COMMAND(packageManager)));
|
|
35
33
|
console.info();
|
|
36
34
|
}
|
|
37
35
|
catch {
|
|
38
36
|
spinner.fail();
|
|
39
37
|
const commandArgs = this.cli.install;
|
|
40
38
|
const commandToRun = this.runner.rawFullCommand(commandArgs);
|
|
41
|
-
console.error(
|
|
39
|
+
console.error(red(MESSAGES.PACKAGE_MANAGER_INSTALLATION_FAILED(bold(commandToRun))));
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
async version() {
|
|
@@ -58,7 +56,7 @@ class AbstractPackageManager {
|
|
|
58
56
|
interval: 120,
|
|
59
57
|
frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
|
|
60
58
|
},
|
|
61
|
-
text:
|
|
59
|
+
text: MESSAGES.PACKAGE_MANAGER_PRODUCTION_INSTALLATION_IN_PROGRESS,
|
|
62
60
|
});
|
|
63
61
|
spinner.start();
|
|
64
62
|
try {
|
|
@@ -101,16 +99,8 @@ class AbstractPackageManager {
|
|
|
101
99
|
return dependencies;
|
|
102
100
|
}
|
|
103
101
|
async readPackageJson() {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (error !== undefined && error !== null) {
|
|
107
|
-
reject(error);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
resolve(JSON.parse(buffer.toString()));
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
102
|
+
const buffer = await readFile(join(process.cwd(), 'package.json'));
|
|
103
|
+
return JSON.parse(buffer.toString());
|
|
114
104
|
}
|
|
115
105
|
async updateProduction(dependencies) {
|
|
116
106
|
const commandArguments = `${this.cli.update} ${dependencies.join(' ')}`;
|
|
@@ -148,4 +138,3 @@ class AbstractPackageManager {
|
|
|
148
138
|
await this.runner.run(commandArguments, collect);
|
|
149
139
|
}
|
|
150
140
|
}
|
|
151
|
-
exports.AbstractPackageManager = AbstractPackageManager;
|