@ohos-npm-ports/nx 23.1.1-beta.1

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