nx 23.2.0-beta.1 → 23.2.0-beta.11

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 (369) hide show
  1. package/README.md +2 -2
  2. package/dist/bin/init-local.js +3 -5
  3. package/dist/bin/nx.js +2 -0
  4. package/dist/release/changelog-renderer/index.js +4 -5
  5. package/dist/release/index.d.ts +1 -1
  6. package/dist/src/adapter/ngcli-adapter.js +60 -1
  7. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
  8. package/dist/src/analytics/analytics.d.ts +6 -0
  9. package/dist/src/analytics/analytics.js +16 -10
  10. package/dist/src/analytics/index.d.ts +1 -1
  11. package/dist/src/analytics/index.js +2 -1
  12. package/dist/src/command-line/add/add.js +5 -0
  13. package/dist/src/command-line/affected/affected.js +1 -0
  14. package/dist/src/command-line/completion/command-object.js +7 -12
  15. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
  16. package/dist/src/command-line/format/format.js +84 -101
  17. package/dist/src/command-line/generate/generate.js +35 -35
  18. package/dist/src/command-line/graph/graph.d.ts +1 -0
  19. package/dist/src/command-line/graph/graph.js +15 -6
  20. package/dist/src/command-line/import/import.js +30 -40
  21. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  22. package/dist/src/command-line/init/command-object.js +4 -2
  23. package/dist/src/command-line/init/configure-plugins.js +4 -1
  24. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  25. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  26. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  27. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  28. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  29. package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
  30. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -0
  31. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  32. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  33. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +9 -1
  34. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  35. package/dist/src/command-line/init/implementation/format.js +114 -0
  36. package/dist/src/command-line/init/implementation/utils.js +8 -0
  37. package/dist/src/command-line/init/init-v1.js +15 -18
  38. package/dist/src/command-line/init/init-v2.js +40 -57
  39. package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
  40. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
  41. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
  42. package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
  43. package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
  44. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
  45. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
  46. package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
  47. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  48. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  49. package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
  50. package/dist/src/command-line/migrate/agentic/select.js +30 -32
  51. package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
  52. package/dist/src/command-line/migrate/agentic/types.js +35 -0
  53. package/dist/src/command-line/migrate/command-object.d.ts +6 -0
  54. package/dist/src/command-line/migrate/command-object.js +19 -1
  55. package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
  56. package/dist/src/command-line/migrate/execute-migration.js +112 -27
  57. package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
  58. package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
  59. package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
  60. package/dist/src/command-line/migrate/migrate-commits.js +130 -15
  61. package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
  62. package/dist/src/command-line/migrate/migrate-config.js +22 -14
  63. package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
  64. package/dist/src/command-line/migrate/migrate-output.js +52 -8
  65. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  66. package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
  67. package/dist/src/command-line/migrate/migrate.d.ts +28 -68
  68. package/dist/src/command-line/migrate/migrate.js +657 -293
  69. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  70. package/dist/src/command-line/migrate/multi-major.js +7 -10
  71. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  72. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  73. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  74. package/dist/src/command-line/migrate/run/index.d.ts +9 -0
  75. package/dist/src/command-line/migrate/run/index.js +23 -0
  76. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  77. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  78. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  79. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  80. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  81. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  82. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  83. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  84. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  85. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  86. package/dist/src/command-line/migrate/run/util.d.ts +59 -0
  87. package/dist/src/command-line/migrate/run/util.js +148 -0
  88. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  89. package/dist/src/command-line/migrate/run/worker.js +682 -0
  90. package/dist/src/command-line/migrate/run-migration-process.js +6 -5
  91. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  92. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  93. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  94. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  95. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  96. package/dist/src/command-line/migrate/step-actions.js +12 -0
  97. package/dist/src/command-line/migrate/text.d.ts +18 -0
  98. package/dist/src/command-line/migrate/text.js +26 -0
  99. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  100. package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
  101. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -21
  102. package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
  103. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  104. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  105. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  106. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  107. package/dist/src/command-line/nx-commands.js +26 -24
  108. package/dist/src/command-line/release/changelog.js +11 -17
  109. package/dist/src/command-line/release/index.d.ts +1 -1
  110. package/dist/src/command-line/release/plan.js +15 -28
  111. package/dist/src/command-line/release/publish.js +5 -0
  112. package/dist/src/command-line/release/release.js +6 -17
  113. package/dist/src/command-line/release/utils/git.js +1 -1
  114. package/dist/src/command-line/release/utils/release-graph.d.ts +18 -0
  115. package/dist/src/command-line/release/utils/release-graph.js +81 -21
  116. package/dist/src/command-line/release/utils/remote-release-clients/github.js +17 -23
  117. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +14 -23
  118. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  119. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  120. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  121. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  122. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  123. package/dist/src/command-line/release/version/version-actions.js +9 -1
  124. package/dist/src/command-line/release/version.js +10 -6
  125. package/dist/src/command-line/reset/reset.js +6 -1
  126. package/dist/src/command-line/run/run-one.js +1 -0
  127. package/dist/src/command-line/run-many/run-many.js +1 -0
  128. package/dist/src/command-line/show/show-target/inputs.js +50 -153
  129. package/dist/src/command-line/show/show-target/outputs.js +48 -173
  130. package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
  131. package/dist/src/command-line/show/show-target/utils.js +83 -3
  132. package/dist/src/command-line/watch/watch.js +13 -0
  133. package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
  134. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  135. package/dist/src/config/misc-interfaces.d.ts +19 -7
  136. package/dist/src/config/nx-json.d.ts +4 -2
  137. package/dist/src/core/graph/main.js +1 -1
  138. package/dist/src/core/graph/styles.js +1 -1
  139. package/dist/src/daemon/client/client.d.ts +52 -1
  140. package/dist/src/daemon/client/client.js +160 -36
  141. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  142. package/dist/src/daemon/client/daemon-environment.js +110 -2
  143. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  144. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  145. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  146. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  147. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  148. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
  149. package/dist/src/daemon/server/latest-nx.js +5 -2
  150. package/dist/src/daemon/server/server.js +31 -4
  151. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  152. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  153. package/dist/src/daemon/socket-utils.d.ts +1 -0
  154. package/dist/src/daemon/socket-utils.js +24 -3
  155. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  156. package/dist/src/daemon/tmp-dir.js +437 -15
  157. package/dist/src/devkit-internals.d.ts +106 -8
  158. package/dist/src/devkit-internals.js +225 -7
  159. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  160. package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
  161. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  162. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  163. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  164. package/dist/src/generators/tree.d.ts +4 -2
  165. package/dist/src/hasher/check-task-files.d.ts +86 -0
  166. package/dist/src/hasher/check-task-files.js +378 -0
  167. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  168. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  169. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  170. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  171. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  172. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  173. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  174. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  175. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  176. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  177. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  178. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  179. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  180. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  181. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  182. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  183. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  184. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  185. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  186. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  187. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  188. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  189. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  190. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  191. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  192. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  193. package/dist/src/native/index.d.ts +37 -4
  194. package/dist/src/native/index.js +71 -28
  195. package/dist/src/native/native-bindings.js +3 -0
  196. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  197. package/dist/src/native/native-file-cache-location.js +86 -12
  198. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  199. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  200. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  201. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  202. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  203. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  204. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  205. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  206. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  207. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  208. package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
  209. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  210. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
  211. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  212. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  213. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  214. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
  215. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  216. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
  217. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  218. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  219. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  220. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  221. package/dist/src/project-graph/build-project-graph.js +7 -1
  222. package/dist/src/project-graph/error-types.d.ts +12 -1
  223. package/dist/src/project-graph/error-types.js +27 -2
  224. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  225. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
  226. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  227. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  228. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  229. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
  230. package/dist/src/project-graph/project-graph.js +23 -0
  231. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
  232. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
  233. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
  234. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
  235. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
  236. package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
  237. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
  238. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
  239. package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
  240. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
  241. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
  242. package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
  243. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
  244. package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
  245. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  246. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  247. package/dist/src/tasks-runner/life-cycle.js +2 -2
  248. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
  249. package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
  250. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  251. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  252. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  253. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  254. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  255. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  256. package/dist/src/tasks-runner/run-command.js +28 -35
  257. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  258. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  259. package/dist/src/tasks-runner/task-env.d.ts +9 -0
  260. package/dist/src/tasks-runner/task-env.js +31 -4
  261. package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
  262. package/dist/src/tasks-runner/task-orchestrator.js +182 -18
  263. package/dist/src/tasks-runner/utils.js +2 -6
  264. package/dist/src/utils/acknowledge-build-scripts.js +7 -5
  265. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  266. package/dist/src/utils/analytics-enabled.js +11 -0
  267. package/dist/src/utils/analytics-prompt.d.ts +0 -6
  268. package/dist/src/utils/analytics-prompt.js +4 -58
  269. package/dist/src/utils/assert-workspace-validity.js +7 -2
  270. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  271. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  272. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  273. package/dist/src/utils/catalog/bun-manager.js +130 -0
  274. package/dist/src/utils/catalog/index.d.ts +1 -1
  275. package/dist/src/utils/catalog/index.js +1 -1
  276. package/dist/src/utils/catalog/manager-factory.js +3 -0
  277. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  278. package/dist/src/utils/catalog/manager-utils.js +9 -4
  279. package/dist/src/utils/catalog/manager.d.ts +13 -1
  280. package/dist/src/utils/catalog/manager.js +30 -0
  281. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  282. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  283. package/dist/src/utils/catalog/types.d.ts +4 -0
  284. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  285. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  286. package/dist/src/utils/child-process.d.ts +31 -1
  287. package/dist/src/utils/child-process.js +103 -0
  288. package/dist/src/utils/chunkify.d.ts +7 -1
  289. package/dist/src/utils/chunkify.js +10 -3
  290. package/dist/src/utils/exit-codes.d.ts +9 -0
  291. package/dist/src/utils/exit-codes.js +19 -0
  292. package/dist/src/utils/fileutils.d.ts +5 -0
  293. package/dist/src/utils/fileutils.js +7 -2
  294. package/dist/src/utils/formatters/index.d.ts +13 -0
  295. package/dist/src/utils/formatters/index.js +74 -0
  296. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  297. package/dist/src/utils/formatters/oxfmt.js +764 -0
  298. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  299. package/dist/src/utils/formatters/prettier.js +201 -0
  300. package/dist/src/utils/formatters/shared.d.ts +5 -0
  301. package/dist/src/utils/formatters/shared.js +8 -0
  302. package/dist/src/utils/git-utils.d.ts +48 -2
  303. package/dist/src/utils/git-utils.js +220 -14
  304. package/dist/src/utils/git-worktrees.d.ts +30 -0
  305. package/dist/src/utils/git-worktrees.js +212 -0
  306. package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
  307. package/dist/src/utils/has-nx-js-plugin.js +1 -1
  308. package/dist/src/utils/ignore.d.ts +170 -1
  309. package/dist/src/utils/ignore.js +263 -11
  310. package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
  311. package/dist/src/utils/kill-child-on-host-exit.js +42 -0
  312. package/dist/src/utils/long-running-target.d.ts +10 -0
  313. package/dist/src/utils/long-running-target.js +19 -0
  314. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  315. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  316. package/dist/src/utils/min-release-age/packument.js +1 -1
  317. package/dist/src/utils/nx-console-prompt.js +3 -6
  318. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  319. package/dist/src/utils/nx-tmp-dir.js +40 -0
  320. package/dist/src/utils/output.d.ts +153 -0
  321. package/dist/src/utils/output.js +289 -5
  322. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  323. package/dist/src/utils/owned-private-dir.js +323 -0
  324. package/dist/src/utils/package-json.d.ts +2 -0
  325. package/dist/src/utils/package-json.js +11 -7
  326. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  327. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  328. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  329. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  330. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  331. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  332. package/dist/src/utils/package-manager.d.ts +23 -2
  333. package/dist/src/utils/package-manager.js +262 -42
  334. package/dist/src/utils/params.d.ts +7 -1
  335. package/dist/src/utils/params.js +64 -6
  336. package/dist/src/utils/plugins/core-plugins.js +4 -0
  337. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  338. package/dist/src/utils/prompt-helpers.js +111 -0
  339. package/dist/src/utils/provenance.js +6 -14
  340. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  341. package/dist/src/utils/registry-config/bun.js +257 -0
  342. package/dist/src/utils/registry-config/index.d.ts +13 -0
  343. package/dist/src/utils/registry-config/index.js +102 -0
  344. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  345. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  346. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  347. package/dist/src/utils/registry-config/utils.js +496 -0
  348. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  349. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  350. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  351. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  352. package/dist/src/utils/safe-spawn.d.ts +24 -0
  353. package/dist/src/utils/safe-spawn.js +104 -0
  354. package/dist/src/utils/shell-quoting.d.ts +15 -0
  355. package/dist/src/utils/shell-quoting.js +35 -0
  356. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  357. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  358. package/dist/src/utils/workspace-id.d.ts +20 -0
  359. package/dist/src/utils/workspace-id.js +54 -0
  360. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  361. package/dist/src/utils/write-formatted-json-file.js +5 -4
  362. package/migrations.json +6 -0
  363. package/package.json +29 -19
  364. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
  365. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
  366. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  367. package/dist/src/utils/is-using-prettier.js +0 -62
  368. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  369. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -39,11 +39,11 @@ async function runMigrationProcess() {
39
39
  const installer = new ChangedDepInstaller(workspacePath);
40
40
  const installDepsIfChanged = () => installer.installDepsIfChanged();
41
41
 
42
- const { changes: fileChanges, nextSteps } = await runNxOrAngularMigration(
43
- workspacePath,
44
- migration,
45
- false
46
- );
42
+ const {
43
+ changes: fileChanges,
44
+ nextSteps,
45
+ skipAgentic,
46
+ } = await runNxOrAngularMigration(workspacePath, migration, false);
47
47
 
48
48
  if (configuration.createCommits) {
49
49
  const commitResult = await commitMigrationIfRequested(
@@ -81,6 +81,7 @@ async function runMigrationProcess() {
81
81
  })),
82
82
  gitRefAfter,
83
83
  nextSteps,
84
+ skipAgentic,
84
85
  })
85
86
  );
86
87
 
@@ -1,33 +1,21 @@
1
- import { prompt as enquirerPrompt } from 'enquirer';
1
+ import { Choice } from '../../utils/prompt-helpers';
2
2
  /**
3
3
  * Whether `nx migrate` may show interactive prompts: requires a TTY on stdin,
4
4
  * not running in CI, and the user not having passed `--no-interactive`.
5
5
  */
6
6
  export declare function canPrompt(interactive: boolean | undefined): boolean;
7
7
  /**
8
- * Drop-in replacement for enquirer's `prompt()` that hardens cancel
9
- * handling for every interactive prompt under `nx migrate`.
10
- *
11
- * Why: enquirer's built-in cancel path (`Prompt.cancel` → `close` →
12
- * `keypress.js` `off` → `readline.pause`) races on `Interface.pause()`
13
- * when triggered more than once in quick succession (mashed Ctrl+C),
14
- * throwing `ERR_USE_AFTER_CLOSE` from an unhandled async chain that
15
- * `await prompt(...)` cannot catch.
16
- *
17
- * In raw mode, Ctrl+C does NOT generate a SIGINT signal (the kernel's
18
- * `ISIG` flag is cleared while enquirer's keypress listener is active);
19
- * instead the 0x03 byte flows through `combos.js` and dispatches the
20
- * `cancel` action. So a `process.on('SIGINT', ...)` handler is the wrong
21
- * mechanism here — it never fires.
22
- *
23
- * The right hook is enquirer's per-prompt `options.cancel` override. When
24
- * present, `Prompt.keypress` (lib/prompt.js:42) calls our handler INSTEAD
25
- * of `this.cancel`, so enquirer's broken cleanup never runs. Both Ctrl+C
26
- * (byte 0x03) and Esc map to the `cancel` action, so this single override
27
- * covers both paths.
28
- *
29
- * The handler emits a single-line notice via `output.warn` and exits with
30
- * POSIX status 130 (128 + SIGINT). Synchronous exit is correct here: the
31
- * user explicitly asked to abort, there's no recovery state to preserve.
8
+ * Yes/no question for `nx migrate`, aborting the run if the user cancels.
32
9
  */
33
- export declare function migratePrompt<T = any>(questions: Parameters<typeof enquirerPrompt>[0]): Promise<T>;
10
+ export declare function migrateConfirm(options: {
11
+ message: string;
12
+ initial?: boolean;
13
+ }): Promise<boolean>;
14
+ /**
15
+ * Single-choice question for `nx migrate`, aborting the run if the user cancels.
16
+ */
17
+ export declare function migrateChoice<T extends string>(options: {
18
+ message: string;
19
+ choices: Choice<T>[];
20
+ initial?: T;
21
+ }): Promise<T>;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.canPrompt = canPrompt;
4
- exports.migratePrompt = migratePrompt;
5
- const enquirer_1 = require("enquirer");
4
+ exports.migrateConfirm = migrateConfirm;
5
+ exports.migrateChoice = migrateChoice;
6
+ const exit_codes_1 = require("../../utils/exit-codes");
6
7
  const is_ci_1 = require("../../utils/is-ci");
7
8
  const output_1 = require("../../utils/output");
9
+ const prompt_helpers_1 = require("../../utils/prompt-helpers");
8
10
  /**
9
11
  * Whether `nx migrate` may show interactive prompts: requires a TTY on stdin,
10
12
  * not running in CI, and the user not having passed `--no-interactive`.
@@ -13,46 +15,33 @@ function canPrompt(interactive) {
13
15
  return !!process.stdin.isTTY && !(0, is_ci_1.isCI)() && interactive !== false;
14
16
  }
15
17
  /**
16
- * Drop-in replacement for enquirer's `prompt()` that hardens cancel
17
- * handling for every interactive prompt under `nx migrate`.
18
- *
19
- * Why: enquirer's built-in cancel path (`Prompt.cancel` → `close` →
20
- * `keypress.js` `off` → `readline.pause`) races on `Interface.pause()`
21
- * when triggered more than once in quick succession (mashed Ctrl+C),
22
- * throwing `ERR_USE_AFTER_CLOSE` from an unhandled async chain that
23
- * `await prompt(...)` cannot catch.
24
- *
25
- * In raw mode, Ctrl+C does NOT generate a SIGINT signal (the kernel's
26
- * `ISIG` flag is cleared while enquirer's keypress listener is active);
27
- * instead the 0x03 byte flows through `combos.js` and dispatches the
28
- * `cancel` action. So a `process.on('SIGINT', ...)` handler is the wrong
29
- * mechanism here — it never fires.
30
- *
31
- * The right hook is enquirer's per-prompt `options.cancel` override. When
32
- * present, `Prompt.keypress` (lib/prompt.js:42) calls our handler INSTEAD
33
- * of `this.cancel`, so enquirer's broken cleanup never runs. Both Ctrl+C
34
- * (byte 0x03) and Esc map to the `cancel` action, so this single override
35
- * covers both paths.
36
- *
37
- * The handler emits a single-line notice via `output.warn` and exits with
38
- * POSIX status 130 (128 + SIGINT). Synchronous exit is correct here: the
39
- * user explicitly asked to abort, there's no recovery state to preserve.
18
+ * Aborts the run the way `nx migrate` wants a cancel to look: one notice, then
19
+ * POSIX 130 (128 + SIGINT). The user asked to stop, so there is no state worth
20
+ * preserving.
40
21
  */
41
- async function migratePrompt(questions) {
42
- const cancel = () => {
43
- // `\n\r` → next line at column 0 (enquirer left the TTY in raw mode,
44
- // so a bare LF would not carry an implicit CR).
45
- // `\x1B[J` → clear from cursor to end of screen. Wipes enquirer's
46
- // leftover choice / input rendering below the row where we'll
47
- // write our message so the exit output isn't shadowed by orphaned
48
- // prompt fragments.
49
- process.stdout.write('\n\r\x1B[J');
50
- output_1.output.warn({ title: 'nx migrate interrupted by user.' });
51
- process.exit(130);
52
- };
53
- const withCancel = (q) => ({ ...q, cancel });
54
- const injected = Array.isArray(questions)
55
- ? questions.map(withCancel)
56
- : withCancel(questions);
57
- return (await (0, enquirer_1.prompt)(injected));
22
+ function cancelMigrate() {
23
+ process.stdout.write('\n');
24
+ output_1.output.warn({ title: 'nx migrate interrupted by user.' });
25
+ (0, exit_codes_1.exitAsInterrupted)();
26
+ }
27
+ /**
28
+ * Yes/no question for `nx migrate`, aborting the run if the user cancels.
29
+ */
30
+ async function migrateConfirm(options) {
31
+ return (0, prompt_helpers_1.confirmationPrompt)({
32
+ message: options.message,
33
+ initial: options.initial,
34
+ onCancel: cancelMigrate,
35
+ });
36
+ }
37
+ /**
38
+ * Single-choice question for `nx migrate`, aborting the run if the user cancels.
39
+ */
40
+ async function migrateChoice(options) {
41
+ return (0, prompt_helpers_1.selectPrompt)({
42
+ message: options.message,
43
+ choices: options.choices,
44
+ initial: options.initial,
45
+ onCancel: cancelMigrate,
46
+ });
58
47
  }
@@ -0,0 +1,16 @@
1
+ interface SortableMigration {
2
+ package: string;
3
+ name: string;
4
+ version: string;
5
+ }
6
+ /**
7
+ * Sorts in place (like `Array.prototype.sort`) and returns the same array.
8
+ *
9
+ * `hoistHandoffGitignore` is set for agentic runs, which write scratch under
10
+ * `.nx/migrate-runs`; see `agentic/handoff-gitignore.ts` for why the v23
11
+ * gitignore migration must run first there.
12
+ */
13
+ export declare function sortMigrations<T extends SortableMigration>(migrations: T[], opts: {
14
+ hoistHandoffGitignore: boolean;
15
+ }): T[];
16
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortMigrations = sortMigrations;
4
+ const semver_1 = require("semver");
5
+ const types_1 = require("./agentic/types");
6
+ const version_utils_1 = require("./version-utils");
7
+ /**
8
+ * Sorts in place (like `Array.prototype.sort`) and returns the same array.
9
+ *
10
+ * `hoistHandoffGitignore` is set for agentic runs, which write scratch under
11
+ * `.nx/migrate-runs`; see `agentic/handoff-gitignore.ts` for why the v23
12
+ * gitignore migration must run first there.
13
+ */
14
+ function sortMigrations(migrations, opts) {
15
+ return migrations.sort((a, b) => {
16
+ if (opts.hoistHandoffGitignore) {
17
+ if ((0, types_1.isHandoffGitignoreMigration)(a))
18
+ return -1;
19
+ if ((0, types_1.isHandoffGitignoreMigration)(b))
20
+ return 1;
21
+ }
22
+ if (a.name === '15-7-0-split-configuration-into-project-json-files') {
23
+ return -1;
24
+ }
25
+ if (b.name === '15-7-0-split-configuration-into-project-json-files') {
26
+ return 1;
27
+ }
28
+ return (0, semver_1.lt)((0, version_utils_1.normalizeVersion)(a.version), (0, version_utils_1.normalizeVersion)(b.version))
29
+ ? -1
30
+ : 1;
31
+ });
32
+ }
@@ -0,0 +1,5 @@
1
+ /** Allowed values for `--step-action`, the orchestrated reconcile's decision relay. */
2
+ export declare const STEP_ACTIONS: readonly ['retry', 'skip', 'retry-clean', 'adopt'];
3
+ export type StepAction = (typeof STEP_ACTIONS)[number];
4
+ /** Runtime guard backed by {@link STEP_ACTIONS} so the two can't drift apart. */
5
+ export declare function isStepAction(value: unknown): value is StepAction;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ // Zero-dep source of truth for --step-action: keeps migrate/run's execution
3
+ // chain out of CLI startup for callers that only need the value list or type.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.STEP_ACTIONS = void 0;
6
+ exports.isStepAction = isStepAction;
7
+ /** Allowed values for `--step-action`, the orchestrated reconcile's decision relay. */
8
+ exports.STEP_ACTIONS = ['retry', 'skip', 'retry-clean', 'adopt'];
9
+ /** Runtime guard backed by {@link STEP_ACTIONS} so the two can't drift apart. */
10
+ function isStepAction(value) {
11
+ return exports.STEP_ACTIONS.includes(value);
12
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Collapses every character a reader could take for a line break, so a value
3
+ * cannot break out of the line it is rendered on. The driving agent scans the
4
+ * same stdout for `<nx_migrate_*>` blocks, which are framed by a bare newline,
5
+ * so a value carrying its own break could open a forged one at a line start.
6
+ *
7
+ * The set is the line terminators and nothing else. U+0085, U+2028 and U+2029
8
+ * are in it because "line start" is the reader's notion, not this process's: a
9
+ * JavaScript `^` under `/m` treats the latter two as terminators, and Nx does
10
+ * not know what parses its output. Quoting is not a substitute either, since
11
+ * `JSON.stringify` leaves all three literal.
12
+ *
13
+ * Deliberately not every control character. Some of this text is already
14
+ * colored when it arrives, and stripping ESC would leave the rest of the
15
+ * escape sequence behind as visible noise without closing anything: only a
16
+ * real terminator can put a value at the start of a line.
17
+ */
18
+ export declare function singleLine(value: string): string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // Dependency-free on purpose. Every module that renders text an AI agent will
3
+ // read needs this, run/run-state.ts included, and that one cannot reach
4
+ // run/util.ts without a cycle through run/state-lock.ts.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.singleLine = singleLine;
7
+ /**
8
+ * Collapses every character a reader could take for a line break, so a value
9
+ * cannot break out of the line it is rendered on. The driving agent scans the
10
+ * same stdout for `<nx_migrate_*>` blocks, which are framed by a bare newline,
11
+ * so a value carrying its own break could open a forged one at a line start.
12
+ *
13
+ * The set is the line terminators and nothing else. U+0085, U+2028 and U+2029
14
+ * are in it because "line start" is the reader's notion, not this process's: a
15
+ * JavaScript `^` under `/m` treats the latter two as terminators, and Nx does
16
+ * not know what parses its output. Quoting is not a substitute either, since
17
+ * `JSON.stringify` leaves all three literal.
18
+ *
19
+ * Deliberately not every control character. Some of this text is already
20
+ * colored when it arrives, and stripping ESC would leave the rest of the
21
+ * escape sequence behind as visible noise without closing anything: only a
22
+ * real terminator can put a value at the start of a line.
23
+ */
24
+ function singleLine(value) {
25
+ return value.replace(/[\r\n\u000b\u000c\u0085\u2028\u2029]+/g, ' ');
26
+ }
@@ -0,0 +1,60 @@
1
+ export declare const NEW_MIGRATE_FLAGS_FLOOR = "23.2.0";
2
+ export declare const NEW_MIGRATE_FLAGS: readonly ['--run-migration', '--runMigration', '--run-id', '--runId', '--step-action', '--stepAction'];
3
+ export declare function findNewMigrateFlag(argv: string[]): string | undefined;
4
+ /**
5
+ * Whether the invocation names an existing orchestrated run. Such an
6
+ * invocation has to execute against the workspace-local nx that owns the run's
7
+ * state under `.nx/migrate-runs`, so it never routes to a temp installation.
8
+ */
9
+ export declare function targetsExistingRun(argv: string[]): boolean;
10
+ /**
11
+ * Guard A (local side, before hop A). The current nx knows the new flags, but
12
+ * the temp CLI 'nx migrate' is about to install may be older and would
13
+ * silently drop them. Decides where a new-flag invocation runs:
14
+ *
15
+ * - No new flag in `argv`, or the temp CLI version resolves at or above the
16
+ * feature floor: 'temp-cli', the normal temp-installation path.
17
+ * - The temp CLI resolves below the floor, or resolution fails (a registry
18
+ * error, or a minimum-release-age violation that a temp install must not
19
+ * bypass): 'local-nx', provided the workspace-local nx can take the flags.
20
+ * The local nx qualifies when it is the exact version running this code
21
+ * (it parsed the flag, so it supports it regardless of the floor) or is at
22
+ * or above the floor. An unreadable local version throws: the hand-off's
23
+ * spawn normally lands on the very install this read verifies, and a
24
+ * layout where the version cannot be read gives no such assurance, so
25
+ * handing off blind could run a below-floor nx that silently drops the
26
+ * flag.
27
+ * - Neither side is capable: throw with remediation.
28
+ *
29
+ * An explicit NX_MIGRATE_CLI_VERSION pinned below the floor throws instead of
30
+ * silently overriding the user's pin with the local fallback.
31
+ *
32
+ * `cliVersionSpec` is NX_MIGRATE_CLI_VERSION when set, else 'latest'.
33
+ */
34
+ export declare function resolveNewMigrateFlagsRunTarget(options: {
35
+ argv: string[];
36
+ cliVersionSpec: string;
37
+ fromEnvOverride: boolean;
38
+ ownNxVersion: string;
39
+ resolveVersion: (spec: string) => Promise<string>;
40
+ readLocalNxVersion: () => string | undefined;
41
+ }): Promise<'temp-cli' | 'local-nx'>;
42
+ /**
43
+ * Guard B (temp side, before hop B). The temp CLI knows the new flags, but the
44
+ * workspace-local nx it is about to hand off to may be older and would silently
45
+ * drop them.
46
+ *
47
+ * A workspace pinned to a feature-carrying 23.2.0 prerelease is refused here
48
+ * too: published prereleases that predate the feature cannot be told apart by
49
+ * version alone. Guard A's same-version bypass does not apply on this side
50
+ * because the invoking nx's version is not forwarded across hop A; the
51
+ * refusal names the workspace update that resolves it.
52
+ *
53
+ * `readLocalNxVersion` returning undefined does not block: the hand-off then
54
+ * resolves nx as it always does, which may fail visibly or land on another nx
55
+ * the package manager locates.
56
+ */
57
+ export declare function assertWorkspaceNxSupportsNewMigrateFlags(options: {
58
+ argv: string[];
59
+ readLocalNxVersion: () => string | undefined;
60
+ }): void;
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NEW_MIGRATE_FLAGS = exports.NEW_MIGRATE_FLAGS_FLOOR = void 0;
4
+ exports.findNewMigrateFlag = findNewMigrateFlag;
5
+ exports.targetsExistingRun = targetsExistingRun;
6
+ exports.resolveNewMigrateFlagsRunTarget = resolveNewMigrateFlagsRunTarget;
7
+ exports.assertWorkspaceNxSupportsNewMigrateFlags = assertWorkspaceNxSupportsNewMigrateFlags;
8
+ const semver_1 = require("semver");
9
+ const logger_1 = require("../../utils/logger");
10
+ const output_1 = require("../../utils/output");
11
+ const version_utils_1 = require("./version-utils");
12
+ // The first stable release shipping --run-migration/--run-id. Deliberately
13
+ // the final release rather than its first prerelease: 23.2.0 prereleases
14
+ // published before the feature landed do not carry it, so a prerelease floor
15
+ // would wrongly accept them. The cost is that a later 23.2.0 prerelease that
16
+ // does carry the feature is refused too, which fails toward refusal.
17
+ // Permanent; never bumped at release time, but it must name the release that
18
+ // actually ships the feature: if that slips past 23.2.0, versions in the gap
19
+ // pass this floor and route to a temp CLI that drops the new flags and runs
20
+ // the plan phase instead.
21
+ exports.NEW_MIGRATE_FLAGS_FLOOR = '23.2.0';
22
+ // yargs accepts both spellings of each flag and the raw argv is forwarded
23
+ // across both migrate hops, so detection must catch every one.
24
+ exports.NEW_MIGRATE_FLAGS = [
25
+ '--run-migration',
26
+ '--runMigration',
27
+ '--run-id',
28
+ '--runId',
29
+ '--step-action',
30
+ '--stepAction',
31
+ ];
32
+ const RUN_ID_FLAGS = ['--run-id', '--runId'];
33
+ /**
34
+ * Matches an exact token or `<flag>=<value>`. The `=` matters: a bare
35
+ * `startsWith` would also match `--run-migrations` (trailing s).
36
+ */
37
+ function findFlag(argv, flags) {
38
+ for (const arg of argv) {
39
+ // Everything after the -- separator is positional data, not options.
40
+ if (arg === '--') {
41
+ return undefined;
42
+ }
43
+ for (const flag of flags) {
44
+ if (arg === flag || arg.startsWith(`${flag}=`)) {
45
+ return flag;
46
+ }
47
+ }
48
+ }
49
+ return undefined;
50
+ }
51
+ function findNewMigrateFlag(argv) {
52
+ return findFlag(argv, exports.NEW_MIGRATE_FLAGS);
53
+ }
54
+ /**
55
+ * Whether the invocation names an existing orchestrated run. Such an
56
+ * invocation has to execute against the workspace-local nx that owns the run's
57
+ * state under `.nx/migrate-runs`, so it never routes to a temp installation.
58
+ */
59
+ function targetsExistingRun(argv) {
60
+ return findFlag(argv, RUN_ID_FLAGS) !== undefined;
61
+ }
62
+ /**
63
+ * Guard A (local side, before hop A). The current nx knows the new flags, but
64
+ * the temp CLI 'nx migrate' is about to install may be older and would
65
+ * silently drop them. Decides where a new-flag invocation runs:
66
+ *
67
+ * - No new flag in `argv`, or the temp CLI version resolves at or above the
68
+ * feature floor: 'temp-cli', the normal temp-installation path.
69
+ * - The temp CLI resolves below the floor, or resolution fails (a registry
70
+ * error, or a minimum-release-age violation that a temp install must not
71
+ * bypass): 'local-nx', provided the workspace-local nx can take the flags.
72
+ * The local nx qualifies when it is the exact version running this code
73
+ * (it parsed the flag, so it supports it regardless of the floor) or is at
74
+ * or above the floor. An unreadable local version throws: the hand-off's
75
+ * spawn normally lands on the very install this read verifies, and a
76
+ * layout where the version cannot be read gives no such assurance, so
77
+ * handing off blind could run a below-floor nx that silently drops the
78
+ * flag.
79
+ * - Neither side is capable: throw with remediation.
80
+ *
81
+ * An explicit NX_MIGRATE_CLI_VERSION pinned below the floor throws instead of
82
+ * silently overriding the user's pin with the local fallback.
83
+ *
84
+ * `cliVersionSpec` is NX_MIGRATE_CLI_VERSION when set, else 'latest'.
85
+ */
86
+ async function resolveNewMigrateFlagsRunTarget(options) {
87
+ const flag = findNewMigrateFlag(options.argv);
88
+ if (!flag) {
89
+ return 'temp-cli';
90
+ }
91
+ // `valid()` returns null for a dist-tag like 'latest' and a normalized
92
+ // version for a concrete spec, which then skips the registry round-trip.
93
+ const concrete = (0, semver_1.valid)(options.cliVersionSpec);
94
+ let resolved;
95
+ try {
96
+ resolved =
97
+ concrete ?? (await options.resolveVersion(options.cliVersionSpec));
98
+ }
99
+ catch (e) {
100
+ // The local-fallback check below decides what a failed resolution means.
101
+ logger_1.logger.verbose(`Could not resolve the nx version for '${options.cliVersionSpec}': ${e}`);
102
+ }
103
+ if (resolved !== undefined &&
104
+ !(0, semver_1.lt)((0, version_utils_1.normalizeVersion)(resolved), exports.NEW_MIGRATE_FLAGS_FLOOR)) {
105
+ return 'temp-cli';
106
+ }
107
+ if (resolved !== undefined && options.fromEnvOverride) {
108
+ throw new Error(`The nx version 'nx migrate' is about to install (${resolved}) does not support ${flag}. ` +
109
+ `This flag ships in nx ${exports.NEW_MIGRATE_FLAGS_FLOOR} or newer. ` +
110
+ `NX_MIGRATE_CLI_VERSION is set to '${options.cliVersionSpec}'. ` +
111
+ `Unset it or set it to nx ${exports.NEW_MIGRATE_FLAGS_FLOOR} or newer.`);
112
+ }
113
+ const localNxVersion = options.readLocalNxVersion();
114
+ if (localNxVersion !== undefined &&
115
+ (localNxVersion === options.ownNxVersion ||
116
+ !(0, semver_1.lt)((0, version_utils_1.normalizeVersion)(localNxVersion), exports.NEW_MIGRATE_FLAGS_FLOOR))) {
117
+ // A pinned spec reaching this point failed to resolve: a resolved pin
118
+ // either returned 'temp-cli' or threw above.
119
+ if (options.fromEnvOverride) {
120
+ output_1.output.warn({
121
+ title: `The nx version pinned by NX_MIGRATE_CLI_VERSION ('${options.cliVersionSpec}') could not be resolved. Running ${flag} with the workspace's installed nx (${localNxVersion}) instead.`,
122
+ });
123
+ }
124
+ return 'local-nx';
125
+ }
126
+ const tempSideOutcome = resolved !== undefined
127
+ ? `resolves to ${resolved}, which does not support it`
128
+ : `could not be resolved`;
129
+ const localSideOutcome = localNxVersion !== undefined
130
+ ? `the workspace's installed nx (${localNxVersion}) does not support it either`
131
+ : `the workspace's installed nx version could not be read to verify support`;
132
+ // The worked example assumes the steady state, where 'latest' satisfies
133
+ // the floor: this branch then fires only when the spec could not be
134
+ // resolved (default or pinned), and updating the workspace to latest
135
+ // genuinely fixes it. Before the floor's stable release the example
136
+ // cannot resolve high enough; that window is deliberately not catered
137
+ // for, since no stable release carries the flags then anyway.
138
+ throw new Error(`${flag} requires nx ${exports.NEW_MIGRATE_FLAGS_FLOOR} or newer. ` +
139
+ `'${options.cliVersionSpec}' (the version 'nx migrate' would install) ${tempSideOutcome}, ` +
140
+ `and ${localSideOutcome}. ` +
141
+ `Update the workspace to nx ${exports.NEW_MIGRATE_FLAGS_FLOOR} or newer first, ` +
142
+ `for example by running 'nx migrate nx@latest' (without ${flag}) or by updating your dependencies.`);
143
+ }
144
+ /**
145
+ * Guard B (temp side, before hop B). The temp CLI knows the new flags, but the
146
+ * workspace-local nx it is about to hand off to may be older and would silently
147
+ * drop them.
148
+ *
149
+ * A workspace pinned to a feature-carrying 23.2.0 prerelease is refused here
150
+ * too: published prereleases that predate the feature cannot be told apart by
151
+ * version alone. Guard A's same-version bypass does not apply on this side
152
+ * because the invoking nx's version is not forwarded across hop A; the
153
+ * refusal names the workspace update that resolves it.
154
+ *
155
+ * `readLocalNxVersion` returning undefined does not block: the hand-off then
156
+ * resolves nx as it always does, which may fail visibly or land on another nx
157
+ * the package manager locates.
158
+ */
159
+ function assertWorkspaceNxSupportsNewMigrateFlags(options) {
160
+ const flag = findNewMigrateFlag(options.argv);
161
+ if (!flag) {
162
+ return;
163
+ }
164
+ const localNxVersion = options.readLocalNxVersion();
165
+ if (!localNxVersion) {
166
+ return;
167
+ }
168
+ if ((0, semver_1.lt)((0, version_utils_1.normalizeVersion)(localNxVersion), exports.NEW_MIGRATE_FLAGS_FLOOR)) {
169
+ // The worked example assumes the steady state (latest at or above the
170
+ // floor); the pre-floor stable window is deliberately not catered for.
171
+ throw new Error(`The workspace's installed nx (${localNxVersion}) does not support ${flag}. ` +
172
+ `Update the workspace to nx ${exports.NEW_MIGRATE_FLAGS_FLOOR} or newer first, ` +
173
+ `for example by running 'nx migrate nx@latest' (without ${flag}) or by updating your dependencies.`);
174
+ }
175
+ }
@@ -8,7 +8,7 @@ exports.connectExistingRepoToNxCloudPrompt = connectExistingRepoToNxCloudPrompt;
8
8
  exports.connectToNxCloudWithPrompt = connectToNxCloudWithPrompt;
9
9
  const tslib_1 = require("tslib");
10
10
  const path_1 = require("path");
11
- const handle_import_1 = require("../../../utils/handle-import");
11
+ const prompt_helpers_1 = require("../../../utils/prompt-helpers");
12
12
  const output_1 = require("../../../utils/output");
13
13
  const configuration_1 = require("../../../config/configuration");
14
14
  const tree_1 = require("../../../generators/tree");
@@ -26,7 +26,6 @@ const workspace_root_1 = require("../../../utils/workspace-root");
26
26
  const git_utils_1 = require("../../../utils/git-utils");
27
27
  const pc = tslib_1.__importStar(require("picocolors"));
28
28
  const ora = require('ora');
29
- const open = require('open');
30
29
  function onlyDefaultRunnerIsUsed(nxJson) {
31
30
  const defaultRunner = nxJson.tasksRunnerOptions?.default?.runner;
32
31
  if (!defaultRunner) {
@@ -161,6 +160,7 @@ async function runConnectToNxCloud(options, command) {
161
160
  try {
162
161
  const cloudConnectSpinner = ora(`Opening Nx Cloud ${connectCloudUrl} in your browser to connect your workspace.`).start();
163
162
  await sleep(2000);
163
+ const { default: open } = await new Function('return import("open")')();
164
164
  await open(connectCloudUrl);
165
165
  cloudConnectSpinner.succeed();
166
166
  }
@@ -248,23 +248,19 @@ function utmContentForCommand(command) {
248
248
  }
249
249
  async function nxCloudPrompt(key, utmContent) {
250
250
  const { message, choices, initial, footer, hint } = ab_testing_1.messages.getPrompt(key);
251
- const promptConfig = {
252
- name: 'NxCloud',
253
- message,
254
- type: 'autocomplete',
255
- choices,
256
- initial,
257
- }; // meeroslav: types in enquirer are not up to date
258
- if (footer) {
259
- promptConfig.footer = () => pc.dim(`${footer} ${(0, ab_testing_1.nxCloudHyperlink)(utmContent)}`);
260
- }
261
- if (hint) {
262
- promptConfig.hint = () => pc.dim(hint);
263
- }
264
- const enquirer = await (0, handle_import_1.handleImport)('enquirer');
265
- return await enquirer
266
- .prompt([promptConfig])
267
- .then((a) => {
268
- return a.NxCloud;
269
- });
251
+ // No separate footer/hint slot, so both are folded into the message.
252
+ const suffix = [hint, footer && `${footer} ${(0, ab_testing_1.nxCloudHyperlink)(utmContent)}`]
253
+ .filter(Boolean)
254
+ .map((t) => pc.dim(t));
255
+ return (await (0, prompt_helpers_1.selectPrompt)({
256
+ message: [message, ...suffix].join('\n'),
257
+ // These choices are `{ value, name }` where `name` is the display text,
258
+ // the inverse of enquirer's usual `{ name, message }`. Prefer `value` so
259
+ // the answer is the key the caller compares against, not the label.
260
+ choices: choices.map((c) => typeof c === 'string'
261
+ ? { value: c, label: c }
262
+ : { value: c.value ?? c.name, label: c.message ?? c.name ?? c.value }),
263
+ initial: choices[initial ?? 0]?.value ??
264
+ choices[initial ?? 0]?.name,
265
+ }));
270
266
  }
@@ -39,6 +39,8 @@ async function viewLogs() {
39
39
  return 1;
40
40
  }
41
41
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
42
+ // Intentionally not runNxSync: this invokes the separate `nx-cloud` binary,
43
+ // not the nx CLI that runNxSync resolves.
42
44
  (0, child_process_1.execSync)(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
43
45
  stdio: [0, 1, 2],
44
46
  windowsHide: true,
@@ -0,0 +1,2 @@
1
+ import { CommandModule } from 'yargs';
2
+ export declare const yargsStartNxAgentsCommand: CommandModule;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.yargsStartNxAgentsCommand = void 0;
4
+ const handle_import_1 = require("../../../utils/handle-import");
5
+ const shared_options_1 = require("../../yargs-utils/shared-options");
6
+ exports.yargsStartNxAgentsCommand = {
7
+ command: 'start-nx-agents [options]',
8
+ describe: 'Provisions Nx Agents for distributed task execution, reading configuration from `.nx/ci-config.yaml`. This command is an alias for [`nx-cloud start-nx-agents`](/docs/reference/nx-cloud-cli#nx-cloud-start-nx-agents).',
9
+ builder: (yargs) => (0, shared_options_1.withVerbose)(yargs)
10
+ .help(false)
11
+ .showHelpOnFail(false)
12
+ .option('help', { describe: 'Show help.', type: 'boolean' }),
13
+ handler: async (args) => {
14
+ process.exit(await (await (0, handle_import_1.handleImport)('./start-nx-agents.js', __dirname)).startNxAgentsHandler(args));
15
+ },
16
+ };
@@ -0,0 +1,4 @@
1
+ export interface StartNxAgentsArgs {
2
+ verbose?: boolean;
3
+ }
4
+ export declare function startNxAgentsHandler(args: StartNxAgentsArgs): Promise<number>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startNxAgentsHandler = startNxAgentsHandler;
4
+ const nx_json_1 = require("../../../config/nx-json");
5
+ const nx_cloud_utils_1 = require("../../../utils/nx-cloud-utils");
6
+ const utils_1 = require("../utils");
7
+ function startNxAgentsHandler(args) {
8
+ if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
9
+ (0, utils_1.warnNotConnectedToCloud)();
10
+ return Promise.resolve(0);
11
+ }
12
+ return (0, utils_1.executeNxCloudCommand)('start-nx-agents', args.verbose);
13
+ }