@depup/nx 23.1.2-depup.1 → 23.2.0-depup.0

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 (296) hide show
  1. package/README.md +7 -6
  2. package/changes.json +12 -8
  3. package/dist/bin/init-local.js +3 -5
  4. package/dist/bin/nx.js +1 -0
  5. package/dist/src/adapter/ngcli-adapter.js +60 -1
  6. package/dist/src/ai/constants.d.ts +15 -0
  7. package/dist/src/ai/constants.js +17 -1
  8. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +57 -9
  9. package/dist/src/ai/utils.d.ts +13 -0
  10. package/dist/src/ai/utils.js +29 -0
  11. package/dist/src/analytics/analytics.js +2 -4
  12. package/dist/src/command-line/completion/command-object.js +7 -12
  13. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +42 -31
  14. package/dist/src/command-line/format/format.js +84 -101
  15. package/dist/src/command-line/generate/generate.js +35 -35
  16. package/dist/src/command-line/import/import.js +29 -38
  17. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  18. package/dist/src/command-line/init/command-object.js +4 -2
  19. package/dist/src/command-line/init/configure-plugins.js +4 -1
  20. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  21. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  22. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  23. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  24. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  25. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
  26. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  27. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  28. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
  29. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  30. package/dist/src/command-line/init/implementation/format.js +114 -0
  31. package/dist/src/command-line/init/implementation/utils.js +8 -8
  32. package/dist/src/command-line/init/init-v1.js +15 -18
  33. package/dist/src/command-line/init/init-v2.js +77 -66
  34. package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
  35. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
  36. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
  37. package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
  38. package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
  39. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
  40. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
  41. package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
  42. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  43. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  44. package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
  45. package/dist/src/command-line/migrate/agentic/select.js +30 -32
  46. package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
  47. package/dist/src/command-line/migrate/agentic/types.js +35 -0
  48. package/dist/src/command-line/migrate/command-object.d.ts +6 -0
  49. package/dist/src/command-line/migrate/command-object.js +19 -1
  50. package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
  51. package/dist/src/command-line/migrate/execute-migration.js +112 -27
  52. package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
  53. package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
  54. package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
  55. package/dist/src/command-line/migrate/migrate-commits.js +130 -15
  56. package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
  57. package/dist/src/command-line/migrate/migrate-config.js +22 -14
  58. package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
  59. package/dist/src/command-line/migrate/migrate-output.js +52 -8
  60. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  61. package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
  62. package/dist/src/command-line/migrate/migrate.d.ts +24 -55
  63. package/dist/src/command-line/migrate/migrate.js +553 -226
  64. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  65. package/dist/src/command-line/migrate/multi-major.js +7 -10
  66. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  67. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  68. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  69. package/dist/src/command-line/migrate/run/index.d.ts +9 -0
  70. package/dist/src/command-line/migrate/run/index.js +23 -0
  71. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  72. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  73. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  74. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  75. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  76. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  77. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  78. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  79. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  80. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  81. package/dist/src/command-line/migrate/run/util.d.ts +59 -0
  82. package/dist/src/command-line/migrate/run/util.js +148 -0
  83. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  84. package/dist/src/command-line/migrate/run/worker.js +682 -0
  85. package/dist/src/command-line/migrate/run-migration-process.js +6 -5
  86. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  87. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  88. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  89. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  90. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  91. package/dist/src/command-line/migrate/step-actions.js +12 -0
  92. package/dist/src/command-line/migrate/text.d.ts +18 -0
  93. package/dist/src/command-line/migrate/text.js +26 -0
  94. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  95. package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
  96. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
  97. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  98. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  99. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  100. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  101. package/dist/src/command-line/nx-commands.js +26 -24
  102. package/dist/src/command-line/release/changelog.js +6 -17
  103. package/dist/src/command-line/release/plan.js +15 -28
  104. package/dist/src/command-line/release/publish.js +5 -0
  105. package/dist/src/command-line/release/release.js +6 -17
  106. package/dist/src/command-line/release/utils/release-graph.d.ts +1 -0
  107. package/dist/src/command-line/release/utils/release-graph.js +10 -2
  108. package/dist/src/command-line/release/utils/remote-release-clients/github.js +10 -22
  109. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
  110. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  111. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  112. package/dist/src/command-line/release/version.js +2 -2
  113. package/dist/src/command-line/reset/reset.js +17 -15
  114. package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  115. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  116. package/dist/src/config/misc-interfaces.d.ts +19 -7
  117. package/dist/src/core/graph/main.js +1 -1
  118. package/dist/src/core/graph/styles.js +1 -1
  119. package/dist/src/daemon/client/client.d.ts +2 -7
  120. package/dist/src/daemon/client/client.js +113 -28
  121. package/dist/src/daemon/client/daemon-environment.d.ts +35 -0
  122. package/dist/src/daemon/client/daemon-environment.js +106 -6
  123. package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
  124. package/dist/src/daemon/client/daemon-socket-messenger.js +8 -3
  125. package/dist/src/daemon/is-v8-serializer-enabled.d.ts +2 -2
  126. package/dist/src/daemon/is-v8-serializer-enabled.js +2 -2
  127. package/dist/src/daemon/message-types/daemon-message.d.ts +2 -1
  128. package/dist/src/daemon/message-types/daemon-message.js +25 -2
  129. package/dist/src/daemon/sandbox-socket-hint.d.ts +27 -0
  130. package/dist/src/daemon/sandbox-socket-hint.js +136 -0
  131. package/dist/src/daemon/server/client-socket-context.d.ts +1 -1
  132. package/dist/src/daemon/server/client-socket-context.js +2 -3
  133. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
  134. package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
  135. package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
  136. package/dist/src/daemon/server/handle-client-env.js +92 -0
  137. package/dist/src/daemon/server/handle-outputs-changes.d.ts +10 -0
  138. package/dist/src/daemon/server/handle-outputs-changes.js +86 -0
  139. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +21 -0
  140. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +159 -6
  141. package/dist/src/daemon/server/server.js +36 -72
  142. package/dist/src/daemon/server/shutdown-utils.d.ts +1 -1
  143. package/dist/src/daemon/server/shutdown-utils.js +2 -2
  144. package/dist/src/daemon/socket-utils.d.ts +26 -7
  145. package/dist/src/daemon/socket-utils.js +45 -31
  146. package/dist/src/daemon/tmp-dir.d.ts +10 -0
  147. package/dist/src/daemon/tmp-dir.js +21 -37
  148. package/dist/src/devkit-internals.d.ts +20 -9
  149. package/dist/src/devkit-internals.js +49 -6
  150. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  151. package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
  152. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  153. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  154. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  155. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  156. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  157. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  158. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  159. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  160. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  161. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  162. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  163. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  164. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  165. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  166. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  167. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  168. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  169. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  170. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  171. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  172. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  173. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  174. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  175. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  176. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  177. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  178. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +2 -2
  179. package/dist/src/native/index.d.ts +7 -3
  180. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  181. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  182. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  183. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  184. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  185. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  186. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  187. package/dist/src/plugins/js/lock-file/npm-parser.js +10 -3
  188. package/dist/src/plugins/js/lock-file/pnpm-parser.js +356 -62
  189. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  190. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +78 -4
  191. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  192. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  193. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  194. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +6 -5
  195. package/dist/src/plugins/js/utils/register.d.ts +11 -0
  196. package/dist/src/plugins/js/utils/register.js +40 -6
  197. package/dist/src/project-graph/plugins/get-plugins.d.ts +27 -1
  198. package/dist/src/project-graph/plugins/get-plugins.js +110 -5
  199. package/dist/src/project-graph/plugins/isolation/enabled.js +1 -4
  200. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +16 -0
  201. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +69 -11
  202. package/dist/src/project-graph/plugins/isolation/messaging.js +1 -3
  203. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +23 -2
  204. package/dist/src/project-graph/project-graph.js +27 -2
  205. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +7 -0
  206. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +14 -6
  207. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +47 -21
  208. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  209. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  210. package/dist/src/tasks-runner/life-cycle.js +2 -2
  211. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
  212. package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
  213. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  214. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  215. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  216. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  217. package/dist/src/tasks-runner/pseudo-ipc.js +14 -13
  218. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  219. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  220. package/dist/src/tasks-runner/run-command.js +32 -39
  221. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  222. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  223. package/dist/src/tasks-runner/task-env.d.ts +25 -0
  224. package/dist/src/tasks-runner/task-env.js +39 -0
  225. package/dist/src/tasks-runner/task-orchestrator.d.ts +68 -0
  226. package/dist/src/tasks-runner/task-orchestrator.js +159 -8
  227. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  228. package/dist/src/utils/analytics-enabled.js +11 -0
  229. package/dist/src/utils/analytics-prompt.js +4 -7
  230. package/dist/src/utils/cache-directory.d.ts +62 -3
  231. package/dist/src/utils/cache-directory.js +276 -25
  232. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  233. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  234. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  235. package/dist/src/utils/catalog/bun-manager.js +130 -0
  236. package/dist/src/utils/catalog/index.d.ts +1 -1
  237. package/dist/src/utils/catalog/index.js +1 -1
  238. package/dist/src/utils/catalog/manager-factory.js +3 -0
  239. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  240. package/dist/src/utils/catalog/manager-utils.js +9 -4
  241. package/dist/src/utils/catalog/manager.d.ts +13 -1
  242. package/dist/src/utils/catalog/manager.js +30 -0
  243. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  244. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  245. package/dist/src/utils/catalog/types.d.ts +4 -0
  246. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  247. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  248. package/dist/src/utils/child-process.d.ts +31 -1
  249. package/dist/src/utils/child-process.js +103 -0
  250. package/dist/src/utils/chunkify.d.ts +7 -1
  251. package/dist/src/utils/chunkify.js +10 -3
  252. package/dist/src/utils/consume-messages-from-socket.d.ts +42 -7
  253. package/dist/src/utils/consume-messages-from-socket.js +273 -38
  254. package/dist/src/utils/db-connection.js +8 -16
  255. package/dist/src/utils/exit-codes.d.ts +9 -0
  256. package/dist/src/utils/exit-codes.js +19 -0
  257. package/dist/src/utils/formatters/index.d.ts +13 -0
  258. package/dist/src/utils/formatters/index.js +74 -0
  259. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  260. package/dist/src/utils/formatters/oxfmt.js +764 -0
  261. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  262. package/dist/src/utils/formatters/prettier.js +201 -0
  263. package/dist/src/utils/formatters/shared.d.ts +5 -0
  264. package/dist/src/utils/formatters/shared.js +8 -0
  265. package/dist/src/utils/git-utils.d.ts +38 -2
  266. package/dist/src/utils/git-utils.js +422 -19
  267. package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
  268. package/dist/src/utils/has-nx-js-plugin.js +1 -1
  269. package/dist/src/utils/ignore.d.ts +47 -5
  270. package/dist/src/utils/ignore.js +93 -11
  271. package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
  272. package/dist/src/utils/kill-child-on-host-exit.js +42 -0
  273. package/dist/src/utils/nx-console-prompt.js +3 -6
  274. package/dist/src/utils/nx-tmp-dir.d.ts +5 -0
  275. package/dist/src/utils/nx-tmp-dir.js +7 -2
  276. package/dist/src/utils/output.d.ts +153 -0
  277. package/dist/src/utils/output.js +289 -5
  278. package/dist/src/utils/owned-private-dir.d.ts +13 -0
  279. package/dist/src/utils/owned-private-dir.js +39 -0
  280. package/dist/src/utils/package-json.d.ts +2 -0
  281. package/dist/src/utils/package-manager.js +17 -7
  282. package/dist/src/utils/params.d.ts +7 -1
  283. package/dist/src/utils/params.js +64 -6
  284. package/dist/src/utils/permission-errors.d.ts +11 -0
  285. package/dist/src/utils/permission-errors.js +17 -0
  286. package/dist/src/utils/plugins/core-plugins.js +4 -0
  287. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  288. package/dist/src/utils/prompt-helpers.js +111 -0
  289. package/dist/src/utils/socket-refused-exit-code.d.ts +15 -0
  290. package/dist/src/utils/socket-refused-exit-code.js +18 -0
  291. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  292. package/dist/src/utils/write-formatted-json-file.js +5 -4
  293. package/package.json +33 -24
  294. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
  295. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  296. package/dist/src/utils/is-using-prettier.js +0 -62
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configureAiAgentsHandler = configureAiAgentsHandler;
4
4
  exports.configureAiAgentsHandlerImpl = configureAiAgentsHandlerImpl;
5
5
  const tslib_1 = require("tslib");
6
- const enquirer_1 = require("enquirer");
6
+ const prompt_helpers_1 = require("../../utils/prompt-helpers");
7
7
  const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = require("node:path");
9
9
  const pc = tslib_1.__importStar(require("picocolors"));
10
10
  const constants_1 = require("../../ai/constants");
11
11
  const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
12
12
  const utils_1 = require("../../ai/utils");
13
+ const permission_errors_1 = require("../../utils/permission-errors");
13
14
  const client_1 = require("../../daemon/client/client");
14
15
  const package_json_1 = require("../../utils/package-json");
15
16
  const output_1 = require("../../utils/output");
@@ -63,8 +64,10 @@ async function configureAiAgentsHandler(args, inner = false) {
63
64
  await resetDaemonAgentStatus();
64
65
  }
65
66
  async function configureAiAgentsHandlerImpl(options) {
66
- // Node 24 has stricter readline behavior, and enquirer is not checking for closed state
67
- // when invoking operations, thus you get an ERR_USE_AFTER_CLOSE error.
67
+ // Node 24's stricter readline throws ERR_USE_AFTER_CLOSE when a prompt
68
+ // library operates on a closed interface. Added for enquirer, which nx no
69
+ // longer uses; verify against Node 24 before removing.
70
+ // TODO(v24): drop if @clack/prompts proves not to need it.
68
71
  process.on('uncaughtException', (error) => {
69
72
  if (error &&
70
73
  typeof error === 'object' &&
@@ -158,7 +161,7 @@ async function configureAiAgentsHandlerImpl(options) {
158
161
  ...partiallyConfiguredAgents,
159
162
  ...outOfDateAgents,
160
163
  ...nonConfiguredAgents,
161
- ].map((a) => getAgentChoiceForPrompt(a).message),
164
+ ].map((a) => getAgentChoiceForPrompt(a).label),
162
165
  });
163
166
  process.exit(1);
164
167
  }
@@ -212,10 +215,18 @@ async function configureAiAgentsHandlerImpl(options) {
212
215
  }
213
216
  catch (e) {
214
217
  configSpinner.fail('Failed to configure AI agents');
215
- output_1.output.error({
216
- title: 'Error details:',
217
- bodyLines: [e.message],
218
- });
218
+ if ((0, permission_errors_1.isPermissionDenied)(e)) {
219
+ output_1.output.error({
220
+ title: 'Nx was not permitted to write the AI agent configuration',
221
+ bodyLines: (0, utils_1.agentConfigWriteBlockedLines)(e),
222
+ });
223
+ }
224
+ else {
225
+ output_1.output.error({
226
+ title: 'Error details:',
227
+ bodyLines: [e.message],
228
+ });
229
+ }
219
230
  process.exit(1);
220
231
  }
221
232
  }
@@ -239,26 +250,22 @@ async function configureAiAgentsHandlerImpl(options) {
239
250
  }
240
251
  // Interactive mode (or non-interactive with explicit --agents)
241
252
  const allAgentChoices = [];
242
- const preselectedIndices = [];
243
- let currentIndex = 0;
253
+ const preselectedAgents = [];
244
254
  // Partially configured agents first (highest priority)
245
255
  partiallyConfiguredAgents.forEach((a) => {
246
256
  allAgentChoices.push(getAgentChoiceForPrompt(a));
247
- preselectedIndices.push(currentIndex);
248
- currentIndex++;
257
+ preselectedAgents.push(a.name);
249
258
  });
250
259
  // Outdated agents second
251
260
  for (const a of fullyConfiguredAgents) {
252
261
  if (a.outdated) {
253
262
  allAgentChoices.push(getAgentChoiceForPrompt(a));
254
- preselectedIndices.push(currentIndex);
255
- currentIndex++;
263
+ preselectedAgents.push(a.name);
256
264
  }
257
265
  }
258
266
  // Non-configured agents last
259
267
  nonConfiguredAgents.forEach((a) => {
260
268
  allAgentChoices.push(getAgentChoiceForPrompt(a));
261
- currentIndex++;
262
269
  });
263
270
  if (allAgentChoices.length === 0) {
264
271
  output_1.output.success({
@@ -270,18 +277,13 @@ async function configureAiAgentsHandlerImpl(options) {
270
277
  let selectedAgents;
271
278
  if (options.interactive !== false) {
272
279
  try {
273
- selectedAgents = (await (0, enquirer_1.prompt)({
274
- type: 'multiselect',
275
- name: 'agents',
280
+ selectedAgents = await (0, prompt_helpers_1.multiselectPrompt)({
276
281
  message: 'Which AI agents would you like to configure? (space to select, enter to confirm)',
277
282
  choices: allAgentChoices,
278
- initial: preselectedIndices,
283
+ initialValues: preselectedAgents,
279
284
  required: true,
280
- footer: function () {
281
- const focused = this.focused;
282
- return pc.dim(` ${getAgentFooterDescription(focused.agentConfiguration)}`);
283
- },
284
- })).agents;
285
+ onCancel: () => process.exit(1),
286
+ });
285
287
  }
286
288
  catch {
287
289
  process.exit(1);
@@ -289,7 +291,7 @@ async function configureAiAgentsHandlerImpl(options) {
289
291
  }
290
292
  else {
291
293
  // non-interactive with explicit --agents: configure all requested
292
- selectedAgents = allAgentChoices.map((a) => a.name);
294
+ selectedAgents = allAgentChoices.map((a) => a.value);
293
295
  }
294
296
  if (selectedAgents?.length === 0) {
295
297
  output_1.output.log({
@@ -317,10 +319,18 @@ async function configureAiAgentsHandlerImpl(options) {
317
319
  }
318
320
  catch (e) {
319
321
  configSpinner.fail('Failed to set up AI agents');
320
- output_1.output.error({
321
- title: 'Error details:',
322
- bodyLines: [e.message],
323
- });
322
+ if ((0, permission_errors_1.isPermissionDenied)(e)) {
323
+ output_1.output.error({
324
+ title: 'Nx was not permitted to write the AI agent configuration',
325
+ bodyLines: (0, utils_1.agentConfigWriteBlockedLines)(e),
326
+ });
327
+ }
328
+ else {
329
+ output_1.output.error({
330
+ title: 'Error details:',
331
+ bodyLines: [e.message],
332
+ });
333
+ }
324
334
  process.exit(1);
325
335
  }
326
336
  }
@@ -388,10 +398,11 @@ function getAgentChoiceForPrompt(agent) {
388
398
  const partiallyConfigured = agent.mcp !== agent.rules;
389
399
  const needsUpdate = partiallyConfigured || agent.outdated;
390
400
  return {
391
- name: agent.name,
392
- message: needsUpdate
401
+ value: agent.name,
402
+ label: needsUpdate
393
403
  ? `${agent.displayName} (update available)`
394
404
  : agent.displayName,
405
+ hint: getAgentFooterDescription(agent),
395
406
  agentConfiguration: agent,
396
407
  };
397
408
  }
@@ -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([