nx 23.2.0-beta.0 → 23.2.0-beta.10

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 (374) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/bin/nx.js +3 -1
  3. package/dist/release/changelog-renderer/index.js +4 -5
  4. package/dist/release/index.d.ts +1 -1
  5. package/dist/src/adapter/ngcli-adapter.js +60 -1
  6. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
  7. package/dist/src/analytics/analytics.d.ts +6 -0
  8. package/dist/src/analytics/analytics.js +16 -10
  9. package/dist/src/analytics/index.d.ts +1 -1
  10. package/dist/src/analytics/index.js +2 -1
  11. package/dist/src/command-line/add/add.js +5 -0
  12. package/dist/src/command-line/affected/affected.js +1 -0
  13. package/dist/src/command-line/completion/command-object.js +7 -12
  14. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
  15. package/dist/src/command-line/format/format.js +84 -101
  16. package/dist/src/command-line/generate/generate.js +35 -35
  17. package/dist/src/command-line/graph/graph.d.ts +1 -0
  18. package/dist/src/command-line/graph/graph.js +15 -6
  19. package/dist/src/command-line/import/import.js +30 -40
  20. package/dist/src/command-line/init/ai-agent-prompts.d.ts +1 -1
  21. package/dist/src/command-line/init/ai-agent-prompts.js +12 -17
  22. package/dist/src/command-line/init/command-object.js +14 -4
  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 +91 -0
  56. package/dist/src/command-line/migrate/execute-migration.js +474 -0
  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 +33 -19
  67. package/dist/src/command-line/migrate/migrate.d.ts +29 -113
  68. package/dist/src/command-line/migrate/migrate.js +666 -664
  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 +20 -2
  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/utils/shared.d.ts +2 -2
  120. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  121. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  122. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  123. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  124. package/dist/src/command-line/release/version/version-actions.js +9 -1
  125. package/dist/src/command-line/release/version.js +10 -6
  126. package/dist/src/command-line/reset/reset.js +6 -1
  127. package/dist/src/command-line/run/run-one.js +1 -0
  128. package/dist/src/command-line/run-many/run-many.js +1 -0
  129. package/dist/src/command-line/show/show-target/inputs.js +50 -153
  130. package/dist/src/command-line/show/show-target/outputs.js +48 -173
  131. package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
  132. package/dist/src/command-line/show/show-target/utils.js +83 -3
  133. package/dist/src/command-line/watch/watch.js +13 -0
  134. package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
  135. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  136. package/dist/src/commands-runner/create-command-graph.js +5 -0
  137. package/dist/src/config/misc-interfaces.d.ts +19 -7
  138. package/dist/src/config/nx-json.d.ts +5 -3
  139. package/dist/src/core/graph/main.js +1 -1
  140. package/dist/src/core/graph/styles.js +1 -1
  141. package/dist/src/daemon/client/client.d.ts +52 -1
  142. package/dist/src/daemon/client/client.js +160 -36
  143. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  144. package/dist/src/daemon/client/daemon-environment.js +110 -2
  145. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  146. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  147. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  148. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  149. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  150. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
  151. package/dist/src/daemon/server/latest-nx.js +5 -2
  152. package/dist/src/daemon/server/server.js +31 -4
  153. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  154. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  155. package/dist/src/daemon/socket-utils.d.ts +1 -0
  156. package/dist/src/daemon/socket-utils.js +24 -3
  157. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  158. package/dist/src/daemon/tmp-dir.js +437 -15
  159. package/dist/src/devkit-internals.d.ts +105 -8
  160. package/dist/src/devkit-internals.js +223 -7
  161. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  162. package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
  163. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  164. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  165. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  166. package/dist/src/generators/tree.d.ts +4 -2
  167. package/dist/src/generators/utils/nx-json.js +13 -3
  168. package/dist/src/hasher/check-task-files.d.ts +86 -0
  169. package/dist/src/hasher/check-task-files.js +378 -0
  170. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  171. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  172. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  173. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  174. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  175. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  176. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  177. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  178. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  179. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  180. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  181. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  182. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  183. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  184. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  185. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  186. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  187. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  188. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  189. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  190. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  191. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  192. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  193. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  194. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  195. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  196. package/dist/src/native/index.d.ts +37 -4
  197. package/dist/src/native/index.js +71 -28
  198. package/dist/src/native/native-bindings.js +3 -0
  199. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  200. package/dist/src/native/native-file-cache-location.js +86 -12
  201. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  202. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  203. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  204. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  205. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  206. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  207. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  208. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  209. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  210. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  211. package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
  212. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  213. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
  214. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  215. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  216. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  217. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
  218. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  219. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
  220. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  221. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  222. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  223. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  224. package/dist/src/project-graph/build-project-graph.js +7 -1
  225. package/dist/src/project-graph/error-types.d.ts +12 -1
  226. package/dist/src/project-graph/error-types.js +27 -2
  227. package/dist/src/project-graph/file-utils.js +6 -1
  228. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  229. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
  230. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  231. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  232. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  233. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
  234. package/dist/src/project-graph/project-graph.js +23 -0
  235. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
  236. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
  237. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
  238. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
  239. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
  240. package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
  241. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
  242. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
  243. package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
  244. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
  245. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
  246. package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
  247. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
  248. package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
  249. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  250. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  251. package/dist/src/tasks-runner/life-cycle.js +2 -2
  252. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +9 -4
  253. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
  254. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +28 -8
  255. package/dist/src/tasks-runner/life-cycles/performance-report.js +117 -30
  256. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  257. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  258. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  259. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  260. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  261. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  262. package/dist/src/tasks-runner/run-command.js +28 -35
  263. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  264. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  265. package/dist/src/tasks-runner/task-env.d.ts +9 -0
  266. package/dist/src/tasks-runner/task-env.js +31 -4
  267. package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
  268. package/dist/src/tasks-runner/task-orchestrator.js +182 -18
  269. package/dist/src/tasks-runner/utils.js +2 -6
  270. package/dist/src/utils/acknowledge-build-scripts.js +7 -5
  271. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  272. package/dist/src/utils/analytics-enabled.js +11 -0
  273. package/dist/src/utils/analytics-prompt.d.ts +0 -6
  274. package/dist/src/utils/analytics-prompt.js +4 -58
  275. package/dist/src/utils/assert-workspace-validity.js +7 -2
  276. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  277. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  278. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  279. package/dist/src/utils/catalog/bun-manager.js +130 -0
  280. package/dist/src/utils/catalog/index.d.ts +1 -1
  281. package/dist/src/utils/catalog/index.js +1 -1
  282. package/dist/src/utils/catalog/manager-factory.js +3 -0
  283. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  284. package/dist/src/utils/catalog/manager-utils.js +9 -4
  285. package/dist/src/utils/catalog/manager.d.ts +13 -1
  286. package/dist/src/utils/catalog/manager.js +30 -0
  287. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  288. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  289. package/dist/src/utils/catalog/types.d.ts +4 -0
  290. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  291. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  292. package/dist/src/utils/child-process.d.ts +31 -1
  293. package/dist/src/utils/child-process.js +103 -0
  294. package/dist/src/utils/chunkify.d.ts +7 -1
  295. package/dist/src/utils/chunkify.js +10 -3
  296. package/dist/src/utils/command-line-utils.js +30 -20
  297. package/dist/src/utils/exit-codes.d.ts +9 -0
  298. package/dist/src/utils/exit-codes.js +19 -0
  299. package/dist/src/utils/fileutils.d.ts +5 -0
  300. package/dist/src/utils/fileutils.js +7 -2
  301. package/dist/src/utils/formatters/index.d.ts +13 -0
  302. package/dist/src/utils/formatters/index.js +74 -0
  303. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  304. package/dist/src/utils/formatters/oxfmt.js +764 -0
  305. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  306. package/dist/src/utils/formatters/prettier.js +201 -0
  307. package/dist/src/utils/formatters/shared.d.ts +5 -0
  308. package/dist/src/utils/formatters/shared.js +8 -0
  309. package/dist/src/utils/git-revision.d.ts +12 -0
  310. package/dist/src/utils/git-revision.js +25 -0
  311. package/dist/src/utils/git-utils.d.ts +48 -2
  312. package/dist/src/utils/git-utils.js +220 -14
  313. package/dist/src/utils/git-worktrees.d.ts +30 -0
  314. package/dist/src/utils/git-worktrees.js +212 -0
  315. package/dist/src/utils/ignore.d.ts +170 -1
  316. package/dist/src/utils/ignore.js +263 -11
  317. package/dist/src/utils/long-running-target.d.ts +10 -0
  318. package/dist/src/utils/long-running-target.js +19 -0
  319. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  320. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  321. package/dist/src/utils/min-release-age/packument.js +1 -1
  322. package/dist/src/utils/nx-console-prompt.js +3 -6
  323. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  324. package/dist/src/utils/nx-tmp-dir.js +40 -0
  325. package/dist/src/utils/output.d.ts +153 -0
  326. package/dist/src/utils/output.js +289 -5
  327. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  328. package/dist/src/utils/owned-private-dir.js +323 -0
  329. package/dist/src/utils/package-json.d.ts +2 -0
  330. package/dist/src/utils/package-json.js +11 -7
  331. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  332. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  333. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  334. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  335. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  336. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  337. package/dist/src/utils/package-manager.d.ts +23 -2
  338. package/dist/src/utils/package-manager.js +268 -44
  339. package/dist/src/utils/params.d.ts +7 -1
  340. package/dist/src/utils/params.js +64 -6
  341. package/dist/src/utils/plugins/core-plugins.js +4 -0
  342. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  343. package/dist/src/utils/prompt-helpers.js +111 -0
  344. package/dist/src/utils/provenance.js +6 -14
  345. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  346. package/dist/src/utils/registry-config/bun.js +257 -0
  347. package/dist/src/utils/registry-config/index.d.ts +13 -0
  348. package/dist/src/utils/registry-config/index.js +102 -0
  349. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  350. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  351. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  352. package/dist/src/utils/registry-config/utils.js +496 -0
  353. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  354. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  355. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  356. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  357. package/dist/src/utils/safe-spawn.d.ts +24 -0
  358. package/dist/src/utils/safe-spawn.js +104 -0
  359. package/dist/src/utils/shell-quoting.d.ts +15 -0
  360. package/dist/src/utils/shell-quoting.js +35 -0
  361. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  362. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  363. package/dist/src/utils/workspace-id.d.ts +20 -0
  364. package/dist/src/utils/workspace-id.js +54 -0
  365. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  366. package/dist/src/utils/write-formatted-json-file.js +5 -4
  367. package/migrations.json +6 -0
  368. package/package.json +29 -19
  369. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
  370. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
  371. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  372. package/dist/src/utils/is-using-prettier.js +0 -62
  373. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  374. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -0,0 +1,91 @@
1
+ import { MigrationsJson } from '../../config/misc-interfaces';
2
+ import { FileChange } from '../../generators/tree';
3
+ import { ArrayPackageGroup, NxMigrationsConfiguration, PackageJson } from '../../utils/package-json';
4
+ interface PackageMigrationConfig extends NxMigrationsConfiguration {
5
+ packageJson: PackageJson;
6
+ packageGroup: ArrayPackageGroup;
7
+ }
8
+ export declare function readPackageMigrationConfig(packageName: string, dir: string): PackageMigrationConfig;
9
+ export declare function runInstall(nxWorkspaceRoot?: string, phase?: MigrationInstallPhase, rerunCommand?: string): Promise<void>;
10
+ export type MigrationInstallPhase = 'pre-migration' | 'post-migration';
11
+ export declare class NpmPeerDepsInstallError extends Error {
12
+ constructor();
13
+ }
14
+ /**
15
+ * Detects npm peer-dependency resolution failures. Keyed on the `ERESOLVE`
16
+ * error code, which npm consistently emits for this class of failure across
17
+ * v7+ (`npm ERR! code ERESOLVE` / `npm error code ERESOLVE`). Falls back to a
18
+ * small set of stable phrases in case the code line is missing from the
19
+ * captured output.
20
+ */
21
+ export declare function isNpmPeerDepsError(stderr: string): boolean;
22
+ export declare function formatSingleMigrationRerunCommand(migrationId: string): string;
23
+ export declare function logNpmPeerDepsError(phase: MigrationInstallPhase, rerunCommand?: string): void;
24
+ export declare function logSkippedPostMigrationInstall(root: string): void;
25
+ export declare class ChangedDepInstaller {
26
+ private readonly root;
27
+ private readonly shouldSkipInstall;
28
+ private readonly rerunCommand?;
29
+ private initialDeps;
30
+ private _skippedInstall;
31
+ private _installed;
32
+ constructor(root: string, shouldSkipInstall?: boolean, rerunCommand?: string);
33
+ get skippedInstall(): boolean;
34
+ /**
35
+ * Whether an install actually ran. Distinct from `!skippedInstall`, which is
36
+ * only about the skip-install flag: dependencies that never changed leave
37
+ * both false.
38
+ */
39
+ get installed(): boolean;
40
+ installDepsIfChanged(): Promise<void>;
41
+ }
42
+ export declare function runNxOrAngularMigration(root: string, migration: {
43
+ package: string;
44
+ name: string;
45
+ description?: string;
46
+ version: string;
47
+ }, isVerbose: boolean, captureGeneratorOutput?: boolean, resolvedCollection?: ResolvedMigrationCollection): Promise<{
48
+ changes: FileChange[];
49
+ nextSteps: string[];
50
+ agentContext: string[];
51
+ skipAgentic: boolean;
52
+ logs: string;
53
+ madeChanges: boolean;
54
+ }>;
55
+ /**
56
+ * The workspace's declared dependencies, serialized for equality comparison,
57
+ * or `null` when package.json could not be read or parsed. Callers that
58
+ * persist the value across processes need that distinction: an unreadable
59
+ * package.json is not an empty dependency set.
60
+ */
61
+ export declare function readPackageJsonDeps(root: string): string | null;
62
+ export declare function getStringifiedPackageJsonDeps(root: string): string;
63
+ export declare function runNxMigration(root: string, collectionPath: string, collection: MigrationsJson, name: string, migrationVersion: string | undefined, captureGeneratorOutput: boolean): Promise<{
64
+ changes: FileChange[];
65
+ nextSteps: string[];
66
+ agentContext: string[];
67
+ skipAgentic: boolean;
68
+ logs: string;
69
+ }>;
70
+ export declare function parseMigrationReturn(value: unknown): {
71
+ nextSteps: string[];
72
+ agentContext: string[];
73
+ skipAgentic: boolean;
74
+ };
75
+ export declare function filterStrings(value: unknown): string[];
76
+ export interface ResolvedMigrationCollection {
77
+ collection: MigrationsJson;
78
+ collectionPath: string;
79
+ }
80
+ export declare function readMigrationCollection(packageName: string, root: string): ResolvedMigrationCollection;
81
+ export declare function resolveDocumentationFileToWorkspacePath(root: string, migrationsDir: string, documentation: string): string | undefined;
82
+ export declare function getImplementationPath(collection: MigrationsJson, collectionPath: string, name: string, migrationVersion?: string): {
83
+ path: string;
84
+ fnSymbol: string;
85
+ };
86
+ export declare class MigrationImplementationMissingError extends Error {
87
+ constructor(baseMessage: string, collectionPath: string, migrationVersion: string | undefined);
88
+ }
89
+ export declare function isAngularMigration(collection: MigrationsJson, name: string): import("../../config/misc-interfaces").MigrationsJsonEntry;
90
+ export declare const getNgCompatLayer: () => Promise<typeof import("../../adapter/ngcli-adapter")>;
91
+ export {};
@@ -0,0 +1,474 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNgCompatLayer = exports.MigrationImplementationMissingError = exports.ChangedDepInstaller = exports.NpmPeerDepsInstallError = void 0;
4
+ exports.readPackageMigrationConfig = readPackageMigrationConfig;
5
+ exports.runInstall = runInstall;
6
+ exports.isNpmPeerDepsError = isNpmPeerDepsError;
7
+ exports.formatSingleMigrationRerunCommand = formatSingleMigrationRerunCommand;
8
+ exports.logNpmPeerDepsError = logNpmPeerDepsError;
9
+ exports.logSkippedPostMigrationInstall = logSkippedPostMigrationInstall;
10
+ exports.runNxOrAngularMigration = runNxOrAngularMigration;
11
+ exports.readPackageJsonDeps = readPackageJsonDeps;
12
+ exports.getStringifiedPackageJsonDeps = getStringifiedPackageJsonDeps;
13
+ exports.runNxMigration = runNxMigration;
14
+ exports.parseMigrationReturn = parseMigrationReturn;
15
+ exports.filterStrings = filterStrings;
16
+ exports.readMigrationCollection = readMigrationCollection;
17
+ exports.resolveDocumentationFileToWorkspacePath = resolveDocumentationFileToWorkspacePath;
18
+ exports.getImplementationPath = getImplementationPath;
19
+ exports.isAngularMigration = isAngularMigration;
20
+ const tslib_1 = require("tslib");
21
+ const pc = tslib_1.__importStar(require("picocolors"));
22
+ const child_process_1 = require("child_process");
23
+ const path_1 = require("path");
24
+ const semver_1 = require("semver");
25
+ const handle_import_1 = require("../../utils/handle-import");
26
+ const tree_1 = require("../../generators/tree");
27
+ const fileutils_1 = require("../../utils/fileutils");
28
+ const logger_1 = require("../../utils/logger");
29
+ const text_1 = require("./text");
30
+ const package_json_1 = require("../../utils/package-json");
31
+ const package_manager_1 = require("../../utils/package-manager");
32
+ const output_1 = require("../../utils/output");
33
+ const fs_1 = require("fs");
34
+ const installation_directory_1 = require("../../utils/installation-directory");
35
+ const shell_quoting_1 = require("../../utils/shell-quoting");
36
+ const project_graph_1 = require("../../project-graph/project-graph");
37
+ const version_utils_1 = require("./version-utils");
38
+ function readPackageMigrationConfig(packageName, dir) {
39
+ const { path: packageJsonPath, packageJson: json } = (0, package_json_1.readModulePackageJson)(packageName, (0, installation_directory_1.getNxRequirePaths)(dir));
40
+ const config = (0, package_json_1.readNxMigrateConfig)(json);
41
+ if (!config) {
42
+ return { packageJson: json, migrations: null, packageGroup: [] };
43
+ }
44
+ try {
45
+ const migrationFile = require.resolve(config.migrations, {
46
+ paths: [(0, path_1.dirname)(packageJsonPath)],
47
+ });
48
+ return {
49
+ packageJson: json,
50
+ migrations: migrationFile,
51
+ packageGroup: config.packageGroup,
52
+ supportsOptionalMigrations: config.supportsOptionalMigrations,
53
+ };
54
+ }
55
+ catch {
56
+ return {
57
+ packageJson: json,
58
+ migrations: null,
59
+ packageGroup: config.packageGroup,
60
+ supportsOptionalMigrations: config.supportsOptionalMigrations,
61
+ };
62
+ }
63
+ }
64
+ function runInstall(nxWorkspaceRoot, phase = 'pre-migration', rerunCommand) {
65
+ const cwd = nxWorkspaceRoot ?? process.cwd();
66
+ const packageManager = (0, package_manager_1.detectPackageManager)(cwd);
67
+ const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager, cwd);
68
+ const installCommand = `${pmCommands.install} ${pmCommands.ignoreScriptsFlag ?? ''}`;
69
+ output_1.output.log({
70
+ title: `Running '${installCommand}' to make sure necessary packages are installed`,
71
+ });
72
+ return new Promise((resolve, reject) => {
73
+ // For npm, pipe stderr so we can detect peer dependency errors while still
74
+ // mirroring it live to the user's terminal. Other package managers inherit
75
+ // stderr directly since we don't need to inspect their output.
76
+ const shouldCaptureStderr = packageManager === 'npm';
77
+ const child = (0, child_process_1.spawn)(installCommand, {
78
+ shell: true,
79
+ stdio: ['inherit', 'inherit', shouldCaptureStderr ? 'pipe' : 'inherit'],
80
+ windowsHide: true,
81
+ cwd,
82
+ });
83
+ const stderrChunks = [];
84
+ child.stderr?.on('data', (chunk) => {
85
+ process.stderr.write(chunk);
86
+ stderrChunks.push(chunk);
87
+ });
88
+ child.on('error', reject);
89
+ child.on('close', (code) => {
90
+ if (code === 0) {
91
+ resolve();
92
+ return;
93
+ }
94
+ if (shouldCaptureStderr) {
95
+ const stderr = Buffer.concat(stderrChunks).toString().trim();
96
+ if (isNpmPeerDepsError(stderr)) {
97
+ // Log the remediation guidance here so every caller of `runInstall`
98
+ // (CLI migrate, `nx repair`, single-migration runner, etc.) surfaces
99
+ // it consistently. Top-level callers catch `NpmPeerDepsInstallError`
100
+ // and return a non-zero exit code without re-logging.
101
+ logNpmPeerDepsError(phase, rerunCommand);
102
+ reject(new NpmPeerDepsInstallError());
103
+ return;
104
+ }
105
+ }
106
+ reject(new Error(`Command failed: ${installCommand}`));
107
+ });
108
+ });
109
+ }
110
+ class NpmPeerDepsInstallError extends Error {
111
+ constructor() {
112
+ super('npm install failed due to peer dependency conflicts.');
113
+ this.name = 'NpmPeerDepsInstallError';
114
+ }
115
+ }
116
+ exports.NpmPeerDepsInstallError = NpmPeerDepsInstallError;
117
+ /**
118
+ * Detects npm peer-dependency resolution failures. Keyed on the `ERESOLVE`
119
+ * error code, which npm consistently emits for this class of failure across
120
+ * v7+ (`npm ERR! code ERESOLVE` / `npm error code ERESOLVE`). Falls back to a
121
+ * small set of stable phrases in case the code line is missing from the
122
+ * captured output.
123
+ */
124
+ function isNpmPeerDepsError(stderr) {
125
+ if (/\bERESOLVE\b/.test(stderr)) {
126
+ return true;
127
+ }
128
+ const lowerStderr = stderr.toLowerCase();
129
+ return (lowerStderr.includes('unable to resolve dependency tree') ||
130
+ lowerStderr.includes('could not resolve dependency') ||
131
+ lowerStderr.includes('conflicting peer dependency'));
132
+ }
133
+ // The single-migration rerun command lands in copyable guidance (see
134
+ // `logNpmPeerDepsError` below), so quote ids a shell would split or expand.
135
+ // Single quotes stay literal in POSIX shells and PowerShell alike; double
136
+ // quotes would leave $-expansion active in both. The embedded-quote escape is
137
+ // the POSIX '\'' sequence, the one character PowerShell disagrees on (it wants
138
+ // ''). cmd.exe is knowingly not covered: it does not group on single quotes,
139
+ // and no quoting suppresses its %VAR% expansion.
140
+ function formatSingleMigrationRerunCommand(migrationId) {
141
+ const id = (0, shell_quoting_1.needsShellQuoting)(migrationId)
142
+ ? `'${migrationId.replace(/'/g, String.raw `'\''`)}'`
143
+ : migrationId;
144
+ return `nx migrate --run-migration=${id}`;
145
+ }
146
+ function logNpmPeerDepsError(phase, rerunCommand = 'nx migrate --run-migrations') {
147
+ const peerDepsResolutionSteps = [
148
+ 'Recommended approaches (in order of preference):',
149
+ '',
150
+ '1. Use "overrides" in package.json to force compatible versions across the dependency tree.',
151
+ ' See https://docs.npmjs.com/cli/configuring-npm/package-json#overrides',
152
+ '2. Persist legacy peer deps resolution in the project ".npmrc":',
153
+ ' npm config set legacy-peer-deps=true --location=project',
154
+ ' (bypasses peer dependency resolution; use with caution)',
155
+ '3. As a last resort, force the installation by running "npm install --force".',
156
+ ' (does not persist and may produce broken installs)',
157
+ ];
158
+ const manualInstallHint = [
159
+ 'If you installed the dependencies manually, pass "--skip-install" to avoid re-installing them:',
160
+ ` ${rerunCommand} --skip-install`,
161
+ ];
162
+ if (phase === 'pre-migration') {
163
+ output_1.output.error({
164
+ title: 'You need to resolve the peer dependency conflicts before the migration can continue',
165
+ bodyLines: [
166
+ ...peerDepsResolutionSteps,
167
+ '',
168
+ 'Once the conflicts are resolved, re-run the migration command:',
169
+ ` ${rerunCommand}`,
170
+ '',
171
+ ...manualInstallHint,
172
+ ],
173
+ });
174
+ }
175
+ else {
176
+ output_1.output.error({
177
+ title: 'Some migrations have been applied, but installing the updated dependencies failed',
178
+ bodyLines: [
179
+ ...peerDepsResolutionSteps,
180
+ '',
181
+ 'Once the conflicts are resolved, run "npm install" to install the updated dependencies.',
182
+ 'If the migration run was interrupted before completing, re-run it:',
183
+ ` ${rerunCommand}`,
184
+ '',
185
+ ...manualInstallHint,
186
+ ],
187
+ });
188
+ }
189
+ }
190
+ function logSkippedPostMigrationInstall(root) {
191
+ const packageManager = (0, package_manager_1.detectPackageManager)(root);
192
+ const installCommand = (0, package_manager_1.getPackageManagerCommand)(packageManager, root).install;
193
+ output_1.output.warn({
194
+ title: 'Migrations updated your dependencies, but the install was skipped',
195
+ bodyLines: [`Run "${installCommand}" to install the updated dependencies.`],
196
+ });
197
+ }
198
+ class ChangedDepInstaller {
199
+ constructor(root, shouldSkipInstall = false, rerunCommand) {
200
+ this.root = root;
201
+ this.shouldSkipInstall = shouldSkipInstall;
202
+ this.rerunCommand = rerunCommand;
203
+ this._skippedInstall = false;
204
+ this._installed = false;
205
+ this.initialDeps = getStringifiedPackageJsonDeps(root);
206
+ }
207
+ get skippedInstall() {
208
+ return this._skippedInstall;
209
+ }
210
+ /**
211
+ * Whether an install actually ran. Distinct from `!skippedInstall`, which is
212
+ * only about the skip-install flag: dependencies that never changed leave
213
+ * both false.
214
+ */
215
+ get installed() {
216
+ return this._installed;
217
+ }
218
+ async installDepsIfChanged() {
219
+ const currentDeps = getStringifiedPackageJsonDeps(this.root);
220
+ if (this.initialDeps !== currentDeps) {
221
+ if (this.shouldSkipInstall) {
222
+ this._skippedInstall = true;
223
+ }
224
+ else {
225
+ await runInstall(this.root, 'post-migration', this.rerunCommand);
226
+ this._installed = true;
227
+ }
228
+ }
229
+ this.initialDeps = currentDeps;
230
+ }
231
+ }
232
+ exports.ChangedDepInstaller = ChangedDepInstaller;
233
+ async function runNxOrAngularMigration(root, migration, isVerbose, captureGeneratorOutput = false, resolvedCollection) {
234
+ const { collection, collectionPath } = resolvedCollection ?? readMigrationCollection(migration.package, root);
235
+ let changes = [];
236
+ let nextSteps = [];
237
+ let agentContext = [];
238
+ // Angular schematics have no return channel, so they can never waive it.
239
+ let skipAgentic = false;
240
+ let logs = '';
241
+ // Angular's `ngResult.changes` is synthesized from the schematic's
242
+ // DryRunEvent stream so Nx and Angular paths can share commit/validation
243
+ // gating via `changes.length > 0`.
244
+ let madeChanges = false;
245
+ logger_1.logger.info(pc.dim('→ Running generator…'));
246
+ if (!isAngularMigration(collection, migration.name)) {
247
+ ({ nextSteps, changes, agentContext, skipAgentic, logs } =
248
+ await runNxMigration(root, collectionPath, collection, migration.name, migration.version, captureGeneratorOutput));
249
+ madeChanges = changes.length > 0;
250
+ logger_1.logger.info((0, text_1.singleLine)(`Ran ${migration.name} from ${migration.package}`));
251
+ if (migration.description) {
252
+ logger_1.logger.info((0, text_1.singleLine)(` ${migration.description}`));
253
+ }
254
+ logger_1.logger.info('');
255
+ if (!madeChanges) {
256
+ logger_1.logger.info(`No changes were made\n`);
257
+ return {
258
+ changes,
259
+ nextSteps,
260
+ agentContext,
261
+ skipAgentic,
262
+ logs,
263
+ madeChanges,
264
+ };
265
+ }
266
+ logger_1.logger.info('Changes:');
267
+ (0, tree_1.printChanges)(changes, ' ');
268
+ logger_1.logger.info('');
269
+ }
270
+ else {
271
+ const ngCliAdapter = await (0, exports.getNgCompatLayer)();
272
+ const migrationProjectGraph = await (0, project_graph_1.createProjectGraphAsync)();
273
+ const ngResult = await ngCliAdapter.runMigration(root, migration.package, migration.name, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(migrationProjectGraph).projects, isVerbose, migrationProjectGraph);
274
+ changes = ngResult.changes;
275
+ madeChanges = ngResult.madeChanges;
276
+ logs = ngResult.loggingQueue.join('\n');
277
+ logger_1.logger.info((0, text_1.singleLine)(`Ran ${migration.name} from ${migration.package}`));
278
+ if (migration.description) {
279
+ logger_1.logger.info((0, text_1.singleLine)(` ${migration.description}`));
280
+ }
281
+ logger_1.logger.info('');
282
+ if (!madeChanges) {
283
+ logger_1.logger.info(`No changes were made\n`);
284
+ return {
285
+ changes,
286
+ nextSteps,
287
+ agentContext,
288
+ skipAgentic,
289
+ logs,
290
+ madeChanges,
291
+ };
292
+ }
293
+ logger_1.logger.info('Changes:');
294
+ ngResult.loggingQueue.forEach((log) => logger_1.logger.info((0, text_1.singleLine)(' ' + log)));
295
+ logger_1.logger.info('');
296
+ }
297
+ return { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges };
298
+ }
299
+ /**
300
+ * The workspace's declared dependencies, serialized for equality comparison,
301
+ * or `null` when package.json could not be read or parsed. Callers that
302
+ * persist the value across processes need that distinction: an unreadable
303
+ * package.json is not an empty dependency set.
304
+ */
305
+ function readPackageJsonDeps(root) {
306
+ try {
307
+ const { dependencies, devDependencies } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
308
+ return JSON.stringify([dependencies, devDependencies]);
309
+ }
310
+ catch {
311
+ return null;
312
+ }
313
+ }
314
+ function getStringifiedPackageJsonDeps(root) {
315
+ // We don't really care if the .nx/installation property changes,
316
+ // whenever nxw is invoked it will handle the dep updates.
317
+ return readPackageJsonDeps(root) ?? '';
318
+ }
319
+ async function runNxMigration(root, collectionPath, collection, name, migrationVersion, captureGeneratorOutput) {
320
+ const { path: implPath, fnSymbol } = getImplementationPath(collection, collectionPath, name, migrationVersion);
321
+ const fn = require(implPath)[fnSymbol];
322
+ const host = new tree_1.FsTree(root, process.env.NX_VERBOSE_LOGGING === 'true', `migration ${collection.name}:${name}`);
323
+ let result;
324
+ let logs = '';
325
+ if (captureGeneratorOutput) {
326
+ const { withGeneratorOutputCapture } = require('./agentic/capture-generator-output');
327
+ ({ result, logs } = await withGeneratorOutputCapture(() => fn(host, {})));
328
+ }
329
+ else {
330
+ result = await fn(host, {});
331
+ }
332
+ const { nextSteps, agentContext, skipAgentic } = parseMigrationReturn(result);
333
+ host.lock();
334
+ const changes = host.listChanges();
335
+ (0, tree_1.flushChanges)(root, changes);
336
+ return { changes, nextSteps, agentContext, skipAgentic, logs };
337
+ }
338
+ function parseMigrationReturn(value) {
339
+ if (Array.isArray(value)) {
340
+ return {
341
+ nextSteps: filterStrings(value),
342
+ agentContext: [],
343
+ skipAgentic: false,
344
+ };
345
+ }
346
+ if (value && typeof value === 'object') {
347
+ const obj = value;
348
+ return {
349
+ nextSteps: filterStrings(obj.nextSteps),
350
+ agentContext: filterStrings(obj.agentContext),
351
+ // Strict, so a truthy non-boolean can't opt a migration out of its AI step.
352
+ skipAgentic: obj.skipAgentic === true,
353
+ };
354
+ }
355
+ // Catches `void`, mistakenly-returned generator callbacks, malformed values.
356
+ return { nextSteps: [], agentContext: [], skipAgentic: false };
357
+ }
358
+ // Bucket-level tolerance: a single non-string entry shouldn't discard the
359
+ // whole `nextSteps` / `agentContext` array. Migration authors occasionally
360
+ // push `null` / `undefined` / a number into the array; we drop the bad entries
361
+ // and keep the rest so end-of-run guidance isn't silently lost.
362
+ function filterStrings(value) {
363
+ if (!Array.isArray(value))
364
+ return [];
365
+ return value.filter((v) => typeof v === 'string');
366
+ }
367
+ function readMigrationCollection(packageName, root) {
368
+ const collectionPath = readPackageMigrationConfig(packageName, root).migrations;
369
+ const collection = (0, fileutils_1.readJsonFile)(collectionPath);
370
+ collection.name ??= packageName;
371
+ return {
372
+ collection,
373
+ collectionPath,
374
+ };
375
+ }
376
+ // Workspace-relative because the agent runs with cwd at the workspace root;
377
+ // absolute only for layouts that resolve outside it (hoisted/symlinked).
378
+ function resolveDocumentationFileToWorkspacePath(root, migrationsDir, documentation) {
379
+ let documentationFile;
380
+ try {
381
+ documentationFile = require.resolve(documentation, {
382
+ paths: [migrationsDir],
383
+ });
384
+ }
385
+ catch {
386
+ return undefined;
387
+ }
388
+ const relativePath = (0, path_1.relative)(root, documentationFile);
389
+ return relativePath.startsWith('..') ? documentationFile : relativePath;
390
+ }
391
+ function getImplementationPath(collection, collectionPath, name, migrationVersion) {
392
+ const g = collection.generators?.[name] || collection.schematics?.[name];
393
+ if (!g) {
394
+ throw new MigrationImplementationMissingError(`Unable to determine implementation path for "${collectionPath}:${name}"`, collectionPath, migrationVersion);
395
+ }
396
+ const implRelativePathAndMaybeSymbol = g.implementation || g.factory;
397
+ const [implRelativePath, fnSymbol = 'default'] = implRelativePathAndMaybeSymbol.split('#');
398
+ let implPath;
399
+ try {
400
+ implPath = require.resolve(implRelativePath, {
401
+ paths: [(0, path_1.dirname)(collectionPath)],
402
+ });
403
+ }
404
+ catch (e) {
405
+ try {
406
+ // workaround for a bug in node 12
407
+ implPath = require.resolve(`${(0, path_1.dirname)(collectionPath)}/${implRelativePath}`);
408
+ }
409
+ catch {
410
+ throw new MigrationImplementationMissingError(`Could not resolve implementation for migration "${name}" from "${collectionPath}"`, collectionPath, migrationVersion ?? g.version);
411
+ }
412
+ }
413
+ return { path: implPath, fnSymbol };
414
+ }
415
+ class MigrationImplementationMissingError extends Error {
416
+ constructor(baseMessage, collectionPath, migrationVersion) {
417
+ super(buildMigrationMissingMessage(baseMessage, collectionPath, migrationVersion));
418
+ this.name = 'MigrationImplementationMissingError';
419
+ }
420
+ }
421
+ exports.MigrationImplementationMissingError = MigrationImplementationMissingError;
422
+ function buildMigrationMissingMessage(baseMessage, collectionPath, migrationVersion) {
423
+ if (!migrationVersion) {
424
+ return baseMessage;
425
+ }
426
+ try {
427
+ const packageJsonPath = (0, path_1.join)((0, path_1.dirname)(collectionPath), 'package.json');
428
+ if (!(0, fs_1.existsSync)(packageJsonPath)) {
429
+ return baseMessage;
430
+ }
431
+ const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
432
+ const installedVersion = packageJson.version;
433
+ if (installedVersion &&
434
+ (0, semver_1.lt)((0, version_utils_1.normalizeVersion)(installedVersion), (0, version_utils_1.normalizeVersion)(migrationVersion))) {
435
+ const packageManager = (0, package_manager_1.detectPackageManager)();
436
+ const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
437
+ const overrideFieldName = getOverrideFieldName(packageManager);
438
+ return (`${baseMessage}\n\n` +
439
+ `The installed version of "${packageJson.name}" is ${installedVersion}, ` +
440
+ `but this migration requires version ${migrationVersion}. ` +
441
+ `This likely means the package version is being held back by an ${overrideFieldName} ` +
442
+ `in your package.json. ` +
443
+ `Remove the ${overrideFieldName} and run "${pmc.install}" to install the correct version.`);
444
+ }
445
+ }
446
+ catch {
447
+ // Fall through to return the base message if we can't read package info
448
+ }
449
+ return baseMessage;
450
+ }
451
+ function getOverrideFieldName(packageManager) {
452
+ switch (packageManager) {
453
+ case 'pnpm':
454
+ return '"pnpm.overrides"';
455
+ case 'yarn':
456
+ return '"resolutions"';
457
+ case 'npm':
458
+ case 'bun':
459
+ return '"overrides"';
460
+ }
461
+ }
462
+ function isAngularMigration(collection, name) {
463
+ return !collection.generators?.[name] && collection.schematics?.[name];
464
+ }
465
+ exports.getNgCompatLayer = (() => {
466
+ let _ngCliAdapter;
467
+ return async function getNgCompatLayer() {
468
+ if (!_ngCliAdapter) {
469
+ _ngCliAdapter = await (0, handle_import_1.handleImport)('../../adapter/ngcli-adapter.js', __dirname);
470
+ require('../../adapter/compat');
471
+ }
472
+ return _ngCliAdapter;
473
+ };
474
+ })();
@@ -67,5 +67,40 @@ export declare function reportMigrateRunError(opts: {
67
67
  migrationCount?: number;
68
68
  error?: unknown;
69
69
  }): void;
70
+ export declare function reportMigrateOrchestratorInit(opts: {
71
+ migrationCount: number;
72
+ createCommits: boolean;
73
+ }): void;
74
+ /**
75
+ * One event per orchestrator dispense. The `action` (dispense case) is a
76
+ * closed enum carried on a reused dimension, read conditioned on the event
77
+ * name (the same multiplexing pattern as {@link reportMigratePrompt});
78
+ * `attempt` rides the migration-count dimension.
79
+ */
80
+ export declare function reportMigrateOrchestratorDispense(opts: {
81
+ action: string;
82
+ attempt: number;
83
+ }): void;
84
+ /**
85
+ * Terminal funnel event. The two step tallies and the total dispense count
86
+ * ride reused numeric dimensions, read conditioned on the event name.
87
+ */
88
+ export declare function reportMigrateOrchestratorComplete(opts: {
89
+ completed: number;
90
+ skipped: number;
91
+ dispenseCount: number;
92
+ }): void;
93
+ /**
94
+ * Counts invocations, not completions: emitted as soon as the migration id
95
+ * resolves, while the worker can still stop before running anything.
96
+ *
97
+ * An invocation recorded into an orchestrated run (`--run-id`) gets its own
98
+ * event name. Every other one keeps the name `--run-migration` shipped with,
99
+ * so that series stays continuous for users who never enable the orchestrator.
100
+ */
101
+ export declare function reportMigrateSingleMigrationInvocation(opts: {
102
+ migrationType: 'generator' | 'prompt' | 'hybrid';
103
+ orchestrated: boolean;
104
+ }): void;
70
105
  export declare function computeMajorsCrossed(installed: string | null | undefined, target: string | null | undefined): number | undefined;
71
106
  export declare function safeReport(emit: () => void): void;
@@ -11,6 +11,10 @@ exports.reportMigrateRunStart = reportMigrateRunStart;
11
11
  exports.hasMigrateRunStarted = hasMigrateRunStarted;
12
12
  exports.reportMigrateRunComplete = reportMigrateRunComplete;
13
13
  exports.reportMigrateRunError = reportMigrateRunError;
14
+ exports.reportMigrateOrchestratorInit = reportMigrateOrchestratorInit;
15
+ exports.reportMigrateOrchestratorDispense = reportMigrateOrchestratorDispense;
16
+ exports.reportMigrateOrchestratorComplete = reportMigrateOrchestratorComplete;
17
+ exports.reportMigrateSingleMigrationInvocation = reportMigrateSingleMigrationInvocation;
14
18
  exports.computeMajorsCrossed = computeMajorsCrossed;
15
19
  exports.safeReport = safeReport;
16
20
  const semver_1 = require("semver");
@@ -180,6 +184,66 @@ function reportMigrateRunError(opts) {
180
184
  });
181
185
  });
182
186
  }
187
+ function reportMigrateOrchestratorInit(opts) {
188
+ safeReport(() => {
189
+ if (!analytics_1.customDimensions)
190
+ return;
191
+ (0, analytics_1.reportEvent)('migrate_orchestrator_init', {
192
+ [analytics_1.customDimensions.createCommits]: opts.createCommits,
193
+ [analytics_1.customDimensions.migrationCount]: opts.migrationCount,
194
+ });
195
+ });
196
+ }
197
+ /**
198
+ * One event per orchestrator dispense. The `action` (dispense case) is a
199
+ * closed enum carried on a reused dimension, read conditioned on the event
200
+ * name (the same multiplexing pattern as {@link reportMigratePrompt});
201
+ * `attempt` rides the migration-count dimension.
202
+ */
203
+ function reportMigrateOrchestratorDispense(opts) {
204
+ safeReport(() => {
205
+ if (!analytics_1.customDimensions)
206
+ return;
207
+ (0, analytics_1.reportEvent)('migrate_orchestrator_dispense', {
208
+ [analytics_1.customDimensions.promptChoice]: opts.action,
209
+ [analytics_1.customDimensions.migrationCount]: opts.attempt,
210
+ });
211
+ });
212
+ }
213
+ /**
214
+ * Terminal funnel event. The two step tallies and the total dispense count
215
+ * ride reused numeric dimensions, read conditioned on the event name.
216
+ */
217
+ function reportMigrateOrchestratorComplete(opts) {
218
+ safeReport(() => {
219
+ if (!analytics_1.customDimensions)
220
+ return;
221
+ (0, analytics_1.reportEvent)('migrate_orchestrator_complete', {
222
+ [analytics_1.customDimensions.appliedCount]: opts.completed,
223
+ [analytics_1.customDimensions.taskCount]: opts.skipped,
224
+ [analytics_1.customDimensions.migrationCount]: opts.dispenseCount,
225
+ });
226
+ });
227
+ }
228
+ /**
229
+ * Counts invocations, not completions: emitted as soon as the migration id
230
+ * resolves, while the worker can still stop before running anything.
231
+ *
232
+ * An invocation recorded into an orchestrated run (`--run-id`) gets its own
233
+ * event name. Every other one keeps the name `--run-migration` shipped with,
234
+ * so that series stays continuous for users who never enable the orchestrator.
235
+ */
236
+ function reportMigrateSingleMigrationInvocation(opts) {
237
+ safeReport(() => {
238
+ if (!analytics_1.customDimensions)
239
+ return;
240
+ (0, analytics_1.reportEvent)(opts.orchestrated
241
+ ? 'migrate_single_migration_recorded'
242
+ : 'migrate_single_migration_invocation', {
243
+ [analytics_1.customDimensions.promptChoice]: opts.migrationType,
244
+ });
245
+ });
246
+ }
183
247
  // `_migrate` runs either from a temp install of the latest CLI or from the
184
248
  // workspace-local installation; same signal as the run-phase re-dispatch
185
249
  // check in migrate.ts.