@depup/nestjs__cli 11.0.24-depup.8 → 12.0.0-depup.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 (220) hide show
  1. package/README.md +6 -14
  2. package/actions/abstract.action.d.ts +1 -2
  3. package/actions/abstract.action.js +1 -5
  4. package/actions/add.action.d.ts +3 -4
  5. package/actions/add.action.js +44 -53
  6. package/actions/build.action.d.ts +18 -11
  7. package/actions/build.action.js +172 -79
  8. package/actions/deploy.action.d.ts +6 -0
  9. package/actions/deploy.action.js +51 -0
  10. package/actions/generate.action.d.ts +3 -3
  11. package/actions/generate.action.js +61 -59
  12. package/actions/index.d.ts +9 -7
  13. package/actions/index.js +9 -23
  14. package/actions/info.action.d.ts +18 -28
  15. package/actions/info.action.js +80 -60
  16. package/actions/new.action.d.ts +3 -3
  17. package/actions/new.action.js +108 -104
  18. package/actions/start.action.d.ts +4 -7
  19. package/actions/start.action.js +40 -47
  20. package/actions/upgrade.action.d.ts +6 -0
  21. package/actions/upgrade.action.js +53 -0
  22. package/bin/nest.js +11 -10
  23. package/changes.json +6 -38
  24. package/commands/abstract.command.d.ts +3 -3
  25. package/commands/abstract.command.js +2 -5
  26. package/commands/add.command.d.ts +3 -3
  27. package/commands/add.command.js +17 -20
  28. package/commands/build.command.d.ts +3 -3
  29. package/commands/build.command.js +52 -56
  30. package/commands/command.input.js +1 -2
  31. package/commands/command.loader.d.ts +2 -2
  32. package/commands/command.loader.js +29 -22
  33. package/commands/context/add.context.d.ts +7 -0
  34. package/commands/context/add.context.js +1 -0
  35. package/commands/context/build.context.d.ts +17 -0
  36. package/commands/context/build.context.js +1 -0
  37. package/commands/context/deploy.context.d.ts +7 -0
  38. package/commands/context/deploy.context.js +1 -0
  39. package/commands/context/generate.context.d.ts +18 -0
  40. package/commands/context/generate.context.js +1 -0
  41. package/commands/context/index.d.ts +7 -0
  42. package/commands/context/index.js +7 -0
  43. package/commands/context/new.context.d.ts +19 -0
  44. package/commands/context/new.context.js +1 -0
  45. package/commands/context/start.context.d.ts +22 -0
  46. package/commands/context/start.context.js +1 -0
  47. package/commands/context/upgrade.context.d.ts +11 -0
  48. package/commands/context/upgrade.context.js +1 -0
  49. package/commands/deploy.command.d.ts +5 -0
  50. package/commands/deploy.command.js +22 -0
  51. package/commands/generate.command.d.ts +3 -3
  52. package/commands/generate.command.js +35 -66
  53. package/commands/index.d.ts +3 -2
  54. package/commands/index.js +3 -18
  55. package/commands/info.command.d.ts +3 -3
  56. package/commands/info.command.js +4 -8
  57. package/commands/new.command.d.ts +3 -3
  58. package/commands/new.command.js +34 -36
  59. package/commands/start.command.d.ts +3 -3
  60. package/commands/start.command.js +48 -73
  61. package/commands/upgrade.command.d.ts +5 -0
  62. package/commands/upgrade.command.js +32 -0
  63. package/lib/compiler/assets-manager.d.ts +20 -8
  64. package/lib/compiler/assets-manager.js +199 -63
  65. package/lib/compiler/base-compiler.d.ts +5 -5
  66. package/lib/compiler/base-compiler.js +10 -13
  67. package/lib/compiler/compiler.d.ts +6 -6
  68. package/lib/compiler/compiler.js +7 -9
  69. package/lib/compiler/defaults/rspack-defaults.d.ts +3 -0
  70. package/lib/compiler/defaults/rspack-defaults.js +179 -0
  71. package/lib/compiler/defaults/swc-defaults.d.ts +5 -2
  72. package/lib/compiler/defaults/swc-defaults.js +22 -6
  73. package/lib/compiler/defaults/webpack-defaults.d.ts +2 -2
  74. package/lib/compiler/defaults/webpack-defaults.js +59 -19
  75. package/lib/compiler/helpers/append-extension.js +3 -6
  76. package/lib/compiler/helpers/copy-path-resolve.js +2 -5
  77. package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
  78. package/lib/compiler/helpers/delete-out-dir.js +45 -10
  79. package/lib/compiler/helpers/get-builder.d.ts +9 -7
  80. package/lib/compiler/helpers/get-builder.js +3 -6
  81. package/lib/compiler/helpers/get-effective-root-dir.d.ts +16 -0
  82. package/lib/compiler/helpers/get-effective-root-dir.js +56 -0
  83. package/lib/compiler/helpers/get-rspack-config-path.d.ts +10 -0
  84. package/lib/compiler/helpers/get-rspack-config-path.js +19 -0
  85. package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
  86. package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
  87. package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
  88. package/lib/compiler/helpers/get-value-or-default.js +3 -8
  89. package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
  90. package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
  91. package/lib/compiler/helpers/glob.d.ts +19 -0
  92. package/lib/compiler/helpers/glob.js +185 -0
  93. package/lib/compiler/helpers/manual-restart.js +4 -8
  94. package/lib/compiler/helpers/path-confinement.d.ts +33 -0
  95. package/lib/compiler/helpers/path-confinement.js +63 -0
  96. package/lib/compiler/helpers/tsconfig-provider.d.ts +7 -6
  97. package/lib/compiler/helpers/tsconfig-provider.js +32 -13
  98. package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
  99. package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
  100. package/lib/compiler/plugins/plugin-metadata-generator.d.ts +37 -1
  101. package/lib/compiler/plugins/plugin-metadata-generator.js +113 -13
  102. package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
  103. package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
  104. package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
  105. package/lib/compiler/plugins/plugins-loader.js +12 -12
  106. package/lib/compiler/rspack-compiler.d.ts +21 -0
  107. package/lib/compiler/rspack-compiler.js +111 -0
  108. package/lib/compiler/swc/constants.d.ts +0 -1
  109. package/lib/compiler/swc/constants.js +9 -13
  110. package/lib/compiler/swc/forked-type-checker.js +13 -18
  111. package/lib/compiler/swc/swc-compiler.d.ts +13 -6
  112. package/lib/compiler/swc/swc-compiler.js +116 -70
  113. package/lib/compiler/swc/type-checker-host.js +31 -24
  114. package/lib/compiler/typescript-loader.js +7 -9
  115. package/lib/compiler/watch-compiler.d.ts +5 -5
  116. package/lib/compiler/watch-compiler.js +13 -15
  117. package/lib/compiler/watchers/recursive-directory-watcher.d.ts +37 -0
  118. package/lib/compiler/watchers/recursive-directory-watcher.js +334 -0
  119. package/lib/compiler/webpack-compiler.d.ts +6 -7
  120. package/lib/compiler/webpack-compiler.js +46 -23
  121. package/lib/configuration/configuration.d.ts +16 -3
  122. package/lib/configuration/configuration.js +1 -2
  123. package/lib/configuration/configuration.loader.d.ts +1 -1
  124. package/lib/configuration/configuration.loader.js +1 -2
  125. package/lib/configuration/defaults.d.ts +2 -1
  126. package/lib/configuration/defaults.js +8 -10
  127. package/lib/configuration/index.d.ts +3 -3
  128. package/lib/configuration/index.js +3 -19
  129. package/lib/configuration/nest-configuration.loader.d.ts +3 -3
  130. package/lib/configuration/nest-configuration.loader.js +28 -29
  131. package/lib/package-managers/abstract.package-manager.d.ts +4 -4
  132. package/lib/package-managers/abstract.package-manager.js +21 -32
  133. package/lib/package-managers/bun.package-manager.d.ts +7 -0
  134. package/lib/package-managers/bun.package-manager.js +22 -0
  135. package/lib/package-managers/index.d.ts +9 -8
  136. package/lib/package-managers/index.js +9 -24
  137. package/lib/package-managers/npm.package-manager.d.ts +2 -2
  138. package/lib/package-managers/npm.package-manager.js +6 -10
  139. package/lib/package-managers/package-manager-commands.js +1 -2
  140. package/lib/package-managers/package-manager.d.ts +2 -1
  141. package/lib/package-managers/package-manager.factory.d.ts +2 -2
  142. package/lib/package-managers/package-manager.factory.js +23 -20
  143. package/lib/package-managers/package-manager.js +3 -5
  144. package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
  145. package/lib/package-managers/pnpm.package-manager.js +6 -10
  146. package/lib/package-managers/project.dependency.js +1 -2
  147. package/lib/package-managers/yarn.package-manager.d.ts +2 -2
  148. package/lib/package-managers/yarn.package-manager.js +6 -10
  149. package/lib/questions/questions.d.ts +5 -1
  150. package/lib/questions/questions.js +2 -7
  151. package/lib/readers/file-system.reader.d.ts +1 -1
  152. package/lib/readers/file-system.reader.js +6 -9
  153. package/lib/readers/index.d.ts +2 -2
  154. package/lib/readers/index.js +2 -18
  155. package/lib/readers/reader.js +3 -5
  156. package/lib/runners/abstract.runner.js +40 -21
  157. package/lib/runners/bun.runner.d.ts +4 -0
  158. package/lib/runners/bun.runner.js +6 -0
  159. package/lib/runners/git.runner.d.ts +1 -1
  160. package/lib/runners/git.runner.js +2 -6
  161. package/lib/runners/index.d.ts +3 -3
  162. package/lib/runners/index.js +3 -19
  163. package/lib/runners/mau.runner.d.ts +8 -0
  164. package/lib/runners/mau.runner.js +10 -0
  165. package/lib/runners/npm.runner.d.ts +1 -1
  166. package/lib/runners/npm.runner.js +2 -6
  167. package/lib/runners/pnpm.runner.d.ts +1 -1
  168. package/lib/runners/pnpm.runner.js +2 -6
  169. package/lib/runners/runner.d.ts +2 -1
  170. package/lib/runners/runner.factory.d.ts +7 -6
  171. package/lib/runners/runner.factory.js +18 -20
  172. package/lib/runners/runner.js +3 -5
  173. package/lib/runners/schematic.runner.d.ts +1 -1
  174. package/lib/runners/schematic.runner.js +5 -7
  175. package/lib/runners/yarn.runner.d.ts +1 -1
  176. package/lib/runners/yarn.runner.js +2 -6
  177. package/lib/schematics/abstract.collection.d.ts +3 -3
  178. package/lib/schematics/abstract.collection.js +3 -5
  179. package/lib/schematics/collection.factory.d.ts +2 -2
  180. package/lib/schematics/collection.factory.js +9 -13
  181. package/lib/schematics/collection.js +2 -5
  182. package/lib/schematics/custom.collection.d.ts +2 -2
  183. package/lib/schematics/custom.collection.js +4 -8
  184. package/lib/schematics/index.d.ts +4 -4
  185. package/lib/schematics/index.js +4 -20
  186. package/lib/schematics/nest.collection.d.ts +3 -3
  187. package/lib/schematics/nest.collection.js +113 -109
  188. package/lib/schematics/schematic.option.js +10 -9
  189. package/lib/ui/banner.js +1 -4
  190. package/lib/ui/emojis.d.ts +17 -17
  191. package/lib/ui/emojis.js +19 -22
  192. package/lib/ui/errors.js +1 -4
  193. package/lib/ui/index.d.ts +5 -5
  194. package/lib/ui/index.js +5 -21
  195. package/lib/ui/messages.d.ts +8 -0
  196. package/lib/ui/messages.js +23 -18
  197. package/lib/ui/prefixes.js +3 -6
  198. package/lib/utils/extra-args-warning.js +3 -6
  199. package/lib/utils/formatting.js +1 -4
  200. package/lib/utils/get-default-tsconfig-path.js +4 -7
  201. package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
  202. package/lib/utils/is-esm-project.d.ts +5 -0
  203. package/lib/utils/is-esm-project.js +16 -0
  204. package/lib/utils/is-interactive.d.ts +8 -0
  205. package/lib/utils/is-interactive.js +10 -0
  206. package/lib/utils/is-module-available.js +3 -4
  207. package/lib/utils/load-configuration.d.ts +1 -1
  208. package/lib/utils/load-configuration.js +4 -7
  209. package/lib/utils/local-binaries.d.ts +2 -2
  210. package/lib/utils/local-binaries.js +8 -11
  211. package/lib/utils/mau.d.ts +14 -0
  212. package/lib/utils/mau.js +46 -0
  213. package/lib/utils/os-info.utils.js +1 -4
  214. package/lib/utils/project-utils.d.ts +1 -3
  215. package/lib/utils/project-utils.js +16 -28
  216. package/lib/utils/remaining-flags.d.ts +2 -2
  217. package/lib/utils/remaining-flags.js +13 -8
  218. package/lib/utils/tree-kill.js +7 -10
  219. package/lib/utils/type-assertions.js +1 -4
  220. package/package.json +64 -77
@@ -1,36 +1,33 @@
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>')
10
7
  .allowUnknownOption()
8
+ // Unknown options are collected into `args`, which commander otherwise
9
+ // rejects as excess arguments — that would break the documented
10
+ // library-specific options this command forwards via `extraFlags`.
11
+ .allowExcessArguments()
11
12
  .description('Adds support for an external library to your project.')
12
13
  .option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
13
14
  .option('-s, --skip-install', 'Skip package installation.', false)
14
15
  .option('-p, --project [project]', 'Project in which to generate files.')
15
16
  .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);
17
+ .action(async (library, options) => {
18
+ const context = {
19
+ library,
20
+ dryRun: !!options.dryRun,
21
+ skipInstall: options.skipInstall,
22
+ project: options.project,
23
+ extraFlags: getRemainingFlags(program),
24
+ };
27
25
  try {
28
- await this.action.handle(inputs, options, flags);
26
+ await this.action.handle(context);
29
27
  }
30
- catch (err) {
28
+ catch {
31
29
  process.exit(1);
32
30
  }
33
31
  });
34
32
  }
35
33
  }
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,74 +1,70 @@
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
- .option('--type-check', 'Enable type checking (when SWC is used).')
13
+ .option('--type-check', 'Enable type checking (when SWC is used).', () => true)
14
+ .option('--no-type-check', 'Disable type checking (when SWC is used).', () => false)
15
+ .option('--emit-declarations', 'Emit declaration files (.d.ts) when using SWC builder.')
16
+ .option('--silent', 'Suppress informational compiler logs.')
17
17
  .option('--webpackPath [path]', 'Path to webpack configuration.')
18
+ .option('--rspackPath [path]', 'Path to rspack configuration.')
18
19
  .option('--tsc', 'Use typescript compiler for compilation.')
19
20
  .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
20
21
  .option('--all', 'Build all projects in a monorepo.')
22
+ .option('--parallel [concurrency]', 'Build projects in parallel (with --all). Optionally limit concurrency.')
21
23
  .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(', ')}`);
44
- return;
24
+ .action(async (apps, options) => {
25
+ const isWebpackEnabled = options.tsc ? false : options.webpack;
26
+ const availableBuilders = ['tsc', 'webpack', 'swc', 'rspack'];
27
+ if (options.builder && !availableBuilders.includes(options.builder)) {
28
+ console.error(ERROR_PREFIX +
29
+ ` Invalid builder option: ${options.builder}. Available builders: ${availableBuilders.join(', ')}`);
30
+ process.exit(1);
45
31
  }
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 &&
58
- !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 });
32
+ let parallel;
33
+ if (options.parallel === true || options.parallel === undefined) {
34
+ // `--parallel` with no value means unlimited; absent means sequential.
35
+ parallel = options.parallel;
36
+ }
37
+ else {
38
+ const parsed = parseInt(options.parallel, 10);
39
+ if (!Number.isFinite(parsed) || parsed < 1) {
40
+ console.error(ERROR_PREFIX +
41
+ ` Invalid --parallel value: "${options.parallel}". Expected a positive integer (e.g. --parallel 4) or no value for unlimited concurrency.`);
42
+ process.exit(1);
43
+ }
44
+ parallel = parsed;
69
45
  }
70
- await this.action.handle(inputs, options);
46
+ const context = {
47
+ apps: apps.length > 0 ? apps : [],
48
+ config: options.config,
49
+ webpack: isWebpackEnabled,
50
+ watch: !!options.watch,
51
+ watchAssets: !!options.watchAssets,
52
+ path: options.path,
53
+ webpackPath: options.webpackPath,
54
+ rspackPath: options.rspackPath,
55
+ builder: options.builder,
56
+ typeCheck: options.typeCheck,
57
+ // Left undefined when the flag is absent so `getValueOrDefault` can
58
+ // still fall through to `compilerOptions.emitDeclarations`.
59
+ emitDeclarations: options.emitDeclarations,
60
+ silent: !!options.silent,
61
+ preserveWatchOutput: !!options.preserveWatchOutput &&
62
+ !!options.watch &&
63
+ !isWebpackEnabled,
64
+ all: !!options.all,
65
+ parallel,
66
+ };
67
+ await this.action.handle(context);
71
68
  });
72
69
  }
73
70
  }
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,38 @@
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, DeployAction, GenerateAction, InfoAction, NewAction, StartAction, UpgradeAction, } 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 { DeployCommand } from './deploy.command.js';
7
+ import { GenerateCommand } from './generate.command.js';
8
+ import { InfoCommand } from './info.command.js';
9
+ import { NewCommand } from './new.command.js';
10
+ import { StartCommand } from './start.command.js';
11
+ import { UpgradeCommand } from './upgrade.command.js';
12
+ export class CommandLoader {
14
13
  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);
14
+ if (!program.__nestCliEsm) {
15
+ console.error(`\n${ERROR_PREFIX} The globally installed ${red('@nestjs/cli')} is outdated and ` +
16
+ 'incompatible with the local version (which requires ESM).\n' +
17
+ 'Please upgrade your global installation:\n\n' +
18
+ ` ${red('npm i -g @nestjs/cli')}\n`);
19
+ process.exit(1);
20
+ }
21
+ new NewCommand(new NewAction()).load(program);
22
+ new BuildCommand(new BuildAction()).load(program);
23
+ new StartCommand(new StartAction()).load(program);
24
+ new InfoCommand(new InfoAction()).load(program);
25
+ new AddCommand(new AddAction()).load(program);
26
+ new DeployCommand(new DeployAction()).load(program);
27
+ new UpgradeCommand(new UpgradeAction()).load(program);
28
+ await new GenerateCommand(new GenerateAction()).load(program);
21
29
  this.handleInvalidCommand(program);
22
30
  }
23
31
  static handleInvalidCommand(program) {
24
32
  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`);
33
+ console.error(`\n${ERROR_PREFIX} Invalid command: ${red `%s`}`, program.args.join(' '));
34
+ console.error(`See ${red `--help`} for a list of available commands.\n`);
27
35
  process.exit(1);
28
36
  });
29
37
  }
30
38
  }
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,17 @@
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
+ rspackPath?: string;
10
+ builder?: string;
11
+ typeCheck?: boolean;
12
+ emitDeclarations?: boolean;
13
+ silent?: boolean;
14
+ preserveWatchOutput: boolean;
15
+ all: boolean;
16
+ parallel?: number | boolean;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface DeployCommandContext {
2
+ /**
3
+ * Arguments forwarded verbatim to `mau deploy`, so every option Mau
4
+ * supports keeps working without the CLI having to mirror it.
5
+ */
6
+ args: string[];
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
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
+ format: boolean;
16
+ type?: string;
17
+ crud?: boolean;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './add.context.js';
2
+ export * from './build.context.js';
3
+ export * from './deploy.context.js';
4
+ export * from './generate.context.js';
5
+ export * from './new.context.js';
6
+ export * from './start.context.js';
7
+ export * from './upgrade.context.js';
@@ -0,0 +1,7 @@
1
+ export * from './add.context.js';
2
+ export * from './build.context.js';
3
+ export * from './deploy.context.js';
4
+ export * from './generate.context.js';
5
+ export * from './new.context.js';
6
+ export * from './start.context.js';
7
+ export * from './upgrade.context.js';
@@ -0,0 +1,19 @@
1
+ export interface NewCommandContext {
2
+ name?: string;
3
+ directory?: string;
4
+ dryRun: boolean;
5
+ skipGit: boolean;
6
+ skipInstall: boolean;
7
+ skipTests: boolean;
8
+ packageManager?: string;
9
+ language: string;
10
+ collection: string;
11
+ strict: boolean;
12
+ format: boolean;
13
+ /**
14
+ * Whether to auto-configure `@nestjs/observe`. Left `undefined` when the
15
+ * user passed neither `--observe` nor `--no-observe`, so the action knows it
16
+ * still has to ask.
17
+ */
18
+ observe?: boolean;
19
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
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
+ rspackPath?: string;
10
+ builder?: string;
11
+ typeCheck?: boolean;
12
+ emitDeclarations?: boolean;
13
+ silent?: boolean;
14
+ preserveWatchOutput: boolean;
15
+ debug?: boolean | string;
16
+ exec?: string;
17
+ sourceRoot?: string;
18
+ entryFile?: string;
19
+ shell: boolean;
20
+ envFile: string[];
21
+ extraFlags: string[];
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export interface UpgradeCommandContext {
2
+ dryRun: boolean;
3
+ skipInstall: boolean;
4
+ /**
5
+ * Tri-state on purpose: `undefined` means neither `--observe` nor
6
+ * `--no-observe` was passed, which lets the schematic's own `x-prompt` ask.
7
+ */
8
+ observe?: boolean;
9
+ tag?: string;
10
+ collection?: string;
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Command } from 'commander';
2
+ import { AbstractCommand } from './abstract.command.js';
3
+ export declare class DeployCommand extends AbstractCommand {
4
+ load(program: Command): void;
5
+ }
@@ -0,0 +1,22 @@
1
+ import { AbstractCommand } from './abstract.command.js';
2
+ export class DeployCommand extends AbstractCommand {
3
+ load(program) {
4
+ program
5
+ .command('deploy')
6
+ // Every option belongs to `mau deploy`, so nothing is claimed here and
7
+ // whatever the user typed is passed straight through.
8
+ .allowUnknownOption()
9
+ .allowExcessArguments()
10
+ .usage('[mau-options]')
11
+ .description('Deploy your application to the cloud (powered by Mau).')
12
+ .action(async (_options, command) => {
13
+ const context = { args: command.args };
14
+ try {
15
+ await this.action.handle(context);
16
+ }
17
+ catch {
18
+ process.exit(1);
19
+ }
20
+ });
21
+ }
22
+ }
@@ -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;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenerateCommand = void 0;
4
- const ansis_1 = require("ansis");
5
- const Table = require("cli-table3");
6
- const schematics_1 = require("../lib/schematics");
7
- const extra_args_warning_1 = require("../lib/utils/extra-args-warning");
8
- const load_configuration_1 = require("../lib/utils/load-configuration");
9
- const abstract_command_1 = require("./abstract.command");
10
- class GenerateCommand extends abstract_command_1.AbstractCommand {
1
+ import { bold, cyan, green } from 'ansis';
2
+ import Table from 'cli-table3';
3
+ import { CollectionFactory, } from '../lib/schematics/index.js';
4
+ import { loadConfiguration } from '../lib/utils/load-configuration.js';
5
+ import { AbstractCommand } from './abstract.command.js';
6
+ export class GenerateCommand extends AbstractCommand {
11
7
  async load(program) {
12
8
  program
13
9
  .command('generate <schematic> [name] [path]')
@@ -19,70 +15,44 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
19
15
  .option('--no-flat', 'Enforce that directories are generated.', () => false)
20
16
  .option('--spec', 'Enforce spec files generation.', () => {
21
17
  return { value: true, passedAsInput: true };
22
- }, true)
18
+ }, { value: true, passedAsInput: false })
23
19
  .option('--spec-file-suffix [suffix]', 'Use a custom suffix for spec files.')
24
20
  .option('--skip-import', 'Skip importing', () => true, false)
21
+ .option('--format', 'Format generated files using Prettier.', false)
25
22
  .option('--no-spec', 'Disable spec files generation.', () => {
26
23
  return { value: false, passedAsInput: true };
27
24
  })
28
25
  .option('-c, --collection [collectionName]', 'Schematics collection to use.')
29
26
  .option('--type <type>', 'Transport layer type (rest, graphql, microservice)')
30
27
  .option('--crud [value]', 'Generate CRUD entry points')
31
- .action(async (schematic, name, path, command) => {
32
- (0, extra_args_warning_1.exitIfExtraArgs)(command, 3);
33
- const options = [];
34
- options.push({ name: 'dry-run', value: !!command.dryRun });
35
- if (command.flat !== undefined) {
36
- options.push({ name: 'flat', value: command.flat });
37
- }
38
- options.push({
39
- name: 'spec',
40
- value: typeof command.spec === 'boolean'
41
- ? command.spec
42
- : command.spec.value,
43
- options: {
44
- passedAsInput: typeof command.spec === 'boolean'
45
- ? false
46
- : command.spec.passedAsInput,
47
- },
48
- });
49
- options.push({
50
- name: 'specFileSuffix',
51
- value: command.specFileSuffix,
52
- });
53
- options.push({
54
- name: 'collection',
55
- value: command.collection,
56
- });
57
- options.push({
58
- name: 'project',
59
- value: command.project,
60
- });
61
- options.push({
62
- name: 'skipImport',
63
- value: command.skipImport,
64
- });
65
- options.push({
66
- name: 'type',
67
- value: command.type,
68
- });
69
- if (command.crud !== undefined) {
70
- options.push({
71
- name: 'crud',
72
- value: command.crud === true || command.crud === 'true',
73
- });
74
- }
75
- const inputs = [];
76
- inputs.push({ name: 'schematic', value: schematic });
77
- inputs.push({ name: 'name', value: name });
78
- inputs.push({ name: 'path', value: path });
79
- await this.action.handle(inputs, options);
28
+ .action(async (schematic, name, path, options) => {
29
+ const context = {
30
+ schematic,
31
+ name,
32
+ path,
33
+ dryRun: !!options.dryRun,
34
+ flat: options.flat,
35
+ spec: options.spec,
36
+ specFileSuffix: options.specFileSuffix,
37
+ collection: options.collection,
38
+ project: options.project,
39
+ skipImport: options.skipImport,
40
+ format: options.format === true,
41
+ type: options.type,
42
+ // `--crud [value]` yields a string whenever a value is supplied,
43
+ // so `--crud false` must still be forwarded (as false) rather than
44
+ // dropped, which would let the schematic apply its own default.
45
+ crud: options.crud === undefined
46
+ ? undefined
47
+ : options.crud === true || options.crud === 'true',
48
+ };
49
+ await this.action.handle(context);
80
50
  });
81
51
  }
82
52
  async buildDescription() {
83
53
  const collection = await this.getCollection();
84
54
  return ('Generate a Nest element.\n' +
85
- ` Schematics available on ${(0, ansis_1.bold)(collection)} collection:\n` +
55
+ ` Schematics available on ${bold(collection)} collection:\n` +
86
56
  this.buildSchematicsListAsTable(await this.getSchematics(collection)));
87
57
  }
88
58
  buildSchematicsListAsTable(schematics) {
@@ -102,20 +72,19 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
102
72
  const table = new Table(tableConfig);
103
73
  for (const schematic of schematics) {
104
74
  table.push([
105
- (0, ansis_1.green)(schematic.name),
106
- (0, ansis_1.cyan)(schematic.alias),
75
+ green(schematic.name),
76
+ cyan(schematic.alias),
107
77
  schematic.description,
108
78
  ]);
109
79
  }
110
80
  return table.toString();
111
81
  }
112
82
  async getCollection() {
113
- const configuration = await (0, load_configuration_1.loadConfiguration)();
83
+ const configuration = await loadConfiguration();
114
84
  return configuration.collection;
115
85
  }
116
86
  async getSchematics(collection) {
117
- const abstractCollection = schematics_1.CollectionFactory.create(collection);
87
+ const abstractCollection = CollectionFactory.create(collection);
118
88
  return abstractCollection.getSchematics();
119
89
  }
120
90
  }
121
- exports.GenerateCommand = GenerateCommand;
@@ -1,2 +1,3 @@
1
- export * from './command.loader';
2
- export * from './command.input';
1
+ export * from './command.input.js';
2
+ export * from './command.loader.js';
3
+ export * from './context/index.js';
package/commands/index.js CHANGED
@@ -1,18 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./command.loader"), exports);
18
- __exportStar(require("./command.input"), exports);
1
+ export * from './command.input.js';
2
+ export * from './command.loader.js';
3
+ export * from './context/index.js';