nx 23.0.0-beta.2 → 23.0.0-beta.21

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 +65 -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 +52 -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 +26 -0
  71. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +18 -0
  72. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +130 -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 +442 -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 +180 -0
  88. package/dist/src/command-line/migrate/migrate-output.js +258 -0
  89. package/dist/src/command-line/migrate/migrate.d.ts +122 -12
  90. package/dist/src/command-line/migrate/migrate.js +1036 -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 +28 -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 +15 -0
  244. package/dist/src/utils/git-utils.js +138 -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 +28 -28
  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
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.yargsCompletionCommand = void 0;
4
+ const enquirer_1 = require("enquirer");
5
+ const fs_1 = require("fs");
6
+ const os_1 = require("os");
7
+ const path_1 = require("path");
8
+ const handle_import_1 = require("../../utils/handle-import");
9
+ const SHELL_CHOICES = ['bash', 'zsh', 'fish', 'powershell'];
10
+ exports.yargsCompletionCommand = {
11
+ command: 'completion [shell]',
12
+ describe: 'Install shell completion for bash, zsh, fish, or powershell. Omit the shell to pick interactively.',
13
+ builder: (yargs) => yargs
14
+ .positional('shell', {
15
+ type: 'string',
16
+ choices: SHELL_CHOICES,
17
+ describe: 'Shell to install completion for.',
18
+ })
19
+ .option('force', {
20
+ type: 'boolean',
21
+ default: false,
22
+ describe: 'Install the completion script even if `nx` is not found on PATH.',
23
+ })
24
+ .option('stdout', {
25
+ type: 'boolean',
26
+ default: false,
27
+ describe: 'Print the completion script to stdout instead of writing to the shell rc file.',
28
+ })
29
+ .example('$0 completion bash', 'Install bash completion to ~/.bashrc')
30
+ .example('$0 completion', 'Pick shells interactively and install completion for each')
31
+ .example('$0 completion bash --stdout >> ~/.bash_profile', 'Print to stdout for a custom rc location'),
32
+ handler: async (args) => {
33
+ const scripts = await (0, handle_import_1.handleImport)('./scripts.js', __dirname);
34
+ const shells = args.shell ? [args.shell] : await pickShellsInteractively();
35
+ if (shells.length === 0) {
36
+ console.warn('nx: no shells selected — nothing installed.');
37
+ process.exit(0);
38
+ }
39
+ if (args.stdout && shells.length > 1) {
40
+ console.warn('nx: --stdout only makes sense with one shell — concatenating two wrapper scripts to stdout is never useful.');
41
+ process.exit(1);
42
+ }
43
+ const emit = args.stdout
44
+ ? scripts.printCompletionScript
45
+ : scripts.installCompletionScript;
46
+ // Fire the PATH-advisory once, before any per-shell emit.
47
+ if (!args.force)
48
+ scripts.maybeWarnNxNotOnPath();
49
+ for (const shell of shells)
50
+ emit(shell);
51
+ process.exit(0);
52
+ },
53
+ };
54
+ async function pickShellsInteractively() {
55
+ if (!process.stdin.isTTY || !process.stderr.isTTY) {
56
+ console.warn('nx: please specify a shell — `nx completion <bash|zsh|fish|powershell>`.');
57
+ process.exit(1);
58
+ }
59
+ const detected = detectAvailableShells();
60
+ const answer = (await (0, enquirer_1.prompt)({
61
+ type: 'multiselect',
62
+ name: 'shells',
63
+ message: 'Install nx completion for which shell(s)?',
64
+ choices: SHELL_CHOICES.map((name) => ({
65
+ name,
66
+ value: name,
67
+ // Pre-check shells we can detect on this machine.
68
+ enabled: detected.has(name),
69
+ })),
70
+ }));
71
+ return answer.shells ?? [];
72
+ }
73
+ /** Best-effort detect-which-shells-the-user-has. Pre-checks the multiselect.
74
+ * Signals: $SHELL basename, presence of conventional rc files, $PSModulePath
75
+ * for PowerShell. False positives are fine — the user can uncheck. */
76
+ function detectAvailableShells() {
77
+ const found = new Set();
78
+ const home = (0, os_1.homedir)();
79
+ const shellEnv = (process.env.SHELL ?? '').replace(/\\/g, '/');
80
+ const shellName = shellEnv.split('/').pop() ?? '';
81
+ if (shellName === 'bash' || (0, fs_1.existsSync)((0, path_1.join)(home, '.bashrc'))) {
82
+ found.add('bash');
83
+ }
84
+ if (shellName === 'zsh' || (0, fs_1.existsSync)((0, path_1.join)(home, '.zshrc'))) {
85
+ found.add('zsh');
86
+ }
87
+ if (shellName === 'fish' ||
88
+ (0, fs_1.existsSync)((0, path_1.join)(home, '.config', 'fish', 'config.fish'))) {
89
+ found.add('fish');
90
+ }
91
+ if (process.env.PSModulePath || process.platform === 'win32') {
92
+ found.add('powershell');
93
+ }
94
+ return found;
95
+ }
@@ -0,0 +1,21 @@
1
+ /** Project names matching `current`. */
2
+ export declare function getProjectNameCompletions(current: string): string[];
3
+ /** Projects that declare `targetName`, matching `current`. */
4
+ export declare function getProjectNamesWithTarget(current: string, targetName: string): string[];
5
+ /** Two-stage `project[:target]` — stage 1 emits `project:` (nospace), stage 2 emits `project:target`. */
6
+ export declare function completeProjectTarget(current: string): string[];
7
+ /** Generator completion. Stage 1 (`nx g <TAB>`) emits plugin names (with `:`)
8
+ * and bare generator names (for `nx g application`); stage 2 emits
9
+ * `plugin:generator`. */
10
+ export declare function completeGenerator(current: string): string[];
11
+ /** Plugin names matching `current` — installed npm plugins + workspace-local
12
+ * plugin projects, only those declaring a generator collection. */
13
+ export declare function getGeneratorPluginCompletions(current: string): string[];
14
+ /** Generator names in a single plugin, matching `current`. */
15
+ export declare function getGeneratorsForPlugin(pluginName: string, current: string): string[];
16
+ /** Unique target names across the workspace, matching `current`. */
17
+ export declare function getTargetNameCompletions(current: string): string[];
18
+ /** Target names for a single project, matching `current`. Falls back to
19
+ * workspace-wide if the project isn't in the graph — covers the
20
+ * `project:t<TAB>` case where the user is still typing the project name. */
21
+ export declare function getTargetNamesForProject(current: string, projectName: string): string[];
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjectNameCompletions = getProjectNameCompletions;
4
+ exports.getProjectNamesWithTarget = getProjectNamesWithTarget;
5
+ exports.completeProjectTarget = completeProjectTarget;
6
+ exports.completeGenerator = completeGenerator;
7
+ exports.getGeneratorPluginCompletions = getGeneratorPluginCompletions;
8
+ exports.getGeneratorsForPlugin = getGeneratorsForPlugin;
9
+ exports.getTargetNameCompletions = getTargetNameCompletions;
10
+ exports.getTargetNamesForProject = getTargetNamesForProject;
11
+ const path_1 = require("path");
12
+ const workspace_root_1 = require("../../utils/workspace-root");
13
+ const project_graph_1 = require("../../project-graph/project-graph");
14
+ const fileutils_1 = require("../../utils/fileutils");
15
+ const local_plugins_1 = require("../../utils/plugins/local-plugins");
16
+ /** Stale graphs are intentionally tolerated — do not "fix" by triggering
17
+ * a recompute. readCachedProjectGraph throws if no cache exists; we
18
+ * swallow because completion must always degrade silently. */
19
+ function getCachedProjectGraph() {
20
+ try {
21
+ return (0, project_graph_1.readCachedProjectGraph)();
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ }
27
+ /** Project names matching `current`. */
28
+ function getProjectNameCompletions(current) {
29
+ const graph = getCachedProjectGraph();
30
+ if (!graph?.nodes) {
31
+ return [];
32
+ }
33
+ const names = Object.keys(graph.nodes);
34
+ if (!current) {
35
+ return names;
36
+ }
37
+ return names.filter((name) => name.startsWith(current));
38
+ }
39
+ /** Projects that declare `targetName`, matching `current`. */
40
+ function getProjectNamesWithTarget(current, targetName) {
41
+ const graph = getCachedProjectGraph();
42
+ if (!graph?.nodes) {
43
+ return [];
44
+ }
45
+ const matches = [];
46
+ for (const [name, node] of Object.entries(graph.nodes)) {
47
+ if (node?.data?.targets?.[targetName]) {
48
+ if (!current || name.startsWith(current)) {
49
+ matches.push(name);
50
+ }
51
+ }
52
+ }
53
+ return matches;
54
+ }
55
+ /** Two-stage `project[:target]` — stage 1 emits `project:` (nospace), stage 2 emits `project:target`. */
56
+ function completeProjectTarget(current) {
57
+ const colonIdx = current.indexOf(':');
58
+ if (colonIdx === -1) {
59
+ return getProjectNameCompletions(current).map((p) => `${p}:`);
60
+ }
61
+ const projectName = current.slice(0, colonIdx);
62
+ const targetPrefix = current.slice(colonIdx + 1);
63
+ return getTargetNamesForProject(targetPrefix, projectName).map((t) => `${projectName}:${t}`);
64
+ }
65
+ /** Generator completion. Stage 1 (`nx g <TAB>`) emits plugin names (with `:`)
66
+ * and bare generator names (for `nx g application`); stage 2 emits
67
+ * `plugin:generator`. */
68
+ function completeGenerator(current) {
69
+ const colonIdx = current.indexOf(':');
70
+ if (colonIdx !== -1) {
71
+ const pluginName = current.slice(0, colonIdx);
72
+ const generatorPrefix = current.slice(colonIdx + 1);
73
+ return getGeneratorsForPlugin(pluginName, generatorPrefix).map((g) => `${pluginName}:${g}`);
74
+ }
75
+ // No prefix on the plugin map — we need every plugin to enumerate bare
76
+ // generator names; dedup bare names across plugins.
77
+ const all = collectPluginDirs();
78
+ const result = [];
79
+ const bare = new Set();
80
+ for (const [name, entry] of all) {
81
+ if (!current || name.startsWith(current)) {
82
+ result.push(`${name}:`);
83
+ }
84
+ for (const gen of readGeneratorNames(entry.dir, entry.field)) {
85
+ if (!current || gen.startsWith(current)) {
86
+ bare.add(gen);
87
+ }
88
+ }
89
+ }
90
+ for (const gen of bare) {
91
+ result.push(gen);
92
+ }
93
+ return result;
94
+ }
95
+ /** Plugin names matching `current` — installed npm plugins + workspace-local
96
+ * plugin projects, only those declaring a generator collection. */
97
+ function getGeneratorPluginCompletions(current) {
98
+ return [...collectPluginDirs(current).keys()];
99
+ }
100
+ /** Generator names in a single plugin, matching `current`. */
101
+ function getGeneratorsForPlugin(pluginName, current) {
102
+ const entry = collectPluginDirs(pluginName).get(pluginName);
103
+ if (!entry) {
104
+ return [];
105
+ }
106
+ const generators = readGeneratorNames(entry.dir, entry.field);
107
+ if (!current) {
108
+ return generators;
109
+ }
110
+ return generators.filter((g) => g.startsWith(current));
111
+ }
112
+ /** plugin name → { dir, generators-collection path }. Workspace-local
113
+ * plugins win over same-named installed ones. `prefix` skips non-matching
114
+ * installed deps before reading their package.json. */
115
+ function collectPluginDirs(prefix = '') {
116
+ const dirs = new Map();
117
+ // Installed plugins: root package.json deps, resolved under node_modules.
118
+ const rootPkg = readJsonSafe((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'));
119
+ if (rootPkg) {
120
+ const deps = {
121
+ ...(rootPkg.dependencies ?? {}),
122
+ ...(rootPkg.devDependencies ?? {}),
123
+ };
124
+ for (const dep of Object.keys(deps)) {
125
+ if (prefix && !dep.startsWith(prefix))
126
+ continue;
127
+ const dir = (0, path_1.join)(workspace_root_1.workspaceRoot, 'node_modules', dep);
128
+ const pkg = readJsonSafe((0, path_1.join)(dir, 'package.json'));
129
+ const field = pkg?.generators ?? pkg?.schematics;
130
+ if (typeof field === 'string')
131
+ dirs.set(dep, { dir, field });
132
+ }
133
+ }
134
+ // Workspace-local plugin projects — shared helper with utils/plugins.
135
+ // Local entries overwrite same-named installed ones (the local one is what
136
+ // the user is developing).
137
+ const graph = getCachedProjectGraph();
138
+ const projectRoots = Object.values(graph?.nodes ?? {})
139
+ .map((n) => n?.data?.root)
140
+ .filter((r) => typeof r === 'string' && r.length > 0);
141
+ for (const [name, entry] of (0, local_plugins_1.findLocalPluginsWithGenerators)(projectRoots)) {
142
+ if (prefix && !name.startsWith(prefix))
143
+ continue;
144
+ dirs.set(name, entry);
145
+ }
146
+ return dirs;
147
+ }
148
+ /**
149
+ * Reads the non-hidden generator names from the `generators`/`schematics`
150
+ * JSON at `field`, relative to the plugin's `pluginDir`.
151
+ */
152
+ function readGeneratorNames(pluginDir, field) {
153
+ const generatorsJson = readJsonSafe((0, path_1.join)(pluginDir, field));
154
+ if (!generatorsJson) {
155
+ return [];
156
+ }
157
+ const collection = generatorsJson.generators ?? generatorsJson.schematics ?? {};
158
+ return Object.keys(collection).filter((k) => !collection[k]?.hidden);
159
+ }
160
+ function readJsonSafe(path) {
161
+ try {
162
+ return (0, fileutils_1.readJsonFile)(path);
163
+ }
164
+ catch {
165
+ return null;
166
+ }
167
+ }
168
+ /** Unique target names across the workspace, matching `current`. */
169
+ function getTargetNameCompletions(current) {
170
+ const graph = getCachedProjectGraph();
171
+ if (!graph?.nodes)
172
+ return [];
173
+ const targetSet = new Set();
174
+ for (const node of Object.values(graph.nodes)) {
175
+ for (const target of Object.keys(node?.data?.targets ?? {})) {
176
+ targetSet.add(target);
177
+ }
178
+ }
179
+ const targets = [...targetSet];
180
+ return current ? targets.filter((t) => t.startsWith(current)) : targets;
181
+ }
182
+ /** Target names for a single project, matching `current`. Falls back to
183
+ * workspace-wide if the project isn't in the graph — covers the
184
+ * `project:t<TAB>` case where the user is still typing the project name. */
185
+ function getTargetNamesForProject(current, projectName) {
186
+ const graph = getCachedProjectGraph();
187
+ if (!graph?.nodes)
188
+ return [];
189
+ const node = graph.nodes[projectName];
190
+ if (!node)
191
+ return getTargetNameCompletions(current);
192
+ const targets = Object.keys(node?.data?.targets ?? {});
193
+ return current ? targets.filter((t) => t.startsWith(current)) : targets;
194
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const metadata_1 = require("./metadata");
4
+ const completion_providers_1 = require("./completion-providers");
5
+ const project_graph_1 = require("../../project-graph/project-graph");
6
+ // `nx <target> <project>` infix completion. Every unique target name in
7
+ // the cached graph gets its own path; union with a conventional set so
8
+ // cold workspaces still get the everyday names.
9
+ //
10
+ // This file is imported LAST in registrations.ts so we can skip target
11
+ // names that collide with real Nx commands ('run', 'add', 'generate',
12
+ // ...). Otherwise a workspace that happens to have e.g. a `run` target
13
+ // would silently shadow the command-specific completer.
14
+ const CONVENTIONAL_TARGETS = [
15
+ 'build',
16
+ 'serve',
17
+ 'test',
18
+ 'lint',
19
+ 'e2e',
20
+ 'dev',
21
+ 'start',
22
+ 'preview',
23
+ 'typecheck',
24
+ ];
25
+ const targetNames = new Set(CONVENTIONAL_TARGETS);
26
+ try {
27
+ const graph = (0, project_graph_1.readCachedProjectGraph)();
28
+ for (const node of Object.values(graph?.nodes ?? {})) {
29
+ for (const t of Object.keys(node?.data?.targets ?? {})) {
30
+ targetNames.add(t);
31
+ }
32
+ }
33
+ }
34
+ catch {
35
+ // No cached graph — conventional set only.
36
+ }
37
+ const reserved = new Set((0, metadata_1.getRegisteredTopLevelPaths)());
38
+ for (const targetName of targetNames) {
39
+ if (reserved.has(targetName))
40
+ continue;
41
+ (0, metadata_1.registerCompletion)(targetName, {
42
+ positionals: [
43
+ {
44
+ complete: (current) => (0, completion_providers_1.getProjectNamesWithTarget)(current, targetName),
45
+ },
46
+ ],
47
+ });
48
+ }
@@ -0,0 +1,22 @@
1
+ export type CompletionFn = (current: string, args: string[]) => string[];
2
+ export interface PositionalCompletion {
3
+ choices?: string[];
4
+ complete?: CompletionFn;
5
+ }
6
+ export interface CommandCompletionMetadata {
7
+ positionals?: PositionalCompletion[];
8
+ /** Flag value handlers, keyed without leading `--`. Aliases get their own
9
+ * entry pointing at the same function. */
10
+ flags?: Record<string, CompletionFn>;
11
+ }
12
+ export declare function registerCompletion(path: string, metadata: CommandCompletionMetadata): void;
13
+ /** Single-token registered paths (infix targets etc.). */
14
+ export declare function getRegisteredTopLevelPaths(): string[];
15
+ /** Longest-prefix match against the leading non-flag args. */
16
+ export declare function findCompletionMetadata(args: string[]): {
17
+ metadata: CommandCompletionMetadata;
18
+ positionalIndex: number;
19
+ } | null;
20
+ export declare function findFlagCompletion(metadata: CommandCompletionMetadata | null, flag: string): CompletionFn | null;
21
+ /** Positional/flag-value dispatch. Returns null when no handler applies. */
22
+ export declare function resolveCompletion(args: string[], current: string, previousToken: string): string[] | null;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ // Per-command completion metadata. Path-keyed because yargs doesn't
3
+ // preserve command-object references through its parse.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.registerCompletion = registerCompletion;
6
+ exports.getRegisteredTopLevelPaths = getRegisteredTopLevelPaths;
7
+ exports.findCompletionMetadata = findCompletionMetadata;
8
+ exports.findFlagCompletion = findFlagCompletion;
9
+ exports.resolveCompletion = resolveCompletion;
10
+ const REGISTRY = new Map();
11
+ function registerCompletion(path, metadata) {
12
+ REGISTRY.set(path, metadata);
13
+ }
14
+ /** Single-token registered paths (infix targets etc.). */
15
+ function getRegisteredTopLevelPaths() {
16
+ const paths = [];
17
+ for (const path of REGISTRY.keys()) {
18
+ if (!path.includes(' '))
19
+ paths.push(path);
20
+ }
21
+ return paths;
22
+ }
23
+ /** Longest-prefix match against the leading non-flag args. */
24
+ function findCompletionMetadata(args) {
25
+ const nonFlag = [];
26
+ for (const arg of args) {
27
+ if (arg.startsWith('-'))
28
+ break;
29
+ nonFlag.push(arg);
30
+ }
31
+ for (let i = nonFlag.length; i > 0; i--) {
32
+ const path = nonFlag.slice(0, i).join(' ');
33
+ const metadata = REGISTRY.get(path);
34
+ if (metadata) {
35
+ const positionalIndex = Math.max(0, nonFlag.length - i - 1);
36
+ return { metadata, positionalIndex };
37
+ }
38
+ }
39
+ return null;
40
+ }
41
+ function findFlagCompletion(metadata, flag) {
42
+ return metadata?.flags?.[flag] ?? null;
43
+ }
44
+ /** Positional/flag-value dispatch. Returns null when no handler applies. */
45
+ function resolveCompletion(args, current, previousToken) {
46
+ if (args.length === 0)
47
+ return null;
48
+ const match = findCompletionMetadata(args);
49
+ const meta = match?.metadata ?? null;
50
+ if (previousToken && previousToken.startsWith('-')) {
51
+ const handler = findFlagCompletion(meta, previousToken.replace(/^-+/, ''));
52
+ if (handler)
53
+ return handler(current, args);
54
+ // The user is typing a flag's value but we don't have a handler for
55
+ // this flag. Emit no candidates so the shell wrapper falls back to its
56
+ // native default (filename/dirname completion in bash via `-o default`).
57
+ // Crucially, do NOT fall through to positional dispatch — that would
58
+ // offer wrong candidates (e.g. project names for `nx g app --directory <TAB>`).
59
+ return [];
60
+ }
61
+ if (match) {
62
+ const positional = match.metadata.positionals?.[match.positionalIndex];
63
+ if (positional?.complete)
64
+ return positional.complete(current, args);
65
+ if (positional?.choices) {
66
+ return positional.choices.filter((c) => c.startsWith(current));
67
+ }
68
+ return null;
69
+ }
70
+ return null;
71
+ }
@@ -0,0 +1,9 @@
1
+ import '../run/completion';
2
+ import '../run-many/completion';
3
+ import '../affected/completion';
4
+ import '../show/completion';
5
+ import '../generate/completion';
6
+ import '../graph/completion';
7
+ import '../watch/completion';
8
+ import '../add/completion';
9
+ import './infix-targets';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // Side-effect imports populating the completion registry. Each
3
+ // command's completion.ts pulls only metadata helpers + providers, not
4
+ // the heavy command-object surface.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ require("../run/completion");
7
+ require("../run-many/completion");
8
+ require("../affected/completion");
9
+ require("../show/completion");
10
+ require("../generate/completion");
11
+ require("../graph/completion");
12
+ require("../watch/completion");
13
+ require("../add/completion");
14
+ // Must be last — infix-targets skips any name already registered above
15
+ // so a real Nx command (`run`, `add`, ...) wins over a same-named target.
16
+ require("./infix-targets");
@@ -0,0 +1,51 @@
1
+ ###-begin-nx-completions-###
2
+ #
3
+ # nx command completion script
4
+ #
5
+ # Installation: nx completion bash >> ~/.bashrc
6
+ # or: nx completion bash >> ~/.bash_profile
7
+ #
8
+ _nx_completions()
9
+ {
10
+ local cur_word args type_list nx_cmd dir
11
+
12
+ cur_word="${COMP_WORDS[COMP_CWORD]}"
13
+ args=("${COMP_WORDS[@]}")
14
+
15
+ # Walk up for a workspace-local nx; fall back to PATH outside a workspace.
16
+ nx_cmd="nx"
17
+ dir="$PWD"
18
+ while [ "$dir" != "/" ]; do
19
+ if [ -x "$dir/node_modules/.bin/nx" ]; then
20
+ nx_cmd="$dir/node_modules/.bin/nx"
21
+ break
22
+ fi
23
+ if [ -x "$dir/.nx/installation/node_modules/.bin/nx" ]; then
24
+ nx_cmd="$dir/.nx/installation/node_modules/.bin/nx"
25
+ break
26
+ fi
27
+ dir="$(dirname "$dir")"
28
+ done
29
+
30
+ # Hide stderr so stray warnings don't land in the buffer; NX_VERBOSE_LOGGING surfaces it.
31
+ if [ -n "$NX_VERBOSE_LOGGING" ]; then
32
+ type_list=$(NX_COMPLETE=bash "$nx_cmd" "${args[@]}")
33
+ else
34
+ type_list=$(NX_COMPLETE=bash "$nx_cmd" "${args[@]}" 2>/dev/null)
35
+ fi
36
+
37
+ COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
38
+
39
+ # Trailing ':' (project:target stage 1) — nospace so the user can TAB again.
40
+ if [ ${#COMPREPLY[@]} -eq 1 ] && [[ "${COMPREPLY[0]}" == *: ]]; then
41
+ compopt -o nospace 2>/dev/null
42
+ fi
43
+
44
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
45
+ COMPREPLY=()
46
+ fi
47
+
48
+ return 0
49
+ }
50
+ complete -o default -F _nx_completions nx
51
+ ###-end-nx-completions-###
@@ -0,0 +1,47 @@
1
+ ###-begin-nx-completions-###
2
+ #
3
+ # nx command completion script for fish
4
+ #
5
+ # Installation:
6
+ # mkdir -p ~/.config/fish/completions
7
+ # nx completion fish > ~/.config/fish/completions/nx.fish
8
+ #
9
+ complete -e -c nx
10
+
11
+ function __nx_completions
12
+ set -l tokens (commandline -cop)
13
+ set -l current (commandline -ct)
14
+ # Walk up for a workspace-local nx; fall back to PATH outside a workspace.
15
+ set -l nx_cmd nx
16
+ set -l dir $PWD
17
+ while test "$dir" != "/"
18
+ if test -x "$dir/node_modules/.bin/nx"
19
+ set nx_cmd "$dir/node_modules/.bin/nx"
20
+ break
21
+ end
22
+ if test -x "$dir/.nx/installation/node_modules/.bin/nx"
23
+ set nx_cmd "$dir/.nx/installation/node_modules/.bin/nx"
24
+ break
25
+ end
26
+ set dir (dirname "$dir")
27
+ end
28
+ # Hide stderr so stray warnings don't land in the buffer; NX_VERBOSE_LOGGING surfaces it.
29
+ set -l output
30
+ if test -n "$NX_VERBOSE_LOGGING"
31
+ set output (NX_COMPLETE=fish $nx_cmd $tokens "$current")
32
+ else
33
+ set output (NX_COMPLETE=fish $nx_cmd $tokens "$current" 2>/dev/null)
34
+ end
35
+ if test (count $output) -gt 0
36
+ printf '%s\n' $output
37
+ return
38
+ end
39
+ # No nx completion — fall back to filename completion. `-f` on the
40
+ # `complete` declaration blocks fish's BUILT-IN file offering, but
41
+ # fish exposes __fish_complete_path for callers that want the same
42
+ # behaviour (trailing '/' on dirs, ~ expansion, hidden-file handling,
43
+ # fish_complete_path config) from inside a function.
44
+ __fish_complete_path $current
45
+ end
46
+ complete -c nx -f -a '(__nx_completions)'
47
+ ###-end-nx-completions-###
@@ -0,0 +1,52 @@
1
+ ###-begin-nx-completions-###
2
+ #
3
+ # nx command completion script for PowerShell
4
+ #
5
+ # Installation: nx completion powershell | Out-File -Append $PROFILE
6
+ #
7
+ Register-ArgumentCompleter -Native -CommandName nx -ScriptBlock {
8
+ param($wordToComplete, $commandAst, $cursorPosition)
9
+
10
+ $tokens = @($commandAst.CommandElements | ForEach-Object { $_.Extent.Text })
11
+ # Match POSIX wrappers' '[...tokens, currentPartial]' layout.
12
+ if ($cursorPosition -gt $commandAst.Extent.EndOffset) {
13
+ $tokens += ''
14
+ }
15
+
16
+ # Walk up for a workspace-local nx.cmd; fall back to PATH outside a workspace.
17
+ $nxCmd = 'nx'
18
+ $dir = $PWD.Path
19
+ while ($dir) {
20
+ $standard = Join-Path $dir 'node_modules\.bin\nx.cmd'
21
+ $nxStyle = Join-Path $dir '.nx\installation\node_modules\.bin\nx.cmd'
22
+ if (Test-Path -LiteralPath $standard) { $nxCmd = $standard; break }
23
+ if (Test-Path -LiteralPath $nxStyle) { $nxCmd = $nxStyle; break }
24
+ $parent = Split-Path -Parent $dir
25
+ if ($parent -eq $dir) { break }
26
+ $dir = $parent
27
+ }
28
+
29
+ $env:NX_COMPLETE = 'powershell'
30
+ # Windows PowerShell 5.1 turns native-command stderr into terminating
31
+ # ErrorRecords when the caller's $ErrorActionPreference is 'Stop', so
32
+ # `2>$null` raises before it can suppress. Force 'Continue' locally —
33
+ # the param has function scope and resets on return.
34
+ $ErrorActionPreference = 'Continue'
35
+ try {
36
+ # Hide stderr so stray warnings don't land in the buffer; NX_VERBOSE_LOGGING surfaces it.
37
+ if ($env:NX_VERBOSE_LOGGING) {
38
+ $lines = & $nxCmd @tokens
39
+ } else {
40
+ $lines = & $nxCmd @tokens 2>$null
41
+ }
42
+ # PowerShell appends a space after each completion — no per-result nospace API.
43
+ # Skip blank lines: PS 5.1's CompletionResult ctor throws on empty completionText.
44
+ foreach ($line in $lines) {
45
+ if ([string]::IsNullOrEmpty($line)) { continue }
46
+ [System.Management.Automation.CompletionResult]::new($line)
47
+ }
48
+ } finally {
49
+ Remove-Item Env:NX_COMPLETE -ErrorAction SilentlyContinue
50
+ }
51
+ }
52
+ ###-end-nx-completions-###