@depup/nx 23.2.1-depup.7 → 23.3.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 (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
@@ -7,7 +7,6 @@ exports.connectToNxCloudCommand = connectToNxCloudCommand;
7
7
  exports.connectExistingRepoToNxCloudPrompt = connectExistingRepoToNxCloudPrompt;
8
8
  exports.connectToNxCloudWithPrompt = connectToNxCloudWithPrompt;
9
9
  const tslib_1 = require("tslib");
10
- const path_1 = require("path");
11
10
  const prompt_helpers_1 = require("../../../utils/prompt-helpers");
12
11
  const output_1 = require("../../../utils/output");
13
12
  const configuration_1 = require("../../../config/configuration");
@@ -15,7 +14,6 @@ const tree_1 = require("../../../generators/tree");
15
14
  const connect_to_nx_cloud_1 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
16
15
  const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
17
16
  const nx_cloud_utils_1 = require("../../../utils/nx-cloud-utils");
18
- const fileutils_1 = require("../../../utils/fileutils");
19
17
  const child_process_1 = require("../../../utils/child-process");
20
18
  const ab_testing_1 = require("../../../utils/ab-testing");
21
19
  const versions_1 = require("../../../utils/versions");
@@ -212,14 +210,6 @@ async function connectToNxCloudWithPrompt(command) {
212
210
  if (setNxCloud === 'yes') {
213
211
  useCloud = await connectToNxCloudCommand({ generateToken: false }, command);
214
212
  }
215
- else if (setNxCloud === 'never') {
216
- const nxJsonPath = (0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json');
217
- const nxJson = (0, configuration_1.readNxJson)();
218
- if (nxJson) {
219
- nxJson.neverConnectToCloud = true;
220
- (0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
221
- }
222
- }
223
213
  await (0, ab_testing_1.recordStat)({
224
214
  command,
225
215
  nxVersion: versions_1.nxVersion,
@@ -249,7 +239,11 @@ function utmContentForCommand(command) {
249
239
  async function nxCloudPrompt(key, utmContent) {
250
240
  const { message, choices, initial, footer, hint } = ab_testing_1.messages.getPrompt(key);
251
241
  // No separate footer/hint slot, so both are folded into the message.
252
- const suffix = [hint, footer && `${footer} ${(0, ab_testing_1.nxCloudHyperlink)(utmContent)}`]
242
+ const suffix = [
243
+ hint,
244
+ footer && `${footer} ${(0, ab_testing_1.nxCloudHyperlink)(utmContent)}`,
245
+ `See it in action: ${(0, ab_testing_1.nxCloudDemoHyperlink)(utmContent)}`,
246
+ ]
253
247
  .filter(Boolean)
254
248
  .map((t) => pc.dim(t));
255
249
  return (await (0, prompt_helpers_1.selectPrompt)({
@@ -181,6 +181,7 @@ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, ex
181
181
  targets: [requiredTargetName],
182
182
  projects: projectNamesWithTarget,
183
183
  file,
184
+ taskSelection: () => (0, run_command_1.selectTasksForProjects)(projectGraph, projectNamesWithTarget, { targets: [requiredTargetName] }, overrides, {}, extraOptions.excludeTaskDependencies),
184
185
  }, projectNamesWithTarget);
185
186
  return {};
186
187
  }
@@ -207,18 +208,20 @@ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, ex
207
208
  * NOTE: Force TUI to be disabled for now.
208
209
  */
209
210
  process.env.NX_TUI = 'false';
210
- const { taskResults } = await (0, run_command_1.runCommandForTasks)(projectsWithTarget, projectGraph, { nxJson }, {
211
+ const publishOutputStyle = args.specifiedOutputStyle ?? 'static';
212
+ const publishArgs = {
211
213
  targets: [requiredTargetName],
212
- // Everything this command reports — the registry, the tag, the
213
- // package.json diff, the dry-run summary — is printed from inside the
214
- // task, so the failures-only default would swallow all of it (under
215
- // --dry-run every task succeeds by definition). An explicit
216
- // --output-style still wins, since it comes in through the spread.
217
- outputStyle: 'static',
218
214
  ...args,
215
+ // All output is printed from inside the task, so the failures-only default
216
+ // would hide it. Set after the spread, on all three fields: the middleware
217
+ // always writes `resolvedOutputStyle`.
218
+ outputStyle: publishOutputStyle,
219
+ specifiedOutputStyle: publishOutputStyle,
220
+ resolvedOutputStyle: publishOutputStyle,
219
221
  // It is possible for workspaces to have circular dependencies between packages and still release them to a registry
220
222
  nxIgnoreCycles: true,
221
- }, overrides, null, {}, extraOptions);
223
+ };
224
+ const { taskResults } = await (0, run_command_1.runTasksForCommand)((0, run_command_1.selectTasksForProjects)(projectGraph, projectsWithTarget.map((p) => p.name), publishArgs, overrides, {}, extraOptions.excludeTaskDependencies), projectGraph, { nxJson }, publishArgs, overrides, null, {}, extraOptions);
222
225
  const endTime = Date.now();
223
226
  const publishProjectsResult = {};
224
227
  for (const taskData of Object.values(taskResults)) {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createGetTouchedProjectsForGroup = createGetTouchedProjectsForGroup;
4
- const workspace_projects_1 = require("../../../project-graph/affected/locators/workspace-projects");
4
+ const native_1 = require("../../../native");
5
+ const transform_objects_1 = require("../../../native/transform-objects");
5
6
  const file_utils_1 = require("../../../project-graph/file-utils");
6
7
  const ignore_1 = require("../../../utils/ignore");
7
8
  const output_1 = require("../../../utils/output");
@@ -44,8 +45,7 @@ function createGetTouchedProjectsForGroup(nxArgs, projectGraph, changedFiles, fi
44
45
  touchedProjects = serializedIgnorePatternsToTouchedProjects.get(serializedIgnorePatterns);
45
46
  }
46
47
  else {
47
- // We only care about directly touched projects, not implicitly affected ones etc
48
- const touchedProjectsArr = await (0, workspace_projects_1.getTouchedProjects)((0, file_utils_1.calculateFileChanges)(changedFiles, nxArgs, undefined, ignore), projectGraph.nodes);
48
+ const touchedProjectsArr = (0, native_1.directlyTouchedProjects)((0, transform_objects_1.transformProjectGraphForLocators)(projectGraph), (0, file_utils_1.calculateFileChanges)(changedFiles, nxArgs, undefined, ignore).map((f) => f.file));
49
49
  touchedProjects = touchedProjectsArr.reduce((acc, project) => ({ ...acc, [project]: true }), {});
50
50
  serializedIgnorePatternsToTouchedProjects.set(serializedIgnorePatterns, touchedProjects);
51
51
  }
@@ -437,7 +437,7 @@ class ReleaseGraph {
437
437
  if (!releaseGroup ||
438
438
  !this.projectsToVersionActions.has(projectName) ||
439
439
  !this.finalConfigsByProject.has(projectName)) {
440
- throw new Error(`Cannot resolve a concrete current version for dependency project "${projectName}" because it is not configured for Nx Release. Include the project in an Nx Release group so that its current version resolver can be configured.`);
440
+ throw Object.assign(new Error(`Cannot resolve a concrete current version for dependency project "${projectName}" because it is not configured for Nx Release. Include the project in an Nx Release group so that its current version resolver can be configured.`), { code: 'NX_RELEASE_PROJECT_NOT_CONFIGURED' });
441
441
  }
442
442
  let currentVersion;
443
443
  try {
@@ -11,8 +11,7 @@ const output_1 = require("../../../../utils/output");
11
11
  const path_1 = require("../../../../utils/path");
12
12
  const extract_repo_slug_1 = require("./extract-repo-slug");
13
13
  const remote_release_client_1 = require("./remote-release-client");
14
- // Use default import with esModuleInterop
15
- const axios_1 = tslib_1.__importDefault(require("axios"));
14
+ const http_client_1 = require("../../../../utils/http-client");
16
15
  exports.defaultCreateReleaseProvider = {
17
16
  provider: 'github',
18
17
  hostname: 'github.com',
@@ -117,9 +116,7 @@ class GithubRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
117
116
  break;
118
117
  }
119
118
  }
120
- const { data } = await axios_1.default
121
- .get(`https://ungh.cc/users/find/${email}`)
122
- .catch(() => ({ data: { user: null } }));
119
+ const { data } = await (0, http_client_1.httpRequest)(`https://ungh.cc/users/find/${email}`).catch(() => ({ data: { user: null } }));
123
120
  if (data?.user?.username) {
124
121
  meta.username = data.user.username;
125
122
  break;
@@ -227,14 +224,14 @@ class GithubRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
227
224
  `---`,
228
225
  `Request Data:`,
229
226
  `Repo: ${this.getRemoteRepoData()?.slug}`,
230
- `Token Header Data: ${this.tokenHeader}`,
227
+ `Token Header: ${this.getRedactedTokenHeader()}`,
231
228
  `Body: ${JSON.stringify(result.requestData)}`,
232
229
  ],
233
230
  });
234
231
  }
235
232
  else {
236
- console.log(error);
237
- console.error(`An unknown error occurred while trying to create a release on GitHub, please report this on https://github.com/nrwl/nx (NOTE: make sure to redact your GitHub token from the error message!)`);
233
+ console.log(this.inspectWithRedactedToken(error));
234
+ console.error(`An unknown error occurred while trying to create a release on GitHub, please report this on https://github.com/nrwl/nx (NOTE: your GitHub token is redacted above, but please double-check before sharing)`);
238
235
  }
239
236
  }
240
237
  const shouldContinueInGitHub = await this.promptForContinueInGitHub();
@@ -143,14 +143,14 @@ class GitLabRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
143
143
  `---`,
144
144
  `Request Data:`,
145
145
  `Repo: ${this.getRemoteRepoData()?.slug}`,
146
- `Token Header Data: ${this.tokenHeader}`,
146
+ `Token Header: ${this.getRedactedTokenHeader()}`,
147
147
  `Body: ${JSON.stringify(result.requestData)}`,
148
148
  ],
149
149
  });
150
150
  }
151
151
  else {
152
- console.log(error);
153
- console.error(`An unknown error occurred while trying to create a release on GitLab, please report this on https://github.com/nrwl/nx (NOTE: make sure to redact your GitLab token from the error message!)`);
152
+ console.log(this.inspectWithRedactedToken(error));
153
+ console.error(`An unknown error occurred while trying to create a release on GitLab, please report this on https://github.com/nrwl/nx (NOTE: your GitLab token is redacted above, but please double-check before sharing)`);
154
154
  }
155
155
  }
156
156
  const shouldContinueInGitLab = await this.promptForContinueInGitLab();
@@ -1,7 +1,7 @@
1
- import type { AxiosRequestConfig } from 'axios';
2
1
  import type { PostGitTask } from '../../changelog';
3
2
  import { ResolvedCreateRemoteReleaseProvider } from '../../config/config';
4
3
  import type { Reference } from '../git';
4
+ import { type HttpRequestConfig } from '../../../../utils/http-client';
5
5
  import { type ReleaseVersion } from '../shared';
6
6
  import type { GithubRemoteReleaseClient } from './github';
7
7
  import type { GitLabRemoteReleaseClient } from './gitlab';
@@ -44,6 +44,8 @@ export declare abstract class RemoteReleaseClient<RemoteRelease extends Record<s
44
44
  headerName: string;
45
45
  } | null);
46
46
  getRemoteRepoData<T extends RemoteRepoData>(): T | null;
47
+ protected inspectWithRedactedToken(error: unknown): string;
48
+ protected getRedactedTokenHeader(): string;
47
49
  /**
48
50
  * Create a post git task that will be executed by nx release changelog after performing any relevant
49
51
  * git operations, if the user has opted into remote release creation.
@@ -60,7 +62,7 @@ export declare abstract class RemoteReleaseClient<RemoteRelease extends Record<s
60
62
  /**
61
63
  * Make an (optionally authenticated) API request to the remote release provider
62
64
  */
63
- protected makeRequest(url: string, opts?: AxiosRequestConfig): Promise<any>;
65
+ protected makeRequest(url: string, opts?: HttpRequestConfig): Promise<any>;
64
66
  createOrUpdateRelease(releaseVersion: ReleaseVersion, changelogContents: string, latestCommit: string, { dryRun }: {
65
67
  dryRun: boolean;
66
68
  }): Promise<void>;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoteReleaseClient = void 0;
4
4
  exports.createRemoteReleaseClient = createRemoteReleaseClient;
5
- const tslib_1 = require("tslib");
6
- const axios_1 = tslib_1.__importDefault(require("axios"));
5
+ const node_util_1 = require("node:util");
7
6
  const handle_import_1 = require("../../../../utils/handle-import");
7
+ const http_client_1 = require("../../../../utils/http-client");
8
8
  const print_changes_1 = require("../print-changes");
9
9
  const shared_1 = require("../shared");
10
10
  /**
@@ -30,6 +30,40 @@ class RemoteReleaseClient {
30
30
  getRemoteRepoData() {
31
31
  return this.remoteRepoData;
32
32
  }
33
+ inspectWithRedactedToken(error) {
34
+ const inspected = (0, node_util_1.inspect)(error);
35
+ // The dump can hold a different string than the raw token: fetch trims
36
+ // header values and inspect() escapes the result, while message/stack keep
37
+ // it bare. Redact every rendering; the Set collapses them for an ordinary
38
+ // token. The CR/LF needle is belt-and-braces - fetch rejects such headers.
39
+ const token = this.tokenData?.token?.trim();
40
+ if (!token) {
41
+ return inspected;
42
+ }
43
+ const needles = new Set([
44
+ token,
45
+ token.replace(/[\r\n]/g, ''),
46
+ (0, node_util_1.inspect)(token).slice(1, -1),
47
+ ]);
48
+ // inspect() renders a long string carrying a line break as concatenated
49
+ // per-line chunks, which no whole-token needle spans. Redact the lines too,
50
+ // skipping fragments short enough to collide with ordinary dump text.
51
+ for (const line of token.split(/[\r\n]+/)) {
52
+ if (line.length >= 8) {
53
+ needles.add(line);
54
+ }
55
+ }
56
+ return [...needles].reduce((text, needle) => text.split(needle).join('<redacted>'), inspected);
57
+ }
58
+ getRedactedTokenHeader() {
59
+ if (!this.tokenData) {
60
+ return 'none';
61
+ }
62
+ const { headerName } = this.tokenData;
63
+ return headerName === 'Authorization'
64
+ ? `${headerName}: Bearer <redacted>`
65
+ : `${headerName}: <redacted>`;
66
+ }
33
67
  /**
34
68
  * Make an (optionally authenticated) API request to the remote release provider
35
69
  */
@@ -46,7 +80,7 @@ class RemoteReleaseClient {
46
80
  ...this.tokenHeader,
47
81
  },
48
82
  };
49
- return (await (0, axios_1.default)(url, config)).data;
83
+ return (await (0, http_client_1.httpRequest)(url, config)).data;
50
84
  }
51
85
  async createOrUpdateRelease(releaseVersion, changelogContents, latestCommit, { dryRun }) {
52
86
  let existingRelease;
@@ -15,6 +15,9 @@ export type SemverBumpType = ReleaseType | 'none';
15
15
  * when it is part of the release, or its current version when it is not being
16
16
  * versioned.
17
17
  *
18
+ * When the project is not configured for Nx Release, the returned promise
19
+ * rejects with an error whose `code` is `NX_RELEASE_PROJECT_NOT_CONFIGURED`.
20
+ *
18
21
  * @public
19
22
  */
20
23
  export type ResolveVersionForDependency = (dependencyProjectName: string) => Promise<string>;
@@ -12,6 +12,7 @@ const client_2 = require("../../nx-cloud/utilities/client");
12
12
  const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
13
13
  const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
14
14
  const configuration_1 = require("../../config/configuration");
15
+ const db_connection_1 = require("../../utils/db-connection");
15
16
  const update_manager_1 = require("../../nx-cloud/update-manager");
16
17
  // Wait at max 5 seconds before giving up on a failing operation.
17
18
  const INCREMENTAL_BACKOFF_MAX_DURATION = 5000;
@@ -82,6 +83,11 @@ async function resetHandler(args) {
82
83
  if ((cloudEnabled && all) || args.onlyCloud) {
83
84
  try {
84
85
  await resetCloudClient();
86
+ }
87
+ catch (e) {
88
+ errors.push('Failed to clean up the Nx Cloud client.', e.toString());
89
+ }
90
+ try {
85
91
  await removeInstalledNxCloudClient();
86
92
  }
87
93
  catch (e) {
@@ -117,10 +123,8 @@ function cleanupDaemonWorkspaceData() {
117
123
  async function resetCloudClient() {
118
124
  // Remove nx cloud marker files. This helps if the use happens to run `nx-cloud start-ci-run` or
119
125
  // similar commands on their local machine.
120
- try {
121
- (await (0, client_2.getCloudClient)((0, get_cloud_options_1.getCloudOptions)())).invoke('cleanup');
122
- }
123
- catch { }
126
+ // `exit` would end the process here, before reset reports its result.
127
+ await (await (0, client_2.getCloudClient)((0, get_cloud_options_1.getCloudOptions)())).invoke('cleanup', false);
124
128
  }
125
129
  function removeInstalledNxCloudClient() {
126
130
  return incrementalBackoff(INCREMENTAL_BACKOFF_FIRST_DELAY, INCREMENTAL_BACKOFF_MAX_DURATION, () => {
@@ -155,6 +159,8 @@ function cleanupNativeFileCache() {
155
159
  }
156
160
  function cleanupWorkspaceData() {
157
161
  return incrementalBackoff(INCREMENTAL_BACKOFF_FIRST_DELAY, INCREMENTAL_BACKOFF_MAX_DURATION, () => {
162
+ // Analytics opened the DB at startup; Windows cannot delete an open file.
163
+ (0, db_connection_1.removeDbConnections)();
158
164
  (0, node_fs_1.rmSync)(cache_directory_1.workspaceDataDirectory, { recursive: true, force: true });
159
165
  // Also clean wherever the DB actually lives, which is outside this
160
166
  // checkout whenever the shared root is reachable. Resolved through the
@@ -37,6 +37,8 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
37
37
  process.exit(0);
38
38
  }
39
39
  await (0, connect_to_nx_cloud_1.connectToNxCloudIfExplicitlyAsked)(nxArgs);
40
+ // --graph's file output draws this selection; the live graph builds its own.
41
+ const selectTasks = () => (0, run_command_1.selectTasksForProjects)(projectGraph, projects.map((p) => p.name), nxArgs, overrides, extraTargetDependencies, extraOptions.excludeTaskDependencies);
40
42
  if (nxArgs.graph) {
41
43
  const projectNames = projects.map((t) => t.name);
42
44
  const file = (0, command_line_utils_1.readGraphFileFromGraphArg)(nxArgs);
@@ -47,10 +49,12 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
47
49
  targets: nxArgs.targets,
48
50
  projects: projectNames,
49
51
  file,
52
+ taskSelection: selectTasks,
53
+ configuration: nxArgs.configuration,
50
54
  }, projectNames);
51
55
  }
52
56
  else {
53
- const status = await (0, run_command_1.runCommand)(projects, projectGraph, { nxJson }, nxArgs, overrides, projectName, extraTargetDependencies, extraOptions);
57
+ const status = await (0, run_command_1.runCommand)(selectTasks(), projectGraph, { nxJson }, nxArgs, overrides, projectName, extraTargetDependencies, extraOptions);
54
58
  await output_1.output.drain();
55
59
  process.exit(status);
56
60
  }
@@ -26,6 +26,8 @@ async function runMany(args, extraTargetDependencies = {}, extraOptions = {
26
26
  await (0, connect_to_nx_cloud_1.connectToNxCloudIfExplicitlyAsked)(nxArgs);
27
27
  const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
28
28
  const projects = projectsToRun(nxArgs, projectGraph);
29
+ // --graph's file output draws this selection; the live graph builds its own.
30
+ const selectTasks = () => (0, run_command_1.selectTasksForProjects)(projectGraph, projects.map((p) => p.name), nxArgs, overrides, extraTargetDependencies, extraOptions.excludeTaskDependencies);
29
31
  if (nxArgs.graph) {
30
32
  const file = (0, command_line_utils_1.readGraphFileFromGraphArg)(nxArgs);
31
33
  const projectNames = projects.map((t) => t.name);
@@ -37,17 +39,19 @@ async function runMany(args, extraTargetDependencies = {}, extraOptions = {
37
39
  targets: nxArgs.targets,
38
40
  projects: projectNames,
39
41
  file,
42
+ taskSelection: selectTasks,
43
+ configuration: nxArgs.configuration,
40
44
  }, projectNames);
41
45
  }
42
46
  else {
43
- const status = await (0, run_command_1.runCommand)(projects, projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, extraOptions);
47
+ const status = await (0, run_command_1.runCommand)(selectTasks(), projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, extraOptions);
44
48
  await output_1.output.drain();
45
49
  process.exit(status);
46
50
  }
47
51
  }
48
52
  function projectsToRun(nxArgs, projectGraph) {
49
53
  const selectedProjects = {};
50
- const validProjects = runnableForTarget(projectGraph.nodes, nxArgs.targets);
54
+ const validProjects = (0, project_graph_utils_1.runnableForTarget)(projectGraph.nodes, nxArgs.targets);
51
55
  const invalidProjects = [];
52
56
  // --all is default now, if --projects is provided, it'll override the --all
53
57
  if (nxArgs.all && nxArgs.projects.length === 0) {
@@ -78,13 +82,3 @@ function projectsToRun(nxArgs, projectGraph) {
78
82
  }
79
83
  return Object.values(selectedProjects);
80
84
  }
81
- function runnableForTarget(projects, targets) {
82
- const runnable = new Set();
83
- for (let projectName in projects) {
84
- const project = projects[projectName];
85
- if (targets.find((target) => (0, project_graph_utils_1.projectHasTarget)(project, target))) {
86
- runnable.add(projectName);
87
- }
88
- }
89
- return runnable;
90
- }
@@ -37,7 +37,7 @@ exports.yargsShowCommand = {
37
37
  const showProjectsCommand = {
38
38
  command: 'projects',
39
39
  describe: 'Show a list of projects in the workspace.',
40
- builder: (yargs) => (0, shared_options_1.withVerbose)((0, shared_options_1.withAffectedOptions)(yargs))
40
+ builder: (yargs) => (0, shared_options_1.withVerbose)((0, shared_options_1.withExplainOption)((0, shared_options_1.withAffectedOptions)(yargs)))
41
41
  .option('affected', {
42
42
  type: 'boolean',
43
43
  description: 'Show only affected projects.',
@@ -4,6 +4,9 @@ exports.showProjectsHandler = showProjectsHandler;
4
4
  const output_1 = require("../../utils/output");
5
5
  const nx_json_1 = require("../../config/nx-json");
6
6
  const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
7
+ const affected_tasks_1 = require("../../project-graph/affected/affected-tasks");
8
+ const print_explanation_1 = require("../../project-graph/affected/print-explanation");
9
+ const affected_reasons_1 = require("../../project-graph/affected/affected-reasons");
7
10
  const file_utils_1 = require("../../project-graph/file-utils");
8
11
  const operators_1 = require("../../project-graph/operators");
9
12
  const project_graph_1 = require("../../project-graph/project-graph");
@@ -17,10 +20,54 @@ async function showProjectsHandler(args) {
17
20
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', {
18
21
  printWarnings: false,
19
22
  }, nxJson);
23
+ const explainsTasks = args.affected &&
24
+ (0, affected_tasks_1.selectsAffectedTasks)() &&
25
+ !!args.withTarget?.length &&
26
+ !args.projects;
27
+ if ((0, affected_reasons_1.isExplaining)(nxArgs.explain) && !explainsTasks) {
28
+ throw new Error((0, affected_reasons_1.explainUnavailable)([
29
+ !(0, affected_tasks_1.selectsAffectedTasks)() && 'NX_LEGACY_AFFECTED=false',
30
+ !args.affected && '--affected',
31
+ !args.withTarget?.length && 'targets passed with --withTarget (-t)',
32
+ ].filter(Boolean), args.projects ? ['--projects'] : []));
33
+ }
20
34
  // Affected touches dependencies so it needs to be processed first.
21
35
  if (args.affected) {
22
36
  const touchedFiles = await getTouchedFiles(nxArgs);
23
- graph = await getAffectedGraph(touchedFiles, nxJson, graph);
37
+ // With a target, list projects owning an affected task for it, matching `affected -t`.
38
+ if ((0, affected_tasks_1.selectsAffectedTasks)() && args.withTarget?.length && !args.projects) {
39
+ const affectedTasks = await (0, affected_tasks_1.computeAffectedTasks)({
40
+ projectGraph: graph,
41
+ nxJson,
42
+ targets: args.withTarget,
43
+ touchedFiles,
44
+ fileChangeArgs: {
45
+ base: nxArgs.base,
46
+ head: nxArgs.head,
47
+ files: nxArgs.files,
48
+ },
49
+ explain: (0, affected_reasons_1.isExplaining)(nxArgs.explain),
50
+ ...(await runCommandModule().runnerInputsForSelection(nxArgs, nxJson)),
51
+ });
52
+ if ((0, affected_reasons_1.isExplaining)(nxArgs.explain)) {
53
+ (0, print_explanation_1.printAffectedExplanation)(affectedTasks.explanation, 'Affected tasks',
54
+ // show projects declares its own --json, which has no executor to
55
+ // pass through to.
56
+ args.json ? 'stdout' : nxArgs.explain, { verbose: args.verbose });
57
+ await output_1.output.drain();
58
+ return;
59
+ }
60
+ const { taskGraph, initiatingTaskIds } = affectedTasks.taskSelection;
61
+ const owning = new Set(initiatingTaskIds.map((id) => taskGraph.tasks[id].target.project));
62
+ // The graph selection ran against: with the daemon on, the daemon's, not `graph`.
63
+ graph = {
64
+ ...affectedTasks.projectGraph,
65
+ nodes: Object.fromEntries(Object.entries(affectedTasks.projectGraph.nodes).filter(([name]) => owning.has(name))),
66
+ };
67
+ }
68
+ else {
69
+ graph = await getAffectedGraph(touchedFiles, nxJson, graph);
70
+ }
24
71
  }
25
72
  const filter = (0, operators_1.filterNodes)((node) => {
26
73
  if (args.type && node.type !== args.type) {
@@ -78,3 +125,7 @@ function getAffectedGraph(touchedFiles, nxJson, graph) {
78
125
  async function getTouchedFiles(nxArgs) {
79
126
  return (0, file_utils_1.calculateFileChanges)((0, command_line_utils_1.parseFiles)(nxArgs).files, nxArgs);
80
127
  }
128
+ /** Loaded only when task selection needs it. */
129
+ function runCommandModule() {
130
+ return require('../../tasks-runner/run-command');
131
+ }
@@ -54,6 +54,10 @@ export declare function withAffectedOptions(yargs: Argv): Argv<ExcludeOptions &
54
54
  } & {
55
55
  head: string;
56
56
  }>;
57
+ /** Only on the commands that report instead of running when it is passed. */
58
+ export declare function withExplainOption<T>(yargs: Argv<T>): Argv<T & {
59
+ explain?: string | boolean;
60
+ }>;
57
61
  export interface RunManyOptions extends RunOptions {
58
62
  projects: string[];
59
63
  /**
@@ -67,7 +71,7 @@ export declare function withOverrides<T extends {
67
71
  }>(args: T, commandLevel?: number): T & {
68
72
  __overrides_unparsed__: string[];
69
73
  };
70
- declare const allOutputStyles: readonly ['tui', 'dynamic', 'dynamic-legacy', 'static', 'static-failures-only', 'stream', 'stream-without-prefixes'];
74
+ declare const allOutputStyles: readonly ['tui', 'dynamic', 'dynamic-legacy', 'static', 'static-failures-only', 'summary', 'stream', 'stream-without-prefixes'];
71
75
  export type OutputStyle = (typeof allOutputStyles)[number];
72
76
  export declare function withOutputStyleOption<T>(yargs: Argv<T>, choices?: ReadonlyArray<OutputStyle>): Argv<T & {
73
77
  outputStyle: OutputStyle;
@@ -9,6 +9,7 @@ exports.withConfiguration = withConfiguration;
9
9
  exports.withVerbose = withVerbose;
10
10
  exports.withBatch = withBatch;
11
11
  exports.withAffectedOptions = withAffectedOptions;
12
+ exports.withExplainOption = withExplainOption;
12
13
  exports.withRunManyOptions = withRunManyOptions;
13
14
  exports.withOverrides = withOverrides;
14
15
  exports.withOutputStyleOption = withOutputStyleOption;
@@ -17,6 +18,7 @@ exports.parseNewlines = parseNewlines;
17
18
  exports.parseCSV = parseCSV;
18
19
  exports.readParallelFromArgsAndEnv = readParallelFromArgsAndEnv;
19
20
  const nx_json_1 = require("../../config/nx-json");
21
+ const native_1 = require("../../native");
20
22
  const is_tui_enabled_1 = require("../../tasks-runner/is-tui-enabled");
21
23
  const node_os_1 = require("node:os");
22
24
  exports.defaultYargsParserConfiguration = {
@@ -243,6 +245,21 @@ function withAffectedOptions(yargs) {
243
245
  }
244
246
  }, true);
245
247
  }
248
+ /** Only on the commands that report instead of running when it is passed. */
249
+ function withExplainOption(yargs) {
250
+ return yargs.option('explain', {
251
+ type: 'string',
252
+ describe: 'Print why each task was considered affected, instead of running anything. Needs task selection (NX_LEGACY_AFFECTED=false). Pass a file path to save the reasons as JSON instead. Pass "stdout" to print the JSON to the terminal.',
253
+ // Same shape as `--graph`: the value is a destination, and a bare
254
+ // `--explain` has to arrive as a boolean. `nx affected` leaves `--json`
255
+ // undeclared so it still reaches the executor.
256
+ coerce: (value) => value === '' || value === 'true' || value === true
257
+ ? true
258
+ : value === 'false' || value === false
259
+ ? false
260
+ : value,
261
+ });
262
+ }
246
263
  function withRunManyOptions(yargs) {
247
264
  return withRunOptions(yargs)
248
265
  .parserConfiguration(exports.defaultYargsParserConfiguration)
@@ -273,6 +290,7 @@ const allOutputStyles = [
273
290
  'dynamic-legacy',
274
291
  'static',
275
292
  'static-failures-only',
293
+ 'summary',
276
294
  'stream',
277
295
  'stream-without-prefixes',
278
296
  ];
@@ -282,12 +300,13 @@ function withOutputStyleOption(yargs, choices = [
282
300
  'tui',
283
301
  'static',
284
302
  'static-failures-only',
303
+ 'summary',
285
304
  'stream',
286
305
  'stream-without-prefixes',
287
306
  ]) {
288
307
  return yargs
289
308
  .option('outputStyle', {
290
- describe: `Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added, and every task prints its full output regardless of status. **static-failures-only**: same as **static**, but successful and cached tasks collapse to a single line, so only failing tasks (and, for a single-project run, the project you asked for) print their full output. This is what Nx uses by default in CI and other non-interactive environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output.`,
309
+ describe: `Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added, and every task prints its full output regardless of status. **static-failures-only**: same as **static**, but successful and cached tasks collapse to a single line, so only failing tasks (and, for a single-project run, the project you asked for) print their full output. This is what Nx uses by default in CI and other non-interactive environments. **summary**: prints only run counts and one line per failing task, naming the file on disk that holds its full output. No task output is printed inline, so the size of a run's output does not depend on how much its tasks logged. This is the default when Nx detects it is being driven by an AI agent. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output.`,
291
310
  type: 'string',
292
311
  choices,
293
312
  })
@@ -298,16 +317,31 @@ function withOutputStyleOption(yargs, choices = [
298
317
  choices.includes(process.env.NX_DEFAULT_OUTPUT_STYLE)) {
299
318
  args.outputStyle = process.env.NX_DEFAULT_OUTPUT_STYLE;
300
319
  }
320
+ // Everything above this line is the user naming a style; everything
321
+ // below infers one. Splitting them here is what lets the rest of the
322
+ // codebase ask either question without re-deriving it from a single
323
+ // overloaded field.
324
+ args.specifiedOutputStyle = args.outputStyle;
301
325
  },
302
326
  (args) => {
327
+ // Resolution, in precedence order. `shouldUseTui` reads
328
+ // `specifiedOutputStyle`, so it sees only what the user named and is
329
+ // not fed a value inferred here - which is what used to make this
330
+ // ordering circular. It also reads `NX_TUI` before its own agent check,
331
+ // so an explicit opt-in beats the agent default without needing a
332
+ // special case: agent detection is ambient (`REPL_ID` is exported into
333
+ // a human's shell), and a human asking for a renderer outranks it.
303
334
  const useTui = (0, is_tui_enabled_1.shouldUseTui)((0, nx_json_1.readNxJson)(), args);
335
+ process.env.NX_TUI = useTui.toString();
336
+ const resolved = args.outputStyle ??
337
+ (useTui ? 'tui' : (0, native_1.isAiAgent)() ? 'summary' : 'static-failures-only');
338
+ args.resolvedOutputStyle = resolved;
339
+ // `outputStyle` stays what yargs parsed, except for the TUI, whose
340
+ // `check` runs after kebab-case normalization and needs both spellings.
304
341
  if (useTui) {
305
- // We have to set both of these because `check` runs after the normalization that
306
- // handles the kebab-case'd args -> camelCase'd args translation.
307
342
  args['output-style'] = 'tui';
308
343
  args.outputStyle = 'tui';
309
344
  }
310
- process.env.NX_TUI = useTui.toString();
311
345
  },
312
346
  ]);
313
347
  }
@@ -3,4 +3,4 @@
3
3
  * `packages/nx/src/native/tasks/types.rs` and exposed to TypeScript via NAPI.
4
4
  * This file re-exports them so existing imports keep working.
5
5
  */
6
- export type { Task, TaskGraph, TaskTarget, TaskHashDetails } from '../native';
6
+ export type { Task, TaskGraph, TaskTarget, TaskHashDetails, TaskUltracacheSettings, } from '../native';
@@ -1,4 +1,4 @@
1
- import type { JsonInput } from '../native';
1
+ import type { JsonInput, TaskUltracacheSettings } from '../native';
2
2
  import type { PackageJson } from '../utils/package-json';
3
3
  import type { NxJsonConfiguration, NxReleaseDockerConfiguration, NxReleaseVersionConfiguration } from './nx-json';
4
4
  /**
@@ -147,6 +147,22 @@ export interface TargetMetadata {
147
147
  };
148
148
  };
149
149
  }
150
+ /**
151
+ * Authoring form of a property merged key-by-key: permits the `'...'` spread
152
+ * token alongside the resolved keys. Merging resolves the token, so it never
153
+ * appears on the resolved shape.
154
+ */
155
+ export type Spreadable<T> = T & {
156
+ '...'?: true;
157
+ };
158
+ /**
159
+ * Ultracache settings for a target's tasks.
160
+ *
161
+ * The resolved shape rides on each Task instance (`Task['ultracache']`), which
162
+ * is why it is shared with the native task definition. Authoring additionally
163
+ * permits `'...'`, which target merging resolves away.
164
+ */
165
+ export type TargetUltracacheSettings = Spreadable<TaskUltracacheSettings>;
150
166
  export interface TargetDependencyConfig {
151
167
  /**
152
168
  * A list of projects that have `target`.
@@ -182,9 +198,11 @@ export type InputDefinition = {
182
198
  input: string;
183
199
  } | {
184
200
  fileset: string;
201
+ includeIgnored?: boolean;
185
202
  } | {
186
203
  fileset: string;
187
204
  dependencies: true;
205
+ includeIgnored?: boolean;
188
206
  } | {
189
207
  runtime: string;
190
208
  } | {
@@ -242,6 +260,10 @@ export interface TargetConfiguration<T = any> {
242
260
  * Determines if Nx is able to cache a given target.
243
261
  */
244
262
  cache?: boolean;
263
+ /**
264
+ * Configures ultracache for tasks of this target. Nx Cloud only.
265
+ */
266
+ ultracache?: TargetUltracacheSettings;
245
267
  /**
246
268
  * Metadata about the target
247
269
  */