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
@@ -118,12 +118,33 @@ export declare function resolvePackageVersionUsingRegistry(packageName: string,
118
118
  * package.json.
119
119
  */
120
120
  export declare function resolvePackageVersionUsingInstallation(packageName: string, version: string): Promise<string>;
121
- export declare function packageRegistryView(pkg: string, version: string, args: string, options?: {
121
+ /**
122
+ * The registry the fetch for `pkg` went to, with its userinfo masked because a
123
+ * registry URL can carry a bare token. The lookup is spawned the way
124
+ * `packageRegistryView` spawns the fetch this describes (same manager, same
125
+ * environment), so a registry the package manager keeps outside the .npmrc
126
+ * chain and a scope resolved for itself both land on the value that fetch used.
127
+ * Null where the manager yields no usable registry URL; throws where it cannot be run.
128
+ */
129
+ export declare function getWorkspaceRegistryUrlForDisplay(pkg: string): string | null;
130
+ export declare function packageRegistryView(pkg: string, version: string, args: string[], options?: {
122
131
  forceNpm?: boolean;
123
132
  }): Promise<string>;
124
- export declare function packageRegistryPack(cwd: string, pkg: string, version: string): Promise<{
133
+ /**
134
+ * Only `npm pack` supports downloading a tarball of a specified remote
135
+ * package. `yarn` packs the active workspace, `pnpm pack` only packs
136
+ * the local project, and `bun` doesn't support pack.
137
+ *
138
+ * @param packDestination Directory passed to npm's `--pack-destination`, where
139
+ * the `.tgz` is written.
140
+ * @see https://github.com/nrwl/nx/pull/9667#discussion_r842553994
141
+ */
142
+ export declare function packageRegistryPack(packDestination: string, pkg: string, version: string, options?: {
143
+ bypassMinReleaseAge?: boolean;
144
+ }): Promise<{
125
145
  tarballPath: string;
126
146
  }>;
147
+ export declare function clearPackageManagerVersionCache(): void;
127
148
  /**
128
149
  * Gets the workspaces defined in the package manager configuration.
129
150
  * @returns workspaces defined in the package manager configuration, empty array if none are defined
@@ -13,8 +13,10 @@ exports.copyPackageManagerConfigurationFiles = copyPackageManagerConfigurationFi
13
13
  exports.createTempNpmDirectory = createTempNpmDirectory;
14
14
  exports.resolvePackageVersionUsingRegistry = resolvePackageVersionUsingRegistry;
15
15
  exports.resolvePackageVersionUsingInstallation = resolvePackageVersionUsingInstallation;
16
+ exports.getWorkspaceRegistryUrlForDisplay = getWorkspaceRegistryUrlForDisplay;
16
17
  exports.packageRegistryView = packageRegistryView;
17
18
  exports.packageRegistryPack = packageRegistryPack;
19
+ exports.clearPackageManagerVersionCache = clearPackageManagerVersionCache;
18
20
  exports.getPackageWorkspaces = getPackageWorkspaces;
19
21
  exports.addPackagePathToWorkspaces = addPackagePathToWorkspaces;
20
22
  const child_process_1 = require("child_process");
@@ -30,9 +32,36 @@ const file_utils_1 = require("../project-graph/file-utils");
30
32
  const catalog_1 = require("./catalog");
31
33
  const fileutils_1 = require("./fileutils");
32
34
  const installation_directory_1 = require("./installation-directory");
35
+ const logger_1 = require("./logger");
33
36
  const package_json_1 = require("./package-json");
37
+ const shell_quoting_1 = require("./shell-quoting");
34
38
  const workspace_root_1 = require("./workspace-root");
35
39
  const execAsync = (0, util_1.promisify)(child_process_1.exec);
40
+ const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
41
+ /**
42
+ * Shell-less spawn for the registry-bridged fetches: `exec` goes through
43
+ * /bin/sh, which is dash on Debian-family systems, and dash drops environment
44
+ * names that are not valid shell identifiers, i.e. every `//...:_authToken`
45
+ * credential and `@scope:registry` entry the overlay carries. Windows stays on
46
+ * `exec`, with every argument quoted, because Node refuses to execFile the
47
+ * package manager's `.cmd` shim without a shell.
48
+ *
49
+ * That quoting is the whole defence on Windows, so it goes through
50
+ * quoteShellArg, which throws on the one argument it cannot make safe.
51
+ */
52
+ function execPackageManagerAsync(pm, args, options) {
53
+ if (process.platform === 'win32') {
54
+ return execAsync([pm, ...args].map(shell_quoting_1.quoteShellArg).join(' '), options);
55
+ }
56
+ return execFileAsync(pm, args, options);
57
+ }
58
+ /** Same split, and the same quoting, for a blocking caller. */
59
+ function execPackageManagerSync(pm, args, options) {
60
+ if (process.platform === 'win32') {
61
+ return (0, child_process_1.execSync)([pm, ...args].map(shell_quoting_1.quoteShellArg).join(' '), options);
62
+ }
63
+ return (0, child_process_1.execFileSync)(pm, args, options);
64
+ }
36
65
  /**
37
66
  * Detects which package manager is used in the workspace based on the lock file.
38
67
  */
@@ -165,8 +194,12 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
165
194
  install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
166
195
  ciInstall: 'pnpm install --frozen-lockfile',
167
196
  updateLockFile: 'pnpm install --lockfile-only',
168
- add: isPnpmWorkspace ? 'pnpm add -w' : 'pnpm add',
169
- addDev: isPnpmWorkspace ? 'pnpm add -Dw' : 'pnpm add -D',
197
+ add: isPnpmWorkspace
198
+ ? 'pnpm add -w --config.frozen-lockfile=false'
199
+ : 'pnpm add --config.frozen-lockfile=false',
200
+ addDev: isPnpmWorkspace
201
+ ? 'pnpm add -Dw --config.frozen-lockfile=false'
202
+ : 'pnpm add -D --config.frozen-lockfile=false',
170
203
  rm: 'pnpm rm',
171
204
  exec: modernPnpm ? 'pnpm exec' : 'pnpx',
172
205
  dlx: modernPnpm ? 'pnpm dlx' : 'pnpx',
@@ -235,7 +268,10 @@ function getPackageManagerVersion(packageManager = detectPackageManager(), cwd =
235
268
  }
236
269
  if (!version) {
237
270
  try {
238
- version = (0, child_process_1.execSync)(`${packageManager} --version`, {
271
+ const versionArgs = packageManager === 'pnpm'
272
+ ? '--ignore-workspace --version'
273
+ : '--version';
274
+ version = (0, child_process_1.execSync)(`${packageManager} ${versionArgs}`, {
239
275
  cwd,
240
276
  encoding: 'utf-8',
241
277
  windowsHide: true,
@@ -345,6 +381,20 @@ function modifyPnpmWorkspaceYamlToFitNewDirectory(contents) {
345
381
  doc.set('packages', ['.']);
346
382
  // Relative patch paths don't resolve in the temp dir.
347
383
  doc.delete('patchedDependencies');
384
+ // link:/file: overrides (e.g. written by `pnpm link`) point at paths that
385
+ // don't exist in the temp dir, and an override would hijack an exact-version
386
+ // add (`pnpm add pkg@x.y.z` would install the linked dir instead).
387
+ const overrides = doc.toJS()?.overrides;
388
+ if (overrides && typeof overrides === 'object') {
389
+ for (const [name, spec] of Object.entries(overrides)) {
390
+ if (typeof spec === 'string' && /^(link|file):/.test(spec)) {
391
+ doc.deleteIn(['overrides', name]);
392
+ }
393
+ }
394
+ if (Object.keys(doc.toJS()?.overrides ?? {}).length === 0) {
395
+ doc.delete('overrides');
396
+ }
397
+ }
348
398
  return doc.toString();
349
399
  }
350
400
  function copyPackageManagerConfigurationFiles(root, destination) {
@@ -390,6 +440,27 @@ function copyPackageManagerConfigurationFiles(root, destination) {
390
440
  }
391
441
  }
392
442
  }
443
+ /**
444
+ * A non-JS workspace has no root package.json and keeps its package manager
445
+ * files under the Nx installation directory instead.
446
+ */
447
+ function getPackageManagerConfigRoot() {
448
+ if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'))) {
449
+ return workspace_root_1.workspaceRoot;
450
+ }
451
+ const installationPath = (0, installation_directory_1.getNxInstallationPath)(workspace_root_1.workspaceRoot);
452
+ // The installation directory can be missing or not a directory, and spawning
453
+ // with such a cwd fails outright (ENOENT/ENOTDIR).
454
+ try {
455
+ return (0, fs_1.statSync)(installationPath).isDirectory()
456
+ ? installationPath
457
+ : workspace_root_1.workspaceRoot;
458
+ }
459
+ catch (e) {
460
+ logger_1.logger.verbose(`Failed to stat the Nx installation directory at "${installationPath}".`, e);
461
+ return workspace_root_1.workspaceRoot;
462
+ }
463
+ }
393
464
  /**
394
465
  * Creates a temporary directory where you can run package manager commands safely.
395
466
  *
@@ -406,8 +477,7 @@ function createTempNpmDirectory(skipCopy = false) {
406
477
  // A package.json is needed for pnpm pack and for .npmrc to resolve
407
478
  (0, fileutils_1.writeJsonFile)(`${dir}/package.json`, {});
408
479
  if (!skipCopy) {
409
- const isNonJs = !(0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'));
410
- copyPackageManagerConfigurationFiles(isNonJs ? (0, installation_directory_1.getNxInstallationPath)(workspace_root_1.workspaceRoot) : workspace_root_1.workspaceRoot, dir);
480
+ copyPackageManagerConfigurationFiles(getPackageManagerConfigRoot(), dir);
411
481
  }
412
482
  const cleanup = async () => {
413
483
  try {
@@ -426,7 +496,9 @@ function createTempNpmDirectory(skipCopy = false) {
426
496
  async function resolvePackageVersionUsingRegistry(packageName, version) {
427
497
  try {
428
498
  const resolvedVersion = (0, catalog_1.resolveCatalogReferenceIfNeeded)(packageName, version);
429
- const result = await packageRegistryView(packageName, resolvedVersion, 'version');
499
+ const result = await packageRegistryView(packageName, resolvedVersion, [
500
+ 'version',
501
+ ]);
430
502
  if (!result) {
431
503
  throw new Error(`Unable to resolve version ${packageName}@${resolvedVersion}.`);
432
504
  }
@@ -448,9 +520,29 @@ async function resolvePackageVersionUsingRegistry(packageName, version) {
448
520
  .replace(/'/g, '');
449
521
  return finalResolvedVersion;
450
522
  }
451
- catch {
452
- throw new Error(`Unable to resolve version ${packageName}@${version}.`);
523
+ catch (e) {
524
+ // npm masks a URL credential only in the password position, so a bare token
525
+ // in the registry URL survives into the error kept as the cause.
526
+ throw new Error(`Unable to resolve version ${packageName}@${version}.`, {
527
+ cause: redactErrorCause(e),
528
+ });
529
+ }
530
+ }
531
+ // Masks the userinfo in a URL: `user`, `user:pass`, or a bare token.
532
+ function redactUrlCredentials(text) {
533
+ return text.replace(/([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/gi, '$1***@');
534
+ }
535
+ function redactErrorCause(error) {
536
+ if (error && typeof error === 'object') {
537
+ const e = error;
538
+ // An exec error carries the command and both output streams as fields.
539
+ for (const field of ['message', 'stack', 'stderr', 'stdout', 'cmd']) {
540
+ if (typeof e[field] === 'string') {
541
+ e[field] = redactUrlCredentials(e[field]);
542
+ }
543
+ }
453
544
  }
545
+ return error;
454
546
  }
455
547
  /**
456
548
  * Return the resolved version for a given package and version tag using by
@@ -480,12 +572,86 @@ async function resolvePackageVersionUsingInstallation(packageName, version) {
480
572
  await cleanup();
481
573
  }
482
574
  }
483
- async function packageRegistryView(pkg, version, args,
484
- // `forceNpm` runs the view through npm even in a pnpm workspace: npm projects
485
- // a field across every matched version, whereas `pnpm view <pkg>@<range>`
486
- // collapses to the single highest match (breaks per-version field queries).
487
- options) {
488
- let pm = detectPackageManager();
575
+ /**
576
+ * What every registry-bound npm spawn resolves the same way: where npm runs,
577
+ * and an environment reproducing the workspace package manager's own registry,
578
+ * auth and TLS resolution for `pkg`. `buildEnv` adds the caller's own entries.
579
+ */
580
+ function createRegistrySpawnContext(pkg) {
581
+ // Deferred so the registry resolvers load only for the commands that spawn
582
+ // npm, not with every package-manager.ts import.
583
+ const { getNpmSpawnRegistryEnv, getPackageScope, ignoresNpmConfigEnv, mergeNpmConfigEnv, } = require('./registry-config');
584
+ const workspacePm = detectPackageManager();
585
+ const configRoot = getPackageManagerConfigRoot();
586
+ const workspacePmVersion = getPackageManagerVersionSafe(workspacePm, configRoot);
587
+ return {
588
+ workspacePm,
589
+ workspacePmVersion,
590
+ configRoot,
591
+ scope: getPackageScope(pkg),
592
+ buildEnv: (extra) => mergeNpmConfigEnv(process.env, {
593
+ ...getNpmSpawnRegistryEnv(pkg, configRoot, workspacePm, workspacePmVersion),
594
+ ...extra,
595
+ }, ignoresNpmConfigEnv(workspacePm, workspacePmVersion)),
596
+ };
597
+ }
598
+ /**
599
+ * The registry the fetch for `pkg` went to, with its userinfo masked because a
600
+ * registry URL can carry a bare token. The lookup is spawned the way
601
+ * `packageRegistryView` spawns the fetch this describes (same manager, same
602
+ * environment), so a registry the package manager keeps outside the .npmrc
603
+ * chain and a scope resolved for itself both land on the value that fetch used.
604
+ * Null where the manager yields no usable registry URL; throws where it cannot be run.
605
+ */
606
+ function getWorkspaceRegistryUrlForDisplay(pkg) {
607
+ const { workspacePm, workspacePmVersion, configRoot, scope, buildEnv } = createRegistrySpawnContext(pkg);
608
+ const { pm, env, usesNativePnpm } = resolveRegistrySpawnTarget(workspacePm, workspacePmVersion, buildEnv);
609
+ // Ask for the package scope first. Native pnpm can keep the workspace
610
+ // `registries.default` separate from the flat `registry`, so it is queried
611
+ // in between.
612
+ const keys = scope ? [`${scope}:registry`] : [];
613
+ if (usesNativePnpm) {
614
+ keys.push('registries.default');
615
+ }
616
+ keys.push('registry');
617
+ for (const key of keys) {
618
+ const value = execPackageManagerSync(pm, ['config', 'get', key], {
619
+ cwd: configRoot,
620
+ timeout: 5000,
621
+ windowsHide: true,
622
+ encoding: 'utf-8',
623
+ // The downgraded pin warns on stderr, which is noise on a path that only
624
+ // decorates an error message.
625
+ stdio: ['ignore', 'pipe', 'ignore'],
626
+ env,
627
+ }).trim();
628
+ if (!value || value === 'undefined' || value === 'null') {
629
+ continue;
630
+ }
631
+ // A present but unusable answer (a `registries:` map with a non-string
632
+ // default serializes as JSON; a non-HTTP(S) scheme) also aborted the fetch
633
+ // this describes, so a key below it was never contacted either.
634
+ if (!URL.canParse(value)) {
635
+ return null;
636
+ }
637
+ const protocol = new URL(value).protocol;
638
+ if (protocol !== 'http:' && protocol !== 'https:') {
639
+ return null;
640
+ }
641
+ return redactUrlCredentials(value);
642
+ }
643
+ return null;
644
+ }
645
+ /**
646
+ * Which manager answers a registry read for this workspace, and the environment
647
+ * it reads under. pnpm 11 reimplemented `view` natively, resolving registry and
648
+ * credentials (tokenHelper included) itself, so it runs on the untouched
649
+ * environment; pnpm 10 passed `view` through to the npm CLI, which needs the
650
+ * overlay. Shared so a lookup describing a fetch cannot resolve against a
651
+ * different environment than the fetch used.
652
+ */
653
+ function resolveRegistrySpawnTarget(workspacePm, workspacePmVersion, buildEnv, options) {
654
+ let pm = workspacePm;
489
655
  if (options?.forceNpm || pm === 'yarn' || pm === 'bun') {
490
656
  /**
491
657
  * yarn has `yarn info` but it behaves differently than (p)npm,
@@ -499,40 +665,98 @@ options) {
499
665
  */
500
666
  pm = 'npm';
501
667
  }
668
+ if (pm === 'pnpm' && ((0, semver_1.parse)(workspacePmVersion)?.major ?? 0) >= 11) {
669
+ return { pm, env: process.env, usesNativePnpm: true };
670
+ }
671
+ // npm_config_force downgrades npm's `devEngines.packageManager` enforcement,
672
+ // which otherwise aborts even a read-only lookup when the pin sets
673
+ // `onFail: error`. Only set for npm so a pnpm spawn is untouched.
674
+ return {
675
+ pm,
676
+ env: buildEnv(pm === 'npm' ? { npm_config_force: 'true' } : {}),
677
+ usesNativePnpm: false,
678
+ };
679
+ }
680
+ async function packageRegistryView(pkg, version, args,
681
+ // `forceNpm` runs the view through npm even in a pnpm workspace: npm projects
682
+ // a field across every matched version, whereas `pnpm view <pkg>@<range>`
683
+ // collapses to the single highest match (breaks per-version field queries).
684
+ options) {
685
+ const { workspacePm, workspacePmVersion, configRoot, buildEnv } = createRegistrySpawnContext(pkg);
686
+ const { pm, env } = resolveRegistrySpawnTarget(workspacePm, workspacePmVersion, buildEnv, options);
502
687
  // An empty version means we want the full packument; omit the trailing `@`.
503
- // Quote the spec so range operators (e.g. `>=0.0.0`) are not parsed as shell
504
- // redirections.
505
688
  const spec = version ? `${pkg}@${version}` : pkg;
506
- // npm enforces `devEngines.packageManager` on every command, even a read-only
507
- // `view`; in a yarn/bun workspace we run npm, so a non-npm pin with
508
- // `onFail: error` aborts the lookup. force downgrades that to a warning.
509
- // Scoped to npm so a `pnpm view` spawn is left untouched.
510
- const { stdout } = await execAsync(`${pm} view "${spec}" ${args}`, {
511
- windowsHide: true,
512
- ...(pm === 'npm'
513
- ? { env: { ...process.env, npm_config_force: 'true' } }
514
- : {}),
515
- });
516
- return stdout.toString().trim();
689
+ try {
690
+ const { stdout } = await execPackageManagerAsync(pm, ['view', spec, ...args], {
691
+ windowsHide: true,
692
+ cwd: configRoot,
693
+ env,
694
+ });
695
+ return stdout.toString().trim();
696
+ }
697
+ catch (e) {
698
+ throw redactErrorCause(e);
699
+ }
517
700
  }
518
- async function packageRegistryPack(cwd, pkg, version) {
519
- /**
520
- * Only `npm pack` supports downloading a tarball of a specified remote
521
- * package. `yarn` packs the active workspace, `pnpm pack` only packs
522
- * the local project, and `bun` doesn't support pack.
523
- *
524
- * @see https://github.com/nrwl/nx/pull/9667#discussion_r842553994
525
- */
701
+ /**
702
+ * Only `npm pack` supports downloading a tarball of a specified remote
703
+ * package. `yarn` packs the active workspace, `pnpm pack` only packs
704
+ * the local project, and `bun` doesn't support pack.
705
+ *
706
+ * @param packDestination Directory passed to npm's `--pack-destination`, where
707
+ * the `.tgz` is written.
708
+ * @see https://github.com/nrwl/nx/pull/9667#discussion_r842553994
709
+ */
710
+ async function packageRegistryPack(packDestination, pkg, version, options) {
526
711
  const pm = 'npm';
527
- const { stdout } = await execAsync(`${pm} pack ${pkg}@${version}`, {
528
- cwd,
529
- windowsHide: true,
530
- // npm enforces `devEngines.packageManager` even on `pack`; force keeps the
531
- // download working in workspaces that pin a non-npm manager (onFail: error).
532
- env: { ...process.env, npm_config_force: 'true' },
533
- });
534
- const tarballPath = stdout.trim();
535
- return { tarballPath };
712
+ const { configRoot, buildEnv } = createRegistrySpawnContext(pkg);
713
+ // Run from the config root, not the temp dir, so npm reads the workspace
714
+ // .npmrc natively; --pack-destination still writes the tarball to the temp
715
+ // dir. npm prints the tarball basename to stdout.
716
+ try {
717
+ const { stdout } = await execPackageManagerAsync(pm, ['pack', `${pkg}@${version}`, '--pack-destination', packDestination], {
718
+ cwd: configRoot,
719
+ windowsHide: true,
720
+ env: buildEnv({
721
+ // downgrade npm's devEngines.packageManager enforcement (onFail:
722
+ // error) to a warning so pack still runs in a non-npm workspace
723
+ npm_config_force: 'true',
724
+ ...(options?.bypassMinReleaseAge
725
+ ? { npm_config_min_release_age: '0' }
726
+ : {}),
727
+ }),
728
+ });
729
+ const tarballPath = stdout.trim();
730
+ return { tarballPath };
731
+ }
732
+ catch (e) {
733
+ throw redactErrorCause(e);
734
+ }
735
+ }
736
+ // The version probe shells out when the packageManager field is absent, and
737
+ // packageRegistryView/packageRegistryPack run in tight resolution loops.
738
+ const packageManagerVersionCache = new Map();
739
+ /**
740
+ * A null version is tolerated per package manager: pnpm and yarn skip bridging,
741
+ * bun assumes a current version.
742
+ */
743
+ function getPackageManagerVersionSafe(packageManager, root) {
744
+ const key = `${packageManager}:${root}`;
745
+ if (!packageManagerVersionCache.has(key)) {
746
+ let version = null;
747
+ try {
748
+ version = getPackageManagerVersion(packageManager, root);
749
+ }
750
+ catch (e) {
751
+ logger_1.logger.verbose(`Failed to determine the ${packageManager} version in "${root}".`, e);
752
+ }
753
+ packageManagerVersionCache.set(key, version);
754
+ }
755
+ return packageManagerVersionCache.get(key);
756
+ }
757
+ // Test-only: production never re-resolves a version mid-run.
758
+ function clearPackageManagerVersionCache() {
759
+ packageManagerVersionCache.clear();
536
760
  }
537
761
  /**
538
762
  * Gets the workspaces defined in the package manager configuration.
@@ -125,16 +125,22 @@ export declare function warnDeprecations(opts: {
125
125
  export declare function convertSmartDefaultsIntoNamedParams(opts: {
126
126
  [k: string]: any;
127
127
  }, schema: Schema, defaultProjectName: string | null, relativeCwd: string | null): void;
128
- type Prompt = ConstructorParameters<typeof import('enquirer').Prompt>[0] & {
128
+ type Prompt = {
129
129
  name: string;
130
130
  type: 'input' | 'autocomplete' | 'multiselect' | 'confirm' | 'numeral';
131
131
  message: string;
132
132
  initial?: any;
133
+ /**
134
+ * Retained because {@link getPromptsForSchema} is exported and asserted on;
135
+ * the prompt itself scrolls rather than truncating.
136
+ */
133
137
  limit?: number;
134
138
  choices?: (string | {
135
139
  name: string;
136
140
  message: string;
137
141
  })[];
142
+ /** Returns `true` when valid, otherwise the message to show. */
143
+ validate?: (value: any) => boolean | string;
138
144
  };
139
145
  export declare function getPromptsForSchema(opts: Options, schema: Schema, projectsConfigurations: ProjectsConfigurations): Prompt[];
140
146
  export {};
@@ -14,7 +14,7 @@ exports.warnDeprecations = warnDeprecations;
14
14
  exports.convertSmartDefaultsIntoNamedParams = convertSmartDefaultsIntoNamedParams;
15
15
  exports.getPromptsForSchema = getPromptsForSchema;
16
16
  const logger_1 = require("./logger");
17
- const handle_import_1 = require("./handle-import");
17
+ const prompt_helpers_1 = require("./prompt-helpers");
18
18
  function camelCase(input) {
19
19
  if (input.indexOf('-') > 1) {
20
20
  return input
@@ -658,13 +658,71 @@ function getPromptsForSchema(opts, schema, projectsConfigurations) {
658
658
  return prompts;
659
659
  }
660
660
  async function promptForValues(opts, schema, projectsConfigurations) {
661
- return await (await (0, handle_import_1.handleImport)('enquirer'))
662
- .prompt(getPromptsForSchema(opts, schema, projectsConfigurations))
663
- .then((values) => ({ ...opts, ...values }))
664
- .catch((e) => {
661
+ try {
662
+ const values = {};
663
+ // Asked one at a time; a schema prompt has no cross-question state, so the
664
+ // order is just the schema's own.
665
+ for (const question of getPromptsForSchema(opts, schema, projectsConfigurations)) {
666
+ values[question.name] = await askSchemaQuestion(question);
667
+ }
668
+ return { ...opts, ...values };
669
+ }
670
+ catch (e) {
665
671
  console.error(e);
666
672
  process.exit(1);
667
- });
673
+ }
674
+ }
675
+ async function askSchemaQuestion(question) {
676
+ const validate = question.validate
677
+ ? (value) => {
678
+ const result = question.validate(value);
679
+ return result === true
680
+ ? undefined
681
+ : typeof result === 'string'
682
+ ? result
683
+ : 'Invalid value';
684
+ }
685
+ : undefined;
686
+ const choices = (question.choices ?? []).map((c) => typeof c === 'string' ? { value: c } : { value: c.name, label: c.message });
687
+ switch (question.type) {
688
+ case 'confirm':
689
+ return (0, prompt_helpers_1.confirmationPrompt)({
690
+ message: question.message,
691
+ initial: question.initial !== false,
692
+ });
693
+ case 'multiselect':
694
+ return (0, prompt_helpers_1.multiselectPrompt)({
695
+ message: question.message,
696
+ choices,
697
+ initialValues: Array.isArray(question.initial)
698
+ ? question.initial
699
+ : undefined,
700
+ });
701
+ case 'autocomplete':
702
+ return (0, prompt_helpers_1.selectPrompt)({
703
+ message: question.message,
704
+ choices,
705
+ initial: question.initial,
706
+ });
707
+ case 'numeral': {
708
+ // No numeric prompt; the answer is parsed back so the schema still
709
+ // receives a number.
710
+ const answer = await (0, prompt_helpers_1.textPrompt)({
711
+ message: question.message,
712
+ initialValue: question.initial === undefined ? undefined : String(question.initial),
713
+ validate: (value) => value !== '' && !Number.isNaN(Number(value))
714
+ ? validate?.(Number(value))
715
+ : 'Please enter a number',
716
+ });
717
+ return Number(answer);
718
+ }
719
+ default:
720
+ return (0, prompt_helpers_1.textPrompt)({
721
+ message: question.message,
722
+ initialValue: typeof question.initial === 'string' ? question.initial : undefined,
723
+ validate,
724
+ });
725
+ }
668
726
  }
669
727
  function findSchemaForProperty(propName, schema) {
670
728
  if (propName in schema.properties) {
@@ -42,6 +42,10 @@ exports.CORE_PLUGINS = [
42
42
  name: '@nx/eslint',
43
43
  capabilities: 'executors,generators',
44
44
  },
45
+ {
46
+ name: '@nx/oxlint',
47
+ capabilities: 'generators',
48
+ },
45
49
  {
46
50
  name: '@nx/nest',
47
51
  capabilities: 'generators',
@@ -0,0 +1,53 @@
1
+ export interface Choice<T extends string> {
2
+ value: T;
3
+ label?: string;
4
+ hint?: string;
5
+ }
6
+ /** A bare string is a choice whose label is its value. */
7
+ export type ChoiceOrValue<T extends string> = T | Choice<T>;
8
+ /**
9
+ * Ctrl+C yields a sentinel rather than throwing. `onCancel` decides what that
10
+ * means for the caller - either a fallback answer or an abort. The default
11
+ * aborts with the POSIX interrupt status.
12
+ */
13
+ export type OnCancel<T> = () => T;
14
+ export declare function selectPrompt<T extends string>(options: {
15
+ message: string;
16
+ choices: readonly ChoiceOrValue<T>[];
17
+ initial?: T;
18
+ /** Answer without prompting; defaults to the first choice. */
19
+ skip?: boolean;
20
+ skippedValue?: T;
21
+ onCancel?: OnCancel<T>;
22
+ }): Promise<T>;
23
+ export declare function confirmationPrompt(options: {
24
+ message: string;
25
+ initial?: boolean;
26
+ skip?: boolean;
27
+ skippedValue?: boolean;
28
+ onCancel?: OnCancel<boolean>;
29
+ }): Promise<boolean>;
30
+ export declare function textPrompt(options: {
31
+ message: string;
32
+ initialValue?: string;
33
+ placeholder?: string;
34
+ /**
35
+ * Runs synchronously; clack does not await validators.
36
+ *
37
+ * Always receives a string. clack validates on Enter *before* it coerces an
38
+ * empty submit to `''`, so it would otherwise hand `undefined` to a prompt
39
+ * declaring no `initialValue`; the wrapper below normalizes that, matching
40
+ * what enquirer passed.
41
+ */
42
+ validate?: (value: string) => string | undefined;
43
+ skip?: boolean;
44
+ skippedValue?: string;
45
+ onCancel?: OnCancel<string>;
46
+ }): Promise<string>;
47
+ export declare function multiselectPrompt<T extends string>(options: {
48
+ message: string;
49
+ choices: readonly ChoiceOrValue<T>[];
50
+ required?: boolean;
51
+ initialValues?: readonly T[];
52
+ onCancel?: OnCancel<T[]>;
53
+ }): Promise<T[]>;