@nestjs/cli 10.4.8 → 11.0.0-next.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.
@@ -7,7 +7,7 @@ aliases:
7
7
  - &install-deps
8
8
  run:
9
9
  name: Install dependencies
10
- command: npm ci --ignore-scripts
10
+ command: npm ci --ignore-scripts --legacy-peer-deps
11
11
  - &build-packages
12
12
  run:
13
13
  name: Build
@@ -31,7 +31,7 @@ jobs:
31
31
  key: dependency-cache-{{ checksum "package.json" }}
32
32
  - run:
33
33
  name: Install dependencies
34
- command: npm ci --ignore-scripts
34
+ command: npm ci --ignore-scripts --legacy-peer-deps
35
35
  - save_cache:
36
36
  key: dependency-cache-{{ checksum "package.json" }}
37
37
  paths:
@@ -49,67 +49,113 @@ class BuildAction extends abstract_action_1.AbstractAction {
49
49
  async runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
50
50
  const configFileName = commandOptions.find((option) => option.name === 'config').value;
51
51
  const configuration = await this.loader.load(configFileName);
52
- const appName = commandInputs.find((input) => input.name === 'app')
52
+ const buildAll = commandOptions.find((opt) => opt.name === 'all')
53
53
  .value;
54
- const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
55
- const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
56
- const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
57
- const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', commandOptions);
58
- const builder = isWebpackEnabled
59
- ? { type: 'webpack' }
60
- : (0, get_builder_1.getBuilder)(configuration, commandOptions, appName);
61
- await (0, delete_out_dir_1.deleteOutDirIfEnabled)(configuration, appName, outDir);
62
- this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
63
- const typeCheck = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', commandOptions);
64
- if (typeCheck && builder.type !== 'swc') {
65
- console.warn(ui_1.INFO_PREFIX +
66
- ` "typeCheck" will not have any effect when "builder" is not "swc".`);
54
+ let appNames;
55
+ if (buildAll) {
56
+ appNames = [];
57
+ if (configuration.projects) {
58
+ appNames.push(...Object.keys(configuration.projects));
59
+ }
60
+ }
61
+ else {
62
+ appNames = commandInputs
63
+ .filter((input) => input.name === 'app')
64
+ .map((input) => input.value);
67
65
  }
68
- switch (builder.type) {
69
- case 'tsc':
70
- return this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName, onSuccess);
71
- case 'webpack':
72
- return this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode, onSuccess);
73
- case 'swc':
74
- return this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions, onSuccess);
66
+ for (const appName of appNames) {
67
+ const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
68
+ const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
69
+ const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
70
+ const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', commandOptions);
71
+ const builder = isWebpackEnabled
72
+ ? { type: 'webpack' }
73
+ : (0, get_builder_1.getBuilder)(configuration, commandOptions, appName);
74
+ await (0, delete_out_dir_1.deleteOutDirIfEnabled)(configuration, appName, outDir);
75
+ this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
76
+ const typeCheck = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', commandOptions);
77
+ if (typeCheck && builder.type !== 'swc') {
78
+ console.warn(ui_1.INFO_PREFIX +
79
+ ` "typeCheck" will not have any effect when "builder" is not "swc".`);
80
+ }
81
+ switch (builder.type) {
82
+ case 'tsc':
83
+ await this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName);
84
+ break;
85
+ case 'webpack':
86
+ await this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode);
87
+ break;
88
+ case 'swc':
89
+ await this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions);
90
+ break;
91
+ }
75
92
  }
93
+ onSuccess?.();
76
94
  }
77
- async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, onSuccess) {
95
+ async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions) {
78
96
  const { SwcCompiler } = await Promise.resolve().then(() => require('../lib/compiler/swc/swc-compiler'));
79
97
  const swc = new SwcCompiler(this.pluginsLoader);
80
- await swc.run(configuration, pathToTsconfig, appName, {
81
- watch: watchMode,
82
- typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
83
- tsOptions,
84
- assetsManager: this.assetsManager,
85
- }, onSuccess);
98
+ return new Promise((onSuccess, onError) => {
99
+ try {
100
+ swc.run(configuration, pathToTsconfig, appName, {
101
+ watch: watchMode,
102
+ typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
103
+ tsOptions,
104
+ assetsManager: this.assetsManager,
105
+ }, onSuccess);
106
+ }
107
+ catch (error) {
108
+ onError(error);
109
+ }
110
+ });
86
111
  }
87
- async runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode, onSuccess) {
112
+ async runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode) {
88
113
  const { WebpackCompiler } = await Promise.resolve().then(() => require('../lib/compiler/webpack-compiler'));
89
114
  const webpackCompiler = new WebpackCompiler(this.pluginsLoader);
90
115
  const webpackPath = (0, get_webpack_config_path_1.getWebpackConfigPath)(configuration, commandOptions, appName) ??
91
116
  defaults_1.defaultWebpackConfigFilename;
92
117
  const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, defaults_1.defaultWebpackConfigFilename);
93
- return webpackCompiler.run(configuration, pathToTsconfig, appName, {
94
- inputs: commandOptions,
95
- webpackConfigFactoryOrConfig,
96
- debug,
97
- watchMode,
98
- assetsManager: this.assetsManager,
99
- }, onSuccess);
118
+ return new Promise((onSuccess, onError) => {
119
+ try {
120
+ return webpackCompiler.run(configuration, pathToTsconfig, appName, {
121
+ inputs: commandOptions,
122
+ webpackConfigFactoryOrConfig,
123
+ debug,
124
+ watchMode,
125
+ assetsManager: this.assetsManager,
126
+ }, onSuccess);
127
+ }
128
+ catch (error) {
129
+ onError(error);
130
+ }
131
+ });
100
132
  }
101
- async runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess) {
133
+ async runTsc(watchMode, options, configuration, pathToTsconfig, appName) {
102
134
  if (watchMode) {
103
135
  const { WatchCompiler } = await Promise.resolve().then(() => require('../lib/compiler/watch-compiler'));
104
136
  const watchCompiler = new WatchCompiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
105
137
  const isPreserveWatchOutputEnabled = options.find((option) => option.name === 'preserveWatchOutput' && option.value === true)?.value;
106
- watchCompiler.run(configuration, pathToTsconfig, appName, { preserveWatchOutput: isPreserveWatchOutputEnabled }, onSuccess);
138
+ return new Promise((onSuccess, onError) => {
139
+ try {
140
+ watchCompiler.run(configuration, pathToTsconfig, appName, { preserveWatchOutput: isPreserveWatchOutputEnabled }, onSuccess);
141
+ }
142
+ catch (error) {
143
+ onError(error);
144
+ }
145
+ });
107
146
  }
108
147
  else {
109
148
  const { Compiler } = await Promise.resolve().then(() => require('../lib/compiler/compiler'));
110
149
  const compiler = new Compiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
111
- compiler.run(configuration, pathToTsconfig, appName, undefined, onSuccess);
112
- this.assetsManager.closeWatchers();
150
+ return new Promise((onSuccess, onError) => {
151
+ try {
152
+ compiler.run(configuration, pathToTsconfig, appName, undefined, onSuccess);
153
+ this.assetsManager.closeWatchers();
154
+ }
155
+ catch (error) {
156
+ onError(error);
157
+ }
158
+ });
113
159
  }
114
160
  }
115
161
  getWebpackConfigFactoryByPath(webpackPath, defaultPath) {
@@ -4,7 +4,6 @@ exports.exit = exports.retrieveCols = exports.NewAction = void 0;
4
4
  const chalk = require("chalk");
5
5
  const child_process_1 = require("child_process");
6
6
  const fs = require("fs");
7
- const inquirer = require("inquirer");
8
7
  const path_1 = require("path");
9
8
  const defaults_1 = require("../lib/configuration/defaults");
10
9
  const package_managers_1 = require("../lib/package-managers");
@@ -14,6 +13,7 @@ const schematics_1 = require("../lib/schematics");
14
13
  const ui_1 = require("../lib/ui");
15
14
  const formatting_1 = require("../lib/utils/formatting");
16
15
  const abstract_action_1 = require("./abstract.action");
16
+ const prompts_1 = require("@inquirer/prompts");
17
17
  class NewAction extends abstract_action_1.AbstractAction {
18
18
  async handle(inputs, options) {
19
19
  const directoryOption = options.find((option) => option.name === 'directory');
@@ -47,23 +47,24 @@ const getProjectDirectory = (applicationName, directoryOption) => {
47
47
  const askForMissingInformation = async (inputs, options) => {
48
48
  console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
49
49
  console.info();
50
- const prompt = inquirer.createPromptModule();
51
50
  const nameInput = getApplicationNameInput(inputs);
52
51
  if (!nameInput.value) {
53
- const message = 'What name would you like to use for the new project?';
54
- const questions = [(0, questions_1.generateInput)('name', message)('nest-app')];
55
- const answers = await prompt(questions);
56
- replaceInputMissingInformation(inputs, answers);
52
+ const message = ui_1.MESSAGES.PROJECT_NAME_QUESTION;
53
+ const question = (0, questions_1.generateInput)('name', message)('nest-app');
54
+ const answer = await (0, prompts_1.input)(question);
55
+ replaceInputMissingInformation(inputs, { name: 'name', value: answer });
57
56
  }
58
57
  const packageManagerInput = getPackageManagerInput(options);
59
58
  if (!packageManagerInput.value) {
60
- const answers = await askForPackageManager();
61
- replaceInputMissingInformation(options, answers);
59
+ const answer = await askForPackageManager();
60
+ replaceInputMissingInformation(options, { name: 'packageManager', value: answer });
62
61
  }
63
62
  };
64
- const replaceInputMissingInformation = (inputs, answers) => {
65
- return inputs.map((input) => (input.value =
66
- input.value !== undefined ? input.value : answers[input.name]));
63
+ const replaceInputMissingInformation = (inputs, answer) => {
64
+ const input = inputs.find(input => input.name === answer.name);
65
+ if (input) {
66
+ input.value = input.value !== undefined ? input.value : answer.value;
67
+ }
67
68
  };
68
69
  const generateApplicationFiles = async (args, options) => {
69
70
  const collectionName = options.find((option) => option.name === 'collection' && option.value != null).value;
@@ -100,15 +101,12 @@ const installPackages = async (options, dryRunMode, installDirectory) => {
100
101
  }
101
102
  };
102
103
  const askForPackageManager = async () => {
103
- const questions = [
104
- (0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
105
- package_managers_1.PackageManager.NPM,
106
- package_managers_1.PackageManager.YARN,
107
- package_managers_1.PackageManager.PNPM,
108
- ]),
109
- ];
110
- const prompt = inquirer.createPromptModule();
111
- return await prompt(questions);
104
+ const question = (0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
105
+ package_managers_1.PackageManager.NPM,
106
+ package_managers_1.PackageManager.YARN,
107
+ package_managers_1.PackageManager.PNPM,
108
+ ]);
109
+ return (0, prompts_1.select)(question);
112
110
  };
113
111
  const initializeGitRepository = async (dir) => {
114
112
  const runner = new git_runner_1.GitRunner();
@@ -2,6 +2,6 @@ import { Input } from '../commands';
2
2
  import { BuildAction } from './build.action';
3
3
  export declare class StartAction extends BuildAction {
4
4
  handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>;
5
- createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string): () => void;
5
+ createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string, useShell: boolean): () => void;
6
6
  private spawnChildProcess;
7
7
  }
@@ -31,7 +31,9 @@ class StartAction extends build_action_1.BuildAction {
31
31
  const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
32
32
  const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', commandOptions, defaults_1.defaultConfiguration.entryFile);
33
33
  const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', commandOptions, defaults_1.defaultConfiguration.sourceRoot);
34
- const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun);
34
+ const shellOption = commandOptions.find((option) => option.name === 'shell');
35
+ const useShell = !!shellOption?.value;
36
+ const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, useShell);
35
37
  await this.runBuild(commandInputs, commandOptions, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
36
38
  }
37
39
  catch (err) {
@@ -43,21 +45,21 @@ class StartAction extends build_action_1.BuildAction {
43
45
  }
44
46
  }
45
47
  }
46
- createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun) {
48
+ createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, useShell) {
47
49
  let childProcessRef;
48
50
  process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
49
51
  return () => {
50
52
  if (childProcessRef) {
51
53
  childProcessRef.removeAllListeners('exit');
52
54
  childProcessRef.on('exit', () => {
53
- childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun);
55
+ childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, useShell);
54
56
  childProcessRef.on('exit', () => (childProcessRef = undefined));
55
57
  });
56
58
  childProcessRef.stdin && childProcessRef.stdin.pause();
57
59
  killProcess(childProcessRef.pid);
58
60
  }
59
61
  else {
60
- childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun);
62
+ childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, useShell);
61
63
  childProcessRef.on('exit', (code) => {
62
64
  process.exitCode = code;
63
65
  childProcessRef = undefined;
@@ -65,7 +67,7 @@ class StartAction extends build_action_1.BuildAction {
65
67
  }
66
68
  };
67
69
  }
68
- spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun) {
70
+ spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, useShell) {
69
71
  let outputFilePath = (0, path_1.join)(outDirName, sourceRoot, entryFile);
70
72
  if (!fs.existsSync(outputFilePath + '.js')) {
71
73
  outputFilePath = (0, path_1.join)(outDirName, entryFile);
@@ -92,7 +94,7 @@ class StartAction extends build_action_1.BuildAction {
92
94
  processArgs.unshift('--enable-source-maps');
93
95
  return (0, child_process_1.spawn)(binaryToRun, processArgs, {
94
96
  stdio: 'inherit',
95
- shell: true,
97
+ shell: useShell,
96
98
  });
97
99
  }
98
100
  }
@@ -6,7 +6,7 @@ const abstract_command_1 = require("./abstract.command");
6
6
  class BuildCommand extends abstract_command_1.AbstractCommand {
7
7
  load(program) {
8
8
  program
9
- .command('build [app]')
9
+ .command('build [apps...]')
10
10
  .option('-c, --config [path]', 'Path to nest-cli configuration file.')
11
11
  .option('-p, --path [path]', 'Path to tsconfig file.')
12
12
  .option('-w, --watch', 'Run in watch mode (live-reload).')
@@ -17,8 +17,9 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
17
17
  .option('--webpackPath [path]', 'Path to webpack configuration.')
18
18
  .option('--tsc', 'Use typescript compiler for compilation.')
19
19
  .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
20
+ .option('--all', 'Build all projects in a monorepo.')
20
21
  .description('Build Nest application.')
21
- .action(async (app, command) => {
22
+ .action(async (apps, command) => {
22
23
  const options = [];
23
24
  options.push({
24
25
  name: 'config',
@@ -56,8 +57,16 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
56
57
  !!command.watch &&
57
58
  !isWebpackEnabled,
58
59
  });
59
- const inputs = [];
60
- inputs.push({ name: 'app', value: app });
60
+ options.push({ name: 'all', value: !!command.all });
61
+ const inputs = apps.map((app) => ({
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
+ }
61
70
  await this.action.handle(inputs, options);
62
71
  });
63
72
  }
@@ -23,6 +23,7 @@ class StartCommand extends abstract_command_1.AbstractCommand {
23
23
  .option('--entryFile [entryFile]', "Path to the entry file where this command will work with. Defaults to the one defined at your Nest's CLI config file.")
24
24
  .option('-e, --exec [binary]', 'Binary to run (default: "node").')
25
25
  .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
26
+ .option('--shell', "Spawn child processes within a shell (see node's child_process.spawn() method docs). Default: true.", true)
26
27
  .description('Run Nest application.')
27
28
  .action(async (app, command) => {
28
29
  const options = [];
@@ -61,6 +62,10 @@ class StartCommand extends abstract_command_1.AbstractCommand {
61
62
  !!command.watch &&
62
63
  !isWebpackEnabled,
63
64
  });
65
+ options.push({
66
+ name: 'shell',
67
+ value: !!command.shell,
68
+ });
64
69
  const availableBuilders = ['tsc', 'webpack', 'swc'];
65
70
  if (command.builder && !availableBuilders.includes(command.builder)) {
66
71
  console.error(ui_1.ERROR_PREFIX +
@@ -10,6 +10,6 @@ export declare class AssetsManager {
10
10
  * If action has been taken recently flag and try again
11
11
  */
12
12
  closeWatchers(): void;
13
- copyAssets(configuration: Required<Configuration>, appName: string, outDir: string, watchAssetsMode: boolean): void;
13
+ copyAssets(configuration: Required<Configuration>, appName: string | undefined, outDir: string, watchAssetsMode: boolean): void;
14
14
  private actionOnFile;
15
15
  }
@@ -7,6 +7,6 @@ export declare class Compiler extends BaseCompiler {
7
7
  private readonly tsConfigProvider;
8
8
  private readonly typescriptLoader;
9
9
  constructor(pluginsLoader: PluginsLoader, tsConfigProvider: TsConfigProvider, typescriptLoader: TypeScriptBinaryLoader);
10
- run(configuration: Required<Configuration>, tsConfigPath: string, appName: string, _extras: any, onSuccess?: () => void): void;
10
+ run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, _extras: any, onSuccess?: () => void): void;
11
11
  private reportAfterCompilationDiagnostic;
12
12
  }
@@ -1,2 +1,2 @@
1
1
  import { Configuration } from '../../configuration';
2
- export declare function deleteOutDirIfEnabled(configuration: Required<Configuration>, appName: string, dirPath: string): Promise<void>;
2
+ export declare function deleteOutDirIfEnabled(configuration: Required<Configuration>, appName: string | undefined, dirPath: string): Promise<void>;
@@ -7,7 +7,7 @@ import { Configuration } from '../../configuration';
7
7
  * @param appName Application name.
8
8
  * @returns The builder to use.
9
9
  */
10
- export declare function getBuilder(configuration: Required<Configuration>, cmdOptions: Input[], appName: string): {
10
+ export declare function getBuilder(configuration: Required<Configuration>, cmdOptions: Input[], appName: string | undefined): {
11
11
  type: "webpack";
12
12
  options?: import("../../configuration").WebpackBuilderOptions;
13
13
  } | {
@@ -7,4 +7,4 @@ import { Configuration } from '../../configuration';
7
7
  * @param appName Application name.
8
8
  * @returns The path to the tsc configuration file to use.
9
9
  */
10
- export declare function getTscConfigPath(configuration: Required<Configuration>, cmdOptions: Input[], appName: string): string;
10
+ export declare function getTscConfigPath(configuration: Required<Configuration>, cmdOptions: Input[], appName: string | undefined): string;
@@ -7,4 +7,4 @@ import { Configuration } from '../../configuration';
7
7
  * @param appName Application name.
8
8
  * @returns The path to the webpack configuration file to use.
9
9
  */
10
- export declare function getWebpackConfigPath(configuration: Required<Configuration>, cmdOptions: Input[], appName: string): string | undefined;
10
+ export declare function getWebpackConfigPath(configuration: Required<Configuration>, cmdOptions: Input[], appName: string | undefined): string | undefined;
@@ -13,7 +13,7 @@ export declare class SwcCompiler extends BaseCompiler {
13
13
  private readonly pluginMetadataGenerator;
14
14
  private readonly typeCheckerHost;
15
15
  constructor(pluginsLoader: PluginsLoader);
16
- run(configuration: Required<Configuration>, tsConfigPath: string, appName: string, extras: SwcCompilerExtras, onSuccess?: () => void): Promise<void>;
16
+ run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras: SwcCompilerExtras, onSuccess?: () => void): Promise<void>;
17
17
  private runTypeChecker;
18
18
  private runSwc;
19
19
  private loadSwcCliBinary;
@@ -51,7 +51,7 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
51
51
  if (extras.watch) {
52
52
  const args = [
53
53
  tsConfigPath,
54
- appName,
54
+ appName ?? 'undefined',
55
55
  configuration.sourceRoot ?? 'src',
56
56
  JSON.stringify(configuration.compilerOptions.plugins ?? []),
57
57
  ];
@@ -14,7 +14,7 @@ export declare class WatchCompiler extends BaseCompiler<TypescriptWatchCompilerE
14
14
  private readonly tsConfigProvider;
15
15
  private readonly typescriptLoader;
16
16
  constructor(pluginsLoader: PluginsLoader, tsConfigProvider: TsConfigProvider, typescriptLoader: TypeScriptBinaryLoader);
17
- run(configuration: Required<Configuration>, tsConfigPath: string, appName: string, extras: TypescriptWatchCompilerExtras, onSuccess?: () => void): void;
17
+ run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras: TypescriptWatchCompilerExtras, onSuccess?: () => void): void;
18
18
  private overrideCreateProgramFn;
19
19
  private createDiagnosticReporter;
20
20
  private createWatchStatusChanged;
@@ -15,7 +15,7 @@ type WebpackCompilerExtras = {
15
15
  };
16
16
  export declare class WebpackCompiler extends BaseCompiler<WebpackCompilerExtras> {
17
17
  constructor(pluginsLoader: PluginsLoader);
18
- run(configuration: Required<Configuration>, tsConfigPath: string, appName: string, extras: WebpackCompilerExtras, onSuccess?: () => void): void;
18
+ run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras: WebpackCompilerExtras, onSuccess?: () => void): void;
19
19
  private createAfterCallback;
20
20
  }
21
21
  export {};
@@ -25,9 +25,7 @@ class NestConfigurationLoader {
25
25
  ? this.reader.read(name)
26
26
  : this.reader.readAnyOf([
27
27
  'nest-cli.json',
28
- '.nestcli.json',
29
28
  '.nest-cli.json',
30
- 'nest.json',
31
29
  ]);
32
30
  if (contentOrError) {
33
31
  const isMissingPermissionsError = contentOrError instanceof readers_1.ReaderFileLackPermissionsError;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSelect = exports.generateInput = void 0;
4
4
  const generateInput = (name, message) => {
5
5
  return (defaultAnswer) => ({
6
- type: 'input',
7
6
  name,
8
7
  message,
9
8
  default: defaultAnswer,
@@ -12,12 +11,17 @@ const generateInput = (name, message) => {
12
11
  exports.generateInput = generateInput;
13
12
  const generateSelect = (name) => {
14
13
  return (message) => {
15
- return (choices) => ({
16
- type: 'list',
17
- name,
18
- message,
19
- choices,
20
- });
14
+ return (choices) => {
15
+ const choicesFormatted = choices.map((choice) => ({
16
+ name: choice,
17
+ value: choice,
18
+ }));
19
+ return {
20
+ name,
21
+ message,
22
+ choices: choicesFormatted,
23
+ };
24
+ };
21
25
  };
22
26
  };
23
27
  exports.generateSelect = generateSelect;
@@ -1,21 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomCollection = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
4
+ const tools_1 = require("@angular-devkit/schematics/tools");
6
5
  const abstract_collection_1 = require("./abstract.collection");
7
6
  class CustomCollection extends abstract_collection_1.AbstractCollection {
8
7
  getSchematics() {
9
- const collectionPackagePath = (0, path_1.dirname)(require.resolve(this.collection));
10
- const collectionPath = (0, path_1.join)(collectionPackagePath, 'collection.json');
11
- const collection = JSON.parse((0, fs_1.readFileSync)(collectionPath, 'utf8'));
12
- const schematics = Object.entries(collection.schematics).map(([name, value]) => {
13
- const schematic = value;
14
- const description = schematic.description;
15
- const alias = schematic?.aliases?.length ? schematic.aliases[0] : '';
16
- return { name, description, alias };
17
- });
18
- return schematics;
8
+ const workflow = new tools_1.NodeWorkflow(process.cwd(), {});
9
+ const collection = workflow.engine.createCollection(this.collection);
10
+ const collectionDescriptions = [
11
+ collection.description,
12
+ ...(collection.baseDescriptions ?? []),
13
+ ];
14
+ const usedNames = new Set();
15
+ const schematics = [];
16
+ for (const collectionDesc of collectionDescriptions) {
17
+ const schematicsDescs = Object.entries(collectionDesc.schematics);
18
+ for (const [name, { description, aliases = [] }] of schematicsDescs) {
19
+ if (usedNames.has(name)) {
20
+ continue;
21
+ }
22
+ usedNames.add(name);
23
+ const alias = aliases.find((a) => !usedNames.has(a)) ?? name;
24
+ for (const alias of aliases) {
25
+ usedNames.add(alias);
26
+ }
27
+ schematics.push({ name, alias, description });
28
+ }
29
+ }
30
+ return schematics.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
19
31
  }
20
32
  }
21
33
  exports.CustomCollection = CustomCollection;
@@ -1,4 +1,5 @@
1
1
  export declare const MESSAGES: {
2
+ PROJECT_NAME_QUESTION: string;
2
3
  PROJECT_SELECTION_QUESTION: string;
3
4
  LIBRARY_PROJECT_SELECTION_QUESTION: string;
4
5
  DRY_RUN_MODE: string;
@@ -4,12 +4,13 @@ exports.MESSAGES = void 0;
4
4
  const chalk = require("chalk");
5
5
  const emojis_1 = require("./emojis");
6
6
  exports.MESSAGES = {
7
+ PROJECT_NAME_QUESTION: 'What name would you like to use for the new project?',
7
8
  PROJECT_SELECTION_QUESTION: 'Which project would you like to generate to?',
8
9
  LIBRARY_PROJECT_SELECTION_QUESTION: 'Which project would you like to add the library to?',
9
10
  DRY_RUN_MODE: 'Command has been executed in dry run mode, nothing changed!',
10
11
  PROJECT_INFORMATION_START: `${emojis_1.EMOJIS.ZAP} We will scaffold your app in a few seconds..`,
11
12
  RUNNER_EXECUTION_ERROR: (command) => `\nFailed to execute command: ${command}`,
12
- PACKAGE_MANAGER_QUESTION: `Which package manager would you ${emojis_1.EMOJIS.HEART} to use?`,
13
+ PACKAGE_MANAGER_QUESTION: `Which package manager would you ${emojis_1.EMOJIS.HEART} to use?`,
13
14
  PACKAGE_MANAGER_INSTALLATION_IN_PROGRESS: `Installation in progress... ${emojis_1.EMOJIS.COFFEE}`,
14
15
  PACKAGE_MANAGER_UPDATE_IN_PROGRESS: `Installation in progress... ${emojis_1.EMOJIS.COFFEE}`,
15
16
  PACKAGE_MANAGER_UPGRADE_IN_PROGRESS: `Installation in progress... ${emojis_1.EMOJIS.COFFEE}`,
@@ -7,7 +7,7 @@ exports.getSpecFileSuffix = getSpecFileSuffix;
7
7
  exports.askForProjectName = askForProjectName;
8
8
  exports.moveDefaultProjectToStart = moveDefaultProjectToStart;
9
9
  exports.hasValidOptionFlag = hasValidOptionFlag;
10
- const inquirer = require("inquirer");
10
+ const prompts_1 = require("@inquirer/prompts");
11
11
  const get_value_or_default_1 = require("../compiler/helpers/get-value-or-default");
12
12
  const questions_1 = require("../questions/questions");
13
13
  function shouldAskForProject(schematic, configurationProjects, appName) {
@@ -69,8 +69,7 @@ async function askForProjectName(promptQuestion, projects) {
69
69
  const questions = [
70
70
  (0, questions_1.generateSelect)('appName')(promptQuestion)(projects),
71
71
  ];
72
- const prompt = inquirer.createPromptModule();
73
- return prompt(questions);
72
+ return (0, prompts_1.select)(questions);
74
73
  }
75
74
  function moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel) {
76
75
  let projects = configuration.projects != null ? Object.keys(configuration.projects) : [];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "10.4.8",
3
+ "version": "11.0.0-next.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "engines": {
9
- "node": ">= 16.14"
9
+ "node": ">= 20.11"
10
10
  },
11
11
  "bin": {
12
12
  "nest": "bin/nest.js"
@@ -38,17 +38,17 @@
38
38
  },
39
39
  "homepage": "https://github.com/nestjs/nest-cli#readme",
40
40
  "dependencies": {
41
- "@angular-devkit/core": "17.3.11",
42
- "@angular-devkit/schematics": "17.3.11",
43
- "@angular-devkit/schematics-cli": "17.3.11",
41
+ "@angular-devkit/core": "19.0.1",
42
+ "@angular-devkit/schematics": "19.0.1",
43
+ "@angular-devkit/schematics-cli": "19.0.1",
44
+ "@inquirer/prompts": "5.3.8",
44
45
  "@nestjs/schematics": "^10.0.1",
45
46
  "chalk": "4.1.2",
46
- "chokidar": "3.6.0",
47
+ "chokidar": "4.0.1",
47
48
  "cli-table3": "0.6.5",
48
49
  "commander": "4.1.1",
49
50
  "fork-ts-checker-webpack-plugin": "9.0.2",
50
- "glob": "10.4.5",
51
- "inquirer": "8.2.6",
51
+ "glob": "11.0.0",
52
52
  "node-emoji": "1.11.0",
53
53
  "ora": "5.4.1",
54
54
  "tree-kill": "1.2.2",
@@ -62,7 +62,7 @@
62
62
  "@commitlint/cli": "19.6.0",
63
63
  "@commitlint/config-angular": "19.6.0",
64
64
  "@swc/cli": "0.5.1",
65
- "@swc/core": "1.9.2",
65
+ "@swc/core": "1.9.3",
66
66
  "@types/inquirer": "9.0.7",
67
67
  "@types/jest": "29.5.14",
68
68
  "@types/node": "22.9.1",
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "../../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "extends": ["../simple/collection.json"],
4
+ "schematics": {
5
+ "simple1": {
6
+ "factory": "factory",
7
+ "description": "Override schematic 1",
8
+ "aliases": ["s1", "simp1"]
9
+ },
10
+ "simple2": {
11
+ "factory": "factory",
12
+ "description": "Override schematic 2",
13
+ "aliases": ["os2", "s2", "simp2"]
14
+ },
15
+ "extend1": {
16
+ "factory": "factory",
17
+ "description": "Extended schematic 1",
18
+ "aliases": ["x1", "ext1"]
19
+ },
20
+ "extend2": {
21
+ "factory": "factory",
22
+ "description": "Extended schematic 2",
23
+ "aliases": ["x2", "ext2", "s3", "simp3"]
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../../../../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "package1": {
5
+ "factory": "factory",
6
+ "description": "Package schematic 1",
7
+ "aliases": ["pkg1"]
8
+ }
9
+ }
10
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "package",
3
+ "version": "0.0.0",
4
+ "schematics": "./a/b/c/collection.json"
5
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "../../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "simple1": {
5
+ "factory": "factory",
6
+ "description": "Simple schematic 1",
7
+ "aliases": ["s1", "simp1"]
8
+ },
9
+ "simple2": {
10
+ "factory": "factory",
11
+ "description": "Simple schematic 2",
12
+ "aliases": ["s2", "simp2"]
13
+ },
14
+ "simple3": {
15
+ "factory": "factory",
16
+ "description": "Simple schematic 3",
17
+ "aliases": ["s3", "simp3"]
18
+ }
19
+ }
20
+ }