@depup/nx 23.1.3-depup.0 → 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 (294) hide show
  1. package/README.md +5 -4
  2. package/changes.json +10 -6
  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/sandbox-socket-hint.d.ts +27 -0
  128. package/dist/src/daemon/sandbox-socket-hint.js +136 -0
  129. package/dist/src/daemon/server/client-socket-context.d.ts +1 -1
  130. package/dist/src/daemon/server/client-socket-context.js +2 -3
  131. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
  132. package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
  133. package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
  134. package/dist/src/daemon/server/handle-client-env.js +92 -0
  135. package/dist/src/daemon/server/handle-outputs-changes.d.ts +10 -0
  136. package/dist/src/daemon/server/handle-outputs-changes.js +86 -0
  137. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +21 -0
  138. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +159 -6
  139. package/dist/src/daemon/server/server.js +36 -72
  140. package/dist/src/daemon/server/shutdown-utils.d.ts +1 -1
  141. package/dist/src/daemon/server/shutdown-utils.js +2 -2
  142. package/dist/src/daemon/socket-utils.d.ts +26 -7
  143. package/dist/src/daemon/socket-utils.js +45 -31
  144. package/dist/src/daemon/tmp-dir.d.ts +10 -0
  145. package/dist/src/daemon/tmp-dir.js +21 -37
  146. package/dist/src/devkit-internals.d.ts +19 -8
  147. package/dist/src/devkit-internals.js +47 -6
  148. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  149. package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
  150. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  151. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  152. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  153. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  154. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  155. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  156. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  157. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  158. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  159. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  160. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  161. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  162. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  163. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  164. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  165. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  166. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  167. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  168. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  169. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  170. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  171. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  172. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  173. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  174. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  175. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  176. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +2 -2
  177. package/dist/src/native/index.d.ts +7 -3
  178. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  179. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  180. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  181. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  182. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  183. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  184. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  185. package/dist/src/plugins/js/lock-file/npm-parser.js +10 -3
  186. package/dist/src/plugins/js/lock-file/pnpm-parser.js +356 -62
  187. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  188. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +78 -4
  189. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  190. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  191. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  192. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +6 -5
  193. package/dist/src/plugins/js/utils/register.d.ts +11 -0
  194. package/dist/src/plugins/js/utils/register.js +40 -6
  195. package/dist/src/project-graph/plugins/get-plugins.d.ts +27 -1
  196. package/dist/src/project-graph/plugins/get-plugins.js +110 -5
  197. package/dist/src/project-graph/plugins/isolation/enabled.js +1 -4
  198. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +16 -0
  199. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +69 -11
  200. package/dist/src/project-graph/plugins/isolation/messaging.js +1 -3
  201. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +23 -2
  202. package/dist/src/project-graph/project-graph.js +27 -2
  203. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +7 -0
  204. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +14 -6
  205. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +47 -21
  206. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  207. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  208. package/dist/src/tasks-runner/life-cycle.js +2 -2
  209. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
  210. package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
  211. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  212. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  213. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  214. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  215. package/dist/src/tasks-runner/pseudo-ipc.js +14 -13
  216. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  217. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  218. package/dist/src/tasks-runner/run-command.js +32 -39
  219. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  220. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  221. package/dist/src/tasks-runner/task-env.d.ts +25 -0
  222. package/dist/src/tasks-runner/task-env.js +39 -0
  223. package/dist/src/tasks-runner/task-orchestrator.d.ts +68 -0
  224. package/dist/src/tasks-runner/task-orchestrator.js +159 -8
  225. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  226. package/dist/src/utils/analytics-enabled.js +11 -0
  227. package/dist/src/utils/analytics-prompt.js +4 -7
  228. package/dist/src/utils/cache-directory.d.ts +62 -3
  229. package/dist/src/utils/cache-directory.js +276 -25
  230. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  231. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  232. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  233. package/dist/src/utils/catalog/bun-manager.js +130 -0
  234. package/dist/src/utils/catalog/index.d.ts +1 -1
  235. package/dist/src/utils/catalog/index.js +1 -1
  236. package/dist/src/utils/catalog/manager-factory.js +3 -0
  237. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  238. package/dist/src/utils/catalog/manager-utils.js +9 -4
  239. package/dist/src/utils/catalog/manager.d.ts +13 -1
  240. package/dist/src/utils/catalog/manager.js +30 -0
  241. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  242. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  243. package/dist/src/utils/catalog/types.d.ts +4 -0
  244. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  245. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  246. package/dist/src/utils/child-process.d.ts +31 -1
  247. package/dist/src/utils/child-process.js +103 -0
  248. package/dist/src/utils/chunkify.d.ts +7 -1
  249. package/dist/src/utils/chunkify.js +10 -3
  250. package/dist/src/utils/consume-messages-from-socket.d.ts +42 -7
  251. package/dist/src/utils/consume-messages-from-socket.js +273 -38
  252. package/dist/src/utils/db-connection.js +8 -16
  253. package/dist/src/utils/exit-codes.d.ts +9 -0
  254. package/dist/src/utils/exit-codes.js +19 -0
  255. package/dist/src/utils/formatters/index.d.ts +13 -0
  256. package/dist/src/utils/formatters/index.js +74 -0
  257. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  258. package/dist/src/utils/formatters/oxfmt.js +764 -0
  259. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  260. package/dist/src/utils/formatters/prettier.js +201 -0
  261. package/dist/src/utils/formatters/shared.d.ts +5 -0
  262. package/dist/src/utils/formatters/shared.js +8 -0
  263. package/dist/src/utils/git-utils.d.ts +38 -2
  264. package/dist/src/utils/git-utils.js +422 -19
  265. package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
  266. package/dist/src/utils/has-nx-js-plugin.js +1 -1
  267. package/dist/src/utils/ignore.d.ts +47 -5
  268. package/dist/src/utils/ignore.js +93 -11
  269. package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
  270. package/dist/src/utils/kill-child-on-host-exit.js +42 -0
  271. package/dist/src/utils/nx-console-prompt.js +3 -6
  272. package/dist/src/utils/nx-tmp-dir.d.ts +5 -0
  273. package/dist/src/utils/nx-tmp-dir.js +7 -2
  274. package/dist/src/utils/output.d.ts +153 -0
  275. package/dist/src/utils/output.js +289 -5
  276. package/dist/src/utils/owned-private-dir.d.ts +13 -0
  277. package/dist/src/utils/owned-private-dir.js +39 -0
  278. package/dist/src/utils/package-json.d.ts +2 -0
  279. package/dist/src/utils/package-manager.js +17 -7
  280. package/dist/src/utils/params.d.ts +7 -1
  281. package/dist/src/utils/params.js +64 -6
  282. package/dist/src/utils/permission-errors.d.ts +11 -0
  283. package/dist/src/utils/permission-errors.js +17 -0
  284. package/dist/src/utils/plugins/core-plugins.js +4 -0
  285. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  286. package/dist/src/utils/prompt-helpers.js +111 -0
  287. package/dist/src/utils/socket-refused-exit-code.d.ts +15 -0
  288. package/dist/src/utils/socket-refused-exit-code.js +18 -0
  289. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  290. package/dist/src/utils/write-formatted-json-file.js +5 -4
  291. package/package.json +29 -20
  292. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
  293. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  294. package/dist/src/utils/is-using-prettier.js +0 -62
@@ -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([
@@ -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,6 +23,7 @@ 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");
@@ -76,14 +77,10 @@ async function importHandler(options) {
76
77
  }
77
78
  const tempImportDirectory = (0, path_1.join)(tmp_1.tmpdir, 'nx-import');
78
79
  if (!sourceRepository) {
79
- sourceRepository = (await (0, enquirer_1.prompt)([
80
- {
81
- type: 'input',
82
- name: 'sourceRepository',
83
- message: 'What is the URL of the repository you want to import? (This can be a local git repository or a git remote URL)',
84
- required: true,
85
- },
86
- ])).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
+ });
87
84
  }
88
85
  try {
89
86
  const maybeLocalDirectory = await (0, promises_1.stat)(sourceRepository);
@@ -131,19 +128,10 @@ async function importHandler(options) {
131
128
  throw new Error('The --ref option is required when running in agent mode.');
132
129
  }
133
130
  const branchChoices = await sourceGitClient.listBranches();
134
- ref = (await (0, enquirer_1.prompt)([
135
- {
136
- type: 'autocomplete',
137
- name: 'ref',
138
- message: `Which branch do you want to import?`,
139
- choices: branchChoices,
140
- /**
141
- * Limit the number of choices so that it fits on screen
142
- */
143
- limit: process.stdout.rows - 3,
144
- required: true,
145
- },
146
- ])).ref;
131
+ ref = await (0, prompt_helpers_1.selectPrompt)({
132
+ message: `Which branch do you want to import?`,
133
+ choices: branchChoices,
134
+ });
147
135
  }
148
136
  if (!source) {
149
137
  if (aiMode) {
@@ -151,28 +139,20 @@ async function importHandler(options) {
151
139
  source = '.';
152
140
  }
153
141
  else {
154
- source = (await (0, enquirer_1.prompt)([
155
- {
156
- type: 'input',
157
- name: 'source',
158
- message: `Which directory do you want to import into this workspace? (leave blank to import the entire repository)`,
159
- },
160
- ])).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
+ });
161
145
  }
162
146
  }
163
147
  if (!destination) {
164
148
  if (aiMode) {
165
149
  throw new Error('The --destination option is required when running in agent mode.');
166
150
  }
167
- destination = (await (0, enquirer_1.prompt)([
168
- {
169
- type: 'input',
170
- name: 'destination',
171
- message: 'Where in this workspace should the code be imported into?',
172
- required: true,
173
- initial: source ? source : undefined,
174
- },
175
- ])).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
+ });
176
156
  }
177
157
  const absSource = (0, path_1.join)(sourceTempRepoPath, source);
178
158
  if ((0, path_1.isAbsolute)(destination)) {
@@ -281,6 +261,7 @@ async function importHandler(options) {
281
261
  const incompatiblePlugins = await (0, check_compatible_with_plugins_1.checkCompatibleWithPlugins)();
282
262
  if (Object.keys(incompatiblePlugins).length > 0) {
283
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');
284
265
  await destinationGitClient.amendCommit();
285
266
  }
286
267
  }
@@ -289,6 +270,7 @@ async function importHandler(options) {
289
270
  if (installed) {
290
271
  const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
291
272
  if (succeededPlugins.length > 0) {
273
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
292
274
  await destinationGitClient.amendCommit();
293
275
  }
294
276
  }
@@ -455,6 +437,7 @@ async function handlePluginOnlyMode(options, destinationGitClient, verbose) {
455
437
  if (installed) {
456
438
  const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
457
439
  if (succeededPlugins.length > 0) {
440
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
458
441
  await destinationGitClient.amendCommit();
459
442
  }
460
443
  }
@@ -489,6 +472,7 @@ async function runInstallDestinationRepo(packageManager, destinationGitClient) {
489
472
  title: 'Installing dependencies for imported code',
490
473
  });
491
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');
492
476
  await destinationGitClient.amendCommit();
493
477
  }
494
478
  catch (e) {
@@ -505,6 +489,7 @@ async function runPluginsInstall(plugins, pmc, destinationGitClient) {
505
489
  output_1.output.log({ title: 'Installing Plugins' });
506
490
  try {
507
491
  (0, configure_plugins_1.installPluginPackages)(workspace_root_1.workspaceRoot, pmc, plugins);
492
+ await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
508
493
  await destinationGitClient.amendCommit();
509
494
  }
510
495
  catch (e) {
@@ -582,6 +567,12 @@ async function handleMissingWorkspacesEntry(pm, pmc, pkgPath, destinationGitClie
582
567
  return;
583
568
  }
584
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');
585
576
  await destinationGitClient.amendCommit();
586
577
  output_1.output.success({
587
578
  title: `Project added in workspaces`,
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.determineAiAgents = determineAiAgents;
4
- const tslib_1 = require("tslib");
5
- const enquirer_1 = require("enquirer");
4
+ const prompt_helpers_1 = require("../../utils/prompt-helpers");
6
5
  const is_ci_1 = require("../../utils/is-ci");
7
6
  const utils_1 = require("../../ai/utils");
8
7
  const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
9
- const pc = tslib_1.__importStar(require("picocolors"));
10
8
  async function determineAiAgents(aiAgents, interactive) {
11
9
  if (aiAgents) {
12
10
  const filtered = aiAgents.filter((a) => a !== 'none');
@@ -22,15 +20,11 @@ async function determineAiAgents(aiAgents, interactive) {
22
20
  return await aiAgentsPrompt();
23
21
  }
24
22
  async function aiAgentsPrompt() {
25
- const promptConfig = {
26
- name: 'agents',
23
+ return (0, prompt_helpers_1.multiselectPrompt)({
27
24
  message: 'Which AI agents, if any, would you like to set up?',
28
- type: 'multiselect',
29
25
  choices: utils_1.supportedAgents.map((a) => ({
30
- name: a,
31
- message: utils_1.agentDisplayMap[a],
26
+ value: a,
27
+ label: utils_1.agentDisplayMap[a],
32
28
  })),
33
- footer: () => pc.dim('Multiple selections possible. <Space> to select. <Enter> to confirm.'),
34
- };
35
- return (await (0, enquirer_1.prompt)([promptConfig])).agents;
29
+ });
36
30
  }
@@ -17,8 +17,10 @@ exports.yargsInitCommand = {
17
17
  return withInitOptions(yargs);
18
18
  },
19
19
  handler: async (args) => {
20
- // Node 24 has stricter readline behavior, and enquirer is not checking for closed state
21
- // when invoking operations, thus you get an ERR_USE_AFTER_CLOSE error.
20
+ // Node 24's stricter readline throws ERR_USE_AFTER_CLOSE when a prompt
21
+ // library operates on a closed interface. Added for enquirer, which nx no
22
+ // longer uses; verify against Node 24 before removing.
23
+ // TODO(v24): drop if @clack/prompts proves not to need it.
22
24
  process.on('uncaughtException', (error) => {
23
25
  if (error &&
24
26
  typeof error === 'object' &&
@@ -19,6 +19,7 @@ const configuration_1 = require("../../config/configuration");
19
19
  const versions_1 = require("../../utils/versions");
20
20
  const child_process_1 = require("../../utils/child-process");
21
21
  const fileutils_1 = require("../../utils/fileutils");
22
+ const format_1 = require("./implementation/format");
22
23
  const spinner_1 = require("../../utils/spinner");
23
24
  function installPluginPackages(repoRoot, pmc = (0, package_manager_1.getPackageManagerCommand)(), plugins) {
24
25
  if (plugins.length === 0) {
@@ -35,7 +36,9 @@ function installPluginPackages(repoRoot, pmc = (0, package_manager_1.getPackageM
35
36
  for (const plugin of plugins) {
36
37
  nxJson.installation.plugins[plugin] = versions_1.nxVersion;
37
38
  }
38
- (0, fileutils_1.writeJsonFile)((0, path_1.join)(repoRoot, 'nx.json'), nxJson);
39
+ const nxJsonPath = (0, path_1.join)(repoRoot, 'nx.json');
40
+ (0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
41
+ (0, format_1.recordInitWrite)(nxJsonPath);
39
42
  try {
40
43
  (0, child_process_1.runNxSync)('--version', { stdio: 'pipe' });
41
44
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addNxToMonorepo = addNxToMonorepo;
4
- const enquirer_1 = require("enquirer");
4
+ const prompt_helpers_1 = require("../../../utils/prompt-helpers");
5
5
  const fs_1 = require("fs");
6
6
  const ignore = require("ignore");
7
7
  const path_1 = require("path");
@@ -23,38 +23,18 @@ async function addNxToMonorepo(options, guided = true) {
23
23
  output_1.output.log({
24
24
  title: '🧑‍🔧 Please answer the following questions about the scripts found in your workspace in order to generate task runner configuration',
25
25
  });
26
- targetDefaults = (await (0, enquirer_1.prompt)([
27
- {
28
- type: 'multiselect',
29
- name: 'targetDefaults',
30
- message: 'Which scripts need to be run in order? (e.g. before building a project, dependent projects must be built)',
31
- choices: scripts,
32
- /**
33
- * limit is missing from the interface but it limits the amount of options shown
34
- */
35
- limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
36
- },
37
- ])).targetDefaults;
38
- cacheableOperations = (await (0, enquirer_1.prompt)([
39
- {
40
- type: 'multiselect',
41
- name: 'cacheableOperations',
42
- message: 'Which scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
43
- choices: scripts,
44
- /**
45
- * limit is missing from the interface but it limits the amount of options shown
46
- */
47
- limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
48
- },
49
- ])).cacheableOperations;
26
+ targetDefaults = await (0, prompt_helpers_1.multiselectPrompt)({
27
+ message: 'Which scripts need to be run in order? (e.g. before building a project, dependent projects must be built)',
28
+ choices: scripts,
29
+ });
30
+ cacheableOperations = await (0, prompt_helpers_1.multiselectPrompt)({
31
+ message: 'Which scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
32
+ choices: scripts,
33
+ });
50
34
  for (const scriptName of cacheableOperations) {
51
- scriptOutputs[scriptName] = (await (0, enquirer_1.prompt)([
52
- {
53
- type: 'input',
54
- name: scriptName,
55
- message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage)`,
56
- },
57
- ]))[scriptName];
35
+ scriptOutputs[scriptName] = await (0, prompt_helpers_1.textPrompt)({
36
+ message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage)`,
37
+ });
58
38
  }
59
39
  nxCloudChoice =
60
40
  options.nxCloud === true