@depup/nx 23.2.1-depup.8 → 23.3.0-depup.1

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 (350) hide show
  1. package/README.md +8 -19
  2. package/changes.json +10 -54
  3. package/dist/bin/init-local.js +7 -1
  4. package/dist/nx-cloud-internals.d.ts +1 -0
  5. package/dist/nx-cloud-internals.js +9 -0
  6. package/dist/plugins/package-json.js +1 -1
  7. package/dist/src/command-line/add/add.js +5 -1
  8. package/dist/src/command-line/affected/affected.js +70 -9
  9. package/dist/src/command-line/affected/command-object.js +1 -1
  10. package/dist/src/command-line/format/format.js +2 -18
  11. package/dist/src/command-line/graph/graph.d.ts +31 -0
  12. package/dist/src/command-line/graph/graph.js +113 -20
  13. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  15. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  16. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  17. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  18. package/dist/src/command-line/init/implementation/format.js +2 -3
  19. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  20. package/dist/src/command-line/init/implementation/utils.js +6 -9
  21. package/dist/src/command-line/init/init-v2.js +0 -3
  22. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  23. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  24. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  25. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  26. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  27. package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
  28. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  29. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  30. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  31. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  32. package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
  33. package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
  34. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
  35. package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
  36. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  37. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  38. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
  39. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
  40. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  41. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
  42. package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
  43. package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
  44. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
  45. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
  46. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  47. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  48. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  49. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  50. package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
  51. package/dist/src/command-line/migrate/agentic/runner.js +57 -239
  52. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  53. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  54. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  55. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  56. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  57. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  58. package/dist/src/command-line/migrate/command-object.d.ts +2 -0
  59. package/dist/src/command-line/migrate/command-object.js +11 -1
  60. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  61. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  62. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  63. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  64. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  65. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  66. package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
  67. package/dist/src/command-line/migrate/migrate-commits.js +16 -6
  68. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  69. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  70. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  71. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  72. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  73. package/dist/src/command-line/migrate/migrate.js +183 -46
  74. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  75. package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
  76. package/dist/src/command-line/migrate/run/agent-output.js +21 -2
  77. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  78. package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
  79. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  80. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  81. package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
  82. package/dist/src/command-line/migrate/run/broker.js +568 -0
  83. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  84. package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
  85. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  86. package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
  87. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  88. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  89. package/dist/src/command-line/migrate/run/index.d.ts +9 -6
  90. package/dist/src/command-line/migrate/run/index.js +21 -2
  91. package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
  92. package/dist/src/command-line/migrate/run/issues.js +1121 -0
  93. package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
  94. package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
  95. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  96. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  97. package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
  98. package/dist/src/command-line/migrate/run/run-state.js +263 -32
  99. package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
  100. package/dist/src/command-line/migrate/run/runbook.js +118 -0
  101. package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
  102. package/dist/src/command-line/migrate/run/state-lock.js +128 -2
  103. package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
  104. package/dist/src/command-line/migrate/run/state-machine.js +339 -26
  105. package/dist/src/command-line/migrate/run/util.d.ts +3 -1
  106. package/dist/src/command-line/migrate/run/util.js +24 -3
  107. package/dist/src/command-line/migrate/run/worker.js +290 -129
  108. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  109. package/dist/src/command-line/migrate/step-actions.js +7 -1
  110. package/dist/src/command-line/migrate/text.d.ts +6 -0
  111. package/dist/src/command-line/migrate/text.js +25 -0
  112. package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
  113. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  114. package/dist/src/command-line/release/publish.js +11 -8
  115. package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
  116. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  117. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
  118. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  119. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
  120. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
  121. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  122. package/dist/src/command-line/reset/reset.js +10 -4
  123. package/dist/src/command-line/run/run-one.js +5 -1
  124. package/dist/src/command-line/run-many/run-many.js +6 -12
  125. package/dist/src/command-line/show/command-object.js +1 -1
  126. package/dist/src/command-line/show/projects.js +52 -1
  127. package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
  128. package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
  129. package/dist/src/config/task-graph.d.ts +1 -1
  130. package/dist/src/config/workspace-json-project-json.d.ts +23 -1
  131. package/dist/src/core/graph/main.js +1 -1
  132. package/dist/src/core/graph/runtime.js +1 -1
  133. package/dist/src/core/graph/styles.js +1 -1
  134. package/dist/src/daemon/client/client.d.ts +14 -8
  135. package/dist/src/daemon/client/client.js +41 -12
  136. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  137. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  138. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  139. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
  140. package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
  141. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  142. package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
  143. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
  144. package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
  145. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  146. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  147. package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
  148. package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
  149. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
  150. package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
  151. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  152. package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
  153. package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
  154. package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
  155. package/dist/src/daemon/server/outputs-tracking.js +7 -107
  156. package/dist/src/daemon/server/planning-context.d.ts +8 -0
  157. package/dist/src/daemon/server/planning-context.js +18 -0
  158. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  159. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
  160. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  161. package/dist/src/daemon/server/restart-checks.js +77 -0
  162. package/dist/src/daemon/server/server.d.ts +1 -0
  163. package/dist/src/daemon/server/server.js +54 -30
  164. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  165. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  166. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  167. package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
  168. package/dist/src/devkit-internals.d.ts +3 -1
  169. package/dist/src/devkit-internals.js +8 -3
  170. package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
  171. package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
  172. package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
  173. package/dist/src/executors/run-commands/running-tasks.js +13 -13
  174. package/dist/src/hasher/create-task-hasher.d.ts +8 -1
  175. package/dist/src/hasher/create-task-hasher.js +13 -3
  176. package/dist/src/hasher/hash-plan-inspector.js +2 -2
  177. package/dist/src/hasher/hash-task.d.ts +2 -2
  178. package/dist/src/hasher/hash-task.js +28 -17
  179. package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
  180. package/dist/src/hasher/native-task-hasher-impl.js +75 -9
  181. package/dist/src/hasher/task-hasher.d.ts +24 -7
  182. package/dist/src/hasher/task-hasher.js +27 -8
  183. package/dist/src/hasher/task-planning-context.d.ts +13 -0
  184. package/dist/src/hasher/task-planning-context.js +12 -0
  185. package/dist/src/native/index.d.ts +582 -21
  186. package/dist/src/native/index.js +3 -3
  187. package/dist/src/native/native-bindings.js +13 -1
  188. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  189. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  190. package/dist/src/native/transform-objects.d.ts +11 -2
  191. package/dist/src/native/transform-objects.js +46 -0
  192. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
  193. package/dist/src/nx-cloud/update-manager.d.ts +3 -0
  194. package/dist/src/nx-cloud/update-manager.js +19 -13
  195. package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
  196. package/dist/src/nx-cloud/utilities/client.js +1 -1
  197. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
  198. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  199. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  200. package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
  201. package/dist/src/plugins/js/index.js +45 -64
  202. package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
  203. package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
  204. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
  205. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
  206. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
  207. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
  208. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
  209. package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
  210. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
  211. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
  212. package/dist/src/plugins/js/utils/register.js +13 -4
  213. package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
  214. package/dist/src/plugins/package-json/create-nodes.js +13 -13
  215. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
  216. package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
  217. package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
  218. package/dist/src/project-graph/affected/affected-projects.js +42 -0
  219. package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
  220. package/dist/src/project-graph/affected/affected-reasons.js +459 -0
  221. package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
  222. package/dist/src/project-graph/affected/affected-tasks.js +386 -0
  223. package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
  224. package/dist/src/project-graph/affected/print-explanation.js +44 -0
  225. package/dist/src/project-graph/error-types.d.ts +5 -0
  226. package/dist/src/project-graph/error-types.js +44 -5
  227. package/dist/src/project-graph/file-utils.d.ts +2 -0
  228. package/dist/src/project-graph/file-utils.js +12 -3
  229. package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
  230. package/dist/src/project-graph/nx-deps-cache.js +4 -4
  231. package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
  232. package/dist/src/project-graph/plugins/get-plugins.js +60 -82
  233. package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
  234. package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
  235. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
  236. package/dist/src/project-graph/plugins/isolation/index.js +3 -1
  237. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
  238. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
  239. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
  240. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
  241. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
  242. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
  243. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
  244. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
  245. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  246. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  247. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  248. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  249. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
  250. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
  251. package/dist/src/project-graph/project-graph.js +43 -42
  252. package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
  253. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
  254. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
  255. package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
  256. package/dist/src/tasks-runner/batch/run-batch.js +15 -0
  257. package/dist/src/tasks-runner/cache.d.ts +37 -2
  258. package/dist/src/tasks-runner/cache.js +42 -1
  259. package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
  260. package/dist/src/tasks-runner/create-task-graph.js +57 -2
  261. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  262. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  263. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
  264. package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
  265. package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
  266. package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
  267. package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
  268. package/dist/src/tasks-runner/life-cycle.js +7 -0
  269. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  270. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  271. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  272. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  273. package/dist/src/tasks-runner/run-command.d.ts +41 -5
  274. package/dist/src/tasks-runner/run-command.js +98 -22
  275. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
  276. package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
  277. package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
  278. package/dist/src/tasks-runner/task-io-service.js +14 -5
  279. package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
  280. package/dist/src/tasks-runner/task-orchestrator.js +266 -66
  281. package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
  282. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  283. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  284. package/dist/src/tasks-runner/utils.d.ts +5 -0
  285. package/dist/src/tasks-runner/utils.js +14 -2
  286. package/dist/src/ultracache/config.d.ts +21 -0
  287. package/dist/src/ultracache/config.js +29 -0
  288. package/dist/src/ultracache/fetch.d.ts +21 -0
  289. package/dist/src/ultracache/fetch.js +43 -0
  290. package/dist/src/ultracache/overrides.d.ts +17 -0
  291. package/dist/src/ultracache/overrides.js +61 -0
  292. package/dist/src/ultracache/report.d.ts +13 -0
  293. package/dist/src/ultracache/report.js +62 -0
  294. package/dist/src/ultracache/store.d.ts +41 -0
  295. package/dist/src/ultracache/store.js +158 -0
  296. package/dist/src/utils/ab-testing.d.ts +4 -1
  297. package/dist/src/utils/ab-testing.js +22 -19
  298. package/dist/src/utils/chunkify.d.ts +1 -7
  299. package/dist/src/utils/chunkify.js +2 -8
  300. package/dist/src/utils/command-line-utils.d.ts +20 -0
  301. package/dist/src/utils/command-line-utils.js +10 -3
  302. package/dist/src/utils/create-cli-options.d.ts +6 -0
  303. package/dist/src/utils/create-cli-options.js +29 -0
  304. package/dist/src/utils/db-connection.d.ts +2 -0
  305. package/dist/src/utils/db-connection.js +2 -0
  306. package/dist/src/utils/formatters/index.d.ts +6 -0
  307. package/dist/src/utils/formatters/index.js +5 -0
  308. package/dist/src/utils/formatters/prettier.d.ts +0 -8
  309. package/dist/src/utils/formatters/prettier.js +4 -26
  310. package/dist/src/utils/git-utils.d.ts +19 -0
  311. package/dist/src/utils/git-utils.js +97 -39
  312. package/dist/src/utils/handle-errors.js +5 -43
  313. package/dist/src/utils/http-client.d.ts +27 -0
  314. package/dist/src/utils/http-client.js +193 -0
  315. package/dist/src/utils/installed-nx-version.js +2 -48
  316. package/dist/src/utils/json-diff.d.ts +4 -2
  317. package/dist/src/utils/json-diff.js +6 -94
  318. package/dist/src/utils/min-release-age/packument.js +1 -1
  319. package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
  320. package/dist/src/utils/nx-cloud-utils.js +6 -1
  321. package/dist/src/utils/output.d.ts +22 -3
  322. package/dist/src/utils/output.js +28 -5
  323. package/dist/src/utils/package-json.d.ts +25 -0
  324. package/dist/src/utils/package-json.js +49 -6
  325. package/dist/src/utils/package-manager.d.ts +6 -0
  326. package/dist/src/utils/package-manager.js +10 -0
  327. package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
  328. package/dist/src/utils/project-graph-utils.d.ts +2 -0
  329. package/dist/src/utils/project-graph-utils.js +12 -0
  330. package/dist/src/utils/provenance.js +20 -4
  331. package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
  332. package/dist/src/utils/workspace-context.d.ts +51 -3
  333. package/dist/src/utils/workspace-context.js +174 -10
  334. package/package.json +38 -100
  335. package/schemas/nx-schema.json +38 -0
  336. package/schemas/project-schema.json +35 -0
  337. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  338. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  339. package/dist/src/daemon/server/watcher.d.ts +0 -18
  340. package/dist/src/daemon/server/watcher.js +0 -126
  341. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  342. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  343. package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
  344. package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
  345. package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
  346. package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
  347. package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
  348. package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
  349. package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
  350. package/dist/src/utils/collapse-expanded-outputs.js +0 -72
@@ -198,12 +198,13 @@ function getUncommittedFiles() {
198
198
  '--name-only',
199
199
  '--no-renames',
200
200
  '--relative',
201
+ '-z',
201
202
  'HEAD',
202
203
  '.',
203
204
  ]);
204
205
  }
205
206
  function getUntrackedFiles() {
206
- return parseGitOutput(['ls-files', '--others', '--exclude-standard']);
207
+ return parseGitOutput(['ls-files', '--others', '--exclude-standard', '-z']);
207
208
  }
208
209
  function getMergeBase(base, head = 'HEAD') {
209
210
  (0, git_revision_1.assertValidGitRevision)(base);
@@ -230,6 +231,7 @@ function getFilesUsingBaseAndHead(base, head) {
230
231
  '--name-only',
231
232
  '--no-renames',
232
233
  '--relative',
234
+ '-z',
233
235
  base,
234
236
  head,
235
237
  ]);
@@ -242,11 +244,16 @@ function runGit(args) {
242
244
  windowsHide: true,
243
245
  });
244
246
  }
247
+ /**
248
+ * Parses NUL-terminated paths, so callers must pass `-z`, and must pass it
249
+ * before the pathspec — git fatals on a `-z` that follows one. Without `-z` git
250
+ * escapes paths that contain non-ASCII or quoting characters, and honours
251
+ * `core.quotepath`, which is on by default.
252
+ */
245
253
  function parseGitOutput(args) {
246
254
  return runGit(args)
247
255
  .toString('utf-8')
248
- .split('\n')
249
- .map((a) => a.trim())
256
+ .split('\0')
250
257
  .filter((a) => a.length > 0);
251
258
  }
252
259
  function getProjectRoots(projectNames, { nodes }) {
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Turns options into CLI flags: `{ maxWarnings: 0, fix: true }` gives
3
+ * `--max-warnings=0 --fix`. Arrays repeat the flag; `false`, `null` and
4
+ * `undefined` give none.
5
+ */
6
+ export declare function createCliOptions(obj: Record<string, string | number | boolean | string[] | undefined | null>): string[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCliOptions = createCliOptions;
4
+ /**
5
+ * Turns options into CLI flags: `{ maxWarnings: 0, fix: true }` gives
6
+ * `--max-warnings=0 --fix`. Arrays repeat the flag; `false`, `null` and
7
+ * `undefined` give none.
8
+ */
9
+ function createCliOptions(obj) {
10
+ const args = [];
11
+ for (const [key, value] of Object.entries(obj)) {
12
+ if (value === undefined || value === null || value === false) {
13
+ continue;
14
+ }
15
+ const flag = `--${key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())}`;
16
+ if (value === true) {
17
+ args.push(flag);
18
+ }
19
+ else if (Array.isArray(value)) {
20
+ for (const item of value) {
21
+ args.push(`${flag}=${item}`);
22
+ }
23
+ }
24
+ else {
25
+ args.push(`${flag}=${value}`);
26
+ }
27
+ }
28
+ return args;
29
+ }
@@ -1,4 +1,5 @@
1
1
  import { ExternalObject } from '../native';
2
+ export declare function sharedWorkspaceDataDirectory(root: string): string;
2
3
  export declare function getDbConnection(opts?: {
3
4
  directory?: string;
4
5
  dbName?: string;
@@ -12,3 +13,4 @@ export declare function getDbConnection(opts?: {
12
13
  export declare function getLocalDbConnection(opts?: {
13
14
  dbName?: string;
14
15
  }): ExternalObject<any>;
16
+ export declare function removeDbConnections(): void;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sharedWorkspaceDataDirectory = sharedWorkspaceDataDirectory;
3
4
  exports.getDbConnection = getDbConnection;
4
5
  exports.getLocalDbConnection = getLocalDbConnection;
6
+ exports.removeDbConnections = removeDbConnections;
5
7
  const native_1 = require("../native");
6
8
  const cache_directory_1 = require("./cache-directory");
7
9
  const workspace_root_1 = require("./workspace-root");
@@ -1,4 +1,6 @@
1
1
  import type { Tree } from '../../generators/tree';
2
+ import { getOxfmtBinPath } from './oxfmt';
3
+ import { getPrettierPath } from './prettier';
2
4
  /**
3
5
  * Adding a member here does NOT reliably break compilation: the repo builds
4
6
  * with `strict: false`, so a `switch` that omits one is not an error. The
@@ -7,6 +9,10 @@ import type { Tree } from '../../generators/tree';
7
9
  * its emitted declarations, so those only fail once it has been rebuilt.
8
10
  */
9
11
  export type FormatterType = 'prettier' | 'oxfmt';
12
+ export declare const resolveFormatterBin: {
13
+ oxfmt: typeof getOxfmtBinPath;
14
+ prettier: typeof getPrettierPath;
15
+ };
10
16
  /** Test-only: the warn-once flag is module state and would leak between cases. */
11
17
  export declare function resetFormatterWarningsForTesting(): void;
12
18
  export declare function detectFormatter(root: string): FormatterType | null;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveFormatterBin = void 0;
3
4
  exports.resetFormatterWarningsForTesting = resetFormatterWarningsForTesting;
4
5
  exports.detectFormatter = detectFormatter;
5
6
  exports.detectFormatterInTree = detectFormatterInTree;
@@ -10,6 +11,10 @@ const fileutils_1 = require("../fileutils");
10
11
  const oxfmt_1 = require("./oxfmt");
11
12
  const prettier_1 = require("./prettier");
12
13
  const logger_1 = require("../logger");
14
+ exports.resolveFormatterBin = {
15
+ oxfmt: oxfmt_1.getOxfmtBinPath,
16
+ prettier: prettier_1.getPrettierPath,
17
+ };
13
18
  // Once per process: detection runs on every one of 200+ `formatFiles` call sites.
14
19
  let warnedBothConfigured = false;
15
20
  function warnBothConfigured() {
@@ -16,11 +16,3 @@ export declare function filterToPrettierSupportedFiles(files: string[]): Promise
16
16
  export declare function writeWithPrettier(patterns: string[], cwd?: string): void;
17
17
  export declare function checkWithPrettier(patterns: string[]): Promise<string[]>;
18
18
  export declare function getPrettierPath(): string;
19
- /**
20
- * Quote a pattern for prettier's shell-based exec calls; oxfmt uses execFile
21
- * and takes raw paths.
22
- *
23
- * Exported so `nx format` can size its chunks against the quoted length -
24
- * patterns are chunked before they get here, and quoting grows each one.
25
- */
26
- export declare function quoteForShell(pattern: string): string;
@@ -7,7 +7,6 @@ exports.filterToPrettierSupportedFiles = filterToPrettierSupportedFiles;
7
7
  exports.writeWithPrettier = writeWithPrettier;
8
8
  exports.checkWithPrettier = checkWithPrettier;
9
9
  exports.getPrettierPath = getPrettierPath;
10
- exports.quoteForShell = quoteForShell;
11
10
  const node_child_process_1 = require("node:child_process");
12
11
  const node_fs_1 = require("node:fs");
13
12
  const node_path_1 = require("node:path");
@@ -98,19 +97,17 @@ cwd) {
98
97
  if (patterns.length === 0) {
99
98
  // Prettier with no file arguments reads stdin, and `stdio: [0, 1, 2]` hands
100
99
  // it nx's own - from a terminal it blocks forever with nothing on screen. At
101
- // EOF it exits 0 under `--list-different` and 2 (which `execSync` throws on)
100
+ // EOF it exits 0 under `--list-different` and 2 (which `execFileSync` throws on)
102
101
  // without it, so which failure you get depends on `shouldUseListDifferent`.
103
102
  return;
104
103
  }
105
104
  const prettierPath = getPrettierPath();
106
- const listDifferentArg = shouldUseListDifferent() ? '--list-different ' : '';
105
+ const listDifferentArg = shouldUseListDifferent() ? ['--list-different'] : [];
107
106
  // No `--parser json` special case for `.swcrc`: prettier's own language table
108
107
  // maps it to the json parser, so it formats correctly on its own (measured).
109
108
  // Splitting the batch also meant one of the two spawns could receive zero
110
109
  // files, which is the error above.
111
- (0, node_child_process_1.execSync)(`node ${quoteForShell(prettierPath)} --write ${listDifferentArg}-- ${patterns
112
- .map(quoteForShell)
113
- .join(' ')}`, {
110
+ (0, node_child_process_1.execFileSync)(process.execPath, [prettierPath, '--write', ...listDifferentArg, '--', ...patterns], {
114
111
  cwd,
115
112
  stdio: [0, 1, 2],
116
113
  windowsHide: true,
@@ -119,9 +116,7 @@ cwd) {
119
116
  function checkWithPrettier(patterns) {
120
117
  const prettierPath = getPrettierPath();
121
118
  return new Promise((resolve, reject) => {
122
- (0, node_child_process_1.exec)(`node ${quoteForShell(prettierPath)} --list-different -- ${patterns
123
- .map(quoteForShell)
124
- .join(' ')}`, { encoding: 'utf-8', windowsHide: true, maxBuffer: shared_1.FORMATTER_MAX_BUFFER }, (error, stdout) => {
119
+ (0, node_child_process_1.execFile)(process.execPath, [prettierPath, '--list-different', '--', ...patterns], { encoding: 'utf-8', windowsHide: true, maxBuffer: shared_1.FORMATTER_MAX_BUFFER }, (error, stdout) => {
125
120
  if (error) {
126
121
  // As the oxfmt sibling: a spawn failure, kill or maxBuffer overrun reports a
127
122
  // string `code` or none. Prettier signals "files differ" numerically, so
@@ -182,20 +177,3 @@ function shouldUseListDifferent() {
182
177
  }
183
178
  return useListDifferent;
184
179
  }
185
- /**
186
- * Quote a pattern for prettier's shell-based exec calls; oxfmt uses execFile
187
- * and takes raw paths.
188
- *
189
- * Exported so `nx format` can size its chunks against the quoted length -
190
- * patterns are chunked before they get here, and quoting grows each one.
191
- */
192
- function quoteForShell(pattern) {
193
- // Interpolated into a command string, so every character special *inside
194
- // double quotes* needs escaping, not just `$`: a backtick substitutes, `"`
195
- // closes the quoting, `\` escapes what follows. One pass over the original,
196
- // since `String.replace` never re-scans what it inserted.
197
- const escaped = process.platform !== 'win32'
198
- ? pattern.replace(/([\\"`$])/g, '\\$1')
199
- : pattern;
200
- return `"${escaped}"`;
201
- }
@@ -90,6 +90,18 @@ export declare function commitChanges(commitMessage: string, directory?: string)
90
90
  * callers' own constants, never from user input.
91
91
  */
92
92
  export declare function tryCommitChanges(commitMessage: string, directory: string, excludePaths?: string[]): string | null;
93
+ /**
94
+ * `tryCommitChanges` for a process that has to stay responsive while git
95
+ * runs: a signing prompt or a hook can hold the commit for minutes.
96
+ */
97
+ export declare function tryCommitChangesAsync(commitMessage: string, directory: string, excludePaths?: string[]): Promise<string | null>;
98
+ /**
99
+ * `git reset --hard <ref>` then `git clean -fd`, keeping `keepPaths` (git
100
+ * exclusion patterns, repo-relative) out of the clean. Throws with git's
101
+ * stderr when either fails. `ref` is a sha a caller validated with `GIT_SHA`,
102
+ * never user input.
103
+ */
104
+ export declare function resetWorkingTree(ref: string, keepPaths: string[], directory: string): void;
93
105
  export declare function getLatestCommitSha(directory?: string): string | null;
94
106
  /**
95
107
  * The shape of a recorded `git rev-parse` output: 40 hex chars, or 64 in a
@@ -97,6 +109,13 @@ export declare function getLatestCommitSha(directory?: string): string | null;
97
109
  * command line has to be checked against this first.
98
110
  */
99
111
  export declare const GIT_SHA: RegExp;
112
+ export type AncestorStatus = 'ancestor' | 'not-ancestor' | 'unknown';
113
+ /**
114
+ * Whether `ancestor` is reachable from `descendant`. 'unknown' means the
115
+ * answer could not be established (invalid input, not a repository, a commit
116
+ * git does not know), which is distinct from a verified 'not-ancestor'.
117
+ */
118
+ export declare function getAncestorStatus(ancestor: string, descendant: string, directory?: string): AncestorStatus;
100
119
  /**
101
120
  * Whether `ancestor` is reachable from `descendant`, i.e. resetting to
102
121
  * `descendant` keeps `ancestor` in history. Returns false when the answer
@@ -19,7 +19,10 @@ exports.getPathCommitExposure = getPathCommitExposure;
19
19
  exports.getUncommittedChangesSnapshot = getUncommittedChangesSnapshot;
20
20
  exports.commitChanges = commitChanges;
21
21
  exports.tryCommitChanges = tryCommitChanges;
22
+ exports.tryCommitChangesAsync = tryCommitChangesAsync;
23
+ exports.resetWorkingTree = resetWorkingTree;
22
24
  exports.getLatestCommitSha = getLatestCommitSha;
25
+ exports.getAncestorStatus = getAncestorStatus;
23
26
  exports.isAncestorCommit = isAncestorCommit;
24
27
  const tslib_1 = require("tslib");
25
28
  const child_process_1 = require("child_process");
@@ -849,47 +852,91 @@ function commitChanges(commitMessage, directory) {
849
852
  */
850
853
  function tryCommitChanges(commitMessage, directory, excludePaths = []) {
851
854
  try {
852
- (0, child_process_1.execSync)('git add -A', {
853
- encoding: 'utf8',
854
- stdio: 'pipe',
855
- cwd: directory,
856
- windowsHide: true,
857
- });
858
- // Exclusion happens as an unstage rather than an add-time pathspec:
859
- // `git add` refuses a pathspec naming an ignored directory (exit 1) even
860
- // as an exclusion, and an add-time pathspec cannot cover entries that
861
- // were already staged before this call. The reset is relative to cwd, so
862
- // a workspace nested inside a larger repo excludes its own path; a path
863
- // with no index entry is a quiet no-op, unborn HEAD included.
864
- for (const excludePath of excludePaths) {
865
- (0, child_process_1.execSync)(`git reset -q -- "${excludePath}"`, {
855
+ for (const { command, input } of commitCommands(commitMessage, excludePaths)) {
856
+ (0, child_process_1.execSync)(command, {
866
857
  encoding: 'utf8',
867
858
  stdio: 'pipe',
859
+ input,
868
860
  cwd: directory,
869
861
  windowsHide: true,
870
862
  });
871
863
  }
872
- (0, child_process_1.execSync)('git commit --no-verify -F -', {
873
- encoding: 'utf8',
874
- stdio: 'pipe',
875
- input: commitMessage,
876
- cwd: directory,
877
- windowsHide: true,
878
- });
879
864
  }
880
865
  catch (err) {
881
- const stderr = err?.stderr?.toString();
882
- const stdout = err?.stdout?.toString();
883
- const detail = [stderr, stdout]
884
- .map((s) => s?.trim())
885
- .filter(Boolean)
886
- .join('\n');
887
- // `{ cause }` preserves structured fields (.signal, .status, .code)
888
- // for callers to inspect; otherwise only stderr/stdout text survives.
889
- throw new Error(detail || (err instanceof Error ? err.message : String(err)), { cause: err });
866
+ throw commitFailure(err);
867
+ }
868
+ return getLatestCommitSha(directory);
869
+ }
870
+ /**
871
+ * `tryCommitChanges` for a process that has to stay responsive while git
872
+ * runs: a signing prompt or a hook can hold the commit for minutes.
873
+ */
874
+ async function tryCommitChangesAsync(commitMessage, directory, excludePaths = []) {
875
+ try {
876
+ for (const { command, input } of commitCommands(commitMessage, excludePaths)) {
877
+ await execAsync(command, directory, input);
878
+ }
879
+ }
880
+ catch (err) {
881
+ throw commitFailure(err);
890
882
  }
891
883
  return getLatestCommitSha(directory);
892
884
  }
885
+ function commitCommands(commitMessage, excludePaths) {
886
+ return [
887
+ { command: 'git add -A' },
888
+ // Exclusion happens as an unstage rather than an add-time pathspec:
889
+ // `git add` refuses a pathspec naming an ignored directory (exit 1) even
890
+ // as an exclusion, and an add-time pathspec cannot cover entries that
891
+ // were already staged before this call. The reset is relative to cwd, so
892
+ // a workspace nested inside a larger repo excludes its own path; a path
893
+ // with no index entry is a quiet no-op, unborn HEAD included.
894
+ ...excludePaths.map((excludePath) => ({
895
+ command: `git reset -q -- "${excludePath}"`,
896
+ })),
897
+ { command: 'git commit --no-verify -F -', input: commitMessage },
898
+ ];
899
+ }
900
+ function commitFailure(err) {
901
+ const stderr = err?.stderr?.toString();
902
+ const stdout = err?.stdout?.toString();
903
+ const detail = [stderr, stdout]
904
+ .map((s) => s?.trim())
905
+ .filter(Boolean)
906
+ .join('\n');
907
+ // `{ cause }` preserves structured fields (.signal, .status, .code)
908
+ // for callers to inspect; otherwise only stderr/stdout text survives.
909
+ return new Error(detail || (err instanceof Error ? err.message : String(err)), { cause: err });
910
+ }
911
+ function execAsync(command, cwd, input) {
912
+ return new Promise((res, rej) => {
913
+ const child = (0, child_process_1.exec)(command, { encoding: 'utf8', cwd, windowsHide: true },
914
+ // The streams ride on the error as `execSync` reports them, so
915
+ // `commitFailure` shapes both the same way.
916
+ (err, stdout, stderr) => err ? rej(Object.assign(err, { stdout, stderr })) : res());
917
+ // Closed for every command, since `git commit -F -` reads to end of
918
+ // input. A child that exits before reading raises EPIPE here, which the
919
+ // exit callback already reports.
920
+ child.stdin?.on('error', () => { });
921
+ child.stdin?.end(input ?? '');
922
+ });
923
+ }
924
+ /**
925
+ * `git reset --hard <ref>` then `git clean -fd`, keeping `keepPaths` (git
926
+ * exclusion patterns, repo-relative) out of the clean. Throws with git's
927
+ * stderr when either fails. `ref` is a sha a caller validated with `GIT_SHA`,
928
+ * never user input.
929
+ */
930
+ function resetWorkingTree(ref, keepPaths, directory) {
931
+ const options = {
932
+ encoding: 'utf8',
933
+ stdio: 'pipe',
934
+ cwd: directory,
935
+ windowsHide: true,
936
+ };
937
+ (0, child_process_1.execFileSync)('git', ['reset', '--hard', ref], options);
938
+ (0, child_process_1.execFileSync)('git', ['clean', '-fd', ...keepPaths.flatMap((keepPath) => ['-e', keepPath])], options);
939
+ }
893
940
  function getLatestCommitSha(directory) {
894
941
  try {
895
942
  return (0, child_process_1.execSync)('git rev-parse HEAD', {
@@ -910,14 +957,13 @@ function getLatestCommitSha(directory) {
910
957
  */
911
958
  exports.GIT_SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
912
959
  /**
913
- * Whether `ancestor` is reachable from `descendant`, i.e. resetting to
914
- * `descendant` keeps `ancestor` in history. Returns false when the answer
915
- * cannot be established (invalid input, not a repository, unknown commits),
916
- * so callers treat an unverifiable commit as not preserved.
960
+ * Whether `ancestor` is reachable from `descendant`. 'unknown' means the
961
+ * answer could not be established (invalid input, not a repository, a commit
962
+ * git does not know), which is distinct from a verified 'not-ancestor'.
917
963
  */
918
- function isAncestorCommit(ancestor, descendant, directory) {
964
+ function getAncestorStatus(ancestor, descendant, directory) {
919
965
  if (!exports.GIT_SHA.test(ancestor) || !exports.GIT_SHA.test(descendant)) {
920
- return false;
966
+ return 'unknown';
921
967
  }
922
968
  try {
923
969
  (0, child_process_1.execSync)(`git merge-base --is-ancestor ${ancestor} ${descendant}`, {
@@ -925,9 +971,21 @@ function isAncestorCommit(ancestor, descendant, directory) {
925
971
  windowsHide: true,
926
972
  cwd: directory,
927
973
  });
928
- return true;
974
+ return 'ancestor';
929
975
  }
930
- catch {
931
- return false;
976
+ catch (e) {
977
+ // Exit 1 is git's verified "no"; anything else is a failed probe.
978
+ return e?.status === 1
979
+ ? 'not-ancestor'
980
+ : 'unknown';
932
981
  }
933
982
  }
983
+ /**
984
+ * Whether `ancestor` is reachable from `descendant`, i.e. resetting to
985
+ * `descendant` keeps `ancestor` in history. Returns false when the answer
986
+ * cannot be established (invalid input, not a repository, unknown commits),
987
+ * so callers treat an unverifiable commit as not preserved.
988
+ */
989
+ function isAncestorCommit(ancestor, descendant, directory) {
990
+ return getAncestorStatus(ancestor, descendant, directory) === 'ancestor';
991
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleErrors = handleErrors;
4
+ const error_types_1 = require("../project-graph/error-types");
4
5
  const logger_1 = require("./logger");
5
6
  const output_1 = require("./output");
6
7
  const handle_import_1 = require("./handle-import");
@@ -17,35 +18,9 @@ async function handleErrors(isVerbose, fn) {
17
18
  if (err.constructor.name === 'UnsuccessfulWorkflowExecution') {
18
19
  logger_1.logger.error('The generator workflow failed. See above.');
19
20
  }
20
- else if (err.name === 'ProjectGraphError') {
21
- const projectGraphError = err;
22
- let title = projectGraphError.message;
23
- if (projectGraphError.cause &&
24
- typeof projectGraphError.cause === 'object' &&
25
- 'message' in projectGraphError.cause) {
26
- title += ' ' + projectGraphError.cause.message + '.';
27
- }
28
- output_1.output.error({
29
- title,
30
- bodyLines: isVerbose
31
- ? formatErrorStackAndCause(projectGraphError, isVerbose)
32
- : projectGraphError.getErrors().map((e) => e.message),
33
- });
34
- }
35
- else if (err.name === 'ProjectConfigurationsError') {
36
- const projectConfigurationsError = err;
37
- let title = projectConfigurationsError.message;
38
- if (projectConfigurationsError.cause &&
39
- typeof projectConfigurationsError.cause === 'object' &&
40
- 'message' in projectConfigurationsError.cause) {
41
- title += ' ' + projectConfigurationsError.cause.message + '.';
42
- }
43
- output_1.output.error({
44
- title,
45
- bodyLines: isVerbose
46
- ? formatErrorStackAndCause(projectConfigurationsError, isVerbose)
47
- : projectConfigurationsError.errors.map((e) => e.message),
48
- });
21
+ else if (err.name === 'ProjectGraphError' ||
22
+ err.name === 'ProjectConfigurationsError') {
23
+ output_1.output.error((0, error_types_1.formatProjectGraphError)(err, isVerbose));
49
24
  }
50
25
  else if (err.name === 'MinReleaseAgeViolationError') {
51
26
  // A cooldown violation already carries a user-shaped headline plus
@@ -59,7 +34,7 @@ async function handleErrors(isVerbose, fn) {
59
34
  const lines = (err.message ? err.message : err.toString()).split('\n');
60
35
  const bodyLines = lines.slice(1);
61
36
  if (isVerbose) {
62
- bodyLines.push(...formatErrorStackAndCause(err, isVerbose));
37
+ bodyLines.push((0, error_types_1.formatErrorStackAndCause)(err));
63
38
  }
64
39
  else if (err.stack) {
65
40
  bodyLines.push('Pass --verbose to see the stacktrace.');
@@ -76,16 +51,3 @@ async function handleErrors(isVerbose, fn) {
76
51
  return 1;
77
52
  }
78
53
  }
79
- function formatErrorStackAndCause(error, verbose) {
80
- return [
81
- verbose ? error.stack || error.message : error.message,
82
- ...(error.cause && typeof error.cause === 'object'
83
- ? [
84
- 'Caused by:',
85
- verbose && 'stack' in error.cause
86
- ? error.cause.stack.toString()
87
- : error.cause.toString(),
88
- ]
89
- : []),
90
- ];
91
- }
@@ -0,0 +1,27 @@
1
+ export interface HttpRequestConfig {
2
+ method?: string;
3
+ baseURL?: string;
4
+ headers?: Record<string, string>;
5
+ params?: Record<string, string | number | boolean | null | undefined>;
6
+ data?: unknown;
7
+ timeout?: number;
8
+ responseType?: 'json' | 'stream';
9
+ signal?: AbortSignal;
10
+ }
11
+ export interface HttpResponse<T = any> {
12
+ status: number;
13
+ headers: Record<string, string>;
14
+ data: T;
15
+ }
16
+ export declare class HttpError extends Error {
17
+ readonly response: HttpResponse;
18
+ readonly status: number;
19
+ constructor(response: HttpResponse);
20
+ }
21
+ export interface HttpClient {
22
+ request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
23
+ get<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
24
+ post<T = any>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
25
+ }
26
+ export declare function createHttpClient(defaults?: HttpRequestConfig): HttpClient;
27
+ export declare function httpRequest<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;