@nestjs/cli 11.0.15 → 12.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/actions/abstract.action.d.ts +1 -2
  2. package/actions/abstract.action.js +1 -5
  3. package/actions/add.action.d.ts +3 -4
  4. package/actions/add.action.js +38 -52
  5. package/actions/build.action.d.ts +11 -10
  6. package/actions/build.action.js +85 -72
  7. package/actions/generate.action.d.ts +3 -3
  8. package/actions/generate.action.js +56 -59
  9. package/actions/index.d.ts +7 -7
  10. package/actions/index.js +7 -23
  11. package/actions/info.action.d.ts +12 -28
  12. package/actions/info.action.js +47 -55
  13. package/actions/new.action.d.ts +3 -3
  14. package/actions/new.action.js +75 -105
  15. package/actions/start.action.d.ts +4 -7
  16. package/actions/start.action.js +36 -46
  17. package/bin/nest.js +14 -10
  18. package/commands/abstract.command.d.ts +3 -3
  19. package/commands/abstract.command.js +2 -5
  20. package/commands/add.command.d.ts +3 -3
  21. package/commands/add.command.js +13 -20
  22. package/commands/build.command.d.ts +3 -3
  23. package/commands/build.command.js +25 -54
  24. package/commands/command.input.js +1 -2
  25. package/commands/command.loader.d.ts +2 -2
  26. package/commands/command.loader.js +18 -22
  27. package/commands/context/add.context.d.ts +7 -0
  28. package/commands/context/add.context.js +1 -0
  29. package/commands/context/build.context.d.ts +13 -0
  30. package/commands/context/build.context.js +1 -0
  31. package/commands/context/generate.context.d.ts +15 -0
  32. package/commands/context/generate.context.js +1 -0
  33. package/commands/context/index.d.ts +5 -0
  34. package/commands/context/index.js +5 -0
  35. package/commands/context/new.context.d.ts +11 -0
  36. package/commands/context/new.context.js +1 -0
  37. package/commands/context/start.context.d.ts +19 -0
  38. package/commands/context/start.context.js +1 -0
  39. package/commands/generate.command.d.ts +3 -3
  40. package/commands/generate.command.js +26 -54
  41. package/commands/index.d.ts +3 -2
  42. package/commands/index.js +3 -18
  43. package/commands/info.command.d.ts +3 -3
  44. package/commands/info.command.js +2 -6
  45. package/commands/new.command.d.ts +3 -3
  46. package/commands/new.command.js +24 -33
  47. package/commands/start.command.d.ts +3 -3
  48. package/commands/start.command.js +34 -71
  49. package/lib/compiler/assets-manager.d.ts +1 -1
  50. package/lib/compiler/assets-manager.js +27 -33
  51. package/lib/compiler/base-compiler.d.ts +5 -5
  52. package/lib/compiler/base-compiler.js +10 -13
  53. package/lib/compiler/compiler.d.ts +6 -6
  54. package/lib/compiler/compiler.js +7 -9
  55. package/lib/compiler/defaults/rspack-defaults.d.ts +2 -0
  56. package/lib/compiler/defaults/rspack-defaults.js +117 -0
  57. package/lib/compiler/defaults/swc-defaults.d.ts +1 -1
  58. package/lib/compiler/defaults/swc-defaults.js +1 -5
  59. package/lib/compiler/defaults/webpack-defaults.d.ts +2 -2
  60. package/lib/compiler/defaults/webpack-defaults.js +13 -16
  61. package/lib/compiler/helpers/append-extension.js +3 -6
  62. package/lib/compiler/helpers/copy-path-resolve.js +2 -5
  63. package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
  64. package/lib/compiler/helpers/delete-out-dir.js +5 -8
  65. package/lib/compiler/helpers/get-builder.d.ts +9 -7
  66. package/lib/compiler/helpers/get-builder.js +3 -6
  67. package/lib/compiler/helpers/get-rspack-config-path.d.ts +9 -0
  68. package/lib/compiler/helpers/get-rspack-config-path.js +15 -0
  69. package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
  70. package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
  71. package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
  72. package/lib/compiler/helpers/get-value-or-default.js +3 -8
  73. package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
  74. package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
  75. package/lib/compiler/helpers/manual-restart.js +4 -8
  76. package/lib/compiler/helpers/tsconfig-provider.d.ts +1 -1
  77. package/lib/compiler/helpers/tsconfig-provider.js +8 -11
  78. package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
  79. package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
  80. package/lib/compiler/plugins/plugin-metadata-generator.d.ts +1 -1
  81. package/lib/compiler/plugins/plugin-metadata-generator.js +10 -13
  82. package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
  83. package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
  84. package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
  85. package/lib/compiler/plugins/plugins-loader.js +13 -13
  86. package/lib/compiler/rspack-compiler.d.ts +19 -0
  87. package/lib/compiler/rspack-compiler.js +97 -0
  88. package/lib/compiler/swc/constants.d.ts +0 -1
  89. package/lib/compiler/swc/constants.js +9 -13
  90. package/lib/compiler/swc/forked-type-checker.js +13 -18
  91. package/lib/compiler/swc/swc-compiler.d.ts +4 -4
  92. package/lib/compiler/swc/swc-compiler.js +41 -39
  93. package/lib/compiler/swc/type-checker-host.js +12 -18
  94. package/lib/compiler/typescript-loader.js +5 -7
  95. package/lib/compiler/watch-compiler.d.ts +5 -5
  96. package/lib/compiler/watch-compiler.js +14 -18
  97. package/lib/compiler/webpack-compiler.d.ts +6 -7
  98. package/lib/compiler/webpack-compiler.js +14 -18
  99. package/lib/configuration/configuration.d.ts +9 -4
  100. package/lib/configuration/configuration.js +1 -2
  101. package/lib/configuration/configuration.loader.d.ts +1 -1
  102. package/lib/configuration/configuration.loader.js +1 -2
  103. package/lib/configuration/defaults.d.ts +2 -1
  104. package/lib/configuration/defaults.js +8 -10
  105. package/lib/configuration/index.d.ts +3 -3
  106. package/lib/configuration/index.js +3 -19
  107. package/lib/configuration/nest-configuration.loader.d.ts +3 -3
  108. package/lib/configuration/nest-configuration.loader.js +11 -20
  109. package/lib/package-managers/abstract.package-manager.d.ts +4 -4
  110. package/lib/package-managers/abstract.package-manager.js +19 -30
  111. package/lib/package-managers/index.d.ts +8 -8
  112. package/lib/package-managers/index.js +8 -24
  113. package/lib/package-managers/npm.package-manager.d.ts +2 -2
  114. package/lib/package-managers/npm.package-manager.js +6 -10
  115. package/lib/package-managers/package-manager-commands.js +1 -2
  116. package/lib/package-managers/package-manager.factory.d.ts +2 -2
  117. package/lib/package-managers/package-manager.factory.js +16 -20
  118. package/lib/package-managers/package-manager.js +2 -5
  119. package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
  120. package/lib/package-managers/pnpm.package-manager.js +6 -10
  121. package/lib/package-managers/project.dependency.js +1 -2
  122. package/lib/package-managers/yarn.package-manager.d.ts +2 -2
  123. package/lib/package-managers/yarn.package-manager.js +6 -10
  124. package/lib/questions/questions.d.ts +5 -1
  125. package/lib/questions/questions.js +2 -7
  126. package/lib/readers/file-system.reader.d.ts +1 -1
  127. package/lib/readers/file-system.reader.js +6 -9
  128. package/lib/readers/index.d.ts +2 -2
  129. package/lib/readers/index.js +2 -18
  130. package/lib/readers/reader.js +3 -5
  131. package/lib/runners/abstract.runner.js +10 -12
  132. package/lib/runners/git.runner.d.ts +1 -1
  133. package/lib/runners/git.runner.js +2 -6
  134. package/lib/runners/index.d.ts +3 -3
  135. package/lib/runners/index.js +3 -19
  136. package/lib/runners/npm.runner.d.ts +1 -1
  137. package/lib/runners/npm.runner.js +2 -6
  138. package/lib/runners/pnpm.runner.d.ts +1 -1
  139. package/lib/runners/pnpm.runner.js +2 -6
  140. package/lib/runners/runner.factory.d.ts +6 -6
  141. package/lib/runners/runner.factory.js +15 -20
  142. package/lib/runners/runner.js +2 -5
  143. package/lib/runners/schematic.runner.d.ts +1 -1
  144. package/lib/runners/schematic.runner.js +5 -7
  145. package/lib/runners/yarn.runner.d.ts +1 -1
  146. package/lib/runners/yarn.runner.js +2 -6
  147. package/lib/schematics/abstract.collection.d.ts +3 -3
  148. package/lib/schematics/abstract.collection.js +3 -5
  149. package/lib/schematics/collection.factory.d.ts +2 -2
  150. package/lib/schematics/collection.factory.js +9 -13
  151. package/lib/schematics/collection.js +2 -5
  152. package/lib/schematics/custom.collection.d.ts +2 -2
  153. package/lib/schematics/custom.collection.js +4 -8
  154. package/lib/schematics/index.d.ts +4 -4
  155. package/lib/schematics/index.js +4 -20
  156. package/lib/schematics/nest.collection.d.ts +3 -3
  157. package/lib/schematics/nest.collection.js +104 -108
  158. package/lib/schematics/schematic.option.js +7 -9
  159. package/lib/ui/banner.js +1 -4
  160. package/lib/ui/emojis.d.ts +17 -17
  161. package/lib/ui/emojis.js +19 -22
  162. package/lib/ui/errors.js +1 -5
  163. package/lib/ui/index.d.ts +5 -5
  164. package/lib/ui/index.js +5 -21
  165. package/lib/ui/messages.js +15 -19
  166. package/lib/ui/prefixes.js +3 -6
  167. package/lib/utils/formatting.js +1 -4
  168. package/lib/utils/get-default-tsconfig-path.js +4 -7
  169. package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
  170. package/lib/utils/is-module-available.js +3 -4
  171. package/lib/utils/load-configuration.d.ts +1 -1
  172. package/lib/utils/load-configuration.js +4 -7
  173. package/lib/utils/local-binaries.d.ts +1 -1
  174. package/lib/utils/local-binaries.js +8 -11
  175. package/lib/utils/os-info.utils.js +1 -4
  176. package/lib/utils/project-utils.d.ts +1 -3
  177. package/lib/utils/project-utils.js +16 -28
  178. package/lib/utils/remaining-flags.d.ts +2 -2
  179. package/lib/utils/remaining-flags.js +2 -5
  180. package/lib/utils/tree-kill.js +7 -10
  181. package/lib/utils/type-assertions.js +1 -4
  182. package/package.json +31 -33
@@ -1,59 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StartAction = void 0;
4
- const ansis_1 = require("ansis");
5
- const child_process_1 = require("child_process");
6
- const fs = require("fs");
7
- const path_1 = require("path");
8
- const get_tsc_config_path_1 = require("../lib/compiler/helpers/get-tsc-config.path");
9
- const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default");
10
- const defaults_1 = require("../lib/configuration/defaults");
11
- const ui_1 = require("../lib/ui");
12
- const tree_kill_1 = require("../lib/utils/tree-kill");
13
- const type_assertions_1 = require("../lib/utils/type-assertions");
14
- const build_action_1 = require("./build.action");
15
- class StartAction extends build_action_1.BuildAction {
16
- async handle(commandInputs, commandOptions) {
1
+ import { red } from 'ansis';
2
+ import { spawn } from 'child_process';
3
+ import * as fs from 'fs';
4
+ import { join } from 'path';
5
+ import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path.js';
6
+ import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default.js';
7
+ import { defaultConfiguration, defaultOutDir, } from '../lib/configuration/defaults.js';
8
+ import { ERROR_PREFIX } from '../lib/ui/index.js';
9
+ import { treeKillSync as killProcessSync } from '../lib/utils/tree-kill.js';
10
+ import { assertNonArray } from '../lib/utils/type-assertions.js';
11
+ import { BuildAction } from './build.action.js';
12
+ export class StartAction extends BuildAction {
13
+ async handle(context) {
17
14
  try {
18
- const configFileName = commandOptions.find((option) => option.name === 'config').value;
15
+ const configFileName = context.config;
19
16
  const configuration = await this.loader.load(configFileName);
20
- const appName = commandInputs.find((input) => input.name === 'app')
21
- .value;
22
- const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
23
- const debugModeOption = commandOptions.find((option) => option.name === 'debug');
24
- const watchModeOption = commandOptions.find((option) => option.name === 'watch');
25
- const isWatchEnabled = !!(watchModeOption && watchModeOption.value);
26
- const watchAssetsModeOption = commandOptions.find((option) => option.name === 'watchAssets');
27
- const isWatchAssetsEnabled = !!(watchAssetsModeOption && watchAssetsModeOption.value);
28
- const debugFlag = debugModeOption && debugModeOption.value;
29
- (0, type_assertions_1.assertNonArray)(debugFlag);
30
- const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', commandOptions, defaults_1.defaultConfiguration.exec);
17
+ const appName = context.app;
18
+ const pathToTsconfig = getTscConfigPath(configuration, context, appName);
19
+ const isWatchEnabled = !!context.watch;
20
+ const isWatchAssetsEnabled = !!context.watchAssets;
21
+ const debugFlag = context.debug;
22
+ assertNonArray(debugFlag);
23
+ const binaryToRun = getValueOrDefault(configuration, 'exec', appName, 'exec', context, defaultConfiguration.exec);
31
24
  const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
32
- const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
33
- const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', commandOptions, defaults_1.defaultConfiguration.entryFile);
34
- const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', commandOptions, defaults_1.defaultConfiguration.sourceRoot);
35
- const shellOption = commandOptions.find((option) => option.name === 'shell');
36
- const useShell = !!shellOption?.value;
37
- const envFileOption = commandOptions.find((option) => option.name === 'envFile');
38
- const envFile = (envFileOption?.value ?? []);
25
+ const outDir = tsOptions.outDir || defaultOutDir;
26
+ const entryFile = getValueOrDefault(configuration, 'entryFile', appName, 'entryFile', context, defaultConfiguration.entryFile);
27
+ const sourceRoot = getValueOrDefault(configuration, 'sourceRoot', appName, 'sourceRoot', context, defaultConfiguration.sourceRoot);
28
+ const useShell = !!context.shell;
29
+ const envFile = context.envFile ?? [];
39
30
  const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, {
40
31
  shell: useShell,
41
32
  envFile,
42
33
  });
43
- await this.runBuild(commandInputs, commandOptions, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
34
+ await this.runBuild(appName ? [appName] : [], context, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
44
35
  }
45
36
  catch (err) {
46
37
  if (err instanceof Error) {
47
- console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
38
+ console.error(`\n${ERROR_PREFIX} ${err.message}\n`);
48
39
  }
49
40
  else {
50
- console.error(`\n${(0, ansis_1.red)(err)}\n`);
41
+ console.error(`\n${red(err)}\n`);
51
42
  }
52
43
  }
53
44
  }
54
45
  createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, options) {
55
46
  let childProcessRef;
56
- process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
47
+ process.on('exit', () => childProcessRef && killProcessSync(childProcessRef.pid));
57
48
  return () => {
58
49
  if (childProcessRef) {
59
50
  childProcessRef.removeAllListeners('exit');
@@ -64,8 +55,8 @@ class StartAction extends build_action_1.BuildAction {
64
55
  });
65
56
  childProcessRef.on('exit', () => (childProcessRef = undefined));
66
57
  });
67
- childProcessRef.stdin && childProcessRef.stdin.pause();
68
- (0, tree_kill_1.treeKillSync)(childProcessRef.pid);
58
+ childProcessRef.stdin?.pause?.();
59
+ killProcessSync(childProcessRef.pid);
69
60
  }
70
61
  else {
71
62
  childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
@@ -80,9 +71,9 @@ class StartAction extends build_action_1.BuildAction {
80
71
  };
81
72
  }
82
73
  spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, options) {
83
- let outputFilePath = (0, path_1.join)(outDirName, sourceRoot, entryFile);
74
+ let outputFilePath = join(outDirName, sourceRoot, entryFile);
84
75
  if (!fs.existsSync(outputFilePath + '.js')) {
85
- outputFilePath = (0, path_1.join)(outDirName, entryFile);
76
+ outputFilePath = join(outDirName, entryFile);
86
77
  }
87
78
  let childProcessArgs = [];
88
79
  const argsStartIndex = process.argv.indexOf('--');
@@ -114,9 +105,8 @@ class StartAction extends build_action_1.BuildAction {
114
105
  };
115
106
  if (options.shell) {
116
107
  const command = [binaryToRun, ...processArgs].join(' ');
117
- return (0, child_process_1.spawn)(command, spawnOptions);
108
+ return spawn(command, spawnOptions);
118
109
  }
119
- return (0, child_process_1.spawn)(binaryToRun, processArgs, spawnOptions);
110
+ return spawn(binaryToRun, processArgs, spawnOptions);
120
111
  }
121
112
  }
122
- exports.StartAction = StartAction;
package/bin/nest.js CHANGED
@@ -1,23 +1,27 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const commander = require("commander");
5
- const commands_1 = require("../commands");
6
- const local_binaries_1 = require("../lib/utils/local-binaries");
2
+ import { createRequire } from 'module';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname } from 'path';
5
+ import { Command } from 'commander';
6
+ import { CommandLoader } from '../commands/index.js';
7
+ import { loadLocalBinCommandLoader, localBinExists, } from '../lib/utils/local-binaries.js';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ const require = createRequire(import.meta.url);
7
11
  const bootstrap = async () => {
8
- const program = commander;
12
+ const program = new Command();
9
13
  program
10
14
  .version(require('../package.json').version, '-v, --version', 'Output the current version.')
11
15
  .usage('<command> [options]')
12
16
  .helpOption('-h, --help', 'Output usage information.');
13
- if ((0, local_binaries_1.localBinExists)()) {
14
- const localCommandLoader = (0, local_binaries_1.loadLocalBinCommandLoader)();
17
+ if (localBinExists()) {
18
+ const localCommandLoader = loadLocalBinCommandLoader();
15
19
  await localCommandLoader.load(program);
16
20
  }
17
21
  else {
18
- await commands_1.CommandLoader.load(program);
22
+ await CommandLoader.load(program);
19
23
  }
20
- await commander.parseAsync(process.argv);
24
+ await program.parseAsync(process.argv);
21
25
  if (!process.argv.slice(2).length) {
22
26
  program.outputHelp();
23
27
  }
@@ -1,7 +1,7 @@
1
- import { CommanderStatic } from 'commander';
2
- import { AbstractAction } from '../actions/abstract.action';
1
+ import { Command } from 'commander';
2
+ import { AbstractAction } from '../actions/abstract.action.js';
3
3
  export declare abstract class AbstractCommand {
4
4
  protected action: AbstractAction;
5
5
  constructor(action: AbstractAction);
6
- abstract load(program: CommanderStatic): void;
6
+ abstract load(program: Command): void;
7
7
  }
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractCommand = void 0;
4
- class AbstractCommand {
1
+ export class AbstractCommand {
2
+ action;
5
3
  constructor(action) {
6
4
  this.action = action;
7
5
  }
8
6
  }
9
- exports.AbstractCommand = AbstractCommand;
@@ -1,5 +1,5 @@
1
- import { CommanderStatic } from 'commander';
2
- import { AbstractCommand } from './abstract.command';
1
+ import { Command } from 'commander';
2
+ import { AbstractCommand } from './abstract.command.js';
3
3
  export declare class AddCommand extends AbstractCommand {
4
- load(program: CommanderStatic): void;
4
+ load(program: Command): void;
5
5
  }
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddCommand = void 0;
4
- const remaining_flags_1 = require("../lib/utils/remaining-flags");
5
- const abstract_command_1 = require("./abstract.command");
6
- class AddCommand extends abstract_command_1.AbstractCommand {
1
+ import { getRemainingFlags } from '../lib/utils/remaining-flags.js';
2
+ import { AbstractCommand } from './abstract.command.js';
3
+ export class AddCommand extends AbstractCommand {
7
4
  load(program) {
8
5
  program
9
6
  .command('add <library>')
@@ -13,24 +10,20 @@ class AddCommand extends abstract_command_1.AbstractCommand {
13
10
  .option('-s, --skip-install', 'Skip package installation.', false)
14
11
  .option('-p, --project [project]', 'Project in which to generate files.')
15
12
  .usage('<library> [options] [library-specific-options]')
16
- .action(async (library, command) => {
17
- const options = [];
18
- options.push({ name: 'dry-run', value: !!command.dryRun });
19
- options.push({ name: 'skip-install', value: command.skipInstall });
20
- options.push({
21
- name: 'project',
22
- value: command.project,
23
- });
24
- const inputs = [];
25
- inputs.push({ name: 'library', value: library });
26
- const flags = (0, remaining_flags_1.getRemainingFlags)(program);
13
+ .action(async (library, options) => {
14
+ const context = {
15
+ library,
16
+ dryRun: !!options.dryRun,
17
+ skipInstall: options.skipInstall,
18
+ project: options.project,
19
+ extraFlags: getRemainingFlags(program),
20
+ };
27
21
  try {
28
- await this.action.handle(inputs, options, flags);
22
+ await this.action.handle(context);
29
23
  }
30
- catch (err) {
24
+ catch {
31
25
  process.exit(1);
32
26
  }
33
27
  });
34
28
  }
35
29
  }
36
- exports.AddCommand = AddCommand;
@@ -1,5 +1,5 @@
1
- import { CommanderStatic } from 'commander';
2
- import { AbstractCommand } from './abstract.command';
1
+ import { Command } from 'commander';
2
+ import { AbstractCommand } from './abstract.command.js';
3
3
  export declare class BuildCommand extends AbstractCommand {
4
- load(program: CommanderStatic): void;
4
+ load(program: Command): void;
5
5
  }
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildCommand = void 0;
4
- const ui_1 = require("../lib/ui");
5
- const abstract_command_1 = require("./abstract.command");
6
- class BuildCommand extends abstract_command_1.AbstractCommand {
1
+ import { ERROR_PREFIX } from '../lib/ui/index.js';
2
+ import { AbstractCommand } from './abstract.command.js';
3
+ export class BuildCommand extends AbstractCommand {
7
4
  load(program) {
8
5
  program
9
6
  .command('build [apps...]')
10
7
  .option('-c, --config [path]', 'Path to nest-cli configuration file.')
11
8
  .option('-p, --path [path]', 'Path to tsconfig file.')
12
9
  .option('-w, --watch', 'Run in watch mode (live-reload).')
13
- .option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
10
+ .option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc, rspack).')
14
11
  .option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
15
12
  .option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).')
16
13
  .option('--type-check', 'Enable type checking (when SWC is used).')
@@ -19,56 +16,30 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
19
16
  .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
20
17
  .option('--all', 'Build all projects in a monorepo.')
21
18
  .description('Build Nest application.')
22
- .action(async (apps, command) => {
23
- const options = [];
24
- options.push({
25
- name: 'config',
26
- value: command.config,
27
- });
28
- const isWebpackEnabled = command.tsc ? false : command.webpack;
29
- options.push({ name: 'webpack', value: isWebpackEnabled });
30
- options.push({ name: 'watch', value: !!command.watch });
31
- options.push({ name: 'watchAssets', value: !!command.watchAssets });
32
- options.push({
33
- name: 'path',
34
- value: command.path,
35
- });
36
- options.push({
37
- name: 'webpackPath',
38
- value: command.webpackPath,
39
- });
40
- const availableBuilders = ['tsc', 'webpack', 'swc'];
41
- if (command.builder && !availableBuilders.includes(command.builder)) {
42
- console.error(ui_1.ERROR_PREFIX +
43
- ` Invalid builder option: ${command.builder}. Available builders: ${availableBuilders.join(', ')}`);
19
+ .action(async (apps, options) => {
20
+ const isWebpackEnabled = options.tsc ? false : options.webpack;
21
+ const availableBuilders = ['tsc', 'webpack', 'swc', 'rspack'];
22
+ if (options.builder && !availableBuilders.includes(options.builder)) {
23
+ console.error(ERROR_PREFIX +
24
+ ` Invalid builder option: ${options.builder}. Available builders: ${availableBuilders.join(', ')}`);
44
25
  return;
45
26
  }
46
- options.push({
47
- name: 'builder',
48
- value: command.builder,
49
- });
50
- options.push({
51
- name: 'typeCheck',
52
- value: command.typeCheck,
53
- });
54
- options.push({
55
- name: 'preserveWatchOutput',
56
- value: !!command.preserveWatchOutput &&
57
- !!command.watch &&
27
+ const context = {
28
+ apps: apps.length > 0 ? apps : [],
29
+ config: options.config,
30
+ webpack: isWebpackEnabled,
31
+ watch: !!options.watch,
32
+ watchAssets: !!options.watchAssets,
33
+ path: options.path,
34
+ webpackPath: options.webpackPath,
35
+ builder: options.builder,
36
+ typeCheck: options.typeCheck,
37
+ preserveWatchOutput: !!options.preserveWatchOutput &&
38
+ !!options.watch &&
58
39
  !isWebpackEnabled,
59
- });
60
- 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
- }
70
- await this.action.handle(inputs, options);
40
+ all: !!options.all,
41
+ };
42
+ await this.action.handle(context);
71
43
  });
72
44
  }
73
45
  }
74
- exports.BuildCommand = BuildCommand;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,5 +1,5 @@
1
- import { CommanderStatic } from 'commander';
1
+ import { Command } from 'commander';
2
2
  export declare class CommandLoader {
3
- static load(program: CommanderStatic): Promise<void>;
3
+ static load(program: Command): Promise<void>;
4
4
  private static handleInvalidCommand;
5
5
  }
@@ -1,31 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommandLoader = void 0;
4
- const ansis_1 = require("ansis");
5
- const actions_1 = require("../actions");
6
- const ui_1 = require("../lib/ui");
7
- const add_command_1 = require("./add.command");
8
- const build_command_1 = require("./build.command");
9
- const generate_command_1 = require("./generate.command");
10
- const info_command_1 = require("./info.command");
11
- const new_command_1 = require("./new.command");
12
- const start_command_1 = require("./start.command");
13
- class CommandLoader {
1
+ import { red } from 'ansis';
2
+ import { AddAction, BuildAction, GenerateAction, InfoAction, NewAction, StartAction, } from '../actions/index.js';
3
+ import { ERROR_PREFIX } from '../lib/ui/index.js';
4
+ import { AddCommand } from './add.command.js';
5
+ import { BuildCommand } from './build.command.js';
6
+ import { GenerateCommand } from './generate.command.js';
7
+ import { InfoCommand } from './info.command.js';
8
+ import { NewCommand } from './new.command.js';
9
+ import { StartCommand } from './start.command.js';
10
+ export class CommandLoader {
14
11
  static async load(program) {
15
- new new_command_1.NewCommand(new actions_1.NewAction()).load(program);
16
- new build_command_1.BuildCommand(new actions_1.BuildAction()).load(program);
17
- new start_command_1.StartCommand(new actions_1.StartAction()).load(program);
18
- new info_command_1.InfoCommand(new actions_1.InfoAction()).load(program);
19
- new add_command_1.AddCommand(new actions_1.AddAction()).load(program);
20
- await new generate_command_1.GenerateCommand(new actions_1.GenerateAction()).load(program);
12
+ new NewCommand(new NewAction()).load(program);
13
+ new BuildCommand(new BuildAction()).load(program);
14
+ new StartCommand(new StartAction()).load(program);
15
+ new InfoCommand(new InfoAction()).load(program);
16
+ new AddCommand(new AddAction()).load(program);
17
+ await new GenerateCommand(new GenerateAction()).load(program);
21
18
  this.handleInvalidCommand(program);
22
19
  }
23
20
  static handleInvalidCommand(program) {
24
21
  program.on('command:*', () => {
25
- console.error(`\n${ui_1.ERROR_PREFIX} Invalid command: ${(0, ansis_1.red) `%s`}`, program.args.join(' '));
26
- console.log(`See ${(0, ansis_1.red) `--help`} for a list of available commands.\n`);
22
+ console.error(`\n${ERROR_PREFIX} Invalid command: ${red `%s`}`, program.args.join(' '));
23
+ console.error(`See ${red `--help`} for a list of available commands.\n`);
27
24
  process.exit(1);
28
25
  });
29
26
  }
30
27
  }
31
- exports.CommandLoader = CommandLoader;
@@ -0,0 +1,7 @@
1
+ export interface AddCommandContext {
2
+ library: string;
3
+ dryRun: boolean;
4
+ skipInstall: boolean;
5
+ project?: string;
6
+ extraFlags: string[];
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export interface BuildCommandContext {
2
+ apps: string[];
3
+ config?: string;
4
+ webpack?: boolean;
5
+ watch: boolean;
6
+ watchAssets: boolean;
7
+ path?: string;
8
+ webpackPath?: string;
9
+ builder?: string;
10
+ typeCheck?: boolean;
11
+ preserveWatchOutput: boolean;
12
+ all: boolean;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ export interface GenerateCommandContext {
2
+ schematic: string;
3
+ name?: string;
4
+ path?: string;
5
+ dryRun: boolean;
6
+ flat?: boolean;
7
+ spec: boolean | {
8
+ value: boolean;
9
+ passedAsInput: boolean;
10
+ };
11
+ specFileSuffix?: string;
12
+ collection?: string;
13
+ project?: string;
14
+ skipImport: boolean;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './add.context.js';
2
+ export * from './build.context.js';
3
+ export * from './generate.context.js';
4
+ export * from './new.context.js';
5
+ export * from './start.context.js';
@@ -0,0 +1,5 @@
1
+ export * from './add.context.js';
2
+ export * from './build.context.js';
3
+ export * from './generate.context.js';
4
+ export * from './new.context.js';
5
+ export * from './start.context.js';
@@ -0,0 +1,11 @@
1
+ export interface NewCommandContext {
2
+ name?: string;
3
+ directory?: string;
4
+ dryRun: boolean;
5
+ skipGit: boolean;
6
+ skipInstall: boolean;
7
+ packageManager?: string;
8
+ language: string;
9
+ collection: string;
10
+ strict: boolean;
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ export interface StartCommandContext {
2
+ app?: string;
3
+ config?: string;
4
+ webpack?: boolean;
5
+ watch: boolean;
6
+ watchAssets: boolean;
7
+ path?: string;
8
+ webpackPath?: string;
9
+ builder?: string;
10
+ typeCheck?: boolean;
11
+ preserveWatchOutput: boolean;
12
+ debug?: boolean | string;
13
+ exec?: string;
14
+ sourceRoot?: string;
15
+ entryFile?: string;
16
+ shell: boolean;
17
+ envFile: string[];
18
+ extraFlags: string[];
19
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
- import { CommanderStatic } from 'commander';
2
- import { AbstractCommand } from './abstract.command';
1
+ import { Command } from 'commander';
2
+ import { AbstractCommand } from './abstract.command.js';
3
3
  export declare class GenerateCommand extends AbstractCommand {
4
- load(program: CommanderStatic): Promise<void>;
4
+ load(program: Command): Promise<void>;
5
5
  private buildDescription;
6
6
  private buildSchematicsListAsTable;
7
7
  private getCollection;