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
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.format = format;
4
4
  const tslib_1 = require("tslib");
5
- const node_child_process_1 = require("node:child_process");
6
5
  const path = tslib_1.__importStar(require("node:path"));
7
- const semver_1 = require("semver");
8
6
  const configuration_1 = require("../../config/configuration");
9
7
  const typescript_1 = require("../../plugins/js/utils/typescript");
10
8
  const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
@@ -13,59 +11,81 @@ const project_graph_1 = require("../../project-graph/project-graph");
13
11
  const chunkify_1 = require("../../utils/chunkify");
14
12
  const command_line_utils_1 = require("../../utils/command-line-utils");
15
13
  const fileutils_1 = require("../../utils/fileutils");
16
- const handle_import_1 = require("../../utils/handle-import");
14
+ const formatters_1 = require("../../utils/formatters");
15
+ const oxfmt_1 = require("../../utils/formatters/oxfmt");
16
+ const prettier_1 = require("../../utils/formatters/prettier");
17
17
  const ignore_1 = require("../../utils/ignore");
18
18
  const object_sort_1 = require("../../utils/object-sort");
19
19
  const output_1 = require("../../utils/output");
20
- const package_json_1 = require("../../utils/package-json");
21
20
  const workspace_root_1 = require("../../utils/workspace-root");
21
+ /**
22
+ * A table, not a `switch`: this lookup sits inside a `try` whose `catch`
23
+ * reports "configured but not installed", and a `never` arm would throw into
24
+ * that catch and be misreported. A missing member is a compile error here.
25
+ */
26
+ const resolveFormatterBin = {
27
+ oxfmt: oxfmt_1.getOxfmtBinPath,
28
+ prettier: prettier_1.getPrettierPath,
29
+ };
22
30
  async function format(command, args) {
23
- let prettier;
31
+ const formatterType = (0, formatters_1.detectFormatter)(workspace_root_1.workspaceRoot);
32
+ if (!formatterType) {
33
+ output_1.output.warn({
34
+ title: 'No formatter configured.',
35
+ bodyLines: ['Install oxfmt or prettier to enable formatting.'],
36
+ });
37
+ return;
38
+ }
39
+ // Detection reads configuration only, so a workspace can be configured for a
40
+ // formatter that is not installed - a fresh clone, `--omit=dev` CI, a pruned
41
+ // node_modules. Resolving now turns a raw MODULE_NOT_FOUND into something
42
+ // actionable.
24
43
  try {
25
- prettier = await (0, handle_import_1.handleImport)('prettier');
44
+ resolveFormatterBin[formatterType]();
26
45
  }
27
46
  catch {
28
47
  output_1.output.error({
29
- title: 'Prettier is not installed.',
48
+ title: `${formatterType} is configured for this workspace but is not installed.`,
30
49
  bodyLines: [
31
- `Please install "prettier" and try again, or don't run the "nx format:${command}" command.`,
50
+ `Install "${formatterType}" and try again, or remove its configuration to disable "nx format:${command}".`,
32
51
  ],
33
52
  });
34
53
  process.exit(1);
35
54
  }
36
55
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: false }, (0, configuration_1.readNxJson)());
37
- const patterns = (await getPatterns(prettier, { ...args, ...nxArgs })).map((p) => {
38
- // On non-Windows, escape $ to prevent shell variable interpolation
39
- // (the shell consumes one \, so \\$ becomes \$ which the shell treats as literal $)
40
- // On Windows (cmd.exe), $ is not a special character, so escaping it would
41
- // cause prettier to look for a file with a literal \$ in the name
42
- // prettier-ignore
43
- const escaped = process.platform !== 'win32' ? p.replace(/\$/g, '\\\$') : p;
44
- return `"${escaped}"`;
56
+ // Patterns are kept raw here. Prettier is invoked through a shell so it
57
+ // quotes them at the call site; oxfmt is invoked with execFile and needs
58
+ // the unquoted paths.
59
+ const patterns = await getPatterns(formatterType, {
60
+ ...args,
61
+ ...nxArgs,
45
62
  });
46
- // Chunkify the patterns array to prevent crashing the windows terminal
47
- const chunkList = (0, chunkify_1.chunkify)(patterns);
63
+ // Chunkify the patterns array to prevent crashing the windows terminal.
64
+ // The prettier path quotes each pattern on its way to the shell, so size the
65
+ // chunks against that; oxfmt goes through execFile and gets them raw.
66
+ const chunkList = (0, chunkify_1.chunkify)(patterns, undefined, formatterType === 'prettier'
67
+ ? (pattern) => (0, prettier_1.quoteForShell)(pattern).length
68
+ : undefined);
48
69
  switch (command) {
49
70
  case 'write':
50
71
  if (nxArgs.sortRootTsconfigPaths) {
51
72
  sortTsConfig();
52
73
  }
53
74
  addRootConfigFiles(chunkList, nxArgs);
54
- chunkList.forEach((chunk) => write(prettier, chunk));
75
+ chunkList.forEach((chunk) => write(formatterType, chunk));
55
76
  break;
56
77
  case 'check': {
57
78
  const filesWithDifferentFormatting = [];
58
79
  for (const chunk of chunkList) {
59
- const files = await check(chunk);
80
+ const files = await check(formatterType, chunk);
60
81
  filesWithDifferentFormatting.push(...files);
61
82
  }
62
83
  if (filesWithDifferentFormatting.length > 0) {
63
84
  if (nxArgs.verbose) {
64
85
  output_1.output.error({
65
- title: 'The following files are not formatted correctly based on your Prettier configuration',
86
+ title: 'The following files are not formatted correctly',
66
87
  bodyLines: [
67
88
  '- Run "nx format:write" and commit the resulting diff to fix these files.',
68
- '- Please note, Prettier does not support a native way to diff the output of its check logic (https://github.com/prettier/prettier/issues/6885).',
69
89
  '',
70
90
  ...filesWithDifferentFormatting,
71
91
  ],
@@ -80,7 +100,7 @@ async function format(command, args) {
80
100
  }
81
101
  }
82
102
  }
83
- async function getPatterns(prettier, args) {
103
+ async function getPatterns(formatterType, args) {
84
104
  const allFilesPattern = ['.'];
85
105
  if (args.all) {
86
106
  return allFilesPattern;
@@ -91,16 +111,16 @@ async function getPatterns(prettier, args) {
91
111
  return getPatternsFromProjects(args.projects, graph);
92
112
  }
93
113
  const p = (0, command_line_utils_1.parseFiles)(args);
94
- const supportedExtensions = new Set((await prettier.getSupportInfo()).languages
95
- .flatMap((language) => language.extensions)
96
- .filter((extension) => !!extension)
97
- // Prettier supports ".swcrc" as a file instead of an extension
98
- // So we add ".swcrc" as a supported extension manually
99
- // which allows it to be considered for calculating "patterns"
100
- .concat('.swcrc'));
101
- const patterns = p.files
114
+ // Deleted files still show up in the changed-file set, and neither
115
+ // formatter should be handed a path that is no longer there.
116
+ let patterns = p.files
102
117
  .map((f) => path.relative(workspace_root_1.workspaceRoot, f))
103
- .filter((f) => (0, fileutils_1.fileExists)(f) && supportedExtensions.has(path.extname(f)));
118
+ .filter((f) => (0, fileutils_1.fileExists)(f));
119
+ if (formatterType === 'prettier') {
120
+ // oxfmt needs no equivalent filter - it silently skips file types it
121
+ // does not handle, and its base args keep an all-skipped run green.
122
+ patterns = await (0, prettier_1.filterToPrettierSupportedFiles)(patterns);
123
+ }
104
124
  // exclude patterns in .nxignore or .gitignore
105
125
  const nonIgnoredPatterns = (0, ignore_1.getIgnoreObject)().filter(patterns);
106
126
  if (args.libsAndApps) {
@@ -130,13 +150,10 @@ function addRootConfigFiles(chunkList, nxArgs) {
130
150
  }
131
151
  const chunk = [];
132
152
  const addToChunkIfNeeded = (file) => {
133
- if (chunkList.every((c) => !c.includes(`"${file}"`))) {
153
+ if (chunkList.every((c) => !c.includes(file))) {
134
154
  chunk.push(file);
135
155
  }
136
156
  };
137
- // if (workspaceJsonPath) {
138
- // addToChunkIfNeeded(workspaceJsonPath);
139
- // }
140
157
  ['nx.json', (0, typescript_1.getRootTsConfigFileName)()]
141
158
  .filter(Boolean)
142
159
  .forEach(addToChunkIfNeeded);
@@ -147,49 +164,43 @@ function addRootConfigFiles(chunkList, nxArgs) {
147
164
  function getPatternsFromProjects(projects, projectGraph) {
148
165
  return (0, command_line_utils_1.getProjectRoots)(projects, projectGraph);
149
166
  }
150
- function write(prettier, patterns) {
151
- if (patterns.length > 0) {
152
- const [swcrcPatterns, regularPatterns] = patterns.reduce((result, pattern) => {
153
- result[pattern.includes('.swcrc') ? 0 : 1].push(pattern);
154
- return result;
155
- }, [[], []]);
156
- const prettierPath = getPrettierPath();
157
- const listDifferentArg = shouldUseListDifferent(prettier.version)
158
- ? '--list-different '
159
- : '';
160
- (0, node_child_process_1.execSync)(`node "${prettierPath}" --write ${listDifferentArg}${regularPatterns.join(' ')}`, {
161
- stdio: [0, 1, 2],
162
- windowsHide: true,
163
- });
164
- if (swcrcPatterns.length > 0) {
165
- (0, node_child_process_1.execSync)(`node "${prettierPath}" --write ${listDifferentArg}${swcrcPatterns.join(' ')} --parser json`, {
166
- stdio: [0, 1, 2],
167
- windowsHide: true,
168
- });
167
+ function write(formatterType, patterns) {
168
+ if (patterns.length === 0) {
169
+ return;
170
+ }
171
+ switch (formatterType) {
172
+ case 'oxfmt':
173
+ (0, oxfmt_1.writeWithOxfmt)(patterns);
174
+ break;
175
+ case 'prettier':
176
+ (0, prettier_1.writeWithPrettier)(patterns);
177
+ break;
178
+ default: {
179
+ // Without this, an unhandled formatter makes `nx format:write` exit 0
180
+ // having formatted nothing, while `check()` throws - the two halves of
181
+ // the same command disagreeing.
182
+ const unhandled = formatterType;
183
+ throw new Error(`Unhandled formatter: ${unhandled}`);
169
184
  }
170
185
  }
171
186
  }
172
- async function check(patterns) {
187
+ async function check(formatterType, patterns) {
173
188
  if (patterns.length === 0) {
174
189
  return [];
175
190
  }
176
- const prettierPath = getPrettierPath();
177
- return new Promise((resolve, reject) => {
178
- (0, node_child_process_1.exec)(`node "${prettierPath}" --list-different ${patterns.join(' ')}`, { encoding: 'utf-8', windowsHide: true }, (error, stdout) => {
179
- if (error) {
180
- // The command failed because Prettier threw an error.
181
- if (stdout.length === 0) {
182
- reject(error);
183
- }
184
- // The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated.
185
- resolve(stdout.trim().split('\n'));
186
- }
187
- else {
188
- // The command succeeded so there are no files with different formatting
189
- resolve([]);
190
- }
191
- });
192
- });
191
+ switch (formatterType) {
192
+ case 'oxfmt':
193
+ return (0, oxfmt_1.checkWithOxfmt)(patterns);
194
+ case 'prettier':
195
+ return (0, prettier_1.checkWithPrettier)(patterns);
196
+ default: {
197
+ // `strict: false` does not make a missing case an error on its own, but
198
+ // it does reject this assignment - so adding a formatter fails to compile
199
+ // here instead of returning undefined into a caller that spreads it.
200
+ const unhandled = formatterType;
201
+ throw new Error(`Unhandled formatter: ${unhandled}`);
202
+ }
203
+ }
193
204
  }
194
205
  function sortTsConfig() {
195
206
  try {
@@ -203,31 +214,3 @@ function sortTsConfig() {
203
214
  // catch noop
204
215
  }
205
216
  }
206
- let prettierPath;
207
- function getPrettierPath() {
208
- if (prettierPath) {
209
- return prettierPath;
210
- }
211
- const { packageJson, path: packageJsonPath } = (0, package_json_1.readModulePackageJson)('prettier');
212
- const bin = packageJson.bin;
213
- const binPath = typeof bin === 'string' ? bin : bin?.['prettier'];
214
- if (!binPath) {
215
- throw new Error(`Could not find prettier binary in ${packageJsonPath}`);
216
- }
217
- prettierPath = path.resolve(path.dirname(packageJsonPath), binPath);
218
- return prettierPath;
219
- }
220
- let useListDifferent;
221
- /**
222
- * Determines if --list-different should be used with --write.
223
- * Prettier 4+ and 3.6.x with experimental CLI don't support combining these flags.
224
- */
225
- function shouldUseListDifferent(prettierVersion) {
226
- if (useListDifferent !== undefined) {
227
- return useListDifferent;
228
- }
229
- const prettierMajor = (0, semver_1.major)(prettierVersion);
230
- const isExperimentalCli = process.env.PRETTIER_EXPERIMENTAL_CLI === '1';
231
- useListDifferent = prettierMajor < 4 && !isExperimentalCli;
232
- return useListDifferent;
233
- }
@@ -6,7 +6,7 @@ exports.printGenHelp = printGenHelp;
6
6
  exports.generate = generate;
7
7
  const tslib_1 = require("tslib");
8
8
  const pc = tslib_1.__importStar(require("picocolors"));
9
- const enquirer_1 = require("enquirer");
9
+ const prompt_helpers_1 = require("../../utils/prompt-helpers");
10
10
  const path_1 = require("path");
11
11
  const configuration_1 = require("../../config/configuration");
12
12
  const tree_1 = require("../../generators/tree");
@@ -91,42 +91,42 @@ async function promptForCollection(generatorName, interactive, projectsConfigura
91
91
  throwInvalidInvocation(Array.from(choicesMap));
92
92
  }
93
93
  else if (interactive && choices.length > 1) {
94
- const noneOfTheAbove = `\nNone of the above`;
94
+ const noneOfTheAbove = `None of the above`;
95
+ // Blank line before the last entry. The newline has to trail the choice
96
+ // *before* the gap: a leading one would land between the following
97
+ // choice's radio marker and its text, splitting that row in two.
98
+ const beforeGap = choices.length - 1;
95
99
  choices.push(noneOfTheAbove);
96
- let { generator, customCollection } = await (0, enquirer_1.prompt)([
97
- {
98
- name: 'generator',
99
- message: `Which generator would you like to use?`,
100
- type: 'autocomplete',
101
- // enquirer's typings are incorrect here... It supports (string | Choice)[], but is typed as (string[] | Choice[])
102
- choices: choices,
103
- },
104
- {
105
- name: 'customCollection',
106
- type: 'input',
107
- message: `Which collection would you like to use?`,
108
- skip: function () {
109
- // Skip this question if the user did not answer None of the above
110
- return this.state.answers.generator !== noneOfTheAbove;
111
- },
112
- validate: function (value) {
113
- if (this.skipped) {
114
- return true;
115
- }
116
- try {
117
- (0, generator_utils_1.getGeneratorInformation)(value, generatorName, workspace_root_1.workspaceRoot, projectsConfiguration.projects);
118
- return true;
119
- }
120
- catch {
121
- logger_1.logger.error(`\nCould not find ${value}:${generatorName}`);
122
- return false;
123
- }
124
- },
100
+ const generator = await (0, prompt_helpers_1.selectPrompt)({
101
+ message: `Which generator would you like to use?`,
102
+ // Local-plugin entries carry a separate display label; the rest are
103
+ // plain collection names. Only the label takes the newline, so the
104
+ // value still resolves as a collection name.
105
+ choices: choices.map((c, i) => {
106
+ const choice = typeof c === 'string'
107
+ ? { value: c, label: c }
108
+ : { value: c.value, label: c.message };
109
+ return i === beforeGap && !choice.label.endsWith('\n')
110
+ ? { ...choice, label: `${choice.label}\n` }
111
+ : choice;
112
+ }),
113
+ });
114
+ if (generator !== noneOfTheAbove) {
115
+ return generator;
116
+ }
117
+ const customCollection = await (0, prompt_helpers_1.textPrompt)({
118
+ message: `Which collection would you like to use?`,
119
+ validate: (value) => {
120
+ try {
121
+ (0, generator_utils_1.getGeneratorInformation)(value, generatorName, workspace_root_1.workspaceRoot, projectsConfiguration.projects);
122
+ return undefined;
123
+ }
124
+ catch {
125
+ return `Could not find ${value}:${generatorName}`;
126
+ }
125
127
  },
126
- ]);
127
- return customCollection
128
- ? `${customCollection}:${generatorName}`
129
- : generator;
128
+ });
129
+ return `${customCollection}:${generatorName}`;
130
130
  }
131
131
  else if (deprecatedChoices.size > 0) {
132
132
  throw new Error([
@@ -50,6 +50,7 @@ export declare function generateGraph(args: {
50
50
  exclude?: string[];
51
51
  affected?: boolean;
52
52
  }, affectedProjects: string[]): Promise<void>;
53
+ export declare function getExpandedTaskInputs(depGraphClientResponse: ProjectGraphClientResponse, expandedTaskInputsCache: Map<string, Record<string, string[]>>, taskId: string): Promise<Record<string, string[]>>;
53
54
  /**
54
55
  * The data type that `nx graph --file graph.json` or `nx build --graph graph.json` contains
55
56
  */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateGraph = generateGraph;
4
+ exports.getExpandedTaskInputs = getExpandedTaskInputs;
4
5
  const tslib_1 = require("tslib");
5
6
  const crypto_1 = require("crypto");
6
7
  const node_child_process_1 = require("node:child_process");
@@ -9,7 +10,6 @@ const daemon_socket_messenger_1 = require("../../daemon/client/daemon-socket-mes
9
10
  const http = tslib_1.__importStar(require("node:http"));
10
11
  const minimatch_1 = require("minimatch");
11
12
  const node_url_1 = require("node:url");
12
- const open_1 = tslib_1.__importDefault(require("open"));
13
13
  const node_path_1 = require("node:path");
14
14
  const net = tslib_1.__importStar(require("node:net"));
15
15
  const node_perf_hooks_1 = require("node:perf_hooks");
@@ -34,6 +34,7 @@ const create_task_hasher_1 = require("../../hasher/create-task-hasher");
34
34
  const task_env_1 = require("../../tasks-runner/task-env");
35
35
  const error_types_1 = require("../../project-graph/error-types");
36
36
  const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
37
+ const split_target_1 = require("../../utils/split-target");
37
38
  // maps file extention to MIME types
38
39
  const mimeType = {
39
40
  '.ico': 'image/x-icon',
@@ -349,7 +350,11 @@ async function generateGraph(args, affectedProjects) {
349
350
  title: `Project graph started at ${url.toString()}`,
350
351
  });
351
352
  if (args.open) {
352
- (0, open_1.default)(url.toString());
353
+ new Function('return import("open")')()
354
+ .then((m) => m.default(url.toString()))
355
+ .catch(() => {
356
+ // Ignore errors when opening browser (e.g. no browser available)
357
+ });
353
358
  }
354
359
  return new Promise((res) => {
355
360
  app.once('close', res);
@@ -438,7 +443,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
438
443
  node_perf_hooks_1.performance.mark('task input generation:start');
439
444
  const taskId = parsedUrl.searchParams.get('taskId');
440
445
  res.writeHead(200, { 'Content-Type': 'application/json' });
441
- const inputs = await getExpandedTaskInputs(taskId);
446
+ const inputs = await getExpandedTaskInputs(currentProjectGraphClientResponse, expandedTaskInputsCache, taskId);
442
447
  node_perf_hooks_1.performance.mark('task input generation:end');
443
448
  res.end(JSON.stringify({ [taskId]: inputs }));
444
449
  node_perf_hooks_1.performance.measure('task input generation', 'task input generation:start', 'task input generation:end');
@@ -823,19 +828,23 @@ async function createTaskGraphForTargetsAndProjects(targetNames, projectNames, c
823
828
  };
824
829
  }
825
830
  }
826
- async function getExpandedTaskInputs(taskId) {
831
+ async function getExpandedTaskInputs(depGraphClientResponse, expandedTaskInputsCache, taskId) {
827
832
  // Check cache first
828
833
  if (expandedTaskInputsCache.has(taskId)) {
829
834
  return expandedTaskInputsCache.get(taskId);
830
835
  }
831
836
  // Use the optimized version that only creates the specific task graph needed
832
- const [projectName, targetName, configuration] = taskId.split(':');
837
+ // Use colon-aware splitting so that target names containing colons
838
+ // (e.g. "test:integration") are parsed correctly instead of being
839
+ // mistaken for a target + configuration pair.
840
+ const projectNodes = Object.fromEntries(depGraphClientResponse.projects.map((p) => [p.name, p]));
841
+ const [projectName, targetName, configuration] = (0, split_target_1.splitTargetFromNodes)(taskId, projectNodes, { silent: true });
833
842
  const taskGraphResponse = await createTaskGraphForTargetsAndProjects([targetName], [projectName], configuration);
834
843
  const allWorkspaceFiles = await (0, all_file_data_1.allFileData)();
835
844
  const inputs = taskGraphResponse.plans?.[taskId];
836
845
  let result = {};
837
846
  if (inputs) {
838
- result = expandInputs(inputs, currentProjectGraphClientResponse.projects.find((p) => p.name === projectName), allWorkspaceFiles, currentProjectGraphClientResponse);
847
+ result = expandInputs(inputs, depGraphClientResponse.projects.find((p) => p.name === projectName), allWorkspaceFiles, depGraphClientResponse);
839
848
  }
840
849
  // Cache the result
841
850
  expandedTaskInputsCache.set(taskId, result);
@@ -8,7 +8,7 @@ const pc = tslib_1.__importStar(require("picocolors"));
8
8
  const git_utils_1 = require("../../utils/git-utils");
9
9
  const promises_1 = require("node:fs/promises");
10
10
  const tmp_1 = require("tmp");
11
- const enquirer_1 = require("enquirer");
11
+ const prompt_helpers_1 = require("../../utils/prompt-helpers");
12
12
  const output_1 = require("../../utils/output");
13
13
  const createSpinner = require('ora');
14
14
  const init_v2_1 = require("../init/init-v2");
@@ -23,10 +23,10 @@ const prepare_source_repo_1 = require("./utils/prepare-source-repo");
23
23
  const merge_remote_source_1 = require("./utils/merge-remote-source");
24
24
  const minimatch_1 = require("minimatch");
25
25
  const configure_plugins_1 = require("../init/configure-plugins");
26
+ const format_1 = require("../init/implementation/format");
26
27
  const check_compatible_with_plugins_1 = require("../init/implementation/check-compatible-with-plugins");
27
28
  const native_1 = require("../../native");
28
29
  const ai_output_1 = require("./utils/ai-output");
29
- const init_v2_2 = require("../init/init-v2");
30
30
  const importRemoteName = '__tmp_nx_import__';
31
31
  async function importHandler(options) {
32
32
  process.env.NX_RUNNING_NX_IMPORT = 'true';
@@ -77,14 +77,10 @@ async function importHandler(options) {
77
77
  }
78
78
  const tempImportDirectory = (0, path_1.join)(tmp_1.tmpdir, 'nx-import');
79
79
  if (!sourceRepository) {
80
- sourceRepository = (await (0, enquirer_1.prompt)([
81
- {
82
- type: 'input',
83
- name: 'sourceRepository',
84
- message: 'What is the URL of the repository you want to import? (This can be a local git repository or a git remote URL)',
85
- required: true,
86
- },
87
- ])).sourceRepository;
80
+ sourceRepository = await (0, prompt_helpers_1.textPrompt)({
81
+ message: 'What is the URL of the repository you want to import? (This can be a local git repository or a git remote URL)',
82
+ validate: (value) => (value ? undefined : 'A repository is required'),
83
+ });
88
84
  }
89
85
  try {
90
86
  const maybeLocalDirectory = await (0, promises_1.stat)(sourceRepository);
@@ -132,19 +128,10 @@ async function importHandler(options) {
132
128
  throw new Error('The --ref option is required when running in agent mode.');
133
129
  }
134
130
  const branchChoices = await sourceGitClient.listBranches();
135
- ref = (await (0, enquirer_1.prompt)([
136
- {
137
- type: 'autocomplete',
138
- name: 'ref',
139
- message: `Which branch do you want to import?`,
140
- choices: branchChoices,
141
- /**
142
- * Limit the number of choices so that it fits on screen
143
- */
144
- limit: process.stdout.rows - 3,
145
- required: true,
146
- },
147
- ])).ref;
131
+ ref = await (0, prompt_helpers_1.selectPrompt)({
132
+ message: `Which branch do you want to import?`,
133
+ choices: branchChoices,
134
+ });
148
135
  }
149
136
  if (!source) {
150
137
  if (aiMode) {
@@ -152,28 +139,20 @@ async function importHandler(options) {
152
139
  source = '.';
153
140
  }
154
141
  else {
155
- source = (await (0, enquirer_1.prompt)([
156
- {
157
- type: 'input',
158
- name: 'source',
159
- message: `Which directory do you want to import into this workspace? (leave blank to import the entire repository)`,
160
- },
161
- ])).source;
142
+ source = await (0, prompt_helpers_1.textPrompt)({
143
+ message: `Which directory do you want to import into this workspace? (leave blank to import the entire repository)`,
144
+ });
162
145
  }
163
146
  }
164
147
  if (!destination) {
165
148
  if (aiMode) {
166
149
  throw new Error('The --destination option is required when running in agent mode.');
167
150
  }
168
- destination = (await (0, enquirer_1.prompt)([
169
- {
170
- type: 'input',
171
- name: 'destination',
172
- message: 'Where in this workspace should the code be imported into?',
173
- required: true,
174
- initial: source ? source : undefined,
175
- },
176
- ])).destination;
151
+ destination = await (0, prompt_helpers_1.textPrompt)({
152
+ message: 'Where in this workspace should the code be imported into?',
153
+ initialValue: source ? source : undefined,
154
+ validate: (value) => (value ? undefined : 'A destination is required'),
155
+ });
177
156
  }
178
157
  const absSource = (0, path_1.join)(sourceTempRepoPath, source);
179
158
  if ((0, path_1.isAbsolute)(destination)) {
@@ -282,6 +261,7 @@ async function importHandler(options) {
282
261
  const incompatiblePlugins = await (0, check_compatible_with_plugins_1.checkCompatibleWithPlugins)();
283
262
  if (Object.keys(incompatiblePlugins).length > 0) {
284
263
  (0, check_compatible_with_plugins_1.updatePluginsInNxJson)(workspace_root_1.workspaceRoot, incompatiblePlugins);
264
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
285
265
  await destinationGitClient.amendCommit();
286
266
  }
287
267
  }
@@ -290,6 +270,7 @@ async function importHandler(options) {
290
270
  if (installed) {
291
271
  const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
292
272
  if (succeededPlugins.length > 0) {
273
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
293
274
  await destinationGitClient.amendCommit();
294
275
  }
295
276
  }
@@ -361,7 +342,7 @@ async function importHandler(options) {
361
342
  (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildImportNeedsPluginSelectionResult)({
362
343
  detectedPlugins: detectedButNotInstalled.map((name) => ({
363
344
  name,
364
- reason: (0, init_v2_2.getPluginReason)(name),
345
+ reason: (0, init_v2_1.getPluginReason)(name),
365
346
  })),
366
347
  sourceRepository,
367
348
  ref,
@@ -456,6 +437,7 @@ async function handlePluginOnlyMode(options, destinationGitClient, verbose) {
456
437
  if (installed) {
457
438
  const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
458
439
  if (succeededPlugins.length > 0) {
440
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
459
441
  await destinationGitClient.amendCommit();
460
442
  }
461
443
  }
@@ -490,6 +472,7 @@ async function runInstallDestinationRepo(packageManager, destinationGitClient) {
490
472
  title: 'Installing dependencies for imported code',
491
473
  });
492
474
  (0, utils_1.runInstall)(workspace_root_1.workspaceRoot, packageManager, (0, package_manager_1.getPackageManagerCommand)(packageManager));
475
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
493
476
  await destinationGitClient.amendCommit();
494
477
  }
495
478
  catch (e) {
@@ -506,6 +489,7 @@ async function runPluginsInstall(plugins, pmc, destinationGitClient) {
506
489
  output_1.output.log({ title: 'Installing Plugins' });
507
490
  try {
508
491
  (0, configure_plugins_1.installPluginPackages)(workspace_root_1.workspaceRoot, pmc, plugins);
492
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
509
493
  await destinationGitClient.amendCommit();
510
494
  }
511
495
  catch (e) {
@@ -583,6 +567,12 @@ async function handleMissingWorkspacesEntry(pm, pmc, pkgPath, destinationGitClie
583
567
  return;
584
568
  }
585
569
  (0, package_manager_1.addPackagePathToWorkspaces)(pkgPath, pm, workspaces, workspace_root_1.workspaceRoot);
570
+ // That helper is shared, so it does not record for us - without this the
571
+ // drain below has nothing to do and the rewritten file ships unformatted.
572
+ // It writes pnpm-workspace.yaml for pnpm and package.json for the rest, so
573
+ // recording package.json unconditionally records a file it never touched.
574
+ (0, format_1.recordInitWrite)((0, path_1.join)(workspace_root_1.workspaceRoot, pm === 'pnpm' ? 'pnpm-workspace.yaml' : 'package.json'));
575
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
586
576
  await destinationGitClient.amendCommit();
587
577
  output_1.output.success({
588
578
  title: `Project added in workspaces`,
@@ -1,2 +1,2 @@
1
1
  import { Agent } from '../../ai/utils';
2
- export declare function determineAiAgents(aiAgents?: Agent[], interactive?: boolean): Promise<Agent[]>;
2
+ export declare function determineAiAgents(aiAgents?: (Agent | 'none')[], interactive?: boolean): Promise<Agent[]>;