@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,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exit = exports.retrieveCols = exports.NewAction = void 0;
4
- const prompts_1 = require("@inquirer/prompts");
5
- const ansis = require("ansis");
6
- const child_process_1 = require("child_process");
7
- const fs = require("fs");
8
- const path_1 = require("path");
9
- const defaults_1 = require("../lib/configuration/defaults");
10
- const package_managers_1 = require("../lib/package-managers");
11
- const questions_1 = require("../lib/questions/questions");
12
- const git_runner_1 = require("../lib/runners/git.runner");
13
- const schematics_1 = require("../lib/schematics");
14
- const ui_1 = require("../lib/ui");
15
- const formatting_1 = require("../lib/utils/formatting");
16
- const gracefully_exit_on_prompt_error_1 = require("../lib/utils/gracefully-exit-on-prompt-error");
17
- const abstract_action_1 = require("./abstract.action");
18
- const type_assertions_1 = require("../lib/utils/type-assertions");
19
- class NewAction extends abstract_action_1.AbstractAction {
20
- async handle(inputs, options) {
21
- const directoryOption = options.find((option) => option.name === 'directory');
22
- const dryRunOption = options.find((option) => option.name === 'dry-run');
23
- const isDryRunEnabled = dryRunOption && dryRunOption.value;
24
- await askForMissingInformation(inputs, options);
25
- await generateApplicationFiles(inputs, options).catch(exports.exit);
26
- const shouldSkipInstall = options.some((option) => option.name === 'skip-install' && option.value === true);
27
- const shouldSkipGit = options.some((option) => option.name === 'skip-git' && option.value === true);
28
- const projectDirectory = getProjectDirectory(getApplicationNameInput(inputs), directoryOption);
29
- if (!shouldSkipInstall) {
30
- await installPackages(options, isDryRunEnabled, projectDirectory);
1
+ import { confirm, input, select } from '@inquirer/prompts';
2
+ import ansis from 'ansis';
3
+ import { execSync } from 'child_process';
4
+ import * as fs from 'fs';
5
+ import { join } from 'path';
6
+ import { defaultGitIgnore } from '../lib/configuration/defaults.js';
7
+ import { PackageManager, PackageManagerFactory, } from '../lib/package-managers/index.js';
8
+ import { generateInput, generateSelect } from '../lib/questions/questions.js';
9
+ import { GitRunner } from '../lib/runners/git.runner.js';
10
+ import { Collection, CollectionFactory, SchematicOption, } from '../lib/schematics/index.js';
11
+ import { EMOJIS, MESSAGES } from '../lib/ui/index.js';
12
+ import { normalizeToKebabOrSnakeCase } from '../lib/utils/formatting.js';
13
+ import { gracefullyExitOnPromptError } from '../lib/utils/gracefully-exit-on-prompt-error.js';
14
+ import { isInteractive } from '../lib/utils/is-interactive.js';
15
+ import { AbstractAction } from './abstract.action.js';
16
+ export class NewAction extends AbstractAction {
17
+ async handle(context) {
18
+ await askForMissingInformation(context);
19
+ await generateApplicationFiles(context).catch(exit);
20
+ const projectDirectory = getProjectDirectory(context);
21
+ if (!context.skipInstall) {
22
+ await installPackages(context, projectDirectory);
31
23
  }
32
- if (!isDryRunEnabled) {
33
- if (!shouldSkipGit) {
24
+ if (!context.dryRun) {
25
+ if (!context.skipGit) {
34
26
  await initializeGitRepository(projectDirectory);
35
27
  await createGitIgnoreFile(projectDirectory);
36
28
  }
@@ -39,81 +31,98 @@ class NewAction extends abstract_action_1.AbstractAction {
39
31
  process.exit(0);
40
32
  }
41
33
  }
42
- exports.NewAction = NewAction;
43
- const getApplicationNameInput = (inputs) => inputs.find((input) => input.name === 'name');
44
- const getPackageManagerInput = (inputs) => inputs.find((options) => options.name === 'packageManager');
45
- const getProjectDirectory = (applicationName, directoryOption) => {
46
- return ((directoryOption && directoryOption.value) ||
47
- (0, formatting_1.normalizeToKebabOrSnakeCase)(applicationName.value));
34
+ const getProjectDirectory = (context) => {
35
+ return (context.directory || normalizeToKebabOrSnakeCase(context.name));
48
36
  };
49
- const askForMissingInformation = async (inputs, options) => {
50
- console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
37
+ const askForMissingInformation = async (context) => {
38
+ console.info(MESSAGES.PROJECT_INFORMATION_START);
51
39
  console.info();
52
- const nameInput = getApplicationNameInput(inputs);
53
- if (!nameInput.value) {
54
- const message = ui_1.MESSAGES.PROJECT_NAME_QUESTION;
55
- const question = (0, questions_1.generateInput)('name', message)('nest-app');
56
- const answer = await (0, prompts_1.input)(question).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
57
- replaceInputMissingInformation(inputs, { name: 'name', value: answer });
40
+ if (!context.name) {
41
+ const message = MESSAGES.PROJECT_NAME_QUESTION;
42
+ const question = generateInput('name', message)('nest-app');
43
+ context.name = (await input(question).catch(gracefullyExitOnPromptError));
58
44
  }
59
- const packageManagerInput = getPackageManagerInput(options);
60
- if (!packageManagerInput.value) {
61
- const answer = await askForPackageManager();
62
- replaceInputMissingInformation(options, {
63
- name: 'packageManager',
64
- value: answer,
65
- });
45
+ if (!context.packageManager) {
46
+ context.packageManager = (await askForPackageManager());
66
47
  }
67
- };
68
- const replaceInputMissingInformation = (inputs, answer) => {
69
- const input = inputs.find((input) => input.name === answer.name);
70
- if (input) {
71
- input.value = input.value !== undefined ? input.value : answer.value;
48
+ if (context.observe === undefined) {
49
+ context.observe = await askForObservability();
72
50
  }
73
51
  };
74
- const generateApplicationFiles = async (args, options) => {
75
- const collectionName = options.find((option) => option.name === 'collection' && option.value != null).value;
76
- const collection = schematics_1.CollectionFactory.create(collectionName || schematics_1.Collection.NESTJS);
77
- const schematicOptions = mapSchematicOptions(args.concat(options));
52
+ const generateApplicationFiles = async (context) => {
53
+ const collection = CollectionFactory.create(context.collection || Collection.NESTJS);
54
+ const schematicOptions = mapContextToSchematicOptions(context);
78
55
  await collection.execute('application', schematicOptions);
79
56
  console.info();
80
57
  };
81
- const mapSchematicOptions = (options) => {
82
- return options.reduce((schematicOptions, option) => {
83
- if (option.name !== 'skip-install') {
84
- (0, type_assertions_1.assertNonArray)(option.value);
85
- schematicOptions.push(new schematics_1.SchematicOption(option.name, option.value));
86
- }
87
- return schematicOptions;
88
- }, []);
58
+ const mapContextToSchematicOptions = (context) => {
59
+ const options = [];
60
+ if (context.name !== undefined)
61
+ options.push(new SchematicOption('name', context.name));
62
+ if (context.directory !== undefined)
63
+ options.push(new SchematicOption('directory', context.directory));
64
+ if (context.dryRun)
65
+ options.push(new SchematicOption('dry-run', true));
66
+ options.push(new SchematicOption('skip-git', context.skipGit));
67
+ options.push(new SchematicOption('strict', context.strict));
68
+ if (context.skipTests) {
69
+ options.push(new SchematicOption('spec', false));
70
+ }
71
+ if (context.packageManager !== undefined)
72
+ options.push(new SchematicOption('packageManager', context.packageManager));
73
+ if (context.collection !== undefined)
74
+ options.push(new SchematicOption('collection', context.collection));
75
+ options.push(new SchematicOption('language', context.language));
76
+ options.push(new SchematicOption('format', context.format));
77
+ if (context.observe) {
78
+ options.push(new SchematicOption('observe', true));
79
+ }
80
+ // note: skip-install is intentionally excluded — not sent to schematics
81
+ return options;
89
82
  };
90
- const installPackages = async (options, dryRunMode, installDirectory) => {
91
- const inputPackageManager = getPackageManagerInput(options).value;
83
+ const installPackages = async (context, installDirectory) => {
84
+ const inputPackageManager = context.packageManager;
92
85
  let packageManager;
93
- if (dryRunMode) {
86
+ if (context.dryRun) {
94
87
  console.info();
95
- console.info(ansis.green(ui_1.MESSAGES.DRY_RUN_MODE));
88
+ console.info(ansis.green(MESSAGES.DRY_RUN_MODE));
96
89
  console.info();
97
90
  return;
98
91
  }
99
92
  try {
100
- packageManager = package_managers_1.PackageManagerFactory.create(inputPackageManager);
93
+ packageManager = PackageManagerFactory.create(inputPackageManager);
101
94
  await packageManager.install(installDirectory, inputPackageManager);
102
95
  }
103
96
  catch (error) {
104
- if (error && error.message) {
97
+ if (error instanceof Error) {
105
98
  console.error(ansis.red(error.message));
106
99
  }
107
100
  }
108
101
  };
102
+ const askForObservability = async () => {
103
+ // Without a TTY (CI, piped input, `execSync`) there is nobody to answer, so
104
+ // fall back to the opt-out default instead of blocking the scaffold.
105
+ if (!isInteractive()) {
106
+ return false;
107
+ }
108
+ return (await confirm({
109
+ message: MESSAGES.OBSERVABILITY_QUESTION,
110
+ default: false,
111
+ }).catch(gracefullyExitOnPromptError));
112
+ };
109
113
  const askForPackageManager = async () => {
110
- const question = (0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([package_managers_1.PackageManager.NPM, package_managers_1.PackageManager.YARN, package_managers_1.PackageManager.PNPM]);
111
- return (0, prompts_1.select)(question).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
114
+ const question = generateSelect('packageManager')(MESSAGES.PACKAGE_MANAGER_QUESTION)([
115
+ PackageManager.NPM,
116
+ PackageManager.YARN,
117
+ PackageManager.PNPM,
118
+ PackageManager.BUN,
119
+ ]);
120
+ return select(question).catch(gracefullyExitOnPromptError);
112
121
  };
113
122
  const initializeGitRepository = async (dir) => {
114
- const runner = new git_runner_1.GitRunner();
115
- await runner.run('init', true, (0, path_1.join)(process.cwd(), dir)).catch(() => {
116
- console.error(ansis.red(ui_1.MESSAGES.GIT_INITIALIZATION_ERROR));
123
+ const runner = new GitRunner();
124
+ await runner.run('init', true, join(process.cwd(), dir)).catch(() => {
125
+ console.error(ansis.red(MESSAGES.GIT_INITIALIZATION_ERROR));
117
126
  });
118
127
  };
119
128
  /**
@@ -127,8 +136,8 @@ const initializeGitRepository = async (dir) => {
127
136
  * @return Resolves when succeeds, or rejects with any error from `fn.writeFile`.
128
137
  */
129
138
  const createGitIgnoreFile = (dir, content) => {
130
- const fileContent = content || defaults_1.defaultGitIgnore;
131
- const filePath = (0, path_1.join)(process.cwd(), dir, '.gitignore');
139
+ const fileContent = content || defaultGitIgnore;
140
+ const filePath = join(process.cwd(), dir, '.gitignore');
132
141
  if (fileExists(filePath)) {
133
142
  return;
134
143
  }
@@ -139,17 +148,18 @@ const printCollective = () => {
139
148
  const yellow = print('yellow');
140
149
  const emptyLine = print();
141
150
  emptyLine();
142
- yellow(`Thanks for installing Nest ${ui_1.EMOJIS.PRAY}`);
151
+ yellow(`Thanks for installing Nest ${EMOJIS.PRAY}`);
143
152
  dim('Please consider donating to our open collective');
144
153
  dim('to help us maintain this package.');
145
154
  emptyLine();
146
155
  emptyLine();
147
- print()(`${ansis.bold `${ui_1.EMOJIS.WINE} Donate:`} ${ansis.underline('https://opencollective.com/nest')}`);
156
+ print()(`${ansis.bold `${EMOJIS.WINE} Donate:`} ${ansis.underline('https://opencollective.com/nest')}`);
148
157
  emptyLine();
149
158
  };
150
159
  const print = (color = null) => (str = '') => {
151
- const terminalCols = (0, exports.retrieveCols)();
152
- const strLength = str.replace(/\u001b\[[0-9]{2}m/g, '').length;
160
+ const terminalCols = retrieveCols();
161
+ // eslint-disable-next-line no-control-regex
162
+ const strLength = str.replace(/\x1b\[[0-9]+m/g, '').length;
153
163
  const leftPaddingLength = Math.floor((terminalCols - strLength) / 2);
154
164
  const leftPadding = ' '.repeat(Math.max(leftPaddingLength, 0));
155
165
  if (color) {
@@ -157,10 +167,17 @@ const print = (color = null) => (str = '') => {
157
167
  }
158
168
  console.log(leftPadding, str);
159
169
  };
160
- const retrieveCols = () => {
170
+ export const retrieveCols = () => {
161
171
  const defaultCols = 80;
172
+ // Prefer process.stdout.columns: it works on every platform (including
173
+ // Windows, where `tput` is not available by default) and reflects the
174
+ // actual terminal size instead of always falling back to the default.
175
+ const stdoutCols = process.stdout.columns;
176
+ if (typeof stdoutCols === 'number' && stdoutCols > 0) {
177
+ return stdoutCols;
178
+ }
162
179
  try {
163
- const terminalCols = (0, child_process_1.execSync)('tput cols', {
180
+ const terminalCols = execSync('tput cols', {
164
181
  stdio: ['pipe', 'pipe', 'ignore'],
165
182
  });
166
183
  return parseInt(terminalCols.toString(), 10) || defaultCols;
@@ -169,18 +186,5 @@ const retrieveCols = () => {
169
186
  return defaultCols;
170
187
  }
171
188
  };
172
- exports.retrieveCols = retrieveCols;
173
- const fileExists = (path) => {
174
- try {
175
- fs.accessSync(path);
176
- return true;
177
- }
178
- catch (err) {
179
- if (err.code === 'ENOENT') {
180
- return false;
181
- }
182
- throw err;
183
- }
184
- };
185
- const exit = () => process.exit(1);
186
- exports.exit = exit;
189
+ const fileExists = (path) => fs.existsSync(path);
190
+ export const exit = () => process.exit(1);
@@ -1,10 +1,7 @@
1
- import { Input } from '../commands';
2
- import { BuildAction } from './build.action';
1
+ import { StartCommandContext } from '../commands/index.js';
2
+ import { BuildAction } from './build.action.js';
3
3
  export declare class StartAction extends BuildAction {
4
- handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>;
5
- createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string, options: {
6
- shell: boolean;
7
- envFile?: string[];
8
- }): () => void;
4
+ handle(context: StartCommandContext): Promise<void>;
5
+ private createOnSuccessHook;
9
6
  private spawnChildProcess;
10
7
  }
@@ -1,60 +1,54 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StartAction = void 0;
4
- const ansis_1 = require("ansis");
5
- const child_process_1 = require("child_process");
6
- const fs = require("fs");
7
- const path_1 = require("path");
8
- const get_tsc_config_path_1 = require("../lib/compiler/helpers/get-tsc-config.path");
9
- const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default");
10
- const defaults_1 = require("../lib/configuration/defaults");
11
- const ui_1 = require("../lib/ui");
12
- const tree_kill_1 = require("../lib/utils/tree-kill");
13
- const type_assertions_1 = require("../lib/utils/type-assertions");
14
- const build_action_1 = require("./build.action");
15
- class StartAction extends build_action_1.BuildAction {
16
- async handle(commandInputs, commandOptions) {
1
+ import { red } from 'ansis';
2
+ import { spawn } from 'child_process';
3
+ import * as fs from 'fs';
4
+ import { join } from 'path';
5
+ import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path.js';
6
+ import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default.js';
7
+ import { defaultConfiguration, defaultOutDir, } from '../lib/configuration/defaults.js';
8
+ import { ERROR_PREFIX } from '../lib/ui/index.js';
9
+ import { treeKillSync as killProcessSync } from '../lib/utils/tree-kill.js';
10
+ import { assertNonArray } from '../lib/utils/type-assertions.js';
11
+ import { BuildAction } from './build.action.js';
12
+ export class StartAction extends BuildAction {
13
+ async handle(context) {
17
14
  try {
18
- const configFileName = commandOptions.find((option) => option.name === 'config').value;
15
+ const configFileName = context.config;
19
16
  const configuration = await this.loader.load(configFileName);
20
- const appName = commandInputs.find((input) => input.name === 'app')
21
- .value;
22
- const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
23
- const debugModeOption = commandOptions.find((option) => option.name === 'debug');
24
- const watchModeOption = commandOptions.find((option) => option.name === 'watch');
25
- const isWatchEnabled = !!(watchModeOption && watchModeOption.value);
26
- const watchAssetsModeOption = commandOptions.find((option) => option.name === 'watchAssets');
27
- const isWatchAssetsEnabled = !!(watchAssetsModeOption && watchAssetsModeOption.value);
28
- const debugFlag = debugModeOption && debugModeOption.value;
29
- (0, type_assertions_1.assertNonArray)(debugFlag);
30
- const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', commandOptions, defaults_1.defaultConfiguration.exec);
17
+ const appName = context.app;
18
+ const pathToTsconfig = getTscConfigPath(configuration, context, appName);
19
+ const isWatchEnabled = !!context.watch;
20
+ const isWatchAssetsEnabled = !!context.watchAssets;
21
+ const debugFlag = context.debug;
22
+ assertNonArray(debugFlag);
23
+ const binaryToRun = getValueOrDefault(configuration, 'exec', appName, 'exec', context, defaultConfiguration.exec);
31
24
  const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
32
- const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
33
- const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', commandOptions, defaults_1.defaultConfiguration.entryFile);
34
- const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', commandOptions, defaults_1.defaultConfiguration.sourceRoot);
35
- const shellOption = commandOptions.find((option) => option.name === 'shell');
36
- const useShell = !!shellOption?.value;
37
- const envFileOption = commandOptions.find((option) => option.name === 'envFile');
38
- const envFile = (envFileOption?.value ?? []);
25
+ const outDir = tsOptions.outDir || defaultOutDir;
26
+ const entryFile = getValueOrDefault(configuration, 'entryFile', appName, 'entryFile', context, defaultConfiguration.entryFile);
27
+ const sourceRoot = getValueOrDefault(configuration, 'sourceRoot', appName, 'sourceRoot', context, defaultConfiguration.sourceRoot);
28
+ const useShell = !!context.shell;
29
+ const envFile = context.envFile ?? [];
39
30
  const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, {
40
31
  shell: useShell,
41
32
  envFile,
42
33
  });
43
- await this.runBuild(commandInputs, commandOptions, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
34
+ await this.runBuild(appName ? [appName] : [], context, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
44
35
  }
45
36
  catch (err) {
46
37
  if (err instanceof Error) {
47
- console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
38
+ console.error(`\n${ERROR_PREFIX} ${err.message}\n`);
48
39
  }
49
40
  else {
50
- console.error(`\n${(0, ansis_1.red)(err)}\n`);
41
+ console.error(`\n${red(err)}\n`);
51
42
  }
43
+ // A failed build (e.g. SWC type-check errors, which now reject instead of
44
+ // exiting the process themselves) must not report success to the caller.
45
+ process.exit(1);
52
46
  }
53
47
  }
54
48
  createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, options) {
55
49
  let childProcessRef;
56
50
  let shuttingDown = false;
57
- process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
51
+ process.on('exit', () => childProcessRef && killProcessSync(childProcessRef.pid));
58
52
  const signalHandler = (signal) => {
59
53
  shuttingDown = true;
60
54
  if (childProcessRef) {
@@ -88,8 +82,8 @@ class StartAction extends build_action_1.BuildAction {
88
82
  }
89
83
  });
90
84
  });
91
- childProcessRef.stdin && childProcessRef.stdin.pause();
92
- (0, tree_kill_1.treeKillSync)(childProcessRef.pid);
85
+ childProcessRef.stdin?.pause?.();
86
+ killProcessSync(childProcessRef.pid);
93
87
  }
94
88
  else {
95
89
  childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
@@ -110,9 +104,9 @@ class StartAction extends build_action_1.BuildAction {
110
104
  };
111
105
  }
112
106
  spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, options) {
113
- let outputFilePath = (0, path_1.join)(outDirName, sourceRoot, entryFile);
107
+ let outputFilePath = join(outDirName, sourceRoot, entryFile);
114
108
  if (!fs.existsSync(outputFilePath + '.js')) {
115
- outputFilePath = (0, path_1.join)(outDirName, entryFile);
109
+ outputFilePath = join(outDirName, entryFile);
116
110
  }
117
111
  let childProcessArgs = [];
118
112
  const argsStartIndex = process.argv.indexOf('--');
@@ -135,7 +129,7 @@ class StartAction extends build_action_1.BuildAction {
135
129
  }
136
130
  if (options.envFile && options.envFile.length > 0) {
137
131
  const envFileNodeArgs = options.envFile.map((envFilePath) => `--env-file=${envFilePath}`);
138
- processArgs.unshift(envFileNodeArgs.join(' '));
132
+ processArgs.unshift(...envFileNodeArgs);
139
133
  }
140
134
  processArgs.unshift('--enable-source-maps');
141
135
  const spawnOptions = {
@@ -144,9 +138,8 @@ class StartAction extends build_action_1.BuildAction {
144
138
  };
145
139
  if (options.shell) {
146
140
  const command = [binaryToRun, ...processArgs].join(' ');
147
- return (0, child_process_1.spawn)(command, spawnOptions);
141
+ return spawn(command, spawnOptions);
148
142
  }
149
- return (0, child_process_1.spawn)(binaryToRun, processArgs, spawnOptions);
143
+ return spawn(binaryToRun, processArgs, spawnOptions);
150
144
  }
151
145
  }
152
- exports.StartAction = StartAction;
@@ -0,0 +1,6 @@
1
+ import { UpgradeCommandContext } from '../commands/index.js';
2
+ import { AbstractAction } from './abstract.action.js';
3
+ export declare class UpgradeAction extends AbstractAction {
4
+ handle(context: UpgradeCommandContext): Promise<void>;
5
+ private mapSchematicOptions;
6
+ }
@@ -0,0 +1,53 @@
1
+ import { green, red } from 'ansis';
2
+ import { Collection, CollectionFactory, SchematicOption, } from '../lib/schematics/index.js';
3
+ import { INFO_PREFIX, MESSAGES } from '../lib/ui/index.js';
4
+ import { isInteractive } from '../lib/utils/is-interactive.js';
5
+ import { loadConfiguration } from '../lib/utils/load-configuration.js';
6
+ import { AbstractAction } from './abstract.action.js';
7
+ const schematicName = 'upgrade';
8
+ export class UpgradeAction extends AbstractAction {
9
+ async handle(context) {
10
+ const configuration = await loadConfiguration();
11
+ const collectionName = context.collection || configuration.collection || Collection.NESTJS;
12
+ const schematicOptions = this.mapSchematicOptions(context);
13
+ console.info(MESSAGES.UPGRADE_IN_PROGRESS);
14
+ try {
15
+ const collection = CollectionFactory.create(collectionName);
16
+ await collection.execute(schematicName, schematicOptions);
17
+ }
18
+ catch (error) {
19
+ if (error instanceof Error) {
20
+ console.error(red(error.message));
21
+ }
22
+ throw error;
23
+ }
24
+ if (context.dryRun) {
25
+ console.info();
26
+ console.info(green(MESSAGES.DRY_RUN_MODE));
27
+ console.info();
28
+ return;
29
+ }
30
+ // The schematic only bumps the project's local @nestjs/cli.
31
+ console.info(`\n${INFO_PREFIX} ${MESSAGES.UPGRADE_GLOBAL_CLI_HINT}\n`);
32
+ }
33
+ mapSchematicOptions(context) {
34
+ const options = [];
35
+ if (context.dryRun)
36
+ options.push(new SchematicOption('dry-run', true));
37
+ if (context.skipInstall) {
38
+ options.push(new SchematicOption('skip-install', true));
39
+ }
40
+ if (context.tag !== undefined) {
41
+ options.push(new SchematicOption('tag', context.tag));
42
+ }
43
+ if (context.observe !== undefined) {
44
+ options.push(new SchematicOption('observe', context.observe));
45
+ }
46
+ else if (!isInteractive()) {
47
+ // The schematic's `x-prompt` would block forever without a TTY (CI,
48
+ // pipes), so answer it up front and leave prompting to TTY sessions.
49
+ options.push(new SchematicOption('observe', false));
50
+ }
51
+ return options;
52
+ }
53
+ }
package/bin/nest.js CHANGED
@@ -1,23 +1,24 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const commander = require("commander");
5
- const commands_1 = require("../commands");
6
- const local_binaries_1 = require("../lib/utils/local-binaries");
2
+ import { Command } from 'commander';
3
+ import { createRequire } from 'module';
4
+ import { CommandLoader } from '../commands/index.js';
5
+ import { loadLocalBinCommandLoader, localBinExists, } from '../lib/utils/local-binaries.js';
6
+ const require = createRequire(import.meta.url);
7
7
  const bootstrap = async () => {
8
- const program = commander;
8
+ const program = new Command();
9
+ program.__nestCliEsm = true;
9
10
  program
10
11
  .version(require('../package.json').version, '-v, --version', 'Output the current version.')
11
12
  .usage('<command> [options]')
12
13
  .helpOption('-h, --help', 'Output usage information.');
13
- if ((0, local_binaries_1.localBinExists)()) {
14
- const localCommandLoader = (0, local_binaries_1.loadLocalBinCommandLoader)();
14
+ if (localBinExists()) {
15
+ const localCommandLoader = await loadLocalBinCommandLoader();
15
16
  await localCommandLoader.load(program);
16
17
  }
17
18
  else {
18
- await commands_1.CommandLoader.load(program);
19
+ await CommandLoader.load(program);
19
20
  }
20
- await commander.parseAsync(process.argv);
21
+ await program.parseAsync(process.argv);
21
22
  if (!process.argv.slice(2).length) {
22
23
  program.outputHelp();
23
24
  }
package/changes.json CHANGED
@@ -1,54 +1,22 @@
1
1
  {
2
2
  "bumped": {
3
3
  "@angular-devkit/core": {
4
- "from": "19.2.27",
4
+ "from": "22.1.5",
5
5
  "to": "^22.1.6"
6
6
  },
7
7
  "@angular-devkit/schematics": {
8
- "from": "19.2.27",
8
+ "from": "22.1.5",
9
9
  "to": "^22.1.6"
10
10
  },
11
11
  "@angular-devkit/schematics-cli": {
12
- "from": "19.2.27",
12
+ "from": "22.1.5",
13
13
  "to": "^22.1.6"
14
14
  },
15
- "@inquirer/prompts": {
16
- "from": "7.10.1",
17
- "to": "^8.7.0"
18
- },
19
- "@nestjs/schematics": {
20
- "from": "^11.0.1",
21
- "to": "^11.1.0"
22
- },
23
- "ansis": {
24
- "from": "4.2.0",
25
- "to": "^4.3.1"
26
- },
27
- "chokidar": {
28
- "from": "4.0.3",
29
- "to": "^5.0.0"
30
- },
31
- "commander": {
32
- "from": "4.1.1",
33
- "to": "^15.0.0"
34
- },
35
- "node-emoji": {
36
- "from": "1.11.0",
37
- "to": "^2.2.0"
38
- },
39
- "ora": {
40
- "from": "5.4.1",
41
- "to": "^9.4.1"
42
- },
43
15
  "typescript": {
44
- "from": "5.9.3",
16
+ "from": "~6.0.2",
45
17
  "to": "^7.0.2"
46
- },
47
- "webpack": {
48
- "from": "5.106.2",
49
- "to": "^5.109.2"
50
18
  }
51
19
  },
52
- "timestamp": "2026-08-27T01:37:40.713Z",
53
- "totalUpdated": 12
20
+ "timestamp": "2026-08-27T11:23:37.886Z",
21
+ "totalUpdated": 4
54
22
  }
@@ -1,7 +1,7 @@
1
- import { CommanderStatic } from 'commander';
2
- import { AbstractAction } from '../actions/abstract.action';
1
+ import { Command } from 'commander';
2
+ import { AbstractAction } from '../actions/abstract.action.js';
3
3
  export declare abstract class AbstractCommand {
4
4
  protected action: AbstractAction;
5
5
  constructor(action: AbstractAction);
6
- abstract load(program: CommanderStatic): void;
6
+ abstract load(program: Command): void;
7
7
  }
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractCommand = void 0;
4
- class AbstractCommand {
1
+ export class AbstractCommand {
2
+ action;
5
3
  constructor(action) {
6
4
  this.action = action;
7
5
  }
8
6
  }
9
- exports.AbstractCommand = AbstractCommand;
@@ -1,5 +1,5 @@
1
- import { CommanderStatic } from 'commander';
2
- import { AbstractCommand } from './abstract.command';
1
+ import { Command } from 'commander';
2
+ import { AbstractCommand } from './abstract.command.js';
3
3
  export declare class AddCommand extends AbstractCommand {
4
- load(program: CommanderStatic): void;
4
+ load(program: Command): void;
5
5
  }