@ohos-ports/nx 23.2.1-beta.0 → 23.3.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1428) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +60 -13
  3. package/dist/bin/init-local.d.ts +8 -0
  4. package/dist/bin/init-local.js +192 -0
  5. package/dist/bin/nx-cloud.d.ts +3 -0
  6. package/dist/bin/nx-cloud.js +47 -0
  7. package/dist/bin/nx.d.ts +3 -0
  8. package/dist/bin/nx.js +341 -0
  9. package/dist/bin/post-install.d.ts +1 -0
  10. package/dist/bin/post-install.js +52 -0
  11. package/dist/bin/run-executor.d.ts +1 -0
  12. package/dist/bin/run-executor.js +66 -0
  13. package/dist/nx-cloud-internals.d.ts +1 -0
  14. package/dist/nx-cloud-internals.js +9 -0
  15. package/dist/plugins/package-json.d.ts +4 -0
  16. package/dist/plugins/package-json.js +40 -0
  17. package/dist/presets/core.json +1 -0
  18. package/dist/presets/npm.json +7 -0
  19. package/dist/release/changelog-renderer/index.d.ts +114 -0
  20. package/dist/release/changelog-renderer/index.js +397 -0
  21. package/dist/release/index.d.ts +4 -0
  22. package/dist/release/index.js +13 -0
  23. package/dist/src/adapter/angular-json.d.ts +10 -0
  24. package/dist/src/adapter/angular-json.js +129 -0
  25. package/dist/src/adapter/compat.d.ts +2 -0
  26. package/dist/src/adapter/compat.js +154 -0
  27. package/dist/src/adapter/ngcli-adapter.d.ts +105 -0
  28. package/dist/src/adapter/ngcli-adapter.js +1083 -0
  29. package/dist/src/adapter/rxjs-for-await.d.ts +109 -0
  30. package/dist/src/adapter/rxjs-for-await.js +362 -0
  31. package/dist/src/ai/clone-ai-config-repo.d.ts +11 -0
  32. package/dist/src/ai/clone-ai-config-repo.js +155 -0
  33. package/dist/src/ai/configure-ai-agents-disclaimer.d.ts +5 -0
  34. package/dist/src/ai/configure-ai-agents-disclaimer.js +31 -0
  35. package/dist/src/ai/constants.d.ts +46 -0
  36. package/dist/src/ai/constants.js +92 -0
  37. package/dist/src/ai/detect-ai-agent.d.ts +2 -0
  38. package/dist/src/ai/detect-ai-agent.js +12 -0
  39. package/dist/src/ai/set-up-ai-agents/get-agent-rules.d.ts +5 -0
  40. package/dist/src/ai/set-up-ai-agents/get-agent-rules.js +26 -0
  41. package/dist/src/ai/set-up-ai-agents/schema.d.ts +11 -0
  42. package/dist/src/ai/set-up-ai-agents/schema.json +34 -0
  43. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts +10 -0
  44. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +578 -0
  45. package/dist/src/ai/utils.d.ts +33 -0
  46. package/dist/src/ai/utils.js +246 -0
  47. package/dist/src/analytics/analytics.d.ts +16 -0
  48. package/dist/src/analytics/analytics.js +246 -0
  49. package/dist/src/analytics/index.d.ts +1 -0
  50. package/dist/src/analytics/index.js +12 -0
  51. package/dist/src/command-line/add/add.d.ts +3 -0
  52. package/dist/src/command-line/add/add.js +142 -0
  53. package/dist/src/command-line/add/command-object.d.ts +8 -0
  54. package/dist/src/command-line/add/command-object.js +28 -0
  55. package/dist/src/command-line/add/completion.d.ts +1 -0
  56. package/dist/src/command-line/add/completion.js +15 -0
  57. package/dist/src/command-line/affected/affected.d.ts +10 -0
  58. package/dist/src/command-line/affected/affected.js +151 -0
  59. package/dist/src/command-line/affected/command-object.d.ts +6 -0
  60. package/dist/src/command-line/affected/command-object.js +83 -0
  61. package/dist/src/command-line/affected/completion.d.ts +1 -0
  62. package/dist/src/command-line/affected/completion.js +15 -0
  63. package/dist/src/command-line/ai/ai-output.d.ts +46 -0
  64. package/dist/src/command-line/ai/ai-output.js +86 -0
  65. package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
  66. package/dist/src/command-line/completion/argv-layout.js +19 -0
  67. package/dist/src/command-line/completion/command-completions.d.ts +19 -0
  68. package/dist/src/command-line/completion/command-completions.js +120 -0
  69. package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
  70. package/dist/src/command-line/completion/command-handlers.js +69 -0
  71. package/dist/src/command-line/completion/command-object.d.ts +10 -0
  72. package/dist/src/command-line/completion/command-object.js +102 -0
  73. package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
  74. package/dist/src/command-line/completion/completion-providers.js +194 -0
  75. package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
  76. package/dist/src/command-line/completion/infix-targets.js +48 -0
  77. package/dist/src/command-line/completion/metadata.d.ts +22 -0
  78. package/dist/src/command-line/completion/metadata.js +71 -0
  79. package/dist/src/command-line/completion/registrations.d.ts +9 -0
  80. package/dist/src/command-line/completion/registrations.js +16 -0
  81. package/dist/src/command-line/completion/scripts/bash.sh +51 -0
  82. package/dist/src/command-line/completion/scripts/fish.fish +47 -0
  83. package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
  84. package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
  85. package/dist/src/command-line/completion/scripts.d.ts +18 -0
  86. package/dist/src/command-line/completion/scripts.js +140 -0
  87. package/dist/src/command-line/completion/trigger.d.ts +3 -0
  88. package/dist/src/command-line/completion/trigger.js +21 -0
  89. package/dist/src/command-line/completion/value-completions.d.ts +3 -0
  90. package/dist/src/command-line/completion/value-completions.js +21 -0
  91. package/dist/src/command-line/configure-ai-agents/command-object.d.ts +8 -0
  92. package/dist/src/command-line/configure-ai-agents/command-object.js +59 -0
  93. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.d.ts +3 -0
  94. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +436 -0
  95. package/dist/src/command-line/daemon/command-object.d.ts +3 -0
  96. package/dist/src/command-line/daemon/command-object.js +29 -0
  97. package/dist/src/command-line/daemon/daemon.d.ts +2 -0
  98. package/dist/src/command-line/daemon/daemon.js +31 -0
  99. package/dist/src/command-line/deprecated/command-objects.d.ts +9 -0
  100. package/dist/src/command-line/deprecated/command-objects.js +48 -0
  101. package/dist/src/command-line/examples.d.ts +12 -0
  102. package/dist/src/command-line/examples.js +403 -0
  103. package/dist/src/command-line/exec/command-object.d.ts +2 -0
  104. package/dist/src/command-line/exec/command-object.js +20 -0
  105. package/dist/src/command-line/exec/exec.d.ts +1 -0
  106. package/dist/src/command-line/exec/exec.js +143 -0
  107. package/dist/src/command-line/format/command-object.d.ts +3 -0
  108. package/dist/src/command-line/format/command-object.js +58 -0
  109. package/dist/src/command-line/format/format.d.ts +2 -0
  110. package/dist/src/command-line/format/format.js +200 -0
  111. package/dist/src/command-line/generate/command-object.d.ts +2 -0
  112. package/dist/src/command-line/generate/command-object.js +67 -0
  113. package/dist/src/command-line/generate/completion.d.ts +1 -0
  114. package/dist/src/command-line/generate/completion.js +9 -0
  115. package/dist/src/command-line/generate/generate.d.ts +21 -0
  116. package/dist/src/command-line/generate/generate.js +281 -0
  117. package/dist/src/command-line/generate/generator-utils.d.ts +18 -0
  118. package/dist/src/command-line/generate/generator-utils.js +91 -0
  119. package/dist/src/command-line/graph/command-object.d.ts +25 -0
  120. package/dist/src/command-line/graph/command-object.js +76 -0
  121. package/dist/src/command-line/graph/completion.d.ts +1 -0
  122. package/dist/src/command-line/graph/completion.js +13 -0
  123. package/dist/src/command-line/graph/graph.d.ts +101 -0
  124. package/dist/src/command-line/graph/graph.js +1080 -0
  125. package/dist/src/command-line/import/command-object.d.ts +2 -0
  126. package/dist/src/command-line/import/command-object.js +63 -0
  127. package/dist/src/command-line/import/import.d.ts +26 -0
  128. package/dist/src/command-line/import/import.js +590 -0
  129. package/dist/src/command-line/import/utils/ai-output.d.ts +93 -0
  130. package/dist/src/command-line/import/utils/ai-output.js +209 -0
  131. package/dist/src/command-line/import/utils/merge-remote-source.d.ts +2 -0
  132. package/dist/src/command-line/import/utils/merge-remote-source.js +14 -0
  133. package/dist/src/command-line/import/utils/prepare-source-repo.d.ts +2 -0
  134. package/dist/src/command-line/import/utils/prepare-source-repo.js +27 -0
  135. package/dist/src/command-line/index.d.ts +22 -0
  136. package/dist/src/command-line/index.js +26 -0
  137. package/dist/src/command-line/init/ai-agent-prompts.d.ts +2 -0
  138. package/dist/src/command-line/init/ai-agent-prompts.js +30 -0
  139. package/dist/src/command-line/init/command-object.d.ts +2 -0
  140. package/dist/src/command-line/init/command-object.js +118 -0
  141. package/dist/src/command-line/init/configure-plugins.d.ts +34 -0
  142. package/dist/src/command-line/init/configure-plugins.js +214 -0
  143. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +6 -0
  144. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +119 -0
  145. package/dist/src/command-line/init/implementation/add-nx-to-nest.d.ts +5 -0
  146. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +350 -0
  147. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +6 -0
  148. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +67 -0
  149. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  150. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +37 -0
  151. package/dist/src/command-line/init/implementation/angular/index.d.ts +2 -0
  152. package/dist/src/command-line/init/implementation/angular/index.js +127 -0
  153. package/dist/src/command-line/init/implementation/angular/integrated-workspace.d.ts +1 -0
  154. package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +9 -0
  155. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.d.ts +2 -0
  156. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +152 -0
  157. package/dist/src/command-line/init/implementation/angular/standalone-workspace.d.ts +1 -0
  158. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +204 -0
  159. package/dist/src/command-line/init/implementation/angular/types.d.ts +20 -0
  160. package/dist/src/command-line/init/implementation/angular/types.js +2 -0
  161. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.d.ts +15 -0
  162. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +136 -0
  163. package/dist/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  164. package/dist/src/command-line/init/implementation/deduce-default-base.js +53 -0
  165. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.d.ts +11 -0
  166. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +151 -0
  167. package/dist/src/command-line/init/implementation/dot-nx/nxw.d.ts +1 -0
  168. package/dist/src/command-line/init/implementation/dot-nx/nxw.js +123 -0
  169. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  170. package/dist/src/command-line/init/implementation/format.js +113 -0
  171. package/dist/src/command-line/init/implementation/utils.d.ts +34 -0
  172. package/dist/src/command-line/init/implementation/utils.js +419 -0
  173. package/dist/src/command-line/init/init-v1.d.ts +8 -0
  174. package/dist/src/command-line/init/init-v1.js +101 -0
  175. package/dist/src/command-line/init/init-v2.d.ts +23 -0
  176. package/dist/src/command-line/init/init-v2.js +619 -0
  177. package/dist/src/command-line/init/utils/ai-output.d.ts +72 -0
  178. package/dist/src/command-line/init/utils/ai-output.js +180 -0
  179. package/dist/src/command-line/list/command-object.d.ts +2 -0
  180. package/dist/src/command-line/list/command-object.js +21 -0
  181. package/dist/src/command-line/list/list.d.ts +15 -0
  182. package/dist/src/command-line/list/list.js +48 -0
  183. package/dist/src/command-line/mcp/command-object.d.ts +2 -0
  184. package/dist/src/command-line/mcp/command-object.js +29 -0
  185. package/dist/src/command-line/mcp/mcp.d.ts +2 -0
  186. package/dist/src/command-line/mcp/mcp.js +60 -0
  187. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +47 -0
  188. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +216 -0
  189. package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
  190. package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
  191. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  192. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  193. package/dist/src/command-line/migrate/agentic/definitions.d.ts +30 -0
  194. package/dist/src/command-line/migrate/agentic/definitions.js +207 -0
  195. package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
  196. package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
  197. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  198. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  199. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +61 -0
  200. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +78 -0
  201. package/dist/src/command-line/migrate/agentic/handoff.d.ts +102 -0
  202. package/dist/src/command-line/migrate/agentic/handoff.js +335 -0
  203. package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
  204. package/dist/src/command-line/migrate/agentic/inception.js +15 -0
  205. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
  206. package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
  207. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  208. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  209. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
  210. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
  211. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  212. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
  213. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +17 -0
  214. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +57 -0
  215. package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
  216. package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
  217. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
  218. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
  219. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +56 -0
  220. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +67 -0
  221. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +49 -0
  222. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +53 -0
  223. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +26 -0
  224. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +27 -0
  225. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +19 -0
  226. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +145 -0
  227. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +70 -0
  228. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +113 -0
  229. package/dist/src/command-line/migrate/agentic/run-step.d.ts +68 -0
  230. package/dist/src/command-line/migrate/agentic/run-step.js +148 -0
  231. package/dist/src/command-line/migrate/agentic/runner.d.ts +21 -0
  232. package/dist/src/command-line/migrate/agentic/runner.js +262 -0
  233. package/dist/src/command-line/migrate/agentic/select.d.ts +24 -0
  234. package/dist/src/command-line/migrate/agentic/select.js +251 -0
  235. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  236. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  237. package/dist/src/command-line/migrate/agentic/types.d.ts +147 -0
  238. package/dist/src/command-line/migrate/agentic/types.js +40 -0
  239. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  240. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  241. package/dist/src/command-line/migrate/command-object.d.ts +55 -0
  242. package/dist/src/command-line/migrate/command-object.js +162 -0
  243. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  244. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  245. package/dist/src/command-line/migrate/execute-migration.d.ts +97 -0
  246. package/dist/src/command-line/migrate/execute-migration.js +511 -0
  247. package/dist/src/command-line/migrate/migrate-analytics.d.ts +131 -0
  248. package/dist/src/command-line/migrate/migrate-analytics.js +378 -0
  249. package/dist/src/command-line/migrate/migrate-commits.d.ts +81 -0
  250. package/dist/src/command-line/migrate/migrate-commits.js +227 -0
  251. package/dist/src/command-line/migrate/migrate-config.d.ts +32 -0
  252. package/dist/src/command-line/migrate/migrate-config.js +120 -0
  253. package/dist/src/command-line/migrate/migrate-output.d.ts +214 -0
  254. package/dist/src/command-line/migrate/migrate-output.js +298 -0
  255. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +89 -0
  256. package/dist/src/command-line/migrate/migrate-ui-api.js +437 -0
  257. package/dist/src/command-line/migrate/migrate.d.ts +245 -0
  258. package/dist/src/command-line/migrate/migrate.js +2944 -0
  259. package/dist/src/command-line/migrate/migration-shape.d.ts +16 -0
  260. package/dist/src/command-line/migrate/migration-shape.js +13 -0
  261. package/dist/src/command-line/migrate/multi-major.d.ts +37 -0
  262. package/dist/src/command-line/migrate/multi-major.js +215 -0
  263. package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
  264. package/dist/src/command-line/migrate/prompt-files.js +134 -0
  265. package/dist/src/command-line/migrate/resolve-package-version.d.ts +24 -0
  266. package/dist/src/command-line/migrate/resolve-package-version.js +228 -0
  267. package/dist/src/command-line/migrate/run/agent-output.d.ts +31 -0
  268. package/dist/src/command-line/migrate/run/agent-output.js +84 -0
  269. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  270. package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
  271. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  272. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  273. package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
  274. package/dist/src/command-line/migrate/run/broker.js +568 -0
  275. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  276. package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
  277. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  278. package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
  279. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  280. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  281. package/dist/src/command-line/migrate/run/index.d.ts +12 -0
  282. package/dist/src/command-line/migrate/run/index.js +42 -0
  283. package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
  284. package/dist/src/command-line/migrate/run/issues.js +1121 -0
  285. package/dist/src/command-line/migrate/run/orchestrator.d.ts +78 -0
  286. package/dist/src/command-line/migrate/run/orchestrator.js +2272 -0
  287. package/dist/src/command-line/migrate/run/run-id.d.ts +8 -0
  288. package/dist/src/command-line/migrate/run/run-id.js +26 -0
  289. package/dist/src/command-line/migrate/run/run-state.d.ts +217 -0
  290. package/dist/src/command-line/migrate/run/run-state.js +669 -0
  291. package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
  292. package/dist/src/command-line/migrate/run/runbook.js +118 -0
  293. package/dist/src/command-line/migrate/run/state-lock.d.ts +56 -0
  294. package/dist/src/command-line/migrate/run/state-lock.js +202 -0
  295. package/dist/src/command-line/migrate/run/state-machine.d.ts +133 -0
  296. package/dist/src/command-line/migrate/run/state-machine.js +628 -0
  297. package/dist/src/command-line/migrate/run/util.d.ts +61 -0
  298. package/dist/src/command-line/migrate/run/util.js +169 -0
  299. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  300. package/dist/src/command-line/migrate/run/worker.js +843 -0
  301. package/dist/src/command-line/migrate/run-migration-process.js +110 -0
  302. package/dist/src/command-line/migrate/safe-prompt.d.ts +21 -0
  303. package/dist/src/command-line/migrate/safe-prompt.js +47 -0
  304. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  305. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  306. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  307. package/dist/src/command-line/migrate/step-actions.js +18 -0
  308. package/dist/src/command-line/migrate/text.d.ts +24 -0
  309. package/dist/src/command-line/migrate/text.js +51 -0
  310. package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
  311. package/dist/src/command-line/migrate/update-filters.js +45 -0
  312. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  313. package/dist/src/command-line/migrate/version-skew-guard.js +177 -0
  314. package/dist/src/command-line/migrate/version-utils.d.ts +5 -0
  315. package/dist/src/command-line/migrate/version-utils.js +52 -0
  316. package/dist/src/command-line/new/command-object.d.ts +2 -0
  317. package/dist/src/command-line/new/command-object.js +26 -0
  318. package/dist/src/command-line/new/new.d.ts +3 -0
  319. package/dist/src/command-line/new/new.js +30 -0
  320. package/dist/src/command-line/nx-cloud/apply-locally/apply-locally.d.ts +4 -0
  321. package/dist/src/command-line/nx-cloud/apply-locally/apply-locally.js +13 -0
  322. package/dist/src/command-line/nx-cloud/apply-locally/command-object.d.ts +2 -0
  323. package/dist/src/command-line/nx-cloud/apply-locally/command-object.js +16 -0
  324. package/dist/src/command-line/nx-cloud/complete-run/command-object.d.ts +2 -0
  325. package/dist/src/command-line/nx-cloud/complete-run/command-object.js +17 -0
  326. package/dist/src/command-line/nx-cloud/complete-run/stop-all-agents.d.ts +4 -0
  327. package/dist/src/command-line/nx-cloud/complete-run/stop-all-agents.js +13 -0
  328. package/dist/src/command-line/nx-cloud/connect/command-object.d.ts +3 -0
  329. package/dist/src/command-line/nx-cloud/connect/command-object.js +28 -0
  330. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.d.ts +13 -0
  331. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +260 -0
  332. package/dist/src/command-line/nx-cloud/connect/view-logs.d.ts +1 -0
  333. package/dist/src/command-line/nx-cloud/connect/view-logs.js +55 -0
  334. package/dist/src/command-line/nx-cloud/download-cloud-client/command-object.d.ts +2 -0
  335. package/dist/src/command-line/nx-cloud/download-cloud-client/command-object.js +13 -0
  336. package/dist/src/command-line/nx-cloud/download-cloud-client/download-cloud-client.d.ts +4 -0
  337. package/dist/src/command-line/nx-cloud/download-cloud-client/download-cloud-client.js +32 -0
  338. package/dist/src/command-line/nx-cloud/fix-ci/command-object.d.ts +2 -0
  339. package/dist/src/command-line/nx-cloud/fix-ci/command-object.js +16 -0
  340. package/dist/src/command-line/nx-cloud/fix-ci/fix-ci.d.ts +4 -0
  341. package/dist/src/command-line/nx-cloud/fix-ci/fix-ci.js +13 -0
  342. package/dist/src/command-line/nx-cloud/login/command-object.d.ts +2 -0
  343. package/dist/src/command-line/nx-cloud/login/command-object.js +20 -0
  344. package/dist/src/command-line/nx-cloud/login/login.d.ts +5 -0
  345. package/dist/src/command-line/nx-cloud/login/login.js +10 -0
  346. package/dist/src/command-line/nx-cloud/logout/command-object.d.ts +2 -0
  347. package/dist/src/command-line/nx-cloud/logout/command-object.js +16 -0
  348. package/dist/src/command-line/nx-cloud/logout/logout.d.ts +4 -0
  349. package/dist/src/command-line/nx-cloud/logout/logout.js +7 -0
  350. package/dist/src/command-line/nx-cloud/record/command-object.d.ts +2 -0
  351. package/dist/src/command-line/nx-cloud/record/command-object.js +19 -0
  352. package/dist/src/command-line/nx-cloud/record/record.d.ts +5 -0
  353. package/dist/src/command-line/nx-cloud/record/record.js +33 -0
  354. package/dist/src/command-line/nx-cloud/start-agent/command-object.d.ts +2 -0
  355. package/dist/src/command-line/nx-cloud/start-agent/command-object.js +16 -0
  356. package/dist/src/command-line/nx-cloud/start-agent/start-agent.d.ts +4 -0
  357. package/dist/src/command-line/nx-cloud/start-agent/start-agent.js +13 -0
  358. package/dist/src/command-line/nx-cloud/start-ci-run/command-object.d.ts +2 -0
  359. package/dist/src/command-line/nx-cloud/start-ci-run/command-object.js +16 -0
  360. package/dist/src/command-line/nx-cloud/start-ci-run/start-ci-run.d.ts +4 -0
  361. package/dist/src/command-line/nx-cloud/start-ci-run/start-ci-run.js +13 -0
  362. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  363. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  364. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  365. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  366. package/dist/src/command-line/nx-cloud/utils.d.ts +2 -0
  367. package/dist/src/command-line/nx-cloud/utils.js +34 -0
  368. package/dist/src/command-line/nx-commands.d.ts +10 -0
  369. package/dist/src/command-line/nx-commands.js +183 -0
  370. package/dist/src/command-line/register/command-object.d.ts +6 -0
  371. package/dist/src/command-line/register/command-object.js +27 -0
  372. package/dist/src/command-line/register/register.d.ts +2 -0
  373. package/dist/src/command-line/register/register.js +9 -0
  374. package/dist/src/command-line/release/changelog/commit-utils.d.ts +13 -0
  375. package/dist/src/command-line/release/changelog/commit-utils.js +63 -0
  376. package/dist/src/command-line/release/changelog/version-plan-filtering.d.ts +43 -0
  377. package/dist/src/command-line/release/changelog/version-plan-filtering.js +156 -0
  378. package/dist/src/command-line/release/changelog/version-plan-utils.d.ts +31 -0
  379. package/dist/src/command-line/release/changelog/version-plan-utils.js +92 -0
  380. package/dist/src/command-line/release/changelog.d.ts +28 -0
  381. package/dist/src/command-line/release/changelog.js +907 -0
  382. package/dist/src/command-line/release/command-object.d.ts +96 -0
  383. package/dist/src/command-line/release/command-object.js +342 -0
  384. package/dist/src/command-line/release/config/config.d.ts +70 -0
  385. package/dist/src/command-line/release/config/config.js +1204 -0
  386. package/dist/src/command-line/release/config/conventional-commits.d.ts +2 -0
  387. package/dist/src/command-line/release/config/conventional-commits.js +106 -0
  388. package/dist/src/command-line/release/config/deep-merge-json.d.ts +1 -0
  389. package/dist/src/command-line/release/config/deep-merge-json.js +28 -0
  390. package/dist/src/command-line/release/config/filter-release-groups.d.ts +23 -0
  391. package/dist/src/command-line/release/config/filter-release-groups.js +157 -0
  392. package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  393. package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
  394. package/dist/src/command-line/release/config/version-plans.d.ts +42 -0
  395. package/dist/src/command-line/release/config/version-plans.js +278 -0
  396. package/dist/src/command-line/release/index.d.ts +49 -0
  397. package/dist/src/command-line/release/index.js +49 -0
  398. package/dist/src/command-line/release/plan-check.d.ts +4 -0
  399. package/dist/src/command-line/release/plan-check.js +170 -0
  400. package/dist/src/command-line/release/plan.d.ts +4 -0
  401. package/dist/src/command-line/release/plan.js +248 -0
  402. package/dist/src/command-line/release/publish.d.ts +9 -0
  403. package/dist/src/command-line/release/publish.js +298 -0
  404. package/dist/src/command-line/release/release.d.ts +5 -0
  405. package/dist/src/command-line/release/release.js +299 -0
  406. package/dist/src/command-line/release/utils/diff.d.ts +21 -0
  407. package/dist/src/command-line/release/utils/diff.js +168 -0
  408. package/dist/src/command-line/release/utils/exec-command.d.ts +1 -0
  409. package/dist/src/command-line/release/utils/exec-command.js +34 -0
  410. package/dist/src/command-line/release/utils/generate-version-plan-content.d.ts +1 -0
  411. package/dist/src/command-line/release/utils/generate-version-plan-content.js +20 -0
  412. package/dist/src/command-line/release/utils/get-touched-projects-for-group.d.ts +7 -0
  413. package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +78 -0
  414. package/dist/src/command-line/release/utils/git.d.ts +126 -0
  415. package/dist/src/command-line/release/utils/git.js +597 -0
  416. package/dist/src/command-line/release/utils/launch-editor.d.ts +1 -0
  417. package/dist/src/command-line/release/utils/launch-editor.js +46 -0
  418. package/dist/src/command-line/release/utils/markdown.d.ts +6 -0
  419. package/dist/src/command-line/release/utils/markdown.js +28 -0
  420. package/dist/src/command-line/release/utils/print-changes.d.ts +6 -0
  421. package/dist/src/command-line/release/utils/print-changes.js +63 -0
  422. package/dist/src/command-line/release/utils/print-config.d.ts +7 -0
  423. package/dist/src/command-line/release/utils/print-config.js +36 -0
  424. package/dist/src/command-line/release/utils/release-graph.d.ts +248 -0
  425. package/dist/src/command-line/release/utils/release-graph.js +769 -0
  426. package/dist/src/command-line/release/utils/remote-release-clients/extract-repo-slug.d.ts +9 -0
  427. package/dist/src/command-line/release/utils/remote-release-clients/extract-repo-slug.js +61 -0
  428. package/dist/src/command-line/release/utils/remote-release-clients/github.d.ts +58 -0
  429. package/dist/src/command-line/release/utils/remote-release-clients/github.js +333 -0
  430. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.d.ts +62 -0
  431. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +259 -0
  432. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +113 -0
  433. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +172 -0
  434. package/dist/src/command-line/release/utils/repository-git-tags.d.ts +25 -0
  435. package/dist/src/command-line/release/utils/repository-git-tags.js +125 -0
  436. package/dist/src/command-line/release/utils/resolve-changelog-renderer.d.ts +2 -0
  437. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +22 -0
  438. package/dist/src/command-line/release/utils/resolve-nx-json-error-message.d.ts +1 -0
  439. package/dist/src/command-line/release/utils/resolve-nx-json-error-message.js +53 -0
  440. package/dist/src/command-line/release/utils/resolve-semver-specifier.d.ts +7 -0
  441. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +41 -0
  442. package/dist/src/command-line/release/utils/semver.d.ts +26 -0
  443. package/dist/src/command-line/release/utils/semver.js +111 -0
  444. package/dist/src/command-line/release/utils/shared-legacy.d.ts +25 -0
  445. package/dist/src/command-line/release/utils/shared-legacy.js +2 -0
  446. package/dist/src/command-line/release/utils/shared.d.ts +64 -0
  447. package/dist/src/command-line/release/utils/shared.js +379 -0
  448. package/dist/src/command-line/release/utils/version-plan-utils.d.ts +40 -0
  449. package/dist/src/command-line/release/utils/version-plan-utils.js +111 -0
  450. package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +8 -0
  451. package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.js +61 -0
  452. package/dist/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
  453. package/dist/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
  454. package/dist/src/command-line/release/version/project-logger.d.ts +8 -0
  455. package/dist/src/command-line/release/version/project-logger.js +47 -0
  456. package/dist/src/command-line/release/version/release-group-processor.d.ts +139 -0
  457. package/dist/src/command-line/release/version/release-group-processor.js +706 -0
  458. package/dist/src/command-line/release/version/resolve-current-version.d.ts +32 -0
  459. package/dist/src/command-line/release/version/resolve-current-version.js +240 -0
  460. package/dist/src/command-line/release/version/topological-sort.d.ts +9 -0
  461. package/dist/src/command-line/release/version/topological-sort.js +41 -0
  462. package/dist/src/command-line/release/version/version-actions.d.ts +227 -0
  463. package/dist/src/command-line/release/version/version-actions.js +255 -0
  464. package/dist/src/command-line/release/version.d.ts +28 -0
  465. package/dist/src/command-line/release/version.js +382 -0
  466. package/dist/src/command-line/repair/command-object.d.ts +2 -0
  467. package/dist/src/command-line/repair/command-object.js +21 -0
  468. package/dist/src/command-line/repair/repair.d.ts +3 -0
  469. package/dist/src/command-line/repair/repair.js +41 -0
  470. package/dist/src/command-line/report/command-object.d.ts +2 -0
  471. package/dist/src/command-line/report/command-object.js +12 -0
  472. package/dist/src/command-line/report/report.d.ts +73 -0
  473. package/dist/src/command-line/report/report.js +432 -0
  474. package/dist/src/command-line/reset/command-object.d.ts +8 -0
  475. package/dist/src/command-line/reset/command-object.js +27 -0
  476. package/dist/src/command-line/reset/reset.d.ts +2 -0
  477. package/dist/src/command-line/reset/reset.js +189 -0
  478. package/dist/src/command-line/run/command-object.d.ts +6 -0
  479. package/dist/src/command-line/run/command-object.js +43 -0
  480. package/dist/src/command-line/run/completion.d.ts +1 -0
  481. package/dist/src/command-line/run/completion.js +7 -0
  482. package/dist/src/command-line/run/executor-utils.d.ts +12 -0
  483. package/dist/src/command-line/run/executor-utils.js +96 -0
  484. package/dist/src/command-line/run/run-one.d.ts +17 -0
  485. package/dist/src/command-line/run/run-one.js +159 -0
  486. package/dist/src/command-line/run/run.d.ts +51 -0
  487. package/dist/src/command-line/run/run.js +179 -0
  488. package/dist/src/command-line/run-many/command-object.d.ts +2 -0
  489. package/dist/src/command-line/run-many/command-object.js +18 -0
  490. package/dist/src/command-line/run-many/completion.d.ts +1 -0
  491. package/dist/src/command-line/run-many/completion.js +13 -0
  492. package/dist/src/command-line/run-many/run-many.d.ts +10 -0
  493. package/dist/src/command-line/run-many/run-many.js +84 -0
  494. package/dist/src/command-line/show/command-object.d.ts +40 -0
  495. package/dist/src/command-line/show/command-object.js +237 -0
  496. package/dist/src/command-line/show/completion.d.ts +1 -0
  497. package/dist/src/command-line/show/completion.js +27 -0
  498. package/dist/src/command-line/show/project.d.ts +2 -0
  499. package/dist/src/command-line/show/project.js +103 -0
  500. package/dist/src/command-line/show/projects.d.ts +2 -0
  501. package/dist/src/command-line/show/projects.js +131 -0
  502. package/dist/src/command-line/show/show-target/index.d.ts +3 -0
  503. package/dist/src/command-line/show/show-target/index.js +9 -0
  504. package/dist/src/command-line/show/show-target/info.d.ts +28 -0
  505. package/dist/src/command-line/show/show-target/info.js +389 -0
  506. package/dist/src/command-line/show/show-target/inputs.d.ts +2 -0
  507. package/dist/src/command-line/show/show-target/inputs.js +83 -0
  508. package/dist/src/command-line/show/show-target/outputs.d.ts +2 -0
  509. package/dist/src/command-line/show/show-target/outputs.js +70 -0
  510. package/dist/src/command-line/show/show-target/utils.d.ts +54 -0
  511. package/dist/src/command-line/show/show-target/utils.js +265 -0
  512. package/dist/src/command-line/sync/command-object.d.ts +6 -0
  513. package/dist/src/command-line/sync/command-object.js +21 -0
  514. package/dist/src/command-line/sync/sync.d.ts +6 -0
  515. package/dist/src/command-line/sync/sync.js +120 -0
  516. package/dist/src/command-line/watch/command-object.d.ts +2 -0
  517. package/dist/src/command-line/watch/command-object.js +91 -0
  518. package/dist/src/command-line/watch/completion.d.ts +1 -0
  519. package/dist/src/command-line/watch/completion.js +10 -0
  520. package/dist/src/command-line/watch/watch.d.ts +31 -0
  521. package/dist/src/command-line/watch/watch.js +211 -0
  522. package/dist/src/command-line/yargs-utils/arguments-of.d.ts +11 -0
  523. package/dist/src/command-line/yargs-utils/arguments-of.js +9 -0
  524. package/dist/src/command-line/yargs-utils/documentation.d.ts +2 -0
  525. package/dist/src/command-line/yargs-utils/documentation.js +12 -0
  526. package/dist/src/command-line/yargs-utils/shared-options.d.ts +95 -0
  527. package/dist/src/command-line/yargs-utils/shared-options.js +431 -0
  528. package/dist/src/commands-runner/command-graph.d.ts +13 -0
  529. package/dist/src/commands-runner/command-graph.js +2 -0
  530. package/dist/src/commands-runner/create-command-graph.d.ts +4 -0
  531. package/dist/src/commands-runner/create-command-graph.js +72 -0
  532. package/dist/src/commands-runner/get-command-projects.d.ts +3 -0
  533. package/dist/src/commands-runner/get-command-projects.js +33 -0
  534. package/dist/src/config/calculate-default-project-name.d.ts +4 -0
  535. package/dist/src/config/calculate-default-project-name.js +41 -0
  536. package/dist/src/config/configuration.d.ts +8 -0
  537. package/dist/src/config/configuration.js +17 -0
  538. package/dist/src/config/misc-interfaces.d.ts +266 -0
  539. package/dist/src/config/misc-interfaces.js +2 -0
  540. package/dist/src/config/nx-json.d.ts +963 -0
  541. package/dist/src/config/nx-json.js +40 -0
  542. package/dist/src/config/project-graph.d.ts +137 -0
  543. package/dist/src/config/project-graph.js +45 -0
  544. package/dist/src/config/schema-utils.d.ts +37 -0
  545. package/dist/src/config/schema-utils.js +199 -0
  546. package/dist/src/config/task-graph.d.ts +6 -0
  547. package/dist/src/config/task-graph.js +2 -0
  548. package/dist/src/config/to-project-name.d.ts +5 -0
  549. package/dist/src/config/to-project-name.js +12 -0
  550. package/dist/src/config/workspace-json-project-json.d.ts +295 -0
  551. package/dist/src/config/workspace-json-project-json.js +2 -0
  552. package/dist/src/core/graph/environment.js +1 -0
  553. package/dist/src/core/graph/favicon.ico +0 -0
  554. package/dist/src/core/graph/index.html +32 -0
  555. package/dist/src/core/graph/main.js +1 -0
  556. package/dist/src/core/graph/runtime.js +1 -0
  557. package/dist/src/core/graph/styles.css +2 -0
  558. package/dist/src/core/graph/styles.js +1 -0
  559. package/dist/src/daemon/cache.d.ts +10 -0
  560. package/dist/src/daemon/cache.js +58 -0
  561. package/dist/src/daemon/client/client.d.ts +167 -0
  562. package/dist/src/daemon/client/client.js +1284 -0
  563. package/dist/src/daemon/client/daemon-environment.d.ts +74 -0
  564. package/dist/src/daemon/client/daemon-environment.js +422 -0
  565. package/dist/src/daemon/client/daemon-socket-messenger.d.ts +12 -0
  566. package/dist/src/daemon/client/daemon-socket-messenger.js +63 -0
  567. package/dist/src/daemon/is-nx-version-mismatch.d.ts +1 -0
  568. package/dist/src/daemon/is-nx-version-mismatch.js +8 -0
  569. package/dist/src/daemon/is-on-daemon.d.ts +1 -0
  570. package/dist/src/daemon/is-on-daemon.js +6 -0
  571. package/dist/src/daemon/is-v8-serializer-enabled.d.ts +5 -0
  572. package/dist/src/daemon/is-v8-serializer-enabled.js +10 -0
  573. package/dist/src/daemon/logger.d.ts +39 -0
  574. package/dist/src/daemon/logger.js +80 -0
  575. package/dist/src/daemon/message-types/configure-ai-agents.d.ts +20 -0
  576. package/dist/src/daemon/message-types/configure-ai-agents.js +19 -0
  577. package/dist/src/daemon/message-types/daemon-message.d.ts +39 -0
  578. package/dist/src/daemon/message-types/daemon-message.js +54 -0
  579. package/dist/src/daemon/message-types/flush-sync-generator-changes-to-disk.d.ts +6 -0
  580. package/dist/src/daemon/message-types/flush-sync-generator-changes-to-disk.js +11 -0
  581. package/dist/src/daemon/message-types/force-shutdown.d.ts +5 -0
  582. package/dist/src/daemon/message-types/force-shutdown.js +11 -0
  583. package/dist/src/daemon/message-types/get-context-file-data.d.ts +5 -0
  584. package/dist/src/daemon/message-types/get-context-file-data.js +11 -0
  585. package/dist/src/daemon/message-types/get-files-in-directory.d.ts +6 -0
  586. package/dist/src/daemon/message-types/get-files-in-directory.js +11 -0
  587. package/dist/src/daemon/message-types/get-nx-workspace-files.d.ts +6 -0
  588. package/dist/src/daemon/message-types/get-nx-workspace-files.js +11 -0
  589. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  590. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  591. package/dist/src/daemon/message-types/get-registered-sync-generators.d.ts +5 -0
  592. package/dist/src/daemon/message-types/get-registered-sync-generators.js +11 -0
  593. package/dist/src/daemon/message-types/get-sync-generator-changes.d.ts +6 -0
  594. package/dist/src/daemon/message-types/get-sync-generator-changes.js +11 -0
  595. package/dist/src/daemon/message-types/glob.d.ts +14 -0
  596. package/dist/src/daemon/message-types/glob.js +19 -0
  597. package/dist/src/daemon/message-types/hash-glob.d.ts +13 -0
  598. package/dist/src/daemon/message-types/hash-glob.js +19 -0
  599. package/dist/src/daemon/message-types/nx-console.d.ts +17 -0
  600. package/dist/src/daemon/message-types/nx-console.js +19 -0
  601. package/dist/src/daemon/message-types/register-project-graph-listener.d.ts +5 -0
  602. package/dist/src/daemon/message-types/register-project-graph-listener.js +11 -0
  603. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +14 -0
  604. package/dist/src/daemon/message-types/run-tasks-execution-hooks.js +19 -0
  605. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
  606. package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
  607. package/dist/src/daemon/message-types/streaming-messages.d.ts +14 -0
  608. package/dist/src/daemon/message-types/streaming-messages.js +19 -0
  609. package/dist/src/daemon/message-types/task-history.d.ts +19 -0
  610. package/dist/src/daemon/message-types/task-history.js +27 -0
  611. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  612. package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
  613. package/dist/src/daemon/message-types/update-workspace-context.d.ts +8 -0
  614. package/dist/src/daemon/message-types/update-workspace-context.js +11 -0
  615. package/dist/src/daemon/sandbox-socket-hint.d.ts +27 -0
  616. package/dist/src/daemon/sandbox-socket-hint.js +136 -0
  617. package/dist/src/daemon/server/client-socket-context.d.ts +23 -0
  618. package/dist/src/daemon/server/client-socket-context.js +88 -0
  619. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
  620. package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
  621. package/dist/src/daemon/server/file-watching/changed-projects.d.ts +10 -0
  622. package/dist/src/daemon/server/file-watching/changed-projects.js +53 -0
  623. package/dist/src/daemon/server/file-watching/file-change-events.d.ts +7 -0
  624. package/dist/src/daemon/server/file-watching/file-change-events.js +19 -0
  625. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +17 -0
  626. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +82 -0
  627. package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
  628. package/dist/src/daemon/server/handle-client-env.js +113 -0
  629. package/dist/src/daemon/server/handle-configure-ai-agents.d.ts +3 -0
  630. package/dist/src/daemon/server/handle-configure-ai-agents.js +101 -0
  631. package/dist/src/daemon/server/handle-context-file-data.d.ts +2 -0
  632. package/dist/src/daemon/server/handle-context-file-data.js +12 -0
  633. package/dist/src/daemon/server/handle-flush-sync-generator-changes-to-disk.d.ts +2 -0
  634. package/dist/src/daemon/server/handle-flush-sync-generator-changes-to-disk.js +11 -0
  635. package/dist/src/daemon/server/handle-force-shutdown.d.ts +5 -0
  636. package/dist/src/daemon/server/handle-force-shutdown.js +18 -0
  637. package/dist/src/daemon/server/handle-get-files-in-directory.d.ts +2 -0
  638. package/dist/src/daemon/server/handle-get-files-in-directory.js +12 -0
  639. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  640. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  641. package/dist/src/daemon/server/handle-get-registered-sync-generators.d.ts +2 -0
  642. package/dist/src/daemon/server/handle-get-registered-sync-generators.js +11 -0
  643. package/dist/src/daemon/server/handle-get-sync-generator-changes.d.ts +2 -0
  644. package/dist/src/daemon/server/handle-get-sync-generator-changes.js +20 -0
  645. package/dist/src/daemon/server/handle-glob.d.ts +3 -0
  646. package/dist/src/daemon/server/handle-glob.js +20 -0
  647. package/dist/src/daemon/server/handle-hash-glob.d.ts +3 -0
  648. package/dist/src/daemon/server/handle-hash-glob.js +20 -0
  649. package/dist/src/daemon/server/handle-hash-tasks.d.ts +20 -0
  650. package/dist/src/daemon/server/handle-hash-tasks.js +43 -0
  651. package/dist/src/daemon/server/handle-nx-console.d.ts +3 -0
  652. package/dist/src/daemon/server/handle-nx-console.js +54 -0
  653. package/dist/src/daemon/server/handle-nx-workspace-files.d.ts +2 -0
  654. package/dist/src/daemon/server/handle-nx-workspace-files.js +12 -0
  655. package/dist/src/daemon/server/handle-outputs-tracking.d.ts +15 -0
  656. package/dist/src/daemon/server/handle-outputs-tracking.js +35 -0
  657. package/dist/src/daemon/server/handle-process-in-background.d.ts +6 -0
  658. package/dist/src/daemon/server/handle-process-in-background.js +32 -0
  659. package/dist/src/daemon/server/handle-request-project-graph.d.ts +3 -0
  660. package/dist/src/daemon/server/handle-request-project-graph.js +36 -0
  661. package/dist/src/daemon/server/handle-request-shutdown.d.ts +5 -0
  662. package/dist/src/daemon/server/handle-request-shutdown.js +27 -0
  663. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
  664. package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
  665. package/dist/src/daemon/server/handle-task-history.d.ts +13 -0
  666. package/dist/src/daemon/server/handle-task-history.js +30 -0
  667. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +20 -0
  668. package/dist/src/daemon/server/handle-tasks-execution-hooks.js +35 -0
  669. package/dist/src/daemon/server/handle-update-workspace-context.d.ts +2 -0
  670. package/dist/src/daemon/server/handle-update-workspace-context.js +11 -0
  671. package/dist/src/daemon/server/handle-watch-events.d.ts +10 -0
  672. package/dist/src/daemon/server/handle-watch-events.js +85 -0
  673. package/dist/src/daemon/server/latest-nx.d.ts +10 -0
  674. package/dist/src/daemon/server/latest-nx.js +56 -0
  675. package/dist/src/daemon/server/nx-console-operations.d.ts +26 -0
  676. package/dist/src/daemon/server/nx-console-operations.js +97 -0
  677. package/dist/src/daemon/server/outputs-tracking.d.ts +11 -0
  678. package/dist/src/daemon/server/outputs-tracking.js +20 -0
  679. package/dist/src/daemon/server/planning-context.d.ts +8 -0
  680. package/dist/src/daemon/server/planning-context.js +18 -0
  681. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +62 -0
  682. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +690 -0
  683. package/dist/src/daemon/server/project-graph-listener-sockets.d.ts +7 -0
  684. package/dist/src/daemon/server/project-graph-listener-sockets.js +25 -0
  685. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  686. package/dist/src/daemon/server/restart-checks.js +77 -0
  687. package/dist/src/daemon/server/server.d.ts +11 -0
  688. package/dist/src/daemon/server/server.js +489 -0
  689. package/dist/src/daemon/server/shutdown-utils.d.ts +18 -0
  690. package/dist/src/daemon/server/shutdown-utils.js +136 -0
  691. package/dist/src/daemon/server/start.d.ts +1 -0
  692. package/dist/src/daemon/server/start.js +20 -0
  693. package/dist/src/daemon/server/sync-generators.d.ts +14 -0
  694. package/dist/src/daemon/server/sync-generators.js +368 -0
  695. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  696. package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
  697. package/dist/src/daemon/socket-utils.d.ts +43 -0
  698. package/dist/src/daemon/socket-utils.js +131 -0
  699. package/dist/src/daemon/tmp-dir.d.ts +62 -0
  700. package/dist/src/daemon/tmp-dir.js +477 -0
  701. package/dist/src/devkit-exports.d.ts +139 -0
  702. package/dist/src/devkit-exports.js +143 -0
  703. package/dist/src/devkit-internals.d.ts +146 -0
  704. package/dist/src/devkit-internals.js +336 -0
  705. package/dist/src/devkit-testing-exports.d.ts +2 -0
  706. package/dist/src/devkit-testing-exports.js +8 -0
  707. package/dist/src/executors/noop/noop.impl.d.ts +3 -0
  708. package/dist/src/executors/noop/noop.impl.js +6 -0
  709. package/dist/src/executors/noop/schema.json +10 -0
  710. package/dist/src/executors/run-commands/run-commands.impl.d.ts +60 -0
  711. package/dist/src/executors/run-commands/run-commands.impl.js +315 -0
  712. package/dist/src/executors/run-commands/running-tasks.d.ts +53 -0
  713. package/dist/src/executors/run-commands/running-tasks.js +603 -0
  714. package/dist/src/executors/run-commands/schema.json +198 -0
  715. package/dist/src/executors/run-script/run-script.impl.d.ts +8 -0
  716. package/dist/src/executors/run-script/run-script.impl.js +86 -0
  717. package/dist/src/executors/run-script/schema.json +28 -0
  718. package/dist/src/executors/utils/convert-nx-executor.d.ts +10 -0
  719. package/dist/src/executors/utils/convert-nx-executor.js +83 -0
  720. package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
  721. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  722. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +26 -0
  723. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +70 -0
  724. package/dist/src/generators/testing-utils/create-tree.d.ts +5 -0
  725. package/dist/src/generators/testing-utils/create-tree.js +14 -0
  726. package/dist/src/generators/tree.d.ts +127 -0
  727. package/dist/src/generators/tree.js +310 -0
  728. package/dist/src/generators/utils/generate-files.d.ts +44 -0
  729. package/dist/src/generators/utils/generate-files.js +114 -0
  730. package/dist/src/generators/utils/glob.d.ts +22 -0
  731. package/dist/src/generators/utils/glob.js +51 -0
  732. package/dist/src/generators/utils/json.d.ts +28 -0
  733. package/dist/src/generators/utils/json.js +48 -0
  734. package/dist/src/generators/utils/nx-json.d.ts +10 -0
  735. package/dist/src/generators/utils/nx-json.js +62 -0
  736. package/dist/src/generators/utils/project-configuration.d.ts +51 -0
  737. package/dist/src/generators/utils/project-configuration.js +299 -0
  738. package/dist/src/hasher/check-task-files.d.ts +86 -0
  739. package/dist/src/hasher/check-task-files.js +378 -0
  740. package/dist/src/hasher/create-task-hasher.d.ts +11 -0
  741. package/dist/src/hasher/create-task-hasher.js +25 -0
  742. package/dist/src/hasher/file-hasher.d.ts +3 -0
  743. package/dist/src/hasher/file-hasher.js +23 -0
  744. package/dist/src/hasher/hash-plan-inspector.d.ts +33 -0
  745. package/dist/src/hasher/hash-plan-inspector.js +70 -0
  746. package/dist/src/hasher/hash-task.d.ts +17 -0
  747. package/dist/src/hasher/hash-task.js +202 -0
  748. package/dist/src/hasher/native-task-hasher-impl.d.ts +34 -0
  749. package/dist/src/hasher/native-task-hasher-impl.js +104 -0
  750. package/dist/src/hasher/task-hasher.d.ts +177 -0
  751. package/dist/src/hasher/task-hasher.js +320 -0
  752. package/dist/src/hasher/task-planning-context.d.ts +13 -0
  753. package/dist/src/hasher/task-planning-context.js +12 -0
  754. package/dist/src/index.d.ts +1 -0
  755. package/dist/src/index.js +2 -0
  756. package/dist/src/migrations/update-15-0-0/prefix-outputs.d.ts +2 -0
  757. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +54 -0
  758. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +2 -0
  759. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +16 -0
  760. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +2 -0
  761. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +82 -0
  762. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +2 -0
  763. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +29 -0
  764. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +2 -0
  765. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +50 -0
  766. package/dist/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +12 -0
  767. package/dist/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +67 -0
  768. package/dist/src/migrations/update-17-0-0/move-cache-directory.d.ts +2 -0
  769. package/dist/src/migrations/update-17-0-0/move-cache-directory.js +35 -0
  770. package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
  771. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +2 -0
  772. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +72 -0
  773. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +2 -0
  774. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +126 -0
  775. package/dist/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
  776. package/dist/src/migrations/update-17-2-0/move-default-base.js +20 -0
  777. package/dist/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
  778. package/dist/src/migrations/update-17-3-0/update-nxw.js +7 -0
  779. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
  780. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +11 -0
  781. package/dist/src/migrations/update-19-2-0/move-workspace-data-directory.d.ts +4 -0
  782. package/dist/src/migrations/update-19-2-0/move-workspace-data-directory.js +33 -0
  783. package/dist/src/migrations/update-19-2-4/set-project-name.d.ts +2 -0
  784. package/dist/src/migrations/update-19-2-4/set-project-name.js +34 -0
  785. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.d.ts +2 -0
  786. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +25 -0
  787. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
  788. package/dist/src/migrations/update-20-0-1/use-legacy-cache.d.ts +2 -0
  789. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +20 -0
  790. package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
  791. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.d.ts +2 -0
  792. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +38 -0
  793. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
  794. package/dist/src/migrations/update-21-0-0/release-version-config-changes.d.ts +2 -0
  795. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +101 -0
  796. package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
  797. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
  798. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
  799. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
  800. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.d.ts +2 -0
  801. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +17 -0
  802. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
  803. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.d.ts +2 -0
  804. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +100 -0
  805. package/dist/src/migrations/update-22-0-0/release-version-config-changes.d.ts +2 -0
  806. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +101 -0
  807. package/dist/src/migrations/update-22-1-0/update-nx-wrapper.d.ts +2 -0
  808. package/dist/src/migrations/update-22-1-0/update-nx-wrapper.js +7 -0
  809. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.d.ts +2 -0
  810. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +19 -0
  811. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
  812. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.d.ts +2 -0
  813. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +16 -0
  814. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.d.ts +2 -0
  815. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +16 -0
  816. package/dist/src/migrations/update-22-6-0/enable-analytics-prompt.d.ts +2 -0
  817. package/dist/src/migrations/update-22-6-0/enable-analytics-prompt.js +23 -0
  818. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.d.ts +2 -0
  819. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +16 -0
  820. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
  821. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
  822. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
  823. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
  824. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  825. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  826. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  827. package/dist/src/migrations/utils/target-defaults.d.ts +28 -0
  828. package/dist/src/migrations/utils/target-defaults.js +46 -0
  829. package/dist/src/native/assert-supported-platform.d.ts +1 -0
  830. package/dist/src/native/assert-supported-platform.js +38 -0
  831. package/dist/src/native/browser.js +1 -0
  832. package/dist/src/native/index.d.ts +1419 -0
  833. package/dist/src/native/index.js +216 -0
  834. package/dist/src/native/native-bindings.js +654 -0
  835. package/dist/src/native/native-file-cache-location.d.ts +17 -0
  836. package/dist/src/native/native-file-cache-location.js +97 -0
  837. package/dist/src/native/nx.openharmony-arm64.node +0 -0
  838. package/dist/src/native/nx.wasi-browser.js +131 -0
  839. package/dist/src/native/nx.wasi.cjs +161 -0
  840. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  841. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  842. package/dist/src/native/transform-objects.d.ts +12 -0
  843. package/dist/src/native/transform-objects.js +97 -0
  844. package/dist/src/native/wasi-worker-browser.mjs +30 -0
  845. package/dist/src/native/wasi-worker.mjs +63 -0
  846. package/dist/src/nx-cloud/debug-logger.d.ts +1 -0
  847. package/dist/src/nx-cloud/debug-logger.js +8 -0
  848. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +14 -0
  849. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +166 -0
  850. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +41 -0
  851. package/dist/src/nx-cloud/models/onboarding-status.d.ts +1 -0
  852. package/dist/src/nx-cloud/models/onboarding-status.js +2 -0
  853. package/dist/src/nx-cloud/nx-cloud-tasks-runner-shell.d.ts +16 -0
  854. package/dist/src/nx-cloud/nx-cloud-tasks-runner-shell.js +41 -0
  855. package/dist/src/nx-cloud/resolution-helpers.d.ts +1 -0
  856. package/dist/src/nx-cloud/resolution-helpers.js +19 -0
  857. package/dist/src/nx-cloud/update-manager.d.ts +26 -0
  858. package/dist/src/nx-cloud/update-manager.js +274 -0
  859. package/dist/src/nx-cloud/utilities/client.d.ts +10 -0
  860. package/dist/src/nx-cloud/utilities/client.js +42 -0
  861. package/dist/src/nx-cloud/utilities/environment.d.ts +3 -0
  862. package/dist/src/nx-cloud/utilities/environment.js +48 -0
  863. package/dist/src/nx-cloud/utilities/get-cloud-options.d.ts +5 -0
  864. package/dist/src/nx-cloud/utilities/get-cloud-options.js +26 -0
  865. package/dist/src/nx-cloud/utilities/is-workspace-claimed.d.ts +1 -0
  866. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +26 -0
  867. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  868. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  869. package/dist/src/nx-cloud/utilities/onboarding.d.ts +5 -0
  870. package/dist/src/nx-cloud/utilities/onboarding.js +31 -0
  871. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +2 -0
  872. package/dist/src/nx-cloud/utilities/url-shorten.js +92 -0
  873. package/dist/src/plugins/js/hasher/hasher.d.ts +5 -0
  874. package/dist/src/plugins/js/hasher/hasher.js +51 -0
  875. package/dist/src/plugins/js/index.d.ts +4 -0
  876. package/dist/src/plugins/js/index.js +182 -0
  877. package/dist/src/plugins/js/lock-file/bun-parser.d.ts +14 -0
  878. package/dist/src/plugins/js/lock-file/bun-parser.js +992 -0
  879. package/dist/src/plugins/js/lock-file/lock-file.d.ts +85 -0
  880. package/dist/src/plugins/js/lock-file/lock-file.js +441 -0
  881. package/dist/src/plugins/js/lock-file/npm-parser.d.ts +10 -0
  882. package/dist/src/plugins/js/lock-file/npm-parser.js +595 -0
  883. package/dist/src/plugins/js/lock-file/pnpm-parser.d.ts +10 -0
  884. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1047 -0
  885. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +35 -0
  886. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +290 -0
  887. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +331 -0
  888. package/dist/src/plugins/js/lock-file/pruned-output.js +1465 -0
  889. package/dist/src/plugins/js/lock-file/utils/package-json.d.ts +10 -0
  890. package/dist/src/plugins/js/lock-file/utils/package-json.js +38 -0
  891. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +23 -0
  892. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +897 -0
  893. package/dist/src/plugins/js/lock-file/yarn-parser.d.ts +10 -0
  894. package/dist/src/plugins/js/lock-file/yarn-parser.js +536 -0
  895. package/dist/src/plugins/js/package-json/create-package-json.d.ts +29 -0
  896. package/dist/src/plugins/js/package-json/create-package-json.js +312 -0
  897. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +11 -0
  898. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +172 -0
  899. package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +12 -0
  900. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +145 -0
  901. package/dist/src/plugins/js/project-graph/affected/touched-projects.d.ts +2 -0
  902. package/dist/src/plugins/js/project-graph/affected/touched-projects.js +18 -0
  903. package/dist/src/plugins/js/project-graph/affected/tsconfig-json-changes.d.ts +4 -0
  904. package/dist/src/plugins/js/project-graph/affected/tsconfig-json-changes.js +63 -0
  905. package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +6 -0
  906. package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +45 -0
  907. package/dist/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +4 -0
  908. package/dist/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +88 -0
  909. package/dist/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +4 -0
  910. package/dist/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +75 -0
  911. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +81 -0
  912. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +468 -0
  913. package/dist/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.d.ts +2 -0
  914. package/dist/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.js +31 -0
  915. package/dist/src/plugins/js/utils/config.d.ts +2 -0
  916. package/dist/src/plugins/js/utils/config.js +61 -0
  917. package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.d.ts +2 -0
  918. package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.js +13 -0
  919. package/dist/src/plugins/js/utils/packages.d.ts +8 -0
  920. package/dist/src/plugins/js/utils/packages.js +91 -0
  921. package/dist/src/plugins/js/utils/register.d.ts +350 -0
  922. package/dist/src/plugins/js/utils/register.js +1279 -0
  923. package/dist/src/plugins/js/utils/resolve-relative-to-dir.d.ts +5 -0
  924. package/dist/src/plugins/js/utils/resolve-relative-to-dir.js +17 -0
  925. package/dist/src/plugins/js/utils/typescript.d.ts +32 -0
  926. package/dist/src/plugins/js/utils/typescript.js +157 -0
  927. package/dist/src/plugins/js/versions.d.ts +1 -0
  928. package/dist/src/plugins/js/versions.js +4 -0
  929. package/dist/src/plugins/package-json/create-nodes.d.ts +28 -0
  930. package/dist/src/plugins/package-json/create-nodes.js +243 -0
  931. package/dist/src/plugins/package-json/index.d.ts +2 -0
  932. package/dist/src/plugins/package-json/index.js +6 -0
  933. package/dist/src/plugins/project-json/build-nodes/project-json.d.ts +5 -0
  934. package/dist/src/plugins/project-json/build-nodes/project-json.js +33 -0
  935. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +25 -0
  936. package/dist/src/project-graph/affected/affected-project-graph-models.js +2 -0
  937. package/dist/src/project-graph/affected/affected-project-graph.d.ts +4 -0
  938. package/dist/src/project-graph/affected/affected-project-graph.js +77 -0
  939. package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
  940. package/dist/src/project-graph/affected/affected-projects.js +42 -0
  941. package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
  942. package/dist/src/project-graph/affected/affected-reasons.js +459 -0
  943. package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
  944. package/dist/src/project-graph/affected/affected-tasks.js +386 -0
  945. package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
  946. package/dist/src/project-graph/affected/print-explanation.js +44 -0
  947. package/dist/src/project-graph/build-project-graph.d.ts +26 -0
  948. package/dist/src/project-graph/build-project-graph.js +309 -0
  949. package/dist/src/project-graph/error-types.d.ts +156 -0
  950. package/dist/src/project-graph/error-types.js +523 -0
  951. package/dist/src/project-graph/file-map-utils.d.ts +18 -0
  952. package/dist/src/project-graph/file-map-utils.js +61 -0
  953. package/dist/src/project-graph/file-utils.d.ts +33 -0
  954. package/dist/src/project-graph/file-utils.js +196 -0
  955. package/dist/src/project-graph/nx-deps-cache.d.ts +65 -0
  956. package/dist/src/project-graph/nx-deps-cache.js +345 -0
  957. package/dist/src/project-graph/operators.d.ts +11 -0
  958. package/dist/src/project-graph/operators.js +70 -0
  959. package/dist/src/project-graph/plugins/get-plugins.d.ts +53 -0
  960. package/dist/src/project-graph/plugins/get-plugins.js +379 -0
  961. package/dist/src/project-graph/plugins/in-process-loader.d.ts +10 -0
  962. package/dist/src/project-graph/plugins/in-process-loader.js +58 -0
  963. package/dist/src/project-graph/plugins/index.d.ts +4 -0
  964. package/dist/src/project-graph/plugins/index.js +12 -0
  965. package/dist/src/project-graph/plugins/isolation/enabled.d.ts +1 -0
  966. package/dist/src/project-graph/plugins/isolation/enabled.js +19 -0
  967. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -0
  968. package/dist/src/project-graph/plugins/isolation/index.js +7 -0
  969. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +103 -0
  970. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +626 -0
  971. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +12 -0
  972. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +74 -0
  973. package/dist/src/project-graph/plugins/isolation/message-types.d.ts +59 -0
  974. package/dist/src/project-graph/plugins/isolation/message-types.js +9 -0
  975. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +156 -0
  976. package/dist/src/project-graph/plugins/isolation/messaging.js +87 -0
  977. package/dist/src/project-graph/plugins/isolation/plugin-lifecycle-manager.d.ts +82 -0
  978. package/dist/src/project-graph/plugins/isolation/plugin-lifecycle-manager.js +188 -0
  979. package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +2 -0
  980. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +225 -0
  981. package/dist/src/project-graph/plugins/isolation/worker-streaming.d.ts +14 -0
  982. package/dist/src/project-graph/plugins/isolation/worker-streaming.js +39 -0
  983. package/dist/src/project-graph/plugins/load-resolved-plugin.d.ts +3 -0
  984. package/dist/src/project-graph/plugins/load-resolved-plugin.js +24 -0
  985. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +44 -0
  986. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +117 -0
  987. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  988. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  989. package/dist/src/project-graph/plugins/public-api.d.ts +139 -0
  990. package/dist/src/project-graph/plugins/public-api.js +4 -0
  991. package/dist/src/project-graph/plugins/resolve-plugin.d.ts +25 -0
  992. package/dist/src/project-graph/plugins/resolve-plugin.js +277 -0
  993. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  994. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  995. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +4 -0
  996. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +80 -0
  997. package/dist/src/project-graph/plugins/transpiler.d.ts +20 -0
  998. package/dist/src/project-graph/plugins/transpiler.js +99 -0
  999. package/dist/src/project-graph/plugins/utils.d.ts +4 -0
  1000. package/dist/src/project-graph/plugins/utils.js +32 -0
  1001. package/dist/src/project-graph/project-graph-builder.d.ts +133 -0
  1002. package/dist/src/project-graph/project-graph-builder.js +395 -0
  1003. package/dist/src/project-graph/project-graph.d.ts +54 -0
  1004. package/dist/src/project-graph/project-graph.js +461 -0
  1005. package/dist/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
  1006. package/dist/src/project-graph/utils/build-all-workspace-files.js +14 -0
  1007. package/dist/src/project-graph/utils/find-project-for-path.d.ts +20 -0
  1008. package/dist/src/project-graph/utils/find-project-for-path.js +55 -0
  1009. package/dist/src/project-graph/utils/implicit-project-dependencies.d.ts +3 -0
  1010. package/dist/src/project-graph/utils/implicit-project-dependencies.js +18 -0
  1011. package/dist/src/project-graph/utils/normalize-project-nodes.d.ts +6 -0
  1012. package/dist/src/project-graph/utils/normalize-project-nodes.js +117 -0
  1013. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +48 -0
  1014. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +270 -0
  1015. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +49 -0
  1016. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +296 -0
  1017. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +34 -0
  1018. package/dist/src/project-graph/utils/project-configuration/source-maps.js +85 -0
  1019. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +50 -0
  1020. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +466 -0
  1021. package/dist/src/project-graph/utils/project-configuration/target-merging.d.ts +32 -0
  1022. package/dist/src/project-graph/utils/project-configuration/target-merging.js +574 -0
  1023. package/dist/src/project-graph/utils/project-configuration/target-normalization.d.ts +12 -0
  1024. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +396 -0
  1025. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +39 -0
  1026. package/dist/src/project-graph/utils/project-configuration/utils.js +216 -0
  1027. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +86 -0
  1028. package/dist/src/project-graph/utils/project-configuration-utils.js +325 -0
  1029. package/dist/src/project-graph/utils/retrieve-workspace-files.d.ts +35 -0
  1030. package/dist/src/project-graph/utils/retrieve-workspace-files.js +110 -0
  1031. package/dist/src/tasks-runner/batch/batch-messages.d.ts +35 -0
  1032. package/dist/src/tasks-runner/batch/batch-messages.js +9 -0
  1033. package/dist/src/tasks-runner/batch/run-batch.d.ts +1 -0
  1034. package/dist/src/tasks-runner/batch/run-batch.js +93 -0
  1035. package/dist/src/tasks-runner/cache.d.ts +129 -0
  1036. package/dist/src/tasks-runner/cache.js +645 -0
  1037. package/dist/src/tasks-runner/create-task-graph.d.ts +64 -0
  1038. package/dist/src/tasks-runner/create-task-graph.js +360 -0
  1039. package/dist/src/tasks-runner/default-tasks-runner.d.ts +25 -0
  1040. package/dist/src/tasks-runner/default-tasks-runner.js +74 -0
  1041. package/dist/src/tasks-runner/fork.d.ts +1 -0
  1042. package/dist/src/tasks-runner/fork.js +73 -0
  1043. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +45 -0
  1044. package/dist/src/tasks-runner/forked-process-task-runner.js +309 -0
  1045. package/dist/src/tasks-runner/init-tasks-runner.d.ts +12 -0
  1046. package/dist/src/tasks-runner/init-tasks-runner.js +124 -0
  1047. package/dist/src/tasks-runner/is-tui-enabled.d.ts +18 -0
  1048. package/dist/src/tasks-runner/is-tui-enabled.js +94 -0
  1049. package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
  1050. package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
  1051. package/dist/src/tasks-runner/life-cycle.d.ts +93 -0
  1052. package/dist/src/tasks-runner/life-cycle.js +155 -0
  1053. package/dist/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts +25 -0
  1054. package/dist/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +366 -0
  1055. package/dist/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.d.ts +24 -0
  1056. package/dist/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +238 -0
  1057. package/dist/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.d.ts +5 -0
  1058. package/dist/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +16 -0
  1059. package/dist/src/tasks-runner/life-cycles/formatting-utils.d.ts +3 -0
  1060. package/dist/src/tasks-runner/life-cycles/formatting-utils.js +55 -0
  1061. package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.d.ts +13 -0
  1062. package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +67 -0
  1063. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +173 -0
  1064. package/dist/src/tasks-runner/life-cycles/performance-analysis.js +508 -0
  1065. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +59 -0
  1066. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +193 -0
  1067. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +77 -0
  1068. package/dist/src/tasks-runner/life-cycles/performance-report.js +428 -0
  1069. package/dist/src/tasks-runner/life-cycles/pretty-time.d.ts +4 -0
  1070. package/dist/src/tasks-runner/life-cycles/pretty-time.js +73 -0
  1071. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +54 -0
  1072. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +203 -0
  1073. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +54 -0
  1074. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +193 -0
  1075. package/dist/src/tasks-runner/life-cycles/store-run-information-life-cycle.d.ts +17 -0
  1076. package/dist/src/tasks-runner/life-cycles/store-run-information-life-cycle.js +87 -0
  1077. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  1078. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  1079. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +11 -0
  1080. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +91 -0
  1081. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +16 -0
  1082. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +117 -0
  1083. package/dist/src/tasks-runner/life-cycles/task-profiling-life-cycle.d.ts +14 -0
  1084. package/dist/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +73 -0
  1085. package/dist/src/tasks-runner/life-cycles/task-results-life-cycle.d.ts +6 -0
  1086. package/dist/src/tasks-runner/life-cycles/task-results-life-cycle.js +17 -0
  1087. package/dist/src/tasks-runner/life-cycles/task-telemetry-life-cycle.d.ts +9 -0
  1088. package/dist/src/tasks-runner/life-cycles/task-telemetry-life-cycle.js +42 -0
  1089. package/dist/src/tasks-runner/life-cycles/task-timings-life-cycle.d.ts +8 -0
  1090. package/dist/src/tasks-runner/life-cycles/task-timings-life-cycle.js +39 -0
  1091. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +19 -0
  1092. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +339 -0
  1093. package/dist/src/tasks-runner/life-cycles/view-logs-utils.d.ts +1 -0
  1094. package/dist/src/tasks-runner/life-cycles/view-logs-utils.js +15 -0
  1095. package/dist/src/tasks-runner/process-metrics-service.d.ts +53 -0
  1096. package/dist/src/tasks-runner/process-metrics-service.js +161 -0
  1097. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  1098. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  1099. package/dist/src/tasks-runner/pseudo-ipc.d.ts +48 -0
  1100. package/dist/src/tasks-runner/pseudo-ipc.js +157 -0
  1101. package/dist/src/tasks-runner/pseudo-terminal.d.ts +72 -0
  1102. package/dist/src/tasks-runner/pseudo-terminal.js +209 -0
  1103. package/dist/src/tasks-runner/remove-old-cache-records.d.ts +1 -0
  1104. package/dist/src/tasks-runner/remove-old-cache-records.js +60 -0
  1105. package/dist/src/tasks-runner/run-command.d.ts +78 -0
  1106. package/dist/src/tasks-runner/run-command.js +971 -0
  1107. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +148 -0
  1108. package/dist/src/tasks-runner/running-tasks/batch-process.js +362 -0
  1109. package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +40 -0
  1110. package/dist/src/tasks-runner/running-tasks/node-child-process.js +175 -0
  1111. package/dist/src/tasks-runner/running-tasks/noop-child-process.d.ts +16 -0
  1112. package/dist/src/tasks-runner/running-tasks/noop-child-process.js +22 -0
  1113. package/dist/src/tasks-runner/running-tasks/output-prefix.d.ts +13 -0
  1114. package/dist/src/tasks-runner/running-tasks/output-prefix.js +63 -0
  1115. package/dist/src/tasks-runner/running-tasks/running-task.d.ts +11 -0
  1116. package/dist/src/tasks-runner/running-tasks/running-task.js +6 -0
  1117. package/dist/src/tasks-runner/running-tasks/shared-running-task.d.ts +15 -0
  1118. package/dist/src/tasks-runner/running-tasks/shared-running-task.js +41 -0
  1119. package/dist/src/tasks-runner/task-env-paths.d.ts +1 -0
  1120. package/dist/src/tasks-runner/task-env-paths.js +45 -0
  1121. package/dist/src/tasks-runner/task-env.d.ts +56 -0
  1122. package/dist/src/tasks-runner/task-env.js +237 -0
  1123. package/dist/src/tasks-runner/task-graph-utils.d.ts +30 -0
  1124. package/dist/src/tasks-runner/task-graph-utils.js +225 -0
  1125. package/dist/src/tasks-runner/task-io-service.d.ts +104 -0
  1126. package/dist/src/tasks-runner/task-io-service.js +131 -0
  1127. package/dist/src/tasks-runner/task-orchestrator.d.ts +330 -0
  1128. package/dist/src/tasks-runner/task-orchestrator.js +1749 -0
  1129. package/dist/src/tasks-runner/tasks-runner.d.ts +26 -0
  1130. package/dist/src/tasks-runner/tasks-runner.js +2 -0
  1131. package/dist/src/tasks-runner/tasks-schedule.d.ts +48 -0
  1132. package/dist/src/tasks-runner/tasks-schedule.js +258 -0
  1133. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  1134. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  1135. package/dist/src/tasks-runner/utils.d.ts +66 -0
  1136. package/dist/src/tasks-runner/utils.js +459 -0
  1137. package/dist/src/ultracache/config.d.ts +21 -0
  1138. package/dist/src/ultracache/config.js +29 -0
  1139. package/dist/src/ultracache/fetch.d.ts +21 -0
  1140. package/dist/src/ultracache/fetch.js +43 -0
  1141. package/dist/src/ultracache/overrides.d.ts +17 -0
  1142. package/dist/src/ultracache/overrides.js +61 -0
  1143. package/dist/src/ultracache/report.d.ts +13 -0
  1144. package/dist/src/ultracache/report.js +62 -0
  1145. package/dist/src/ultracache/store.d.ts +41 -0
  1146. package/dist/src/ultracache/store.js +158 -0
  1147. package/dist/src/utils/ab-testing.d.ts +62 -0
  1148. package/dist/src/utils/ab-testing.js +145 -0
  1149. package/dist/src/utils/acknowledge-build-scripts.d.ts +13 -0
  1150. package/dist/src/utils/acknowledge-build-scripts.js +102 -0
  1151. package/dist/src/utils/all-file-data.d.ts +2 -0
  1152. package/dist/src/utils/all-file-data.js +8 -0
  1153. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  1154. package/dist/src/utils/analytics-enabled.js +11 -0
  1155. package/dist/src/utils/analytics-prompt.d.ts +9 -0
  1156. package/dist/src/utils/analytics-prompt.js +81 -0
  1157. package/dist/src/utils/assert-workspace-validity.d.ts +3 -0
  1158. package/dist/src/utils/assert-workspace-validity.js +90 -0
  1159. package/dist/src/utils/async-iterator.d.ts +2 -0
  1160. package/dist/src/utils/async-iterator.js +18 -0
  1161. package/dist/src/utils/binary-extensions.d.ts +1 -0
  1162. package/dist/src/utils/binary-extensions.js +279 -0
  1163. package/dist/src/utils/cache-directory.d.ts +68 -0
  1164. package/dist/src/utils/cache-directory.js +337 -0
  1165. package/dist/src/utils/call-sites.d.ts +14 -0
  1166. package/dist/src/utils/call-sites.js +28 -0
  1167. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  1168. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  1169. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  1170. package/dist/src/utils/catalog/bun-manager.js +130 -0
  1171. package/dist/src/utils/catalog/index.d.ts +22 -0
  1172. package/dist/src/utils/catalog/index.js +87 -0
  1173. package/dist/src/utils/catalog/manager-factory.d.ts +5 -0
  1174. package/dist/src/utils/catalog/manager-factory.js +23 -0
  1175. package/dist/src/utils/catalog/manager-utils.d.ts +15 -0
  1176. package/dist/src/utils/catalog/manager-utils.js +237 -0
  1177. package/dist/src/utils/catalog/manager.d.ts +52 -0
  1178. package/dist/src/utils/catalog/manager.js +43 -0
  1179. package/dist/src/utils/catalog/pnpm-manager.d.ts +23 -0
  1180. package/dist/src/utils/catalog/pnpm-manager.js +142 -0
  1181. package/dist/src/utils/catalog/types.d.ts +15 -0
  1182. package/dist/src/utils/catalog/types.js +2 -0
  1183. package/dist/src/utils/catalog/yarn-manager.d.ts +26 -0
  1184. package/dist/src/utils/catalog/yarn-manager.js +130 -0
  1185. package/dist/src/utils/child-process.d.ts +52 -0
  1186. package/dist/src/utils/child-process.js +194 -0
  1187. package/dist/src/utils/chunkify.d.ts +11 -0
  1188. package/dist/src/utils/chunkify.js +45 -0
  1189. package/dist/src/utils/code-frames.d.ts +14 -0
  1190. package/dist/src/utils/code-frames.js +116 -0
  1191. package/dist/src/utils/command-line-utils.d.ts +77 -0
  1192. package/dist/src/utils/command-line-utils.js +266 -0
  1193. package/dist/src/utils/compile-cache.d.ts +24 -0
  1194. package/dist/src/utils/compile-cache.js +49 -0
  1195. package/dist/src/utils/consume-messages-from-socket.d.ts +44 -0
  1196. package/dist/src/utils/consume-messages-from-socket.js +291 -0
  1197. package/dist/src/utils/create-cli-options.d.ts +6 -0
  1198. package/dist/src/utils/create-cli-options.js +29 -0
  1199. package/dist/src/utils/db-connection.d.ts +16 -0
  1200. package/dist/src/utils/db-connection.js +58 -0
  1201. package/dist/src/utils/default-base.d.ts +1 -0
  1202. package/dist/src/utils/default-base.js +17 -0
  1203. package/dist/src/utils/delayed-spinner.d.ts +51 -0
  1204. package/dist/src/utils/delayed-spinner.js +88 -0
  1205. package/dist/src/utils/dotenv.d.ts +7 -0
  1206. package/dist/src/utils/dotenv.js +19 -0
  1207. package/dist/src/utils/enable-compile-cache.d.ts +1 -0
  1208. package/dist/src/utils/enable-compile-cache.js +7 -0
  1209. package/dist/src/utils/exit-codes.d.ts +24 -0
  1210. package/dist/src/utils/exit-codes.js +94 -0
  1211. package/dist/src/utils/fileutils.d.ts +72 -0
  1212. package/dist/src/utils/fileutils.js +117 -0
  1213. package/dist/src/utils/find-matching-projects.d.ts +18 -0
  1214. package/dist/src/utils/find-matching-projects.js +222 -0
  1215. package/dist/src/utils/find-workspace-root.d.ts +11 -0
  1216. package/dist/src/utils/find-workspace-root.js +33 -0
  1217. package/dist/src/utils/formatters/index.d.ts +19 -0
  1218. package/dist/src/utils/formatters/index.js +79 -0
  1219. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  1220. package/dist/src/utils/formatters/oxfmt.js +764 -0
  1221. package/dist/src/utils/formatters/prettier.d.ts +18 -0
  1222. package/dist/src/utils/formatters/prettier.js +179 -0
  1223. package/dist/src/utils/formatters/shared.d.ts +5 -0
  1224. package/dist/src/utils/formatters/shared.js +8 -0
  1225. package/dist/src/utils/get-package-name-from-import-path.d.ts +1 -0
  1226. package/dist/src/utils/get-package-name-from-import-path.js +17 -0
  1227. package/dist/src/utils/git-revision.d.ts +12 -0
  1228. package/dist/src/utils/git-revision.js +25 -0
  1229. package/dist/src/utils/git-utils.d.ts +125 -0
  1230. package/dist/src/utils/git-utils.index-filter.d.ts +1 -0
  1231. package/dist/src/utils/git-utils.index-filter.js +23 -0
  1232. package/dist/src/utils/git-utils.js +991 -0
  1233. package/dist/src/utils/git-utils.tree-filter.d.ts +1 -0
  1234. package/dist/src/utils/git-utils.tree-filter.js +47 -0
  1235. package/dist/src/utils/git-worktrees.d.ts +30 -0
  1236. package/dist/src/utils/git-worktrees.js +212 -0
  1237. package/dist/src/utils/globs.d.ts +3 -0
  1238. package/dist/src/utils/globs.js +18 -0
  1239. package/dist/src/utils/handle-errors.d.ts +1 -0
  1240. package/dist/src/utils/handle-errors.js +53 -0
  1241. package/dist/src/utils/handle-import.d.ts +15 -0
  1242. package/dist/src/utils/handle-import.js +86 -0
  1243. package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
  1244. package/dist/src/utils/has-nx-js-plugin.js +24 -0
  1245. package/dist/src/utils/http-client.d.ts +27 -0
  1246. package/dist/src/utils/http-client.js +193 -0
  1247. package/dist/src/utils/ignore.d.ts +178 -0
  1248. package/dist/src/utils/ignore.js +294 -0
  1249. package/dist/src/utils/installation-directory.d.ts +2 -0
  1250. package/dist/src/utils/installation-directory.js +12 -0
  1251. package/dist/src/utils/installed-nx-version.d.ts +23 -0
  1252. package/dist/src/utils/installed-nx-version.js +67 -0
  1253. package/dist/src/utils/is-ci.d.ts +1 -0
  1254. package/dist/src/utils/is-ci.js +26 -0
  1255. package/dist/src/utils/is-sandbox.d.ts +1 -0
  1256. package/dist/src/utils/is-sandbox.js +11 -0
  1257. package/dist/src/utils/json-diff.d.ts +20 -0
  1258. package/dist/src/utils/json-diff.js +24 -0
  1259. package/dist/src/utils/json.d.ts +44 -0
  1260. package/dist/src/utils/json.js +62 -0
  1261. package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
  1262. package/dist/src/utils/kill-child-on-host-exit.js +42 -0
  1263. package/dist/src/utils/legacy-task-history.d.ts +8 -0
  1264. package/dist/src/utils/legacy-task-history.js +87 -0
  1265. package/dist/src/utils/logger.d.ts +23 -0
  1266. package/dist/src/utils/logger.js +74 -0
  1267. package/dist/src/utils/long-running-target.d.ts +10 -0
  1268. package/dist/src/utils/long-running-target.js +19 -0
  1269. package/dist/src/utils/machine-id-cache.d.ts +5 -0
  1270. package/dist/src/utils/machine-id-cache.js +93 -0
  1271. package/dist/src/utils/min-release-age/behavior/bun.d.ts +30 -0
  1272. package/dist/src/utils/min-release-age/behavior/bun.js +274 -0
  1273. package/dist/src/utils/min-release-age/behavior/npm.d.ts +21 -0
  1274. package/dist/src/utils/min-release-age/behavior/npm.js +296 -0
  1275. package/dist/src/utils/min-release-age/behavior/pnpm.d.ts +23 -0
  1276. package/dist/src/utils/min-release-age/behavior/pnpm.js +535 -0
  1277. package/dist/src/utils/min-release-age/behavior/yarn.d.ts +22 -0
  1278. package/dist/src/utils/min-release-age/behavior/yarn.js +314 -0
  1279. package/dist/src/utils/min-release-age/constants.d.ts +3 -0
  1280. package/dist/src/utils/min-release-age/constants.js +8 -0
  1281. package/dist/src/utils/min-release-age/errors.d.ts +28 -0
  1282. package/dist/src/utils/min-release-age/errors.js +22 -0
  1283. package/dist/src/utils/min-release-age/packument.d.ts +13 -0
  1284. package/dist/src/utils/min-release-age/packument.js +34 -0
  1285. package/dist/src/utils/min-release-age/pick.d.ts +72 -0
  1286. package/dist/src/utils/min-release-age/pick.js +206 -0
  1287. package/dist/src/utils/min-release-age/pnpm-exclude-writer.d.ts +12 -0
  1288. package/dist/src/utils/min-release-age/pnpm-exclude-writer.js +58 -0
  1289. package/dist/src/utils/min-release-age/policy.d.ts +38 -0
  1290. package/dist/src/utils/min-release-age/policy.js +59 -0
  1291. package/dist/src/utils/min-release-age/resolve.d.ts +8 -0
  1292. package/dist/src/utils/min-release-age/resolve.js +14 -0
  1293. package/dist/src/utils/nx-cloud-utils.d.ts +6 -0
  1294. package/dist/src/utils/nx-cloud-utils.js +33 -0
  1295. package/dist/src/utils/nx-console-prompt.d.ts +1 -0
  1296. package/dist/src/utils/nx-console-prompt.js +61 -0
  1297. package/dist/src/utils/nx-key.d.ts +6 -0
  1298. package/dist/src/utils/nx-key.js +50 -0
  1299. package/dist/src/utils/nx-package-group.d.ts +8 -0
  1300. package/dist/src/utils/nx-package-group.js +15 -0
  1301. package/dist/src/utils/nx-tmp-dir.d.ts +23 -0
  1302. package/dist/src/utils/nx-tmp-dir.js +45 -0
  1303. package/dist/src/utils/object-sort.d.ts +1 -0
  1304. package/dist/src/utils/object-sort.js +9 -0
  1305. package/dist/src/utils/output.d.ts +251 -0
  1306. package/dist/src/utils/output.js +571 -0
  1307. package/dist/src/utils/owned-private-dir.d.ts +145 -0
  1308. package/dist/src/utils/owned-private-dir.js +362 -0
  1309. package/dist/src/utils/package-json.d.ts +256 -0
  1310. package/dist/src/utils/package-json.js +441 -0
  1311. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  1312. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  1313. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  1314. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  1315. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  1316. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  1317. package/dist/src/utils/package-manager.d.ts +167 -0
  1318. package/dist/src/utils/package-manager.js +860 -0
  1319. package/dist/src/utils/params.d.ts +146 -0
  1320. package/dist/src/utils/params.js +768 -0
  1321. package/dist/src/utils/path.d.ts +25 -0
  1322. package/dist/src/utils/path.js +53 -0
  1323. package/dist/src/utils/perf-hooks.d.ts +19 -0
  1324. package/dist/src/utils/perf-logging.d.ts +1 -0
  1325. package/dist/src/utils/perf-logging.js +46 -0
  1326. package/dist/src/utils/permission-errors.d.ts +11 -0
  1327. package/dist/src/utils/permission-errors.js +17 -0
  1328. package/dist/src/utils/plugin-cache-utils.d.ts +82 -0
  1329. package/dist/src/utils/plugin-cache-utils.js +212 -0
  1330. package/dist/src/utils/plugin-progress-text.d.ts +1 -0
  1331. package/dist/src/utils/plugin-progress-text.js +15 -0
  1332. package/dist/src/utils/plugins/atomizer-utils.d.ts +11 -0
  1333. package/dist/src/utils/plugins/atomizer-utils.js +23 -0
  1334. package/dist/src/utils/plugins/core-plugins.d.ts +6 -0
  1335. package/dist/src/utils/plugins/core-plugins.js +117 -0
  1336. package/dist/src/utils/plugins/index.d.ts +5 -0
  1337. package/dist/src/utils/plugins/index.js +15 -0
  1338. package/dist/src/utils/plugins/installed-plugins.d.ts +5 -0
  1339. package/dist/src/utils/plugins/installed-plugins.js +76 -0
  1340. package/dist/src/utils/plugins/local-plugins.d.ts +22 -0
  1341. package/dist/src/utils/plugins/local-plugins.js +60 -0
  1342. package/dist/src/utils/plugins/output.d.ts +34 -0
  1343. package/dist/src/utils/plugins/output.js +201 -0
  1344. package/dist/src/utils/plugins/plugin-capabilities.d.ts +15 -0
  1345. package/dist/src/utils/plugins/plugin-capabilities.js +83 -0
  1346. package/dist/src/utils/pnpm-workspace.d.ts +8 -0
  1347. package/dist/src/utils/pnpm-workspace.js +2 -0
  1348. package/dist/src/utils/print-help.d.ts +11 -0
  1349. package/dist/src/utils/print-help.js +259 -0
  1350. package/dist/src/utils/progress-topics.d.ts +19 -0
  1351. package/dist/src/utils/progress-topics.js +21 -0
  1352. package/dist/src/utils/project-graph-utils.d.ts +20 -0
  1353. package/dist/src/utils/project-graph-utils.js +90 -0
  1354. package/dist/src/utils/promised-based-queue.d.ts +6 -0
  1355. package/dist/src/utils/promised-based-queue.js +43 -0
  1356. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  1357. package/dist/src/utils/prompt-helpers.js +111 -0
  1358. package/dist/src/utils/provenance.d.ts +47 -0
  1359. package/dist/src/utils/provenance.js +123 -0
  1360. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  1361. package/dist/src/utils/registry-config/bun.js +257 -0
  1362. package/dist/src/utils/registry-config/index.d.ts +13 -0
  1363. package/dist/src/utils/registry-config/index.js +102 -0
  1364. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  1365. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  1366. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  1367. package/dist/src/utils/registry-config/utils.js +496 -0
  1368. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  1369. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  1370. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  1371. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  1372. package/dist/src/utils/require-nx-key.d.ts +1 -0
  1373. package/dist/src/utils/require-nx-key.js +23 -0
  1374. package/dist/src/utils/safe-spawn.d.ts +24 -0
  1375. package/dist/src/utils/safe-spawn.js +104 -0
  1376. package/dist/src/utils/serializable-error.d.ts +4 -0
  1377. package/dist/src/utils/serializable-error.js +33 -0
  1378. package/dist/src/utils/serialize-overrides-into-command-line.d.ts +3 -0
  1379. package/dist/src/utils/serialize-overrides-into-command-line.js +39 -0
  1380. package/dist/src/utils/serialize-target.d.ts +1 -0
  1381. package/dist/src/utils/serialize-target.js +6 -0
  1382. package/dist/src/utils/shell-quoting.d.ts +25 -0
  1383. package/dist/src/utils/shell-quoting.js +76 -0
  1384. package/dist/src/utils/socket-refused-exit-code.d.ts +15 -0
  1385. package/dist/src/utils/socket-refused-exit-code.js +18 -0
  1386. package/dist/src/utils/spinner.d.ts +24 -0
  1387. package/dist/src/utils/spinner.js +77 -0
  1388. package/dist/src/utils/split-target.d.ts +15 -0
  1389. package/dist/src/utils/split-target.js +239 -0
  1390. package/dist/src/utils/strip-indents.d.ts +14 -0
  1391. package/dist/src/utils/strip-indents.js +23 -0
  1392. package/dist/src/utils/sync-generators.d.ts +66 -0
  1393. package/dist/src/utils/sync-generators.js +355 -0
  1394. package/dist/src/utils/tar.d.ts +8 -0
  1395. package/dist/src/utils/tar.js +44 -0
  1396. package/dist/src/utils/task-history.d.ts +17 -0
  1397. package/dist/src/utils/task-history.js +51 -0
  1398. package/dist/src/utils/terminal-link.d.ts +20 -0
  1399. package/dist/src/utils/terminal-link.js +85 -0
  1400. package/dist/src/utils/update-nxw.d.ts +2 -0
  1401. package/dist/src/utils/update-nxw.js +22 -0
  1402. package/dist/src/utils/versions.d.ts +1 -0
  1403. package/dist/src/utils/versions.js +4 -0
  1404. package/dist/src/utils/wait-for-socket-connection.d.ts +26 -0
  1405. package/dist/src/utils/wait-for-socket-connection.js +59 -0
  1406. package/dist/src/utils/workspace-context.d.ts +69 -0
  1407. package/dist/src/utils/workspace-context.js +284 -0
  1408. package/dist/src/utils/workspace-id.d.ts +20 -0
  1409. package/dist/src/utils/workspace-id.js +54 -0
  1410. package/dist/src/utils/workspace-root.d.ts +6 -0
  1411. package/dist/src/utils/workspace-root.js +40 -0
  1412. package/dist/src/utils/write-formatted-json-file.d.ts +7 -0
  1413. package/dist/src/utils/write-formatted-json-file.js +24 -0
  1414. package/dist/src/utils/yarn-syml/index.d.ts +23 -0
  1415. package/dist/src/utils/yarn-syml/index.js +151 -0
  1416. package/dist/src/utils/yarn-syml/syml-grammar.js +1911 -0
  1417. package/dist/tasks-runners/default.d.ts +1 -0
  1418. package/dist/tasks-runners/default.js +5 -0
  1419. package/executors.json +19 -0
  1420. package/generators.json +16 -0
  1421. package/migrations.json +195 -0
  1422. package/package.json +516 -9
  1423. package/readme-template.md +16 -0
  1424. package/schemas/migrations-schema.json +186 -0
  1425. package/schemas/nx-schema.json +1653 -0
  1426. package/schemas/project-schema.json +461 -0
  1427. package/schemas/workspace-schema.json +185 -0
  1428. package/local-natives.js +0 -59
@@ -0,0 +1,2944 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHybridMigration = exports.isPromptOnlyMigration = exports.filterDowngradedUpdates = exports.Migrator = exports.normalizeVersion = void 0;
4
+ exports.formatCommandFailure = formatCommandFailure;
5
+ exports.resolveCanonicalNxPackage = resolveCanonicalNxPackage;
6
+ exports.resolveInclude = resolveInclude;
7
+ exports.parseMigrationsOptions = parseMigrationsOptions;
8
+ exports.createFetcher = createFetcher;
9
+ exports.generateMigrationsJsonAndUpdatePackageJson = generateMigrationsJsonAndUpdatePackageJson;
10
+ exports.formatSkippedPromptsNextStep = formatSkippedPromptsNextStep;
11
+ exports.executeMigrations = executeMigrations;
12
+ exports.isRunPhaseInvocation = isRunPhaseInvocation;
13
+ exports.migrate = migrate;
14
+ exports.readLocalNxVersion = readLocalNxVersion;
15
+ exports.runMigration = runMigration;
16
+ exports.resolveMigrationForRun = resolveMigrationForRun;
17
+ exports.nxCliPath = nxCliPath;
18
+ const tslib_1 = require("tslib");
19
+ const pc = tslib_1.__importStar(require("picocolors"));
20
+ const child_process_1 = require("child_process");
21
+ const safe_prompt_1 = require("./safe-prompt");
22
+ const path_1 = require("path");
23
+ const module_1 = require("module");
24
+ const path_2 = require("../../utils/path");
25
+ const semver_1 = require("semver");
26
+ const node_url_1 = require("node:url");
27
+ const util_1 = require("util");
28
+ const fileutils_1 = require("../../utils/fileutils");
29
+ const tar_1 = require("../../utils/tar");
30
+ const write_formatted_json_file_1 = require("../../utils/write-formatted-json-file");
31
+ const shell_quoting_1 = require("../../utils/shell-quoting");
32
+ const logger_1 = require("../../utils/logger");
33
+ const native_1 = require("../../native");
34
+ const git_utils_1 = require("../../utils/git-utils");
35
+ const package_json_1 = require("../../utils/package-json");
36
+ const package_manager_1 = require("../../utils/package-manager");
37
+ const errors_1 = require("../../utils/min-release-age/errors");
38
+ const resolve_package_version_1 = require("./resolve-package-version");
39
+ const handle_errors_1 = require("../../utils/handle-errors");
40
+ const connect_to_nx_cloud_1 = require("../nx-cloud/connect/connect-to-nx-cloud");
41
+ const output_1 = require("../../utils/output");
42
+ const fs_1 = require("fs");
43
+ const workspace_root_1 = require("../../utils/workspace-root");
44
+ const is_ci_1 = require("../../utils/is-ci");
45
+ const installation_directory_1 = require("../../utils/installation-directory");
46
+ const installed_nx_version_1 = require("../../utils/installed-nx-version");
47
+ const configuration_1 = require("../../config/configuration");
48
+ const child_process_2 = require("../../utils/child-process");
49
+ const client_1 = require("../../daemon/client/client");
50
+ const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
51
+ const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
52
+ const provenance_1 = require("../../utils/provenance");
53
+ const catalog_1 = require("../../utils/catalog");
54
+ const migrate_analytics_1 = require("./migrate-analytics");
55
+ const multi_major_1 = require("./multi-major");
56
+ const prompt_files_1 = require("./prompt-files");
57
+ const command_object_1 = require("./command-object");
58
+ const migrate_config_1 = require("./migrate-config");
59
+ const migrate_commits_1 = require("./migrate-commits");
60
+ const migrate_output_1 = require("./migrate-output");
61
+ const migration_shape_1 = require("./migration-shape");
62
+ Object.defineProperty(exports, "isHybridMigration", { enumerable: true, get: function () { return migration_shape_1.isHybridMigration; } });
63
+ Object.defineProperty(exports, "isPromptOnlyMigration", { enumerable: true, get: function () { return migration_shape_1.isPromptOnlyMigration; } });
64
+ const update_filters_1 = require("./update-filters");
65
+ Object.defineProperty(exports, "filterDowngradedUpdates", { enumerable: true, get: function () { return update_filters_1.filterDowngradedUpdates; } });
66
+ const version_utils_1 = require("./version-utils");
67
+ Object.defineProperty(exports, "normalizeVersion", { enumerable: true, get: function () { return version_utils_1.normalizeVersion; } });
68
+ const execute_migration_1 = require("./execute-migration");
69
+ const step_actions_1 = require("./step-actions");
70
+ const sort_migrations_1 = require("./sort-migrations");
71
+ const inception_1 = require("./agentic/inception");
72
+ const version_skew_guard_1 = require("./version-skew-guard");
73
+ const versions_1 = require("../../utils/versions");
74
+ tslib_1.__exportStar(require("./execute-migration"), exports);
75
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
76
+ function formatCommandFailure(command, error) {
77
+ const normalizeCommandOutput = (output) => {
78
+ if (!output) {
79
+ return undefined;
80
+ }
81
+ const normalized = typeof output === 'string' ? output.trim() : output.toString().trim();
82
+ return normalized || undefined;
83
+ };
84
+ const details = normalizeCommandOutput(error.stderr) ||
85
+ normalizeCommandOutput(error.stdout) ||
86
+ normalizeCommandOutput(error.message)
87
+ ?.replace(`Command failed: ${command}`, '')
88
+ .trim();
89
+ return [`Command failed: ${command}`, ...(details ? [details] : [])].join('\n');
90
+ }
91
+ function runOrReturnExitCode(run) {
92
+ try {
93
+ run();
94
+ return 0;
95
+ }
96
+ catch (e) {
97
+ if (typeof e === 'object' &&
98
+ e !== null &&
99
+ 'status' in e &&
100
+ typeof e.status === 'number') {
101
+ return e.status;
102
+ }
103
+ throw e;
104
+ }
105
+ }
106
+ function cleanSemver(version) {
107
+ return (0, semver_1.clean)(version) ?? (0, semver_1.coerce)(version);
108
+ }
109
+ function normalizeSlashes(packageName) {
110
+ return packageName.replace(/\\/g, '/');
111
+ }
112
+ class Migrator {
113
+ constructor(opts) {
114
+ this.packageUpdates = {};
115
+ this.collectedVersions = {};
116
+ this.promptAnswers = {};
117
+ this.pendingPackageJsonUpdates = new Map();
118
+ this.appliedPackageJsonUpdates = new Set();
119
+ if ((opts.include === 'required' || opts.include === 'optional') &&
120
+ !opts.requiredPackages) {
121
+ throw new Error(`Error: 'requiredPackages' is required when 'include' is '${opts.include}'.`);
122
+ }
123
+ this.packageJson = opts.packageJson;
124
+ this.nxInstallation = opts.nxInstallation;
125
+ this.getInstalledPackageVersion = opts.getInstalledPackageVersion;
126
+ this.fetch = opts.fetch;
127
+ this.installedPkgVersionOverrides = opts.from;
128
+ this.to = opts.to;
129
+ this.interactive = opts.interactive;
130
+ this.excludeAppliedMigrations = opts.excludeAppliedMigrations;
131
+ this.include = opts.include;
132
+ this.requiredPackages = opts.requiredPackages;
133
+ }
134
+ async fetchMigrationConfig(packageName, packageVersion) {
135
+ const migrationConfig = await this.fetch(packageName, packageVersion);
136
+ if (!migrationConfig.version) {
137
+ throw new Error(`Fetched migration metadata for ${packageName} is invalid: the target version is missing.`);
138
+ }
139
+ return migrationConfig;
140
+ }
141
+ async migrate(targetPackage, targetVersion) {
142
+ await this.buildPackageJsonUpdates(targetPackage, {
143
+ version: targetVersion,
144
+ addToPackageJson: false,
145
+ });
146
+ await this.applyPendingPackageJsonUpdates();
147
+ this.applyIncludeFilter();
148
+ const { migrations, promptContents } = await this.createMigrateJson();
149
+ return {
150
+ packageUpdates: this.packageUpdates,
151
+ migrations,
152
+ ...(Object.keys(promptContents).length > 0 ? { promptContents } : {}),
153
+ minVersionWithSkippedUpdates: this.minVersionWithSkippedUpdates,
154
+ };
155
+ }
156
+ async createMigrateJson() {
157
+ const promptContents = {};
158
+ const migrations = await Promise.all(Object.keys(this.packageUpdates).map(async (packageName) => {
159
+ if (this.packageUpdates[packageName].ignoreMigrations) {
160
+ return [];
161
+ }
162
+ const currentVersion = this.getPkgVersion(packageName);
163
+ if (currentVersion === null)
164
+ return [];
165
+ const { version } = this.packageUpdates[packageName];
166
+ const { generators: migrationEntries, resolvedPromptFiles } = await this.fetchMigrationConfig(packageName, version);
167
+ if (!migrationEntries)
168
+ return [];
169
+ if (resolvedPromptFiles) {
170
+ for (const [promptPath, content] of Object.entries(resolvedPromptFiles)) {
171
+ promptContents[(0, prompt_files_1.promptContentKey)(packageName, promptPath)] = content;
172
+ }
173
+ }
174
+ return Object.entries(migrationEntries)
175
+ .filter(([, migration]) => migration.version &&
176
+ this.gt(migration.version, currentVersion) &&
177
+ this.lte(migration.version, version) &&
178
+ this.areMigrationRequirementsMet(packageName, migration))
179
+ .map(([migrationName, migration]) => ({
180
+ ...migration,
181
+ package: packageName,
182
+ name: migrationName,
183
+ }));
184
+ }));
185
+ return { migrations: migrations.flat(), promptContents };
186
+ }
187
+ async buildPackageJsonUpdates(targetPackage, target) {
188
+ const packagesToCheck = await this.populatePackageJsonUpdatesAndGetPackagesToCheck(targetPackage, target);
189
+ for (const packageToCheck of packagesToCheck) {
190
+ const filteredUpdates = {};
191
+ for (const [packageUpdateKey, packageUpdate] of Object.entries(packageToCheck.updates)) {
192
+ Object.assign(filteredUpdates, await this.applyPackageJsonUpdate(packageToCheck.package, packageUpdateKey, packageUpdate));
193
+ }
194
+ await Promise.all(Object.entries(filteredUpdates).map(([name, update]) => this.buildPackageJsonUpdates(name, update)));
195
+ }
196
+ }
197
+ async applyPackageJsonUpdate(sourcePackage, packageUpdateKey, packageUpdate) {
198
+ const appliedKey = JSON.stringify([sourcePackage, packageUpdateKey]);
199
+ if (this.appliedPackageJsonUpdates.has(appliedKey)) {
200
+ this.pendingPackageJsonUpdates.delete(appliedKey);
201
+ return {};
202
+ }
203
+ if (!this.areRequirementsMet(packageUpdate.requires) ||
204
+ this.areIncompatiblePackagesPresent(packageUpdate.incompatibleWith)) {
205
+ this.pendingPackageJsonUpdates.set(appliedKey, {
206
+ package: sourcePackage,
207
+ key: packageUpdateKey,
208
+ update: packageUpdate,
209
+ });
210
+ return {};
211
+ }
212
+ this.pendingPackageJsonUpdates.delete(appliedKey);
213
+ if (this.interactive &&
214
+ !(await this.runPackageJsonUpdatesConfirmationPrompt(packageUpdate, packageUpdateKey, sourcePackage))) {
215
+ return {};
216
+ }
217
+ this.appliedPackageJsonUpdates.add(appliedKey);
218
+ const updateEntries = Object.entries(packageUpdate.packages);
219
+ // Validate all up front so invalid metadata fails fast, before any
220
+ // resolution does I/O.
221
+ for (const [name, update] of updateEntries) {
222
+ this.validatePackageUpdateVersion(sourcePackage, name, update);
223
+ }
224
+ const filteredUpdates = {};
225
+ // Resolve serially: resolution can prompt (pnpm strict cooldown) and append
226
+ // to minimumReleaseAgeExclude, so a serial loop avoids overlapping prompts
227
+ // and keeps packageUpdates ordering stable.
228
+ for (const [name, update] of updateEntries) {
229
+ const resolvedUpdate = {
230
+ ...update,
231
+ version: await this.resolveVersionForCascade(name, update.version),
232
+ };
233
+ this.addPackageUpdate(name, resolvedUpdate);
234
+ filteredUpdates[name] = this.packageUpdates[name];
235
+ }
236
+ return filteredUpdates;
237
+ }
238
+ async applyPendingPackageJsonUpdates() {
239
+ while (this.pendingPackageJsonUpdates.size) {
240
+ let applied = false;
241
+ const filteredUpdates = {};
242
+ for (const pending of [...this.pendingPackageJsonUpdates.values()]) {
243
+ const updates = await this.applyPackageJsonUpdate(pending.package, pending.key, pending.update);
244
+ if (Object.keys(updates).length) {
245
+ applied = true;
246
+ Object.assign(filteredUpdates, updates);
247
+ }
248
+ }
249
+ if (!applied) {
250
+ return;
251
+ }
252
+ await Promise.all(Object.entries(filteredUpdates).map(([name, update]) => this.buildPackageJsonUpdates(name, update)));
253
+ }
254
+ }
255
+ async resolveVersionForCascade(packageName, version) {
256
+ // Already a fully-qualified semver (incl. prereleases) - nothing to resolve.
257
+ if ((0, semver_1.valid)(version)) {
258
+ return version;
259
+ }
260
+ // Otherwise resolve the spec (range/tag) through the min-release-age policy,
261
+ // which also honors any configured minimumReleaseAgeExclude entries.
262
+ return (0, resolve_package_version_1.resolvePackageVersionRespectingMinReleaseAge)(packageName, version);
263
+ }
264
+ async populatePackageJsonUpdatesAndGetPackagesToCheck(targetPackage, target) {
265
+ let targetVersion = target.version;
266
+ if (this.to[targetPackage]) {
267
+ targetVersion = this.to[targetPackage];
268
+ }
269
+ if (!this.getPkgVersion(targetPackage)) {
270
+ this.addPackageUpdate(targetPackage, {
271
+ version: target.version,
272
+ addToPackageJson: target.addToPackageJson || false,
273
+ ...(target.ignoreMigrations && { ignoreMigrations: true }),
274
+ });
275
+ return [];
276
+ }
277
+ let migrationConfig;
278
+ try {
279
+ migrationConfig = await this.fetchMigrationConfig(targetPackage, targetVersion);
280
+ }
281
+ catch (e) {
282
+ // A cooldown violation must keep its type so the top-level handler can
283
+ // surface its remediation; only a generic "no matching version" earns the
284
+ // --to hint.
285
+ if (!(e instanceof errors_1.MinReleaseAgeViolationError) &&
286
+ e?.message?.includes('No matching version')) {
287
+ throw new Error(`${e.message}\nRun migrate with --to="package1@version1,package2@version2"`);
288
+ }
289
+ else {
290
+ throw e;
291
+ }
292
+ }
293
+ targetVersion = migrationConfig.version;
294
+ if (this.collectedVersions[targetPackage] &&
295
+ (0, semver_1.gte)(this.collectedVersions[targetPackage], targetVersion)) {
296
+ return [];
297
+ }
298
+ this.collectedVersions[targetPackage] = targetVersion;
299
+ this.addPackageUpdate(targetPackage, {
300
+ version: migrationConfig.version,
301
+ addToPackageJson: target.addToPackageJson || false,
302
+ ...(target.ignoreMigrations && { ignoreMigrations: true }),
303
+ });
304
+ const { packageJsonUpdates, packageGroupOrder } = this.getPackageJsonUpdatesFromMigrationConfig(targetPackage, targetVersion, migrationConfig, target.ignorePackageGroup);
305
+ if (!Object.keys(packageJsonUpdates).length) {
306
+ return [];
307
+ }
308
+ const shouldCheckUpdates = Object.values(packageJsonUpdates).some((packageJsonUpdate) => (this.interactive && packageJsonUpdate['x-prompt']) ||
309
+ Object.keys(packageJsonUpdate.requires ?? {}).length ||
310
+ Object.keys(packageJsonUpdate.incompatibleWith ?? {}).length);
311
+ if (shouldCheckUpdates) {
312
+ return [{ package: targetPackage, updates: packageJsonUpdates }];
313
+ }
314
+ const packageUpdatesToApply = Object.values(packageJsonUpdates).reduce((m, c) => ({ ...m, ...c.packages }), {});
315
+ return (await Promise.all(Object.entries(packageUpdatesToApply).map(([packageName, packageUpdate]) => {
316
+ this.validatePackageUpdateVersion(targetPackage, packageName, packageUpdate);
317
+ return this.populatePackageJsonUpdatesAndGetPackagesToCheck(packageName, packageUpdate);
318
+ })))
319
+ .filter((pkgs) => pkgs.length)
320
+ .flat()
321
+ .sort((pkgUpdate1, pkgUpdate2) => packageGroupOrder.indexOf(pkgUpdate1.package) -
322
+ packageGroupOrder.indexOf(pkgUpdate2.package));
323
+ }
324
+ getPackageJsonUpdatesFromMigrationConfig(packageName, targetVersion, migrationConfig, ignorePackageGroup) {
325
+ const packageGroupOrder = this.getPackageJsonUpdatesFromPackageGroup(packageName, targetVersion, migrationConfig, ignorePackageGroup);
326
+ if (!migrationConfig.packageJsonUpdates ||
327
+ !this.getPkgVersion(packageName)) {
328
+ return { packageJsonUpdates: {}, packageGroupOrder };
329
+ }
330
+ const packageJsonUpdates = this.filterPackageJsonUpdates(migrationConfig.packageJsonUpdates, packageName, targetVersion);
331
+ return { packageJsonUpdates, packageGroupOrder };
332
+ }
333
+ /**
334
+ * Mutates migrationConfig, adding package group updates into packageJsonUpdates section
335
+ *
336
+ * @param packageName Package which is being migrated
337
+ * @param targetVersion Version which is being migrated to
338
+ * @param migrationConfig Configuration which is mutated to contain package json updates
339
+ * @returns Order of package groups
340
+ */
341
+ getPackageJsonUpdatesFromPackageGroup(packageName, targetVersion, migrationConfig, ignorePackageGroup) {
342
+ if (ignorePackageGroup) {
343
+ return [];
344
+ }
345
+ const packageGroup = packageName === '@nrwl/workspace' && (0, version_utils_1.isLegacyEra)(targetVersion)
346
+ ? LEGACY_NRWL_PACKAGE_GROUP
347
+ : (migrationConfig.packageGroup ?? []);
348
+ let packageGroupOrder = [];
349
+ if (packageGroup.length) {
350
+ packageGroupOrder = packageGroup.map((packageConfig) => packageConfig.package);
351
+ migrationConfig.packageJsonUpdates ??= {};
352
+ const packages = {};
353
+ migrationConfig.packageJsonUpdates[targetVersion + '--PackageGroup'] = {
354
+ version: targetVersion,
355
+ packages,
356
+ };
357
+ for (const packageConfig of packageGroup) {
358
+ packages[packageConfig.package] = {
359
+ version: packageConfig.version === '*'
360
+ ? targetVersion
361
+ : packageConfig.version,
362
+ alwaysAddToPackageJson: false,
363
+ };
364
+ if (packageConfig.version === '*' &&
365
+ this.installedPkgVersionOverrides[packageName]) {
366
+ this.installedPkgVersionOverrides[packageConfig.package] ??=
367
+ this.installedPkgVersionOverrides[packageName];
368
+ }
369
+ }
370
+ }
371
+ return packageGroupOrder;
372
+ }
373
+ filterPackageJsonUpdates(packageJsonUpdates, packageName, targetVersion) {
374
+ const filteredPackageJsonUpdates = {};
375
+ for (const [packageJsonUpdateKey, packageJsonUpdate] of Object.entries(packageJsonUpdates)) {
376
+ if (!packageJsonUpdate.packages ||
377
+ this.lt(packageJsonUpdate.version, this.getPkgVersion(packageName)) ||
378
+ this.gt(packageJsonUpdate.version, targetVersion)) {
379
+ continue;
380
+ }
381
+ const dependencies = {
382
+ ...this.packageJson?.dependencies,
383
+ ...this.packageJson?.devDependencies,
384
+ ...this.nxInstallation?.plugins,
385
+ ...(this.nxInstallation && { nx: this.nxInstallation.version }),
386
+ };
387
+ const filtered = {};
388
+ for (const [packageName, packageUpdate] of Object.entries(packageJsonUpdate.packages)) {
389
+ if (this.shouldExcludePackage(packageName)) {
390
+ continue;
391
+ }
392
+ if (this.shouldApplyPackageUpdate(packageUpdate, packageName, dependencies)) {
393
+ filtered[packageName] = {
394
+ version: packageUpdate.version,
395
+ addToPackageJson: packageUpdate.alwaysAddToPackageJson
396
+ ? typeof packageUpdate.alwaysAddToPackageJson === 'string'
397
+ ? packageUpdate.alwaysAddToPackageJson
398
+ : 'dependencies'
399
+ : packageUpdate.addToPackageJson || false,
400
+ ...(packageUpdate.ignorePackageGroup && {
401
+ ignorePackageGroup: true,
402
+ }),
403
+ ...(packageUpdate.ignoreMigrations && {
404
+ ignoreMigrations: true,
405
+ }),
406
+ };
407
+ }
408
+ }
409
+ if (Object.keys(filtered).length) {
410
+ packageJsonUpdate.packages = filtered;
411
+ filteredPackageJsonUpdates[packageJsonUpdateKey] = packageJsonUpdate;
412
+ }
413
+ }
414
+ return filteredPackageJsonUpdates;
415
+ }
416
+ shouldExcludePackage(packageName) {
417
+ if (!this.requiredPackages) {
418
+ return false;
419
+ }
420
+ if (this.include === 'required') {
421
+ return !this.requiredPackages.has(packageName);
422
+ }
423
+ return false;
424
+ }
425
+ applyIncludeFilter() {
426
+ if (this.include !== 'optional') {
427
+ return;
428
+ }
429
+ // Cascade walks through the required packages so cross-plugin optional
430
+ // deps (e.g. typescript managed by @nx/js but used by @nx/angular) get
431
+ // surfaced. Drop the required set from the final result here so only
432
+ // optional updates land in package.json.
433
+ for (const name of Object.keys(this.packageUpdates)) {
434
+ if (this.requiredPackages.has(name)) {
435
+ delete this.packageUpdates[name];
436
+ }
437
+ }
438
+ }
439
+ shouldApplyPackageUpdate(packageUpdate, packageName, dependencies) {
440
+ return ((!packageUpdate.ifPackageInstalled ||
441
+ this.getPkgVersion(packageUpdate.ifPackageInstalled)) &&
442
+ (packageUpdate.alwaysAddToPackageJson ||
443
+ packageUpdate.addToPackageJson ||
444
+ !!dependencies?.[packageName]) &&
445
+ (!this.collectedVersions[packageName] ||
446
+ this.gt(packageUpdate.version, this.collectedVersions[packageName])));
447
+ }
448
+ validatePackageUpdateVersion(sourcePackageName, packageName, packageUpdate) {
449
+ if (!packageUpdate.version) {
450
+ throw new Error(`Fetched migration metadata for ${sourcePackageName} is invalid: the target version for ${packageName} is missing.`);
451
+ }
452
+ }
453
+ addPackageUpdate(name, packageUpdate) {
454
+ if (!this.packageUpdates[name] ||
455
+ !this.lt(packageUpdate.version, this.packageUpdates[name].version)) {
456
+ this.packageUpdates[name] = packageUpdate;
457
+ }
458
+ }
459
+ areRequirementsMet(requirements) {
460
+ if (!requirements || !Object.keys(requirements).length) {
461
+ return true;
462
+ }
463
+ return Object.entries(requirements).every(([pkgName, versionRange]) => {
464
+ if (this.packageUpdates[pkgName]) {
465
+ return (0, semver_1.satisfies)(cleanSemver(this.packageUpdates[pkgName].version), versionRange, { includePrerelease: true });
466
+ }
467
+ return (this.getPkgVersion(pkgName) &&
468
+ (0, semver_1.satisfies)(this.getPkgVersion(pkgName), versionRange, {
469
+ includePrerelease: true,
470
+ }));
471
+ });
472
+ }
473
+ areIncompatiblePackagesPresent(incompatibleWith) {
474
+ if (!incompatibleWith || !Object.keys(incompatibleWith).length) {
475
+ return false;
476
+ }
477
+ return Object.entries(incompatibleWith).some(([pkgName, versionRange]) => {
478
+ if (this.packageUpdates[pkgName]) {
479
+ return (0, semver_1.satisfies)(cleanSemver(this.packageUpdates[pkgName].version), versionRange, { includePrerelease: true });
480
+ }
481
+ return (this.getPkgVersion(pkgName) &&
482
+ (0, semver_1.satisfies)(this.getPkgVersion(pkgName), versionRange, {
483
+ includePrerelease: true,
484
+ }));
485
+ });
486
+ }
487
+ areMigrationRequirementsMet(packageName, migration) {
488
+ if (!this.excludeAppliedMigrations) {
489
+ return this.areRequirementsMet(migration.requires);
490
+ }
491
+ return ((this.wasMigrationSkipped(migration.requires) ||
492
+ this.isMigrationForHigherVersionThanWhatIsInstalled(packageName, migration)) &&
493
+ this.areRequirementsMet(migration.requires));
494
+ }
495
+ isMigrationForHigherVersionThanWhatIsInstalled(packageName, migration) {
496
+ const installedVersion = this.getInstalledPackageVersion(packageName);
497
+ return (migration.version &&
498
+ (!installedVersion || this.gt(migration.version, installedVersion)) &&
499
+ this.lte(migration.version, this.packageUpdates[packageName].version));
500
+ }
501
+ wasMigrationSkipped(requirements) {
502
+ // no requiremets, so it ran before
503
+ if (!requirements || !Object.keys(requirements).length) {
504
+ return false;
505
+ }
506
+ // at least a requirement was not met, it was skipped
507
+ return Object.entries(requirements).some(([pkgName, versionRange]) => !this.getInstalledPackageVersion(pkgName) ||
508
+ !(0, semver_1.satisfies)(this.getInstalledPackageVersion(pkgName), versionRange, {
509
+ includePrerelease: true,
510
+ }));
511
+ }
512
+ async runPackageJsonUpdatesConfirmationPrompt(packageUpdate, packageUpdateKey, packageName) {
513
+ if (!packageUpdate['x-prompt']) {
514
+ return Promise.resolve(true);
515
+ }
516
+ const promptKey = this.getPackageUpdatePromptKey(packageUpdate);
517
+ if (this.promptAnswers[promptKey] !== undefined) {
518
+ // a same prompt was already answered, skip
519
+ return Promise.resolve(false);
520
+ }
521
+ // No footer slot, so the docs link is appended to the message.
522
+ const detailsLink = packageName.startsWith('@nx/')
523
+ ? pc.dim(`\n View migration details at https://nx.dev/nx-api/${packageName.replace('@nx/', '')}#${packageUpdateKey.replace(/[-\.]/g, '')}packageupdates`)
524
+ : '';
525
+ return await (0, safe_prompt_1.migrateConfirm)({
526
+ message: `${packageUpdate['x-prompt']}${detailsLink}`,
527
+ initial: true,
528
+ }).then((shouldApply) => {
529
+ this.promptAnswers[promptKey] = shouldApply;
530
+ if (!shouldApply &&
531
+ (!this.minVersionWithSkippedUpdates ||
532
+ (0, semver_1.lt)(packageUpdate.version, this.minVersionWithSkippedUpdates))) {
533
+ this.minVersionWithSkippedUpdates = packageUpdate.version;
534
+ }
535
+ return shouldApply;
536
+ });
537
+ }
538
+ getPackageUpdatePromptKey(packageUpdate) {
539
+ return Object.entries(packageUpdate.packages)
540
+ .map(([name, update]) => `${name}:${JSON.stringify(update)}`)
541
+ .join('|');
542
+ }
543
+ getPkgVersion(pkg) {
544
+ return this.getInstalledPackageVersion(pkg, this.installedPkgVersionOverrides);
545
+ }
546
+ gt(v1, v2) {
547
+ return (0, semver_1.gt)((0, version_utils_1.normalizeVersion)(v1), (0, version_utils_1.normalizeVersion)(v2));
548
+ }
549
+ lt(v1, v2) {
550
+ return (0, semver_1.lt)((0, version_utils_1.normalizeVersion)(v1), (0, version_utils_1.normalizeVersion)(v2));
551
+ }
552
+ lte(v1, v2) {
553
+ return (0, semver_1.lte)((0, version_utils_1.normalizeVersion)(v1), (0, version_utils_1.normalizeVersion)(v2));
554
+ }
555
+ }
556
+ exports.Migrator = Migrator;
557
+ const LEGACY_NRWL_PACKAGE_GROUP = [
558
+ { package: '@nrwl/workspace', version: '*' },
559
+ { package: '@nrwl/angular', version: '*' },
560
+ { package: '@nrwl/cypress', version: '*' },
561
+ { package: '@nrwl/devkit', version: '*' },
562
+ { package: '@nrwl/eslint-plugin-nx', version: '*' },
563
+ { package: '@nrwl/express', version: '*' },
564
+ { package: '@nrwl/jest', version: '*' },
565
+ { package: '@nrwl/linter', version: '*' },
566
+ { package: '@nrwl/nest', version: '*' },
567
+ { package: '@nrwl/next', version: '*' },
568
+ { package: '@nrwl/node', version: '*' },
569
+ { package: '@nrwl/nx-plugin', version: '*' },
570
+ { package: '@nrwl/react', version: '*' },
571
+ { package: '@nrwl/storybook', version: '*' },
572
+ { package: '@nrwl/web', version: '*' },
573
+ { package: '@nrwl/js', version: '*' },
574
+ { package: 'nx-cloud', version: 'latest' },
575
+ { package: '@nrwl/react-native', version: '*' },
576
+ { package: '@nrwl/detox', version: '*' },
577
+ { package: '@nrwl/expo', version: '*' },
578
+ { package: '@nrwl/tao', version: '*' },
579
+ ];
580
+ function resolveRequiredPackages(targetPackage, packageGroup) {
581
+ const set = new Set([targetPackage]);
582
+ for (const { package: name } of packageGroup ?? []) {
583
+ set.add(name);
584
+ }
585
+ return set;
586
+ }
587
+ /**
588
+ * The canonical Nx package for a given target version: `@nrwl/workspace` for
589
+ * legacy (`< 14.0.0-beta.0`), `nx` otherwise. Non-semver inputs (e.g. the
590
+ * literal `'latest'` sentinel before tag resolution) resolve to modern era.
591
+ */
592
+ function resolveCanonicalNxPackage(targetVersion) {
593
+ return (0, version_utils_1.isLegacyEra)(targetVersion) ? '@nrwl/workspace' : 'nx';
594
+ }
595
+ /**
596
+ * `@nx/workspace` is version-synced with `nx` but declares an intentionally
597
+ * narrow `packageGroup`; resolve eligibility, bounds, and the optional walk
598
+ * against `nx`'s full closure so they match what the cascade actually walks.
599
+ */
600
+ function toNxClosurePackage(packageName) {
601
+ return packageName === '@nx/workspace' ? 'nx' : packageName;
602
+ }
603
+ async function resolveInclude(include, context, configuredInclude) {
604
+ // An explicit `--include` is validated against the target's `supportsOptionalMigrations` in
605
+ // `resolveTargetAndInclude`, so honor it directly here.
606
+ if (include) {
607
+ (0, migrate_analytics_1.setMigrateIncludeSource)('flag');
608
+ return include;
609
+ }
610
+ // Targets that don't declare `supportsOptionalMigrations` only ever run the full
611
+ // migration; there is nothing to pick between.
612
+ if (!context.targetSupportsOptionalUpdates) {
613
+ if (configuredInclude && configuredInclude !== 'all') {
614
+ output_1.output.warn({
615
+ title: `The configured nx.json migrate.include '${configuredInclude}' is not available for this migration; falling back to 'all'.`,
616
+ bodyLines: [`The target package does not support optional updates.`],
617
+ });
618
+ }
619
+ (0, migrate_analytics_1.setMigrateIncludeSource)('default');
620
+ return 'all';
621
+ }
622
+ // nx.json `migrate.include` pre-selects the answer the prompt would ask for.
623
+ if (configuredInclude) {
624
+ (0, migrate_analytics_1.setMigrateIncludeSource)('nx-json');
625
+ return configuredInclude;
626
+ }
627
+ const choices = [
628
+ {
629
+ value: 'required',
630
+ label: 'Required only (the target package and the packages it ships with)',
631
+ },
632
+ ];
633
+ // `--interactive` keeps the legacy x-prompt flow, which the `optional` value
634
+ // supersedes and is incompatible with, so omit it when interactive.
635
+ if (!context.hasFrom &&
636
+ !context.hasExcludeAppliedMigrations &&
637
+ context.interactive !== true) {
638
+ choices.push({
639
+ value: 'optional',
640
+ label: 'Optional only (the dependency updates those packages recommend)',
641
+ });
642
+ }
643
+ if (!(0, safe_prompt_1.canPrompt)(context.interactive)) {
644
+ (0, migrate_analytics_1.setMigrateIncludeSource)('default');
645
+ return 'all';
646
+ }
647
+ choices.push({
648
+ value: 'all',
649
+ label: 'All (required and optional)',
650
+ });
651
+ const selected = await (0, safe_prompt_1.migrateChoice)({
652
+ message: 'Which packages would you like to migrate?',
653
+ choices,
654
+ });
655
+ (0, migrate_analytics_1.reportMigratePrompt)('include', selected);
656
+ (0, migrate_analytics_1.setMigrateIncludeSource)('prompt');
657
+ return selected;
658
+ }
659
+ async function versionOverrides(overrides, param) {
660
+ const res = {};
661
+ const promises = overrides.split(',').map((p) => {
662
+ const split = p.lastIndexOf('@');
663
+ if (split === -1 || split === 0) {
664
+ throw new Error(`Incorrect '${param}' section. Use --${param}="package@version"`);
665
+ }
666
+ const selectedPackage = p.substring(0, split).trim();
667
+ const selectedVersion = p.substring(split + 1).trim();
668
+ if (!selectedPackage || !selectedVersion) {
669
+ throw new Error(`Incorrect '${param}' section. Use --${param}="package@version"`);
670
+ }
671
+ return (0, version_utils_1.normalizeVersionWithTagCheck)(selectedPackage, selectedVersion).then((version) => {
672
+ res[normalizeSlashes(selectedPackage)] = version;
673
+ });
674
+ });
675
+ await Promise.all(promises);
676
+ return res;
677
+ }
678
+ async function parseTargetPackageAndVersion(args) {
679
+ if (!args) {
680
+ throw new Error(`Provide the correct package name and version. E.g., my-package@9.0.0.`);
681
+ }
682
+ if (args.indexOf('@') > -1) {
683
+ const i = args.lastIndexOf('@');
684
+ if (i === 0) {
685
+ return { targetPackage: args.trim(), targetVersion: 'latest' };
686
+ }
687
+ const targetPackage = args.substring(0, i);
688
+ const maybeVersion = args.substring(i + 1);
689
+ if (!targetPackage || !maybeVersion) {
690
+ throw new Error(`Provide the correct package name and version. E.g., my-package@9.0.0.`);
691
+ }
692
+ const targetVersion = await (0, version_utils_1.normalizeVersionWithTagCheck)(targetPackage, maybeVersion);
693
+ return { targetPackage, targetVersion };
694
+ }
695
+ if (version_utils_1.DIST_TAGS.includes(args) ||
696
+ (0, semver_1.valid)(args) ||
697
+ args.match(/^\d+(?:\.\d+)?(?:\.\d+)?$/)) {
698
+ // Passing `nx` here may seem wrong, but nx and @nrwl/workspace are synced in version.
699
+ // We could duplicate the ternary below, but its not necessary since they are equivalent
700
+ // on the registry
701
+ const targetVersion = await (0, version_utils_1.normalizeVersionWithTagCheck)('nx', args);
702
+ const isDistTag = version_utils_1.DIST_TAGS.includes(args);
703
+ const targetPackage = isDistTag
704
+ ? 'nx'
705
+ : resolveCanonicalNxPackage(targetVersion);
706
+ return { targetPackage, targetVersion };
707
+ }
708
+ return { targetPackage: args, targetVersion: 'latest' };
709
+ }
710
+ async function parseMigrationsOptions(options, fetch) {
711
+ // A run recorded or reconciled via `--run-id` is driven by the outer agent;
712
+ // spawning another agent from it would double-drive the run. Only the
713
+ // explicit "on" values conflict; the nx.json default is not applied to
714
+ // those invocations instead. The `--run-migrations` shape is the
715
+ // exception: there `--run-id` names the run a continue re-enters, or the
716
+ // one a `--start-fresh` replaces.
717
+ if (options.runId !== undefined &&
718
+ options.agentic !== undefined &&
719
+ options.agentic !== false &&
720
+ options.runMigrations === undefined) {
721
+ throw new Error(`Error: '--agentic' cannot be combined with '--run-id'.`);
722
+ }
723
+ if (options.startFresh === true) {
724
+ if (options.runMigrations === undefined) {
725
+ throw new Error(`Error: '--start-fresh' requires '--run-migrations'.`);
726
+ }
727
+ if (options.runId === undefined) {
728
+ throw new Error(`Error: '--start-fresh' requires '--run-id=<id>' naming the run to replace; the report prints it.`);
729
+ }
730
+ }
731
+ if (options.runMigration !== undefined) {
732
+ if (options.runMigration === '') {
733
+ throw new Error(`Error: '--run-migration' requires a migration id, e.g. '--run-migration=@nx/js:my-migration'.`);
734
+ }
735
+ if (options.runId === '') {
736
+ throw new Error(`Error: '--run-id' requires the id of the migrate run to record into.`);
737
+ }
738
+ if (options.stepAction !== undefined) {
739
+ throw new Error(`Error: '--step-action' cannot be combined with '--run-migration'. It applies to an orchestrated reconcile ('--run-id' without '--run-migration').`);
740
+ }
741
+ if (options.runMigrations !== undefined) {
742
+ throw new Error(`Error: '--run-migration' (run a single migration) cannot be combined with '--run-migrations' (run the whole migrations file).`);
743
+ }
744
+ if (options.include) {
745
+ throw new Error(`Error: '--run-migration' cannot be combined with '--include'.`);
746
+ }
747
+ if (options.multiMajorMode) {
748
+ throw new Error(`Error: '--run-migration' cannot be combined with '--multi-major-mode'.`);
749
+ }
750
+ // `--if-exists` only applies to a whole-file run, so an explicit "on"
751
+ // conflicts. Its yargs default (false) is always present and is tolerated.
752
+ if (options.ifExists === true) {
753
+ throw new Error(`Error: '--run-migration' cannot be combined with '--if-exists'.`);
754
+ }
755
+ return {
756
+ type: 'runSingleMigration',
757
+ runMigration: options.runMigration,
758
+ runId: options.runId,
759
+ agentic: options.agentic,
760
+ validate: options.validate,
761
+ interactive: options.interactive,
762
+ };
763
+ }
764
+ if (options.runId !== undefined) {
765
+ // Empty '--run-id' is an error on every path.
766
+ if (options.runId === '') {
767
+ throw new Error(`Error: '--run-id' requires the id of the migrate run to record into.`);
768
+ }
769
+ // With `--run-migrations`, `--run-id` continues the named run, which needs
770
+ // `--agentic`; a start-fresh names the run it replaces instead.
771
+ if (options.runMigrations !== undefined &&
772
+ options.startFresh !== true &&
773
+ (options.agentic === undefined || options.agentic === false)) {
774
+ throw new Error(`Error: '--run-id' (reconcile an orchestrated run) cannot be combined with '--run-migrations' (run the whole migrations file). To continue the run, pass '--agentic' (or '--agentic=<agent>') as well.`);
775
+ }
776
+ if (options.runMigrations !== undefined &&
777
+ options.stepAction !== undefined) {
778
+ throw new Error(`Error: '--step-action' cannot be combined with '--run-migrations'.`);
779
+ }
780
+ // A bare '--run-id' reconciles the run it names. Ungated, unlike init:
781
+ // the id has to name a run directory that exists, and only a gated init
782
+ // ever creates one.
783
+ // yargs' choices already reject bad CLI values; this guards programmatic
784
+ // callers, where silently dropping the action would reconcile without it.
785
+ if (options.stepAction !== undefined && !(0, step_actions_1.isStepAction)(options.stepAction)) {
786
+ throw new Error(`Error: '--step-action' must be one of ${step_actions_1.STEP_ACTIONS.join(', ')}.`);
787
+ }
788
+ if (options.runMigrations === undefined) {
789
+ return {
790
+ type: 'orchestratorReconcile',
791
+ runId: options.runId,
792
+ ...(options.stepAction !== undefined
793
+ ? { stepAction: options.stepAction }
794
+ : {}),
795
+ };
796
+ }
797
+ }
798
+ if (options.stepAction !== undefined) {
799
+ throw new Error(`Error: '--step-action' requires '--run-id'.`);
800
+ }
801
+ if (options.runMigrations === '') {
802
+ options.runMigrations = 'migrations.json';
803
+ }
804
+ if (options.include && options.runMigrations) {
805
+ throw new Error(`Error: '--include' cannot be combined with '--run-migrations'.`);
806
+ }
807
+ if (options.multiMajorMode && options.runMigrations) {
808
+ throw new Error(`Error: '--multi-major-mode' cannot be combined with '--run-migrations'.`);
809
+ }
810
+ if (options.runMigrations) {
811
+ return {
812
+ type: 'runMigrations',
813
+ runMigrations: options.runMigrations,
814
+ ifExists: options.ifExists,
815
+ agentic: options.agentic,
816
+ validate: options.validate,
817
+ finalValidation: options.finalValidation,
818
+ interactive: options.interactive,
819
+ ...(options.runId !== undefined ? { runId: options.runId } : {}),
820
+ ...(options.startFresh === true ? { startFresh: true } : {}),
821
+ };
822
+ }
823
+ assertOptionalIncludeFlagCompatibility(options);
824
+ const [from, to] = await Promise.all([
825
+ options.from
826
+ ? versionOverrides(options.from, 'from')
827
+ : Promise.resolve({}),
828
+ options.to
829
+ ? await versionOverrides(options.to, 'to')
830
+ : Promise.resolve({}),
831
+ ]);
832
+ // The gate reads `supportsOptionalMigrations` through this fetcher (registry-first, install
833
+ // fallback) so private registries don't fail closed. In production the caller
834
+ // shares its fetcher; standalone callers (tests) get a fresh one.
835
+ const resolvedFetch = fetch ?? createFetcher((0, package_manager_1.getPackageManagerCommand)());
836
+ const positional = options['packageAndVersion'];
837
+ const resolved = await resolveTargetAndInclude({
838
+ positional,
839
+ from,
840
+ options,
841
+ fetch: resolvedFetch,
842
+ });
843
+ const { include, installedTargetVersion } = resolved;
844
+ let { targetPackage, targetVersion } = resolved;
845
+ // Crossing more than one major can silently skip migrations: each
846
+ // major's metadata may have pruned entries from much-older versions.
847
+ const multiMajorResult = await (0, multi_major_1.maybePromptOrWarnMultiMajorMigration)({
848
+ include,
849
+ options,
850
+ targetPackage,
851
+ targetVersion,
852
+ });
853
+ targetVersion = multiMajorResult.chosen;
854
+ if (include === 'optional') {
855
+ // `include` can resolve to optional via nx.json, which bypasses the early
856
+ // CLI-only check above; re-assert against the resolved value.
857
+ assertOptionalIncludeFlagCompatibility({
858
+ include,
859
+ from: options.from,
860
+ excludeAppliedMigrations: options.excludeAppliedMigrations,
861
+ interactive: options.interactive,
862
+ });
863
+ assertOptionalTargetBounds({
864
+ targetPackage,
865
+ targetVersion,
866
+ to,
867
+ // `resolveTargetAndInclude` always resolves the installed bounds version for
868
+ // the `optional` value (or throws), so it is present here.
869
+ installedTargetVersion: installedTargetVersion,
870
+ });
871
+ }
872
+ return {
873
+ type: 'generateMigrations',
874
+ targetPackage,
875
+ targetVersion,
876
+ from,
877
+ to,
878
+ interactive: options.interactive,
879
+ excludeAppliedMigrations: options.excludeAppliedMigrations,
880
+ include,
881
+ originalTargetVersion: multiMajorResult.originalTarget,
882
+ multiMajorMode: multiMajorResult.gradual ? 'gradual' : undefined,
883
+ multiMajorChoice: multiMajorResult.decision,
884
+ };
885
+ }
886
+ function assertOptionalIncludeFlagCompatibility(options) {
887
+ if (options.include !== 'optional')
888
+ return;
889
+ if (options.from) {
890
+ throw new Error(`Error: '--include=optional' cannot be combined with '--from'.`);
891
+ }
892
+ if (options.excludeAppliedMigrations === true) {
893
+ throw new Error(`Error: '--include=optional' cannot be combined with '--exclude-applied-migrations'.`);
894
+ }
895
+ if (options.interactive === true) {
896
+ throw new Error(`Error: '--include=optional' cannot be combined with '--interactive'.`);
897
+ }
898
+ }
899
+ // Resolves the target package/version up front (the `optional` value anchors to
900
+ // the installed target; otherwise dist-tags resolve to a concrete version), then
901
+ // resolves the include value and rejects `--include` when the target doesn't support it.
902
+ // Bare invocations require an explicit target on older installs rather than
903
+ // defaulting to `latest` across a large major gap.
904
+ async function resolveTargetAndInclude(args) {
905
+ const { positional, from, options, fetch } = args;
906
+ let targetPackage;
907
+ let targetVersion;
908
+ if (positional) {
909
+ const parsed = await parseTargetPackageAndVersion(positional);
910
+ targetPackage = normalizeSlashes(parsed.targetPackage);
911
+ targetVersion = parsed.targetVersion;
912
+ }
913
+ const installed = resolveInstalledCanonical();
914
+ const installedMajor = installed && (0, semver_1.valid)(installed.version) ? (0, semver_1.major)(installed.version) : null;
915
+ // `--include=optional` anchors the target to the installed version below, so
916
+ // it never needs a target or dist-tag resolved up front.
917
+ const isExplicitOptional = options.include === 'optional';
918
+ // Bare `nx migrate` defaults to `nx@latest`. Only do so from a recent-enough
919
+ // install (v22+); an unknown or far-behind version would otherwise silently
920
+ // run a large multi-major jump, so require an explicit target there instead.
921
+ if (!positional && !isExplicitOptional) {
922
+ if (installedMajor === null || installedMajor < 22) {
923
+ throw new Error(`Provide the package and version to migrate to. E.g., \`nx migrate nx@<version>\`.`);
924
+ }
925
+ targetPackage = 'nx';
926
+ targetVersion = 'latest';
927
+ }
928
+ // Resolve dist-tags to a concrete version so the `supportsOptionalMigrations` gate and the
929
+ // downstream cascade read a real semver. Explicit dist-tags arrive already
930
+ // resolved from `parseTargetPackageAndVersion`; only bare invocations and
931
+ // bare package names (`nx migrate nx`) reach here unresolved.
932
+ if (!isExplicitOptional &&
933
+ targetPackage &&
934
+ targetVersion &&
935
+ !(0, semver_1.valid)(targetVersion)) {
936
+ try {
937
+ targetVersion = await (0, version_utils_1.normalizeVersionWithTagCheck)(targetPackage, targetVersion);
938
+ }
939
+ catch {
940
+ // Registry unavailable: keep the tag. The sentinel degrades gracefully
941
+ // downstream (multi-major and the cascade tolerate it).
942
+ }
943
+ }
944
+ // `--include` is only available for targets that opt in via `supportsOptionalMigrations`.
945
+ // required/all/prompt/nx.json read the flag at the version being migrated
946
+ // to. Skipped when the include value can't depend on it (no `--include`, no nx.json
947
+ // default, no interactive prompt) and for the explicit `optional` value, which
948
+ // anchors to the installed target and reads at that version below.
949
+ let targetSupportsOptionalUpdates = false;
950
+ // The package/version whose `supportsOptionalMigrations` flag the gate actually read,
951
+ // surfaced verbatim in the rejection message below.
952
+ let eligibilityPackage = targetPackage;
953
+ let eligibilityVersion = targetVersion;
954
+ if (!isExplicitOptional &&
955
+ targetPackage &&
956
+ (options.include ||
957
+ options.includeFromConfig ||
958
+ (0, safe_prompt_1.canPrompt)(options.interactive))) {
959
+ // Read at the canonical closure package so the gate shares the cascade's
960
+ // cached fetch (the walk normalizes `@nx/workspace` -> `nx` too).
961
+ eligibilityPackage = toNxClosurePackage(targetPackage);
962
+ targetSupportsOptionalUpdates = await fetchSupportsOptionalUpdates(fetch, eligibilityPackage, targetVersion);
963
+ }
964
+ // Recorded before the interactive prompts (include, multi-major) so runs
965
+ // abandoned at a prompt still register a start.
966
+ (0, migrate_analytics_1.reportMigrateGenerateStart)({
967
+ targetPackage: targetPackage ?? 'nx',
968
+ interactive: options.interactive,
969
+ excludeAppliedMigrations: options.excludeAppliedMigrations,
970
+ });
971
+ const include = await resolveInclude(options.include, {
972
+ hasFrom: Object.keys(from).length > 0,
973
+ hasExcludeAppliedMigrations: options.excludeAppliedMigrations === true,
974
+ interactive: options.interactive,
975
+ targetSupportsOptionalUpdates,
976
+ }, options.includeFromConfig);
977
+ let installedTargetVersion;
978
+ // The `optional` value catches up the deps the target manages for the version
979
+ // you are already on, capped at the installed version. `@nx/workspace` is
980
+ // version-synced with `nx` but declares a narrower group, so resolve the
981
+ // installed bounds against `nx`'s full closure.
982
+ if (include === 'optional') {
983
+ if (!positional) {
984
+ // Bare `--include=optional`: catch up the deps Nx manages for installed Nx.
985
+ if (!installed) {
986
+ throw new Error(`Error: '--include=optional' requires 'nx' (or '@nrwl/workspace' on Nx <14) to be installed in your workspace. Install dependencies first, then re-run.`);
987
+ }
988
+ targetPackage = installed.canonical;
989
+ installedTargetVersion = installed.version;
990
+ targetVersion = installedTargetVersion;
991
+ }
992
+ else {
993
+ const boundsPackage = toNxClosurePackage(targetPackage);
994
+ installedTargetVersion = (0, installed_nx_version_1.getInstalledVersion)(boundsPackage);
995
+ if (!installedTargetVersion) {
996
+ throw new Error(`Error: '--include=optional' requires '${boundsPackage}' to be installed in your workspace. Install dependencies first, then re-run.`);
997
+ }
998
+ // A bare package name (no semver, surfaced as the literal `'latest'`)
999
+ // anchors the catch-up walk to installed; an explicit version is kept and
1000
+ // bounded against installed downstream.
1001
+ if (!(0, semver_1.valid)(targetVersion)) {
1002
+ targetVersion = installedTargetVersion;
1003
+ }
1004
+ }
1005
+ // An explicit `--include=optional` is gated on the INSTALLED version's flag:
1006
+ // you catch up the deps you already have, so eligibility follows the
1007
+ // installed package, not the (possibly older) explicit target. Config /
1008
+ // prompt-derived `optional` value was already vetted via the to-target read.
1009
+ if (options.include === 'optional') {
1010
+ eligibilityPackage = toNxClosurePackage(targetPackage);
1011
+ eligibilityVersion = installedTargetVersion;
1012
+ targetSupportsOptionalUpdates = await fetchSupportsOptionalUpdates(fetch, eligibilityPackage, installedTargetVersion);
1013
+ }
1014
+ }
1015
+ if (options.include && !targetSupportsOptionalUpdates) {
1016
+ throw new Error(`Error: '--include' requires the target package to support optional updates, but '${eligibilityPackage}@${eligibilityVersion}' does not.`);
1017
+ }
1018
+ return {
1019
+ targetPackage: targetPackage,
1020
+ targetVersion: targetVersion,
1021
+ include,
1022
+ installedTargetVersion,
1023
+ };
1024
+ }
1025
+ // `--include` is opt-in per package via `supportsOptionalMigrations` in the target's
1026
+ // `nx-migrations`/`ng-update` config. Read it through the shared fetcher
1027
+ // (registry-first, install fallback) so registries that can't serve metadata
1028
+ // via `npm view` resolve it from an install rather than failing the gate.
1029
+ async function fetchSupportsOptionalUpdates(fetch, packageName, packageVersion) {
1030
+ const config = await fetch(packageName, packageVersion);
1031
+ return config.supportsOptionalMigrations === true;
1032
+ }
1033
+ // `--include=optional` upper-bound gate. The optional walk catches up from
1034
+ // zero, so a target or `--to` above the installed version would surface
1035
+ // optional bumps that only exist in the newer package's history. The
1036
+ // required set is the target package's declared `packageGroup`; the legacy
1037
+ // era falls back to the hardcoded `LEGACY_NRWL_PACKAGE_GROUP`. `installed` is
1038
+ // the installed bounds version already resolved by `resolveTargetAndInclude`.
1039
+ function assertOptionalTargetBounds(args) {
1040
+ const { targetPackage, targetVersion, to, installedTargetVersion: installed, } = args;
1041
+ const boundsPackage = toNxClosurePackage(targetPackage);
1042
+ if ((0, semver_1.gt)(targetVersion, installed)) {
1043
+ throw new Error(`Error: '--include=optional' cannot migrate to a version higher than what is currently installed (got '${targetPackage}@${targetVersion}', installed '${boundsPackage}@${installed}'). Either drop '--include=optional' or lower the target.`);
1044
+ }
1045
+ const requiredSet = (0, version_utils_1.isLegacyEra)(targetVersion)
1046
+ ? new Set([
1047
+ boundsPackage,
1048
+ ...LEGACY_NRWL_PACKAGE_GROUP.map((p) => p.package),
1049
+ ])
1050
+ : (0, installed_nx_version_1.getInstalledPackageGroup)(boundsPackage);
1051
+ for (const [pkg, version] of Object.entries(to)) {
1052
+ if (requiredSet.has(pkg) && (0, semver_1.gt)(version, installed)) {
1053
+ throw new Error(`Error: '--include=optional' cannot migrate to a version higher than what is currently installed (got '--to ${pkg}@${version}', installed '${boundsPackage}@${installed}'). Either drop '--include=optional' or lower the '--to' value.`);
1054
+ }
1055
+ }
1056
+ }
1057
+ /**
1058
+ * Pick the canonical Nx package + version for `--include=optional` when the
1059
+ * user didn't supply an explicit version. Returns `'nx'` for modern era,
1060
+ * falls back to `'@nrwl/workspace'` (legacy era) when only that is installed
1061
+ * or when the installed `nx` itself is `<14`.
1062
+ */
1063
+ function resolveInstalledCanonical() {
1064
+ const installedNx = (0, installed_nx_version_1.getInstalledNxVersion)();
1065
+ if (installedNx) {
1066
+ return {
1067
+ canonical: resolveCanonicalNxPackage(installedNx),
1068
+ version: installedNx,
1069
+ };
1070
+ }
1071
+ const installedLegacy = (0, installed_nx_version_1.getInstalledLegacyNrwlWorkspaceVersion)();
1072
+ if (installedLegacy) {
1073
+ return { canonical: '@nrwl/workspace', version: installedLegacy };
1074
+ }
1075
+ return null;
1076
+ }
1077
+ function createInstalledPackageVersionsResolver(root) {
1078
+ const cache = {};
1079
+ const nxRequires = (0, installation_directory_1.getNxRequirePaths)(root).map((path) => (0, module_1.createRequire)((0, path_1.join)(path, 'package.json')));
1080
+ function getInstalledPackageVersion(packageName, overrides) {
1081
+ if (overrides?.[packageName]) {
1082
+ return overrides[packageName];
1083
+ }
1084
+ if (packageName === 'nx') {
1085
+ const nxVersion = cache[packageName] ??
1086
+ (() => {
1087
+ for (const req of nxRequires) {
1088
+ try {
1089
+ const packageJsonPath = req.resolve('nx/package.json');
1090
+ if (packageJsonPath.startsWith(workspace_root_1.workspaceRoot)) {
1091
+ return (0, fileutils_1.readJsonFile)(packageJsonPath).version;
1092
+ }
1093
+ }
1094
+ catch { }
1095
+ }
1096
+ return getInstalledPackageVersion('@nrwl/workspace', overrides);
1097
+ })();
1098
+ if (nxVersion) {
1099
+ cache[packageName] = nxVersion;
1100
+ }
1101
+ return nxVersion;
1102
+ }
1103
+ try {
1104
+ if (!cache[packageName]) {
1105
+ const { packageJson, path } = (0, package_json_1.readModulePackageJson)(packageName, (0, installation_directory_1.getNxRequirePaths)(root));
1106
+ // old workspaces would have the temp installation of nx in the cache,
1107
+ // so the resolved package is not the one we need
1108
+ if (!path.startsWith(workspace_root_1.workspaceRoot)) {
1109
+ throw new Error('Resolved a package outside the workspace root.');
1110
+ }
1111
+ cache[packageName] = packageJson.version;
1112
+ }
1113
+ return cache[packageName];
1114
+ }
1115
+ catch {
1116
+ return null;
1117
+ }
1118
+ }
1119
+ return getInstalledPackageVersion;
1120
+ }
1121
+ // testing-fetch-start
1122
+ function createFetcher(pmc) {
1123
+ const migrationsCache = {};
1124
+ const resolvedVersionCache = {};
1125
+ const stats = { registryCount: 0, installCount: 0 };
1126
+ function recordInstallFetch(reason) {
1127
+ stats.installCount++;
1128
+ stats.fallbackReason ??= reason;
1129
+ }
1130
+ function fetchMigrations(packageName, packageVersion, setCache) {
1131
+ if (!(0, resolve_package_version_1.isRegistryResolutionEnabled)()) {
1132
+ // Skip registry fetch and use installation method directly
1133
+ logger_1.logger.info(`Fetching ${packageName}@${packageVersion}`);
1134
+ recordInstallFetch('env-skip');
1135
+ return getPackageMigrationsUsingInstall(packageName, packageVersion, pmc);
1136
+ }
1137
+ const cacheKey = packageName + '-' + packageVersion;
1138
+ return Promise.resolve(resolvedVersionCache[cacheKey])
1139
+ .then((cachedResolvedVersion) => {
1140
+ if (cachedResolvedVersion) {
1141
+ return cachedResolvedVersion;
1142
+ }
1143
+ resolvedVersionCache[cacheKey] =
1144
+ (0, resolve_package_version_1.resolvePackageVersionRespectingMinReleaseAge)(packageName, packageVersion);
1145
+ return resolvedVersionCache[cacheKey];
1146
+ })
1147
+ .then((resolvedVersion) => {
1148
+ if (resolvedVersion !== packageVersion &&
1149
+ migrationsCache[`${packageName}-${resolvedVersion}`]) {
1150
+ return migrationsCache[`${packageName}-${resolvedVersion}`];
1151
+ }
1152
+ setCache(packageName, resolvedVersion);
1153
+ return getPackageMigrationsUsingRegistry(packageName, resolvedVersion).then((result) => {
1154
+ stats.registryCount++;
1155
+ return result;
1156
+ });
1157
+ })
1158
+ .catch((e) => {
1159
+ // A cooldown violation would fail an install identically (only slower),
1160
+ // so surface it instead of retrying through the package manager.
1161
+ if (e instanceof errors_1.MinReleaseAgeViolationError) {
1162
+ throw e;
1163
+ }
1164
+ logger_1.logger.verbose(`Failed to get migrations from registry for ${packageName}@${packageVersion}: ${e.message}. Falling back to install.`);
1165
+ logger_1.logger.info(`Fetching ${packageName}@${packageVersion}`);
1166
+ recordInstallFetch((0, migrate_analytics_1.classifyMigrateFetchFallback)(e));
1167
+ return getPackageMigrationsUsingInstall(packageName, packageVersion, pmc);
1168
+ });
1169
+ }
1170
+ const nxMigrateFetcher = (packageName, packageVersion) => {
1171
+ if (migrationsCache[`${packageName}-${packageVersion}`]) {
1172
+ return migrationsCache[`${packageName}-${packageVersion}`];
1173
+ }
1174
+ let resolvedVersion = packageVersion;
1175
+ let migrations;
1176
+ function setCache(packageName, packageVersion) {
1177
+ migrationsCache[packageName + '-' + packageVersion] = migrations;
1178
+ }
1179
+ migrations = fetchMigrations(packageName, packageVersion, setCache).then((result) => {
1180
+ // An exact requested version must come back verbatim; a mismatch means
1181
+ // a config surface (registry proxy, override, cooldown gate) silently
1182
+ // substituted another version, which would corrupt the whole plan.
1183
+ if ((0, semver_1.valid)(packageVersion) &&
1184
+ result.version &&
1185
+ result.version !== packageVersion) {
1186
+ throw new Error(`Fetching ${packageName}@${packageVersion} resolved to version ${result.version}. ` +
1187
+ `Check for registry, override, or minimum-release-age configuration that hides the requested version.`);
1188
+ }
1189
+ if (result.schematics) {
1190
+ result.generators = { ...result.schematics, ...result.generators };
1191
+ delete result.schematics;
1192
+ }
1193
+ resolvedVersion = result.version;
1194
+ return result;
1195
+ });
1196
+ setCache(packageName, packageVersion);
1197
+ return migrations;
1198
+ };
1199
+ nxMigrateFetcher.stats = stats;
1200
+ return nxMigrateFetcher;
1201
+ }
1202
+ // testing-fetch-end
1203
+ async function getPackageMigrationsUsingRegistry(packageName, packageVersion) {
1204
+ if ((0, provenance_1.getNxPackageGroup)().includes(packageName)) {
1205
+ await (0, provenance_1.ensurePackageHasProvenance)(packageName, packageVersion);
1206
+ }
1207
+ // check if there are migrations in the packages by looking at the
1208
+ // registry directly
1209
+ const migrationsConfig = await getPackageMigrationsConfigFromRegistry(packageName, packageVersion);
1210
+ if (!migrationsConfig) {
1211
+ return {
1212
+ name: packageName,
1213
+ version: packageVersion,
1214
+ };
1215
+ }
1216
+ if (!migrationsConfig.migrations) {
1217
+ return {
1218
+ name: packageName,
1219
+ version: packageVersion,
1220
+ packageGroup: migrationsConfig.packageGroup,
1221
+ supportsOptionalMigrations: migrationsConfig.supportsOptionalMigrations,
1222
+ };
1223
+ }
1224
+ logger_1.logger.info(`Fetching ${packageName}@${packageVersion}`);
1225
+ // try to obtain the migrations from the registry directly
1226
+ return await downloadPackageMigrationsFromRegistry(packageName, packageVersion, migrationsConfig);
1227
+ }
1228
+ // Matched exactly: a hostname that merely contains one of these is a different
1229
+ // registry. registry.yarnpkg.com is npmjs' CNAME, so it serves the same
1230
+ // metadata; the two loopback literals are the spellings of a local registry
1231
+ // that the substring below cannot reach, since neither contains "localhost".
1232
+ const FULL_METADATA_REGISTRIES = [
1233
+ 'registry.npmjs.org',
1234
+ 'registry.yarnpkg.com',
1235
+ '127.0.0.1',
1236
+ '[::1]',
1237
+ ];
1238
+ // Matched as substrings, since neither names a single host: a local registry
1239
+ // can sit on a subdomain of localhost, and an Artifactory instance is
1240
+ // identified only by that word appearing somewhere in its hostname.
1241
+ const FULL_METADATA_REGISTRY_MARKERS = [
1242
+ 'localhost',
1243
+ 'artifactory',
1244
+ ];
1245
+ async function getPackageMigrationsConfigFromRegistry(packageName, packageVersion) {
1246
+ const result = await (0, package_manager_1.packageRegistryView)(packageName, packageVersion, [
1247
+ 'nx-migrations',
1248
+ 'ng-update',
1249
+ 'dist',
1250
+ '--json',
1251
+ ]);
1252
+ if (!result) {
1253
+ return null;
1254
+ }
1255
+ const json = (0, package_manager_1.parseRegistryViewJson)(result);
1256
+ if (!json['nx-migrations'] && !json['ng-update']) {
1257
+ const registry = new node_url_1.URL('dist' in json ? json.dist.tarball : json.tarball)
1258
+ .hostname;
1259
+ // Other registries may not support full metadata via npm view; throw to
1260
+ // trigger the install fallback.
1261
+ if (!FULL_METADATA_REGISTRIES.includes(registry) &&
1262
+ !FULL_METADATA_REGISTRY_MARKERS.some((v) => registry.includes(v))) {
1263
+ throw new Error(`Getting migration config from registry is not supported from ${registry}`);
1264
+ }
1265
+ }
1266
+ return (0, package_json_1.readNxMigrateConfig)(json);
1267
+ }
1268
+ async function downloadPackageMigrationsFromRegistry(packageName, packageVersion, { migrations: migrationsFilePath, packageGroup, supportsOptionalMigrations, }) {
1269
+ const { dir, cleanup } = (0, package_manager_1.createTempNpmDirectory)();
1270
+ let result;
1271
+ try {
1272
+ const { tarballPath } = await (0, package_manager_1.packageRegistryPack)(dir, packageName, packageVersion,
1273
+ // packageVersion is exact and already resolved through the workspace
1274
+ // package manager's min-release-age policy by the fetcher. In an npm
1275
+ // workspace the pack gate IS that policy, so leave it enforcing; for
1276
+ // other package managers npm's gate is foreign config with no
1277
+ // exclusions and would wrongly re-judge the vetted version.
1278
+ { bypassMinReleaseAge: (0, package_manager_1.detectPackageManager)() !== 'npm' });
1279
+ const fullTarballPath = (0, path_1.join)(dir, tarballPath);
1280
+ let migrations;
1281
+ try {
1282
+ migrations = await (0, tar_1.extractFileFromTarball)(fullTarballPath, (0, path_2.joinPathFragments)('package', migrationsFilePath), (0, path_1.join)(dir, migrationsFilePath)).then((path) => (0, fileutils_1.readJsonFile)(path));
1283
+ }
1284
+ catch {
1285
+ throw new Error(`Failed to find migrations file "${migrationsFilePath}" in package "${packageName}@${packageVersion}".`);
1286
+ }
1287
+ (0, prompt_files_1.validateMigrationEntries)(packageName, packageVersion, migrations);
1288
+ const resolvedPromptFiles = await (0, prompt_files_1.extractPromptFilesFromTarball)(packageName, packageVersion, migrations, migrationsFilePath, fullTarballPath, dir);
1289
+ result = {
1290
+ ...migrations,
1291
+ packageGroup,
1292
+ supportsOptionalMigrations,
1293
+ version: packageVersion,
1294
+ ...(resolvedPromptFiles ? { resolvedPromptFiles } : {}),
1295
+ };
1296
+ }
1297
+ finally {
1298
+ await cleanup();
1299
+ }
1300
+ return result;
1301
+ }
1302
+ function createConcurrencyLimiter(concurrency) {
1303
+ const queue = [];
1304
+ let active = 0;
1305
+ function next() {
1306
+ while (queue.length > 0 && active < concurrency) {
1307
+ active++;
1308
+ queue.shift()();
1309
+ }
1310
+ }
1311
+ return function limit(fn) {
1312
+ return new Promise((resolve, reject) => {
1313
+ queue.push(() => {
1314
+ fn()
1315
+ .then(resolve, reject)
1316
+ .finally(() => {
1317
+ active--;
1318
+ next();
1319
+ });
1320
+ });
1321
+ next();
1322
+ });
1323
+ };
1324
+ }
1325
+ const installConcurrencyLimit = process.env.NX_MIGRATE_INSTALL_CONCURRENCY
1326
+ ? createConcurrencyLimiter(Math.max(1, Math.floor(Number(process.env.NX_MIGRATE_INSTALL_CONCURRENCY)) || 1))
1327
+ : null;
1328
+ async function getPackageMigrationsUsingInstall(packageName, packageVersion, pmc) {
1329
+ const run = () => getPackageMigrationsUsingInstallImpl(packageName, packageVersion, pmc);
1330
+ return installConcurrencyLimit ? installConcurrencyLimit(run) : run();
1331
+ }
1332
+ async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion, pmc) {
1333
+ const { dir, cleanup } = (0, package_manager_1.createTempNpmDirectory)();
1334
+ let result;
1335
+ if ((0, provenance_1.getNxPackageGroup)().includes(packageName)) {
1336
+ await (0, provenance_1.ensurePackageHasProvenance)(packageName, packageVersion);
1337
+ }
1338
+ try {
1339
+ const addCommand = `${pmc.add} ${packageName}@${packageVersion}`;
1340
+ try {
1341
+ await execAsync(addCommand, {
1342
+ cwd: dir,
1343
+ env: {
1344
+ ...process.env,
1345
+ npm_config_legacy_peer_deps: 'true',
1346
+ },
1347
+ });
1348
+ }
1349
+ catch (e) {
1350
+ // Only the install command failed; format it as a command failure so the
1351
+ // user sees the package manager's stderr. Errors from the later steps
1352
+ // (reading/validating migrations, resolving prompt files) are surfaced
1353
+ // as-is by the outer catch instead of being mislabeled as install failures.
1354
+ throw new Error(formatCommandFailure(addCommand, e));
1355
+ }
1356
+ const { migrations: migrationsFilePath, packageGroup, supportsOptionalMigrations, packageJson, } = (0, execute_migration_1.readPackageMigrationConfig)(packageName, dir);
1357
+ let migrations = undefined;
1358
+ let resolvedPromptFiles;
1359
+ if (migrationsFilePath) {
1360
+ migrations = (0, fileutils_1.readJsonFile)(migrationsFilePath);
1361
+ (0, prompt_files_1.validateMigrationEntries)(packageName, packageVersion, migrations);
1362
+ resolvedPromptFiles = await (0, prompt_files_1.readPromptFilesFromInstall)(packageName, packageVersion, migrations, migrationsFilePath);
1363
+ }
1364
+ result = {
1365
+ ...migrations,
1366
+ packageGroup,
1367
+ supportsOptionalMigrations,
1368
+ version: packageJson.version,
1369
+ ...(resolvedPromptFiles ? { resolvedPromptFiles } : {}),
1370
+ };
1371
+ }
1372
+ catch (e) {
1373
+ throw new Error([
1374
+ `Failed to fetch migrations for ${packageName}@${packageVersion}`,
1375
+ e instanceof Error ? e.message : String(e),
1376
+ ].join('\n'));
1377
+ }
1378
+ finally {
1379
+ await cleanup();
1380
+ }
1381
+ return result;
1382
+ }
1383
+ async function createMigrationsFile(root, migrations) {
1384
+ await (0, write_formatted_json_file_1.writeFormattedJsonFile)((0, path_1.join)(root, 'migrations.json'), { migrations });
1385
+ }
1386
+ async function updatePackageJson(root, updatedPackages) {
1387
+ const packageJsonPath = (0, path_1.join)(root, 'package.json');
1388
+ if (!(0, fs_1.existsSync)(packageJsonPath)) {
1389
+ return false;
1390
+ }
1391
+ const parseOptions = {};
1392
+ const json = (0, fileutils_1.readJsonFile)(packageJsonPath, parseOptions);
1393
+ const manager = (0, catalog_1.getCatalogManager)(root);
1394
+ const catalogUpdates = [];
1395
+ let modified = false;
1396
+ Object.keys(updatedPackages).forEach((p) => {
1397
+ const existingVersion = json.dependencies?.[p] ?? json.devDependencies?.[p];
1398
+ if (existingVersion && manager?.isCatalogReference(existingVersion)) {
1399
+ const { catalogName } = manager.parseCatalogReference(existingVersion);
1400
+ catalogUpdates.push({
1401
+ packageName: p,
1402
+ version: updatedPackages[p].version,
1403
+ catalogName,
1404
+ });
1405
+ // don't overwrite the catalog reference with the new version
1406
+ return;
1407
+ }
1408
+ // Update non-catalog packages in package.json
1409
+ if (json.devDependencies?.[p]) {
1410
+ if (json.devDependencies[p] !== updatedPackages[p].version) {
1411
+ json.devDependencies[p] = updatedPackages[p].version;
1412
+ modified = true;
1413
+ }
1414
+ return;
1415
+ }
1416
+ if (json.dependencies?.[p]) {
1417
+ if (json.dependencies[p] !== updatedPackages[p].version) {
1418
+ json.dependencies[p] = updatedPackages[p].version;
1419
+ modified = true;
1420
+ }
1421
+ return;
1422
+ }
1423
+ const dependencyType = updatedPackages[p].addToPackageJson;
1424
+ if (typeof dependencyType === 'string') {
1425
+ json[dependencyType] ??= {};
1426
+ if (json[dependencyType][p] !== updatedPackages[p].version) {
1427
+ json[dependencyType][p] = updatedPackages[p].version;
1428
+ modified = true;
1429
+ }
1430
+ }
1431
+ });
1432
+ if (modified) {
1433
+ await (0, write_formatted_json_file_1.writeFormattedJsonFile)(packageJsonPath, json, {
1434
+ appendNewLine: parseOptions.endsWithNewline,
1435
+ });
1436
+ }
1437
+ // Update catalog definitions
1438
+ if (catalogUpdates.length) {
1439
+ // manager is guaranteed to be defined when there are catalog updates
1440
+ manager.updateCatalogVersions(root, catalogUpdates);
1441
+ await formatCatalogDefinitionFiles(manager, root);
1442
+ }
1443
+ return modified || catalogUpdates.length > 0;
1444
+ }
1445
+ async function formatCatalogDefinitionFiles(manager, root) {
1446
+ const catalogDefinitionFilePaths = manager.getCatalogDefinitionFilePaths();
1447
+ const catalogDefinitionFiles = catalogDefinitionFilePaths.map((filePath) => {
1448
+ const absolutePath = (0, path_1.join)(root, filePath);
1449
+ return {
1450
+ path: filePath,
1451
+ absolutePath,
1452
+ content: (0, fs_1.readFileSync)(absolutePath, 'utf-8'),
1453
+ };
1454
+ });
1455
+ const results = await (0, format_changed_files_1.formatFileContents)(catalogDefinitionFiles.map(({ path, content }) => ({ path, content })), root, { silent: true });
1456
+ for (const { path, absolutePath, content } of catalogDefinitionFiles) {
1457
+ (0, fs_1.writeFileSync)(absolutePath, results.has(path) ? results.get(path) : content, { encoding: 'utf-8' });
1458
+ }
1459
+ }
1460
+ async function updateInstallationDetails(root, updatedPackages) {
1461
+ const nxJsonPath = (0, path_1.join)(root, 'nx.json');
1462
+ const parseOptions = {};
1463
+ const nxJson = (0, fileutils_1.readJsonFile)(nxJsonPath, parseOptions);
1464
+ if (!nxJson.installation) {
1465
+ return false;
1466
+ }
1467
+ let modified = false;
1468
+ const nxVersion = updatedPackages.nx?.version;
1469
+ if (nxVersion && nxJson.installation.version !== nxVersion) {
1470
+ nxJson.installation.version = nxVersion;
1471
+ modified = true;
1472
+ }
1473
+ if (nxJson.installation.plugins) {
1474
+ for (const dep in nxJson.installation.plugins) {
1475
+ const update = updatedPackages[dep];
1476
+ if (update) {
1477
+ const newVersion = (0, semver_1.valid)(update.version)
1478
+ ? update.version
1479
+ : await (0, resolve_package_version_1.resolvePackageVersionRespectingMinReleaseAge)(dep, update.version);
1480
+ if (nxJson.installation.plugins[dep] !== newVersion) {
1481
+ nxJson.installation.plugins[dep] = newVersion;
1482
+ modified = true;
1483
+ }
1484
+ }
1485
+ }
1486
+ }
1487
+ if (modified) {
1488
+ await (0, write_formatted_json_file_1.writeFormattedJsonFile)(nxJsonPath, nxJson, {
1489
+ appendNewLine: parseOptions.endsWithNewline,
1490
+ });
1491
+ }
1492
+ return modified;
1493
+ }
1494
+ async function isMigratingToNewMajor(from, to) {
1495
+ from = (0, version_utils_1.normalizeVersion)(from);
1496
+ to = ['latest', 'next', 'canary'].includes(to) ? to : (0, version_utils_1.normalizeVersion)(to);
1497
+ if (!(0, semver_1.valid)(from)) {
1498
+ from = await (0, resolve_package_version_1.resolvePackageVersionRespectingMinReleaseAge)('nx', from);
1499
+ }
1500
+ if (!(0, semver_1.valid)(to)) {
1501
+ to = await (0, resolve_package_version_1.resolvePackageVersionRespectingMinReleaseAge)('nx', to);
1502
+ }
1503
+ return (0, semver_1.major)(from) < (0, semver_1.major)(to);
1504
+ }
1505
+ function readNxVersion(packageJson, root) {
1506
+ return ((0, package_json_1.getDependencyVersionFromPackageJson)('nx', root, packageJson) ??
1507
+ (0, package_json_1.getDependencyVersionFromPackageJson)('@nx/workspace', root, packageJson) ??
1508
+ (0, package_json_1.getDependencyVersionFromPackageJson)('@nrwl/workspace', root, packageJson));
1509
+ }
1510
+ // Exported for testing the optional-include orchestration seam (see NXC-4590).
1511
+ async function generateMigrationsJsonAndUpdatePackageJson(root, opts, fetch) {
1512
+ const pmc = (0, package_manager_1.getPackageManagerCommand)();
1513
+ let phase = 'fetch_migrations';
1514
+ try {
1515
+ const rootPkgJsonPath = (0, path_1.join)(root, 'package.json');
1516
+ let originalPackageJson = (0, fs_1.existsSync)(rootPkgJsonPath)
1517
+ ? (0, fileutils_1.readJsonFile)(rootPkgJsonPath)
1518
+ : null;
1519
+ const originalNxJson = (0, configuration_1.readNxJson)();
1520
+ const from = originalNxJson.installation?.version ??
1521
+ readNxVersion(originalPackageJson, root);
1522
+ const include = opts.include;
1523
+ (0, migrate_analytics_1.setMigrateInclude)(include);
1524
+ let walkedTargetPackage = opts.targetPackage;
1525
+ let fromOverrides = opts.from;
1526
+ let excludeApplied = opts.excludeAppliedMigrations;
1527
+ if (include === 'optional') {
1528
+ // The `optional` value catches up the deps the target manages, so walk the
1529
+ // target from zero, against `nx`'s full managed-deps closure.
1530
+ walkedTargetPackage = toNxClosurePackage(opts.targetPackage);
1531
+ fromOverrides = { [walkedTargetPackage]: '0.0.0' };
1532
+ excludeApplied = true;
1533
+ }
1534
+ logger_1.logger.info(`Fetching meta data about packages.`);
1535
+ logger_1.logger.info(`It may take a few minutes.`);
1536
+ const resolvedFetch = fetch ?? createFetcher(pmc);
1537
+ let requiredPackages;
1538
+ if (include === 'required' || include === 'optional') {
1539
+ // `@nx/workspace` declares an intentionally narrow `packageGroup`
1540
+ // ({ nx, nx-cloud }) in its migrations config, whereas `nx` declares the
1541
+ // full @nx/* plugin fan-out. Their transitive required closures are
1542
+ // equivalent, so resolve the closure against `nx`.
1543
+ const sourcePackage = toNxClosurePackage(walkedTargetPackage);
1544
+ const rootMetadata = await resolvedFetch(sourcePackage, opts.targetVersion);
1545
+ // Legacy `@nrwl/workspace<14` doesn't ship a complete `packageGroup`
1546
+ // in its metadata; the Migrator's cascade injects
1547
+ // `LEGACY_NRWL_PACKAGE_GROUP` for that case, and the post-build
1548
+ // optional filter must mirror that set or required `@nrwl/*`
1549
+ // plugins slip past it.
1550
+ const packageGroup = sourcePackage === '@nrwl/workspace' && (0, version_utils_1.isLegacyEra)(opts.targetVersion)
1551
+ ? LEGACY_NRWL_PACKAGE_GROUP
1552
+ : rootMetadata.packageGroup;
1553
+ requiredPackages = resolveRequiredPackages(sourcePackage, packageGroup);
1554
+ }
1555
+ const installedPackageVersions = createInstalledPackageVersionsResolver(root);
1556
+ const migrator = new Migrator({
1557
+ packageJson: originalPackageJson,
1558
+ nxInstallation: originalNxJson.installation,
1559
+ getInstalledPackageVersion: installedPackageVersions,
1560
+ fetch: resolvedFetch,
1561
+ from: fromOverrides,
1562
+ to: opts.to,
1563
+ interactive: opts.interactive && !(0, is_ci_1.isCI)(),
1564
+ excludeAppliedMigrations: excludeApplied,
1565
+ include,
1566
+ requiredPackages,
1567
+ });
1568
+ const { migrations, packageUpdates, promptContents, minVersionWithSkippedUpdates, } = await migrator.migrate(walkedTargetPackage, opts.targetVersion);
1569
+ // The cascade collects packageJsonUpdates entries against the cascade
1570
+ // root's installed version, but inner per-package pins are only gated
1571
+ // against the in-flight cascade tally — not against each inner package's
1572
+ // installed version. A from-zero walk (e.g. `--include=optional`) can
1573
+ // surface a stale historical pin that would write a lower version than
1574
+ // the user already has. Drop those before writing; nx migrate is
1575
+ // forward-only, never a downgrade.
1576
+ phase = 'package_updates';
1577
+ // Resolve catalog: specifiers first so the filter compares real versions.
1578
+ const writableUpdates = (0, update_filters_1.filterDowngradedUpdates)(packageUpdates, (0, catalog_1.resolveCatalogSpecifiers)(originalPackageJson), installedPackageVersions);
1579
+ const wrotePackageJson = await updatePackageJson(root, writableUpdates);
1580
+ const wroteNxJsonInstallation = await updateInstallationDetails(root, writableUpdates);
1581
+ // Under `--include=optional` the target's own entry is filtered out of
1582
+ // `packageUpdates` (it's a required package), so resolve the version
1583
+ // defensively. Also reused by the completion analytics below.
1584
+ const resolvedTargetVersion = packageUpdates[walkedTargetPackage]?.version ?? opts.targetVersion;
1585
+ const promptMigrationFiles = (0, prompt_files_1.writePromptMigrationFiles)(root, migrations, promptContents ?? {}, resolvedTargetVersion);
1586
+ if (migrations.length > 0) {
1587
+ await createMigrationsFile(root, [
1588
+ ...addSplitConfigurationMigrationIfAvailable(from, writableUpdates),
1589
+ ...migrations,
1590
+ ]);
1591
+ }
1592
+ const includeLine = include === 'required'
1593
+ ? `- Processed required updates only (skipped optional dependency bumps).`
1594
+ : include === 'optional'
1595
+ ? `- Processed optional dependency updates only (skipped required package updates).`
1596
+ : null;
1597
+ // The param expressions below evaluate before the report function is
1598
+ // entered; `safeReport` keeps them inside the analytics boundary so a
1599
+ // param-building throw can't surface here and convert an already
1600
+ // successful migrate into a reported failure.
1601
+ const recordCompletion = () => (0, migrate_analytics_1.safeReport)(() => (0, migrate_analytics_1.reportMigrateGenerateComplete)({
1602
+ targetVersion: resolvedTargetVersion,
1603
+ requestedTargetVersion: opts.originalTargetVersion ?? resolvedTargetVersion,
1604
+ installedTargetVersion: (0, multi_major_1.isNxTarget)(opts.targetPackage, opts.targetVersion)
1605
+ ? from
1606
+ : installedPackageVersions(opts.targetPackage),
1607
+ include,
1608
+ multiMajorChoice: opts.multiMajorChoice,
1609
+ fetchStats: resolvedFetch.stats,
1610
+ }));
1611
+ const noChanges = !wrotePackageJson && !wroteNxJsonInstallation && migrations.length === 0;
1612
+ if (noChanges) {
1613
+ output_1.output.success({
1614
+ title: `No updates were applied.`,
1615
+ bodyLines: [
1616
+ ...(includeLine ? [includeLine] : []),
1617
+ include === 'optional'
1618
+ ? `- No optional dependency updates were found for the installed version. Either your dependencies are already up to date, or this workspace doesn't manage them in a place 'nx migrate' writes to (e.g. non-JS workspaces).`
1619
+ : `- No package updates or migrations were found.`,
1620
+ ],
1621
+ });
1622
+ // Nothing was applied; skip the "Next steps" guidance below — it would
1623
+ // tell the user to inspect package.json changes that don't exist.
1624
+ recordCompletion();
1625
+ return;
1626
+ }
1627
+ output_1.output.success({
1628
+ title: `The migrate command has run successfully.`,
1629
+ bodyLines: [
1630
+ ...(includeLine ? [includeLine] : []),
1631
+ ...(wrotePackageJson ? [`- package.json has been updated.`] : []),
1632
+ ...(wroteNxJsonInstallation
1633
+ ? [`- nx.json (installation) has been updated.`]
1634
+ : []),
1635
+ migrations.length > 0
1636
+ ? `- migrations.json has been generated.`
1637
+ : `- There are no migrations to run, so migrations.json has not been created.`,
1638
+ ...(promptMigrationFiles.length > 0
1639
+ ? [
1640
+ `- ${promptMigrationFiles.length} AI migration prompt(s) have been written to ${prompt_files_1.AI_MIGRATIONS_DIR}/.`,
1641
+ ]
1642
+ : []),
1643
+ ],
1644
+ });
1645
+ try {
1646
+ if (opts.interactive !== false &&
1647
+ ['nx', '@nrwl/workspace'].includes(opts.targetPackage) &&
1648
+ (await isMigratingToNewMajor(from, opts.targetVersion)) &&
1649
+ !(0, is_ci_1.isCI)() &&
1650
+ !(0, nx_cloud_utils_1.isNxCloudDisabled)(originalNxJson) &&
1651
+ !(0, nx_cloud_utils_1.isNxCloudUsed)(originalNxJson)) {
1652
+ output_1.output.success({
1653
+ title: 'Connect to Nx Cloud',
1654
+ bodyLines: [
1655
+ 'Nx Cloud is a first-party CI companion for Nx projects. It improves critical aspects of CI:',
1656
+ '- Speed: 30% - 70% faster CI',
1657
+ '- Cost: 40% - 75% reduction in CI costs',
1658
+ '- Reliability: by automatically identifying flaky tasks and re-running them',
1659
+ ],
1660
+ });
1661
+ await (0, connect_to_nx_cloud_1.connectToNxCloudWithPrompt)('migrate');
1662
+ originalPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
1663
+ }
1664
+ }
1665
+ catch {
1666
+ // The above code is to remind folks when updating to a new major and not currently using Nx cloud.
1667
+ // If for some reason it fails, it shouldn't affect the overall migration process
1668
+ }
1669
+ const bodyLines = process.env['NX_CONSOLE']
1670
+ ? [
1671
+ '- Inspect the package.json changes in the built-in diff editor [Click to open]',
1672
+ '- Confirm the changes to install the new dependencies and continue the migration',
1673
+ ]
1674
+ : [
1675
+ `- Make sure package.json changes make sense and then run '${pmc.install}',`,
1676
+ ...(promptMigrationFiles.length > 0
1677
+ ? [
1678
+ `- Review and tweak the AI migration prompts in ${prompt_files_1.AI_MIGRATIONS_DIR}/ as needed.`,
1679
+ ]
1680
+ : []),
1681
+ ...(migrations.length > 0
1682
+ ? [`- Run '${pmc.exec} nx migrate --run-migrations'`]
1683
+ : []),
1684
+ ...(opts.originalTargetVersion
1685
+ ? [
1686
+ `- After applying these migrations, run '${pmc.exec} nx migrate ${opts.targetPackage}@${opts.originalTargetVersion} --include=${opts.include}${opts.multiMajorMode === 'gradual'
1687
+ ? ` ${multi_major_1.MULTI_MAJOR_MODE_FLAG}=gradual`
1688
+ : ''}' to continue toward your original target.`,
1689
+ ]
1690
+ : []),
1691
+ ...(opts.interactive && minVersionWithSkippedUpdates
1692
+ ? [
1693
+ `- You opted out of some migrations for now. Write the following command down somewhere to apply these migrations later:`,
1694
+ ` nx migrate ${opts.targetVersion} --from ${opts.targetPackage}@${minVersionWithSkippedUpdates} --exclude-applied-migrations`,
1695
+ `- To learn more go to https://nx.dev/recipes/tips-n-tricks/advanced-update`,
1696
+ ]
1697
+ : [
1698
+ `- To learn more go to https://nx.dev/features/automate-updating-dependencies`,
1699
+ ]),
1700
+ ...(showConnectToCloudMessage()
1701
+ ? [
1702
+ `- You may run '${pmc.run('nx', 'connect-to-nx-cloud')}' to get faster builds, GitHub integration, and more. Check out https://nx.app`,
1703
+ ]
1704
+ : []),
1705
+ ];
1706
+ output_1.output.log({
1707
+ title: 'Next steps:',
1708
+ bodyLines,
1709
+ });
1710
+ recordCompletion();
1711
+ }
1712
+ catch (e) {
1713
+ (0, migrate_analytics_1.reportMigrateGenerateError)(phase, e);
1714
+ output_1.output.error({
1715
+ title: `The migrate command failed.`,
1716
+ });
1717
+ throw e;
1718
+ }
1719
+ }
1720
+ function addSplitConfigurationMigrationIfAvailable(from, packageJson) {
1721
+ if (!packageJson['@nrwl/workspace'])
1722
+ return [];
1723
+ if ((0, semver_1.gte)(packageJson['@nrwl/workspace'].version, '15.7.0-beta.0') &&
1724
+ (0, semver_1.lt)((0, version_utils_1.normalizeVersion)(from), '15.7.0-beta.0')) {
1725
+ return [
1726
+ {
1727
+ version: '15.7.0-beta.0',
1728
+ description: 'Split global configuration files into individual project.json files. This migration has been added automatically to the beginning of your migration set to retroactively make them work with the new version of Nx.',
1729
+ implementation: './src/migrations/update-15-7-0/split-configuration-into-project-json-files',
1730
+ package: '@nrwl/workspace',
1731
+ name: '15-7-0-split-configuration-into-project-json-files',
1732
+ },
1733
+ ];
1734
+ }
1735
+ else {
1736
+ return [];
1737
+ }
1738
+ }
1739
+ function showConnectToCloudMessage() {
1740
+ try {
1741
+ const nxJson = (0, configuration_1.readNxJson)();
1742
+ const defaultRunnerIsUsed = (0, connect_to_nx_cloud_1.onlyDefaultRunnerIsUsed)(nxJson);
1743
+ return !!defaultRunnerIsUsed;
1744
+ }
1745
+ catch {
1746
+ return false;
1747
+ }
1748
+ }
1749
+ function formatSkippedPromptsNextStep(skipped) {
1750
+ return [
1751
+ 'Some prompt migrations were skipped. Review and apply each of the following prompt files to the workspace, in the listed order:',
1752
+ ...skipped.map((m) => ` - ${m.prompt}`),
1753
+ ].join('\n');
1754
+ }
1755
+ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix, shouldSkipInstall = false, agentic, agenticHasDiffContext = false, shouldRunValidation = false) {
1756
+ const changedDepInstaller = new execute_migration_1.ChangedDepInstaller(root, shouldSkipInstall);
1757
+ const migrationsWithNoChanges = [];
1758
+ const sortedMigrations = (0, sort_migrations_1.sortMigrations)(migrations, {
1759
+ hoistHandoffGitignore: agentic?.kind === 'enabled',
1760
+ });
1761
+ // Lazy-load the agentic chain so non-agentic runs don't pay its startup cost.
1762
+ let agenticRun;
1763
+ if (agentic?.kind === 'enabled' && sortedMigrations.length > 0) {
1764
+ const { initRunDir, resolveAgenticRunId } = require('./agentic/handoff');
1765
+ const { runAgenticPromptStep } = require('./agentic/run-step');
1766
+ agenticRun = {
1767
+ agentic,
1768
+ runDir: initRunDir(root, resolveAgenticRunId(sortedMigrations)),
1769
+ runStep: runAgenticPromptStep,
1770
+ };
1771
+ }
1772
+ const printDroppedAgentContext = agentic?.kind === 'inside-agent'
1773
+ ? require('./agentic/print-dropped-agent-context').printDroppedAgentContextForOuterAgent
1774
+ : undefined;
1775
+ logger_1.logger.info(`Running the following migrations:`);
1776
+ sortedMigrations.forEach((m) => logger_1.logger.info(m.description
1777
+ ? `- ${m.package}: ${m.name} — ${m.description}`
1778
+ : `- ${m.package}: ${m.name}`));
1779
+ logger_1.logger.info('');
1780
+ // Tracked separately from `skippedPrompts` so the end-of-run logic can
1781
+ // render them distinctly per resolution mode.
1782
+ const migrationEmittedNextSteps = [];
1783
+ const skippedPrompts = [];
1784
+ // One record per migration the loop touched. `status: 'completed'` records
1785
+ // are pushed at the end of each successful iteration; `status: 'aborted'`
1786
+ // is pushed by the catch block when a migration throws mid-iteration, so
1787
+ // `outcomes` is the single source of truth for the recap and tally — no
1788
+ // parallel "pending" list. `outcomes.length` always equals `migrationIndex`
1789
+ // after the loop body runs.
1790
+ const outcomes = [];
1791
+ // Prompt-only migrations whose agent never ran. Hybrid migrations with a
1792
+ // skipped prompt are NOT counted here — their deterministic half still ran.
1793
+ let notRunMigrationsCount = 0;
1794
+ const skipReason = agentic?.kind === 'inside-agent'
1795
+ ? 'deferred to the AI agent driving this run'
1796
+ : 'agentic flow disabled';
1797
+ const installDepsIfChanged = () => changedDepInstaller.installDepsIfChanged();
1798
+ // Returns the migrations whose own commits failed and whose diffs are
1799
+ // still sitting in the working tree — derived live from `outcomes`. The
1800
+ // next successful commit absorbs them via `git add -A`; its commit body
1801
+ // lists them so a reader of `git log -p` can see which prior migrations'
1802
+ // diffs got pulled in.
1803
+ const pendingForCommitBody = () => outcomes
1804
+ .filter((o) => o.commit.kind === 'failed')
1805
+ .map((o) => ({ package: o.migration.package, name: o.migration.name }));
1806
+ // True while at least one prior migration's commit has failed and its
1807
+ // diff hasn't been absorbed yet. While true, the working tree carries
1808
+ // prior-migration state, so the `hasDiffContext` flag in the hybrid-
1809
+ // agentic and validation-agentic prompt branches is suppressed (the
1810
+ // prompt-only-with-agentic branch doesn't use `hasDiffContext`).
1811
+ const hasPendingCommitDebt = () => outcomes.some((o) => o.commit.kind === 'failed');
1812
+ // Single funnel for per-migration commit attempts. Returns the
1813
+ // `CommitState` to record on the migration's outcome. On `committed`,
1814
+ // back-annotates any prior failed-commit outcomes to `kind: 'absorbed'`
1815
+ // (their diffs were just rolled into this commit via `git add -A`).
1816
+ async function attemptMigrationCommit(m) {
1817
+ const pending = pendingForCommitBody();
1818
+ const result = await (0, migrate_commits_1.commitMigrationIfRequested)(root, m, shouldCreateCommits, commitPrefix, installDepsIfChanged, pending);
1819
+ if (result.status === 'committed') {
1820
+ // This commit absorbed every pending failed-commit migration's diff.
1821
+ // Transition their `commit.kind: 'failed'` records to `'absorbed'` so
1822
+ // the failure recap (if a later migration throws) can anchor them
1823
+ // and the retained-state filter no longer counts them as
1824
+ // uncommitted.
1825
+ //
1826
+ // The key is `package:name`; matching on `name` alone would conflate
1827
+ // across packages. Guard the kind check so a subsequent absorption-
1828
+ // of-same-name cannot overwrite an earlier annotation.
1829
+ if (pending.length > 0) {
1830
+ const absorbedKeys = new Set(pending.map((p) => `${p.package}:${p.name}`));
1831
+ for (const o of outcomes) {
1832
+ const key = `${o.migration.package}:${o.migration.name}`;
1833
+ if (absorbedKeys.has(key) && o.commit.kind === 'failed') {
1834
+ o.commit = {
1835
+ kind: 'absorbed',
1836
+ into: { name: m.name, sha: result.sha },
1837
+ };
1838
+ }
1839
+ }
1840
+ }
1841
+ return { kind: 'landed', sha: result.sha };
1842
+ }
1843
+ if (result.status === 'failed') {
1844
+ // Diff is still in WT. Subsequent prompts cannot claim git-isolation
1845
+ // until a later commit absorbs the backlog.
1846
+ return { kind: 'failed' };
1847
+ }
1848
+ // `no-changes` and `disabled` — no commit attempted, nothing to record
1849
+ // as a commit failure.
1850
+ return { kind: 'none' };
1851
+ }
1852
+ // Records what a migration's deterministic phase produced. A migration that
1853
+ // changed nothing must not attempt a commit: the absorbing `git add -A`
1854
+ // would build a commit subject naming this no-op migration even though its
1855
+ // content is entirely prior pending diffs, confusing `git log` / `git blame`
1856
+ // attribution. Pending stays pending and the next change-producing migration
1857
+ // absorbs it.
1858
+ async function commitOrRecordNoChanges(m, madeChanges) {
1859
+ if (!madeChanges) {
1860
+ migrationsWithNoChanges.push(m);
1861
+ return { kind: 'none' };
1862
+ }
1863
+ const commit = await attemptMigrationCommit(m);
1864
+ if (commit.kind === 'landed' && commit.sha) {
1865
+ logger_1.logger.info(pc.dim(`Committed as ${commit.sha}`));
1866
+ }
1867
+ return commit;
1868
+ }
1869
+ const totalMigrations = sortedMigrations.length;
1870
+ let migrationIndex = 0;
1871
+ for (const m of sortedMigrations) {
1872
+ migrationIndex++;
1873
+ (0, migrate_output_1.logMigrationBoundary)(migrationIndex, totalMigrations, m.package, m.name);
1874
+ // Snapshot the WT for before/after comparison in the catch block.
1875
+ // Content-sensitive so a dirty→dirty case (this migration mutating an
1876
+ // already-dirty shared file like `package.json`) doesn't collapse.
1877
+ const baselineWorkingTreeSnapshot = (0, git_utils_1.getUncommittedChangesSnapshot)(root);
1878
+ // Tracks whether a failure originated in the agentic step so the error
1879
+ // event classifies it as 'agentic' rather than 'migration_exec'.
1880
+ let inAgenticStep = false;
1881
+ try {
1882
+ // Read this migration's collection once and derive everything from it:
1883
+ // the implementation context (passed to runNxOrAngularMigration) and the
1884
+ // documentation path (passed to the agent). Read fresh per iteration so a
1885
+ // prior migration's reinstall is reflected.
1886
+ const { resolvedCollection, documentationPath } = resolveMigrationForRun(root, m, !!agenticRun);
1887
+ let outcome;
1888
+ let commit = { kind: 'none' };
1889
+ // Set when the migration returned `skipAgentic: true` and something was
1890
+ // actually waived, so the end-of-run recaps can report it. A hybrid's
1891
+ // prompt is owed in every agentic mode, so waiving it always counts; a
1892
+ // generator-only migration only counts when validation would have run.
1893
+ let waivedAgenticStep = false;
1894
+ if ((0, migration_shape_1.isPromptOnlyMigration)(m)) {
1895
+ if (agenticRun) {
1896
+ inAgenticStep = true;
1897
+ const stepResult = await agenticRun.runStep({
1898
+ root,
1899
+ migration: m,
1900
+ agentic: agenticRun.agentic,
1901
+ runDir: agenticRun.runDir,
1902
+ installDepsIfChanged,
1903
+ documentationPath,
1904
+ });
1905
+ inAgenticStep = false;
1906
+ commit = await attemptMigrationCommit(m);
1907
+ (0, migrate_output_1.logAgenticSuccessOutcome)(stepResult.ambiguous ? 'Marked complete by user' : 'Applied', commit.kind === 'landed' ? commit.sha : null, stepResult.summary);
1908
+ outcome = 'applied';
1909
+ }
1910
+ else {
1911
+ logger_1.logger.info(pc.dim(`↷ Skipped — ${skipReason}. Listed in next steps.`));
1912
+ skippedPrompts.push(m);
1913
+ notRunMigrationsCount++;
1914
+ outcome = 'deferred';
1915
+ }
1916
+ }
1917
+ else if ((0, migration_shape_1.isHybridMigration)(m)) {
1918
+ const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
1919
+ /* captureGeneratorOutput: */ !!agenticRun, resolvedCollection);
1920
+ migrationEmittedNextSteps.push(...nextSteps);
1921
+ if (skipAgentic) {
1922
+ // The generator reported the prompt half unnecessary, so nothing is
1923
+ // owed: no agent run, and no next-steps entry telling the user to
1924
+ // run the prompt themselves. Runs in all three agentic modes.
1925
+ (0, migrate_output_1.logWaivedAgenticStep)(m, agentContext);
1926
+ waivedAgenticStep = true;
1927
+ commit = await commitOrRecordNoChanges(m, madeChanges);
1928
+ outcome = madeChanges ? 'applied' : 'no-changes';
1929
+ }
1930
+ else if (agenticRun) {
1931
+ // Install any deps the deterministic phase added/bumped before the
1932
+ // agent runs — the prompt half may depend on them being present in
1933
+ // node_modules.
1934
+ await installDepsIfChanged();
1935
+ inAgenticStep = true;
1936
+ const stepResult = await agenticRun.runStep({
1937
+ root,
1938
+ migration: m,
1939
+ agentic: agenticRun.agentic,
1940
+ runDir: agenticRun.runDir,
1941
+ installDepsIfChanged,
1942
+ documentationPath,
1943
+ implContext: {
1944
+ logs,
1945
+ changes,
1946
+ agentContext,
1947
+ // When prior commits failed, the working tree carries their
1948
+ // diff. The git-inspect path of the prompt would mislead the
1949
+ // agent in that case; fall back to embedded `<files_changed>`.
1950
+ hasDiffContext: agenticHasDiffContext && !hasPendingCommitDebt(),
1951
+ },
1952
+ });
1953
+ inAgenticStep = false;
1954
+ commit = await attemptMigrationCommit(m);
1955
+ (0, migrate_output_1.logAgenticSuccessOutcome)(stepResult.ambiguous ? 'Marked complete by user' : 'Applied', commit.kind === 'landed' ? commit.sha : null, stepResult.summary);
1956
+ outcome = 'applied';
1957
+ }
1958
+ else {
1959
+ // The inner prompt step doesn't run here (agentic disabled, or
1960
+ // running inside an outer agent). Under `inside-agent`, surface the
1961
+ // generator-emitted `agentContext` to stdout so the outer driving
1962
+ // agent can ingest it. Under `disabled` the run is human-driven;
1963
+ // agent-targeted context would only add noise — drop.
1964
+ logger_1.logger.info(pc.dim(`↷ Prompt phase skipped — ${skipReason}. Listed in next steps.`));
1965
+ if (printDroppedAgentContext && agentContext.length > 0) {
1966
+ printDroppedAgentContext({ migration: m, agentContext });
1967
+ }
1968
+ skippedPrompts.push(m);
1969
+ commit = await commitOrRecordNoChanges(m, madeChanges);
1970
+ outcome = 'deferred';
1971
+ }
1972
+ }
1973
+ else {
1974
+ // Defer commit until validation succeeds; failed validation leaves
1975
+ // changes uncommitted in the working tree for the user to review.
1976
+ const validationRun = agenticRun && shouldRunValidation ? agenticRun : undefined;
1977
+ const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, m, isVerbose,
1978
+ /* captureGeneratorOutput: */ !!validationRun, resolvedCollection);
1979
+ migrationEmittedNextSteps.push(...nextSteps);
1980
+ // Whether a validation step was on the table at all. `skipAgentic`
1981
+ // waives nothing when it wasn't, so the whole waived path hangs off
1982
+ // this, not just the log line.
1983
+ const validationApplies = !!validationRun && changes.length > 0;
1984
+ const canRunValidation = validationApplies && !skipAgentic;
1985
+ if (canRunValidation) {
1986
+ // Install any deps the deterministic phase added/bumped before the
1987
+ // validation agent runs — the agent may run tasks that need them.
1988
+ await installDepsIfChanged();
1989
+ inAgenticStep = true;
1990
+ const stepResult = await validationRun.runStep({
1991
+ root,
1992
+ migration: m,
1993
+ agentic: validationRun.agentic,
1994
+ runDir: validationRun.runDir,
1995
+ installDepsIfChanged,
1996
+ documentationPath,
1997
+ implContext: {
1998
+ logs,
1999
+ changes,
2000
+ agentContext,
2001
+ // See the hybrid agentic branch above for the rationale on
2002
+ // why pending commit debt gates git-inspect context.
2003
+ hasDiffContext: agenticHasDiffContext && !hasPendingCommitDebt(),
2004
+ },
2005
+ mode: 'generic-validation',
2006
+ });
2007
+ inAgenticStep = false;
2008
+ commit = await attemptMigrationCommit(m);
2009
+ (0, migrate_output_1.logAgenticSuccessOutcome)(stepResult.ambiguous
2010
+ ? 'Marked complete by user'
2011
+ : 'Validation passed', commit.kind === 'landed' ? commit.sha : null, stepResult.summary);
2012
+ outcome = 'applied';
2013
+ }
2014
+ else {
2015
+ if (skipAgentic && validationApplies) {
2016
+ (0, migrate_output_1.logWaivedAgenticStep)(m, agentContext);
2017
+ waivedAgenticStep = true;
2018
+ }
2019
+ else if (printDroppedAgentContext && agentContext.length > 0) {
2020
+ // Inner validation step didn't run. Surface `agentContext` under
2021
+ // `inside-agent` so the outer driving agent can ingest it.
2022
+ printDroppedAgentContext({ migration: m, agentContext });
2023
+ }
2024
+ commit = await commitOrRecordNoChanges(m, madeChanges);
2025
+ outcome = madeChanges ? 'applied' : 'no-changes';
2026
+ }
2027
+ }
2028
+ outcomes.push({
2029
+ migration: { package: m.package, name: m.name },
2030
+ status: 'completed',
2031
+ kind: outcome,
2032
+ commit,
2033
+ waivedAgenticStep,
2034
+ });
2035
+ logger_1.logger.info('');
2036
+ }
2037
+ catch (e) {
2038
+ // Record the in-flight migration as `aborted` so the recap and tally
2039
+ // see it. `commit: 'failed'` requires both: (1) commits were
2040
+ // requested — otherwise the "could not be created" recap line is
2041
+ // false; (2) the WT snapshot diverged from the iteration baseline —
2042
+ // net-new state, not the pre-existing pending diff. Else `'none'`.
2043
+ const leftNewDiff = (0, git_utils_1.getUncommittedChangesSnapshot)(root) !== baselineWorkingTreeSnapshot;
2044
+ outcomes.push({
2045
+ migration: { package: m.package, name: m.name },
2046
+ status: 'aborted',
2047
+ commit: shouldCreateCommits && leftNewDiff
2048
+ ? { kind: 'failed' }
2049
+ : { kind: 'none' },
2050
+ });
2051
+ // `nx repair` reuses executeMigrations; only record for migrate runs.
2052
+ if ((0, migrate_analytics_1.hasMigrateRunStarted)()) {
2053
+ (0, migrate_analytics_1.reportMigrateRunError)({
2054
+ code: e instanceof execute_migration_1.NpmPeerDepsInstallError
2055
+ ? 'npm_install'
2056
+ : inAgenticStep
2057
+ ? 'agentic'
2058
+ : 'migration_exec',
2059
+ migrationPackage: m.package,
2060
+ migrationName: m.name,
2061
+ migrationCount: totalMigrations,
2062
+ error: e,
2063
+ });
2064
+ }
2065
+ if (!(e instanceof execute_migration_1.NpmPeerDepsInstallError)) {
2066
+ // `withGeneratorOutputCapture` attaches the generator's `console.*`
2067
+ // output as `capturedLogs` (best-effort; may be absent). Surface it
2068
+ // so the user sees what the generator printed before it crashed.
2069
+ const capturedLogs = e?.capturedLogs;
2070
+ const bodyLines = typeof capturedLogs === 'string' && capturedLogs.length > 0
2071
+ ? [
2072
+ 'Output from the generator before it failed:',
2073
+ '',
2074
+ ...capturedLogs.split('\n'),
2075
+ ]
2076
+ : undefined;
2077
+ output_1.output.error({
2078
+ title: `Failed to run ${m.name} from ${m.package}. This workspace is NOT up to date!`,
2079
+ bodyLines,
2080
+ });
2081
+ (0, migrate_output_1.logFailureRecap)({
2082
+ migrationIndex,
2083
+ totalMigrations,
2084
+ outcomes,
2085
+ migrationEmittedNextSteps,
2086
+ insideAgent: agentic?.kind === 'inside-agent',
2087
+ });
2088
+ }
2089
+ throw e;
2090
+ }
2091
+ }
2092
+ if (!shouldCreateCommits) {
2093
+ await installDepsIfChanged();
2094
+ }
2095
+ if (changedDepInstaller.skippedInstall) {
2096
+ (0, execute_migration_1.logSkippedPostMigrationInstall)(root);
2097
+ }
2098
+ // Combined-view next-steps array kept for back-compat with repair.ts, which
2099
+ // consumes the single `nextSteps` field.
2100
+ const combinedNextSteps = [...migrationEmittedNextSteps];
2101
+ if (skippedPrompts.length > 0) {
2102
+ combinedNextSteps.push(formatSkippedPromptsNextStep(skippedPrompts));
2103
+ }
2104
+ return {
2105
+ migrationsWithNoChanges,
2106
+ skippedPromptsCount: skippedPrompts.length,
2107
+ notRunMigrationsCount,
2108
+ nextSteps: combinedNextSteps,
2109
+ skippedPrompts,
2110
+ migrationEmittedNextSteps,
2111
+ committedShasCount: (0, migrate_output_1.countLandedCommits)(outcomes),
2112
+ waivedAgenticStepsCount: (0, migrate_output_1.countWaivedAgenticSteps)(outcomes),
2113
+ // Migrations whose commits failed and never got absorbed by a later
2114
+ // commit. The caller surfaces them so a successful run doesn't claim
2115
+ // "up to date" while leaving uncommitted diffs in the working tree.
2116
+ // Formatted as `package: name` for direct display.
2117
+ retainedAtSuccess: (0, migrate_output_1.retainedMigrations)(outcomes).map((p) => `${p.package}: ${p.name}`),
2118
+ };
2119
+ }
2120
+ function orchestratorFlagNeedsOrchestrator(flag) {
2121
+ return `'${flag}' acts on an orchestrated migrate run (NX_MIGRATE_ORCHESTRATOR=true with an enabled agent), and this invocation is not orchestrated.`;
2122
+ }
2123
+ // nx is located at spawn time, after the gated pre-install, so the child runs
2124
+ // the bytes that install put in place.
2125
+ function handOffToLocalNx(args) {
2126
+ const exitCode = runOrReturnExitCode(() => (0, child_process_2.runNxArgvSync)(['migrate', ...args], {
2127
+ stdio: ['inherit', 'inherit', 'inherit'],
2128
+ env: {
2129
+ ...process.env,
2130
+ NX_MIGRATE_SKIP_INSTALL: 'true',
2131
+ NX_MIGRATE_USE_LOCAL: 'true',
2132
+ },
2133
+ }));
2134
+ return exitCode !== 0 ? exitCode : undefined;
2135
+ }
2136
+ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits, commitPrefix, shouldSkipInstall = false) {
2137
+ // Both flags act on an orchestrated run: refuse them where none can run
2138
+ // (an explicit --agentic=false outside an agent cannot reach one either),
2139
+ // before the install and before --if-exists could return silently.
2140
+ const orchestratorFlag = opts.startFresh === true
2141
+ ? '--start-fresh'
2142
+ : opts.runId !== undefined
2143
+ ? '--run-id'
2144
+ : undefined;
2145
+ if (orchestratorFlag !== undefined &&
2146
+ (process.env.NX_MIGRATE_ORCHESTRATOR !== 'true' ||
2147
+ (opts.agentic === false && !(0, inception_1.isInsideAgent)()))) {
2148
+ throw new Error(orchestratorFlagNeedsOrchestrator(orchestratorFlag));
2149
+ }
2150
+ const isContinue = opts.runId !== undefined && opts.startFresh !== true;
2151
+ let continued;
2152
+ if (isContinue) {
2153
+ // Before the install: a concurrent start-fresh must not delete the run
2154
+ // this command is about to continue.
2155
+ const { holdRunToContinue } = require('./run');
2156
+ continued = holdRunToContinue(root, opts.runId);
2157
+ }
2158
+ else if (opts.startFresh === true) {
2159
+ // Before the install too: with no active run there is nothing to replace.
2160
+ const { activeRunToReplace } = require('./run');
2161
+ activeRunToReplace(root, opts.runId);
2162
+ }
2163
+ if (!shouldSkipInstall && !process.env.NX_MIGRATE_SKIP_INSTALL) {
2164
+ await (0, execute_migration_1.runInstall)();
2165
+ }
2166
+ if (!__dirname.startsWith(workspace_root_1.workspaceRoot)) {
2167
+ // we are running from a temp installation with nx latest, switch to running
2168
+ // from local installation
2169
+ if (isContinue) {
2170
+ // The child holds the run itself and refuses while this process does.
2171
+ const { releaseRunToHandOff } = require('./run');
2172
+ releaseRunToHandOff(root, opts.runId);
2173
+ }
2174
+ return handOffToLocalNx(args);
2175
+ }
2176
+ let migrationsJson;
2177
+ if (isContinue) {
2178
+ // A continue runs the plan the run recorded, not whatever the workspace's
2179
+ // migrations file holds now (it may be gone, or belong to another plan).
2180
+ const { latestRound, runDir } = require('./run');
2181
+ const round = latestRound(continued);
2182
+ if (!round) {
2183
+ throw new Error(`Migrate run '${opts.runId}' records no plan.`);
2184
+ }
2185
+ migrationsJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(runDir(root, opts.runId), round.planSnapshot));
2186
+ }
2187
+ else {
2188
+ const migrationsExists = (0, fileutils_1.fileExists)(opts.runMigrations);
2189
+ if (opts.ifExists && !migrationsExists) {
2190
+ output_1.output.log({
2191
+ title: `Migrations file '${opts.runMigrations}' doesn't exist`,
2192
+ });
2193
+ return;
2194
+ }
2195
+ else if (!opts.ifExists && !migrationsExists) {
2196
+ throw new Error(`File '${opts.runMigrations}' doesn't exist, can't run migrations. Use flag --if-exists to run migrations only if the file exists`);
2197
+ }
2198
+ migrationsJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, opts.runMigrations));
2199
+ }
2200
+ const migrations = migrationsJson.migrations;
2201
+ // Defer the nx package lookup until an orchestrated branch needs this payload.
2202
+ const orchestratorInitInput = (createCommits) => ({
2203
+ root,
2204
+ migrationsJson,
2205
+ migrationsPath: opts.runMigrations,
2206
+ createCommits,
2207
+ commitPrefix,
2208
+ // The flag only, never NX_MIGRATE_SKIP_INSTALL: the wrapper's local
2209
+ // re-exec sets that env var for its own hop, and it says nothing about
2210
+ // what the user asked for.
2211
+ skipInstall: shouldSkipInstall,
2212
+ installedNxVersion: (0, package_json_1.readModulePackageJson)('nx', (0, installation_directory_1.getNxRequirePaths)(root))
2213
+ .packageJson.version,
2214
+ validate: opts.validate,
2215
+ finalValidation: opts.finalValidation,
2216
+ });
2217
+ // An outer agent drives the loop, so hand off to the orchestrator instead of
2218
+ // the classic loop: init starts a fresh run or reports an already-active
2219
+ // one; `--run-id` continues that run. Bare `--run-id` reconciles are
2220
+ // dispatched separately and never reach here.
2221
+ if (process.env.NX_MIGRATE_ORCHESTRATOR === 'true' && (0, inception_1.isInsideAgent)()) {
2222
+ const { runOrchestratorInit, runOrchestratorResume } = require('./run');
2223
+ // Orchestrated runs are agent-driven, so commits default on exactly as they
2224
+ // do under `--agentic=enabled`; the orchestrator replaces `resolveAgentic`.
2225
+ const { effective: effectiveCreateCommits, warning: createCommitsWarning, error: createCommitsError, } = (0, migrate_commits_1.resolveCreateCommits)({
2226
+ createCommits: shouldCreateCommits,
2227
+ mode: 'orchestrated',
2228
+ isGitRepo: (0, git_utils_1.isGitRepository)(root),
2229
+ commitPrefixIsCustom: commitPrefix !== command_object_1.DEFAULT_MIGRATION_COMMIT_PREFIX,
2230
+ });
2231
+ if (createCommitsError) {
2232
+ throw new Error(createCommitsError);
2233
+ }
2234
+ if (createCommitsWarning) {
2235
+ output_1.output.warn({ title: createCommitsWarning });
2236
+ }
2237
+ if (isContinue) {
2238
+ runOrchestratorResume({
2239
+ root,
2240
+ runId: opts.runId,
2241
+ policy: {
2242
+ createCommits: effectiveCreateCommits,
2243
+ skipInstall: shouldSkipInstall,
2244
+ },
2245
+ });
2246
+ return;
2247
+ }
2248
+ // The run commits on the user's behalf across many invocations and the
2249
+ // agent driving it cannot answer a terminal prompt, so a commit policy the
2250
+ // user never asked for stops the run on the default branch before any of
2251
+ // them. `--create-commits` or nx.json `migrate.createCommits` is that ask.
2252
+ // Asked by init only once it is about to start a run: an active run is
2253
+ // reported instead, and keeps its own policy.
2254
+ const refuseCommitsOnDefaultBranch = async () => {
2255
+ if (!effectiveCreateCommits || shouldCreateCommits !== undefined) {
2256
+ return true;
2257
+ }
2258
+ const defaultBranch = (0, migrate_commits_1.currentBranchIfDefault)(root);
2259
+ if (!defaultBranch) {
2260
+ return true;
2261
+ }
2262
+ output_1.output.log({
2263
+ title: `Not starting the run: you are on the default branch '${defaultBranch}' and nx migrate would create a commit for each migration on it.`,
2264
+ bodyLines: [
2265
+ 'Ask the user how to proceed, then either:',
2266
+ '- re-run with --create-commits to commit on this branch for this run,',
2267
+ '- set "migrate": { "createCommits": true } in nx.json to always allow it, then re-run,',
2268
+ '- or switch to another branch and re-run.',
2269
+ ],
2270
+ });
2271
+ return false;
2272
+ };
2273
+ const init = orchestratorInitInput(effectiveCreateCommits);
2274
+ await runOrchestratorInit({
2275
+ ...init,
2276
+ onExistingRun: opts.startFresh === true ? 'start-fresh' : 'report',
2277
+ ...(opts.startFresh === true ? { replaceRunId: opts.runId } : {}),
2278
+ confirmStart: refuseCommitsOnDefaultBranch,
2279
+ });
2280
+ return;
2281
+ }
2282
+ (0, migrate_analytics_1.reportMigrateRunStart)({
2283
+ createCommits: shouldCreateCommits ?? false,
2284
+ migrationCount: migrations.length,
2285
+ });
2286
+ const { resolveAgentic, resolveShouldRunValidation } = require('./agentic/select');
2287
+ let agentic;
2288
+ try {
2289
+ agentic = await resolveAgentic({
2290
+ agentic: opts.agentic,
2291
+ migrations,
2292
+ interactive: opts.interactive,
2293
+ });
2294
+ }
2295
+ catch (e) {
2296
+ (0, migrate_analytics_1.reportMigrateRunError)({ code: 'agentic', error: e });
2297
+ throw e;
2298
+ }
2299
+ const { effective: effectiveCreateCommits, agenticHasDiffContext, warning: createCommitsWarning, error: createCommitsError, } = (0, migrate_commits_1.resolveCreateCommits)({
2300
+ createCommits: shouldCreateCommits,
2301
+ mode: agentic.kind,
2302
+ isGitRepo: (0, git_utils_1.isGitRepository)(root),
2303
+ commitPrefixIsCustom: commitPrefix !== command_object_1.DEFAULT_MIGRATION_COMMIT_PREFIX,
2304
+ });
2305
+ if (createCommitsError) {
2306
+ throw new Error(createCommitsError);
2307
+ }
2308
+ if (createCommitsWarning) {
2309
+ output_1.output.warn({ title: createCommitsWarning });
2310
+ }
2311
+ // Asked only for a run this invocation starts: the master session hands it
2312
+ // to init, which asks once it is about to start one; a continued run keeps
2313
+ // the policy it was started with.
2314
+ const confirmNewRunCommits = async () => !effectiveCreateCommits ||
2315
+ !(0, safe_prompt_1.canPrompt)(opts.interactive) ||
2316
+ (0, migrate_commits_1.confirmMigrationCommitsOnDefaultBranch)(root, 'running migrations');
2317
+ // Dark: with the env var set, the agent drives the whole run through the
2318
+ // orchestrator from one session instead of being spawned per step. Not
2319
+ // under WASM, where the broker has no native lock to detect a dead parent.
2320
+ if (agentic.kind === 'enabled' &&
2321
+ process.env.NX_MIGRATE_ORCHESTRATOR === 'true' &&
2322
+ !native_1.IS_WASM) {
2323
+ const init = orchestratorInitInput(effectiveCreateCommits);
2324
+ const { runMasterSession } = require('./agentic/master/run-master-session');
2325
+ return await runMasterSession({
2326
+ ...init,
2327
+ agent: agentic.selectedAgent,
2328
+ interactive: opts.interactive,
2329
+ runId: opts.runId,
2330
+ startFresh: opts.startFresh,
2331
+ confirmStart: confirmNewRunCommits,
2332
+ });
2333
+ }
2334
+ if (orchestratorFlag !== undefined) {
2335
+ throw new Error(orchestratorFlagNeedsOrchestrator(orchestratorFlag));
2336
+ }
2337
+ if (!(await confirmNewRunCommits())) {
2338
+ return;
2339
+ }
2340
+ const shouldRunValidation = resolveShouldRunValidation({
2341
+ validate: opts.validate,
2342
+ agenticKind: agentic.kind,
2343
+ });
2344
+ output_1.output.log({
2345
+ title: `Running migrations from '${opts.runMigrations}'` +
2346
+ (effectiveCreateCommits
2347
+ ? ', with each applied in a dedicated commit'
2348
+ : ''),
2349
+ });
2350
+ if (effectiveCreateCommits) {
2351
+ (0, migrate_commits_1.commitCheckpointBeforeMigrations)(root, commitPrefix);
2352
+ }
2353
+ if (agentic.kind === 'enabled') {
2354
+ const { applyAgenticHandoffGitignoreFallback } = require('./agentic/handoff-gitignore');
2355
+ const { packageJson: nxPackageJson } = (0, package_json_1.readModulePackageJson)('nx', (0, installation_directory_1.getNxRequirePaths)(root));
2356
+ await applyAgenticHandoffGitignoreFallback({
2357
+ migrations,
2358
+ installedNxVersion: nxPackageJson.version,
2359
+ effectiveCreateCommits,
2360
+ commitPrefix,
2361
+ root,
2362
+ });
2363
+ }
2364
+ const { migrationsWithNoChanges, skippedPromptsCount, notRunMigrationsCount, skippedPrompts, migrationEmittedNextSteps, committedShasCount, waivedAgenticStepsCount, retainedAtSuccess, } = await executeMigrations(root, migrations, isVerbose, effectiveCreateCommits, commitPrefix, shouldSkipInstall, agentic, agenticHasDiffContext, shouldRunValidation);
2365
+ const ranWithChangesCount = migrations.length - notRunMigrationsCount - migrationsWithNoChanges.length;
2366
+ // The "applied" tally counts fully-completed migrations — those that
2367
+ // left no deferred work behind. Hybrid migrations whose prompt half was
2368
+ // deferred count as "deferred", not "applied".
2369
+ const appliedCount = migrations.length - skippedPrompts.length;
2370
+ const insideAgent = agentic.kind === 'inside-agent';
2371
+ const tallyLine = (0, migrate_output_1.buildTallyBodyLine)({
2372
+ appliedCount,
2373
+ committedShasCount,
2374
+ skippedPromptsCount,
2375
+ waivedAgenticStepsCount,
2376
+ insideAgent,
2377
+ });
2378
+ const tallyBody = tallyLine ? [tallyLine] : undefined;
2379
+ // Only claim "up to date" when there's nothing pending: no deferred
2380
+ // prompts AND no migrations whose commits failed without being absorbed.
2381
+ const upToDateSuffix = skippedPromptsCount > 0 || retainedAtSuccess.length > 0
2382
+ ? ''
2383
+ : ' This workspace is up to date!';
2384
+ // Demote `output.success` to `output.warn` when there's uncommitted state
2385
+ // retained from failed commits — the run did its work, but it would be
2386
+ // misleading to lead with a green "Successfully finished" before the
2387
+ // retained-state block. `.bind(output)` is required: assigning the method
2388
+ // reference to a local would otherwise call it with `this === undefined`.
2389
+ const completionLog = (retainedAtSuccess.length > 0 ? output_1.output.warn : output_1.output.success).bind(output_1.output);
2390
+ const completionTitlePrefix = retainedAtSuccess.length > 0
2391
+ ? 'Finished running migrations with uncommitted state retained'
2392
+ : 'Successfully finished running migrations';
2393
+ if (notRunMigrationsCount === migrations.length && migrations.length > 0) {
2394
+ const remediation = insideAgent
2395
+ ? 'The AI agent driving this run should apply each prompt — see next steps below.'
2396
+ : 'Re-run with --agentic to apply them. See next steps below.';
2397
+ output_1.output.warn({
2398
+ title: `No migrations from '${opts.runMigrations}' were applied — every entry is a prompt-only migration. ${remediation}`,
2399
+ bodyLines: tallyBody,
2400
+ });
2401
+ }
2402
+ else if (ranWithChangesCount > 0) {
2403
+ completionLog({
2404
+ title: `${completionTitlePrefix} from '${opts.runMigrations}'.${upToDateSuffix}`,
2405
+ bodyLines: tallyBody,
2406
+ });
2407
+ }
2408
+ else {
2409
+ // Pathological-but-possible: a no-op run that still has retained state
2410
+ // (e.g. pre-existing pending diffs that no commit absorbed). Demote
2411
+ // explicitly rather than rely on the implicit invariant.
2412
+ completionLog({
2413
+ title: `No changes were made from running '${opts.runMigrations}'.${upToDateSuffix}`,
2414
+ bodyLines: tallyBody,
2415
+ });
2416
+ }
2417
+ if (retainedAtSuccess.length > 0) {
2418
+ output_1.output.warn({
2419
+ title: `Working-tree state retained from ${retainedAtSuccess.length} migration${retainedAtSuccess.length === 1 ? '' : 's'} whose commits could not be created`,
2420
+ bodyLines: (0, migrate_output_1.buildRetainedAtSuccessBody)(retainedAtSuccess),
2421
+ });
2422
+ }
2423
+ if (insideAgent) {
2424
+ // Under inside-agent, emit a directive block so the outer agent has
2425
+ // explicit instructions to act on, not just relay.
2426
+ const directiveLines = (0, migrate_output_1.buildDirectiveBlockBodyLines)({
2427
+ skippedPrompts,
2428
+ migrationEmittedNextSteps,
2429
+ });
2430
+ if (directiveLines.length > 0) {
2431
+ output_1.output.log({
2432
+ title: 'Next steps for the AI agent driving this run',
2433
+ bodyLines: directiveLines,
2434
+ });
2435
+ }
2436
+ }
2437
+ else if (skippedPromptsCount > 0 || migrationEmittedNextSteps.length > 0) {
2438
+ // Non-inside-agent path keeps the legacy "additional information" shape —
2439
+ // the consumer is the human user.
2440
+ const bodyLines = [];
2441
+ if (skippedPromptsCount > 0) {
2442
+ bodyLines.push(formatSkippedPromptsNextStep(skippedPrompts));
2443
+ }
2444
+ bodyLines.push(...migrationEmittedNextSteps);
2445
+ output_1.output.log({
2446
+ title: `Some migrations have additional information, see below.`,
2447
+ bodyLines: bodyLines.map((line) => `- ${line}`),
2448
+ });
2449
+ }
2450
+ (0, migrate_analytics_1.reportMigrateRunComplete)({
2451
+ agenticOutcome: agentic.kind,
2452
+ agentUsed: agentic.kind === 'enabled' ? agentic.selectedAgent.id : undefined,
2453
+ migrationCount: migrations.length,
2454
+ appliedCount,
2455
+ });
2456
+ }
2457
+ function isRunPhaseInvocation(args) {
2458
+ return (args.runMigration !== undefined ||
2459
+ args.runId !== undefined ||
2460
+ args.stepAction !== undefined);
2461
+ }
2462
+ async function migrate(root, args, rawArgs) {
2463
+ await client_1.daemonClient.stop();
2464
+ return (0, handle_errors_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
2465
+ const mergedArgs = (0, migrate_config_1.applyNxJsonMigrateDefaults)(args, (0, configuration_1.readNxJson)().migrate);
2466
+ // Run-phase invocations resolve their commit config downstream (run.json
2467
+ // for recorded runs, resolveCreateCommits for standalone), so this assert
2468
+ // must not fire for them; otherwise an nx.json prefix the whole-file run
2469
+ // legitimately uses would wedge every dispensed command.
2470
+ const runPhase = isRunPhaseInvocation(mergedArgs);
2471
+ if (!runPhase) {
2472
+ (0, migrate_config_1.assertCommitPrefixHasCommits)(mergedArgs);
2473
+ }
2474
+ // One fetcher (registry-first, install fallback) shared by the `--include`
2475
+ // eligibility gate and the migration cascade so package metadata is fetched
2476
+ // at most once per package/version.
2477
+ const fetch = createFetcher((0, package_manager_1.getPackageManagerCommand)());
2478
+ // `--run-migrations` without a value parses as '', so only undefined (and
2479
+ // no run-phase flag) means the generate phase.
2480
+ const isGenerateInvocation = mergedArgs['runMigrations'] === undefined && !runPhase;
2481
+ let opts;
2482
+ try {
2483
+ opts = await parseMigrationsOptions(mergedArgs, fetch);
2484
+ }
2485
+ catch (e) {
2486
+ if (isGenerateInvocation) {
2487
+ (0, migrate_analytics_1.reportMigrateGenerateError)('resolve_version', e);
2488
+ }
2489
+ else if (runPhase) {
2490
+ (0, migrate_analytics_1.reportMigrateRunError)({ code: 'other', error: e });
2491
+ }
2492
+ throw e;
2493
+ }
2494
+ switch (opts.type) {
2495
+ case 'generateMigrations':
2496
+ await generateMigrationsJsonAndUpdatePackageJson(root, opts, fetch);
2497
+ return;
2498
+ case 'runSingleMigration':
2499
+ try {
2500
+ return await runSingleMigrationFromCli(root, opts, rawArgs, mergedArgs);
2501
+ }
2502
+ catch (e) {
2503
+ // `runInstall` already logged the remediation; returning instead of
2504
+ // rethrowing keeps `handleErrors` from printing a stack over it.
2505
+ if (e instanceof execute_migration_1.NpmPeerDepsInstallError) {
2506
+ (0, migrate_analytics_1.reportMigrateRunError)({ code: 'npm_install', error: e });
2507
+ return 1;
2508
+ }
2509
+ (0, migrate_analytics_1.reportMigrateRunError)({ code: 'other', error: e });
2510
+ throw e;
2511
+ }
2512
+ case 'orchestratorReconcile':
2513
+ return await runOrchestratorReconcileFromCli(root, opts, rawArgs);
2514
+ case 'runMigrations':
2515
+ try {
2516
+ return await runMigrations(root, opts, rawArgs, mergedArgs['verbose'], mergedArgs['createCommits'], mergedArgs['commitPrefix'] ?? command_object_1.DEFAULT_MIGRATION_COMMIT_PREFIX, mergedArgs['skipInstall']);
2517
+ }
2518
+ catch (e) {
2519
+ if (e instanceof execute_migration_1.NpmPeerDepsInstallError) {
2520
+ (0, migrate_analytics_1.reportMigrateRunError)({ code: 'npm_install', error: e });
2521
+ return 1;
2522
+ }
2523
+ (0, migrate_analytics_1.reportMigrateRunError)({ code: 'other', error: e });
2524
+ throw e;
2525
+ }
2526
+ default: {
2527
+ // `unhandled: never` makes a new invocation type a compile error here
2528
+ // rather than a silent fall-through.
2529
+ const unhandled = opts;
2530
+ throw new Error(`Unhandled migrate invocation type: ${JSON.stringify(unhandled)}`);
2531
+ }
2532
+ }
2533
+ });
2534
+ }
2535
+ // Evaluated manifest code can throw any value: a null-prototype object defeats
2536
+ // String() (the Object.prototype.toString rung catches it), and a revoked
2537
+ // proxy defeats that too. Interpolating either in a catch would throw again
2538
+ // and escape the catch.
2539
+ function stringifyCaught(e) {
2540
+ try {
2541
+ return String(e);
2542
+ }
2543
+ catch {
2544
+ try {
2545
+ return Object.prototype.toString.call(e);
2546
+ }
2547
+ catch {
2548
+ return '<unprintable value>';
2549
+ }
2550
+ }
2551
+ }
2552
+ // A resolver-based lookup (including `resolveWithoutCachePollution`,
2553
+ // which does defeat Node's package self-reference) is the wrong tool here:
2554
+ // resolvers fall back to NODE_PATH after the explicit paths, and NODE_PATH
2555
+ // names the temp installation when this runs there. The scan below reads its
2556
+ // candidate directories itself, so neither NODE_PATH nor self-reference can
2557
+ // reach it; `getNxBin` (utils/child-process.ts), which locates the nx the
2558
+ // hand-off spawns, avoids resolvers for the same reason, over a narrower set
2559
+ // of directories: it skips `.nx/installation`, declines a root without a
2560
+ // package.json, and stops at the nearest install rather than reading past an
2561
+ // unusable one. The PnP branch below stays bespoke either way: a resolver
2562
+ // cannot see into the zip cache without the PnP runtime.
2563
+ function readLocalNxVersion(root) {
2564
+ // A PnP manifest is consulted only when yarn drives the hand-off:
2565
+ // `getRunNxBaseCommand` builds the hand-off command through this same
2566
+ // detectPackageManager call (which answers from nx.json's
2567
+ // cli.packageManager first, before any lockfile), and yarn is the one
2568
+ // package manager that executes the manifest's nx. That mirror alone
2569
+ // cannot see a switch off yarn, because yarn.lock survives one and
2570
+ // outranks all but bun's lockfiles in the detection order, while .pnp.cjs
2571
+ // lingers only on a switch to another package manager (yarn removes it
2572
+ // when moving to node_modules linking). A rival lockfile beside the
2573
+ // manifest is therefore read as evidence of such a switch, though not
2574
+ // proof, since `pnpm install --lockfile-only` writes one without
2575
+ // installing: on a scan miss the manifest still answers rather than
2576
+ // failing the guards, and a rival install over a still-live PnP
2577
+ // workspace is read over the PnP nx the yarn spawn executes, because
2578
+ // preferring the manifest would judge the dead install that a completed
2579
+ // switch leaves behind and refuse persistently. The known misread left
2580
+ // is yarn classic driving a workspace with a leftover Berry manifest
2581
+ // and no other lockfile; telling the two yarns apart from disk is not
2582
+ // worth the fragility, and a `yarn node` runtime probe was rejected
2583
+ // because its stdout is forgeable through an inherited NODE_OPTIONS
2584
+ // preload and a hung descendant holding the output pipe outlives a
2585
+ // subprocess timeout on this synchronous path.
2586
+ const pnpManifest = ['.pnp.cjs', '.pnp.js']
2587
+ .map((f) => (0, path_1.join)(root, f))
2588
+ .find((f) => (0, fs_1.existsSync)(f));
2589
+ if (pnpManifest) {
2590
+ const competingLockfile = [
2591
+ 'package-lock.json',
2592
+ 'npm-shrinkwrap.json',
2593
+ 'pnpm-lock.yaml',
2594
+ 'bun.lockb',
2595
+ 'bun.lock',
2596
+ ].some((f) => (0, fs_1.existsSync)((0, path_1.join)(root, f)));
2597
+ if (competingLockfile) {
2598
+ const version = scanNodeModulesForNxVersion(root);
2599
+ if (version) {
2600
+ return version;
2601
+ }
2602
+ }
2603
+ try {
2604
+ if ((0, package_manager_1.detectPackageManager)(root) === 'yarn') {
2605
+ // Compiled manually rather than required: a require would serve the
2606
+ // stale cached copy the runtime loaded at startup. new Function does
2607
+ // not strip a leading shebang like the CJS loader, so drop it here.
2608
+ const manifestModule = {
2609
+ exports: {},
2610
+ };
2611
+ new Function('module', 'exports', 'require', '__dirname', '__filename', (0, fs_1.readFileSync)(pnpManifest, 'utf-8').replace(/^#!.*/, ''))(manifestModule, manifestModule.exports, require, root, pnpManifest);
2612
+ const packageJsonPath = manifestModule.exports.resolveRequest('nx/package.json', (0, path_1.join)(root, 'package.json'));
2613
+ if (packageJsonPath) {
2614
+ // A resolving manifest names the install the yarn spawn runs, so
2615
+ // every branch below returns rather than falling through to the
2616
+ // ancestor scan.
2617
+ try {
2618
+ const { version } = (0, fileutils_1.readJsonFile)(packageJsonPath);
2619
+ if (typeof version === 'string') {
2620
+ logger_1.logger.verbose(`Read the workspace's nx version ${version} from '${packageJsonPath}'.`);
2621
+ return version;
2622
+ }
2623
+ logger_1.logger.verbose(`'${packageJsonPath}' does not declare a usable version.`);
2624
+ return undefined;
2625
+ }
2626
+ catch (readError) {
2627
+ // A zip-served path (installs with scripts disabled keep nx
2628
+ // zipped) cannot be read without the PnP runtime's zip fs, but
2629
+ // the manifest's own locator still names the version (e.g.
2630
+ // 'virtual:<hash>#npm:23.1.0').
2631
+ let version;
2632
+ try {
2633
+ const reference = manifestModule.exports.findPackageLocator?.(packageJsonPath)?.reference;
2634
+ version =
2635
+ typeof reference === 'string'
2636
+ ? reference.match(/npm:([^#:]+)/)?.[1]
2637
+ : undefined;
2638
+ }
2639
+ catch (locatorError) {
2640
+ logger_1.logger.verbose(`Could not read the nx locator from the PnP manifest '${pnpManifest}': ${stringifyCaught(locatorError)}`);
2641
+ }
2642
+ if (version && (0, semver_1.valid)(version)) {
2643
+ logger_1.logger.verbose(`Read the workspace's nx version ${version} from the locator in the PnP manifest '${pnpManifest}'.`);
2644
+ return version;
2645
+ }
2646
+ logger_1.logger.verbose(`Could not read the workspace's nx version through the PnP manifest '${pnpManifest}': ${stringifyCaught(readError)}`);
2647
+ return undefined;
2648
+ }
2649
+ }
2650
+ }
2651
+ }
2652
+ catch (e) {
2653
+ // Degrade to the full scan: neither a failed detection nor an
2654
+ // unevaluable manifest can name the spawn's nx.
2655
+ logger_1.logger.verbose(`Could not read the workspace's nx version through the PnP manifest '${pnpManifest}': ${stringifyCaught(e)}`);
2656
+ }
2657
+ }
2658
+ return scanNodeModulesForNxVersion(root);
2659
+ }
2660
+ // The workspace's own install locations first (.nx/installation, root), then
2661
+ // ancestor directories: package-manager executable lookup ascends (npx and
2662
+ // bun always, pnpm and yarn inside an outer workspace) and hoisted layouts
2663
+ // install nx above the workspace root. `getNxBin` ascends too, so an ancestor
2664
+ // read here is usually the one the hand-off spawns. They diverge for a
2665
+ // `.nx/installation` workspace, which `getNxBin` declines, and where the only
2666
+ // nx found sits past the package manager's own lookup boundary and the spawn
2667
+ // has fallen back to that manager: yarn then reports "command not found"
2668
+ // while pnpm exec lands on an nx on PATH. The version read here is therefore
2669
+ // the readable answer, not necessarily the executed one.
2670
+ function scanNodeModulesForNxVersion(root) {
2671
+ const searchPaths = [...(0, installation_directory_1.getNxRequirePaths)(root)];
2672
+ for (let dir = (0, path_1.dirname)(root);; dir = (0, path_1.dirname)(dir)) {
2673
+ searchPaths.push(dir);
2674
+ if (dir === (0, path_1.dirname)(dir)) {
2675
+ break;
2676
+ }
2677
+ }
2678
+ return readNxVersionFromNodeModules(searchPaths);
2679
+ }
2680
+ function readNxVersionFromNodeModules(searchPaths) {
2681
+ for (const searchPath of searchPaths) {
2682
+ const packageJsonPath = (0, path_1.join)(searchPath, 'node_modules', 'nx', 'package.json');
2683
+ try {
2684
+ if ((0, fs_1.existsSync)(packageJsonPath)) {
2685
+ const { version } = (0, fileutils_1.readJsonFile)(packageJsonPath);
2686
+ if (typeof version === 'string') {
2687
+ logger_1.logger.verbose(`Resolved nx version ${version} from '${packageJsonPath}'.`);
2688
+ return version;
2689
+ }
2690
+ logger_1.logger.verbose(`'${packageJsonPath}' does not declare a usable version; continuing the search.`);
2691
+ }
2692
+ }
2693
+ catch (e) {
2694
+ logger_1.logger.verbose(`Could not read the workspace's installed nx version from '${packageJsonPath}': ${e}`);
2695
+ }
2696
+ }
2697
+ return undefined;
2698
+ }
2699
+ // Mirrors the local-nx hand-off of the other run paths so a reconcile always
2700
+ // executes against the workspace-local nx that owns the run state, never the
2701
+ // temp installation. Reconciles only read state and commit, so no install.
2702
+ async function runOrchestratorReconcileFromCli(root, opts, args) {
2703
+ if (!__dirname.startsWith(workspace_root_1.workspaceRoot)) {
2704
+ // The workspace-local nx we are about to hand off to must be new enough to
2705
+ // understand the new flags we forward to it.
2706
+ (0, version_skew_guard_1.assertWorkspaceNxSupportsNewMigrateFlags)({
2707
+ argv: args,
2708
+ readLocalNxVersion: () => readLocalNxVersion(root),
2709
+ });
2710
+ return handOffToLocalNx(args);
2711
+ }
2712
+ const { runOrchestratorReconcile } = require('./run');
2713
+ return runOrchestratorReconcile({
2714
+ root,
2715
+ runId: opts.runId,
2716
+ stepAction: opts.stepAction,
2717
+ });
2718
+ }
2719
+ // Keeps `--run-migration` behaving like `--run-migrations` when invoked from
2720
+ // a temp `nx@latest` install: same pre-install, same local-nx hand-off.
2721
+ async function runSingleMigrationFromCli(root, opts, args, mergedArgs) {
2722
+ const shouldSkipInstall = mergedArgs['skipInstall'] ?? false;
2723
+ // A recorded execution skips the pre-install: the run carries its own
2724
+ // install policy and its worker installs what the migration changed, so
2725
+ // paying for a full install ahead of every dispensed command would be
2726
+ // redundant.
2727
+ if (opts.runId === undefined &&
2728
+ !shouldSkipInstall &&
2729
+ !process.env.NX_MIGRATE_SKIP_INSTALL) {
2730
+ await (0, execute_migration_1.runInstall)(undefined, 'pre-migration', (0, execute_migration_1.formatSingleMigrationRerunCommand)(opts.runMigration));
2731
+ }
2732
+ if (!__dirname.startsWith(workspace_root_1.workspaceRoot)) {
2733
+ // Must stay after the pre-install: it reads the version that install may
2734
+ // have just updated, so checking earlier would falsely refuse a workspace
2735
+ // whose package.json bump was not installed yet.
2736
+ (0, version_skew_guard_1.assertWorkspaceNxSupportsNewMigrateFlags)({
2737
+ argv: args,
2738
+ // `workspaceRoot`, not `root`: the migrate flow's `root` is the
2739
+ // invocation directory, which may sit below the workspace the hand-off
2740
+ // resolves nx in.
2741
+ readLocalNxVersion: () => readLocalNxVersion(workspace_root_1.workspaceRoot),
2742
+ });
2743
+ return handOffToLocalNx(args);
2744
+ }
2745
+ // The worker resolves the agentic flow, the effective commit config, and
2746
+ // the default-branch confirmation itself; hand it the raw flags. Recorded
2747
+ // runs (--run-id) take their commit config from run.json instead.
2748
+ // Lazy-load run/ so plain migrate and repair runs don't pay for the agentic
2749
+ // selection chain its barrel pulls in eagerly.
2750
+ const { runSingleMigrationWorker } = require('./run');
2751
+ await runSingleMigrationWorker({
2752
+ root,
2753
+ runMigration: opts.runMigration,
2754
+ runId: opts.runId,
2755
+ agentic: opts.agentic,
2756
+ validate: opts.validate,
2757
+ createCommits: mergedArgs['createCommits'],
2758
+ commitPrefix: mergedArgs['commitPrefix'] ??
2759
+ command_object_1.DEFAULT_MIGRATION_COMMIT_PREFIX,
2760
+ interactive: opts.interactive,
2761
+ skipInstall: shouldSkipInstall,
2762
+ isVerbose: mergedArgs['verbose'] ?? false,
2763
+ });
2764
+ }
2765
+ async function runMigration() {
2766
+ return (0, handle_errors_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
2767
+ // Spawning `nx _migrate` re-resolves the workspace's nx, normally the
2768
+ // very installation running this code: bin/nx.ts delegated the outer
2769
+ // `migrate` command to it, while `_migrate` skips that delegation. A
2770
+ // new-flag invocation reaching this fallback therefore lands on an nx
2771
+ // that parsed the flags, so it needs no capability check. Two lookups
2772
+ // can still diverge from the running install, both properties of the
2773
+ // spawn machinery rather than of this fallback: a `.nx/installation`
2774
+ // beside a root package.json, and, once the spawn falls back to the
2775
+ // package manager, a lookup that misses the workspace install and lands
2776
+ // on an nx on PATH (pnpm exec).
2777
+ const forwardedArgv = process.argv.slice(3);
2778
+ const runLocalMigrate = () => runOrReturnExitCode(() => (0, child_process_2.runNxArgvSync)(['_migrate', ...forwardedArgv], {
2779
+ stdio: ['inherit', 'inherit', 'inherit'],
2780
+ }));
2781
+ if (!(0, version_skew_guard_1.targetsExistingRun)(process.argv.slice(3)) &&
2782
+ process.env.NX_USE_LOCAL !== 'true' &&
2783
+ process.env.NX_MIGRATE_USE_LOCAL === undefined) {
2784
+ // The version spec mirrors nxCliPath's; keep the two in sync.
2785
+ const cliVersionSpec = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
2786
+ const target = await (0, version_skew_guard_1.resolveNewMigrateFlagsRunTarget)({
2787
+ argv: process.argv.slice(3),
2788
+ cliVersionSpec,
2789
+ fromEnvOverride: !!process.env.NX_MIGRATE_CLI_VERSION,
2790
+ ownNxVersion: versions_1.nxVersion,
2791
+ resolveVersion: (spec) =>
2792
+ // A probe must not prompt, write pnpm excludes, or install; a
2793
+ // minimum-release-age violation surfaces as a rejection and
2794
+ // routes local.
2795
+ (0, resolve_package_version_1.resolvePackageVersionRespectingMinReleaseAge)('nx', spec, {
2796
+ applySideEffects: false,
2797
+ }),
2798
+ readLocalNxVersion: () => readLocalNxVersion(workspace_root_1.workspaceRoot),
2799
+ });
2800
+ if (target === 'local-nx') {
2801
+ return runLocalMigrate();
2802
+ }
2803
+ const p = await nxCliPath();
2804
+ if (p === null) {
2805
+ return runLocalMigrate();
2806
+ }
2807
+ // ensure local registry from process is not interfering with the install
2808
+ // when we start the process from temp folder the local registry would override the custom registry
2809
+ if (process.env.npm_config_registry &&
2810
+ process.env.npm_config_registry.match(/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/)) {
2811
+ delete process.env.npm_config_registry;
2812
+ }
2813
+ // Intentionally not the workspace's nx: `p` is an nx CLI freshly
2814
+ // installed into a temp dir by nxCliPath() (latest, or
2815
+ // NX_MIGRATE_CLI_VERSION), so migrations run with an up-to-date migrate
2816
+ // implementation. `p` is <tmpDir>/node_modules/.bin/nx, a shell shim;
2817
+ // spawning the entry point that install's own manifest names instead
2818
+ // keeps the forwarded argv out of a shell. That install declares nx
2819
+ // itself, so it is read without ascending: an nx above the temp dir is
2820
+ // one nothing asked for, and the shim below is the answer instead.
2821
+ const tempNxEntry = (0, child_process_2.readInstalledNxBin)((0, path_1.dirname)((0, path_1.dirname)((0, path_1.dirname)(p))));
2822
+ return runOrReturnExitCode(() => tempNxEntry
2823
+ ? (0, child_process_2.runNxArgvSync)(['_migrate', ...forwardedArgv], {
2824
+ stdio: ['inherit', 'inherit', 'inherit'],
2825
+ nxBin: tempNxEntry,
2826
+ })
2827
+ : (0, child_process_1.execSync)(`${(0, shell_quoting_1.quoteShellArg)(p)} _migrate ${forwardedArgv
2828
+ .map(shell_quoting_1.quoteShellArg)
2829
+ .join(' ')}`, {
2830
+ stdio: ['inherit', 'inherit', 'inherit'],
2831
+ windowsHide: true,
2832
+ }));
2833
+ }
2834
+ return runLocalMigrate();
2835
+ });
2836
+ }
2837
+ /**
2838
+ * Resolves a migration's collection once and derives everything the run loop
2839
+ * needs from that single read: the implementation context (`collection` +
2840
+ * `collectionPath`, handed to `runNxOrAngularMigration`) and, for agentic runs,
2841
+ * the workspace-relative documentation path handed to the agent.
2842
+ *
2843
+ * Read fresh per migration (not cached across the loop) so a prior migration's
2844
+ * reinstall is reflected, exactly as before. Error handling matches each field's
2845
+ * role:
2846
+ * - Migrations that run an implementation REQUIRE the collection; an unreadable
2847
+ * collection throws and aborts that migration (caught by the run loop).
2848
+ * - Prompt-only migrations don't run an implementation, so the collection is
2849
+ * read only to resolve documentation - a failure there is non-fatal: the
2850
+ * prompt still runs and the supplementary doc is skipped with a warning.
2851
+ */
2852
+ function resolveMigrationForRun(root, migration, resolveDocumentation) {
2853
+ let resolvedCollection;
2854
+ if (!(0, migration_shape_1.isPromptOnlyMigration)(migration)) {
2855
+ resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
2856
+ }
2857
+ else if (resolveDocumentation && migration.documentation) {
2858
+ try {
2859
+ resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
2860
+ }
2861
+ catch {
2862
+ // Non-fatal: documentation is supplementary; the warning below fires.
2863
+ }
2864
+ }
2865
+ let documentationPath;
2866
+ if (resolveDocumentation && migration.documentation) {
2867
+ documentationPath = resolvedCollection
2868
+ ? (0, execute_migration_1.resolveDocumentationFileToWorkspacePath)(root, (0, path_1.dirname)(resolvedCollection.collectionPath), migration.documentation)
2869
+ : undefined;
2870
+ if (!documentationPath) {
2871
+ logger_1.logger.warn(`Could not resolve the "documentation" file "${migration.documentation}" declared for migration "${migration.package}: ${migration.name}". It will be skipped as additional context for the AI agent.`);
2872
+ }
2873
+ }
2874
+ return { resolvedCollection, documentationPath };
2875
+ }
2876
+ async function nxCliPath(nxWorkspaceRoot) {
2877
+ const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
2878
+ const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
2879
+ await (0, provenance_1.ensurePackageHasProvenance)('nx', version);
2880
+ try {
2881
+ const packageManager = (0, package_manager_1.detectPackageManager)();
2882
+ const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
2883
+ const { dirSync } = require('tmp');
2884
+ const tmpDir = dirSync().name;
2885
+ (0, fileutils_1.writeJsonFile)((0, path_1.join)(tmpDir, 'package.json'), {
2886
+ dependencies: {
2887
+ nx: version,
2888
+ },
2889
+ license: 'MIT',
2890
+ });
2891
+ const root = nxWorkspaceRoot ?? workspace_root_1.workspaceRoot;
2892
+ const isNonJs = !(0, fs_1.existsSync)((0, path_1.join)(root, 'package.json'));
2893
+ (0, package_manager_1.copyPackageManagerConfigurationFiles)(isNonJs ? (0, installation_directory_1.getNxInstallationPath)(root) : root, tmpDir);
2894
+ // Let's print the output of the install process to the console when verbose
2895
+ // is enabled, so it's easier to debug issues with the installation process
2896
+ const stdio = isVerbose
2897
+ ? ['ignore', 'inherit', 'inherit']
2898
+ : 'ignore';
2899
+ if (pmc.preInstall) {
2900
+ // ensure package.json and repo in tmp folder is set to a proper package manager state
2901
+ (0, child_process_1.execSync)(pmc.preInstall, {
2902
+ cwd: tmpDir,
2903
+ stdio,
2904
+ windowsHide: true,
2905
+ });
2906
+ // if it's berry ensure we set the node_linker to node-modules
2907
+ if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) {
2908
+ (0, child_process_1.execSync)('yarn config set nodeLinker node-modules', {
2909
+ cwd: tmpDir,
2910
+ stdio,
2911
+ windowsHide: true,
2912
+ });
2913
+ }
2914
+ }
2915
+ (0, child_process_1.execSync)(`${pmc.install} ${pmc.ignoreScriptsFlag ?? ''}`, {
2916
+ cwd: tmpDir,
2917
+ stdio,
2918
+ windowsHide: true,
2919
+ });
2920
+ // Set NODE_PATH so that these modules can be used for module resolution
2921
+ addToNodePath((0, path_1.join)(tmpDir, 'node_modules'));
2922
+ addToNodePath((0, path_1.join)(nxWorkspaceRoot ?? workspace_root_1.workspaceRoot, 'node_modules'));
2923
+ return (0, path_1.join)(tmpDir, `node_modules`, '.bin', 'nx');
2924
+ }
2925
+ catch (e) {
2926
+ console.error(`Failed to install the ${version} version of the migration script. Falling back to the workspace's installed nx.`);
2927
+ if (isVerbose) {
2928
+ console.error(e);
2929
+ }
2930
+ return null;
2931
+ }
2932
+ }
2933
+ function addToNodePath(dir) {
2934
+ // NODE_PATH is a delimited list of paths.
2935
+ // The delimiter is different for windows.
2936
+ const delimiter = require('os').platform() === 'win32' ? ';' : ':';
2937
+ const paths = process.env.NODE_PATH
2938
+ ? process.env.NODE_PATH.split(delimiter)
2939
+ : [];
2940
+ // Add the tmp path
2941
+ paths.push(dir);
2942
+ // Update the env variable.
2943
+ process.env.NODE_PATH = paths.join(delimiter);
2944
+ }