nx 23.0.0-beta.2 → 23.0.0-beta.20

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 (274) hide show
  1. package/dist/bin/init-local.js +11 -20
  2. package/dist/bin/nx.d.ts +1 -0
  3. package/dist/bin/nx.js +28 -2
  4. package/dist/plugins/package-json.js +4 -2
  5. package/dist/src/adapter/ngcli-adapter.d.ts +2 -1
  6. package/dist/src/adapter/ngcli-adapter.js +25 -2
  7. package/dist/src/ai/clone-ai-config-repo.js +20 -3
  8. package/dist/src/analytics/analytics.js +10 -1
  9. package/dist/src/command-line/add/completion.d.ts +1 -0
  10. package/dist/src/command-line/add/completion.js +15 -0
  11. package/dist/src/command-line/affected/completion.d.ts +1 -0
  12. package/dist/src/command-line/affected/completion.js +15 -0
  13. package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
  14. package/dist/src/command-line/completion/argv-layout.js +19 -0
  15. package/dist/src/command-line/completion/command-completions.d.ts +19 -0
  16. package/dist/src/command-line/completion/command-completions.js +120 -0
  17. package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
  18. package/dist/src/command-line/completion/command-handlers.js +69 -0
  19. package/dist/src/command-line/completion/command-object.d.ts +10 -0
  20. package/dist/src/command-line/completion/command-object.js +95 -0
  21. package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
  22. package/dist/src/command-line/completion/completion-providers.js +194 -0
  23. package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
  24. package/dist/src/command-line/completion/infix-targets.js +48 -0
  25. package/dist/src/command-line/completion/metadata.d.ts +22 -0
  26. package/dist/src/command-line/completion/metadata.js +71 -0
  27. package/dist/src/command-line/completion/registrations.d.ts +9 -0
  28. package/dist/src/command-line/completion/registrations.js +16 -0
  29. package/dist/src/command-line/completion/scripts/bash.sh +51 -0
  30. package/dist/src/command-line/completion/scripts/fish.fish +47 -0
  31. package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
  32. package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
  33. package/dist/src/command-line/completion/scripts.d.ts +18 -0
  34. package/dist/src/command-line/completion/scripts.js +140 -0
  35. package/dist/src/command-line/completion/trigger.d.ts +3 -0
  36. package/dist/src/command-line/completion/trigger.js +21 -0
  37. package/dist/src/command-line/completion/value-completions.d.ts +3 -0
  38. package/dist/src/command-line/completion/value-completions.js +21 -0
  39. package/dist/src/command-line/examples.js +1 -1
  40. package/dist/src/command-line/format/format.js +15 -5
  41. package/dist/src/command-line/generate/completion.d.ts +1 -0
  42. package/dist/src/command-line/generate/completion.js +9 -0
  43. package/dist/src/command-line/graph/completion.d.ts +1 -0
  44. package/dist/src/command-line/graph/completion.js +13 -0
  45. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +14 -18
  46. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +1 -0
  47. package/dist/src/command-line/init/implementation/utils.d.ts +7 -1
  48. package/dist/src/command-line/init/implementation/utils.js +51 -14
  49. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +22 -0
  50. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +100 -0
  51. package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
  52. package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
  53. package/dist/src/command-line/migrate/agentic/definitions.d.ts +6 -0
  54. package/dist/src/command-line/migrate/agentic/definitions.js +98 -0
  55. package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
  56. package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
  57. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +46 -0
  58. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +87 -0
  59. package/dist/src/command-line/migrate/agentic/handoff.d.ts +63 -0
  60. package/dist/src/command-line/migrate/agentic/handoff.js +183 -0
  61. package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
  62. package/dist/src/command-line/migrate/agentic/inception.js +15 -0
  63. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +22 -0
  64. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +50 -0
  65. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +51 -0
  66. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +73 -0
  67. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +44 -0
  68. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +60 -0
  69. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +21 -0
  70. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +29 -0
  71. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +9 -0
  72. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +87 -0
  73. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +46 -0
  74. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +88 -0
  75. package/dist/src/command-line/migrate/agentic/run-step.d.ts +51 -0
  76. package/dist/src/command-line/migrate/agentic/run-step.js +121 -0
  77. package/dist/src/command-line/migrate/agentic/runner.d.ts +33 -0
  78. package/dist/src/command-line/migrate/agentic/runner.js +439 -0
  79. package/dist/src/command-line/migrate/agentic/select.d.ts +14 -0
  80. package/dist/src/command-line/migrate/agentic/select.js +150 -0
  81. package/dist/src/command-line/migrate/agentic/types.d.ts +102 -0
  82. package/dist/src/command-line/migrate/agentic/types.js +2 -0
  83. package/dist/src/command-line/migrate/command-object.d.ts +1 -0
  84. package/dist/src/command-line/migrate/command-object.js +32 -7
  85. package/dist/src/command-line/migrate/migrate-commits.d.ts +50 -0
  86. package/dist/src/command-line/migrate/migrate-commits.js +102 -0
  87. package/dist/src/command-line/migrate/migrate-output.d.ts +121 -0
  88. package/dist/src/command-line/migrate/migrate-output.js +241 -0
  89. package/dist/src/command-line/migrate/migrate.d.ts +122 -12
  90. package/dist/src/command-line/migrate/migrate.js +1033 -217
  91. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  92. package/dist/src/command-line/migrate/migration-shape.js +13 -0
  93. package/dist/src/command-line/migrate/multi-major.d.ts +30 -0
  94. package/dist/src/command-line/migrate/multi-major.js +185 -0
  95. package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
  96. package/dist/src/command-line/migrate/prompt-files.js +141 -0
  97. package/dist/src/command-line/migrate/run-migration-process.js +20 -6
  98. package/dist/src/command-line/migrate/safe-prompt.d.ts +28 -0
  99. package/dist/src/command-line/migrate/safe-prompt.js +49 -0
  100. package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
  101. package/dist/src/command-line/migrate/update-filters.js +44 -0
  102. package/dist/src/command-line/migrate/version-utils.d.ts +6 -0
  103. package/dist/src/command-line/migrate/version-utils.js +59 -0
  104. package/dist/src/command-line/nx-commands.js +9 -0
  105. package/dist/src/command-line/release/config/config.d.ts +3 -6
  106. package/dist/src/command-line/release/config/config.js +77 -45
  107. package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  108. package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
  109. package/dist/src/command-line/release/utils/release-graph.js +2 -3
  110. package/dist/src/command-line/release/utils/repository-git-tags.js +1 -1
  111. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +7 -19
  112. package/dist/src/command-line/release/version/resolve-current-version.js +1 -1
  113. package/dist/src/command-line/release/version/version-actions.js +3 -7
  114. package/dist/src/command-line/report/report.js +2 -2
  115. package/dist/src/command-line/run/completion.d.ts +1 -0
  116. package/dist/src/command-line/run/completion.js +7 -0
  117. package/dist/src/command-line/run-many/completion.d.ts +1 -0
  118. package/dist/src/command-line/run-many/completion.js +13 -0
  119. package/dist/src/command-line/show/completion.d.ts +1 -0
  120. package/dist/src/command-line/show/completion.js +27 -0
  121. package/dist/src/command-line/show/show-target/info.d.ts +1 -0
  122. package/dist/src/command-line/show/show-target/info.js +100 -19
  123. package/dist/src/command-line/watch/command-object.js +24 -4
  124. package/dist/src/command-line/watch/completion.d.ts +1 -0
  125. package/dist/src/command-line/watch/completion.js +10 -0
  126. package/dist/src/command-line/watch/watch.d.ts +7 -0
  127. package/dist/src/command-line/watch/watch.js +1 -1
  128. package/dist/src/config/misc-interfaces.d.ts +25 -2
  129. package/dist/src/config/nx-json.d.ts +43 -56
  130. package/dist/src/config/schema-utils.d.ts +21 -0
  131. package/dist/src/config/schema-utils.js +92 -18
  132. package/dist/src/config/task-graph.d.ts +4 -107
  133. package/dist/src/core/graph/main.js +1 -1
  134. package/dist/src/core/graph/styles.css +2 -3
  135. package/dist/src/core/graph/styles.js +1 -1
  136. package/dist/src/daemon/client/client.d.ts +1 -1
  137. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +1 -1
  138. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +1 -1
  139. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +9 -0
  140. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +76 -0
  141. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +45 -11
  142. package/dist/src/daemon/server/server.js +4 -43
  143. package/dist/src/daemon/server/start.d.ts +1 -1
  144. package/dist/src/daemon/server/start.js +2 -0
  145. package/dist/src/devkit-exports.d.ts +2 -2
  146. package/dist/src/devkit-internals.d.ts +5 -1
  147. package/dist/src/devkit-internals.js +17 -1
  148. package/dist/src/executors/run-commands/running-tasks.d.ts +7 -0
  149. package/dist/src/executors/run-commands/running-tasks.js +178 -105
  150. package/dist/src/executors/run-script/run-script.impl.js +3 -10
  151. package/dist/src/executors/utils/convert-nx-executor.js +1 -1
  152. package/dist/src/hasher/hash-plan-inspector.d.ts +1 -1
  153. package/dist/src/hasher/task-hasher.js +6 -4
  154. package/dist/src/index.d.ts +1 -1
  155. package/dist/src/index.js +0 -3
  156. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +6 -2
  157. package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
  158. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +20 -4
  159. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
  160. package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
  161. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
  162. package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
  163. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
  164. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
  165. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
  166. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
  167. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
  168. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
  169. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
  170. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.d.ts +35 -0
  171. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.js +139 -0
  172. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.md +66 -0
  173. package/dist/src/native/index.d.ts +79 -2
  174. package/dist/src/native/native-bindings.js +3 -0
  175. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  176. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  177. package/dist/src/plugins/js/lock-file/npm-parser.js +37 -19
  178. package/dist/src/plugins/js/lock-file/pnpm-parser.js +51 -4
  179. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +12 -4
  180. package/dist/src/plugins/js/utils/packages.js +1 -1
  181. package/dist/src/plugins/js/utils/register.d.ts +103 -14
  182. package/dist/src/plugins/js/utils/register.js +434 -39
  183. package/dist/src/plugins/js/utils/typescript.d.ts +7 -0
  184. package/dist/src/plugins/js/utils/typescript.js +39 -0
  185. package/dist/src/plugins/package-json/create-nodes.d.ts +3 -2
  186. package/dist/src/plugins/package-json/create-nodes.js +7 -5
  187. package/dist/src/project-graph/affected/locators/project-glob-changes.js +2 -1
  188. package/dist/src/project-graph/build-project-graph.d.ts +5 -0
  189. package/dist/src/project-graph/build-project-graph.js +6 -2
  190. package/dist/src/project-graph/file-map-utils.d.ts +5 -0
  191. package/dist/src/project-graph/file-map-utils.js +10 -1
  192. package/dist/src/project-graph/plugins/get-plugins.d.ts +7 -2
  193. package/dist/src/project-graph/plugins/get-plugins.js +8 -5
  194. package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
  195. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +2 -0
  196. package/dist/src/project-graph/plugins/resolve-plugin.d.ts +7 -4
  197. package/dist/src/project-graph/plugins/resolve-plugin.js +152 -33
  198. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +4 -2
  199. package/dist/src/project-graph/plugins/transpiler.d.ts +12 -0
  200. package/dist/src/project-graph/plugins/transpiler.js +37 -0
  201. package/dist/src/project-graph/plugins/utils.js +13 -7
  202. package/dist/src/project-graph/project-graph.js +1 -1
  203. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +95 -4
  204. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +515 -68
  205. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +13 -5
  206. package/dist/src/project-graph/utils/project-configuration-utils.js +14 -6
  207. package/dist/src/project-graph/utils/retrieve-workspace-files.js +1 -1
  208. package/dist/src/tasks-runner/create-task-graph.d.ts +4 -4
  209. package/dist/src/tasks-runner/create-task-graph.js +1 -1
  210. package/dist/src/tasks-runner/default-tasks-runner.d.ts +0 -2
  211. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  212. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -6
  213. package/dist/src/tasks-runner/init-tasks-runner.d.ts +0 -15
  214. package/dist/src/tasks-runner/init-tasks-runner.js +0 -63
  215. package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
  216. package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
  217. package/dist/src/tasks-runner/life-cycle.d.ts +7 -8
  218. package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +6 -6
  219. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
  220. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
  221. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +11 -2
  222. package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
  223. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  224. package/dist/src/tasks-runner/run-command.js +8 -11
  225. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
  226. package/dist/src/tasks-runner/running-tasks/batch-process.js +3 -5
  227. package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
  228. package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -7
  229. package/dist/src/tasks-runner/task-env.d.ts +1 -1
  230. package/dist/src/tasks-runner/task-env.js +6 -1
  231. package/dist/src/tasks-runner/task-orchestrator.d.ts +11 -1
  232. package/dist/src/tasks-runner/task-orchestrator.js +112 -38
  233. package/dist/src/tasks-runner/tasks-schedule.js +3 -3
  234. package/dist/src/tasks-runner/utils.d.ts +7 -8
  235. package/dist/src/tasks-runner/utils.js +23 -27
  236. package/dist/src/utils/child-process.js +2 -2
  237. package/dist/src/utils/compile-cache.d.ts +24 -0
  238. package/dist/src/utils/compile-cache.js +49 -0
  239. package/dist/src/utils/enable-compile-cache.d.ts +1 -0
  240. package/dist/src/utils/enable-compile-cache.js +7 -0
  241. package/dist/src/utils/fileutils.d.ts +0 -8
  242. package/dist/src/utils/fileutils.js +0 -40
  243. package/dist/src/utils/git-utils.d.ts +14 -0
  244. package/dist/src/utils/git-utils.js +73 -0
  245. package/dist/src/utils/handle-import.d.ts +4 -1
  246. package/dist/src/utils/handle-import.js +56 -2
  247. package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
  248. package/dist/src/utils/has-nx-js-plugin.js +24 -0
  249. package/dist/src/utils/installed-nx-version.d.ts +14 -4
  250. package/dist/src/utils/installed-nx-version.js +54 -7
  251. package/dist/src/utils/logger.d.ts +12 -1
  252. package/dist/src/utils/logger.js +57 -36
  253. package/dist/src/utils/nx-key.d.ts +0 -1
  254. package/dist/src/utils/nx-key.js +20 -23
  255. package/dist/src/utils/nx-package-group.d.ts +8 -0
  256. package/dist/src/utils/nx-package-group.js +15 -0
  257. package/dist/src/utils/output.d.ts +3 -2
  258. package/dist/src/utils/output.js +29 -28
  259. package/dist/src/utils/package-json.d.ts +14 -1
  260. package/dist/src/utils/package-json.js +20 -21
  261. package/dist/src/utils/perf-logging.js +3 -1
  262. package/dist/src/utils/plugin-cache-utils.d.ts +13 -4
  263. package/dist/src/utils/plugin-cache-utils.js +23 -13
  264. package/dist/src/utils/plugins/local-plugins.d.ts +18 -0
  265. package/dist/src/utils/plugins/local-plugins.js +30 -0
  266. package/dist/src/utils/tar.d.ts +8 -0
  267. package/dist/src/utils/tar.js +44 -0
  268. package/migrations.json +16 -0
  269. package/package.json +27 -27
  270. package/schemas/nx-schema.json +114 -80
  271. package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +0 -7
  272. package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +0 -155
  273. package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +0 -16
  274. package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +0 -121
@@ -30,13 +30,18 @@ async function initLocal(workspace) {
30
30
  handleAngularCLIFallbacks(workspace);
31
31
  return;
32
32
  }
33
- // Ensure NxConsole is installed if the user has it configured.
34
- try {
35
- await ensureNxConsoleInstalledViaDaemon();
33
+ // Skip per-TAB shell completion calls those must not spawn the daemon.
34
+ if (!process.env.NX_COMPLETE) {
35
+ try {
36
+ await ensureNxConsoleInstalledViaDaemon();
37
+ }
38
+ catch { }
36
39
  }
37
- catch { }
38
40
  const command = process.argv[2];
39
- if (command === 'run' || command === 'g' || command === 'generate') {
41
+ if (command === 'completion' ||
42
+ command === 'run' ||
43
+ command === 'g' ||
44
+ command === 'generate') {
40
45
  nx_commands_1.commandsObject.parse(process.argv.slice(2));
41
46
  }
42
47
  else if (isKnownCommand(command)) {
@@ -110,14 +115,7 @@ function isKnownCommand(command) {
110
115
  }
111
116
  function shouldDelegateToAngularCLI() {
112
117
  const command = process.argv[2];
113
- const commands = [
114
- 'analytics',
115
- 'cache',
116
- 'completion',
117
- 'config',
118
- 'doc',
119
- 'update',
120
- ];
118
+ const commands = ['analytics', 'cache', 'config', 'doc', 'update'];
121
119
  return commands.indexOf(command) > -1;
122
120
  }
123
121
  async function ensureNxConsoleInstalledViaDaemon() {
@@ -169,13 +167,6 @@ function handleAngularCLIFallbacks(workspace) {
169
167
  console.log(`Running "ng update" can still be useful in some dev workflows, so we aren't planning to remove it.`);
170
168
  console.log(`If you need to use it, run "FORCE_NG_UPDATE=true ng update".`);
171
169
  }
172
- else if (process.argv[2] === 'completion') {
173
- if (!process.argv[3]) {
174
- console.log(`"ng completion" is not natively supported by Nx.
175
- Instead, you could try an Nx Editor Plugin for a visual tool to run Nx commands. If you're using VSCode, you can use the Nx Console plugin, or if you're using WebStorm, you could use one of the available community plugins.
176
- For more information, see https://nx.dev/getting-started/editor-setup`);
177
- }
178
- }
179
170
  else if (process.argv[2] === 'cache') {
180
171
  console.log(`"ng cache" is not natively supported by Nx.
181
172
  To clear the cache, you can delete the ".angular/cache" directory (or the directory configured by "cli.cache.path" in the "nx.json" file).
package/dist/bin/nx.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
+ import '../src/utils/enable-compile-cache';
2
3
  import '../src/utils/perf-logging';
package/dist/bin/nx.js CHANGED
@@ -8,6 +8,8 @@ if (process.env.FORCE_COLOR === '0') {
8
8
  process.env.NO_COLOR = '1';
9
9
  delete process.env.FORCE_COLOR;
10
10
  }
11
+ // Must be the first import — see enable-compile-cache.ts.
12
+ require("../src/utils/enable-compile-cache");
11
13
  const find_workspace_root_1 = require("../src/utils/find-workspace-root");
12
14
  const pc = tslib_1.__importStar(require("picocolors"));
13
15
  const output_1 = require("../src/utils/output");
@@ -27,10 +29,32 @@ require("../src/utils/perf-logging");
27
29
  const isTsExt = (0, path_1.extname)(__filename).endsWith('.ts');
28
30
  const pathToPkgJson = isTsExt ? '../package.json' : '../../package.json';
29
31
  async function main() {
32
+ // Tab-completion fast path. Bare env-var read so nothing runs before
33
+ // the try/catch — a throw here would splice a stack trace into the
34
+ // user's command line.
35
+ if (process.env.NX_COMPLETE) {
36
+ try {
37
+ perf_hooks_1.performance.mark('init-local');
38
+ const { tryValueCompletion } = await import('nx/src/command-line/completion/value-completions');
39
+ if (tryValueCompletion())
40
+ return;
41
+ const { tryCommandSurfaceCompletion } = await import('nx/src/command-line/completion/command-completions');
42
+ tryCommandSurfaceCompletion();
43
+ }
44
+ catch (e) {
45
+ // Swallow: a broken completion must produce no suggestions, not a
46
+ // stack trace. NX_VERBOSE_LOGGING surfaces the cause to stderr.
47
+ if (process.env.NX_VERBOSE_LOGGING) {
48
+ console.error(e);
49
+ }
50
+ }
51
+ return;
52
+ }
30
53
  if (process.argv[2] !== 'report' &&
31
54
  process.argv[2] !== '--version' &&
32
55
  process.argv[2] !== '--help' &&
33
- process.argv[2] !== 'reset') {
56
+ process.argv[2] !== 'reset' &&
57
+ process.argv[2] !== 'completion') {
34
58
  const { assertSupportedPlatform } = await import('../src/native/assert-supported-platform.js');
35
59
  assertSupportedPlatform();
36
60
  }
@@ -52,6 +76,8 @@ async function main() {
52
76
  process.argv[2] === '_migrate' ||
53
77
  process.argv[2] === 'init' ||
54
78
  process.argv[2] === 'configure-ai-agents' ||
79
+ process.argv[2] === 'mcp' ||
80
+ process.argv[2] === 'completion' ||
55
81
  (process.argv[2] === 'graph' && !workspace)) {
56
82
  process.env.NX_DAEMON = 'false';
57
83
  (await import('nx/src/command-line/nx-commands')).commandsObject.argv;
@@ -210,7 +236,7 @@ function handleMissingLocalInstallation(detectedWorkspaceRoot) {
210
236
  * Warns if out of date by 1 major version or more.
211
237
  */
212
238
  function warnIfUsingOutdatedGlobalInstall(globalNxVersion, localNxVersion) {
213
- // Never display this warning if Nx is already running via Nx
239
+ // Skip when Nx is recursively invoking itself.
214
240
  if (process.env.NX_CLI_SET) {
215
241
  return;
216
242
  }
@@ -8,6 +8,7 @@ const cache_directory_1 = require("../src/utils/cache-directory");
8
8
  const path_1 = require("path");
9
9
  const fileutils_1 = require("../src/utils/fileutils");
10
10
  const plugin_cache_utils_1 = require("../src/utils/plugin-cache-utils");
11
+ const package_manager_1 = require("../src/utils/package-manager");
11
12
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'package-json.hash');
12
13
  let packageJsonPluginCache = null;
13
14
  function readPackageJsonConfigurationCache() {
@@ -16,7 +17,7 @@ function readPackageJsonConfigurationCache() {
16
17
  }
17
18
  function writeCache() {
18
19
  if (packageJsonPluginCache) {
19
- packageJsonPluginCache.writeToDisk(cachePath);
20
+ packageJsonPluginCache.writeToDisk();
20
21
  }
21
22
  }
22
23
  const plugin = {
@@ -27,7 +28,8 @@ const plugin = {
27
28
  const cache = readPackageJsonConfigurationCache();
28
29
  const patterns = (0, package_json_1.buildPackageJsonPatterns)(context.workspaceRoot, (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, f)));
29
30
  const isInPackageJsonWorkspaces = (0, package_json_1.buildPackageJsonWorkspacesMatcher)(patterns);
30
- const result = (0, plugins_1.createNodesFromFiles)((packageJsonPath) => (0, package_json_1.createNodeFromPackageJson)(packageJsonPath, workspace_root_1.workspaceRoot, cache, isInPackageJsonWorkspaces(packageJsonPath)), configFiles, options, context);
31
+ const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)((0, package_manager_1.detectPackageManager)(context.workspaceRoot), context.workspaceRoot);
32
+ const result = (0, plugins_1.createNodesFromFiles)((packageJsonPath) => (0, package_json_1.createNodeFromPackageJson)(packageJsonPath, workspace_root_1.workspaceRoot, cache, isInPackageJsonWorkspaces(packageJsonPath), packageManagerCommand), configFiles, options, context);
31
33
  writeCache();
32
34
  return result;
33
35
  },
@@ -3,7 +3,7 @@ import { FileBuffer } from '@angular-devkit/core/src/virtual-fs/host/interface';
3
3
  import { Observable } from 'rxjs';
4
4
  import type { GenerateOptions } from '../command-line/generate/generate';
5
5
  import { ProjectConfiguration } from '../config/workspace-json-project-json';
6
- import { Tree } from '../generators/tree';
6
+ import { FileChange, Tree } from '../generators/tree';
7
7
  import type { ProjectGraph } from '../config/project-graph';
8
8
  import { ExecutorContext, GeneratorCallback } from '../config/misc-interfaces';
9
9
  export declare function createBuilderContext(builderInfo: {
@@ -59,6 +59,7 @@ export declare class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
59
59
  export declare function generate(root: string, opts: GenerateOptions, projects: Record<string, ProjectConfiguration>, verbose: boolean, projectGraph: ProjectGraph): Promise<number>;
60
60
  export declare function runMigration(root: string, packageName: string, migrationName: string, projects: Record<string, ProjectConfiguration>, isVerbose: boolean, projectGraph: ProjectGraph): Promise<{
61
61
  loggingQueue: string[];
62
+ changes: FileChange[];
62
63
  madeChanges: boolean;
63
64
  }>;
64
65
  /**
@@ -239,20 +239,38 @@ async function createRecorder(host, record, logger) {
239
239
  }
240
240
  else if (event.kind === 'update') {
241
241
  record.loggingQueue.push(core_1.tags.oneLine `${pc.white('UPDATE')} ${eventPath}`);
242
+ record.changes?.push(emptyFileChange('UPDATE', eventPath));
242
243
  }
243
244
  else if (event.kind === 'create') {
244
245
  record.loggingQueue.push(core_1.tags.oneLine `${pc.green('CREATE')} ${eventPath}`);
246
+ record.changes?.push(emptyFileChange('CREATE', eventPath));
245
247
  }
246
248
  else if (event.kind === 'delete') {
247
249
  record.loggingQueue.push(`${pc.yellow('DELETE')} ${eventPath}`);
250
+ record.changes?.push({ type: 'DELETE', path: eventPath, content: null });
248
251
  }
249
252
  else if (event.kind === 'rename') {
250
253
  record.loggingQueue.push(`${pc.blue('RENAME')} ${eventPath} => ${event.to}`);
254
+ // Surface as DELETE source + CREATE destination so downstream consumers
255
+ // (e.g. the agentic validation prompt's `<files_changed>` block) see
256
+ // both endpoints.
257
+ const toPath = event.to.startsWith('/') ? event.to.slice(1) : event.to;
258
+ record.changes?.push({ type: 'DELETE', path: eventPath, content: null });
259
+ record.changes?.push(emptyFileChange('CREATE', toPath));
251
260
  }
252
261
  };
253
262
  }
263
+ // Empty content for non-DELETE FileChange entries: the Angular workflow has
264
+ // already flushed bytes to disk, and our only downstream consumer (agentic
265
+ // prompt builders) reads `path` + `type` only. `null` is reserved for DELETE.
266
+ function emptyFileChange(type, path) {
267
+ return { type, path, content: Buffer.alloc(0) };
268
+ }
254
269
  async function runSchematic(host, root, workflow, logger, opts, schematic, printDryRunMessage = true, recorder = null) {
255
- const record = { loggingQueue: [], error: false };
270
+ const record = {
271
+ loggingQueue: [],
272
+ error: false,
273
+ };
256
274
  workflow.reporter.subscribe(recorder || (await createRecorder(host, record, logger)));
257
275
  try {
258
276
  await workflow
@@ -643,7 +661,11 @@ async function runMigration(root, packageName, migrationName, projects, isVerbos
643
661
  const fsHost = new NxScopeHostUsedForWrappedSchematics(root, new tree_1.FsTree(root, isVerbose, `ng-cli migration: ${packageName}:${migrationName}`), projectGraph);
644
662
  const workflow = createWorkflow(fsHost, root, {}, projects);
645
663
  const collection = resolveMigrationsCollection(packageName);
646
- const record = { loggingQueue: [], error: false };
664
+ const record = {
665
+ loggingQueue: [],
666
+ changes: [],
667
+ error: false,
668
+ };
647
669
  workflow.reporter.subscribe(await createRecorder(fsHost, record, logger));
648
670
  await workflow
649
671
  .execute({
@@ -656,6 +678,7 @@ async function runMigration(root, packageName, migrationName, projects, isVerbos
656
678
  .toPromise();
657
679
  return {
658
680
  loggingQueue: record.loggingQueue,
681
+ changes: record.changes,
659
682
  madeChanges: record.loggingQueue.length > 0,
660
683
  };
661
684
  }
@@ -125,14 +125,31 @@ function cleanupOldCaches(currentCommitHash) {
125
125
  function getAiConfigRepoPath() {
126
126
  // 1. Get latest commit hash (first 10 chars)
127
127
  const commitHash = getLatestCommitHash();
128
- // 2. Check if cached version exists
128
+ // 2. Reuse cached version if it still has content (macOS may have
129
+ // swept its files but left the directory tree).
129
130
  const cachedPath = (0, path_1.join)(CACHE_DIR, commitHash);
130
- if ((0, fs_1.existsSync)(cachedPath)) {
131
+ if (hasRootFile(cachedPath)) {
131
132
  return cachedPath;
132
133
  }
133
- // 3. Clone fresh
134
+ // 3. Wipe any empty skeleton, then clone fresh
135
+ if ((0, fs_1.existsSync)(cachedPath)) {
136
+ (0, fs_1.rmSync)(cachedPath, { recursive: true, force: true });
137
+ }
134
138
  cloneRepo(cachedPath);
135
139
  // 4. Clean up old cached versions
136
140
  cleanupOldCaches(commitHash);
137
141
  return cachedPath;
138
142
  }
143
+ /**
144
+ * The repo always has at least one regular file at its root (e.g. README).
145
+ * If everything at the root is a directory, the cache was swept by macOS
146
+ * tmp cleanup and we should re-clone.
147
+ */
148
+ function hasRootFile(dir) {
149
+ try {
150
+ return (0, fs_1.readdirSync)(dir, { withFileTypes: true }).some((e) => e.isFile());
151
+ }
152
+ catch {
153
+ return false;
154
+ }
155
+ }
@@ -16,6 +16,7 @@ const native_1 = require("../native");
16
16
  const package_manager_1 = require("../utils/package-manager");
17
17
  const semver_1 = require("semver");
18
18
  const os = tslib_1.__importStar(require("os"));
19
+ const crypto_1 = require("crypto");
19
20
  const machine_id_cache_1 = require("../utils/machine-id-cache");
20
21
  const is_ci_1 = require("../utils/is-ci");
21
22
  const analytics_prompt_1 = require("../utils/analytics-prompt");
@@ -56,7 +57,7 @@ async function startAnalytics() {
56
57
  return;
57
58
  }
58
59
  const isNxCloud = !!(nxJson?.nxCloudId ?? nxJson?.nxCloudAccessToken);
59
- const userId = await (0, machine_id_cache_1.getCurrentMachineId)();
60
+ const userId = await getTelemetryUserId(workspaceId);
60
61
  const packageManagerInfo = getPackageManagerInfo();
61
62
  const nodeVersion = (0, semver_1.parse)(process.version);
62
63
  const nodeVersionString = nodeVersion
@@ -225,3 +226,11 @@ function isAnalyticsEnabled() {
225
226
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
226
227
  return nxJson?.analytics === true;
227
228
  }
229
+ // Mix workspace id in: shared Docker images (Gitpod, Cypress, etc.) bake
230
+ // in /etc/machine-id, so machine-id alone collapses many users into one.
231
+ async function getTelemetryUserId(workspaceId) {
232
+ const machineId = await (0, machine_id_cache_1.getCurrentMachineId)();
233
+ return (0, crypto_1.createHash)('sha256')
234
+ .update(`${machineId}|${workspaceId}`)
235
+ .digest('hex');
236
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const metadata_1 = require("../completion/metadata");
4
+ const nx_package_group_1 = require("../../utils/nx-package-group");
5
+ // Same list `nx report` uses. Filter to first-party plugins and sort.
6
+ const FIRST_PARTY_PLUGINS = (0, nx_package_group_1.readNxPackageGroup)()
7
+ .filter((p) => p.startsWith('@nx/'))
8
+ .sort();
9
+ (0, metadata_1.registerCompletion)('add', {
10
+ positionals: [
11
+ {
12
+ complete: (current) => FIRST_PARTY_PLUGINS.filter((p) => p.startsWith(current)),
13
+ },
14
+ ],
15
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const metadata_1 = require("../completion/metadata");
4
+ const completion_providers_1 = require("../completion/completion-providers");
5
+ // Aliases are written out; the fast path runs before yargs can resolve them.
6
+ (0, metadata_1.registerCompletion)('affected', {
7
+ flags: {
8
+ projects: completion_providers_1.getProjectNameCompletions,
9
+ p: completion_providers_1.getProjectNameCompletions,
10
+ exclude: completion_providers_1.getProjectNameCompletions,
11
+ targets: completion_providers_1.getTargetNameCompletions,
12
+ target: completion_providers_1.getTargetNameCompletions,
13
+ t: completion_providers_1.getTargetNameCompletions,
14
+ },
15
+ });
@@ -0,0 +1,6 @@
1
+ export interface ParsedCompletionArgs {
2
+ tokens: string[];
3
+ current: string;
4
+ previousToken: string;
5
+ }
6
+ export declare function parseCompletionArgs(argv?: readonly string[]): ParsedCompletionArgs | null;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // Wrappers must invoke nx with argv: [node, nx-bin, ...tokens, currentPartial].
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseCompletionArgs = parseCompletionArgs;
5
+ function parseCompletionArgs(argv = process.argv) {
6
+ const tail = argv.slice(2);
7
+ // Wrappers usually prepend the literal 'nx' (from COMP_WORDS /
8
+ // commandline -cop / etc.). They sometimes don't — most notably the
9
+ // `.nx/installation` wrapper invokes the real bin directly without the
10
+ // 'nx' token, and manual invocations like `NX_COMPLETE=fish nx show
11
+ // target in` for dev testing skip it too. Strip when present, otherwise
12
+ // take the args as-is.
13
+ const tokens = tail[0] === 'nx' ? tail.slice(1) : tail;
14
+ if (tokens.length === 0)
15
+ return null;
16
+ const current = tokens[tokens.length - 1] ?? '';
17
+ const previousToken = tokens.length >= 2 ? tokens[tokens.length - 2] : '';
18
+ return { tokens, current, previousToken };
19
+ }
@@ -0,0 +1,19 @@
1
+ /** Slow-path entry point. Returns true if anything was emitted. */
2
+ export declare function tryCommandSurfaceCompletion(argv?: readonly string[]): boolean;
3
+ /** Top-level command names. Unions yargs handlers with the completion
4
+ * registry's single-token paths (infix targets). */
5
+ export declare function getTopLevelCommands(current: string, withDesc: boolean): string[] | null;
6
+ /**
7
+ * Enumerates subcommands + options of a matched top-level command. Returns
8
+ * null when no top-level command name is matched in `args`.
9
+ */
10
+ export declare function getCommandCompletions(current: string, args: string[]): string[] | null;
11
+ /** value\tdescription separator. TAB because completion values can contain
12
+ * colons (`my-app:build`); descriptions get TABs collapsed. */
13
+ export declare const DESC_SEPARATOR = "\t";
14
+ /** Strip the y18n marker yargs prepends to its built-in --help / --version
15
+ * descriptions, and collapse stray TABs so they can't forge the
16
+ * value/description separator. */
17
+ export declare function formatDescription(raw: string | undefined): string;
18
+ /** zsh (compadd -d) and fish (complete -a) parse `value\tdescription`. */
19
+ export declare function shellRendersDescriptions(): boolean;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ // Slow-path completion: command/subcommand/flag names. Runs after
3
+ // tryValueCompletion has nothing to offer.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.DESC_SEPARATOR = void 0;
6
+ exports.tryCommandSurfaceCompletion = tryCommandSurfaceCompletion;
7
+ exports.getTopLevelCommands = getTopLevelCommands;
8
+ exports.getCommandCompletions = getCommandCompletions;
9
+ exports.formatDescription = formatDescription;
10
+ exports.shellRendersDescriptions = shellRendersDescriptions;
11
+ const trigger_1 = require("./trigger");
12
+ const argv_layout_1 = require("./argv-layout");
13
+ const metadata_1 = require("./metadata");
14
+ const command_handlers_1 = require("./command-handlers");
15
+ /** Slow-path entry point. Returns true if anything was emitted. */
16
+ function tryCommandSurfaceCompletion(argv = process.argv) {
17
+ const parsed = (0, argv_layout_1.parseCompletionArgs)(argv);
18
+ if (parsed === null)
19
+ return false;
20
+ const matched = getCommandCompletions(parsed.current, parsed.tokens);
21
+ const completions = matched !== null
22
+ ? matched
23
+ : getTopLevelCommands(parsed.current, shellRendersDescriptions());
24
+ if (completions === null || completions.length === 0)
25
+ return false;
26
+ for (const line of completions) {
27
+ console.log(line);
28
+ }
29
+ return true;
30
+ }
31
+ /** Top-level command names. Unions yargs handlers with the completion
32
+ * registry's single-token paths (infix targets). */
33
+ function getTopLevelCommands(current, withDesc) {
34
+ const handlers = (0, command_handlers_1.getNxCommandHandlers)();
35
+ const seen = new Set();
36
+ const completions = [];
37
+ for (const name of Object.keys(handlers)) {
38
+ if (name === '$0' || name.startsWith('_'))
39
+ continue;
40
+ if (current && !name.startsWith(current))
41
+ continue;
42
+ const handler = handlers[name];
43
+ if (handler?.description === false)
44
+ continue; // hidden
45
+ seen.add(name);
46
+ const desc = withDesc ? formatDescription(handler?.description) : '';
47
+ completions.push(desc ? `${name}${exports.DESC_SEPARATOR}${desc}` : name);
48
+ }
49
+ // Infix targets + any other top-level completion-only paths.
50
+ for (const name of (0, metadata_1.getRegisteredTopLevelPaths)()) {
51
+ if (seen.has(name))
52
+ continue;
53
+ if (current && !name.startsWith(current))
54
+ continue;
55
+ seen.add(name);
56
+ completions.push(name);
57
+ }
58
+ return completions;
59
+ }
60
+ /**
61
+ * Enumerates subcommands + options of a matched top-level command. Returns
62
+ * null when no top-level command name is matched in `args`.
63
+ */
64
+ function getCommandCompletions(current, args) {
65
+ const handlers = (0, command_handlers_1.getNxCommandHandlers)();
66
+ const cmdName = args.find((a) => handlers[a]);
67
+ if (!cmdName) {
68
+ return null;
69
+ }
70
+ const handler = handlers[cmdName];
71
+ // Once we recognize a top-level command in `args`, we own the slot —
72
+ // return [] (not null) for the "found a command but can't enumerate its
73
+ // surface" case so the caller doesn't fall back to top-level commands
74
+ // (which would mis-offer e.g. `exec` for `nx g c ex`).
75
+ if (typeof handler.builder !== 'function') {
76
+ return [];
77
+ }
78
+ const intro = (0, command_handlers_1.introspectBuilder)(handler.builder);
79
+ if (!intro)
80
+ return [];
81
+ const completions = [];
82
+ const isFlagPrefix = current.startsWith('-');
83
+ const withDesc = shellRendersDescriptions();
84
+ if (!isFlagPrefix) {
85
+ for (const [name, desc] of intro.subcommands) {
86
+ const formatted = withDesc ? formatDescription(desc) : '';
87
+ completions.push(formatted ? `${name}${exports.DESC_SEPARATOR}${formatted}` : name);
88
+ }
89
+ }
90
+ for (const [name, desc] of intro.options) {
91
+ const formatted = withDesc ? formatDescription(desc) : '';
92
+ completions.push(formatted ? `--${name}${exports.DESC_SEPARATOR}${formatted}` : `--${name}`);
93
+ }
94
+ if (!current) {
95
+ return completions;
96
+ }
97
+ const flagName = current.replace(/^-+/, '');
98
+ return completions.filter((c) => {
99
+ if (isFlagPrefix) {
100
+ return c.startsWith(`--${flagName}`);
101
+ }
102
+ return c.startsWith(current);
103
+ });
104
+ }
105
+ /** value\tdescription separator. TAB because completion values can contain
106
+ * colons (`my-app:build`); descriptions get TABs collapsed. */
107
+ exports.DESC_SEPARATOR = '\t';
108
+ /** Strip the y18n marker yargs prepends to its built-in --help / --version
109
+ * descriptions, and collapse stray TABs so they can't forge the
110
+ * value/description separator. */
111
+ function formatDescription(raw) {
112
+ if (!raw)
113
+ return '';
114
+ return raw.replace(/^__yargsString__:/, '').replace(/\t/g, ' ');
115
+ }
116
+ /** zsh (compadd -d) and fish (complete -a) parse `value\tdescription`. */
117
+ function shellRendersDescriptions() {
118
+ const shell = (0, trigger_1.getCompletionShell)();
119
+ return shell === 'zsh' || shell === 'fish';
120
+ }
@@ -0,0 +1,30 @@
1
+ /** A single entry from yargs' `getCommandHandlers()`. */
2
+ export interface CommandHandler {
3
+ description?: string | false;
4
+ builder?: (yargs: any) => any;
5
+ }
6
+ export type CommandHandlers = Record<string, CommandHandler>;
7
+ /**
8
+ * Reach into the yargs commandsObject to enumerate registered command
9
+ * handlers. Lazy-required: nx-commands pulls in the full command tree
10
+ * and is only needed on the slow path.
11
+ *
12
+ * Yargs only keys handlers by canonical name. We mirror each alias to its
13
+ * canonical handler reference so lookups like `handlers['g']` resolve to
14
+ * the same entry as `handlers['generate']`.
15
+ */
16
+ export declare function getNxCommandHandlers(): CommandHandlers;
17
+ /** Subcommand name → description, visible-option name → description, and
18
+ * canonical option name → its yargs-declared aliases (e.g. projects → [p]). */
19
+ export interface BuilderIntrospection {
20
+ subcommands: Map<string, string | undefined>;
21
+ options: Map<string, string | undefined>;
22
+ aliases: Map<string, string[]>;
23
+ }
24
+ /**
25
+ * Run a yargs builder against a throwaway instance and return its declared
26
+ * subcommands, visible options, and option-alias groups. Returns null if
27
+ * the builder throws. Does NOT call `.argv` — would trigger parse and the
28
+ * help-printing path we're avoiding.
29
+ */
30
+ export declare function introspectBuilder(builder: (yargs: any) => any): BuilderIntrospection | null;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNxCommandHandlers = getNxCommandHandlers;
4
+ exports.introspectBuilder = introspectBuilder;
5
+ /**
6
+ * Reach into the yargs commandsObject to enumerate registered command
7
+ * handlers. Lazy-required: nx-commands pulls in the full command tree
8
+ * and is only needed on the slow path.
9
+ *
10
+ * Yargs only keys handlers by canonical name. We mirror each alias to its
11
+ * canonical handler reference so lookups like `handlers['g']` resolve to
12
+ * the same entry as `handlers['generate']`.
13
+ */
14
+ function getNxCommandHandlers() {
15
+ const { commandsObject } = require('../nx-commands');
16
+ const internal = commandsObject.getInternalMethods();
17
+ const handlers = { ...internal.getCommandInstance().getCommandHandlers() };
18
+ for (const row of internal.getUsageInstance().getCommands()) {
19
+ // usage.getCommands() rows: [usagePattern, description, isDefault, aliases, deprecated]
20
+ const usagePattern = String(row[0] ?? '');
21
+ const aliases = Array.isArray(row[3]) ? row[3] : [];
22
+ const canonical = usagePattern.split(/\s+/)[0];
23
+ const handler = handlers[canonical];
24
+ if (!handler)
25
+ continue;
26
+ for (const alias of aliases) {
27
+ if (!handlers[alias])
28
+ handlers[alias] = handler;
29
+ }
30
+ }
31
+ return handlers;
32
+ }
33
+ /**
34
+ * Run a yargs builder against a throwaway instance and return its declared
35
+ * subcommands, visible options, and option-alias groups. Returns null if
36
+ * the builder throws. Does NOT call `.argv` — would trigger parse and the
37
+ * help-printing path we're avoiding.
38
+ */
39
+ function introspectBuilder(builder) {
40
+ const yargs = require('yargs');
41
+ const temp = yargs();
42
+ try {
43
+ builder(temp);
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ const usage = temp.getInternalMethods().getUsageInstance();
49
+ const subcommands = new Map();
50
+ for (const [usagePattern, desc] of usage.getCommands()) {
51
+ const name = String(usagePattern).split(/\s+/)[0];
52
+ if (name === '$0')
53
+ continue;
54
+ subcommands.set(name, desc);
55
+ }
56
+ const opts = temp.getOptions();
57
+ const descriptions = usage.getDescriptions();
58
+ const options = new Map();
59
+ for (const k of Object.keys(opts.key ?? {})) {
60
+ if ((opts.hiddenOptions ?? []).includes(k))
61
+ continue;
62
+ options.set(k, descriptions[k]);
63
+ }
64
+ const aliases = new Map();
65
+ for (const [canonical, list] of Object.entries(opts.alias ?? {})) {
66
+ aliases.set(canonical, list);
67
+ }
68
+ return { subcommands, options, aliases };
69
+ }
@@ -0,0 +1,10 @@
1
+ import { CommandModule } from 'yargs';
2
+ declare const SHELL_CHOICES: readonly ["bash", "zsh", "fish", "powershell"];
3
+ type Shell = (typeof SHELL_CHOICES)[number];
4
+ interface CompletionArgs {
5
+ shell?: Shell;
6
+ force?: boolean;
7
+ stdout?: boolean;
8
+ }
9
+ export declare const yargsCompletionCommand: CommandModule<{}, CompletionArgs>;
10
+ export {};