@depup/nestjs__cli 11.0.16-depup.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +42 -0
  3. package/actions/abstract.action.d.ts +4 -0
  4. package/actions/abstract.action.js +6 -0
  5. package/actions/add.action.d.ts +12 -0
  6. package/actions/add.action.js +113 -0
  7. package/actions/build.action.d.ts +22 -0
  8. package/actions/build.action.js +145 -0
  9. package/actions/generate.action.d.ts +5 -0
  10. package/actions/generate.action.js +97 -0
  11. package/actions/index.d.ts +7 -0
  12. package/actions/index.js +23 -0
  13. package/actions/info.action.d.ts +35 -0
  14. package/actions/info.action.js +181 -0
  15. package/actions/new.action.d.ts +7 -0
  16. package/actions/new.action.js +186 -0
  17. package/actions/start.action.d.ts +10 -0
  18. package/actions/start.action.js +122 -0
  19. package/bin/nest.d.ts +2 -0
  20. package/bin/nest.js +25 -0
  21. package/changes.json +54 -0
  22. package/commands/abstract.command.d.ts +7 -0
  23. package/commands/abstract.command.js +9 -0
  24. package/commands/add.command.d.ts +5 -0
  25. package/commands/add.command.js +36 -0
  26. package/commands/build.command.d.ts +5 -0
  27. package/commands/build.command.js +74 -0
  28. package/commands/command.input.d.ts +5 -0
  29. package/commands/command.input.js +2 -0
  30. package/commands/command.loader.d.ts +5 -0
  31. package/commands/command.loader.js +31 -0
  32. package/commands/generate.command.d.ts +9 -0
  33. package/commands/generate.command.js +107 -0
  34. package/commands/index.d.ts +2 -0
  35. package/commands/index.js +18 -0
  36. package/commands/info.command.d.ts +5 -0
  37. package/commands/info.command.js +16 -0
  38. package/commands/new.command.d.ts +5 -0
  39. package/commands/new.command.js +61 -0
  40. package/commands/start.command.d.ts +5 -0
  41. package/commands/start.command.js +104 -0
  42. package/lib/compiler/assets-manager.d.ts +15 -0
  43. package/lib/compiler/assets-manager.js +129 -0
  44. package/lib/compiler/base-compiler.d.ts +9 -0
  45. package/lib/compiler/base-compiler.js +26 -0
  46. package/lib/compiler/compiler.d.ts +12 -0
  47. package/lib/compiler/compiler.js +61 -0
  48. package/lib/compiler/defaults/swc-defaults.d.ts +61 -0
  49. package/lib/compiler/defaults/swc-defaults.js +57 -0
  50. package/lib/compiler/defaults/webpack-defaults.d.ts +3 -0
  51. package/lib/compiler/defaults/webpack-defaults.js +104 -0
  52. package/lib/compiler/helpers/append-extension.d.ts +1 -0
  53. package/lib/compiler/helpers/append-extension.js +7 -0
  54. package/lib/compiler/helpers/copy-path-resolve.d.ts +7 -0
  55. package/lib/compiler/helpers/copy-path-resolve.js +25 -0
  56. package/lib/compiler/helpers/delete-out-dir.d.ts +2 -0
  57. package/lib/compiler/helpers/delete-out-dir.js +12 -0
  58. package/lib/compiler/helpers/get-builder.d.ts +21 -0
  59. package/lib/compiler/helpers/get-builder.js +19 -0
  60. package/lib/compiler/helpers/get-tsc-config.path.d.ts +10 -0
  61. package/lib/compiler/helpers/get-tsc-config.path.js +24 -0
  62. package/lib/compiler/helpers/get-value-or-default.d.ts +4 -0
  63. package/lib/compiler/helpers/get-value-or-default.js +66 -0
  64. package/lib/compiler/helpers/get-webpack-config-path.d.ts +10 -0
  65. package/lib/compiler/helpers/get-webpack-config-path.js +23 -0
  66. package/lib/compiler/helpers/manual-restart.d.ts +2 -0
  67. package/lib/compiler/helpers/manual-restart.js +17 -0
  68. package/lib/compiler/helpers/tsconfig-provider.d.ts +11 -0
  69. package/lib/compiler/helpers/tsconfig-provider.js +22 -0
  70. package/lib/compiler/hooks/tsconfig-paths.hook.d.ts +2 -0
  71. package/lib/compiler/hooks/tsconfig-paths.hook.js +76 -0
  72. package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +10 -0
  73. package/lib/compiler/interfaces/readonly-visitor.interface.js +2 -0
  74. package/lib/compiler/plugins/plugin-metadata-generator.d.ts +58 -0
  75. package/lib/compiler/plugins/plugin-metadata-generator.js +84 -0
  76. package/lib/compiler/plugins/plugin-metadata-printer.d.ts +17 -0
  77. package/lib/compiler/plugins/plugin-metadata-printer.js +51 -0
  78. package/lib/compiler/plugins/plugins-loader.d.ts +30 -0
  79. package/lib/compiler/plugins/plugins-loader.js +70 -0
  80. package/lib/compiler/swc/constants.d.ts +9 -0
  81. package/lib/compiler/swc/constants.js +13 -0
  82. package/lib/compiler/swc/forked-type-checker.d.ts +1 -0
  83. package/lib/compiler/swc/forked-type-checker.js +63 -0
  84. package/lib/compiler/swc/swc-compiler.d.ts +25 -0
  85. package/lib/compiler/swc/swc-compiler.js +231 -0
  86. package/lib/compiler/swc/type-checker-host.d.ts +14 -0
  87. package/lib/compiler/swc/type-checker-host.js +90 -0
  88. package/lib/compiler/typescript-loader.d.ts +6 -0
  89. package/lib/compiler/typescript-loader.js +31 -0
  90. package/lib/compiler/watch-compiler.d.ts +22 -0
  91. package/lib/compiler/watch-compiler.js +89 -0
  92. package/lib/compiler/webpack-compiler.d.ts +21 -0
  93. package/lib/compiler/webpack-compiler.js +99 -0
  94. package/lib/configuration/configuration.d.ts +91 -0
  95. package/lib/configuration/configuration.js +2 -0
  96. package/lib/configuration/configuration.loader.d.ts +4 -0
  97. package/lib/configuration/configuration.loader.js +2 -0
  98. package/lib/configuration/defaults.d.ts +6 -0
  99. package/lib/configuration/defaults.js +86 -0
  100. package/lib/configuration/index.d.ts +3 -0
  101. package/lib/configuration/index.js +19 -0
  102. package/lib/configuration/nest-configuration.loader.d.ts +8 -0
  103. package/lib/configuration/nest-configuration.loader.js +61 -0
  104. package/lib/package-managers/abstract.package-manager.d.ts +25 -0
  105. package/lib/package-managers/abstract.package-manager.js +151 -0
  106. package/lib/package-managers/index.d.ts +8 -0
  107. package/lib/package-managers/index.js +24 -0
  108. package/lib/package-managers/npm.package-manager.d.ts +7 -0
  109. package/lib/package-managers/npm.package-manager.js +26 -0
  110. package/lib/package-managers/package-manager-commands.d.ts +9 -0
  111. package/lib/package-managers/package-manager-commands.js +2 -0
  112. package/lib/package-managers/package-manager.d.ts +5 -0
  113. package/lib/package-managers/package-manager.factory.d.ts +6 -0
  114. package/lib/package-managers/package-manager.factory.js +41 -0
  115. package/lib/package-managers/package-manager.js +9 -0
  116. package/lib/package-managers/pnpm.package-manager.d.ts +7 -0
  117. package/lib/package-managers/pnpm.package-manager.js +27 -0
  118. package/lib/package-managers/project.dependency.d.ts +4 -0
  119. package/lib/package-managers/project.dependency.js +2 -0
  120. package/lib/package-managers/yarn.package-manager.d.ts +7 -0
  121. package/lib/package-managers/yarn.package-manager.js +26 -0
  122. package/lib/questions/questions.d.ts +9 -0
  123. package/lib/questions/questions.js +27 -0
  124. package/lib/readers/file-system.reader.d.ts +8 -0
  125. package/lib/readers/file-system.reader.js +46 -0
  126. package/lib/readers/index.d.ts +2 -0
  127. package/lib/readers/index.js +18 -0
  128. package/lib/readers/reader.d.ts +10 -0
  129. package/lib/readers/reader.js +11 -0
  130. package/lib/runners/abstract.runner.d.ts +11 -0
  131. package/lib/runners/abstract.runner.js +47 -0
  132. package/lib/runners/git.runner.d.ts +4 -0
  133. package/lib/runners/git.runner.js +10 -0
  134. package/lib/runners/index.d.ts +3 -0
  135. package/lib/runners/index.js +19 -0
  136. package/lib/runners/npm.runner.d.ts +4 -0
  137. package/lib/runners/npm.runner.js +10 -0
  138. package/lib/runners/pnpm.runner.d.ts +4 -0
  139. package/lib/runners/pnpm.runner.js +10 -0
  140. package/lib/runners/runner.d.ts +6 -0
  141. package/lib/runners/runner.factory.d.ts +8 -0
  142. package/lib/runners/runner.factory.js +26 -0
  143. package/lib/runners/runner.js +10 -0
  144. package/lib/runners/schematic.runner.d.ts +6 -0
  145. package/lib/runners/schematic.runner.js +21 -0
  146. package/lib/runners/yarn.runner.d.ts +4 -0
  147. package/lib/runners/yarn.runner.js +10 -0
  148. package/lib/schematics/abstract.collection.d.ts +12 -0
  149. package/lib/schematics/abstract.collection.js +23 -0
  150. package/lib/schematics/collection.d.ts +3 -0
  151. package/lib/schematics/collection.factory.d.ts +5 -0
  152. package/lib/schematics/collection.factory.js +19 -0
  153. package/lib/schematics/collection.js +7 -0
  154. package/lib/schematics/custom.collection.d.ts +10 -0
  155. package/lib/schematics/custom.collection.js +33 -0
  156. package/lib/schematics/index.d.ts +4 -0
  157. package/lib/schematics/index.js +20 -0
  158. package/lib/schematics/nest.collection.d.ts +15 -0
  159. package/lib/schematics/nest.collection.js +126 -0
  160. package/lib/schematics/schematic.option.d.ts +8 -0
  161. package/lib/schematics/schematic.option.js +44 -0
  162. package/lib/ui/banner.d.ts +1 -0
  163. package/lib/ui/banner.js +12 -0
  164. package/lib/ui/emojis.d.ts +19 -0
  165. package/lib/ui/emojis.js +23 -0
  166. package/lib/ui/errors.d.ts +4 -0
  167. package/lib/ui/errors.js +8 -0
  168. package/lib/ui/index.d.ts +5 -0
  169. package/lib/ui/index.js +21 -0
  170. package/lib/ui/messages.d.ts +24 -0
  171. package/lib/ui/messages.js +32 -0
  172. package/lib/ui/prefixes.d.ts +2 -0
  173. package/lib/ui/prefixes.js +6 -0
  174. package/lib/utils/formatting.d.ts +8 -0
  175. package/lib/utils/formatting.js +18 -0
  176. package/lib/utils/get-default-tsconfig-path.d.ts +1 -0
  177. package/lib/utils/get-default-tsconfig-path.js +12 -0
  178. package/lib/utils/gracefully-exit-on-prompt-error.d.ts +1 -0
  179. package/lib/utils/gracefully-exit-on-prompt-error.js +11 -0
  180. package/lib/utils/is-module-available.d.ts +1 -0
  181. package/lib/utils/is-module-available.js +12 -0
  182. package/lib/utils/load-configuration.d.ts +2 -0
  183. package/lib/utils/load-configuration.js +9 -0
  184. package/lib/utils/local-binaries.d.ts +3 -0
  185. package/lib/utils/local-binaries.js +15 -0
  186. package/lib/utils/os-info.utils.d.ts +1 -0
  187. package/lib/utils/os-info.utils.js +23 -0
  188. package/lib/utils/project-utils.d.ts +11 -0
  189. package/lib/utils/project-utils.js +83 -0
  190. package/lib/utils/remaining-flags.d.ts +2 -0
  191. package/lib/utils/remaining-flags.js +36 -0
  192. package/lib/utils/tree-kill.d.ts +1 -0
  193. package/lib/utils/tree-kill.js +68 -0
  194. package/lib/utils/type-assertions.d.ts +1 -0
  195. package/lib/utils/type-assertions.js +8 -0
  196. package/package.json +161 -0
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2025
4
+ Kamil Mysliwiec <https://kamilmysliwiec.com>
5
+ Thomas Ricart <thomasr2309@gmail.com>
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ 'Software'), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @depup/nestjs__cli
2
+
3
+ > Dependency-bumped version of [@nestjs/cli](https://www.npmjs.com/package/@nestjs/cli)
4
+
5
+ Generated by [DepUp](https://github.com/depup/npm) -- all production
6
+ dependencies bumped to latest versions.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @depup/nestjs__cli
12
+ ```
13
+
14
+ | Field | Value |
15
+ |-------|-------|
16
+ | Original | [@nestjs/cli](https://www.npmjs.com/package/@nestjs/cli) @ 11.0.16 |
17
+ | Processed | 2026-03-23 |
18
+ | Smoke test | failed |
19
+ | Deps updated | 12 |
20
+
21
+ ## Dependency Changes
22
+
23
+ | Dependency | From | To |
24
+ |------------|------|-----|
25
+ | @angular-devkit/core | 19.2.19 | ^21.2.3 |
26
+ | @angular-devkit/schematics | 19.2.19 | ^21.2.3 |
27
+ | @angular-devkit/schematics-cli | 19.2.19 | ^21.2.3 |
28
+ | @inquirer/prompts | 7.10.1 | ^8.3.2 |
29
+ | @nestjs/schematics | ^11.0.1 | ^11.0.9 |
30
+ | chokidar | 4.0.3 | ^5.0.0 |
31
+ | commander | 4.1.1 | ^14.0.3 |
32
+ | glob | 13.0.0 | ^13.0.6 |
33
+ | node-emoji | 1.11.0 | ^2.2.0 |
34
+ | ora | 5.4.1 | ^9.3.0 |
35
+ | typescript | 5.9.3 | ^6.0.2 |
36
+ | webpack | 5.104.1 | ^5.105.4 |
37
+
38
+ ---
39
+
40
+ Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/@nestjs/cli
41
+
42
+ License inherited from the original package.
@@ -0,0 +1,4 @@
1
+ import { Input } from '../commands';
2
+ export declare abstract class AbstractAction {
3
+ abstract handle(inputs?: Input[], options?: Input[], extraFlags?: string[]): Promise<void>;
4
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractAction = void 0;
4
+ class AbstractAction {
5
+ }
6
+ exports.AbstractAction = AbstractAction;
@@ -0,0 +1,12 @@
1
+ import { Input } from '../commands';
2
+ import { AbstractAction } from './abstract.action';
3
+ export declare class AddAction extends AbstractAction {
4
+ handle(inputs: Input[], options: Input[], extraFlags: string[]): Promise<void>;
5
+ private getSourceRoot;
6
+ private installPackage;
7
+ private addLibrary;
8
+ private getLibraryName;
9
+ private getPackageName;
10
+ private getCollectionName;
11
+ private getTagName;
12
+ }
@@ -0,0 +1,113 @@
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");
12
+ const schematicName = 'nest-add';
13
+ class AddAction extends abstract_action_1.AbstractAction {
14
+ async handle(inputs, options, extraFlags) {
15
+ const libraryName = this.getLibraryName(inputs);
16
+ const packageName = this.getPackageName(libraryName);
17
+ const collectionName = this.getCollectionName(libraryName, packageName);
18
+ 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));
21
+ if (packageInstallSuccess) {
22
+ const sourceRootOption = await this.getSourceRoot(inputs.concat(options));
23
+ options.push(sourceRootOption);
24
+ await this.addLibrary(collectionName, options, extraFlags);
25
+ }
26
+ 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));
29
+ }
30
+ }
31
+ async getSourceRoot(inputs) {
32
+ const configuration = await (0, load_configuration_1.loadConfiguration)();
33
+ 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)
38
+ : configuration.sourceRoot;
39
+ const shouldAsk = (0, project_utils_1.shouldAskForProject)(schematicName, configurationProjects, appName);
40
+ if (shouldAsk) {
41
+ const defaultLabel = ' [ Default ]';
42
+ let defaultProjectName = configuration.sourceRoot + defaultLabel;
43
+ for (const property in configurationProjects) {
44
+ if (configurationProjects[property].sourceRoot ===
45
+ configuration.sourceRoot) {
46
+ defaultProjectName = property + defaultLabel;
47
+ break;
48
+ }
49
+ }
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;
55
+ }
56
+ }
57
+ return { name: 'sourceRoot', value: sourceRoot };
58
+ }
59
+ async installPackage(collectionName, tagName) {
60
+ const manager = await package_managers_1.PackageManagerFactory.find();
61
+ tagName = tagName || 'latest';
62
+ let installResult = false;
63
+ try {
64
+ installResult = await manager.addProduction([collectionName], tagName);
65
+ }
66
+ catch (error) {
67
+ if (error && error.message) {
68
+ console.error((0, ansis_1.red)(error.message));
69
+ }
70
+ }
71
+ return installResult;
72
+ }
73
+ async addLibrary(collectionName, options, extraFlags) {
74
+ console.info(ui_1.MESSAGES.LIBRARY_INSTALLATION_STARTS);
75
+ const schematicOptions = [];
76
+ schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', options.find((option) => option.name === 'sourceRoot').value));
77
+ const extraFlagsString = extraFlags ? extraFlags.join(' ') : undefined;
78
+ try {
79
+ const collection = schematics_1.CollectionFactory.create(collectionName);
80
+ await collection.execute(schematicName, schematicOptions, extraFlagsString);
81
+ }
82
+ catch (error) {
83
+ if (error && error.message) {
84
+ console.error((0, ansis_1.red)(error.message));
85
+ return Promise.reject();
86
+ }
87
+ }
88
+ }
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
+ getPackageName(library) {
97
+ return library.startsWith('@')
98
+ ? library.split('/', 2).join('/')
99
+ : library.split('/', 1)[0];
100
+ }
101
+ getCollectionName(library, packageName) {
102
+ return ((packageName.startsWith('@')
103
+ ? packageName.split('@', 2).join('@')
104
+ : packageName.split('@', 1).join('@')) +
105
+ library.slice(packageName.length));
106
+ }
107
+ getTagName(packageName) {
108
+ return packageName.startsWith('@')
109
+ ? packageName.split('@', 3)[2]
110
+ : packageName.split('@', 2)[1];
111
+ }
112
+ }
113
+ exports.AddAction = AddAction;
@@ -0,0 +1,22 @@
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';
9
+ export declare class BuildAction extends AbstractAction {
10
+ protected readonly pluginsLoader: PluginsLoader;
11
+ protected readonly tsLoader: TypeScriptBinaryLoader;
12
+ protected readonly tsConfigProvider: TsConfigProvider;
13
+ protected readonly fileSystemReader: FileSystemReader;
14
+ 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>;
18
+ private runSwc;
19
+ private runWebpack;
20
+ private runTsc;
21
+ private getWebpackConfigFactoryByPath;
22
+ }
@@ -0,0 +1,145 @@
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();
30
+ }
31
+ async handle(commandInputs, commandOptions) {
32
+ 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);
38
+ }
39
+ catch (err) {
40
+ if (err instanceof Error) {
41
+ console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
42
+ }
43
+ else {
44
+ console.error(`\n${(0, ansis_1.red)(err)}\n`);
45
+ }
46
+ process.exit(1);
47
+ }
48
+ }
49
+ async runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
50
+ const configFileName = commandOptions.find((option) => option.name === 'config').value;
51
+ const configuration = await this.loader.load(configFileName);
52
+ const buildAll = commandOptions.find((opt) => opt.name === 'all')?.value;
53
+ let appNames;
54
+ if (buildAll) {
55
+ // If the "all" flag is set, we need to build all projects in a monorepo.
56
+ appNames = [];
57
+ if (configuration.projects) {
58
+ appNames.push(...Object.keys(configuration.projects));
59
+ }
60
+ }
61
+ else {
62
+ appNames = commandInputs
63
+ .filter((input) => input.name === 'app')
64
+ .map((input) => input.value);
65
+ }
66
+ if (appNames.length === 0) {
67
+ // If there are no projects, use "undefined" to build the default project.
68
+ appNames.push(undefined);
69
+ }
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);
75
+ const builder = isWebpackEnabled
76
+ ? { type: 'webpack' }
77
+ : (0, get_builder_1.getBuilder)(configuration, commandOptions, appName);
78
+ await (0, delete_out_dir_1.deleteOutDirIfEnabled)(configuration, appName, outDir);
79
+ this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
80
+ const typeCheck = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', commandOptions);
81
+ if (typeCheck && builder.type !== 'swc') {
82
+ console.warn(ui_1.INFO_PREFIX +
83
+ ` "typeCheck" will not have any effect when "builder" is not "swc".`);
84
+ }
85
+ switch (builder.type) {
86
+ case 'tsc':
87
+ await this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName, onSuccess);
88
+ break;
89
+ case 'webpack':
90
+ await this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode, onSuccess);
91
+ break;
92
+ case 'swc':
93
+ await this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions, onSuccess);
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, onSuccess) {
99
+ const { SwcCompiler } = await Promise.resolve().then(() => require('../lib/compiler/swc/swc-compiler'));
100
+ const swc = new SwcCompiler(this.pluginsLoader);
101
+ await swc.run(configuration, pathToTsconfig, appName, {
102
+ watch: watchMode,
103
+ typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
104
+ tsOptions,
105
+ assetsManager: this.assetsManager,
106
+ }, onSuccess);
107
+ }
108
+ async runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode, onSuccess) {
109
+ const { WebpackCompiler } = await Promise.resolve().then(() => require('../lib/compiler/webpack-compiler'));
110
+ 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);
114
+ return webpackCompiler.run(configuration, pathToTsconfig, appName, {
115
+ inputs: commandOptions,
116
+ webpackConfigFactoryOrConfig,
117
+ debug,
118
+ watchMode,
119
+ assetsManager: this.assetsManager,
120
+ }, onSuccess);
121
+ }
122
+ async runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess) {
123
+ if (watchMode) {
124
+ const { WatchCompiler } = await Promise.resolve().then(() => require('../lib/compiler/watch-compiler'));
125
+ const watchCompiler = new WatchCompiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
126
+ const isPreserveWatchOutputEnabled = options.find((option) => option.name === 'preserveWatchOutput' && option.value === true)?.value;
127
+ watchCompiler.run(configuration, pathToTsconfig, appName, { preserveWatchOutput: isPreserveWatchOutputEnabled }, onSuccess);
128
+ }
129
+ else {
130
+ const { Compiler } = await Promise.resolve().then(() => require('../lib/compiler/compiler'));
131
+ const compiler = new Compiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
132
+ compiler.run(configuration, pathToTsconfig, appName, undefined, onSuccess);
133
+ this.assetsManager.closeWatchers();
134
+ }
135
+ }
136
+ getWebpackConfigFactoryByPath(webpackPath, defaultPath) {
137
+ const pathToWebpackFile = (0, path_1.join)(process.cwd(), webpackPath);
138
+ const isWebpackFileAvailable = (0, is_module_available_1.isModuleAvailable)(pathToWebpackFile);
139
+ if (!isWebpackFileAvailable && webpackPath === defaultPath) {
140
+ return ({}) => ({});
141
+ }
142
+ return require(pathToWebpackFile);
143
+ }
144
+ }
145
+ exports.BuildAction = BuildAction;
@@ -0,0 +1,5 @@
1
+ import { Input } from '../commands';
2
+ import { AbstractAction } from './abstract.action';
3
+ export declare class GenerateAction extends AbstractAction {
4
+ handle(inputs: Input[], options: Input[]): Promise<void>;
5
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateAction = void 0;
4
+ const ansis_1 = require("ansis");
5
+ const path = require("path");
6
+ const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default");
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");
12
+ const type_assertions_1 = require("../lib/utils/type-assertions");
13
+ class GenerateAction extends abstract_action_1.AbstractAction {
14
+ async handle(inputs, options) {
15
+ await generateFiles(inputs.concat(options));
16
+ }
17
+ }
18
+ exports.GenerateAction = GenerateAction;
19
+ const generateFiles = async (inputs) => {
20
+ const configuration = await (0, load_configuration_1.loadConfiguration)();
21
+ const collectionOption = inputs.find((option) => option.name === 'collection').value;
22
+ const schematic = inputs.find((option) => option.name === 'schematic')
23
+ .value;
24
+ const appName = inputs.find((option) => option.name === 'project')
25
+ .value;
26
+ const spec = inputs.find((option) => option.name === 'spec');
27
+ const flat = inputs.find((option) => option.name === 'flat');
28
+ const specFileSuffix = inputs.find((option) => option.name === 'specFileSuffix');
29
+ const collection = schematics_1.CollectionFactory.create(collectionOption || configuration.collection || schematics_1.Collection.NESTJS);
30
+ const schematicOptions = mapSchematicOptions(inputs);
31
+ schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language));
32
+ const configurationProjects = configuration.projects;
33
+ let sourceRoot = appName
34
+ ? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
35
+ : configuration.sourceRoot;
36
+ const specValue = spec.value;
37
+ const flatValue = !!flat?.value;
38
+ const specFileSuffixValue = specFileSuffix.value;
39
+ const specOptions = spec.options;
40
+ let generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, appName, specValue, specOptions.passedAsInput);
41
+ let generateFlat = (0, project_utils_1.shouldGenerateFlat)(configuration, appName, flatValue);
42
+ let generateSpecFileSuffix = (0, project_utils_1.getSpecFileSuffix)(configuration, appName, specFileSuffixValue);
43
+ // If you only add a `lib` we actually don't have monorepo: true BUT we do have "projects"
44
+ // Ensure we don't run for new app/libs schematics
45
+ if ((0, project_utils_1.shouldAskForProject)(schematic, configurationProjects, appName)) {
46
+ const defaultLabel = ' [ Default ]';
47
+ let defaultProjectName = configuration.sourceRoot + defaultLabel;
48
+ for (const property in configurationProjects) {
49
+ if (configurationProjects[property].sourceRoot === configuration.sourceRoot) {
50
+ defaultProjectName = property + defaultLabel;
51
+ break;
52
+ }
53
+ }
54
+ const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
55
+ const selectedProjectName = (await (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.PROJECT_SELECTION_QUESTION, projects));
56
+ const project = selectedProjectName.replace(defaultLabel, '');
57
+ if (project !== configuration.sourceRoot) {
58
+ sourceRoot = configurationProjects[project].sourceRoot;
59
+ }
60
+ if (selectedProjectName !== defaultProjectName) {
61
+ // Only overwrite if the appName is not the default- as it has already been loaded above
62
+ generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, selectedProjectName, specValue, specOptions.passedAsInput);
63
+ generateFlat = (0, project_utils_1.shouldGenerateFlat)(configuration, selectedProjectName, flatValue);
64
+ generateSpecFileSuffix = (0, project_utils_1.getSpecFileSuffix)(configuration, appName, specFileSuffixValue);
65
+ }
66
+ }
67
+ if (configuration.generateOptions?.baseDir) {
68
+ sourceRoot = path.join(sourceRoot, configuration.generateOptions.baseDir);
69
+ }
70
+ schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', sourceRoot));
71
+ schematicOptions.push(new schematics_1.SchematicOption('spec', generateSpec));
72
+ schematicOptions.push(new schematics_1.SchematicOption('flat', generateFlat));
73
+ schematicOptions.push(new schematics_1.SchematicOption('specFileSuffix', generateSpecFileSuffix));
74
+ try {
75
+ const schematicInput = inputs.find((input) => input.name === 'schematic');
76
+ if (!schematicInput) {
77
+ throw new Error('Unable to find a schematic for this configuration');
78
+ }
79
+ await collection.execute(schematicInput.value, schematicOptions);
80
+ }
81
+ catch (error) {
82
+ if (error && error.message) {
83
+ console.error((0, ansis_1.red)(error.message));
84
+ }
85
+ }
86
+ };
87
+ const mapSchematicOptions = (inputs) => {
88
+ const excludedInputNames = ['schematic', 'spec', 'flat', 'specFileSuffix'];
89
+ const options = [];
90
+ inputs.forEach((input) => {
91
+ if (!excludedInputNames.includes(input.name) && input.value !== undefined) {
92
+ (0, type_assertions_1.assertNonArray)(input.value);
93
+ options.push(new schematics_1.SchematicOption(input.name, input.value));
94
+ }
95
+ });
96
+ return options;
97
+ };
@@ -0,0 +1,7 @@
1
+ export * from './abstract.action';
2
+ export * from './build.action';
3
+ export * from './generate.action';
4
+ export * from './info.action';
5
+ export * from './new.action';
6
+ export * from './start.action';
7
+ export * from './add.action';
@@ -0,0 +1,23 @@
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("./abstract.action"), exports);
18
+ __exportStar(require("./build.action"), exports);
19
+ __exportStar(require("./generate.action"), exports);
20
+ __exportStar(require("./info.action"), exports);
21
+ __exportStar(require("./new.action"), exports);
22
+ __exportStar(require("./start.action"), exports);
23
+ __exportStar(require("./add.action"), exports);
@@ -0,0 +1,35 @@
1
+ import { AbstractAction } from './abstract.action';
2
+ interface LockfileDependency {
3
+ version: string;
4
+ }
5
+ interface PackageJsonDependencies {
6
+ [key: string]: LockfileDependency;
7
+ }
8
+ interface NestDependency {
9
+ name: string;
10
+ value: string;
11
+ packageName: string;
12
+ }
13
+ interface NestDependencyWarnings {
14
+ [key: string]: Array<NestDependency>;
15
+ }
16
+ export declare class InfoAction extends AbstractAction {
17
+ private manager;
18
+ private warningMessageDependenciesWhiteList;
19
+ handle(): Promise<void>;
20
+ private displayBanner;
21
+ private displaySystemInformation;
22
+ displayPackageManagerVersion(): Promise<void>;
23
+ displayNestInformation(): Promise<void>;
24
+ displayNestInformationFromPackage(): Promise<void>;
25
+ displayCliVersion(): void;
26
+ readProjectPackageDependencies(): PackageJsonDependencies;
27
+ displayNestVersions(dependencies: PackageJsonDependencies): void;
28
+ displayWarningMessage(nestDependencies: NestDependency[]): void;
29
+ buildNestVersionsWarningMessage(nestDependencies: NestDependency[]): NestDependencyWarnings;
30
+ buildNestVersionsMessage(dependencies: PackageJsonDependencies): NestDependency[];
31
+ collectNestDependencies(dependencies: PackageJsonDependencies): NestDependency[];
32
+ format(dependencies: NestDependency[]): NestDependency[];
33
+ rightPad(name: string, length: number): string;
34
+ }
35
+ export {};