@depup/nestjs__cli 11.0.24-depup.7 → 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 +7 -15
  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 +9 -41
  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 +70 -83
package/README.md CHANGED
@@ -13,27 +13,19 @@ npm install @depup/nestjs__cli
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@nestjs/cli](https://www.npmjs.com/package/@nestjs/cli) @ 11.0.24 |
17
- | Processed | 2026-08-20 |
16
+ | Original | [@nestjs/cli](https://www.npmjs.com/package/@nestjs/cli) @ 12.0.0 |
17
+ | Processed | 2026-08-27 |
18
18
  | Smoke test | failed |
19
- | Deps updated | 12 |
19
+ | Deps updated | 4 |
20
20
 
21
21
  ## Dependency Changes
22
22
 
23
23
  | Dependency | From | To |
24
24
  |------------|------|-----|
25
- | @angular-devkit/core | 19.2.27 | ^22.1.5 |
26
- | @angular-devkit/schematics | 19.2.27 | ^22.1.5 |
27
- | @angular-devkit/schematics-cli | 19.2.27 | ^22.1.5 |
28
- | @inquirer/prompts | 7.10.1 | ^8.6.0 |
29
- | @nestjs/schematics | ^11.0.1 | ^11.1.0 |
30
- | ansis | 4.2.0 | ^4.3.1 |
31
- | chokidar | 4.0.3 | ^5.0.0 |
32
- | commander | 4.1.1 | ^15.0.0 |
33
- | node-emoji | 1.11.0 | ^2.2.0 |
34
- | ora | 5.4.1 | ^9.4.1 |
35
- | typescript | 5.9.3 | ^7.0.2 |
36
- | webpack | 5.106.2 | ^5.109.2 |
25
+ | @angular-devkit/core | 22.1.5 | ^22.1.6 |
26
+ | @angular-devkit/schematics | 22.1.5 | ^22.1.6 |
27
+ | @angular-devkit/schematics-cli | 22.1.5 | ^22.1.6 |
28
+ | typescript | ~6.0.2 | ^7.0.2 |
37
29
 
38
30
  ---
39
31
 
@@ -1,4 +1,3 @@
1
- import { Input } from '../commands';
2
1
  export declare abstract class AbstractAction {
3
- abstract handle(inputs?: Input[], options?: Input[], extraFlags?: string[]): Promise<void>;
2
+ abstract handle(context?: any): Promise<void>;
4
3
  }
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractAction = void 0;
4
- class AbstractAction {
1
+ export class AbstractAction {
5
2
  }
6
- exports.AbstractAction = AbstractAction;
@@ -1,11 +1,10 @@
1
- import { Input } from '../commands';
2
- import { AbstractAction } from './abstract.action';
1
+ import { AddCommandContext } from '../commands/index.js';
2
+ import { AbstractAction } from './abstract.action.js';
3
3
  export declare class AddAction extends AbstractAction {
4
- handle(inputs: Input[], options: Input[], extraFlags: string[]): Promise<void>;
4
+ handle(context: AddCommandContext): Promise<void>;
5
5
  private getSourceRoot;
6
6
  private installPackage;
7
7
  private addLibrary;
8
- private getLibraryName;
9
8
  private getPackageName;
10
9
  private getCollectionName;
11
10
  private getTagName;
@@ -1,42 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddAction = void 0;
4
- const ansis_1 = require("ansis");
5
- const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default");
6
- const package_managers_1 = require("../lib/package-managers");
7
- const schematics_1 = require("../lib/schematics");
8
- const ui_1 = require("../lib/ui");
9
- const load_configuration_1 = require("../lib/utils/load-configuration");
10
- const project_utils_1 = require("../lib/utils/project-utils");
11
- const abstract_action_1 = require("./abstract.action");
1
+ import { red } from 'ansis';
2
+ import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default.js';
3
+ import { PackageManagerFactory, } from '../lib/package-managers/index.js';
4
+ import { CollectionFactory, SchematicOption, } from '../lib/schematics/index.js';
5
+ import { MESSAGES } from '../lib/ui/index.js';
6
+ import { loadConfiguration } from '../lib/utils/load-configuration.js';
7
+ import { askForProjectName, moveDefaultProjectToStart, shouldAskForProject, } from '../lib/utils/project-utils.js';
8
+ import { AbstractAction } from './abstract.action.js';
12
9
  const schematicName = 'nest-add';
13
- class AddAction extends abstract_action_1.AbstractAction {
14
- async handle(inputs, options, extraFlags) {
15
- const libraryName = this.getLibraryName(inputs);
10
+ export class AddAction extends AbstractAction {
11
+ async handle(context) {
12
+ const libraryName = context.library;
16
13
  const packageName = this.getPackageName(libraryName);
17
14
  const collectionName = this.getCollectionName(libraryName, packageName);
18
15
  const tagName = this.getTagName(packageName);
19
- const skipInstall = (0, project_utils_1.hasValidOptionFlag)('skip-install', options);
20
- const packageInstallSuccess = skipInstall || (await this.installPackage(collectionName, tagName));
16
+ const packageInstallSuccess = context.skipInstall ||
17
+ (await this.installPackage(collectionName, tagName));
21
18
  if (packageInstallSuccess) {
22
- const sourceRootOption = await this.getSourceRoot(inputs.concat(options));
23
- options.push(sourceRootOption);
24
- await this.addLibrary(collectionName, options, extraFlags);
19
+ const sourceRoot = await this.getSourceRoot(context.project);
20
+ await this.addLibrary(collectionName, sourceRoot, context.extraFlags);
25
21
  }
26
22
  else {
27
- console.error((0, ansis_1.red)(ui_1.MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName)));
28
- throw new Error(ui_1.MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName));
23
+ console.error(red(MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName)));
24
+ throw new Error(MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName));
29
25
  }
30
26
  }
31
- async getSourceRoot(inputs) {
32
- const configuration = await (0, load_configuration_1.loadConfiguration)();
27
+ async getSourceRoot(project) {
28
+ const configuration = await loadConfiguration();
33
29
  const configurationProjects = configuration.projects;
34
- const appName = inputs.find((option) => option.name === 'project')
35
- .value;
36
- let sourceRoot = appName
37
- ? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
30
+ let sourceRoot = project
31
+ ? getValueOrDefault(configuration, 'sourceRoot', project)
38
32
  : configuration.sourceRoot;
39
- const shouldAsk = (0, project_utils_1.shouldAskForProject)(schematicName, configurationProjects, appName);
33
+ const shouldAsk = shouldAskForProject(schematicName, configurationProjects, project ?? '');
40
34
  if (shouldAsk) {
41
35
  const defaultLabel = ' [ Default ]';
42
36
  let defaultProjectName = configuration.sourceRoot + defaultLabel;
@@ -47,52 +41,45 @@ class AddAction extends abstract_action_1.AbstractAction {
47
41
  break;
48
42
  }
49
43
  }
50
- const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
51
- const selectedProject = (await (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.LIBRARY_PROJECT_SELECTION_QUESTION, projects));
52
- const project = selectedProject.replace(defaultLabel, '');
53
- if (project !== configuration.sourceRoot) {
54
- sourceRoot = configurationProjects[project].sourceRoot;
44
+ const projects = moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel);
45
+ const selectedProject = (await askForProjectName(MESSAGES.LIBRARY_PROJECT_SELECTION_QUESTION, projects));
46
+ const projectName = selectedProject.replace(defaultLabel, '');
47
+ if (projectName !== configuration.sourceRoot) {
48
+ sourceRoot = configurationProjects[projectName].sourceRoot;
55
49
  }
56
50
  }
57
- return { name: 'sourceRoot', value: sourceRoot };
51
+ return sourceRoot;
58
52
  }
59
53
  async installPackage(collectionName, tagName) {
60
- const manager = await package_managers_1.PackageManagerFactory.find();
54
+ const manager = await PackageManagerFactory.find();
61
55
  tagName = tagName || 'latest';
62
56
  let installResult = false;
63
57
  try {
64
58
  installResult = await manager.addProduction([collectionName], tagName);
65
59
  }
66
60
  catch (error) {
67
- if (error && error.message) {
68
- console.error((0, ansis_1.red)(error.message));
61
+ if (error instanceof Error) {
62
+ console.error(red(error.message));
69
63
  }
70
64
  }
71
65
  return installResult;
72
66
  }
73
- async addLibrary(collectionName, options, extraFlags) {
74
- console.info(ui_1.MESSAGES.LIBRARY_INSTALLATION_STARTS);
67
+ async addLibrary(collectionName, sourceRoot, extraFlags) {
68
+ console.info(MESSAGES.LIBRARY_INSTALLATION_STARTS);
75
69
  const schematicOptions = [];
76
- schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', options.find((option) => option.name === 'sourceRoot').value));
70
+ schematicOptions.push(new SchematicOption('sourceRoot', sourceRoot));
77
71
  const extraFlagsString = extraFlags ? extraFlags.join(' ') : undefined;
78
72
  try {
79
- const collection = schematics_1.CollectionFactory.create(collectionName);
73
+ const collection = CollectionFactory.create(collectionName);
80
74
  await collection.execute(schematicName, schematicOptions, extraFlagsString);
81
75
  }
82
76
  catch (error) {
83
- if (error && error.message) {
84
- console.error((0, ansis_1.red)(error.message));
85
- return Promise.reject();
77
+ if (error instanceof Error) {
78
+ console.error(red(error.message));
86
79
  }
80
+ throw error;
87
81
  }
88
82
  }
89
- getLibraryName(inputs) {
90
- const libraryInput = inputs.find((input) => input.name === 'library');
91
- if (!libraryInput) {
92
- throw new Error('No library found in command input');
93
- }
94
- return libraryInput.value;
95
- }
96
83
  getPackageName(library) {
97
84
  return library.startsWith('@')
98
85
  ? library.split('/', 2).join('/')
@@ -105,9 +92,13 @@ class AddAction extends abstract_action_1.AbstractAction {
105
92
  library.slice(packageName.length));
106
93
  }
107
94
  getTagName(packageName) {
108
- return packageName.startsWith('@')
95
+ // For scoped packages like "@scope/pkg@1.0.0", split('@', 3) yields
96
+ // ["", "scope/pkg", "1.0.0"]. For "@scope/pkg" with no version,
97
+ // the tag slot is undefined. Fall back to an empty string so the
98
+ // return type stays string and installPackage can substitute "latest".
99
+ const tag = packageName.startsWith('@')
109
100
  ? packageName.split('@', 3)[2]
110
101
  : packageName.split('@', 2)[1];
102
+ return tag ?? '';
111
103
  }
112
104
  }
113
- exports.AddAction = AddAction;
@@ -1,22 +1,29 @@
1
- import { Input } from '../commands';
2
- import { AssetsManager } from '../lib/compiler/assets-manager';
3
- import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider';
4
- import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader';
5
- import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader';
6
- import { ConfigurationLoader } from '../lib/configuration';
7
- import { FileSystemReader } from '../lib/readers';
8
- import { AbstractAction } from './abstract.action';
1
+ import { AssetsManager } from '../lib/compiler/assets-manager.js';
2
+ import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider.js';
3
+ import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader.js';
4
+ import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader.js';
5
+ import { ConfigurationLoader } from '../lib/configuration/index.js';
6
+ import { FileSystemReader } from '../lib/readers/index.js';
7
+ import { AbstractAction } from './abstract.action.js';
9
8
  export declare class BuildAction extends AbstractAction {
10
9
  protected readonly pluginsLoader: PluginsLoader;
11
10
  protected readonly tsLoader: TypeScriptBinaryLoader;
12
11
  protected readonly tsConfigProvider: TsConfigProvider;
13
12
  protected readonly fileSystemReader: FileSystemReader;
14
13
  protected readonly loader: ConfigurationLoader;
15
- protected readonly assetsManager: AssetsManager;
16
- handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>;
17
- runBuild(commandInputs: Input[], commandOptions: Input[], watchMode: boolean, watchAssetsMode: boolean, isDebugEnabled?: boolean, onSuccess?: () => void): Promise<void>;
14
+ /**
15
+ * Each app build owns its assets manager: `closeWatchers()` closes every
16
+ * watcher it holds, so a manager shared across a `--parallel` run would let
17
+ * the first app to finish tear down the watchers of apps still building.
18
+ */
19
+ protected createAssetsManager(): AssetsManager;
20
+ handle(context: any): Promise<void>;
21
+ runBuild(apps: (string | undefined)[], options: Record<string, any>, watchMode: boolean, watchAssetsMode: boolean, isDebugEnabled?: boolean, onSuccess?: () => void): Promise<void>;
18
22
  private runSwc;
19
23
  private runWebpack;
20
24
  private runTsc;
21
25
  private getWebpackConfigFactoryByPath;
26
+ private runRspack;
27
+ private getRspackConfigFactoryByPath;
28
+ private warnOnIgnoredLibraryAssets;
22
29
  }
@@ -1,145 +1,238 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildAction = void 0;
4
- const ansis_1 = require("ansis");
5
- const path_1 = require("path");
6
- const assets_manager_1 = require("../lib/compiler/assets-manager");
7
- const delete_out_dir_1 = require("../lib/compiler/helpers/delete-out-dir");
8
- const get_builder_1 = require("../lib/compiler/helpers/get-builder");
9
- const get_tsc_config_path_1 = require("../lib/compiler/helpers/get-tsc-config.path");
10
- const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default");
11
- const get_webpack_config_path_1 = require("../lib/compiler/helpers/get-webpack-config-path");
12
- const tsconfig_provider_1 = require("../lib/compiler/helpers/tsconfig-provider");
13
- const plugins_loader_1 = require("../lib/compiler/plugins/plugins-loader");
14
- const typescript_loader_1 = require("../lib/compiler/typescript-loader");
15
- const configuration_1 = require("../lib/configuration");
16
- const defaults_1 = require("../lib/configuration/defaults");
17
- const readers_1 = require("../lib/readers");
18
- const ui_1 = require("../lib/ui");
19
- const is_module_available_1 = require("../lib/utils/is-module-available");
20
- const abstract_action_1 = require("./abstract.action");
21
- class BuildAction extends abstract_action_1.AbstractAction {
22
- constructor() {
23
- super(...arguments);
24
- this.pluginsLoader = new plugins_loader_1.PluginsLoader();
25
- this.tsLoader = new typescript_loader_1.TypeScriptBinaryLoader();
26
- this.tsConfigProvider = new tsconfig_provider_1.TsConfigProvider(this.tsLoader);
27
- this.fileSystemReader = new readers_1.FileSystemReader(process.cwd());
28
- this.loader = new configuration_1.NestConfigurationLoader(this.fileSystemReader);
29
- this.assetsManager = new assets_manager_1.AssetsManager();
1
+ import { createRequire } from 'module';
2
+ import { red } from 'ansis';
3
+ import { join } from 'path';
4
+ import { AssetsManager } from '../lib/compiler/assets-manager.js';
5
+ import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir.js';
6
+ import { getBuilder } from '../lib/compiler/helpers/get-builder.js';
7
+ import { getEffectiveRootDir } from '../lib/compiler/helpers/get-effective-root-dir.js';
8
+ import { getRspackConfigPath } from '../lib/compiler/helpers/get-rspack-config-path.js';
9
+ import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path.js';
10
+ import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default.js';
11
+ import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config-path.js';
12
+ import { TsConfigProvider, } from '../lib/compiler/helpers/tsconfig-provider.js';
13
+ import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader.js';
14
+ import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader.js';
15
+ import { NestConfigurationLoader, } from '../lib/configuration/index.js';
16
+ import { defaultOutDir, defaultRspackConfigFilename, defaultWebpackConfigFilename, } from '../lib/configuration/defaults.js';
17
+ import { FileSystemReader } from '../lib/readers/index.js';
18
+ import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui/index.js';
19
+ import { isModuleAvailable } from '../lib/utils/is-module-available.js';
20
+ import { AbstractAction } from './abstract.action.js';
21
+ const require = createRequire(import.meta.url);
22
+ export class BuildAction extends AbstractAction {
23
+ pluginsLoader = new PluginsLoader();
24
+ tsLoader = new TypeScriptBinaryLoader();
25
+ tsConfigProvider = new TsConfigProvider(this.tsLoader);
26
+ fileSystemReader = new FileSystemReader(process.cwd());
27
+ loader = new NestConfigurationLoader(this.fileSystemReader);
28
+ /**
29
+ * Each app build owns its assets manager: `closeWatchers()` closes every
30
+ * watcher it holds, so a manager shared across a `--parallel` run would let
31
+ * the first app to finish tear down the watchers of apps still building.
32
+ */
33
+ createAssetsManager() {
34
+ return new AssetsManager();
30
35
  }
31
- async handle(commandInputs, commandOptions) {
36
+ async handle(context) {
37
+ const { apps, watch, watchAssets } = context;
32
38
  try {
33
- const watchModeOption = commandOptions.find((option) => option.name === 'watch');
34
- const watchMode = !!(watchModeOption && watchModeOption.value);
35
- const watchAssetsModeOption = commandOptions.find((option) => option.name === 'watchAssets');
36
- const watchAssetsMode = !!(watchAssetsModeOption && watchAssetsModeOption.value);
37
- await this.runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode);
39
+ await this.runBuild(apps, context, watch, watchAssets);
38
40
  }
39
41
  catch (err) {
40
42
  if (err instanceof Error) {
41
- console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
43
+ console.error(`\n${ERROR_PREFIX} ${err.message}\n`);
42
44
  }
43
45
  else {
44
- console.error(`\n${(0, ansis_1.red)(err)}\n`);
46
+ console.error(`\n${red(err)}\n`);
45
47
  }
46
48
  process.exit(1);
47
49
  }
48
50
  }
49
- async runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
50
- const configFileName = commandOptions.find((option) => option.name === 'config').value;
51
+ async runBuild(apps, options, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
52
+ const configFileName = options.config;
51
53
  const configuration = await this.loader.load(configFileName);
52
- const buildAll = commandOptions.find((opt) => opt.name === 'all')?.value;
53
54
  let appNames;
54
- if (buildAll) {
55
- // If the "all" flag is set, we need to build all projects in a monorepo.
55
+ if (options.all) {
56
56
  appNames = [];
57
57
  if (configuration.projects) {
58
58
  appNames.push(...Object.keys(configuration.projects));
59
59
  }
60
60
  }
61
61
  else {
62
- appNames = commandInputs
63
- .filter((input) => input.name === 'app')
64
- .map((input) => input.value);
62
+ appNames = apps;
65
63
  }
66
64
  if (appNames.length === 0) {
67
- // If there are no projects, use "undefined" to build the default project.
68
65
  appNames.push(undefined);
69
66
  }
70
- for (const appName of appNames) {
71
- const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
72
- const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
73
- const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
74
- const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', commandOptions);
67
+ const appBuildContexts = appNames.map((appName) => {
68
+ const pathToTsconfig = getTscConfigPath(configuration, options, appName);
69
+ const { exclude, options: tsOptions, fileNames: tsFileNames, } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
70
+ return {
71
+ appName,
72
+ pathToTsconfig,
73
+ tsOptions,
74
+ exclude,
75
+ outDir: tsOptions.outDir || defaultOutDir,
76
+ tsRootDir: getEffectiveRootDir(tsOptions.rootDir, tsFileNames),
77
+ };
78
+ });
79
+ // Every output directory is cleaned before any app starts emitting.
80
+ // Cleaning inside the per-app build deletes output another app already
81
+ // wrote whenever projects share an outDir (the default monorepo layout):
82
+ // a race under `--parallel`, and deterministic clobbering under `--all`.
83
+ for (const { appName, outDir, tsOptions } of appBuildContexts) {
84
+ await deleteOutDirIfEnabled(configuration, appName, outDir, tsOptions);
85
+ }
86
+ this.warnOnIgnoredLibraryAssets(configuration, appNames);
87
+ const buildApp = async ({ appName, pathToTsconfig, tsOptions, exclude, outDir, tsRootDir, }) => {
88
+ const assetsManager = this.createAssetsManager();
89
+ const isWebpackEnabled = getValueOrDefault(configuration, 'compilerOptions.webpack', appName, 'webpack', options);
75
90
  const builder = isWebpackEnabled
76
91
  ? { type: 'webpack' }
77
- : (0, get_builder_1.getBuilder)(configuration, commandOptions, appName);
78
- await (0, delete_out_dir_1.deleteOutDirIfEnabled)(configuration, appName, outDir, tsOptions);
79
- this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
80
- const typeCheck = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', commandOptions);
92
+ : getBuilder(configuration, options, appName);
93
+ assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode, onSuccess, tsRootDir);
94
+ const typeCheck = getValueOrDefault(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options);
81
95
  if (typeCheck && builder.type !== 'swc') {
82
- console.warn(ui_1.INFO_PREFIX +
96
+ console.warn(INFO_PREFIX +
83
97
  ` "typeCheck" will not have any effect when "builder" is not "swc".`);
84
98
  }
99
+ const emitDeclarations = getValueOrDefault(configuration, 'compilerOptions.emitDeclarations', appName, 'emitDeclarations', options);
100
+ if (emitDeclarations && builder.type !== 'swc') {
101
+ console.warn(INFO_PREFIX +
102
+ ` "emitDeclarations" will not have any effect when "builder" is not "swc".`);
103
+ }
85
104
  switch (builder.type) {
86
105
  case 'tsc':
87
- await this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName, onSuccess);
106
+ await this.runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess, assetsManager);
88
107
  break;
89
108
  case 'webpack':
90
- await this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode, onSuccess);
109
+ await this.runWebpack(configuration, appName, options, pathToTsconfig, isDebugEnabled, watchMode, onSuccess, assetsManager);
110
+ break;
111
+ case 'rspack':
112
+ await this.runRspack(configuration, appName, options, pathToTsconfig, tsOptions, isDebugEnabled, watchMode, onSuccess, assetsManager);
91
113
  break;
92
114
  case 'swc':
93
- await this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions, onSuccess);
115
+ await this.runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, exclude, emitDeclarations, onSuccess, assetsManager);
94
116
  break;
95
117
  }
118
+ };
119
+ const parallel = options.parallel;
120
+ if (parallel && appBuildContexts.length > 1) {
121
+ // Coerce to a positive integer; fall back to unlimited for any
122
+ // non-positive or non-finite value to guard against an infinite loop
123
+ // when `i += concurrency` would never advance.
124
+ const requested = typeof parallel === 'number' ? parallel : appBuildContexts.length;
125
+ const concurrency = Number.isFinite(requested) && requested >= 1
126
+ ? Math.floor(requested)
127
+ : appBuildContexts.length;
128
+ for (let i = 0; i < appBuildContexts.length; i += concurrency) {
129
+ const chunk = appBuildContexts.slice(i, i + concurrency);
130
+ await Promise.all(chunk.map((context) => buildApp(context)));
131
+ }
132
+ }
133
+ else {
134
+ for (const context of appBuildContexts) {
135
+ await buildApp(context);
136
+ }
96
137
  }
97
138
  }
98
- async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, onSuccess) {
99
- const { SwcCompiler } = await Promise.resolve().then(() => require('../lib/compiler/swc/swc-compiler'));
139
+ async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, tsConfigExclude, emitDeclarations, onSuccess, assetsManager) {
140
+ const { SwcCompiler } = await import('../lib/compiler/swc/swc-compiler.js');
100
141
  const swc = new SwcCompiler(this.pluginsLoader);
142
+ const isSilent = !!options.silent;
101
143
  await swc.run(configuration, pathToTsconfig, appName, {
102
144
  watch: watchMode,
103
- typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
145
+ typeCheck: getValueOrDefault(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
146
+ emitDeclarations,
104
147
  tsOptions,
105
- assetsManager: this.assetsManager,
148
+ tsConfigExclude,
149
+ assetsManager,
150
+ silent: isSilent,
106
151
  }, onSuccess);
107
152
  }
108
- async runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode, onSuccess) {
109
- const { WebpackCompiler } = await Promise.resolve().then(() => require('../lib/compiler/webpack-compiler'));
153
+ async runWebpack(configuration, appName, options, pathToTsconfig, debug, watchMode, onSuccess, assetsManager) {
154
+ const { WebpackCompiler } = await import('../lib/compiler/webpack-compiler.js');
110
155
  const webpackCompiler = new WebpackCompiler(this.pluginsLoader);
111
- const webpackPath = (0, get_webpack_config_path_1.getWebpackConfigPath)(configuration, commandOptions, appName) ??
112
- defaults_1.defaultWebpackConfigFilename;
113
- const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, defaults_1.defaultWebpackConfigFilename);
156
+ const webpackPath = getWebpackConfigPath(configuration, options, appName) ??
157
+ defaultWebpackConfigFilename;
158
+ const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, defaultWebpackConfigFilename);
114
159
  return webpackCompiler.run(configuration, pathToTsconfig, appName, {
115
- inputs: commandOptions,
160
+ options,
116
161
  webpackConfigFactoryOrConfig,
117
162
  debug,
118
163
  watchMode,
119
- assetsManager: this.assetsManager,
164
+ assetsManager,
120
165
  }, onSuccess);
121
166
  }
122
- async runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess) {
167
+ async runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess, assetsManager) {
123
168
  if (watchMode) {
124
- const { WatchCompiler } = await Promise.resolve().then(() => require('../lib/compiler/watch-compiler'));
169
+ const { WatchCompiler } = await import('../lib/compiler/watch-compiler.js');
125
170
  const watchCompiler = new WatchCompiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
126
- const isPreserveWatchOutputEnabled = options.find((option) => option.name === 'preserveWatchOutput' && option.value === true)?.value;
171
+ const isPreserveWatchOutputEnabled = !!options.preserveWatchOutput;
127
172
  watchCompiler.run(configuration, pathToTsconfig, appName, { preserveWatchOutput: isPreserveWatchOutputEnabled }, onSuccess);
128
173
  }
129
174
  else {
130
- const { Compiler } = await Promise.resolve().then(() => require('../lib/compiler/compiler'));
175
+ const { Compiler } = await import('../lib/compiler/compiler.js');
131
176
  const compiler = new Compiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
132
177
  compiler.run(configuration, pathToTsconfig, appName, undefined, onSuccess);
133
- await this.assetsManager.closeWatchers();
178
+ await assetsManager.closeWatchers();
134
179
  }
135
180
  }
136
181
  getWebpackConfigFactoryByPath(webpackPath, defaultPath) {
137
- const pathToWebpackFile = (0, path_1.join)(process.cwd(), webpackPath);
138
- const isWebpackFileAvailable = (0, is_module_available_1.isModuleAvailable)(pathToWebpackFile);
182
+ const pathToWebpackFile = join(process.cwd(), webpackPath);
183
+ const isWebpackFileAvailable = isModuleAvailable(pathToWebpackFile);
139
184
  if (!isWebpackFileAvailable && webpackPath === defaultPath) {
140
- return ({}) => ({});
185
+ return (_config) => ({});
141
186
  }
142
187
  return require(pathToWebpackFile);
143
188
  }
189
+ async runRspack(configuration, appName, options, pathToTsconfig, tsOptions, debug, watchMode, onSuccess, assetsManager) {
190
+ const { RspackCompiler } = await import('../lib/compiler/rspack-compiler.js');
191
+ const rspackCompiler = new RspackCompiler(this.pluginsLoader);
192
+ const rspackPath = getRspackConfigPath(configuration, options, appName) ??
193
+ defaultRspackConfigFilename;
194
+ const rspackConfigFactoryOrConfig = this.getRspackConfigFactoryByPath(rspackPath, defaultRspackConfigFilename);
195
+ return rspackCompiler.run(configuration, pathToTsconfig, appName, {
196
+ options,
197
+ rspackConfigFactoryOrConfig,
198
+ debug,
199
+ watchMode,
200
+ tsOptions,
201
+ assetsManager,
202
+ }, onSuccess);
203
+ }
204
+ getRspackConfigFactoryByPath(rspackPath, defaultPath) {
205
+ const pathToRspackFile = join(process.cwd(), rspackPath);
206
+ const isRspackFileAvailable = isModuleAvailable(pathToRspackFile);
207
+ if (!isRspackFileAvailable && rspackPath === defaultPath) {
208
+ return (_config) => ({});
209
+ }
210
+ return require(pathToRspackFile);
211
+ }
212
+ warnOnIgnoredLibraryAssets(configuration, appNames) {
213
+ if (!configuration.projects) {
214
+ return;
215
+ }
216
+ // A library whose assets any of the apps being built opts into via
217
+ // `includeLibraryAssets` *is* copied, so warning about it would be wrong.
218
+ const includedLibraries = new Set();
219
+ for (const appName of appNames) {
220
+ const included = getValueOrDefault(configuration, 'compilerOptions.includeLibraryAssets', appName) || [];
221
+ for (const libraryName of included) {
222
+ includedLibraries.add(libraryName);
223
+ }
224
+ }
225
+ for (const [projectName, project] of Object.entries(configuration.projects)) {
226
+ if (appNames.includes(projectName) ||
227
+ includedLibraries.has(projectName)) {
228
+ continue;
229
+ }
230
+ if (project.type === 'library' &&
231
+ project.compilerOptions?.assets?.length) {
232
+ console.warn(INFO_PREFIX +
233
+ ` Assets configured for library "${projectName}" will not be copied during application build.` +
234
+ ` Add it to "compilerOptions.includeLibraryAssets" or build the library separately.`);
235
+ }
236
+ }
237
+ }
144
238
  }
145
- exports.BuildAction = BuildAction;
@@ -0,0 +1,6 @@
1
+ import { DeployCommandContext } from '../commands/index.js';
2
+ import { AbstractAction } from './abstract.action.js';
3
+ export declare class DeployAction extends AbstractAction {
4
+ handle(context: DeployCommandContext): Promise<void>;
5
+ private installMau;
6
+ }