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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/README.md +2 -2
  2. package/dist/bin/init-local.js +3 -5
  3. package/dist/bin/nx.js +2 -0
  4. package/dist/release/changelog-renderer/index.js +4 -5
  5. package/dist/release/index.d.ts +1 -1
  6. package/dist/src/adapter/ngcli-adapter.js +60 -1
  7. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
  8. package/dist/src/analytics/analytics.d.ts +6 -0
  9. package/dist/src/analytics/analytics.js +16 -10
  10. package/dist/src/analytics/index.d.ts +1 -1
  11. package/dist/src/analytics/index.js +2 -1
  12. package/dist/src/command-line/add/add.js +5 -0
  13. package/dist/src/command-line/affected/affected.js +1 -0
  14. package/dist/src/command-line/completion/command-object.js +7 -12
  15. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
  16. package/dist/src/command-line/format/format.js +84 -101
  17. package/dist/src/command-line/generate/generate.js +35 -35
  18. package/dist/src/command-line/graph/graph.d.ts +1 -0
  19. package/dist/src/command-line/graph/graph.js +15 -6
  20. package/dist/src/command-line/import/import.js +30 -40
  21. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  22. package/dist/src/command-line/init/command-object.js +4 -2
  23. package/dist/src/command-line/init/configure-plugins.js +4 -1
  24. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  25. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  26. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  27. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  28. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  29. package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
  30. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -0
  31. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  32. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  33. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +9 -1
  34. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  35. package/dist/src/command-line/init/implementation/format.js +114 -0
  36. package/dist/src/command-line/init/implementation/utils.js +8 -0
  37. package/dist/src/command-line/init/init-v1.js +15 -18
  38. package/dist/src/command-line/init/init-v2.js +40 -57
  39. package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
  40. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
  41. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
  42. package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
  43. package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
  44. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
  45. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
  46. package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
  47. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  48. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  49. package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
  50. package/dist/src/command-line/migrate/agentic/select.js +30 -32
  51. package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
  52. package/dist/src/command-line/migrate/agentic/types.js +35 -0
  53. package/dist/src/command-line/migrate/command-object.d.ts +6 -0
  54. package/dist/src/command-line/migrate/command-object.js +19 -1
  55. package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
  56. package/dist/src/command-line/migrate/execute-migration.js +112 -27
  57. package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
  58. package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
  59. package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
  60. package/dist/src/command-line/migrate/migrate-commits.js +130 -15
  61. package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
  62. package/dist/src/command-line/migrate/migrate-config.js +22 -14
  63. package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
  64. package/dist/src/command-line/migrate/migrate-output.js +52 -8
  65. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  66. package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
  67. package/dist/src/command-line/migrate/migrate.d.ts +28 -68
  68. package/dist/src/command-line/migrate/migrate.js +657 -293
  69. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  70. package/dist/src/command-line/migrate/multi-major.js +7 -10
  71. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  72. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  73. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  74. package/dist/src/command-line/migrate/run/index.d.ts +9 -0
  75. package/dist/src/command-line/migrate/run/index.js +23 -0
  76. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  77. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  78. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  79. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  80. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  81. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  82. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  83. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  84. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  85. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  86. package/dist/src/command-line/migrate/run/util.d.ts +59 -0
  87. package/dist/src/command-line/migrate/run/util.js +148 -0
  88. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  89. package/dist/src/command-line/migrate/run/worker.js +682 -0
  90. package/dist/src/command-line/migrate/run-migration-process.js +6 -5
  91. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  92. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  93. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  94. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  95. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  96. package/dist/src/command-line/migrate/step-actions.js +12 -0
  97. package/dist/src/command-line/migrate/text.d.ts +18 -0
  98. package/dist/src/command-line/migrate/text.js +26 -0
  99. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  100. package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
  101. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -21
  102. package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
  103. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  104. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  105. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  106. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  107. package/dist/src/command-line/nx-commands.js +26 -24
  108. package/dist/src/command-line/release/changelog.js +11 -17
  109. package/dist/src/command-line/release/index.d.ts +1 -1
  110. package/dist/src/command-line/release/plan.js +15 -28
  111. package/dist/src/command-line/release/publish.js +5 -0
  112. package/dist/src/command-line/release/release.js +6 -17
  113. package/dist/src/command-line/release/utils/git.js +1 -1
  114. package/dist/src/command-line/release/utils/release-graph.d.ts +18 -0
  115. package/dist/src/command-line/release/utils/release-graph.js +81 -21
  116. package/dist/src/command-line/release/utils/remote-release-clients/github.js +17 -23
  117. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +14 -23
  118. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  119. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  120. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  121. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  122. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  123. package/dist/src/command-line/release/version/version-actions.js +9 -1
  124. package/dist/src/command-line/release/version.js +10 -6
  125. package/dist/src/command-line/reset/reset.js +6 -1
  126. package/dist/src/command-line/run/run-one.js +1 -0
  127. package/dist/src/command-line/run-many/run-many.js +1 -0
  128. package/dist/src/command-line/show/show-target/inputs.js +50 -153
  129. package/dist/src/command-line/show/show-target/outputs.js +48 -173
  130. package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
  131. package/dist/src/command-line/show/show-target/utils.js +83 -3
  132. package/dist/src/command-line/watch/watch.js +13 -0
  133. package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
  134. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  135. package/dist/src/config/misc-interfaces.d.ts +19 -7
  136. package/dist/src/config/nx-json.d.ts +4 -2
  137. package/dist/src/core/graph/main.js +1 -1
  138. package/dist/src/core/graph/styles.js +1 -1
  139. package/dist/src/daemon/client/client.d.ts +52 -1
  140. package/dist/src/daemon/client/client.js +160 -36
  141. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  142. package/dist/src/daemon/client/daemon-environment.js +110 -2
  143. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  144. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  145. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  146. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  147. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  148. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
  149. package/dist/src/daemon/server/latest-nx.js +5 -2
  150. package/dist/src/daemon/server/server.js +31 -4
  151. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  152. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  153. package/dist/src/daemon/socket-utils.d.ts +1 -0
  154. package/dist/src/daemon/socket-utils.js +24 -3
  155. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  156. package/dist/src/daemon/tmp-dir.js +437 -15
  157. package/dist/src/devkit-internals.d.ts +106 -8
  158. package/dist/src/devkit-internals.js +225 -7
  159. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  160. package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
  161. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  162. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  163. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  164. package/dist/src/generators/tree.d.ts +4 -2
  165. package/dist/src/hasher/check-task-files.d.ts +86 -0
  166. package/dist/src/hasher/check-task-files.js +378 -0
  167. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  168. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  169. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  170. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  171. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  172. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  173. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  174. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  175. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  176. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  177. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  178. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  179. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  180. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  181. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  182. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  183. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  184. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  185. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  186. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  187. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  188. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  189. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  190. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  191. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  192. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  193. package/dist/src/native/index.d.ts +37 -4
  194. package/dist/src/native/index.js +71 -28
  195. package/dist/src/native/native-bindings.js +3 -0
  196. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  197. package/dist/src/native/native-file-cache-location.js +86 -12
  198. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  199. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  200. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  201. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  202. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  203. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  204. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  205. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  206. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  207. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  208. package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
  209. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  210. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
  211. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  212. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  213. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  214. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
  215. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  216. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
  217. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  218. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  219. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  220. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  221. package/dist/src/project-graph/build-project-graph.js +7 -1
  222. package/dist/src/project-graph/error-types.d.ts +12 -1
  223. package/dist/src/project-graph/error-types.js +27 -2
  224. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  225. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
  226. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  227. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  228. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  229. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
  230. package/dist/src/project-graph/project-graph.js +23 -0
  231. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
  232. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
  233. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
  234. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
  235. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
  236. package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
  237. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
  238. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
  239. package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
  240. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
  241. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
  242. package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
  243. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
  244. package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
  245. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  246. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  247. package/dist/src/tasks-runner/life-cycle.js +2 -2
  248. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
  249. package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
  250. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  251. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  252. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  253. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  254. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  255. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  256. package/dist/src/tasks-runner/run-command.js +28 -35
  257. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  258. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  259. package/dist/src/tasks-runner/task-env.d.ts +9 -0
  260. package/dist/src/tasks-runner/task-env.js +31 -4
  261. package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
  262. package/dist/src/tasks-runner/task-orchestrator.js +182 -18
  263. package/dist/src/tasks-runner/utils.js +2 -6
  264. package/dist/src/utils/acknowledge-build-scripts.js +7 -5
  265. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  266. package/dist/src/utils/analytics-enabled.js +11 -0
  267. package/dist/src/utils/analytics-prompt.d.ts +0 -6
  268. package/dist/src/utils/analytics-prompt.js +4 -58
  269. package/dist/src/utils/assert-workspace-validity.js +7 -2
  270. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  271. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  272. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  273. package/dist/src/utils/catalog/bun-manager.js +130 -0
  274. package/dist/src/utils/catalog/index.d.ts +1 -1
  275. package/dist/src/utils/catalog/index.js +1 -1
  276. package/dist/src/utils/catalog/manager-factory.js +3 -0
  277. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  278. package/dist/src/utils/catalog/manager-utils.js +9 -4
  279. package/dist/src/utils/catalog/manager.d.ts +13 -1
  280. package/dist/src/utils/catalog/manager.js +30 -0
  281. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  282. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  283. package/dist/src/utils/catalog/types.d.ts +4 -0
  284. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  285. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  286. package/dist/src/utils/child-process.d.ts +31 -1
  287. package/dist/src/utils/child-process.js +103 -0
  288. package/dist/src/utils/chunkify.d.ts +7 -1
  289. package/dist/src/utils/chunkify.js +10 -3
  290. package/dist/src/utils/exit-codes.d.ts +9 -0
  291. package/dist/src/utils/exit-codes.js +19 -0
  292. package/dist/src/utils/fileutils.d.ts +5 -0
  293. package/dist/src/utils/fileutils.js +7 -2
  294. package/dist/src/utils/formatters/index.d.ts +13 -0
  295. package/dist/src/utils/formatters/index.js +74 -0
  296. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  297. package/dist/src/utils/formatters/oxfmt.js +764 -0
  298. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  299. package/dist/src/utils/formatters/prettier.js +201 -0
  300. package/dist/src/utils/formatters/shared.d.ts +5 -0
  301. package/dist/src/utils/formatters/shared.js +8 -0
  302. package/dist/src/utils/git-utils.d.ts +48 -2
  303. package/dist/src/utils/git-utils.js +220 -14
  304. package/dist/src/utils/git-worktrees.d.ts +30 -0
  305. package/dist/src/utils/git-worktrees.js +212 -0
  306. package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
  307. package/dist/src/utils/has-nx-js-plugin.js +1 -1
  308. package/dist/src/utils/ignore.d.ts +170 -1
  309. package/dist/src/utils/ignore.js +263 -11
  310. package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
  311. package/dist/src/utils/kill-child-on-host-exit.js +42 -0
  312. package/dist/src/utils/long-running-target.d.ts +10 -0
  313. package/dist/src/utils/long-running-target.js +19 -0
  314. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  315. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  316. package/dist/src/utils/min-release-age/packument.js +1 -1
  317. package/dist/src/utils/nx-console-prompt.js +3 -6
  318. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  319. package/dist/src/utils/nx-tmp-dir.js +40 -0
  320. package/dist/src/utils/output.d.ts +153 -0
  321. package/dist/src/utils/output.js +289 -5
  322. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  323. package/dist/src/utils/owned-private-dir.js +323 -0
  324. package/dist/src/utils/package-json.d.ts +2 -0
  325. package/dist/src/utils/package-json.js +11 -7
  326. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  327. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  328. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  329. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  330. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  331. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  332. package/dist/src/utils/package-manager.d.ts +23 -2
  333. package/dist/src/utils/package-manager.js +262 -42
  334. package/dist/src/utils/params.d.ts +7 -1
  335. package/dist/src/utils/params.js +64 -6
  336. package/dist/src/utils/plugins/core-plugins.js +4 -0
  337. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  338. package/dist/src/utils/prompt-helpers.js +111 -0
  339. package/dist/src/utils/provenance.js +6 -14
  340. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  341. package/dist/src/utils/registry-config/bun.js +257 -0
  342. package/dist/src/utils/registry-config/index.d.ts +13 -0
  343. package/dist/src/utils/registry-config/index.js +102 -0
  344. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  345. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  346. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  347. package/dist/src/utils/registry-config/utils.js +496 -0
  348. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  349. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  350. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  351. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  352. package/dist/src/utils/safe-spawn.d.ts +24 -0
  353. package/dist/src/utils/safe-spawn.js +104 -0
  354. package/dist/src/utils/shell-quoting.d.ts +15 -0
  355. package/dist/src/utils/shell-quoting.js +35 -0
  356. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  357. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  358. package/dist/src/utils/workspace-id.d.ts +20 -0
  359. package/dist/src/utils/workspace-id.js +54 -0
  360. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  361. package/dist/src/utils/write-formatted-json-file.js +5 -4
  362. package/migrations.json +6 -0
  363. package/package.json +29 -19
  364. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
  365. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
  366. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  367. package/dist/src/utils/is-using-prettier.js +0 -62
  368. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  369. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -8,6 +8,21 @@ export declare const INTEGER_LIKE_KEY_PATTERN: RegExp;
8
8
  export declare class IntegerLikeSpreadKeyError extends Error {
9
9
  constructor(key: string, context: string);
10
10
  }
11
+ /**
12
+ * Throws `IntegerLikeSpreadKeyError` when `value` is a `'...'` spread object
13
+ * whose enumeration hoists an integer-like key ahead of the spread, making its
14
+ * authored position ambiguous.
15
+ *
16
+ * The ambiguity is a property of the authored value alone, not of any merge
17
+ * base. `mergeObjectWithSpread` runs this the moment it merges such a value —
18
+ * but a merge layer that lets the base win a key drops the incoming value
19
+ * without merging it, so the check must also be run eagerly at those
20
+ * base-owns-key shortcuts. Otherwise the error would surface or vanish
21
+ * depending on which side owns the key (e.g. it fires in the target-defaults
22
+ * staging merge but not the real merge), which is exactly the divergence that
23
+ * makes discarding staging errors unsafe.
24
+ */
25
+ export declare function assertNoIntegerLikeSpreadKey(value: unknown, errorContext: string): void;
11
26
  type SourceMapContext = {
12
27
  sourceMap: Record<string, SourceInformation>;
13
28
  key: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IntegerLikeSpreadKeyError = exports.INTEGER_LIKE_KEY_PATTERN = exports.NX_SPREAD_TOKEN = void 0;
4
4
  exports.uniqueKeysInObjects = uniqueKeysInObjects;
5
+ exports.assertNoIntegerLikeSpreadKey = assertNoIntegerLikeSpreadKey;
5
6
  exports.getMergeValueResult = getMergeValueResult;
6
7
  const source_maps_1 = require("./source-maps");
7
8
  exports.NX_SPREAD_TOKEN = '...';
@@ -30,6 +31,29 @@ class IntegerLikeSpreadKeyError extends Error {
30
31
  }
31
32
  }
32
33
  exports.IntegerLikeSpreadKeyError = IntegerLikeSpreadKeyError;
34
+ /**
35
+ * Throws `IntegerLikeSpreadKeyError` when `value` is a `'...'` spread object
36
+ * whose enumeration hoists an integer-like key ahead of the spread, making its
37
+ * authored position ambiguous.
38
+ *
39
+ * The ambiguity is a property of the authored value alone, not of any merge
40
+ * base. `mergeObjectWithSpread` runs this the moment it merges such a value —
41
+ * but a merge layer that lets the base win a key drops the incoming value
42
+ * without merging it, so the check must also be run eagerly at those
43
+ * base-owns-key shortcuts. Otherwise the error would surface or vanish
44
+ * depending on which side owns the key (e.g. it fires in the target-defaults
45
+ * staging merge but not the real merge), which is exactly the divergence that
46
+ * makes discarding staging errors unsafe.
47
+ */
48
+ function assertNoIntegerLikeSpreadKey(value, errorContext) {
49
+ if (!isObject(value) || value[exports.NX_SPREAD_TOKEN] !== true) {
50
+ return;
51
+ }
52
+ const keys = Object.keys(value);
53
+ if (keys[0] && exports.INTEGER_LIKE_KEY_PATTERN.test(keys[0])) {
54
+ throw new IntegerLikeSpreadKeyError(keys[0], errorContext);
55
+ }
56
+ }
33
57
  /**
34
58
  * `"..."` in `newValue` (as an array element or a key set to `true`)
35
59
  * expands the base at that position; otherwise `newValue` replaces
@@ -52,11 +76,25 @@ function getMergeValueResult(baseValue, newValue, sourceMapContext, deferSpreads
52
76
  // plugin already set, purely as a merge guard — must not steal provenance
53
77
  // from the layer that introduced the value. A genuinely new value (no base,
54
78
  // or a different one) still attributes to the new layer.
55
- if (!isUnchangedPrimitive(newValue, baseValue)) {
79
+ //
80
+ // The exception cuts the other way too: when the *existing* attribution is a
81
+ // target-defaults stamp (TD merges before the plugin whose value it
82
+ // predicted, so its stamp lands first), a real plugin re-stating that value
83
+ // is the genuine author and reclaims the key.
84
+ if (!isUnchangedPrimitive(newValue, baseValue) ||
85
+ isReclaimableTargetDefaultsStamp(sourceMapContext)) {
56
86
  writeTopLevelSourceMap(sourceMapContext);
57
87
  }
58
88
  return newValue;
59
89
  }
90
+ // Whether the key's current attribution is a weak target-defaults stamp that
91
+ // the (non-target-defaults) writer should reclaim despite the value being
92
+ // unchanged.
93
+ function isReclaimableTargetDefaultsStamp(ctx) {
94
+ return (!!ctx &&
95
+ ctx.sourceMap[ctx.key]?.[1] === source_maps_1.TARGET_DEFAULTS_PLUGIN_NAME &&
96
+ ctx.sourceInformation[1] !== source_maps_1.TARGET_DEFAULTS_PLUGIN_NAME);
97
+ }
60
98
  // Whether `newValue` leaves a defined primitive base untouched. Objects fall
61
99
  // through (always re-attributed) to preserve the existing replace semantics —
62
100
  // the regression this guards is scalar executor/command re-stamping.
@@ -120,12 +158,10 @@ function mergeObjectWithSpread(baseValue, newValue, sourceMapContext, deferSprea
120
158
  const errorContext = sourceMapContext?.key
121
159
  ? `Object at "${sourceMapContext.key}"`
122
160
  : 'Object';
161
+ // Integer-like keys are hoisted to the front of enumeration, so one
162
+ // alongside `'...'` makes its authored position ambiguous.
163
+ assertNoIntegerLikeSpreadKey(newValue, errorContext);
123
164
  const newKeys = Object.keys(newValue);
124
- // Integer-like keys are hoisted to the front of enumeration, so if one
125
- // exists alongside `'...'` it must be newKeys[0].
126
- if (newKeys[0] && exports.INTEGER_LIKE_KEY_PATTERN.test(newKeys[0])) {
127
- throw new IntegerLikeSpreadKeyError(newKeys[0], errorContext);
128
- }
129
165
  // Base per-key sources captured lazily — only for shared keys the new
130
166
  // object overwrites before `'...'`, since writing their new source
131
167
  // clobbers the base entry the spread will need to restore.
@@ -60,19 +60,22 @@ export type MergeError = AggregateCreateNodesError | MergeNodesError | ProjectsW
60
60
  /**
61
61
  * Merges create nodes results into a single rootMap.
62
62
  *
63
- * Specified plugin results are merged once into the manager. Default
64
- * plugin results are first staged into an intermediate rootMap (with
65
- * `'...'` spreads deferred) so that synthesis can read each layer's
66
- * contribution without re-running the merge. The synthetic result from
67
- * `createTargetDefaultsResults` is then merged into the manager, and
68
- * the staged intermediate is replayed on top — that replay is where
69
- * deferred spreads expand against the final (specified + synth) base.
63
+ * Every layer merges into the manager through the same source-map-aware
64
+ * merge, in precedence order:
70
65
  *
71
- * Synthesis itself doesn't materialize a second rootMap. Per
72
- * (root, target) it does an on-the-fly merge of the two layered
73
- * contributions to learn the eventual executor/command, then matches
74
- * defaults against that merged shape. This keeps specified-plugin
75
- * merge work to a single pass.
66
+ * specified plugins → synthetic target defaults → default plugins
67
+ *
68
+ * so field-level provenance is decided by the merge itself for all three
69
+ * layers — whichever layer a field's final value came from owns its
70
+ * attribution, and `'...'` spreads in default-plugin configs resolve against
71
+ * the accumulated specified + target-defaults base.
72
+ *
73
+ * Target-default synthesis needs the *merged* shape of the default layer
74
+ * (to predict each target's eventual executor/command) before that layer
75
+ * merges into the manager. To get it, default results are first staged into
76
+ * a throwaway intermediate rootMap with unresolvable `'...'` spreads
77
+ * deferred. The staging output feeds only `createTargetDefaultsResults`; the
78
+ * default plugins then merge into the manager from their original results.
76
79
  */
77
80
  export declare function mergeCreateNodesResults(specifiedResults: CreateNodesResultEntry[][], defaultResults: CreateNodesResultEntry[][], nxJsonConfiguration: NxJsonConfiguration, workspaceRoot: string, errors: MergeError[]): {
78
81
  projectRootMap: Record<string, ProjectConfiguration>;
@@ -13,10 +13,10 @@ const delayed_spinner_1 = require("../../utils/delayed-spinner");
13
13
  const plugin_progress_text_1 = require("../../utils/plugin-progress-text");
14
14
  const progress_topics_1 = require("../../utils/progress-topics");
15
15
  const error_types_1 = require("../error-types");
16
- const source_maps_1 = require("./project-configuration/source-maps");
17
16
  const target_defaults_1 = require("./project-configuration/target-defaults");
18
17
  var target_merging_1 = require("./project-configuration/target-merging");
19
18
  Object.defineProperty(exports, "mergeTargetConfigurations", { enumerable: true, get: function () { return target_merging_1.mergeTargetConfigurations; } });
19
+ const target_merging_2 = require("./project-configuration/target-merging");
20
20
  var target_defaults_2 = require("./project-configuration/target-defaults");
21
21
  Object.defineProperty(exports, "readTargetDefaultsForTarget", { enumerable: true, get: function () { return target_defaults_2.readTargetDefaultsForTarget; } });
22
22
  /**
@@ -123,14 +123,13 @@ async function createProjectConfigurationsWithPlugins(root = workspace_root_1.wo
123
123
  * Runs a single plugin batch through two passes:
124
124
  *
125
125
  * 1. Every project node in every plugin result is handed to `mergeFn`,
126
- * which decides where it lands (the manager's rootMap, an
127
- * intermediate rootMap, etc.). Any failure is collected into
128
- * `errors`; processing keeps going. External nodes are accumulated
129
- * onto the shared `externalNodes` record.
126
+ * which merges it into the manager's rootMap. Any failure is
127
+ * collected into `errors`; processing keeps going. External nodes
128
+ * are accumulated onto the shared `externalNodes` record.
130
129
  * 2. After every project in the batch has been merged, name-reference
131
- * sentinels for the batch are registered against `nameRefRootMap` —
132
- * the rootMap the batch was merged into — so sentinels point at the
133
- * target objects that actually received the merges.
130
+ * sentinels for the batch are registered against the manager's
131
+ * rootMap, so sentinels point at the target objects that actually
132
+ * received the merges.
134
133
  *
135
134
  * The two passes can't be collapsed: a sentinel registered too early
136
135
  * would point at the pre-merge object, and a later project in the same
@@ -138,7 +137,11 @@ async function createProjectConfigurationsWithPlugins(root = workspace_root_1.wo
138
137
  * the registration into a second pass also lets forward references
139
138
  * inside the same batch resolve eagerly.
140
139
  */
141
- function mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeFn, nodesManager, nameRefRootMap, externalNodes, errors) {
140
+ function mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeFn, nodesManager, externalNodes, errors) {
141
+ mergeSinglePluginResults(pluginResults, mergeFn, externalNodes, errors);
142
+ registerNameRefsFromSinglePlugin(pluginResults, nodesManager, errors);
143
+ }
144
+ function mergeSinglePluginResults(pluginResults, mergeFn, externalNodes, errors) {
142
145
  for (const result of pluginResults) {
143
146
  const [pluginName, file, nodes, pluginIndex] = result;
144
147
  const { projects: projectNodes, externalNodes: pluginExternalNodes } = nodes;
@@ -156,11 +159,13 @@ function mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeFn, nodesMa
156
159
  }
157
160
  Object.assign(externalNodes, pluginExternalNodes);
158
161
  }
162
+ }
163
+ function registerNameRefsFromSinglePlugin(pluginResults, nodesManager, errors) {
159
164
  for (const result of pluginResults) {
160
165
  const [pluginName, file, nodes, pluginIndex] = result;
161
166
  const { projects: projectNodes } = nodes;
162
167
  try {
163
- nodesManager.registerNameRefs(projectNodes, nameRefRootMap);
168
+ nodesManager.registerNameRefs(projectNodes);
164
169
  }
165
170
  catch (error) {
166
171
  errors.push(new error_types_1.MergeNodesError({ file, pluginName, error, pluginIndex }));
@@ -170,108 +175,83 @@ function mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeFn, nodesMa
170
175
  /**
171
176
  * Merges create nodes results into a single rootMap.
172
177
  *
173
- * Specified plugin results are merged once into the manager. Default
174
- * plugin results are first staged into an intermediate rootMap (with
175
- * `'...'` spreads deferred) so that synthesis can read each layer's
176
- * contribution without re-running the merge. The synthetic result from
177
- * `createTargetDefaultsResults` is then merged into the manager, and
178
- * the staged intermediate is replayed on top — that replay is where
179
- * deferred spreads expand against the final (specified + synth) base.
178
+ * Every layer merges into the manager through the same source-map-aware
179
+ * merge, in precedence order:
180
+ *
181
+ * specified plugins → synthetic target defaults → default plugins
182
+ *
183
+ * so field-level provenance is decided by the merge itself for all three
184
+ * layers — whichever layer a field's final value came from owns its
185
+ * attribution, and `'...'` spreads in default-plugin configs resolve against
186
+ * the accumulated specified + target-defaults base.
180
187
  *
181
- * Synthesis itself doesn't materialize a second rootMap. Per
182
- * (root, target) it does an on-the-fly merge of the two layered
183
- * contributions to learn the eventual executor/command, then matches
184
- * defaults against that merged shape. This keeps specified-plugin
185
- * merge work to a single pass.
188
+ * Target-default synthesis needs the *merged* shape of the default layer
189
+ * (to predict each target's eventual executor/command) before that layer
190
+ * merges into the manager. To get it, default results are first staged into
191
+ * a throwaway intermediate rootMap with unresolvable `'...'` spreads
192
+ * deferred. The staging output feeds only `createTargetDefaultsResults`; the
193
+ * default plugins then merge into the manager from their original results.
186
194
  */
187
195
  function mergeCreateNodesResults(specifiedResults, defaultResults, nxJsonConfiguration, workspaceRoot, errors) {
188
196
  perf_hooks_1.performance.mark('createNodes:merge - start');
189
197
  const nodesManager = new project_nodes_manager_1.ProjectNodesManager();
190
198
  const externalNodes = {};
191
199
  const configurationSourceMaps = {};
192
- const intermediateDefaultRootMap = {};
193
- // Kept separate so the intermediate merge doesn't clobber
194
- // specified/TD attribution on fields the defaults don't touch.
195
- const defaultConfigurationSourceMaps = {};
196
200
  const mergeToManager = (project, sourceInfo) => nodesManager.mergeProjectNode(project, configurationSourceMaps, sourceInfo);
197
- const mergeToIntermediate = (project, sourceInfo) => {
198
- (0, project_nodes_manager_1.mergeProjectConfigurationIntoRootMap)(intermediateDefaultRootMap, project, defaultConfigurationSourceMaps, sourceInfo);
199
- };
200
201
  for (const pluginResults of specifiedResults) {
201
- mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeToManager, nodesManager, nodesManager.getRootMap(), externalNodes, errors);
202
- }
203
- for (const pluginResults of defaultResults) {
204
- mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeToIntermediate, nodesManager, intermediateDefaultRootMap, externalNodes, errors);
205
- }
206
- const targetDefaultsResults = (0, target_defaults_1.createTargetDefaultsResults)(nodesManager.getRootMap(), intermediateDefaultRootMap, nxJsonConfiguration, configurationSourceMaps, defaultConfigurationSourceMaps);
207
- if (targetDefaultsResults.length > 0) {
208
- mergeCreateNodesResultsFromSinglePlugin(targetDefaultsResults, mergeToManager, nodesManager, nodesManager.getRootMap(), externalNodes, errors);
202
+ mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeToManager, nodesManager, externalNodes, errors);
209
203
  }
210
- // Apply the intermediate default rootMap as a single layer. Preserved
211
- // spread sentinels resolve here against the real specified + TD base.
212
- // Source maps are intentionally not written — TD attribution for
213
- // fields that yield to the base (e.g. keys before `...`) stays intact.
214
- for (const root in intermediateDefaultRootMap) {
215
- const project = intermediateDefaultRootMap[root];
216
- try {
217
- nodesManager.mergeProjectNode(project, undefined, undefined);
204
+ // Without target defaults there is nothing to synthesize, and the staging
205
+ // pass exists only to feed synthesis — skip straight to the default-plugin
206
+ // merge.
207
+ if (Object.keys(nxJsonConfiguration.targetDefaults ?? {}).length > 0) {
208
+ // Throwaway staging area: the default layer's merged shape (unresolvable
209
+ // `'...'` spreads deferred), read only by target-default synthesis. The
210
+ // default plugins merge into the manager from their original results, not
211
+ // from this map. No source maps are kept for it — synthesis attributes
212
+ // targets without them (a default plugin can never be named by a
213
+ // `filter.plugin`); the real default merge writes the manager's.
214
+ const intermediateDefaultRootMap = {};
215
+ // The rootMap merge adopts input arrays/objects by reference and grows
216
+ // them in place (e.g. `mergeMetadata`), so staging works on deep clones —
217
+ // handing it the plugin results themselves would corrupt them before the
218
+ // real merge below reads them.
219
+ const mergeToIntermediate = (project, sourceInfo) => {
220
+ (0, project_nodes_manager_1.mergeProjectConfigurationIntoRootMap)(intermediateDefaultRootMap, (0, target_merging_2.deepClone)(project), undefined, sourceInfo, false, true);
221
+ };
222
+ // Stage the default layer for synthesis. Merge errors are discarded and
223
+ // external nodes land in a scratch object — the same results merge into
224
+ // the manager below, where both surface once with proper plugin context.
225
+ // The discard is safe because every merge throw is base-independent in
226
+ // both its condition and its reachability: each throw's condition reads
227
+ // only the plugin's own config, and the spread-ambiguity throws fire even
228
+ // when a key is dropped by a base-owns-key shortcut, because those
229
+ // shortcuts eagerly validate the dropped value (`assertNoIntegerLikeSpreadKey`).
230
+ // So a given config raises the same error in this pass and the real merge
231
+ // below despite their bases differing.
232
+ // Name references are NOT registered here: `applySubstitutions` sweeps only
233
+ // the manager's `rootMap`, so sentinels registered against this throwaway
234
+ // rootMap would never be visited and would never resolve.
235
+ const stagingErrors = [];
236
+ const stagingExternalNodes = {};
237
+ for (const pluginResults of defaultResults) {
238
+ mergeSinglePluginResults(pluginResults, mergeToIntermediate, stagingExternalNodes, stagingErrors);
218
239
  }
219
- catch (error) {
220
- errors.push(new error_types_1.MergeNodesError({
221
- file: 'nx.json',
222
- pluginName: 'nx/default-plugins',
223
- error,
224
- pluginIndex: undefined,
225
- }));
240
+ const targetDefaultsResults = (0, target_defaults_1.createTargetDefaultsResults)(nodesManager.getRootMap(), intermediateDefaultRootMap, nxJsonConfiguration, configurationSourceMaps);
241
+ if (targetDefaultsResults.length > 0) {
242
+ mergeCreateNodesResultsFromSinglePlugin(targetDefaultsResults, mergeToManager, nodesManager, externalNodes, errors);
226
243
  }
227
244
  }
228
- // The intermediate apply may have rebuilt dependsOn / inputs arrays via
229
- // spread merges, introducing name-ref strings that weren't visible in any
230
- // single plugin result. Re-walking the final merged targets sentinelizes
231
- // them so the final substitution sweep resolves them too.
232
- nodesManager.registerNameRefs(intermediateDefaultRootMap);
233
- // Overlay default-plugin attribution onto the main source maps using
234
- // "only fill missing" semantics. Any key already present in
235
- // configurationSourceMaps was written by a specified plugin or by
236
- // target defaults, and that attribution is strictly more correct:
237
- // - For fields the default plugin never shadowed, the existing entry
238
- // already matches what the default plugin would overlay.
239
- // - For fields where a default plugin placed `...` after other keys,
240
- // those keys yielded to the base during the single-layer apply
241
- // above. The stale default-plugin entry in
242
- // `defaultConfigurationSourceMaps` must NOT clobber the base
243
- // attribution that the specified plugin / TD already recorded.
244
- const mainRootMap = nodesManager.getRootMap();
245
- for (const root in defaultConfigurationSourceMaps) {
246
- const existing = (configurationSourceMaps[root] ??= {});
247
- const incoming = defaultConfigurationSourceMaps[root];
248
- // A default plugin's targets are synthesized into the main rootmap by
249
- // target defaults *before* the default layer is applied, so target
250
- // defaults wrote the main source map's entry for the target node and its
251
- // identity fields first — even though it never authored them (it only
252
- // stamps them as a merge guard and cannot bring a target into existence).
253
- // The identity fields are the executor/command plus, for run-commands, the
254
- // `options.command`/`options.commands` the synthetic copies from the winner
255
- // to stay compatible (#36067). For those keys, the real default plugin's
256
- // attribution must override the target-defaults stamp.
257
- const identityKeys = new Set();
258
- for (const targetName in mainRootMap[root]?.targets ?? {}) {
259
- const base = (0, source_maps_1.targetSourceMapKey)(targetName);
260
- identityKeys.add(base);
261
- identityKeys.add(`${base}.executor`);
262
- identityKeys.add(`${base}.command`);
263
- identityKeys.add(`${base}.options.command`);
264
- identityKeys.add(`${base}.options.commands`);
265
- }
266
- for (const key in incoming) {
267
- if (existing[key] === undefined) {
268
- existing[key] = incoming[key];
269
- }
270
- else if (identityKeys.has(key) &&
271
- existing[key][1] === source_maps_1.TARGET_DEFAULTS_PLUGIN_NAME) {
272
- existing[key] = incoming[key];
273
- }
274
- }
245
+ // Merge the default plugins into the manager on top of the specified + TD
246
+ // base, from their original results. This is the same source-map-aware path
247
+ // the other layers take, so every field a default plugin wins — including
248
+ // fields it overrides on a specified/TD target — is attributed to it by the
249
+ // merge itself, `'...'` spreads resolve against the real base (keys a spread
250
+ // lets the base win keep their base attribution), and identity provenance
251
+ // follows the node-ownership rules in `recordTargetIdentitySourceMapInfo` /
252
+ // `getMergeValueResult`.
253
+ for (const pluginResults of defaultResults) {
254
+ mergeCreateNodesResultsFromSinglePlugin(pluginResults, mergeToManager, nodesManager, externalNodes, errors);
275
255
  }
276
256
  const projectRootMap = nodesManager.getRootMap();
277
257
  try {
@@ -6,6 +6,7 @@ exports.shouldUseTui = shouldUseTui;
6
6
  const native_1 = require("../native");
7
7
  const is_ci_1 = require("../utils/is-ci");
8
8
  const logger_1 = require("../utils/logger");
9
+ const output_1 = require("../utils/output");
9
10
  exports.ORIGINAL_TUI_ENV_VALUE = process.env.NX_TUI;
10
11
  /**
11
12
  * @returns If tui is enabled
@@ -38,7 +39,8 @@ function shouldUseTui(nxJson, nxArgs, skipCapabilityCheck = process.env.NX_TUI_S
38
39
  if (!isCapable) {
39
40
  return false;
40
41
  }
41
- if (['static', 'stream', 'stream-without-prefixes', 'dynamic-legacy'].includes(nxArgs.outputStyle)) {
42
+ if ((0, output_1.isStaticOutputStyle)(nxArgs.outputStyle) ||
43
+ ['stream', 'stream-without-prefixes', 'dynamic-legacy'].includes(nxArgs.outputStyle)) {
42
44
  // If the user has specified a non-TUI output style, we disable the TUI
43
45
  return false;
44
46
  }
@@ -44,7 +44,7 @@ export interface LifeCycle {
44
44
  startTasks?(task: Task[], metadata: TaskMetadata): void | Promise<void>;
45
45
  endTasks?(taskResults: TaskResult[], metadata: TaskMetadata): void | Promise<void>;
46
46
  printTaskTerminalOutput?(task: Task, status: TaskStatus, output: string): void;
47
- registerRunningTask?(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
47
+ registerRunningTask?(taskId: string, ptyHandles: ExternalObject<[any, any, any]>): void;
48
48
  registerRunningTaskWithEmptyParser?(taskId: string): void;
49
49
  appendTaskOutput?(taskId: string, output: string, isPtyTask: boolean): void;
50
50
  setTaskStatus?(taskId: string, status: NativeTaskStatus): void;
@@ -72,7 +72,7 @@ export declare class CompositeLifeCycle implements LifeCycle {
72
72
  startTasks(tasks: Task[], metadata: TaskMetadata): Promise<void>;
73
73
  endTasks(taskResults: TaskResult[], metadata: TaskMetadata): Promise<void>;
74
74
  printTaskTerminalOutput(task: Task, status: TaskStatus, output: string): void;
75
- registerRunningTask(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
75
+ registerRunningTask(taskId: string, ptyHandles: ExternalObject<[any, any, any]>): void;
76
76
  registerRunningTaskWithEmptyParser(taskId: string): void;
77
77
  appendTaskOutput(taskId: string, output: string, isPtyTask: boolean): void;
78
78
  setTaskStatus(taskId: string, status: NativeTaskStatus): void;
@@ -67,10 +67,10 @@ class CompositeLifeCycle {
67
67
  }
68
68
  }
69
69
  }
70
- registerRunningTask(taskId, parserAndWriter) {
70
+ registerRunningTask(taskId, ptyHandles) {
71
71
  for (let l of this.lifeCycles) {
72
72
  if (l.registerRunningTask) {
73
- l.registerRunningTask(taskId, parserAndWriter);
73
+ l.registerRunningTask(taskId, ptyHandles);
74
74
  }
75
75
  }
76
76
  }
@@ -1,5 +1,17 @@
1
1
  import type { PerformanceSummaryPayload } from '../../native';
2
+ import type { NxJsonConfiguration } from '../../config/nx-json';
2
3
  import type { PerformanceSummary, TaskDurationRow } from './performance-analysis';
4
+ /**
5
+ * Point the remote-cache CTA at a short Nx Cloud onboarding URL for a
6
+ * disconnected GitHub workspace - the VCS flow where Cloud opens the nx.json PR.
7
+ * Non-GitHub remotes keep the get-started link (handles every provider) and skip
8
+ * the network entirely. Runs in CI too - terminal + job summary.
9
+ *
10
+ * Best-effort: the get-started link stays on failure/timeout. Fired at run start;
11
+ * the CTA needs a >30s run (MIN_RECOMMENDATION_RUN_DURATION), so the fetch
12
+ * always resolves first.
13
+ */
14
+ export declare function prefetchRemoteCacheOnboardingUrl(nxJson: NxJsonConfiguration): Promise<void>;
3
15
  /**
4
16
  * A recommendation built from structured parts so the link text comes from the link
5
17
  * definition (not a substring scanned out of the assembled report). A part is literal
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MEANINGFUL_OVERHEAD = exports.MIN_RECOMMENDATION_RUN_DURATION = void 0;
4
+ exports.prefetchRemoteCacheOnboardingUrl = prefetchRemoteCacheOnboardingUrl;
4
5
  exports.recommendationToPayloadString = recommendationToPayloadString;
5
6
  exports.buildRecommendations = buildRecommendations;
6
7
  exports.formatReport = formatReport;
@@ -8,14 +9,72 @@ exports.formatReportMarkdown = formatReportMarkdown;
8
9
  exports.buildExitSummaryPayload = buildExitSummaryPayload;
9
10
  const native_1 = require("../../native");
10
11
  const terminal_link_1 = require("../../utils/terminal-link");
12
+ const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
13
+ const url_shorten_1 = require("../../nx-cloud/utilities/url-shorten");
14
+ const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
15
+ const git_utils_1 = require("../../utils/git-utils");
16
+ const logger_1 = require("../../utils/logger");
11
17
  const NX_AGENTS_URL = 'https://nx.dev/ci/features/distribute-task-execution';
12
- const NX_REMOTE_CACHE_URL = 'https://nx.dev/ci/features/remote-cache';
18
+ // Fallback for the remote-cache CTA when the short onboarding URL can't be
19
+ // fetched: the generic Cloud get-started page (still drives to onboarding).
20
+ const NX_CLOUD_GET_STARTED_URL = 'https://cloud.nx.app/get-started';
13
21
  const NX_PERFORMANCE_URL = 'https://nx.dev/docs/concepts/ci-concepts/parallelization-distribution';
14
22
  /** utm tag attributing report clicks back to it; the content names the CTA clicked. */
15
23
  const utm = (content) => `?utm_source=nx-cli&utm_medium=cli&utm_campaign=performance-report&utm_content=${content}`;
16
24
  const NX_PERFORMANCE_LINK = `${NX_PERFORMANCE_URL}${utm('parallelization')}`;
17
25
  const NX_AGENTS_LINK = `${NX_AGENTS_URL}${utm('nx-agents')}`;
18
- const NX_REMOTE_CACHE_LINK = `${NX_REMOTE_CACHE_URL}${utm('remote-cache')}`;
26
+ const NX_REMOTE_CACHE_LINK = `${NX_CLOUD_GET_STARTED_URL}${utm('remote-cache')}`;
27
+ // Defaults to the get-started link; a disconnected workspace gets a short Nx
28
+ // Cloud onboarding URL instead (see prefetchRemoteCacheOnboardingUrl).
29
+ let remoteCacheLink = NX_REMOTE_CACHE_LINK;
30
+ // Give up on the short URL after this long so a slow/hung Cloud API never
31
+ // lingers past the exit report. Covers two sequential round trips (features
32
+ // GET, onboarding POST); the 30s CTA floor leaves room. Timing out also aborts
33
+ // the request - Promise.race alone would leave the socket holding the event
34
+ // loop open, which strands programmatic callers that never process.exit.
35
+ const ONBOARDING_URL_TIMEOUT = 5000;
36
+ /**
37
+ * Point the remote-cache CTA at a short Nx Cloud onboarding URL for a
38
+ * disconnected GitHub workspace - the VCS flow where Cloud opens the nx.json PR.
39
+ * Non-GitHub remotes keep the get-started link (handles every provider) and skip
40
+ * the network entirely. Runs in CI too - terminal + job summary.
41
+ *
42
+ * Best-effort: the get-started link stays on failure/timeout. Fired at run start;
43
+ * the CTA needs a >30s run (MIN_RECOMMENDATION_RUN_DURATION), so the fetch
44
+ * always resolves first.
45
+ */
46
+ async function prefetchRemoteCacheOnboardingUrl(nxJson) {
47
+ if ((0, nx_cloud_utils_1.isNxCloudDisabled)(nxJson) || (0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
48
+ return;
49
+ }
50
+ if ((0, git_utils_1.getVcsRemoteInfo)()?.domain !== 'github.com') {
51
+ return;
52
+ }
53
+ const abortController = new AbortController();
54
+ try {
55
+ const url = await Promise.race([
56
+ (0, url_shorten_1.createNxCloudOnboardingURL)('nx-cli-perf-report', undefined, undefined, false, false, undefined, abortController.signal),
57
+ new Promise((resolve) => {
58
+ // unref so the pending timer never keeps the CLI alive on its own.
59
+ setTimeout(() => {
60
+ abortController.abort();
61
+ resolve(null);
62
+ }, ONBOARDING_URL_TIMEOUT).unref();
63
+ }),
64
+ ]);
65
+ // createNxCloudOnboardingURL never throws - on an unreachable API it returns a
66
+ // paste-a-token URL (accessToken=undefined). Only accept a real short link.
67
+ if (url?.startsWith(`${(0, get_cloud_options_1.getCloudUrl)()}/connect/`)) {
68
+ remoteCacheLink = url;
69
+ }
70
+ else {
71
+ logger_1.logger.verbose(`Keeping the get-started remote-cache link (${url === null ? 'onboarding URL timed out' : `got: ${url}`})`);
72
+ }
73
+ }
74
+ catch (e) {
75
+ logger_1.logger.verbose(`Keeping the get-started remote-cache link: ${e}`);
76
+ }
77
+ }
19
78
  /**
20
79
  * Whole-phrase CTA: the whole sentence is the link. The Rust TUI popup keeps no
21
80
  * copy of this string; it gets the phrase + href from the exit payload's `links`.
@@ -176,7 +235,7 @@ const RECOMMENDATIONS = [
176
235
  c.cacheableCount > 0 &&
177
236
  !c.remoteCacheEnabled &&
178
237
  c.cacheHits / c.cacheableCount <= LOW_CACHE_HIT_RATE,
179
- build: () => [phraseLink(NX_REMOTE_CACHE_CTA, NX_REMOTE_CACHE_LINK), `.`],
238
+ build: () => [phraseLink(NX_REMOTE_CACHE_CTA, remoteCacheLink), `.`],
180
239
  },
181
240
  {
182
241
  // Cache skipped: drop the flag to restore unchanged tasks instantly.
@@ -16,14 +16,39 @@ export declare class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
16
16
  private readonly taskOverrides;
17
17
  failedTasks: Task[];
18
18
  cachedTasks: Task[];
19
+ stoppedTasks: Task[];
19
20
  allCompletedTasks: Map<string, Task>;
21
+ private collapsedTasks;
22
+ /** Stopped tasks that produced output; a batch-stopped task has none. */
23
+ private stoppedTasksWithOutput;
20
24
  constructor(projectNames: string[], tasks: Task[], args: {
21
25
  targets?: string[];
22
26
  configuration?: string;
27
+ verbose?: boolean;
28
+ outputStyle?: string;
23
29
  }, taskOverrides: any);
24
30
  startCommand(): void;
25
31
  endCommand(): void;
32
+ /**
33
+ * Tasks with a `skipped` status are never reported through `endTasks`, so
34
+ * they are derived by subtracting everything that did complete.
35
+ */
26
36
  private skippedTasks;
37
+ /**
38
+ * Whether this run prints every task's output in full rather than collapsing
39
+ * the ones that succeeded.
40
+ */
41
+ private get printsFullOutput();
42
+ /**
43
+ * Tells the reader that output was withheld, so a task that succeeded while
44
+ * printing something worth reading is not silently swallowed.
45
+ */
46
+ private hiddenOutputHint;
47
+ /**
48
+ * Tasks that never produced output worth printing are summarized as counts,
49
+ * with their names available behind --verbose.
50
+ */
51
+ private tasksNotRunSummary;
27
52
  endTasks(taskResults: TaskResult[]): void;
28
- printTaskTerminalOutput(task: Task, cacheStatus: TaskStatus, terminalOutput: string): void;
53
+ printTaskTerminalOutput(task: Task, taskStatus: TaskStatus, terminalOutput: string): void;
29
54
  }