@depup/nestjs__cli 11.0.16-depup.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/LICENSE +24 -0
- package/README.md +42 -0
- package/actions/abstract.action.d.ts +4 -0
- package/actions/abstract.action.js +6 -0
- package/actions/add.action.d.ts +12 -0
- package/actions/add.action.js +113 -0
- package/actions/build.action.d.ts +22 -0
- package/actions/build.action.js +145 -0
- package/actions/generate.action.d.ts +5 -0
- package/actions/generate.action.js +97 -0
- package/actions/index.d.ts +7 -0
- package/actions/index.js +23 -0
- package/actions/info.action.d.ts +35 -0
- package/actions/info.action.js +181 -0
- package/actions/new.action.d.ts +7 -0
- package/actions/new.action.js +186 -0
- package/actions/start.action.d.ts +10 -0
- package/actions/start.action.js +122 -0
- package/bin/nest.d.ts +2 -0
- package/bin/nest.js +25 -0
- package/changes.json +54 -0
- package/commands/abstract.command.d.ts +7 -0
- package/commands/abstract.command.js +9 -0
- package/commands/add.command.d.ts +5 -0
- package/commands/add.command.js +36 -0
- package/commands/build.command.d.ts +5 -0
- package/commands/build.command.js +74 -0
- package/commands/command.input.d.ts +5 -0
- package/commands/command.input.js +2 -0
- package/commands/command.loader.d.ts +5 -0
- package/commands/command.loader.js +31 -0
- package/commands/generate.command.d.ts +9 -0
- package/commands/generate.command.js +107 -0
- package/commands/index.d.ts +2 -0
- package/commands/index.js +18 -0
- package/commands/info.command.d.ts +5 -0
- package/commands/info.command.js +16 -0
- package/commands/new.command.d.ts +5 -0
- package/commands/new.command.js +61 -0
- package/commands/start.command.d.ts +5 -0
- package/commands/start.command.js +104 -0
- package/lib/compiler/assets-manager.d.ts +15 -0
- package/lib/compiler/assets-manager.js +129 -0
- package/lib/compiler/base-compiler.d.ts +9 -0
- package/lib/compiler/base-compiler.js +26 -0
- package/lib/compiler/compiler.d.ts +12 -0
- package/lib/compiler/compiler.js +61 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +61 -0
- package/lib/compiler/defaults/swc-defaults.js +57 -0
- package/lib/compiler/defaults/webpack-defaults.d.ts +3 -0
- package/lib/compiler/defaults/webpack-defaults.js +104 -0
- package/lib/compiler/helpers/append-extension.d.ts +1 -0
- package/lib/compiler/helpers/append-extension.js +7 -0
- package/lib/compiler/helpers/copy-path-resolve.d.ts +7 -0
- package/lib/compiler/helpers/copy-path-resolve.js +25 -0
- package/lib/compiler/helpers/delete-out-dir.d.ts +2 -0
- package/lib/compiler/helpers/delete-out-dir.js +12 -0
- package/lib/compiler/helpers/get-builder.d.ts +21 -0
- package/lib/compiler/helpers/get-builder.js +19 -0
- package/lib/compiler/helpers/get-tsc-config.path.d.ts +10 -0
- package/lib/compiler/helpers/get-tsc-config.path.js +24 -0
- package/lib/compiler/helpers/get-value-or-default.d.ts +4 -0
- package/lib/compiler/helpers/get-value-or-default.js +66 -0
- package/lib/compiler/helpers/get-webpack-config-path.d.ts +10 -0
- package/lib/compiler/helpers/get-webpack-config-path.js +23 -0
- package/lib/compiler/helpers/manual-restart.d.ts +2 -0
- package/lib/compiler/helpers/manual-restart.js +17 -0
- package/lib/compiler/helpers/tsconfig-provider.d.ts +11 -0
- package/lib/compiler/helpers/tsconfig-provider.js +22 -0
- package/lib/compiler/hooks/tsconfig-paths.hook.d.ts +2 -0
- package/lib/compiler/hooks/tsconfig-paths.hook.js +76 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +10 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.js +2 -0
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +58 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +84 -0
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +17 -0
- package/lib/compiler/plugins/plugin-metadata-printer.js +51 -0
- package/lib/compiler/plugins/plugins-loader.d.ts +30 -0
- package/lib/compiler/plugins/plugins-loader.js +70 -0
- package/lib/compiler/swc/constants.d.ts +9 -0
- package/lib/compiler/swc/constants.js +13 -0
- package/lib/compiler/swc/forked-type-checker.d.ts +1 -0
- package/lib/compiler/swc/forked-type-checker.js +63 -0
- package/lib/compiler/swc/swc-compiler.d.ts +25 -0
- package/lib/compiler/swc/swc-compiler.js +231 -0
- package/lib/compiler/swc/type-checker-host.d.ts +14 -0
- package/lib/compiler/swc/type-checker-host.js +90 -0
- package/lib/compiler/typescript-loader.d.ts +6 -0
- package/lib/compiler/typescript-loader.js +31 -0
- package/lib/compiler/watch-compiler.d.ts +22 -0
- package/lib/compiler/watch-compiler.js +89 -0
- package/lib/compiler/webpack-compiler.d.ts +21 -0
- package/lib/compiler/webpack-compiler.js +99 -0
- package/lib/configuration/configuration.d.ts +91 -0
- package/lib/configuration/configuration.js +2 -0
- package/lib/configuration/configuration.loader.d.ts +4 -0
- package/lib/configuration/configuration.loader.js +2 -0
- package/lib/configuration/defaults.d.ts +6 -0
- package/lib/configuration/defaults.js +86 -0
- package/lib/configuration/index.d.ts +3 -0
- package/lib/configuration/index.js +19 -0
- package/lib/configuration/nest-configuration.loader.d.ts +8 -0
- package/lib/configuration/nest-configuration.loader.js +61 -0
- package/lib/package-managers/abstract.package-manager.d.ts +25 -0
- package/lib/package-managers/abstract.package-manager.js +151 -0
- package/lib/package-managers/index.d.ts +8 -0
- package/lib/package-managers/index.js +24 -0
- package/lib/package-managers/npm.package-manager.d.ts +7 -0
- package/lib/package-managers/npm.package-manager.js +26 -0
- package/lib/package-managers/package-manager-commands.d.ts +9 -0
- package/lib/package-managers/package-manager-commands.js +2 -0
- package/lib/package-managers/package-manager.d.ts +5 -0
- package/lib/package-managers/package-manager.factory.d.ts +6 -0
- package/lib/package-managers/package-manager.factory.js +41 -0
- package/lib/package-managers/package-manager.js +9 -0
- package/lib/package-managers/pnpm.package-manager.d.ts +7 -0
- package/lib/package-managers/pnpm.package-manager.js +27 -0
- package/lib/package-managers/project.dependency.d.ts +4 -0
- package/lib/package-managers/project.dependency.js +2 -0
- package/lib/package-managers/yarn.package-manager.d.ts +7 -0
- package/lib/package-managers/yarn.package-manager.js +26 -0
- package/lib/questions/questions.d.ts +9 -0
- package/lib/questions/questions.js +27 -0
- package/lib/readers/file-system.reader.d.ts +8 -0
- package/lib/readers/file-system.reader.js +46 -0
- package/lib/readers/index.d.ts +2 -0
- package/lib/readers/index.js +18 -0
- package/lib/readers/reader.d.ts +10 -0
- package/lib/readers/reader.js +11 -0
- package/lib/runners/abstract.runner.d.ts +11 -0
- package/lib/runners/abstract.runner.js +47 -0
- package/lib/runners/git.runner.d.ts +4 -0
- package/lib/runners/git.runner.js +10 -0
- package/lib/runners/index.d.ts +3 -0
- package/lib/runners/index.js +19 -0
- package/lib/runners/npm.runner.d.ts +4 -0
- package/lib/runners/npm.runner.js +10 -0
- package/lib/runners/pnpm.runner.d.ts +4 -0
- package/lib/runners/pnpm.runner.js +10 -0
- package/lib/runners/runner.d.ts +6 -0
- package/lib/runners/runner.factory.d.ts +8 -0
- package/lib/runners/runner.factory.js +26 -0
- package/lib/runners/runner.js +10 -0
- package/lib/runners/schematic.runner.d.ts +6 -0
- package/lib/runners/schematic.runner.js +21 -0
- package/lib/runners/yarn.runner.d.ts +4 -0
- package/lib/runners/yarn.runner.js +10 -0
- package/lib/schematics/abstract.collection.d.ts +12 -0
- package/lib/schematics/abstract.collection.js +23 -0
- package/lib/schematics/collection.d.ts +3 -0
- package/lib/schematics/collection.factory.d.ts +5 -0
- package/lib/schematics/collection.factory.js +19 -0
- package/lib/schematics/collection.js +7 -0
- package/lib/schematics/custom.collection.d.ts +10 -0
- package/lib/schematics/custom.collection.js +33 -0
- package/lib/schematics/index.d.ts +4 -0
- package/lib/schematics/index.js +20 -0
- package/lib/schematics/nest.collection.d.ts +15 -0
- package/lib/schematics/nest.collection.js +126 -0
- package/lib/schematics/schematic.option.d.ts +8 -0
- package/lib/schematics/schematic.option.js +44 -0
- package/lib/ui/banner.d.ts +1 -0
- package/lib/ui/banner.js +12 -0
- package/lib/ui/emojis.d.ts +19 -0
- package/lib/ui/emojis.js +23 -0
- package/lib/ui/errors.d.ts +4 -0
- package/lib/ui/errors.js +8 -0
- package/lib/ui/index.d.ts +5 -0
- package/lib/ui/index.js +21 -0
- package/lib/ui/messages.d.ts +24 -0
- package/lib/ui/messages.js +32 -0
- package/lib/ui/prefixes.d.ts +2 -0
- package/lib/ui/prefixes.js +6 -0
- package/lib/utils/formatting.d.ts +8 -0
- package/lib/utils/formatting.js +18 -0
- package/lib/utils/get-default-tsconfig-path.d.ts +1 -0
- package/lib/utils/get-default-tsconfig-path.js +12 -0
- package/lib/utils/gracefully-exit-on-prompt-error.d.ts +1 -0
- package/lib/utils/gracefully-exit-on-prompt-error.js +11 -0
- package/lib/utils/is-module-available.d.ts +1 -0
- package/lib/utils/is-module-available.js +12 -0
- package/lib/utils/load-configuration.d.ts +2 -0
- package/lib/utils/load-configuration.js +9 -0
- package/lib/utils/local-binaries.d.ts +3 -0
- package/lib/utils/local-binaries.js +15 -0
- package/lib/utils/os-info.utils.d.ts +1 -0
- package/lib/utils/os-info.utils.js +23 -0
- package/lib/utils/project-utils.d.ts +11 -0
- package/lib/utils/project-utils.js +83 -0
- package/lib/utils/remaining-flags.d.ts +2 -0
- package/lib/utils/remaining-flags.js +36 -0
- package/lib/utils/tree-kill.d.ts +1 -0
- package/lib/utils/tree-kill.js +68 -0
- package/lib/utils/type-assertions.d.ts +1 -0
- package/lib/utils/type-assertions.js +8 -0
- package/package.json +161 -0
|
@@ -0,0 +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';
|
|
6
|
+
export declare class Compiler extends BaseCompiler {
|
|
7
|
+
private readonly tsConfigProvider;
|
|
8
|
+
private readonly typescriptLoader;
|
|
9
|
+
constructor(pluginsLoader: PluginsLoader, tsConfigProvider: TsConfigProvider, typescriptLoader: TypeScriptBinaryLoader);
|
|
10
|
+
run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, _extras: any, onSuccess?: () => void): void;
|
|
11
|
+
private reportAfterCompilationDiagnostic;
|
|
12
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Compiler = void 0;
|
|
4
|
+
const ts = require("typescript");
|
|
5
|
+
const base_compiler_1 = require("./base-compiler");
|
|
6
|
+
const tsconfig_paths_hook_1 = require("./hooks/tsconfig-paths.hook");
|
|
7
|
+
class Compiler extends base_compiler_1.BaseCompiler {
|
|
8
|
+
constructor(pluginsLoader, tsConfigProvider, typescriptLoader) {
|
|
9
|
+
super(pluginsLoader);
|
|
10
|
+
this.tsConfigProvider = tsConfigProvider;
|
|
11
|
+
this.typescriptLoader = typescriptLoader;
|
|
12
|
+
}
|
|
13
|
+
run(configuration, tsConfigPath, appName, _extras, onSuccess) {
|
|
14
|
+
const tsBinary = this.typescriptLoader.load();
|
|
15
|
+
const formatHost = {
|
|
16
|
+
getCanonicalFileName: (path) => path,
|
|
17
|
+
getCurrentDirectory: tsBinary.sys.getCurrentDirectory,
|
|
18
|
+
getNewLine: () => tsBinary.sys.newLine,
|
|
19
|
+
};
|
|
20
|
+
const { options, fileNames, projectReferences } = this.tsConfigProvider.getByConfigFilename(tsConfigPath);
|
|
21
|
+
const createProgram = tsBinary.createIncrementalProgram || tsBinary.createProgram;
|
|
22
|
+
const program = createProgram.call(ts, {
|
|
23
|
+
rootNames: fileNames,
|
|
24
|
+
projectReferences,
|
|
25
|
+
options,
|
|
26
|
+
});
|
|
27
|
+
const plugins = this.loadPlugins(configuration, tsConfigPath, appName);
|
|
28
|
+
const tsconfigPathsPlugin = (0, tsconfig_paths_hook_1.tsconfigPathsBeforeHookFactory)(options);
|
|
29
|
+
const programRef = program.getProgram
|
|
30
|
+
? program.getProgram()
|
|
31
|
+
: program;
|
|
32
|
+
const before = plugins.beforeHooks.map((hook) => hook(programRef));
|
|
33
|
+
const after = plugins.afterHooks.map((hook) => hook(programRef));
|
|
34
|
+
const afterDeclarations = plugins.afterDeclarationsHooks.map((hook) => hook(programRef));
|
|
35
|
+
const emitResult = program.emit(undefined, undefined, undefined, undefined, {
|
|
36
|
+
before: tsconfigPathsPlugin
|
|
37
|
+
? before.concat(tsconfigPathsPlugin)
|
|
38
|
+
: before,
|
|
39
|
+
after,
|
|
40
|
+
afterDeclarations,
|
|
41
|
+
});
|
|
42
|
+
const errorsCount = this.reportAfterCompilationDiagnostic(program, emitResult, tsBinary, formatHost);
|
|
43
|
+
if (errorsCount) {
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
else if (!errorsCount && onSuccess) {
|
|
47
|
+
onSuccess();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
reportAfterCompilationDiagnostic(program, emitResult, tsBinary, formatHost) {
|
|
51
|
+
const diagnostics = tsBinary
|
|
52
|
+
.getPreEmitDiagnostics(program)
|
|
53
|
+
.concat(emitResult.diagnostics);
|
|
54
|
+
if (diagnostics.length > 0) {
|
|
55
|
+
console.error(tsBinary.formatDiagnosticsWithColorAndContext(diagnostics, formatHost));
|
|
56
|
+
console.info(`Found ${diagnostics.length} error(s).` + tsBinary.sys.newLine);
|
|
57
|
+
}
|
|
58
|
+
return diagnostics.length;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Compiler = Compiler;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { Configuration } from '../../configuration';
|
|
3
|
+
export declare const swcDefaultsFactory: (tsOptions?: ts.CompilerOptions, configuration?: Configuration) => {
|
|
4
|
+
swcOptions: {
|
|
5
|
+
sourceMaps: string | boolean | undefined;
|
|
6
|
+
module: {
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
jsc: {
|
|
10
|
+
target: string;
|
|
11
|
+
parser: {
|
|
12
|
+
syntax: string;
|
|
13
|
+
decorators: boolean;
|
|
14
|
+
dynamicImport: boolean;
|
|
15
|
+
};
|
|
16
|
+
transform: {
|
|
17
|
+
legacyDecorator: boolean;
|
|
18
|
+
decoratorMetadata: boolean;
|
|
19
|
+
useDefineForClassFields: boolean;
|
|
20
|
+
};
|
|
21
|
+
keepClassNames: boolean;
|
|
22
|
+
baseUrl: string | undefined;
|
|
23
|
+
paths: ts.MapLike<string[]> | undefined;
|
|
24
|
+
};
|
|
25
|
+
minify: boolean;
|
|
26
|
+
swcrc: boolean;
|
|
27
|
+
};
|
|
28
|
+
cliOptions: {
|
|
29
|
+
outDir: string;
|
|
30
|
+
filenames: string[];
|
|
31
|
+
sync: boolean;
|
|
32
|
+
extensions: string[];
|
|
33
|
+
copyFiles: boolean;
|
|
34
|
+
includeDotfiles: boolean;
|
|
35
|
+
quiet: boolean;
|
|
36
|
+
watch: boolean;
|
|
37
|
+
stripLeadingPaths: boolean;
|
|
38
|
+
} | {
|
|
39
|
+
swcrcPath?: string;
|
|
40
|
+
outDir: string;
|
|
41
|
+
filenames: string[];
|
|
42
|
+
sync: boolean;
|
|
43
|
+
extensions: string[];
|
|
44
|
+
copyFiles: boolean;
|
|
45
|
+
includeDotfiles: boolean;
|
|
46
|
+
quiet: boolean;
|
|
47
|
+
watch: boolean;
|
|
48
|
+
stripLeadingPaths: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
configPath?: string;
|
|
51
|
+
outDir: string;
|
|
52
|
+
filenames: string[];
|
|
53
|
+
sync: boolean;
|
|
54
|
+
extensions: string[];
|
|
55
|
+
copyFiles: boolean;
|
|
56
|
+
includeDotfiles: boolean;
|
|
57
|
+
quiet: boolean;
|
|
58
|
+
watch: boolean;
|
|
59
|
+
stripLeadingPaths: boolean;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.swcDefaultsFactory = void 0;
|
|
4
|
+
const swcDefaultsFactory = (tsOptions, configuration) => {
|
|
5
|
+
const builderOptions = typeof configuration?.compilerOptions?.builder !== 'string'
|
|
6
|
+
? configuration?.compilerOptions?.builder?.options
|
|
7
|
+
: {};
|
|
8
|
+
return {
|
|
9
|
+
swcOptions: {
|
|
10
|
+
sourceMaps: tsOptions?.sourceMap || (tsOptions?.inlineSourceMap && 'inline'),
|
|
11
|
+
module: {
|
|
12
|
+
type: 'commonjs',
|
|
13
|
+
},
|
|
14
|
+
jsc: {
|
|
15
|
+
target: 'es2021',
|
|
16
|
+
parser: {
|
|
17
|
+
syntax: 'typescript',
|
|
18
|
+
decorators: true,
|
|
19
|
+
dynamicImport: true,
|
|
20
|
+
},
|
|
21
|
+
transform: {
|
|
22
|
+
legacyDecorator: true,
|
|
23
|
+
decoratorMetadata: true,
|
|
24
|
+
useDefineForClassFields: false,
|
|
25
|
+
},
|
|
26
|
+
keepClassNames: true,
|
|
27
|
+
baseUrl: tsOptions?.baseUrl,
|
|
28
|
+
paths: tsOptions?.paths,
|
|
29
|
+
},
|
|
30
|
+
minify: false,
|
|
31
|
+
swcrc: true,
|
|
32
|
+
},
|
|
33
|
+
cliOptions: {
|
|
34
|
+
outDir: tsOptions?.outDir ? convertPath(tsOptions.outDir) : 'dist',
|
|
35
|
+
filenames: [configuration?.sourceRoot ?? 'src'],
|
|
36
|
+
sync: false,
|
|
37
|
+
extensions: ['.js', '.ts'],
|
|
38
|
+
copyFiles: false,
|
|
39
|
+
includeDotfiles: false,
|
|
40
|
+
quiet: false,
|
|
41
|
+
watch: false,
|
|
42
|
+
stripLeadingPaths: true,
|
|
43
|
+
...builderOptions,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.swcDefaultsFactory = swcDefaultsFactory;
|
|
48
|
+
/**
|
|
49
|
+
* Converts Windows specific file paths to posix
|
|
50
|
+
* @param windowsPath
|
|
51
|
+
*/
|
|
52
|
+
function convertPath(windowsPath) {
|
|
53
|
+
return windowsPath
|
|
54
|
+
.replace(/^\\\\\?\\/, '')
|
|
55
|
+
.replace(/\\/g, '/')
|
|
56
|
+
.replace(/\/\/+/g, '/');
|
|
57
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MultiNestCompilerPlugins } from '../plugins/plugins-loader';
|
|
2
|
+
import webpack = require('webpack');
|
|
3
|
+
export declare const webpackDefaultsFactory: (sourceRoot: string, relativeSourceRoot: string, entryFilename: string, isDebugEnabled: boolean | undefined, tsConfigFile: string | undefined, plugins: MultiNestCompilerPlugins) => webpack.Configuration;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webpackDefaultsFactory = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
|
|
6
|
+
const defaults_1 = require("../../configuration/defaults");
|
|
7
|
+
const append_extension_1 = require("../helpers/append-extension");
|
|
8
|
+
const webpack = require("webpack");
|
|
9
|
+
const nodeExternals = require("webpack-node-externals");
|
|
10
|
+
const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultTsconfigFilename, plugins) => {
|
|
11
|
+
const isPluginRegistered = isAnyPluginRegistered(plugins);
|
|
12
|
+
const webpackConfiguration = {
|
|
13
|
+
entry: (0, append_extension_1.appendTsExtension)((0, path_1.join)(sourceRoot, entryFilename)),
|
|
14
|
+
devtool: isDebugEnabled ? 'inline-source-map' : false,
|
|
15
|
+
target: 'node',
|
|
16
|
+
output: {
|
|
17
|
+
filename: (0, path_1.join)(relativeSourceRoot, `${entryFilename}.js`),
|
|
18
|
+
},
|
|
19
|
+
ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
|
|
20
|
+
externals: [nodeExternals()],
|
|
21
|
+
externalsPresets: { node: true },
|
|
22
|
+
module: {
|
|
23
|
+
rules: [
|
|
24
|
+
{
|
|
25
|
+
test: /.tsx?$/,
|
|
26
|
+
use: [
|
|
27
|
+
{
|
|
28
|
+
loader: 'ts-loader',
|
|
29
|
+
options: {
|
|
30
|
+
transpileOnly: !isPluginRegistered,
|
|
31
|
+
configFile: tsConfigFile,
|
|
32
|
+
getCustomTransformers: (program) => ({
|
|
33
|
+
before: plugins.beforeHooks.map((hook) => hook(program)),
|
|
34
|
+
after: plugins.afterHooks.map((hook) => hook(program)),
|
|
35
|
+
afterDeclarations: plugins.afterDeclarationsHooks.map((hook) => hook(program)),
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
exclude: /node_modules/,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
resolve: {
|
|
45
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
46
|
+
plugins: [
|
|
47
|
+
new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
|
|
48
|
+
configFile: tsConfigFile,
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
mode: 'none',
|
|
53
|
+
optimization: {
|
|
54
|
+
nodeEnv: false,
|
|
55
|
+
},
|
|
56
|
+
node: {
|
|
57
|
+
__filename: false,
|
|
58
|
+
__dirname: false,
|
|
59
|
+
},
|
|
60
|
+
plugins: [
|
|
61
|
+
new webpack.IgnorePlugin({
|
|
62
|
+
checkResource(resource) {
|
|
63
|
+
const lazyImports = [
|
|
64
|
+
'@nestjs/microservices',
|
|
65
|
+
'@nestjs/microservices/microservices-module',
|
|
66
|
+
'@nestjs/websockets/socket-module',
|
|
67
|
+
'class-validator',
|
|
68
|
+
'class-transformer',
|
|
69
|
+
'class-transformer/storage',
|
|
70
|
+
];
|
|
71
|
+
if (!lazyImports.includes(resource)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
require.resolve(resource, {
|
|
76
|
+
paths: [process.cwd()],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
if (!isPluginRegistered) {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
89
|
+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
90
|
+
webpackConfiguration.plugins.push(new ForkTsCheckerWebpackPlugin({
|
|
91
|
+
typescript: {
|
|
92
|
+
configFile: tsConfigFile,
|
|
93
|
+
},
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
return webpackConfiguration;
|
|
97
|
+
};
|
|
98
|
+
exports.webpackDefaultsFactory = webpackDefaultsFactory;
|
|
99
|
+
function isAnyPluginRegistered(plugins) {
|
|
100
|
+
return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
|
|
101
|
+
(plugins.beforeHooks && plugins.beforeHooks.length > 0) ||
|
|
102
|
+
(plugins.afterDeclarationsHooks &&
|
|
103
|
+
plugins.afterDeclarationsHooks.length > 0));
|
|
104
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appendTsExtension(path: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendTsExtension = appendTsExtension;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
function appendTsExtension(path) {
|
|
6
|
+
return (0, path_1.extname)(path) === '.ts' ? path : path + '.ts';
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function for returning a copy destination filename
|
|
3
|
+
*
|
|
4
|
+
* @description used in `assets-manager.ts` (copy from `copyfiles`)
|
|
5
|
+
* @see https://github.com/calvinmetcalf/copyfiles/blob/master/index.js#L22
|
|
6
|
+
*/
|
|
7
|
+
export declare function copyPathResolve(filePath: string, outDir: string, up: number): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyPathResolve = copyPathResolve;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
/**
|
|
6
|
+
* Helper function for returning a copy destination filename
|
|
7
|
+
*
|
|
8
|
+
* @description used in `assets-manager.ts` (copy from `copyfiles`)
|
|
9
|
+
* @see https://github.com/calvinmetcalf/copyfiles/blob/master/index.js#L22
|
|
10
|
+
*/
|
|
11
|
+
function copyPathResolve(filePath, outDir, up) {
|
|
12
|
+
return path.join(outDir, dealWith(filePath, up));
|
|
13
|
+
}
|
|
14
|
+
function dealWith(inPath, up) {
|
|
15
|
+
if (!up) {
|
|
16
|
+
return inPath;
|
|
17
|
+
}
|
|
18
|
+
if (depth(inPath) < up - 1) {
|
|
19
|
+
throw new Error('Path outside of project folder is not allowed');
|
|
20
|
+
}
|
|
21
|
+
return path.join(...path.normalize(inPath).split(path.sep).slice(up));
|
|
22
|
+
}
|
|
23
|
+
function depth(string) {
|
|
24
|
+
return path.normalize(string).split(path.sep).length - 1;
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteOutDirIfEnabled = deleteOutDirIfEnabled;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const get_value_or_default_1 = require("./get-value-or-default");
|
|
6
|
+
async function deleteOutDirIfEnabled(configuration, appName, dirPath) {
|
|
7
|
+
const isDeleteEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.deleteOutDir', appName);
|
|
8
|
+
if (!isDeleteEnabled) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
await (0, promises_1.rm)(dirPath, { recursive: true, force: true });
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Input } from '../../../commands';
|
|
2
|
+
import { Configuration } from '../../configuration';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the builder to use for the given application.
|
|
5
|
+
* @param configuration Configuration object.
|
|
6
|
+
* @param cmdOptions Command line options.
|
|
7
|
+
* @param appName Application name.
|
|
8
|
+
* @returns The builder to use.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getBuilder(configuration: Required<Configuration>, cmdOptions: Input[], appName: string | undefined): {
|
|
11
|
+
type: "webpack";
|
|
12
|
+
options?: import("../../configuration").WebpackBuilderOptions;
|
|
13
|
+
} | {
|
|
14
|
+
type: "swc";
|
|
15
|
+
options?: import("../../configuration").SwcBuilderOptions;
|
|
16
|
+
} | {
|
|
17
|
+
type: "tsc";
|
|
18
|
+
options?: import("../../configuration").TscBuilderOptions;
|
|
19
|
+
} | {
|
|
20
|
+
type: import("../../configuration").BuilderVariant;
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBuilder = getBuilder;
|
|
4
|
+
const get_value_or_default_1 = require("./get-value-or-default");
|
|
5
|
+
/**
|
|
6
|
+
* Returns the builder to use for the given application.
|
|
7
|
+
* @param configuration Configuration object.
|
|
8
|
+
* @param cmdOptions Command line options.
|
|
9
|
+
* @param appName Application name.
|
|
10
|
+
* @returns The builder to use.
|
|
11
|
+
*/
|
|
12
|
+
function getBuilder(configuration, cmdOptions, appName) {
|
|
13
|
+
const builderValue = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', cmdOptions, 'tsc');
|
|
14
|
+
return typeof builderValue === 'string'
|
|
15
|
+
? {
|
|
16
|
+
type: builderValue,
|
|
17
|
+
}
|
|
18
|
+
: builderValue;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Input } from '../../../commands';
|
|
2
|
+
import { Configuration } from '../../configuration';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the path to the tsc configuration file to use for the given application.
|
|
5
|
+
* @param configuration Configuration object.
|
|
6
|
+
* @param cmdOptions Command line options.
|
|
7
|
+
* @param appName Application name.
|
|
8
|
+
* @returns The path to the tsc configuration file to use.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTscConfigPath(configuration: Required<Configuration>, cmdOptions: Input[], appName: string | undefined): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTscConfigPath = getTscConfigPath;
|
|
4
|
+
const get_default_tsconfig_path_1 = require("../../utils/get-default-tsconfig-path");
|
|
5
|
+
const get_value_or_default_1 = require("./get-value-or-default");
|
|
6
|
+
/**
|
|
7
|
+
* Returns the path to the tsc configuration file to use for the given application.
|
|
8
|
+
* @param configuration Configuration object.
|
|
9
|
+
* @param cmdOptions Command line options.
|
|
10
|
+
* @param appName Application name.
|
|
11
|
+
* @returns The path to the tsc configuration file to use.
|
|
12
|
+
*/
|
|
13
|
+
function getTscConfigPath(configuration, cmdOptions, appName) {
|
|
14
|
+
let tsconfigPath = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', cmdOptions);
|
|
15
|
+
if (tsconfigPath) {
|
|
16
|
+
return tsconfigPath;
|
|
17
|
+
}
|
|
18
|
+
const builder = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName);
|
|
19
|
+
tsconfigPath =
|
|
20
|
+
typeof builder === 'object' && builder?.type === 'tsc'
|
|
21
|
+
? builder.options?.configPath
|
|
22
|
+
: undefined;
|
|
23
|
+
return tsconfigPath ?? (0, get_default_tsconfig_path_1.getDefaultTsconfigPath)();
|
|
24
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Input } from '../../../commands';
|
|
2
|
+
import { Configuration } from '../../configuration';
|
|
3
|
+
export declare function getValueOrDefault<T = any>(configuration: Required<Configuration>, propertyPath: string, appName: string | undefined, key?: 'path' | 'webpack' | 'webpackPath' | 'entryFile' | 'sourceRoot' | 'exec' | 'builder' | 'typeCheck', options?: Input[], defaultValue?: T): T;
|
|
4
|
+
export declare function getValueOfPath<T = any>(object: Record<string, any>, propertyPath: string): T;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValueOrDefault = getValueOrDefault;
|
|
4
|
+
exports.getValueOfPath = getValueOfPath;
|
|
5
|
+
function getValueOrDefault(configuration, propertyPath, appName, key, options = [], defaultValue) {
|
|
6
|
+
const item = options.find((option) => option.name === key);
|
|
7
|
+
const origValue = item && item.value;
|
|
8
|
+
if (origValue !== undefined && origValue !== null) {
|
|
9
|
+
return origValue;
|
|
10
|
+
}
|
|
11
|
+
if (configuration.projects && configuration.projects[appName]) {
|
|
12
|
+
// Wrap the application name in double-quotes to prevent splitting it
|
|
13
|
+
// into separate chunks
|
|
14
|
+
appName = appName && !appName.includes('"') ? `"${appName}"` : appName;
|
|
15
|
+
const perAppValue = getValueOfPath(configuration, `projects.${appName}.`.concat(propertyPath));
|
|
16
|
+
if (perAppValue !== undefined) {
|
|
17
|
+
return perAppValue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let value = getValueOfPath(configuration, propertyPath);
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
value = defaultValue;
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function getValueOfPath(object, propertyPath) {
|
|
27
|
+
const fragments = propertyPath.split('.');
|
|
28
|
+
let propertyValue = object;
|
|
29
|
+
let isConcatInProgress = false;
|
|
30
|
+
let path = '';
|
|
31
|
+
for (const fragment of fragments) {
|
|
32
|
+
if (!propertyValue) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* When path is escaped with "" double quotes,
|
|
37
|
+
* concatenate the property path.
|
|
38
|
+
* Reference: https://github.com/nestjs/nest-cli/issues/947
|
|
39
|
+
*/
|
|
40
|
+
if (fragment.startsWith('"') && fragment.endsWith('"')) {
|
|
41
|
+
path = stripDoubleQuotes(fragment);
|
|
42
|
+
}
|
|
43
|
+
else if (fragment.startsWith('"')) {
|
|
44
|
+
path += stripDoubleQuotes(fragment) + '.';
|
|
45
|
+
isConcatInProgress = true;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
else if (isConcatInProgress && !fragment.endsWith('"')) {
|
|
49
|
+
path += fragment + '.';
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
else if (fragment.endsWith('"')) {
|
|
53
|
+
path += stripDoubleQuotes(fragment);
|
|
54
|
+
isConcatInProgress = false;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
path = fragment;
|
|
58
|
+
}
|
|
59
|
+
propertyValue = propertyValue[path];
|
|
60
|
+
path = '';
|
|
61
|
+
}
|
|
62
|
+
return propertyValue;
|
|
63
|
+
}
|
|
64
|
+
function stripDoubleQuotes(text) {
|
|
65
|
+
return text.replace(/"/g, '');
|
|
66
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Input } from '../../../commands';
|
|
2
|
+
import { Configuration } from '../../configuration';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the path to the webpack configuration file to use for the given application.
|
|
5
|
+
* @param configuration Configuration object.
|
|
6
|
+
* @param cmdOptions Command line options.
|
|
7
|
+
* @param appName Application name.
|
|
8
|
+
* @returns The path to the webpack configuration file to use.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getWebpackConfigPath(configuration: Required<Configuration>, cmdOptions: Input[], appName: string | undefined): string | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWebpackConfigPath = getWebpackConfigPath;
|
|
4
|
+
const get_value_or_default_1 = require("./get-value-or-default");
|
|
5
|
+
/**
|
|
6
|
+
* Returns the path to the webpack configuration file to use for the given application.
|
|
7
|
+
* @param configuration Configuration object.
|
|
8
|
+
* @param cmdOptions Command line options.
|
|
9
|
+
* @param appName Application name.
|
|
10
|
+
* @returns The path to the webpack configuration file to use.
|
|
11
|
+
*/
|
|
12
|
+
function getWebpackConfigPath(configuration, cmdOptions, appName) {
|
|
13
|
+
let webpackPath = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', cmdOptions);
|
|
14
|
+
if (webpackPath) {
|
|
15
|
+
return webpackPath;
|
|
16
|
+
}
|
|
17
|
+
const builder = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName);
|
|
18
|
+
webpackPath =
|
|
19
|
+
typeof builder === 'object' && builder?.type === 'webpack'
|
|
20
|
+
? builder.options?.configPath
|
|
21
|
+
: undefined;
|
|
22
|
+
return webpackPath;
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listenForManualRestart = listenForManualRestart;
|
|
4
|
+
exports.displayManualRestartTip = displayManualRestartTip;
|
|
5
|
+
const ansis_1 = require("ansis");
|
|
6
|
+
function listenForManualRestart(callback) {
|
|
7
|
+
const stdinListener = (data) => {
|
|
8
|
+
if (data.toString().trim() === 'rs') {
|
|
9
|
+
process.stdin.removeListener('data', stdinListener);
|
|
10
|
+
callback();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
process.stdin.on('data', stdinListener);
|
|
14
|
+
}
|
|
15
|
+
function displayManualRestartTip() {
|
|
16
|
+
console.log(`To restart at any time, enter ${(0, ansis_1.gray) `rs`}.\n`);
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { TypeScriptBinaryLoader } from '../typescript-loader';
|
|
3
|
+
export declare class TsConfigProvider {
|
|
4
|
+
private readonly typescriptLoader;
|
|
5
|
+
constructor(typescriptLoader: TypeScriptBinaryLoader);
|
|
6
|
+
getByConfigFilename(configFilename: string): {
|
|
7
|
+
options: ts.CompilerOptions;
|
|
8
|
+
fileNames: string[];
|
|
9
|
+
projectReferences: readonly ts.ProjectReference[] | undefined;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TsConfigProvider = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const ui_1 = require("../../ui");
|
|
7
|
+
class TsConfigProvider {
|
|
8
|
+
constructor(typescriptLoader) {
|
|
9
|
+
this.typescriptLoader = typescriptLoader;
|
|
10
|
+
}
|
|
11
|
+
getByConfigFilename(configFilename) {
|
|
12
|
+
const configPath = (0, path_1.join)(process.cwd(), configFilename);
|
|
13
|
+
if (!(0, fs_1.existsSync)(configPath)) {
|
|
14
|
+
throw new Error(ui_1.CLI_ERRORS.MISSING_TYPESCRIPT(configFilename));
|
|
15
|
+
}
|
|
16
|
+
const tsBinary = this.typescriptLoader.load();
|
|
17
|
+
const parsedCmd = tsBinary.getParsedCommandLineOfConfigFile(configPath, undefined, tsBinary.sys);
|
|
18
|
+
const { options, fileNames, projectReferences } = parsedCmd;
|
|
19
|
+
return { options, fileNames, projectReferences };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.TsConfigProvider = TsConfigProvider;
|