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
@@ -79,11 +79,23 @@ class TaskOrchestrator {
79
79
  // underlying real tasks become the anchors.
80
80
  this.initializingTaskIds = (0, utils_1.expandInitiatingTasksThroughNoop)(this.initiatingTasks, this.taskGraph, this.projectGraph);
81
81
  this.processedTasks = new Map();
82
+ // Hashes confirmed absent from the cache this run. A confirmed miss can
83
+ // only become a hit when the task itself runs — and then it leaves the
84
+ // schedule — so a missed hash never needs re-querying. Without this, a
85
+ // miss waiting for a worker slot is re-queried (including the remote
86
+ // retrieval) on every coordinator cycle.
87
+ this.cacheMissedHashes = new Set();
82
88
  this.completedTasks = new Map();
83
89
  this.waitingForTasks = [];
84
90
  this.pendingDiscreteWorkers = new Set();
85
91
  this.groups = [];
86
92
  this.continuousTasksStarted = 0;
93
+ /**
94
+ * How many folds each batch id has rendered. A batch that reports a strict
95
+ * subset of its tasks is re-run under the same id, so one id can produce more
96
+ * than one fold and the redirect lines have to point at the right one.
97
+ */
98
+ this.batchFoldRenders = new Map();
87
99
  this.bailed = false;
88
100
  this.resolveStopPromise = null;
89
101
  this.stopRequested = false;
@@ -324,9 +336,12 @@ class TaskOrchestrator {
324
336
  * inside DbCache.getBatch.
325
337
  */
326
338
  async fetchCacheHits(tasks) {
327
- const batchResults = await this.cache.getBatch(tasks);
339
+ const tasksToQuery = tasks.filter((t) => t.hash && !this.cacheMissedHashes.has(t.hash));
340
+ if (tasksToQuery.length === 0)
341
+ return [];
342
+ const batchResults = await this.cache.getBatch(tasksToQuery);
328
343
  const cacheHits = [];
329
- for (const task of tasks) {
344
+ for (const task of tasksToQuery) {
330
345
  const cachedResult = batchResults.get(task.hash);
331
346
  // Replay a cached result only under the same condition it was cached
332
347
  // under (shouldCacheTaskResult): successes always, failures only when
@@ -335,6 +350,9 @@ class TaskOrchestrator {
335
350
  if (cachedResult && this.shouldCacheTaskResult(task, cachedResult.code)) {
336
351
  cacheHits.push({ task, cachedResult });
337
352
  }
353
+ else {
354
+ this.cacheMissedHashes.add(task.hash);
355
+ }
338
356
  }
339
357
  return cacheHits;
340
358
  }
@@ -396,14 +414,19 @@ class TaskOrchestrator {
396
414
  * The coordinator relies on this running unconditionally (when cache
397
415
  * is enabled): tasks dispatched in step 5 via runTaskDirectly skip
398
416
  * their own cache lookup on the assumption that this has already
399
- * confirmed them as misses. Don't add length-based bails.
417
+ * confirmed them as misses. Excluding cacheMissedHashes preserves that
418
+ * invariant — every dispatched hash was queried exactly once — but
419
+ * don't add other length-based bails.
400
420
  */
401
421
  async resolveCachedTasksBulk() {
402
422
  const { scheduledTasks } = this.tasksSchedule.getAllScheduledTasks();
403
423
  const candidates = [];
404
424
  for (const id of scheduledTasks) {
405
425
  const task = this.taskGraph.tasks[id];
406
- if (task.hash && !task.continuous && task.cache) {
426
+ if (task.hash &&
427
+ !this.cacheMissedHashes.has(task.hash) &&
428
+ !task.continuous &&
429
+ task.cache) {
407
430
  candidates.push(task);
408
431
  }
409
432
  }
@@ -559,8 +582,9 @@ class TaskOrchestrator {
559
582
  }
560
583
  async runBatch(batch, env, groupId) {
561
584
  const runBatchStart = perf_hooks_1.performance.mark('TaskOrchestrator-run-batch:start');
585
+ let batchProcess;
562
586
  try {
563
- const batchProcess = await this.forkedProcessTaskRunner.forkProcessForBatch(batch, this.projectGraph, this.fullTaskGraph, env);
587
+ batchProcess = await this.forkedProcessTaskRunner.forkProcessForBatch(batch, this.projectGraph, this.fullTaskGraph, env);
564
588
  // Stream output from batch process to the batch
565
589
  batchProcess.onOutput((output) => {
566
590
  this.options.lifeCycle.appendBatchOutput?.(batch.id, output);
@@ -578,7 +602,12 @@ class TaskOrchestrator {
578
602
  // Skipped tasks didn't run, so they have no terminal output and don't
579
603
  // need a per-task PTY — calling printTaskTerminalOutput would otherwise
580
604
  // allocate one just to write a cursor-hide escape.
581
- if (status !== 'skipped') {
605
+ //
606
+ // When the batch is being folded, printing is deferred to batch end
607
+ // (printGroupedBatchOutput), which always renders each task through the
608
+ // life cycle and adds the worker's whole log as a fold when the run
609
+ // asked for full output or any task failed or was stopped.
610
+ if (status !== 'skipped' && !(0, output_1.shouldGroupBatchOutput)()) {
582
611
  this.options.lifeCycle.printTaskTerminalOutput(task, status, result.terminalOutput ?? '');
583
612
  }
584
613
  task.startTime = result.startTime;
@@ -590,7 +619,7 @@ class TaskOrchestrator {
590
619
  });
591
620
  const results = await batchProcess.getResults();
592
621
  const batchResultEntries = Object.entries(results);
593
- return batchResultEntries.map(([taskId, result]) => {
622
+ const taskResults = batchResultEntries.map(([taskId, result]) => {
594
623
  const task = this.taskGraph.tasks[taskId];
595
624
  task.startTime = result.startTime;
596
625
  task.endTime = result.endTime;
@@ -602,10 +631,14 @@ class TaskOrchestrator {
602
631
  terminalOutput: result.terminalOutput,
603
632
  };
604
633
  });
634
+ if ((0, output_1.shouldGroupBatchOutput)()) {
635
+ this.renderBatchOutputSafely(batch.id, () => this.printGroupedBatchOutput(batch, taskResults, batchProcess.getCapturedOutputPath()));
636
+ }
637
+ return taskResults;
605
638
  }
606
639
  catch (e) {
607
640
  const isBatchStopping = this.stopRequested;
608
- return Object.keys(batch.taskGraph.tasks).map((taskId) => {
641
+ const taskResults = Object.keys(batch.taskGraph.tasks).map((taskId) => {
609
642
  const task = this.taskGraph.tasks[taskId];
610
643
  if (isBatchStopping) {
611
644
  task.endTime = Date.now();
@@ -617,12 +650,147 @@ class TaskOrchestrator {
617
650
  terminalOutput: isBatchStopping ? '' : (e.stack ?? e.message ?? ''),
618
651
  };
619
652
  });
653
+ // The worker died without reporting results, so nothing was attributed to
654
+ // a task and no per-task output ran. Everything it wrote went to
655
+ // stdout/stderr, held back under log grouping — surface it as one fold.
656
+ // Outside grouping it already streamed live. This matters just as much
657
+ // when the batch was stopped: every task is marked stopped whether or not
658
+ // it finished, so the log is the only record of what got through. Only
659
+ // the exit-code error is dropped there, since it restates the
660
+ // cancellation.
661
+ if ((0, output_1.shouldGroupBatchOutput)()) {
662
+ const capturedOutputPath = batchProcess?.getCapturedOutputPath();
663
+ const trailer = isBatchStopping ? undefined : e.message;
664
+ if (capturedOutputPath || trailer) {
665
+ this.renderBatchOutputSafely(batch.id, () => this.printBatchFold(batch, taskResults, {
666
+ capturedOutputPath,
667
+ trailer,
668
+ }));
669
+ }
670
+ }
671
+ return taskResults;
620
672
  }
621
673
  finally {
674
+ batchProcess?.discardCapturedOutput();
622
675
  const runBatchEnd = perf_hooks_1.performance.mark('TaskOrchestrator-run-batch:end');
623
676
  perf_hooks_1.performance.measure('TaskOrchestrator-run-batch', runBatchStart.name, runBatchEnd.name);
624
677
  }
625
678
  }
679
+ /**
680
+ * Rendering a batch's output must never change the batch's results. A throw
681
+ * from the printer would otherwise land in `runBatch`'s own error handling:
682
+ * on the resolved path it rewrites every task to `failure` with the printer's
683
+ * stack as its output — reporting a green build red to the life cycles and Nx
684
+ * Cloud — and on the crash path it escapes `runBatch`, replacing the built
685
+ * failure results with the printer's error. Both call sites degrade to a
686
+ * warning here instead.
687
+ */
688
+ renderBatchOutputSafely(batchId, render) {
689
+ try {
690
+ render();
691
+ }
692
+ catch (e) {
693
+ output_1.output.warn({
694
+ title: `Could not render output for batch ${batchId}`,
695
+ bodyLines: [e.message],
696
+ });
697
+ }
698
+ }
699
+ /**
700
+ * Prints a completed batch's output once, under log grouping. Live forwarding
701
+ * was suppressed while grouping, so this is the only copy — which is why the
702
+ * requested output style has to reach this path rather than stopping at the
703
+ * life cycle.
704
+ *
705
+ * Two things are rendered, and they answer different questions.
706
+ *
707
+ * Every task always renders through the life cycle, exactly as in a non-batch
708
+ * run - failures in full, successes collapsed to a line for run-many, plus the
709
+ * initiating project in full for run-one. That is what attributes output to a
710
+ * task, and it is the only place some of it exists: `@nx/jest` synthesizes
711
+ * each task's `terminalOutput` from an aggregated result and never writes
712
+ * those per-project summaries to the worker's stdio at all.
713
+ *
714
+ * The worker's whole captured log is rendered as a fold above them when the
715
+ * run asked for full output, or when any task failed or was stopped. A
716
+ * diagnostic that explains a failure is routinely one no task claimed:
717
+ * `@nx/maven`'s batch impl writes its exit-code dump and failed-task outputs
718
+ * to the worker's stderr via `console.error`, and the Maven JVM it spawns
719
+ * points slf4j at `System.out` because its own stderr carries the result
720
+ * protocol - two layers, two streams, both captured and neither attributed to
721
+ * a task - and `@nx/gradle` emits configuration-phase errors before the first
722
+ * `> Task :x:y` header tells it which task to attribute to. Both catch their
723
+ * own crash and backfill task results, so the batch resolves and lands here
724
+ * rather than in the caller's failure path.
725
+ *
726
+ * Rendering both duplicates some bytes, deliberately. `@nx/maven` and
727
+ * `@nx/gradle` tee each task's output into the worker's stdio on the way to
728
+ * `terminalOutput`, so a failing task's body appears in the fold and again in
729
+ * its own block. That is bounded on the default style, where successes
730
+ * collapse to a line each and a crashed batch backfills a short
731
+ * `e.toString()` rather than a body, so the case with the largest fold
732
+ * duplicates the least. Under a full-output style it is not bounded: every
733
+ * task prints in full beside a log that already contains it, which is the
734
+ * price of that style asking for everything. What it buys either way is
735
+ * attribution the fold cannot express. The
736
+ * alternative, letting the fold replace per-task rendering, silently dropped
737
+ * `@nx/jest`'s summaries and is what this shape exists to avoid.
738
+ *
739
+ * A batch that never reported results is handled by the caller instead.
740
+ */
741
+ printGroupedBatchOutput(batch, taskResults, capturedOutputPath) {
742
+ // Read from the same field the streaming decision uses. `this.options` has
743
+ // its own `outputStyle`, merged from `nx.json`'s tasksRunnerOptions, so the
744
+ // two disagree whenever a style is configured there but not named on the
745
+ // command line - and `init-tasks-runner` passes a populated `options` with
746
+ // no style argument at all, so on that path only `options` can carry one.
747
+ const printsFullOutput = (0, output_1.printsFullTaskOutput)({
748
+ verbose: this.options.verbose,
749
+ outputStyle: this.outputStyle,
750
+ });
751
+ const batchOwnsTheDiagnostic = taskResults.some((r) => r.status === 'failure' || r.status === 'stopped');
752
+ if ((printsFullOutput || batchOwnsTheDiagnostic) && capturedOutputPath) {
753
+ // No redirect lines: every task renders itself below, so there is nothing
754
+ // to redirect anyone to.
755
+ this.printBatchFold(batch, taskResults, { capturedOutputPath }, { redirectLines: false });
756
+ }
757
+ for (const { task, status, terminalOutput } of taskResults) {
758
+ if (status !== 'skipped') {
759
+ this.options.lifeCycle.printTaskTerminalOutput(task, status, terminalOutput ?? '');
760
+ }
761
+ }
762
+ }
763
+ /**
764
+ * Renders a batch's whole output as one fold, plus — unless `redirectLines`
765
+ * is off — a line per task pointing at it. The fold is labelled with the
766
+ * executor and a run-unique id (the same
767
+ * executor can run more than one batch), rather than an arbitrary task. Safe
768
+ * to write to `output` directly: grouping implies GitHub Actions implies a
769
+ * non-TTY, static lifecycle.
770
+ */
771
+ printBatchFold(batch, taskResults, body, { redirectLines = true } = {}) {
772
+ // batch.id is already `<executor> <n>`, numbered per executor when the batch
773
+ // was scheduled. Deriving a second number here would drift from it, since
774
+ // only batches that render a fold would be counted. The suffix disambiguates
775
+ // re-runs of the same batch rather than replacing the id, so it cannot.
776
+ const renders = (this.batchFoldRenders.get(batch.id) ?? 0) + 1;
777
+ this.batchFoldRenders.set(batch.id, renders);
778
+ const label = renders === 1 ? `batch ${batch.id}` : `batch ${batch.id}:${renders}`;
779
+ const worst = taskResults.some((r) => r.status === 'failure')
780
+ ? 'failure'
781
+ : taskResults.some((r) => r.status === 'stopped')
782
+ ? 'stopped'
783
+ : 'success';
784
+ output_1.output.logBatchGroup(label, body, worst);
785
+ if (!redirectLines) {
786
+ return;
787
+ }
788
+ for (const { task, status } of taskResults) {
789
+ if (status !== 'skipped') {
790
+ output_1.output.logCommandRedirect((0, utils_1.getPrintableCommandArgsForTask)(task).join(' '), status, `(output in "${label}" above)`);
791
+ }
792
+ }
793
+ }
626
794
  // endregion Batch
627
795
  // region Single Task
628
796
  /**
@@ -710,13 +878,11 @@ class TaskOrchestrator {
710
878
  await this.preRunSteps([task], { groupId });
711
879
  const pipeOutput = await this.pipeOutputCapture(task);
712
880
  const temporaryOutputPath = this.cache.temporaryOutputPath(task);
713
- const streamOutput = this.outputStyle === 'static'
881
+ const streamOutput = (0, output_1.isStaticOutputStyle)(this.outputStyle)
714
882
  ? false
715
883
  : (0, utils_1.shouldStreamOutput)(task, this.initiatingProject);
716
884
  const env = pipeOutput
717
- ? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, process.env.FORCE_COLOR === undefined
718
- ? 'true'
719
- : process.env.FORCE_COLOR, this.options.skipNxCache, this.options.captureStderr, null, null)
885
+ ? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, (0, task_env_1.getForceColorForChild)(), this.options.skipNxCache, this.options.captureStderr, null, null)
720
886
  : (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, undefined, this.options.skipNxCache, this.options.captureStderr, temporaryOutputPath, streamOutput);
721
887
  let resolveDiscreteExit;
722
888
  const discreteExitHandled = new Promise((r) => (resolveDiscreteExit = r));
@@ -790,7 +956,7 @@ class TaskOrchestrator {
790
956
  else if (this.tuiEnabled) {
791
957
  if (runningTask instanceof pseudo_terminal_1.PseudoTtyProcess) {
792
958
  // This is an external of a the pseudo terminal where a task is running and can be passed to the TUI
793
- this.options.lifeCycle.registerRunningTask(task.id, runningTask.getParserAndWriter());
959
+ this.options.lifeCycle.registerRunningTask(task.id, runningTask.getPtyHandles());
794
960
  runningTask.onOutput((output) => {
795
961
  this.options.lifeCycle.appendTaskOutput(task.id, output, true);
796
962
  });
@@ -839,7 +1005,7 @@ class TaskOrchestrator {
839
1005
  if (this.tuiEnabled) {
840
1006
  if (runningTask instanceof pseudo_terminal_1.PseudoTtyProcess) {
841
1007
  // This is an external of a the pseudo terminal where a task is running and can be passed to the TUI
842
- this.options.lifeCycle.registerRunningTask(task.id, runningTask.getParserAndWriter());
1008
+ this.options.lifeCycle.registerRunningTask(task.id, runningTask.getPtyHandles());
843
1009
  runningTask.onOutput((output) => {
844
1010
  this.options.lifeCycle.appendTaskOutput(task.id, output, true);
845
1011
  });
@@ -923,13 +1089,11 @@ class TaskOrchestrator {
923
1089
  const pipeOutput = await this.pipeOutputCapture(task);
924
1090
  // obtain metadata
925
1091
  const temporaryOutputPath = this.cache.temporaryOutputPath(task);
926
- const streamOutput = this.outputStyle === 'static'
1092
+ const streamOutput = (0, output_1.isStaticOutputStyle)(this.outputStyle)
927
1093
  ? false
928
1094
  : (0, utils_1.shouldStreamOutput)(task, this.initiatingProject);
929
1095
  let env = pipeOutput
930
- ? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, process.env.FORCE_COLOR === undefined
931
- ? 'true'
932
- : process.env.FORCE_COLOR, this.options.skipNxCache, this.options.captureStderr, null, null)
1096
+ ? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, (0, task_env_1.getForceColorForChild)(), this.options.skipNxCache, this.options.captureStderr, null, null)
933
1097
  : (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, undefined, this.options.skipNxCache, this.options.captureStderr, temporaryOutputPath, streamOutput);
934
1098
  this.detectTaskInvocationLoop(task);
935
1099
  const childProcess = await this.runTask(task, streamOutput, env, temporaryOutputPath, pipeOutput);
@@ -36,6 +36,7 @@ const fileutils_1 = require("../utils/fileutils");
36
36
  const find_matching_projects_1 = require("../utils/find-matching-projects");
37
37
  const legacy_depends_on_warning_1 = require("./legacy-depends-on-warning");
38
38
  const globs_1 = require("../utils/globs");
39
+ const long_running_target_1 = require("../utils/long-running-target");
39
40
  const path_1 = require("../utils/path");
40
41
  const serialize_overrides_into_command_line_1 = require("../utils/serialize-overrides-into-command-line");
41
42
  const split_target_1 = require("../utils/split-target");
@@ -429,14 +430,9 @@ function isCacheableTask(task) {
429
430
  return task.cache;
430
431
  }
431
432
  function longRunningTask(task) {
432
- const t = task.target.target;
433
433
  return (task.continuous ||
434
434
  (!!task.overrides['watch'] && task.overrides['watch'] !== 'false') ||
435
- t.endsWith(':watch') ||
436
- t.endsWith('-watch') ||
437
- t === 'serve' ||
438
- t === 'dev' ||
439
- t === 'start');
435
+ (0, long_running_target_1.isLongRunningTargetName)(task.target.target));
440
436
  }
441
437
  // TODO: vsavkin remove when nx-cloud doesn't depend on it
442
438
  function unparse(options) {
@@ -7,6 +7,7 @@ const yaml_1 = require("yaml");
7
7
  const semver_1 = require("semver");
8
8
  const package_manager_1 = require("./package-manager");
9
9
  const fileutils_1 = require("./fileutils");
10
+ const json_1 = require("./json");
10
11
  const PNPM_WORKSPACE_FILE = 'pnpm-workspace.yaml';
11
12
  /**
12
13
  * Records build-script decisions for dependencies that are about to be
@@ -42,23 +43,24 @@ function acknowledgePnpmBuildScripts(treeOrRoot, entries) {
42
43
  // A file that doesn't parse cleanly or whose root isn't a mapping is
43
44
  // malformed for pnpm; leave it alone rather than crashing or replacing the
44
45
  // user's content. pnpm's own error on the file is the actionable signal.
46
+ // Empty and comment-only files have no contents at all; setIn creates the
47
+ // mapping for them while keeping whatever comments they carry.
45
48
  if (parsed.errors.length > 0 ||
46
49
  (parsed.contents != null && !(parsed.contents instanceof yaml_1.YAMLMap))) {
47
50
  return;
48
51
  }
49
- const doc = parsed.contents instanceof yaml_1.YAMLMap ? parsed : new yaml_1.Document({});
50
52
  let changed = false;
51
53
  for (const [pkg, allowed] of Object.entries(entries)) {
52
54
  // Only a real boolean is a user decision. pnpm's non-strict installs stub
53
55
  // undecided packages with a placeholder string ("set this to true or
54
56
  // false"), which would fail the next strict install if left in place.
55
- if (typeof doc.getIn(['allowBuilds', pkg]) !== 'boolean') {
56
- doc.setIn(['allowBuilds', pkg], allowed);
57
+ if (typeof parsed.getIn(['allowBuilds', pkg]) !== 'boolean') {
58
+ parsed.setIn(['allowBuilds', pkg], allowed);
57
59
  changed = true;
58
60
  }
59
61
  }
60
62
  if (changed) {
61
- host.write(PNPM_WORKSPACE_FILE, doc.toString());
63
+ host.write(PNPM_WORKSPACE_FILE, parsed.toString());
62
64
  }
63
65
  }
64
66
  function createHost(treeOrRoot) {
@@ -76,7 +78,7 @@ function createHost(treeOrRoot) {
76
78
  exists: (p) => treeOrRoot.exists(p),
77
79
  read: (p) => treeOrRoot.read(p, 'utf-8'),
78
80
  write: (p, c) => treeOrRoot.write(p, c),
79
- readJson: (p) => JSON.parse(treeOrRoot.read(p, 'utf-8')),
81
+ readJson: (p) => (0, json_1.parseJson)(treeOrRoot.read(p, 'utf-8')),
80
82
  };
81
83
  }
82
84
  function getPnpmVersion(host) {
@@ -0,0 +1,7 @@
1
+ import type { NxJsonConfiguration } from '../config/nx-json';
2
+ /**
3
+ * Analytics are opt-in: both `"analytics": false` and an unset flag mean no
4
+ * event is ever sent. Anything enabled for the sake of analytics (network
5
+ * allowlists, endpoints) gates on this, not on an explicit opt-out alone.
6
+ */
7
+ export declare function isAnalyticsEnabled(nxJson: NxJsonConfiguration | null): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAnalyticsEnabled = isAnalyticsEnabled;
4
+ /**
5
+ * Analytics are opt-in: both `"analytics": false` and an unset flag mean no
6
+ * event is ever sent. Anything enabled for the sake of analytics (network
7
+ * allowlists, endpoints) gates on this, not on an explicit opt-out alone.
8
+ */
9
+ function isAnalyticsEnabled(nxJson) {
10
+ return nxJson?.analytics === true;
11
+ }
@@ -7,9 +7,3 @@
7
7
  */
8
8
  export declare function ensureAnalyticsPreferenceSet(root?: string, interactive?: boolean): Promise<'yes' | 'no' | 'unset'>;
9
9
  export declare function promptForAnalyticsPreference(): Promise<boolean>;
10
- /**
11
- * Generates a deterministic workspace ID.
12
- * Priority: nxCloudId > git remote URL (hashed).
13
- * Returns null if neither is available (no telemetry).
14
- */
15
- export declare function generateWorkspaceId(cwd?: string): string | null;
@@ -2,11 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureAnalyticsPreferenceSet = ensureAnalyticsPreferenceSet;
4
4
  exports.promptForAnalyticsPreference = promptForAnalyticsPreference;
5
- exports.generateWorkspaceId = generateWorkspaceId;
6
- const crypto_1 = require("crypto");
7
- const child_process_1 = require("child_process");
8
5
  const fs_1 = require("fs");
9
- const enquirer_1 = require("enquirer");
6
+ const prompt_helpers_1 = require("./prompt-helpers");
10
7
  const path_1 = require("path");
11
8
  const output_1 = require("./output");
12
9
  const is_ci_1 = require("./is-ci");
@@ -50,16 +47,13 @@ async function promptForAnalyticsPreference() {
50
47
  'Learn more: https://cloud.nx.app/privacy',
51
48
  ],
52
49
  });
53
- const { enableAnalytics } = await (0, enquirer_1.prompt)({
54
- type: 'confirm',
55
- name: 'enableAnalytics',
50
+ return await (0, prompt_helpers_1.confirmationPrompt)({
56
51
  message: 'Share usage data with the Nx team?',
57
- initial: true,
52
+ // Cancelling is a decline, not a failure.
53
+ onCancel: () => false,
58
54
  });
59
- return enableAnalytics;
60
55
  }
61
56
  catch {
62
- // User cancelled - default to false
63
57
  return false;
64
58
  }
65
59
  }
@@ -85,51 +79,3 @@ async function saveAnalyticsPreference(root, enabled) {
85
79
  // Silently fail - don't block user's command
86
80
  }
87
81
  }
88
- /**
89
- * Generates a deterministic workspace ID.
90
- * Priority: nxCloudId > git remote URL (hashed).
91
- * Returns null if neither is available (no telemetry).
92
- */
93
- function generateWorkspaceId(cwd) {
94
- const root = cwd ?? workspace_root_1.workspaceRoot;
95
- // Use nxCloudId if available — most stable identifier
96
- const nxJson = (0, nx_json_1.readNxJson)(root);
97
- const nxCloudId = nxJson?.nxCloudId ?? nxJson?.nxCloudAccessToken;
98
- if (nxCloudId) {
99
- return nxCloudId;
100
- }
101
- // Fall back to git remote URL hash
102
- try {
103
- const remoteUrl = (0, child_process_1.execSync)('git remote get-url origin', {
104
- stdio: 'pipe',
105
- cwd: root,
106
- windowsHide: true,
107
- })
108
- .toString()
109
- .trim();
110
- if (remoteUrl) {
111
- return (0, crypto_1.createHash)('sha256').update(remoteUrl).digest('hex').slice(0, 32);
112
- }
113
- }
114
- catch {
115
- // No git remote available
116
- }
117
- // Fall back to first commit SHA — already a hash
118
- try {
119
- const firstCommit = (0, child_process_1.execSync)('git rev-list --max-parents=0 HEAD', {
120
- stdio: 'pipe',
121
- cwd: root,
122
- windowsHide: true,
123
- })
124
- .toString()
125
- .trim()
126
- .split('\n')[0];
127
- if (firstCommit) {
128
- return firstCommit;
129
- }
130
- }
131
- catch {
132
- // Not a git repo
133
- }
134
- return null;
135
- }
@@ -3,7 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertWorkspaceValidity = assertWorkspaceValidity;
4
4
  const find_matching_projects_1 = require("./find-matching-projects");
5
5
  const output_1 = require("./output");
6
- const devkit_internals_1 = require("../devkit-internals");
6
+ // Import from the defining module, not the devkit-internals barrel: this file
7
+ // is on the project-graph construction path, and the barrel now eagerly
8
+ // re-exports the project-graph modules, which would create a require cycle back
9
+ // through build-project-graph. (Release modules cross the barrel as erased
10
+ // types only — see the note in packages/devkit/internal.ts.)
11
+ const error_types_1 = require("../project-graph/error-types");
7
12
  function assertWorkspaceValidity(projects, nxJson) {
8
13
  const projectNames = Object.keys(projects);
9
14
  const projectGraphNodes = projectNames.reduce((graph, project) => {
@@ -65,7 +70,7 @@ function assertWorkspaceValidity(projects, nxJson) {
65
70
  })
66
71
  .join('\n\n');
67
72
  }
68
- throw new devkit_internals_1.WorkspaceValidityError(message);
73
+ throw new error_types_1.WorkspaceValidityError(message);
69
74
  }
70
75
  function detectAndSetInvalidProjectGlobValues(map, sourceName, desiredImplicitDeps, projectConfigurations, projects) {
71
76
  const invalidProjectsOrGlobs = desiredImplicitDeps.filter((implicit) => {
@@ -0,0 +1,8 @@
1
+ import type { Tree } from '../../generators/tree';
2
+ import type { CatalogDefinitions } from './types';
3
+ export declare function readBunCatalogDefinitions(filename: string, treeOrRoot: Tree | string, cache: Map<string, CatalogDefinitions | null>): CatalogDefinitions | null;
4
+ export declare function updateBunCatalogVersionsInFile(filename: string, treeOrRoot: Tree | string, updates: Array<{
5
+ packageName: string;
6
+ version: string;
7
+ catalogName?: string;
8
+ }>): void;