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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/bin/nx.js +3 -1
  3. package/dist/release/changelog-renderer/index.js +4 -5
  4. package/dist/release/index.d.ts +1 -1
  5. package/dist/src/adapter/ngcli-adapter.js +60 -1
  6. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
  7. package/dist/src/analytics/analytics.d.ts +6 -0
  8. package/dist/src/analytics/analytics.js +16 -10
  9. package/dist/src/analytics/index.d.ts +1 -1
  10. package/dist/src/analytics/index.js +2 -1
  11. package/dist/src/command-line/add/add.js +5 -0
  12. package/dist/src/command-line/affected/affected.js +1 -0
  13. package/dist/src/command-line/completion/command-object.js +7 -12
  14. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
  15. package/dist/src/command-line/format/format.js +84 -101
  16. package/dist/src/command-line/generate/generate.js +35 -35
  17. package/dist/src/command-line/graph/graph.d.ts +1 -0
  18. package/dist/src/command-line/graph/graph.js +15 -6
  19. package/dist/src/command-line/import/import.js +30 -40
  20. package/dist/src/command-line/init/ai-agent-prompts.d.ts +1 -1
  21. package/dist/src/command-line/init/ai-agent-prompts.js +12 -17
  22. package/dist/src/command-line/init/command-object.js +14 -4
  23. package/dist/src/command-line/init/configure-plugins.js +4 -1
  24. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  25. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  26. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  27. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  28. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  29. package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
  30. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -0
  31. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  32. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  33. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +9 -1
  34. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  35. package/dist/src/command-line/init/implementation/format.js +114 -0
  36. package/dist/src/command-line/init/implementation/utils.js +8 -0
  37. package/dist/src/command-line/init/init-v1.js +15 -18
  38. package/dist/src/command-line/init/init-v2.js +40 -57
  39. package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
  40. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
  41. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
  42. package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
  43. package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
  44. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
  45. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
  46. package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
  47. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  48. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  49. package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
  50. package/dist/src/command-line/migrate/agentic/select.js +30 -32
  51. package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
  52. package/dist/src/command-line/migrate/agentic/types.js +35 -0
  53. package/dist/src/command-line/migrate/command-object.d.ts +6 -0
  54. package/dist/src/command-line/migrate/command-object.js +19 -1
  55. package/dist/src/command-line/migrate/execute-migration.d.ts +91 -0
  56. package/dist/src/command-line/migrate/execute-migration.js +474 -0
  57. package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
  58. package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
  59. package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
  60. package/dist/src/command-line/migrate/migrate-commits.js +130 -15
  61. package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
  62. package/dist/src/command-line/migrate/migrate-config.js +22 -14
  63. package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
  64. package/dist/src/command-line/migrate/migrate-output.js +52 -8
  65. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  66. package/dist/src/command-line/migrate/migrate-ui-api.js +33 -19
  67. package/dist/src/command-line/migrate/migrate.d.ts +29 -113
  68. package/dist/src/command-line/migrate/migrate.js +666 -664
  69. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  70. package/dist/src/command-line/migrate/multi-major.js +7 -10
  71. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  72. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  73. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  74. package/dist/src/command-line/migrate/run/index.d.ts +9 -0
  75. package/dist/src/command-line/migrate/run/index.js +23 -0
  76. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  77. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  78. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  79. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  80. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  81. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  82. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  83. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  84. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  85. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  86. package/dist/src/command-line/migrate/run/util.d.ts +59 -0
  87. package/dist/src/command-line/migrate/run/util.js +148 -0
  88. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  89. package/dist/src/command-line/migrate/run/worker.js +682 -0
  90. package/dist/src/command-line/migrate/run-migration-process.js +6 -5
  91. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  92. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  93. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  94. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  95. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  96. package/dist/src/command-line/migrate/step-actions.js +12 -0
  97. package/dist/src/command-line/migrate/text.d.ts +18 -0
  98. package/dist/src/command-line/migrate/text.js +26 -0
  99. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  100. package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
  101. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -21
  102. package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
  103. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  104. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  105. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  106. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  107. package/dist/src/command-line/nx-commands.js +26 -24
  108. package/dist/src/command-line/release/changelog.js +11 -17
  109. package/dist/src/command-line/release/index.d.ts +1 -1
  110. package/dist/src/command-line/release/plan.js +15 -28
  111. package/dist/src/command-line/release/publish.js +5 -0
  112. package/dist/src/command-line/release/release.js +6 -17
  113. package/dist/src/command-line/release/utils/git.js +1 -1
  114. package/dist/src/command-line/release/utils/release-graph.d.ts +20 -2
  115. package/dist/src/command-line/release/utils/release-graph.js +81 -21
  116. package/dist/src/command-line/release/utils/remote-release-clients/github.js +17 -23
  117. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +14 -23
  118. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  119. package/dist/src/command-line/release/utils/shared.d.ts +2 -2
  120. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  121. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  122. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  123. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  124. package/dist/src/command-line/release/version/version-actions.js +9 -1
  125. package/dist/src/command-line/release/version.js +10 -6
  126. package/dist/src/command-line/reset/reset.js +6 -1
  127. package/dist/src/command-line/run/run-one.js +1 -0
  128. package/dist/src/command-line/run-many/run-many.js +1 -0
  129. package/dist/src/command-line/show/show-target/inputs.js +50 -153
  130. package/dist/src/command-line/show/show-target/outputs.js +48 -173
  131. package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
  132. package/dist/src/command-line/show/show-target/utils.js +83 -3
  133. package/dist/src/command-line/watch/watch.js +13 -0
  134. package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
  135. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  136. package/dist/src/commands-runner/create-command-graph.js +5 -0
  137. package/dist/src/config/misc-interfaces.d.ts +19 -7
  138. package/dist/src/config/nx-json.d.ts +5 -3
  139. package/dist/src/core/graph/main.js +1 -1
  140. package/dist/src/core/graph/styles.js +1 -1
  141. package/dist/src/daemon/client/client.d.ts +52 -1
  142. package/dist/src/daemon/client/client.js +160 -36
  143. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  144. package/dist/src/daemon/client/daemon-environment.js +110 -2
  145. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  146. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  147. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  148. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  149. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  150. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
  151. package/dist/src/daemon/server/latest-nx.js +5 -2
  152. package/dist/src/daemon/server/server.js +31 -4
  153. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  154. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  155. package/dist/src/daemon/socket-utils.d.ts +1 -0
  156. package/dist/src/daemon/socket-utils.js +24 -3
  157. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  158. package/dist/src/daemon/tmp-dir.js +437 -15
  159. package/dist/src/devkit-internals.d.ts +105 -8
  160. package/dist/src/devkit-internals.js +223 -7
  161. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  162. package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
  163. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  164. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  165. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  166. package/dist/src/generators/tree.d.ts +4 -2
  167. package/dist/src/generators/utils/nx-json.js +13 -3
  168. package/dist/src/hasher/check-task-files.d.ts +86 -0
  169. package/dist/src/hasher/check-task-files.js +378 -0
  170. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  171. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  172. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  173. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  174. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  175. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  176. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  177. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  178. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  179. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  180. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  181. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  182. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  183. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  184. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  185. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  186. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  187. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  188. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  189. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  190. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  191. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  192. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  193. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  194. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  195. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  196. package/dist/src/native/index.d.ts +37 -4
  197. package/dist/src/native/index.js +71 -28
  198. package/dist/src/native/native-bindings.js +3 -0
  199. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  200. package/dist/src/native/native-file-cache-location.js +86 -12
  201. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  202. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  203. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  204. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  205. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  206. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  207. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  208. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  209. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  210. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  211. package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
  212. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  213. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
  214. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  215. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  216. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  217. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
  218. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  219. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
  220. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  221. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  222. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  223. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  224. package/dist/src/project-graph/build-project-graph.js +7 -1
  225. package/dist/src/project-graph/error-types.d.ts +12 -1
  226. package/dist/src/project-graph/error-types.js +27 -2
  227. package/dist/src/project-graph/file-utils.js +6 -1
  228. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  229. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
  230. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  231. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  232. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  233. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
  234. package/dist/src/project-graph/project-graph.js +23 -0
  235. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
  236. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
  237. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
  238. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
  239. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
  240. package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
  241. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
  242. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
  243. package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
  244. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
  245. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
  246. package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
  247. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
  248. package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
  249. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  250. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  251. package/dist/src/tasks-runner/life-cycle.js +2 -2
  252. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +9 -4
  253. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
  254. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +28 -8
  255. package/dist/src/tasks-runner/life-cycles/performance-report.js +117 -30
  256. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  257. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  258. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  259. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  260. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  261. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  262. package/dist/src/tasks-runner/run-command.js +28 -35
  263. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  264. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  265. package/dist/src/tasks-runner/task-env.d.ts +9 -0
  266. package/dist/src/tasks-runner/task-env.js +31 -4
  267. package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
  268. package/dist/src/tasks-runner/task-orchestrator.js +182 -18
  269. package/dist/src/tasks-runner/utils.js +2 -6
  270. package/dist/src/utils/acknowledge-build-scripts.js +7 -5
  271. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  272. package/dist/src/utils/analytics-enabled.js +11 -0
  273. package/dist/src/utils/analytics-prompt.d.ts +0 -6
  274. package/dist/src/utils/analytics-prompt.js +4 -58
  275. package/dist/src/utils/assert-workspace-validity.js +7 -2
  276. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  277. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  278. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  279. package/dist/src/utils/catalog/bun-manager.js +130 -0
  280. package/dist/src/utils/catalog/index.d.ts +1 -1
  281. package/dist/src/utils/catalog/index.js +1 -1
  282. package/dist/src/utils/catalog/manager-factory.js +3 -0
  283. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  284. package/dist/src/utils/catalog/manager-utils.js +9 -4
  285. package/dist/src/utils/catalog/manager.d.ts +13 -1
  286. package/dist/src/utils/catalog/manager.js +30 -0
  287. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  288. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  289. package/dist/src/utils/catalog/types.d.ts +4 -0
  290. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  291. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  292. package/dist/src/utils/child-process.d.ts +31 -1
  293. package/dist/src/utils/child-process.js +103 -0
  294. package/dist/src/utils/chunkify.d.ts +7 -1
  295. package/dist/src/utils/chunkify.js +10 -3
  296. package/dist/src/utils/command-line-utils.js +30 -20
  297. package/dist/src/utils/exit-codes.d.ts +9 -0
  298. package/dist/src/utils/exit-codes.js +19 -0
  299. package/dist/src/utils/fileutils.d.ts +5 -0
  300. package/dist/src/utils/fileutils.js +7 -2
  301. package/dist/src/utils/formatters/index.d.ts +13 -0
  302. package/dist/src/utils/formatters/index.js +74 -0
  303. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  304. package/dist/src/utils/formatters/oxfmt.js +764 -0
  305. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  306. package/dist/src/utils/formatters/prettier.js +201 -0
  307. package/dist/src/utils/formatters/shared.d.ts +5 -0
  308. package/dist/src/utils/formatters/shared.js +8 -0
  309. package/dist/src/utils/git-revision.d.ts +12 -0
  310. package/dist/src/utils/git-revision.js +25 -0
  311. package/dist/src/utils/git-utils.d.ts +48 -2
  312. package/dist/src/utils/git-utils.js +220 -14
  313. package/dist/src/utils/git-worktrees.d.ts +30 -0
  314. package/dist/src/utils/git-worktrees.js +212 -0
  315. package/dist/src/utils/ignore.d.ts +170 -1
  316. package/dist/src/utils/ignore.js +263 -11
  317. package/dist/src/utils/long-running-target.d.ts +10 -0
  318. package/dist/src/utils/long-running-target.js +19 -0
  319. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  320. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  321. package/dist/src/utils/min-release-age/packument.js +1 -1
  322. package/dist/src/utils/nx-console-prompt.js +3 -6
  323. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  324. package/dist/src/utils/nx-tmp-dir.js +40 -0
  325. package/dist/src/utils/output.d.ts +153 -0
  326. package/dist/src/utils/output.js +289 -5
  327. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  328. package/dist/src/utils/owned-private-dir.js +323 -0
  329. package/dist/src/utils/package-json.d.ts +2 -0
  330. package/dist/src/utils/package-json.js +11 -7
  331. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  332. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  333. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  334. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  335. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  336. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  337. package/dist/src/utils/package-manager.d.ts +23 -2
  338. package/dist/src/utils/package-manager.js +268 -44
  339. package/dist/src/utils/params.d.ts +7 -1
  340. package/dist/src/utils/params.js +64 -6
  341. package/dist/src/utils/plugins/core-plugins.js +4 -0
  342. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  343. package/dist/src/utils/prompt-helpers.js +111 -0
  344. package/dist/src/utils/provenance.js +6 -14
  345. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  346. package/dist/src/utils/registry-config/bun.js +257 -0
  347. package/dist/src/utils/registry-config/index.d.ts +13 -0
  348. package/dist/src/utils/registry-config/index.js +102 -0
  349. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  350. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  351. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  352. package/dist/src/utils/registry-config/utils.js +496 -0
  353. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  354. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  355. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  356. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  357. package/dist/src/utils/safe-spawn.d.ts +24 -0
  358. package/dist/src/utils/safe-spawn.js +104 -0
  359. package/dist/src/utils/shell-quoting.d.ts +15 -0
  360. package/dist/src/utils/shell-quoting.js +35 -0
  361. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  362. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  363. package/dist/src/utils/workspace-id.d.ts +20 -0
  364. package/dist/src/utils/workspace-id.js +54 -0
  365. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  366. package/dist/src/utils/write-formatted-json-file.js +5 -4
  367. package/migrations.json +6 -0
  368. package/package.json +29 -19
  369. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
  370. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
  371. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  372. package/dist/src/utils/is-using-prettier.js +0 -62
  373. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  374. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -1,15 +1,11 @@
1
1
  const { join, basename } = require('path');
2
- const {
3
- copyFileSync,
4
- existsSync,
5
- mkdirSync,
6
- renameSync,
7
- statSync,
8
- unlinkSync,
9
- } = require('fs');
2
+ const { copyFileSync, renameSync, statSync, unlinkSync } = require('fs');
3
+ const { createHash } = require('crypto');
10
4
  const Module = require('module');
11
5
  const { nxVersion } = require('../utils/versions');
12
- const { getNativeFileCacheLocation } = require('./native-file-cache-location');
6
+ const {
7
+ ensureSecureNativeFileCacheLocation,
8
+ } = require('./native-file-cache-location');
13
9
 
14
10
  const MAX_COPY_RETRIES = 3;
15
11
 
@@ -73,6 +69,14 @@ function statsOrNull(path) {
73
69
  }
74
70
  }
75
71
 
72
+ function removeIfPresent(path) {
73
+ try {
74
+ unlinkSync(path);
75
+ } catch {
76
+ // Ignore cleanup errors
77
+ }
78
+ }
79
+
76
80
  function isNoExecError(e) {
77
81
  return e.code === 'EACCES' || e.code === 'EPERM';
78
82
  }
@@ -95,20 +99,44 @@ Module._load = function (request, parent, isMain) {
95
99
  const nativeLocation = require.resolve(modulePath);
96
100
  const fileName = basename(nativeLocation);
97
101
 
98
- // we copy the file to a workspace-scoped tmp directory and prefix with nxVersion to avoid stale files being loaded
99
- const nativeFileCacheLocation = getNativeFileCacheLocation();
102
+ // null when the cache dir cannot be created *and trusted*; loading in place
103
+ // from node_modules is safer than loading out of a directory we don't own.
104
+ const nativeFileCacheLocation = ensureSecureNativeFileCacheLocation();
105
+ if (!nativeFileCacheLocation) {
106
+ return originalLoad.apply(this, [nativeLocation, parent, isMain]);
107
+ }
108
+
109
+ // nxVersion alone is not enough: in a source checkout it is the placeholder
110
+ // 0.0.1 for every worktree, so hashing the resolved binding path keeps each
111
+ // checkout in its own entry.
112
+ const cacheKey =
113
+ nxVersion +
114
+ '-' +
115
+ createHash('sha256')
116
+ .update(nativeLocation)
117
+ .digest('hex')
118
+ .substring(0, 12);
119
+
100
120
  // This is a path to copy to, not the one that gets loaded
101
121
  const tmpTmpFile = join(
102
122
  nativeFileCacheLocation,
103
- nxVersion + '-' + Math.random() + fileName
123
+ cacheKey + '-' + Math.random() + fileName
104
124
  );
105
125
  // This is the path that will get loaded
106
- const tmpFile = join(nativeFileCacheLocation, nxVersion + '-' + fileName);
107
- const expectedFileSize = statSync(nativeLocation).size;
126
+ const tmpFile = join(nativeFileCacheLocation, cacheKey + '-' + fileName);
127
+ const sourceStats = statSync(nativeLocation);
128
+ const expectedFileSize = sourceStats.size;
108
129
  const existingFileStats = statsOrNull(tmpFile);
109
130
 
110
- // If the file to be loaded already exists, just load it
111
- if (existingFileStats?.size === expectedFileSize) {
131
+ // Size alone does not detect a rebuilt binding: a small Rust edit routinely
132
+ // produces a byte-identical size. The copy is taken after the build, so a
133
+ // cache entry older than the source means the source was rebuilt since.
134
+ const isFresh =
135
+ existingFileStats?.size === expectedFileSize &&
136
+ existingFileStats.mtimeMs >= sourceStats.mtimeMs;
137
+
138
+ // If the file to be loaded already exists and is current, just load it
139
+ if (isFresh) {
112
140
  try {
113
141
  return originalLoad.apply(this, [tmpFile, parent, isMain]);
114
142
  } catch (e) {
@@ -119,20 +147,36 @@ Module._load = function (request, parent, isMain) {
119
147
  throw e;
120
148
  }
121
149
  }
122
- if (!existsSync(nativeFileCacheLocation)) {
123
- mkdirSync(nativeFileCacheLocation, { recursive: true });
124
- }
125
150
 
126
151
  // Retry copying up to 3 times, validating after each copy
152
+ let attemptsMade = 0;
153
+ let cacheError = null;
127
154
  for (let attempt = 1; attempt <= MAX_COPY_RETRIES; attempt++) {
155
+ attemptsMade = attempt;
128
156
  // First copy to a unique location for each process
129
- copyFileSync(nativeLocation, tmpTmpFile);
157
+ try {
158
+ copyFileSync(nativeLocation, tmpTmpFile);
159
+ } catch (e) {
160
+ // Permission errors won't heal on retry, and a throwing copy can still
161
+ // have left a partial file behind.
162
+ cacheError = e;
163
+ removeIfPresent(tmpTmpFile);
164
+ break;
165
+ }
130
166
 
131
167
  // Validate the copy - check file size matches expected
132
168
  const copiedFileStats = statsOrNull(tmpTmpFile);
133
169
  if (copiedFileStats?.size === expectedFileSize) {
134
170
  // Copy succeeded, rename to final location and load
135
- renameSync(tmpTmpFile, tmpFile);
171
+ try {
172
+ renameSync(tmpTmpFile, tmpFile);
173
+ } catch (e) {
174
+ // Unguarded, this throws out of `require` and native-bindings.js
175
+ // reports it as a missing optional dependency, which it is not.
176
+ cacheError = e;
177
+ removeIfPresent(tmpTmpFile);
178
+ break;
179
+ }
136
180
  try {
137
181
  return originalLoad.apply(this, [tmpFile, parent, isMain]);
138
182
  } catch (e) {
@@ -145,16 +189,15 @@ Module._load = function (request, parent, isMain) {
145
189
  }
146
190
 
147
191
  // Copy failed validation, clean up the malformed file
148
- try {
149
- unlinkSync(tmpTmpFile);
150
- } catch {
151
- // Ignore cleanup errors
152
- }
192
+ removeIfPresent(tmpTmpFile);
153
193
  }
154
194
 
155
- // All retries failed - warn and load from original location
195
+ // Name the errno: ENOSPC, EROFS, EACCES and EDQUOT are all actionable and
196
+ // otherwise indistinguishable.
156
197
  console.warn(
157
- `Warning: Failed to copy native module to cache after ${MAX_COPY_RETRIES} attempts. ` +
198
+ `Warning: Failed to copy native module to cache after ${attemptsMade} attempt${
199
+ attemptsMade === 1 ? '' : 's'
200
+ }${cacheError ? ` (${cacheError.code ?? cacheError.message})` : ''}. ` +
158
201
  `Loading from original location instead. ` +
159
202
  `This may cause file locking issues on Windows.`
160
203
  );
@@ -610,6 +610,7 @@ module.exports.getBinaryTarget = nativeBinding.getBinaryTarget
610
610
  module.exports.getDefaultMaxCacheSize = nativeBinding.getDefaultMaxCacheSize
611
611
  module.exports.getEventDimensions = nativeBinding.getEventDimensions
612
612
  module.exports.getFilesForOutputsBatch = nativeBinding.getFilesForOutputsBatch
613
+ module.exports.getHardcodedIgnorePatterns = nativeBinding.getHardcodedIgnorePatterns
613
614
  module.exports.getMainWorktreeRoot = nativeBinding.getMainWorktreeRoot
614
615
  module.exports.getTransformableOutputs = nativeBinding.getTransformableOutputs
615
616
  module.exports.GroupType = nativeBinding.GroupType
@@ -625,6 +626,8 @@ module.exports.isEditorInstalled = nativeBinding.isEditorInstalled
625
626
  module.exports.killProcessTree = nativeBinding.killProcessTree
626
627
  module.exports.killProcessTreeGraceful = nativeBinding.killProcessTreeGraceful
627
628
  module.exports.logDebug = nativeBinding.logDebug
629
+ module.exports.matchGlobPaths = nativeBinding.matchGlobPaths
630
+ module.exports.matchOutputPaths = nativeBinding.matchOutputPaths
628
631
  module.exports.parseTaskStatus = nativeBinding.parseTaskStatus
629
632
  module.exports.remove = nativeBinding.remove
630
633
  module.exports.restoreTerminal = nativeBinding.restoreTerminal
@@ -1 +1,17 @@
1
- export declare function getNativeFileCacheLocation(): string;
1
+ /**
2
+ * Path of the current user's native binary cache. Nothing about the constant is
3
+ * owner-only — `ensureSecureNativeFileCacheLocation` is what establishes that,
4
+ * and on Windows nothing does, since the OS temp dir is already per-account.
5
+ */
6
+ export declare const NATIVE_CACHE_ROOT: string;
7
+ export declare function getNativeFileCacheLocationToDelete(): string | null;
8
+ /**
9
+ * Create the native file cache dir, or return `null` if it cannot be created
10
+ * *securely* — in which case the caller loads the binding in place.
11
+ *
12
+ * The stable top-level container is verified as safe for private children. The
13
+ * uid directory and every directory loaded through are owner-only.
14
+ * `ensureOwnedPrivateDir` refuses a directory or symlink another local user
15
+ * planted before us.
16
+ */
17
+ export declare function ensureSecureNativeFileCacheLocation(cacheRoot?: string): string | null;
@@ -1,23 +1,97 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNativeFileCacheLocation = getNativeFileCacheLocation;
4
- const os_1 = require("os");
3
+ exports.NATIVE_CACHE_ROOT = void 0;
4
+ exports.getNativeFileCacheLocationToDelete = getNativeFileCacheLocationToDelete;
5
+ exports.ensureSecureNativeFileCacheLocation = ensureSecureNativeFileCacheLocation;
5
6
  const path_1 = require("path");
6
- const crypto_1 = require("crypto");
7
- const workspace_root_1 = require("../utils/workspace-root");
7
+ const fs_1 = require("fs");
8
+ const nx_tmp_dir_1 = require("../utils/nx-tmp-dir");
8
9
  const versions_1 = require("../utils/versions");
9
- function getNativeFileCacheLocation() {
10
- if (process.env.NX_NATIVE_FILE_CACHE_DIRECTORY) {
11
- return process.env.NX_NATIVE_FILE_CACHE_DIRECTORY;
10
+ const owned_private_dir_1 = require("../utils/owned-private-dir");
11
+ /**
12
+ * Path of the current user's native binary cache. Nothing about the constant is
13
+ * owner-only — `ensureSecureNativeFileCacheLocation` is what establishes that,
14
+ * and on Windows nothing does, since the OS temp dir is already per-account.
15
+ */
16
+ exports.NATIVE_CACHE_ROOT = (0, path_1.join)(nx_tmp_dir_1.NX_USER_TMP_DIR, 'native-cache');
17
+ /**
18
+ * The configured cache dir, normalized. `resolve` strips a trailing slash, which
19
+ * would otherwise defeat the guards downstream: `lstat` on a path ending in `/`
20
+ * resolves a symlink rather than reporting it, and `O_NOFOLLOW` then opens the
21
+ * target. `NX_SOCKET_DIR` is normalized for the same reason.
22
+ */
23
+ function configuredCacheDir() {
24
+ const dir = process.env.NX_NATIVE_FILE_CACHE_DIRECTORY;
25
+ return dir ? (0, path_1.resolve)(dir) : undefined;
26
+ }
27
+ function getNativeFileCacheLocationToDelete() {
28
+ const configured = configuredCacheDir();
29
+ if (configured !== undefined) {
30
+ // Checked for ownership before it is handed to a recursive delete: being
31
+ // configured does not make it ours. Weaker than the load path below, which
32
+ // also enforces mode and validates the version directory.
33
+ return (0, owned_private_dir_1.isOwnedRealDirectory)(configured) ? configured : null;
12
34
  }
13
- else {
14
- const hash = (0, crypto_1.createHash)('sha256').update(workspace_root_1.workspaceRoot).update(versions_1.nxVersion);
35
+ return (0, owned_private_dir_1.isSafeSharedRoot)(nx_tmp_dir_1.NX_TMP_DIR).status === 'ok' &&
36
+ (0, owned_private_dir_1.isOwnedRealDirectory)(nx_tmp_dir_1.NX_USER_TMP_DIR) &&
37
+ (0, owned_private_dir_1.isOwnedRealDirectory)(exports.NATIVE_CACHE_ROOT)
38
+ ? (0, path_1.join)(exports.NATIVE_CACHE_ROOT, versions_1.nxVersion)
39
+ : null;
40
+ }
41
+ /**
42
+ * Create the native file cache dir, or return `null` if it cannot be created
43
+ * *securely* — in which case the caller loads the binding in place.
44
+ *
45
+ * The stable top-level container is verified as safe for private children. The
46
+ * uid directory and every directory loaded through are owner-only.
47
+ * `ensureOwnedPrivateDir` refuses a directory or symlink another local user
48
+ * planted before us.
49
+ */
50
+ function ensureSecureNativeFileCacheLocation(
51
+ // Test seam: lets a spec plant a hostile directory under a root it controls.
52
+ cacheRoot = exports.NATIVE_CACHE_ROOT) {
53
+ const configured = configuredCacheDir();
54
+ if (configured !== undefined) {
55
+ const dir = configured;
15
56
  try {
16
- hash.update((0, os_1.userInfo)().username);
57
+ // Held to the same 0700 bar as the default location: a `.node` is loaded
58
+ // out of here. Unlike NX_SOCKET_DIR it is not additionally refused for
59
+ // naming one of Nx's own roots, which is the only case that throws.
60
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(dir), { recursive: true });
61
+ const established = (0, owned_private_dir_1.ensureOwnedPrivateDir)(dir);
62
+ if (established.status !== 'ok') {
63
+ // The guard's own reason rather than a fixed sentence: `not-created
64
+ // (EACCES)` and `foreign-owner` are exactly what the catch below
65
+ // promises to tell apart, and one string for all of them cannot.
66
+ throw new owned_private_dir_1.DirectoryRefusedError(established.refusal);
67
+ }
68
+ return dir;
17
69
  }
18
70
  catch (e) {
19
- // if there's no user, we only use the workspace root for the hash and move on
71
+ // Never discard a configured directory silently — the socket directory
72
+ // follows the same rule. A typo, EACCES or EROFS is otherwise
73
+ // indistinguishable from a working cache.
74
+ console.warn(`Nx could not use the configured native file cache directory ${dir} (${e?.code ?? e?.message ?? e}). Loading the native binding in place instead.`);
75
+ return null;
76
+ }
77
+ }
78
+ const userRoot = (0, path_1.dirname)(cacheRoot);
79
+ const sharedRoot = (0, path_1.dirname)(userRoot);
80
+ // Outermost first: the stable shared container must either belong to root or
81
+ // to us, and must be sticky if peers can write there. The uid directory then
82
+ // becomes the owner-only boundary for sockets and native-cache alike.
83
+ if ((0, owned_private_dir_1.ensureSafeSharedRoot)(sharedRoot).status !== 'ok') {
84
+ return null;
85
+ }
86
+ for (const root of [userRoot, cacheRoot]) {
87
+ if ((0, owned_private_dir_1.ensureOwnedPrivateDir)(root).status !== 'ok') {
88
+ return null;
20
89
  }
21
- return (0, path_1.join)((0, os_1.tmpdir)(), `nx-native-file-cache-${hash.digest('hex').substring(0, 7)}`);
22
90
  }
91
+ // Verified, not assumed: this is the directory we load a `.node` out of.
92
+ const versionDir = (0, path_1.join)(cacheRoot, versions_1.nxVersion);
93
+ if ((0, owned_private_dir_1.ensureOwnedPrivateDir)(versionDir).status !== 'ok') {
94
+ return null;
95
+ }
96
+ return versionDir;
23
97
  }
Binary file
@@ -6,7 +6,7 @@ const child_process_1 = require("child_process");
6
6
  const output_1 = require("../../../utils/output");
7
7
  const json_1 = require("../../../generators/utils/json");
8
8
  const nx_json_1 = require("../../../generators/utils/nx-json");
9
- const format_changed_files_with_prettier_if_available_1 = require("../../../generators/internal-utils/format-changed-files-with-prettier-if-available");
9
+ const format_changed_files_1 = require("../../../generators/internal-utils/format-changed-files");
10
10
  const url_shorten_1 = require("../../utilities/url-shorten");
11
11
  const get_cloud_options_1 = require("../../utilities/get-cloud-options");
12
12
  const path_1 = require("path");
@@ -137,14 +137,14 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
137
137
  }
138
138
  if (responseFromCreateNxCloudWorkspaceV2) {
139
139
  addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
140
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
140
+ await (0, format_changed_files_1.formatChangedFiles)(tree, {
141
141
  silent: schema.hideFormatLogs,
142
142
  });
143
143
  return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
144
144
  }
145
145
  else if (responseFromCreateNxCloudWorkspaceV1) {
146
146
  addNxCloudAccessTokenToNxJson(tree, responseFromCreateNxCloudWorkspaceV1?.token, schema.directory);
147
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
147
+ await (0, format_changed_files_1.formatChangedFiles)(tree, {
148
148
  silent: schema.hideFormatLogs,
149
149
  });
150
150
  return responseFromCreateNxCloudWorkspaceV1.token;
@@ -5,12 +5,15 @@ exports.getCloudUrl = getCloudUrl;
5
5
  exports.removeTrailingSlash = removeTrailingSlash;
6
6
  exports.isNxCloudId = isNxCloudId;
7
7
  const nx_json_1 = require("../../config/nx-json");
8
- const run_command_1 = require("../../tasks-runner/run-command");
9
8
  const workspace_root_1 = require("../../utils/workspace-root");
10
9
  function getCloudOptions(directory = workspace_root_1.workspaceRoot) {
10
+ // Required lazily: this module is reachable from the @nx/devkit/internal
11
+ // barrel that plugin workers load, and run-command eagerly pulls in the whole
12
+ // task-execution subsystem.
13
+ const { getRunnerOptions, } = require('../../tasks-runner/run-command');
11
14
  const nxJson = (0, nx_json_1.readNxJson)(directory);
12
15
  // TODO: The default is not always cloud? But it's not handled at the moment
13
- return (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
16
+ return getRunnerOptions('default', nxJson, {}, true);
14
17
  }
15
18
  function getCloudUrl() {
16
19
  return removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
@@ -5,7 +5,6 @@ exports.getNxCloudAppOnBoardingUrl = getNxCloudAppOnBoardingUrl;
5
5
  exports.readNxCloudToken = readNxCloudToken;
6
6
  const is_workspace_claimed_1 = require("./is-workspace-claimed");
7
7
  const url_shorten_1 = require("./url-shorten");
8
- const run_command_1 = require("../../tasks-runner/run-command");
9
8
  const nx_json_1 = require("../../generators/utils/nx-json");
10
9
  async function createNxCloudOnboardingURLForWelcomeApp(tree, token) {
11
10
  token = token || readNxCloudToken(tree);
@@ -22,7 +21,11 @@ async function getNxCloudAppOnBoardingUrl(token) {
22
21
  return onboardingUrl;
23
22
  }
24
23
  function readNxCloudToken(tree) {
24
+ // Required lazily: this module is re-exported from the @nx/devkit/internal
25
+ // barrel that plugin workers load, and run-command eagerly pulls in the whole
26
+ // task-execution subsystem.
27
+ const { getRunnerOptions, } = require('../../tasks-runner/run-command');
25
28
  const nxJson = (0, nx_json_1.readNxJson)(tree);
26
- const { accessToken, nxCloudId } = (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
29
+ const { accessToken, nxCloudId } = getRunnerOptions('default', nxJson, {}, true);
27
30
  return accessToken || nxCloudId;
28
31
  }
@@ -1,5 +1,2 @@
1
- /**
2
- * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
3
- */
4
- export declare function createNxCloudOnboardingURL(onboardingSource: string, accessToken?: string, meta?: string, forceManual?: boolean, forceGithub?: boolean, directory?: string): Promise<string>;
1
+ export declare function createNxCloudOnboardingURL(onboardingSource: string, accessToken?: string, meta?: string, forceManual?: boolean, forceGithub?: boolean, directory?: string, signal?: AbortSignal): Promise<string>;
5
2
  export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string, accessToken?: string): string;
@@ -5,13 +5,14 @@ exports.getURLifShortenFailed = getURLifShortenFailed;
5
5
  const logger_1 = require("../../utils/logger");
6
6
  const get_cloud_options_1 = require("./get-cloud-options");
7
7
  const git_utils_1 = require("../../utils/git-utils");
8
- /**
9
- * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
10
- */
11
- async function createNxCloudOnboardingURL(onboardingSource, accessToken, meta, forceManual = false, forceGithub = false, directory) {
8
+ async function createNxCloudOnboardingURL(onboardingSource, accessToken, meta, forceManual = false, forceGithub = false, directory,
9
+ // Aborting tears down the in-flight request; without it a caller that stops
10
+ // waiting (see prefetchRemoteCacheOnboardingUrl) leaves the socket holding
11
+ // the event loop open, since axios has no default timeout.
12
+ signal) {
12
13
  const remoteInfo = (0, git_utils_1.getVcsRemoteInfo)(directory);
13
14
  const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
14
- const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
15
+ const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl, signal);
15
16
  let usesGithub = false;
16
17
  if (forceGithub) {
17
18
  usesGithub = installationSupportsGitHub;
@@ -32,7 +33,7 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, meta, f
32
33
  selectedRepositoryName: remoteInfo?.slug ?? null,
33
34
  repositoryDomain: remoteInfo?.domain ?? null,
34
35
  meta,
35
- });
36
+ }, { signal });
36
37
  if (!response?.data || response.data.message) {
37
38
  throw new Error(response?.data?.message ?? 'Failed to shorten Nx Cloud URL');
38
39
  }
@@ -66,9 +67,9 @@ function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessTok
66
67
  }
67
68
  return `${apiUrl}/setup/connect-workspace/manual?accessToken=${accessToken}&source=${source}`;
68
69
  }
69
- async function getInstallationSupportsGitHub(apiUrl) {
70
+ async function getInstallationSupportsGitHub(apiUrl, signal) {
70
71
  try {
71
- const response = await require('axios').get(`${apiUrl}/nx-cloud/system/features`);
72
+ const response = await require('axios').get(`${apiUrl}/nx-cloud/system/features`, { signal });
72
73
  if (!response?.data || response.data.message) {
73
74
  throw new Error(response?.data?.message ?? 'Failed to shorten Nx Cloud URL');
74
75
  }
@@ -12,6 +12,16 @@ const project_graph_1 = require("../../../config/project-graph");
12
12
  const file_hasher_1 = require("../../../hasher/file-hasher");
13
13
  const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
14
14
  const json_1 = require("../../../utils/json");
15
+ // Highest bun.lock version this parser has been verified against:
16
+ // - 1: workspace packages are no longer listed with their dependencies
17
+ // - 2: identical content, stricter validation in Bun's own reader
18
+ // - 3: values in "overrides" may be objects holding rules scoped to a parent
19
+ // package (`"parent": { "child": "1.0.0" }`) and keys may carry a version
20
+ // selector (`"parent@1"`, `"child@<2"`). This parser never reads
21
+ // "overrides"; the resolved packages are listed in "packages" as before.
22
+ // Newer versions are parsed on a best-effort basis instead of being rejected
23
+ // outright.
24
+ const MAX_KNOWN_LOCKFILE_VERSION = 3;
15
25
  const DEPENDENCY_TYPES = [
16
26
  'dependencies',
17
27
  'devDependencies',
@@ -356,9 +366,12 @@ function parseLockFile(lockFileContent, lockFileHash) {
356
366
  if (typeof result.lockfileVersion !== 'number') {
357
367
  throw new Error(`Lockfile version must be a number, got ${typeof result.lockfileVersion}`);
358
368
  }
359
- const supportedVersions = [0, 1];
360
- if (!supportedVersions.includes(result.lockfileVersion)) {
361
- throw new Error(`Unsupported lockfile version ${result.lockfileVersion}. Supported versions: ${supportedVersions.join(', ')}`);
369
+ if (!Number.isInteger(result.lockfileVersion) ||
370
+ result.lockfileVersion < 0) {
371
+ throw new Error(`Unsupported lockfile version ${result.lockfileVersion}. Lockfile version must be a non-negative integer`);
372
+ }
373
+ if (result.lockfileVersion > MAX_KNOWN_LOCKFILE_VERSION) {
374
+ console.warn(`bun.lock has lockfileVersion ${result.lockfileVersion}, which is newer than the version ${MAX_KNOWN_LOCKFILE_VERSION} this version of Nx was tested with. Attempting to parse it anyway.`);
362
375
  }
363
376
  }
364
377
  if (!result.packages || typeof result.packages !== 'object') {
@@ -616,7 +629,7 @@ function processPackageForDependencies(packageKey, packageData, lockFile, index,
616
629
  const deps = packageDependencies[depType];
617
630
  if (!deps || typeof deps !== 'object')
618
631
  continue;
619
- const depDependencies = processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePackages, lockFile.manifests);
632
+ const depDependencies = processDependencyEntries(deps, packageKey, sourceNodeName, lockFile, index, ctx, workspacePackages);
620
633
  dependencies.push(...depDependencies);
621
634
  }
622
635
  return dependencies;
@@ -634,12 +647,12 @@ function extractPackageDependencies(packageData) {
634
647
  }
635
648
  return undefined;
636
649
  }
637
- function processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePackages, manifests) {
650
+ function processDependencyEntries(deps, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages) {
638
651
  const dependencies = [];
639
652
  const depsEntries = Object.entries(deps);
640
653
  for (const [packageName, versionSpec] of depsEntries) {
641
654
  try {
642
- const dependency = processSingleDependency(packageName, versionSpec, sourceNodeName, index, ctx, workspacePackages, manifests);
655
+ const dependency = processSingleDependency(packageName, versionSpec, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages);
643
656
  if (dependency) {
644
657
  dependencies.push(dependency);
645
658
  }
@@ -650,7 +663,7 @@ function processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePac
650
663
  }
651
664
  return dependencies;
652
665
  }
653
- function processSingleDependency(packageName, versionSpec, sourceNodeName, index, ctx, workspacePackages, manifests) {
666
+ function processSingleDependency(packageName, versionSpec, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages) {
654
667
  if (typeof packageName !== 'string' || typeof versionSpec !== 'string') {
655
668
  return null;
656
669
  }
@@ -663,14 +676,22 @@ function processSingleDependency(packageName, versionSpec, sourceNodeName, index
663
676
  }
664
677
  let targetPackageName = packageName;
665
678
  let targetVersion = versionSpec;
666
- const aliasTarget = resolveAliasTarget(versionSpec);
667
- if (aliasTarget) {
679
+ // A "<parent>/<name>" entry records what this parent actually resolved the
680
+ // dependency to. Overrides scoped to a parent (bun.lock v3) can pick a
681
+ // version outside the declared range, so it takes precedence over matching
682
+ // the range against the versions in the lockfile.
683
+ const nestedVersion = resolveNestedVersion(sourcePackageKey, packageName, lockFile);
684
+ const aliasTarget = nestedVersion ? null : resolveAliasTarget(versionSpec);
685
+ if (nestedVersion) {
686
+ targetVersion = nestedVersion;
687
+ }
688
+ else if (aliasTarget) {
668
689
  targetPackageName = aliasTarget.packageName;
669
690
  targetVersion = aliasTarget.version;
670
691
  }
671
692
  else {
672
693
  // O(1) lookup using index instead of O(n) scan
673
- const resolvedVersion = findResolvedVersion(packageName, versionSpec, index, manifests);
694
+ const resolvedVersion = findResolvedVersion(packageName, versionSpec, index, lockFile.manifests);
674
695
  if (!resolvedVersion) {
675
696
  return null;
676
697
  }
@@ -693,6 +714,18 @@ function processSingleDependency(packageName, versionSpec, sourceNodeName, index
693
714
  return null;
694
715
  }
695
716
  }
717
+ function resolveNestedVersion(sourcePackageKey, packageName, lockFile) {
718
+ const nestedEntry = lockFile.packages[`${sourcePackageKey}/${packageName}`];
719
+ if (!Array.isArray(nestedEntry) || typeof nestedEntry[0] !== 'string') {
720
+ return null;
721
+ }
722
+ const { name, version } = getCachedSpecInfo(nestedEntry[0]);
723
+ // aliases ("alias@npm:real@1.0.0") are resolved to the real package by the caller
724
+ if (name !== packageName || !version || version.startsWith('npm:')) {
725
+ return null;
726
+ }
727
+ return version;
728
+ }
696
729
  function resolveTargetNodeName(targetPackageName, targetVersion, ctx) {
697
730
  const hoistedNodeName = `npm:${targetPackageName}`;
698
731
  const versionedNodeName = `npm:${targetPackageName}@${targetVersion}`;
@@ -35,9 +35,51 @@ export declare function getLockFilePath(packageManager: PackageManager): string;
35
35
  /**
36
36
  * Create lock file based on the root level lock file and (pruned) package.json
37
37
  *
38
- * @param packageJson
39
- * @param isProduction
40
- * @param packageManager
41
- * @returns
38
+ * A pruned pnpm lockfile no longer declares the resolution-time pnpm config it
39
+ * bakes into its snapshots, so the config is dropped from `packageJson` too:
40
+ * pnpm 10 and below validate the manifest against the lockfile and abort a
41
+ * frozen install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH when the two disagree.
42
+ * An inherited `pnpm.patchedDependencies` goes with it, since the prune scopes
43
+ * the lockfile's patches to the packages that survive it and rewrites their
44
+ * paths onto the output.
45
+ * The manifest is left alone for npm and yarn, which never read that block.
46
+ * Mutating it means callers must write or emit the manifest after this returns.
47
+ *
48
+ * The lockfile alone does not make a complete pnpm output. A workspace
49
+ * declaring build-script approvals, patches or vendored local paths also needs
50
+ * the artifacts `generatePrunedDeployOutput` ships, and this warns when that is
51
+ * the case.
52
+ *
53
+ * On a pruning error the root lockfile is returned as a fail-open fallback,
54
+ * with the manifest left as authored.
55
+ *
56
+ * @deprecated Use `generatePrunedDeployOutput` instead. This will be removed in Nx 25.
42
57
  */
43
58
  export declare function createLockFile(packageJson: PackageJson, graph: ProjectGraph, packageManager?: PackageManager): string;
59
+ type PrunedDeploySink = {
60
+ outputDirectory: string;
61
+ emit?: never;
62
+ } | {
63
+ emit: (path: string, content: string | Buffer) => void;
64
+ outputDirectory?: never;
65
+ };
66
+ /**
67
+ * Generates the standalone deploy output a generate-package-json flow ships
68
+ * alongside its manifest: the pruned lockfile and, for pnpm, the install-time
69
+ * artifacts that lockfile needs (the settings-only pnpm-workspace.yaml, the
70
+ * `pnpm patch` files, and the vendored non-workspace local-path dependencies).
71
+ * `options` carries either an `outputDirectory` to write into or an `emit` sink
72
+ * for a bundler's asset pipeline, never both.
73
+ *
74
+ * Mutates `packageJson` into the form the output must ship (the relocated
75
+ * local-path specifiers, the pnpm config strip, the pnpm <=10 build settings),
76
+ * so write or emit the manifest after this returns.
77
+ *
78
+ * Bun has no lockfile generation, so it warns and ships nothing, leaving the
79
+ * manifest as authored.
80
+ */
81
+ export declare function generatePrunedDeployOutput(packageJson: PackageJson, graph: ProjectGraph, projectRoot: string, options: PrunedDeploySink & {
82
+ packageManager: PackageManager;
83
+ workspaceRoot?: string;
84
+ }): void;
85
+ export {};