@ohos-ports/nx 23.3.0-beta.3 → 24.0.2-beta.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 (301) hide show
  1. package/README.md +3 -6
  2. package/dist/bin/nx.js +2 -2
  3. package/dist/bin/post-install.js +5 -3
  4. package/dist/nx-cloud-internals.d.ts +1 -0
  5. package/dist/nx-cloud-internals.js +7 -1
  6. package/dist/src/adapter/ngcli-adapter.js +2 -2
  7. package/dist/src/ai/clone-ai-config-repo.js +49 -12
  8. package/dist/src/command-line/add/add.d.ts +2 -0
  9. package/dist/src/command-line/add/add.js +24 -6
  10. package/dist/src/command-line/affected/affected.js +2 -2
  11. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +1 -13
  12. package/dist/src/command-line/graph/graph.js +38 -10
  13. package/dist/src/command-line/init/command-object.js +0 -12
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
  15. package/dist/src/command-line/init/init-v2.js +1 -3
  16. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +1 -1
  17. package/dist/src/command-line/migrate/agentic/close-agent-session.js +4 -3
  18. package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
  19. package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
  20. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -45
  21. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -51
  22. package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
  23. package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
  24. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
  25. package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
  26. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
  27. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -49
  28. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
  29. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +86 -24
  30. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
  31. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
  32. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
  33. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
  34. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
  35. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
  36. package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
  37. package/dist/src/command-line/migrate/agentic/select.js +38 -8
  38. package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
  39. package/dist/src/command-line/migrate/agentic/types.js +6 -8
  40. package/dist/src/command-line/migrate/command-object.js +6 -10
  41. package/dist/src/command-line/migrate/execute-migration.d.ts +6 -6
  42. package/dist/src/command-line/migrate/execute-migration.js +25 -15
  43. package/dist/src/command-line/migrate/migrate-analytics.d.ts +18 -1
  44. package/dist/src/command-line/migrate/migrate-analytics.js +38 -0
  45. package/dist/src/command-line/migrate/migrate-commits.d.ts +29 -17
  46. package/dist/src/command-line/migrate/migrate-commits.js +86 -32
  47. package/dist/src/command-line/migrate/migrate-config.d.ts +6 -6
  48. package/dist/src/command-line/migrate/migrate-config.js +12 -6
  49. package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
  50. package/dist/src/command-line/migrate/migrate-output.js +1 -10
  51. package/dist/src/command-line/migrate/migrate.d.ts +6 -30
  52. package/dist/src/command-line/migrate/migrate.js +257 -255
  53. package/dist/src/command-line/migrate/resolve-package-version.d.ts +2 -4
  54. package/dist/src/command-line/migrate/resolve-package-version.js +2 -35
  55. package/dist/src/command-line/migrate/run/agent-output.d.ts +2 -0
  56. package/dist/src/command-line/migrate/run/agent-output.js +9 -0
  57. package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
  58. package/dist/src/command-line/migrate/run/broker.js +69 -21
  59. package/dist/src/command-line/migrate/run/clean-retry.js +4 -2
  60. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +1 -1
  61. package/dist/src/command-line/migrate/run/existing-run-report.js +7 -5
  62. package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
  63. package/dist/src/command-line/migrate/run/give-up.js +8 -5
  64. package/dist/src/command-line/migrate/run/index.d.ts +7 -5
  65. package/dist/src/command-line/migrate/run/index.js +16 -1
  66. package/dist/src/command-line/migrate/run/issues.js +7 -2
  67. package/dist/src/command-line/migrate/run/orchestrator.d.ts +61 -4
  68. package/dist/src/command-line/migrate/run/orchestrator.js +397 -133
  69. package/dist/src/command-line/migrate/run/run-state.d.ts +17 -1
  70. package/dist/src/command-line/migrate/run/run-state.js +41 -2
  71. package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
  72. package/dist/src/command-line/migrate/run/runbook.js +115 -18
  73. package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
  74. package/dist/src/command-line/migrate/run/state-lock.js +102 -10
  75. package/dist/src/command-line/migrate/run/state-machine.js +4 -1
  76. package/dist/src/command-line/migrate/run/util.d.ts +7 -2
  77. package/dist/src/command-line/migrate/run/util.js +30 -3
  78. package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
  79. package/dist/src/command-line/migrate/run/worker.js +252 -250
  80. package/dist/src/command-line/migrate/sort-migrations.d.ts +1 -7
  81. package/dist/src/command-line/migrate/sort-migrations.js +1 -12
  82. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -12
  83. package/dist/src/command-line/release/changelog.js +9 -6
  84. package/dist/src/command-line/release/config/config.d.ts +1 -0
  85. package/dist/src/command-line/release/config/config.js +48 -9
  86. package/dist/src/command-line/release/release.js +2 -2
  87. package/dist/src/command-line/release/utils/git.js +8 -7
  88. package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
  89. package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
  90. package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
  91. package/dist/src/command-line/release/utils/release-graph.js +1 -0
  92. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -6
  93. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +5 -6
  94. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
  95. package/dist/src/command-line/release/utils/shared.js +10 -10
  96. package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
  97. package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
  98. package/dist/src/command-line/release/version/version-actions.js +2 -1
  99. package/dist/src/command-line/release/version.js +5 -2
  100. package/dist/src/command-line/repair/repair.js +1 -1
  101. package/dist/src/command-line/report/report.js +1 -1
  102. package/dist/src/command-line/reset/reset.js +58 -62
  103. package/dist/src/command-line/run/executor-utils.js +1 -0
  104. package/dist/src/command-line/run/run-one.d.ts +20 -1
  105. package/dist/src/command-line/run/run-one.js +153 -5
  106. package/dist/src/command-line/run/run.js +2 -1
  107. package/dist/src/command-line/show/projects.js +5 -3
  108. package/dist/src/command-line/show/show-target/info.d.ts +10 -1
  109. package/dist/src/command-line/show/show-target/info.js +100 -15
  110. package/dist/src/command-line/show/show-target/inputs.js +10 -2
  111. package/dist/src/command-line/show/show-target/utils.js +1 -0
  112. package/dist/src/command-line/watch/command-object.js +3 -22
  113. package/dist/src/command-line/watch/watch.d.ts +0 -7
  114. package/dist/src/command-line/watch/watch.js +1 -1
  115. package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
  116. package/dist/src/config/misc-interfaces.d.ts +18 -0
  117. package/dist/src/config/nx-json.d.ts +22 -11
  118. package/dist/src/config/task-graph.d.ts +1 -1
  119. package/dist/src/config/workspace-json-project-json.d.ts +88 -0
  120. package/dist/src/core/graph/main.js +1 -1
  121. package/dist/src/core/graph/runtime.js +1 -1
  122. package/dist/src/core/graph/styles.css +1 -1
  123. package/dist/src/core/graph/styles.js +1 -1
  124. package/dist/src/daemon/client/client.d.ts +15 -0
  125. package/dist/src/daemon/client/client.js +181 -71
  126. package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
  127. package/dist/src/daemon/client/daemon-socket-messenger.js +2 -2
  128. package/dist/src/daemon/server/client-socket-context.js +1 -1
  129. package/dist/src/daemon/server/handle-configure-ai-agents.js +2 -2
  130. package/dist/src/daemon/server/handle-process-in-background.js +21 -9
  131. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +2 -1
  132. package/dist/src/daemon/server/handle-select-affected-tasks.js +21 -13
  133. package/dist/src/daemon/server/native-js-loader.d.ts +1 -0
  134. package/dist/src/daemon/server/native-js-loader.js +21 -0
  135. package/dist/src/daemon/server/nx-console-operations.js +2 -2
  136. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +4 -8
  137. package/dist/src/daemon/server/server.d.ts +2 -1
  138. package/dist/src/daemon/server/server.js +17 -4
  139. package/dist/src/daemon/server/shutdown-utils.js +1 -4
  140. package/dist/src/daemon/server/start.d.ts +1 -0
  141. package/dist/src/daemon/server/start.js +2 -0
  142. package/dist/src/daemon/socket-utils.d.ts +11 -9
  143. package/dist/src/daemon/socket-utils.js +31 -61
  144. package/dist/src/daemon/tmp-dir.d.ts +19 -14
  145. package/dist/src/daemon/tmp-dir.js +142 -354
  146. package/dist/src/devkit-exports.d.ts +9 -1
  147. package/dist/src/devkit-exports.js +12 -1
  148. package/dist/src/devkit-internals.d.ts +6 -5
  149. package/dist/src/devkit-internals.js +13 -4
  150. package/dist/src/executors/run-commands/run-commands.impl.d.ts +4 -2
  151. package/dist/src/executors/run-commands/run-commands.impl.js +53 -27
  152. package/dist/src/executors/run-commands/running-tasks.d.ts +13 -4
  153. package/dist/src/executors/run-commands/running-tasks.js +148 -95
  154. package/dist/src/executors/run-commands/schema.json +1 -1
  155. package/dist/src/hasher/check-task-files.js +5 -8
  156. package/dist/src/hasher/file-hasher.js +9 -7
  157. package/dist/src/hasher/hash-task.js +4 -0
  158. package/dist/src/hasher/native-task-hasher-impl.js +3 -1
  159. package/dist/src/hasher/task-hasher.d.ts +2 -0
  160. package/dist/src/hasher/task-hasher.js +4 -1
  161. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
  162. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
  163. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
  164. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
  165. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
  166. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
  167. package/dist/src/migrations/update-24-0-0/find-custom-hashers.d.ts +3 -0
  168. package/dist/src/migrations/update-24-0-0/find-custom-hashers.js +100 -0
  169. package/dist/src/migrations/update-24-0-0/find-custom-hashers.md +63 -0
  170. package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +146 -0
  171. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
  172. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
  173. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
  174. package/dist/src/native/assert-supported-platform.js +1 -1
  175. package/dist/src/native/index.d.ts +238 -18
  176. package/dist/src/native/index.js +6 -1
  177. package/dist/src/native/native-bindings.js +15 -6
  178. package/dist/src/native/nx.openharmony-arm64.node +0 -0
  179. package/dist/src/native/nx.wasi-browser.js +1 -0
  180. package/dist/src/native/nx.wasi.cjs +1 -0
  181. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  182. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  183. package/dist/src/nx-cloud/update-manager.d.ts +14 -0
  184. package/dist/src/nx-cloud/update-manager.js +237 -50
  185. package/dist/src/plugins/js/lock-file/pnpm-parser.js +3 -4
  186. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
  187. package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
  188. package/dist/src/plugins/js/utils/register.js +9 -4
  189. package/dist/src/project-graph/affected/affected-tasks.d.ts +9 -6
  190. package/dist/src/project-graph/affected/affected-tasks.js +31 -7
  191. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +7 -0
  192. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
  193. package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
  194. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +12 -133
  195. package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
  196. package/dist/src/project-graph/utils/retrieve-workspace-files.js +27 -6
  197. package/dist/src/tasks-runner/create-task-graph.d.ts +8 -7
  198. package/dist/src/tasks-runner/create-task-graph.js +50 -27
  199. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  200. package/dist/src/tasks-runner/init-tasks-runner.js +116 -59
  201. package/dist/src/tasks-runner/life-cycle.d.ts +4 -1
  202. package/dist/src/tasks-runner/life-cycle.js +7 -0
  203. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +5 -2
  204. package/dist/src/tasks-runner/life-cycles/performance-analysis.js +13 -7
  205. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +4 -3
  206. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +9 -2
  207. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
  208. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +4 -1
  209. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +5 -1
  210. package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
  211. package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
  212. package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
  213. package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
  214. package/dist/src/tasks-runner/readiness/executor-ready-signal.d.ts +7 -0
  215. package/dist/src/tasks-runner/readiness/executor-ready-signal.js +43 -0
  216. package/dist/src/tasks-runner/readiness/probes.d.ts +14 -0
  217. package/dist/src/tasks-runner/readiness/probes.js +101 -0
  218. package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
  219. package/dist/src/tasks-runner/readiness/ready-signal-server.js +72 -0
  220. package/dist/src/tasks-runner/readiness/ready-signal.d.ts +33 -0
  221. package/dist/src/tasks-runner/readiness/ready-signal.js +92 -0
  222. package/dist/src/tasks-runner/readiness/ready-when.d.ts +84 -0
  223. package/dist/src/tasks-runner/readiness/ready-when.js +371 -0
  224. package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
  225. package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
  226. package/dist/src/tasks-runner/run-command.d.ts +6 -2
  227. package/dist/src/tasks-runner/run-command.js +21 -31
  228. package/dist/src/tasks-runner/run-outcome.d.ts +16 -0
  229. package/dist/src/tasks-runner/run-outcome.js +39 -0
  230. package/dist/src/tasks-runner/running-tasks/batch-process.js +6 -0
  231. package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
  232. package/dist/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
  233. package/dist/src/tasks-runner/task-env.d.ts +10 -0
  234. package/dist/src/tasks-runner/task-env.js +37 -5
  235. package/dist/src/tasks-runner/task-graph-utils.d.ts +9 -6
  236. package/dist/src/tasks-runner/task-graph-utils.js +17 -12
  237. package/dist/src/tasks-runner/task-orchestrator.d.ts +62 -18
  238. package/dist/src/tasks-runner/task-orchestrator.js +750 -150
  239. package/dist/src/tasks-runner/tasks-runner.d.ts +1 -1
  240. package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
  241. package/dist/src/tasks-runner/tasks-schedule.js +63 -6
  242. package/dist/src/tasks-runner/tokens.d.ts +54 -0
  243. package/dist/src/tasks-runner/tokens.js +161 -0
  244. package/dist/src/tasks-runner/utils.d.ts +35 -6
  245. package/dist/src/tasks-runner/utils.js +149 -68
  246. package/dist/src/ultracache/ci-status.d.ts +24 -0
  247. package/dist/src/ultracache/ci-status.js +87 -0
  248. package/dist/src/ultracache/config.d.ts +3 -3
  249. package/dist/src/ultracache/config.js +4 -4
  250. package/dist/src/ultracache/fetch.d.ts +2 -0
  251. package/dist/src/ultracache/fetch.js +1 -0
  252. package/dist/src/ultracache/overrides.js +4 -0
  253. package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
  254. package/dist/src/utils/acknowledge-build-scripts.js +171 -32
  255. package/dist/src/utils/child-process.js +2 -1
  256. package/dist/src/utils/find-matching-projects.js +9 -6
  257. package/dist/src/utils/git-utils.d.ts +12 -5
  258. package/dist/src/utils/git-utils.js +69 -11
  259. package/dist/src/utils/long-running-target.d.ts +1 -3
  260. package/dist/src/utils/long-running-target.js +1 -3
  261. package/dist/src/utils/nx-package-group.js +1 -1
  262. package/dist/src/utils/output.d.ts +4 -3
  263. package/dist/src/utils/output.js +4 -3
  264. package/dist/src/utils/owned-private-dir.d.ts +1 -17
  265. package/dist/src/utils/owned-private-dir.js +10 -62
  266. package/dist/src/utils/package-json.js +1 -1
  267. package/dist/src/utils/package-manager.d.ts +8 -0
  268. package/dist/src/utils/package-manager.js +65 -8
  269. package/dist/src/utils/perf-hooks.d.ts +1 -0
  270. package/dist/src/utils/plugins/core-plugins.js +5 -1
  271. package/dist/src/utils/progress-topics.d.ts +1 -0
  272. package/dist/src/utils/progress-topics.js +1 -0
  273. package/dist/src/utils/safe-spawn.js +1 -5
  274. package/dist/src/utils/shell-quoting.d.ts +8 -1
  275. package/dist/src/utils/shell-quoting.js +12 -1
  276. package/dist/src/utils/spawn-without-terminal.d.ts +27 -0
  277. package/dist/src/utils/spawn-without-terminal.js +110 -0
  278. package/dist/src/utils/string-similarity.d.ts +38 -0
  279. package/dist/src/utils/string-similarity.js +108 -0
  280. package/dist/src/utils/versions.js +1 -1
  281. package/migrations.json +20 -6
  282. package/package.json +15 -24
  283. package/schemas/migrations-schema.json +11 -0
  284. package/schemas/nx-schema.json +133 -11
  285. package/schemas/project-schema.json +114 -4
  286. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
  287. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
  288. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
  289. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
  290. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
  291. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
  292. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
  293. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
  294. package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
  295. package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
  296. package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
  297. package/dist/src/command-line/migrate/agentic/runner.js +0 -262
  298. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
  299. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
  300. package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +0 -18
  301. package/dist/src/tasks-runner/legacy-depends-on-warning.js +0 -109
@@ -24,7 +24,7 @@ export interface TaskSelection {
24
24
  ultracacheConfigurationOutcome?: UltracacheConfigurationOutcome | null;
25
25
  }
26
26
  import { LifeCycle, TaskResult, TaskResults } from './life-cycle';
27
- import { TasksRunner } from './tasks-runner';
27
+ import { TasksRunner, TaskStatus } from './tasks-runner';
28
28
  /**
29
29
  * `targets` on whole projects, as `run-many` runs them: every task of the
30
30
  * projects' targets and what they depend on, with those tasks initiating.
@@ -43,6 +43,7 @@ export declare function runTasksForCommand(taskSelection: TaskSelection, current
43
43
  loadDotEnvFiles: boolean;
44
44
  }): Promise<{
45
45
  taskResults: TaskResults;
46
+ taskStatuses?: Record<string, TaskStatus>;
46
47
  completed: boolean;
47
48
  }>;
48
49
  export declare function setEnvVarsBasedOnArgs(nxArgs: NxArgs, loadDotEnvFiles: boolean): void;
@@ -60,7 +61,10 @@ export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, life
60
61
  /** Already loaded for this command; `undefined` loads it here. */
61
62
  ultracacheConfigurationOutcome?: UltracacheConfigurationOutcome | null;
62
63
  }): Promise<{
63
- [id: string]: TaskResult;
64
+ taskResults: {
65
+ [id: string]: TaskResult;
66
+ };
67
+ taskStatuses?: Record<string, TaskStatus>;
64
68
  }>;
65
69
  export declare function constructLifeCycles(lifeCycle: LifeCycle, taskGraph: TaskGraph, nxJson?: NxJsonConfiguration, skipNxCache?: boolean): LifeCycle[];
66
70
  /**
@@ -50,9 +50,10 @@ const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle
50
50
  const task_telemetry_life_cycle_1 = require("./life-cycles/task-telemetry-life-cycle");
51
51
  const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
52
52
  const tui_summary_life_cycle_1 = require("./life-cycles/tui-summary-life-cycle");
53
+ const ready_when_1 = require("./readiness/ready-when");
53
54
  const task_graph_utils_1 = require("./task-graph-utils");
54
55
  const utils_1 = require("./utils");
55
- const exit_codes_1 = require("../utils/exit-codes");
56
+ const run_outcome_1 = require("./run-outcome");
56
57
  const handle_import_1 = require("../utils/handle-import");
57
58
  const pc = tslib_1.__importStar(require("picocolors"));
58
59
  const originalStdoutWrite = process.stdout.write.bind(process.stdout);
@@ -80,7 +81,7 @@ const SYNC_SKIPPED_FIX_MESSAGE_LINES = [
80
81
  '',
81
82
  'Run `nx sync` (no flags) later to sync the workspace.',
82
83
  ];
83
- async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides) {
84
+ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, projectGraph, nxArgs, nxJson, overrides) {
84
85
  const overridesWithoutHidden = { ...overrides };
85
86
  delete overridesWithoutHidden['__overrides_unparsed__'];
86
87
  const isRunOne = initiatingProject != null;
@@ -133,7 +134,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
133
134
  pinnedTasks.push(mainTaskId);
134
135
  const mainContinuousDependencies = taskGraph.continuousDependencies[mainTaskId];
135
136
  if (mainContinuousDependencies.length > 0) {
136
- pinnedTasks.push(mainContinuousDependencies[0]);
137
+ pinnedTasks.push(mainContinuousDependencies[0].id);
137
138
  }
138
139
  const [, target] = mainTaskId.split(':');
139
140
  titleText = `1 ${target} task`;
@@ -179,7 +180,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
179
180
  const lifeCycles = [tsLifeCycle];
180
181
  // Only run the TUI if there are tasks to run
181
182
  if (tasks.length > 0) {
182
- appLifeCycle = new AppLifeCycle(tasks, initiatingTasks.map((t) => t.id), isRunOne ? 0 /* RunMode.RunOne */ : 1 /* RunMode.RunMany */, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText, workspace_root_1.workspaceRoot, taskGraph, (0, nx_cloud_utils_1.isNxCloudUsed)(nxJson));
183
+ appLifeCycle = new AppLifeCycle(tasks, initiatingTasks.map((t) => t.id), isRunOne ? 0 /* RunMode.RunOne */ : 1 /* RunMode.RunMany */, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText, workspace_root_1.workspaceRoot, taskGraph, (0, ready_when_1.getReadyDependencies)(taskGraph, projectGraph), (0, nx_cloud_utils_1.isNxCloudUsed)(nxJson));
183
184
  // The native endCommand renders the perf report in the exit popup; the runner
184
185
  // sources the payload and CompositeLifeCycle forwards it here.
185
186
  lifeCycles.unshift(appLifeCycle);
@@ -361,19 +362,14 @@ async function runCommand(taskSelection, currentProjectGraph, { nxJson }, nxArgs
361
362
  argv: process.argv,
362
363
  });
363
364
  const startTime = Date.now();
364
- const { taskResults, completed } = await runTasksForCommand(taskSelection, currentProjectGraph, { nxJson }, {
365
+ const { taskResults, taskStatuses, completed } = await runTasksForCommand(taskSelection, currentProjectGraph, { nxJson }, {
365
366
  ...nxArgs,
366
367
  skipNxCache: nxArgs.skipNxCache ||
367
368
  process.env.NX_SKIP_NX_CACHE === 'true' ||
368
369
  process.env.NX_DISABLE_NX_CACHE === 'true',
369
370
  }, overrides, initiatingProject, extraTargetDependencies, extraOptions);
370
371
  const endTime = Date.now();
371
- const exitCode = !completed
372
- ? (0, exit_codes_1.signalToCode)('SIGINT')
373
- : Object.values(taskResults).some((taskResult) => taskResult.status === 'failure' ||
374
- taskResult.status === 'skipped')
375
- ? 1
376
- : 0;
372
+ const exitCode = (0, run_outcome_1.getRunExitCode)(completed, taskResults, taskStatuses);
377
373
  await (0, tasks_execution_hooks_1.runPostTasksExecution)({
378
374
  id,
379
375
  taskResults,
@@ -401,9 +397,9 @@ async function runTasksForCommand(taskSelection, currentProjectGraph, { nxJson }
401
397
  const projectNames = [
402
398
  ...new Set(initiatingTasks.map((t) => t.target.project)),
403
399
  ];
404
- const { lifeCycle, renderIsDone, printSummary, restoreTerminal } = await getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides);
400
+ const { lifeCycle, renderIsDone, printSummary, restoreTerminal } = await getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, projectGraph, nxArgs, nxJson, overrides);
405
401
  try {
406
- const taskResults = await invokeTasksRunner({
402
+ const { taskResults, taskStatuses } = await invokeTasksRunner({
407
403
  tasks,
408
404
  projectGraph,
409
405
  taskGraph,
@@ -426,7 +422,8 @@ async function runTasksForCommand(taskSelection, currentProjectGraph, { nxJson }
426
422
  logger_1.logger.log((0, nx_key_1.createNxKeyLicenseeInformation)(nxKey));
427
423
  return {
428
424
  taskResults,
429
- completed: didCommandComplete(tasks, taskResults),
425
+ taskStatuses,
426
+ completed: (0, run_outcome_1.didCommandComplete)(tasks, taskResults, taskStatuses),
430
427
  };
431
428
  }
432
429
  catch (e) {
@@ -458,19 +455,6 @@ async function printConfigureAiAgentsDisclaimer() {
458
455
  // Silently ignore errors
459
456
  }
460
457
  }
461
- function didCommandComplete(tasks, taskResults) {
462
- if (tasks.length === 0)
463
- return true;
464
- for (const task of tasks) {
465
- if (!task.continuous) {
466
- // Discrete task must have a result (was started and finished)
467
- if (!taskResults[task.id])
468
- return false;
469
- }
470
- }
471
- // Any stopped task means the run was interrupted
472
- return !Object.values(taskResults).some((r) => r.status === 'stopped');
473
- }
474
458
  async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, nxArgs, overrides, extraTargetDependencies, extraOptions, taskSelection) {
475
459
  let taskGraph = runValidations(projectGraph, taskSelection.taskGraph, nxArgs);
476
460
  if (nxArgs.skipSync || (0, is_ci_1.isCI)()) {
@@ -719,7 +703,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
719
703
  // this is used for two reasons: to fetch all remote cache hits AND
720
704
  // to submit everything that is known in advance to Nx Cloud to run in
721
705
  // a distributed fashion
722
- const deferredTaskIds = await (0, hash_task_1.hashTasksThatDoNotDependOnOutputsOfOtherTasks)(hasher, projectGraph, taskGraph, nxJson, taskDetails, ultracacheConfigurations);
706
+ const hashingDeferredTaskIds = await (0, hash_task_1.hashTasksThatDoNotDependOnOutputsOfOtherTasks)(hasher, projectGraph, taskGraph, nxJson, taskDetails, ultracacheConfigurations);
723
707
  reportUltracacheConfigurations(ultracacheConfigurationOutcome, projectGraph, taskGraph, nxArgs);
724
708
  const taskResultsLifecycle = new task_results_life_cycle_1.TaskResultsLifeCycle();
725
709
  const compositedLifeCycle = new life_cycle_1.CompositeLifeCycle([
@@ -790,13 +774,19 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
790
774
  },
791
775
  },
792
776
  daemon: client_1.daemonClient,
793
- deferredTaskIds,
777
+ hashingDeferredTaskIds,
794
778
  });
795
779
  if (promiseOrObservable.subscribe) {
796
780
  promiseOrObservable = convertObservableToPromise(promiseOrObservable);
797
781
  }
798
- await promiseOrObservable;
799
- return taskResultsLifecycle.getTaskResults();
782
+ const taskStatuses = await promiseOrObservable;
783
+ return {
784
+ taskResults: taskResultsLifecycle.getTaskResults(),
785
+ // Custom runners are not guaranteed to resolve to a status map.
786
+ taskStatuses: taskStatuses && typeof taskStatuses === 'object'
787
+ ? taskStatuses
788
+ : undefined,
789
+ };
800
790
  }
801
791
  function constructLifeCycles(lifeCycle, taskGraph, nxJson, skipNxCache) {
802
792
  const lifeCycles = [];
@@ -0,0 +1,16 @@
1
+ import type { Task } from '../config/task-graph';
2
+ import type { TaskResults } from './life-cycle';
3
+ import type { TaskStatus } from './tasks-runner';
4
+ /**
5
+ * Whether the run got to the end, as opposed to being interrupted.
6
+ *
7
+ * A discrete task skipped because a dependency failed has no `TaskResult`,
8
+ * but the runner still settled it, so it must not make the run look
9
+ * interrupted.
10
+ */
11
+ export declare function didCommandComplete(tasks: Task[], taskResults: TaskResults, taskStatuses?: Record<string, TaskStatus>): boolean;
12
+ /**
13
+ * Exit code for a run: 130 (SIGINT) when it was interrupted, 1 when any task
14
+ * failed or was skipped, 0 otherwise.
15
+ */
16
+ export declare function getRunExitCode(completed: boolean, taskResults: TaskResults, taskStatuses?: Record<string, TaskStatus>): number;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.didCommandComplete = didCommandComplete;
4
+ exports.getRunExitCode = getRunExitCode;
5
+ const exit_codes_1 = require("../utils/exit-codes");
6
+ /**
7
+ * Whether the run got to the end, as opposed to being interrupted.
8
+ *
9
+ * A discrete task skipped because a dependency failed has no `TaskResult`,
10
+ * but the runner still settled it, so it must not make the run look
11
+ * interrupted.
12
+ */
13
+ function didCommandComplete(tasks, taskResults, taskStatuses) {
14
+ if (tasks.length === 0)
15
+ return true;
16
+ for (const task of tasks) {
17
+ if (!task.continuous) {
18
+ // Discrete task must have been settled by the runner
19
+ if (!taskResults[task.id] && !taskStatuses?.[task.id])
20
+ return false;
21
+ }
22
+ }
23
+ // Any stopped task means the run was interrupted
24
+ return (!Object.values(taskResults).some((r) => r.status === 'stopped') &&
25
+ !Object.values(taskStatuses ?? {}).some((s) => s === 'stopped'));
26
+ }
27
+ /**
28
+ * Exit code for a run: 130 (SIGINT) when it was interrupted, 1 when any task
29
+ * failed or was skipped, 0 otherwise.
30
+ */
31
+ function getRunExitCode(completed, taskResults, taskStatuses) {
32
+ if (!completed)
33
+ return (0, exit_codes_1.signalToCode)('SIGINT');
34
+ const failedOrSkipped = (status) => status === 'failure' || status === 'skipped';
35
+ return Object.values(taskResults).some((r) => failedOrSkipped(r.status)) ||
36
+ Object.values(taskStatuses ?? {}).some(failedOrSkipped)
37
+ ? 1
38
+ : 0;
39
+ }
@@ -80,6 +80,12 @@ class BatchProcess {
80
80
  for (const cb of this.batchResultsCallbacks) {
81
81
  cb(message.results);
82
82
  }
83
+ // The worker runs a single batch. Its IPC channel would otherwise
84
+ // keep it alive until cleanup kills it, which waits out the grace
85
+ // period on Windows, where SIGTERM is a no-op.
86
+ if (this.childProcess.connected) {
87
+ this.childProcess.disconnect();
88
+ }
83
89
  break;
84
90
  }
85
91
  case batch_messages_1.BatchMessageType.RunTasks: {
@@ -14,6 +14,9 @@ class NodeChildProcessWithNonDirectOutput {
14
14
  this.terminalOutputChunks = [];
15
15
  this.exitCallbacks = [];
16
16
  this.outputCallbacks = [];
17
+ // Decode as a stream so a code point split across chunks stays intact
18
+ this.childProcess.stdout.setEncoding('utf8');
19
+ this.childProcess.stderr.setEncoding('utf8');
17
20
  if (streamOutput) {
18
21
  if (process.env.NX_PREFIX_OUTPUT === 'true') {
19
22
  const color = (0, output_prefix_1.getColor)(prefix);
@@ -54,16 +57,14 @@ class NodeChildProcessWithNonDirectOutput {
54
57
  process.send(message);
55
58
  }
56
59
  });
57
- this.childProcess.stdout.on('data', (chunk) => {
58
- const output = chunk.toString();
60
+ this.childProcess.stdout.on('data', (output) => {
59
61
  this.terminalOutputChunks.push(output);
60
62
  // Stream output to TUI via callbacks
61
63
  for (const cb of this.outputCallbacks) {
62
64
  cb(output);
63
65
  }
64
66
  });
65
- this.childProcess.stderr.on('data', (chunk) => {
66
- const output = chunk.toString();
67
+ this.childProcess.stderr.on('data', (output) => {
67
68
  this.terminalOutputChunks.push(output);
68
69
  // Stream output to TUI via callbacks
69
70
  for (const cb of this.outputCallbacks) {
@@ -6,6 +6,6 @@ export declare abstract class RunningTask {
6
6
  }>;
7
7
  abstract onExit(cb: (code: number) => void): void;
8
8
  abstract kill(signal?: NodeJS.Signals): Promise<void> | void;
9
- abstract onOutput?(cb: (output: string) => void): void;
9
+ abstract onOutput?(cb: (output: string, isCommandHeader?: boolean) => void): void;
10
10
  abstract send?(message: Serializable): void;
11
11
  }
@@ -37,6 +37,16 @@ export declare function getTaskSpecificEnv(task: Task, graph: ProjectGraph): Nod
37
37
  */
38
38
  export declare function getGraphTimeDotEnvForTask(projectRoot: string, target: string, configuration?: string, nonAtomizedTarget?: string, baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
39
39
  export declare function getEnvVariablesForTask(task: Task, taskSpecificEnv: NodeJS.ProcessEnv, forceColor: string, skipNxCache: boolean, captureStderr: boolean, outputPath: string, streamOutput: boolean): NodeJS.ProcessEnv;
40
+ /**
41
+ * Pids of the nx processes this one is nested inside, outermost first. Empty
42
+ * for a root invocation.
43
+ */
44
+ export declare function getInvocationAncestorPids(): number[];
45
+ /**
46
+ * Pid of the outermost nx process in this tree, which is this process when it
47
+ * is the root.
48
+ */
49
+ export declare function getInvocationRootPid(): number;
40
50
  /**
41
51
  * This function loads one or more .env files and expands the variables in them.
42
52
  * When multiple files are provided, all files are loaded first, then variable
@@ -5,9 +5,12 @@ exports.getEnvVariablesForBatchProcess = getEnvVariablesForBatchProcess;
5
5
  exports.getTaskSpecificEnv = getTaskSpecificEnv;
6
6
  exports.getGraphTimeDotEnvForTask = getGraphTimeDotEnvForTask;
7
7
  exports.getEnvVariablesForTask = getEnvVariablesForTask;
8
+ exports.getInvocationAncestorPids = getInvocationAncestorPids;
9
+ exports.getInvocationRootPid = getInvocationRootPid;
8
10
  exports.loadAndExpandDotEnvFile = loadAndExpandDotEnvFile;
9
11
  exports.unloadDotEnvFile = unloadDotEnvFile;
10
12
  exports.getEnvFilesForTask = getEnvFilesForTask;
13
+ const ready_signal_1 = require("./readiness/ready-signal");
11
14
  const dotenv_1 = require("dotenv");
12
15
  const dotenv_expand_1 = require("dotenv-expand");
13
16
  const node_path_1 = require("node:path");
@@ -39,6 +42,11 @@ function getEnvVariablesForBatchProcess(skipNxCache, captureStderr) {
39
42
  };
40
43
  // NX_ORIGINAL_FORCE_COLOR is an internal signal and should not leak into child processes
41
44
  delete res.NX_ORIGINAL_FORCE_COLOR;
45
+ // The orchestrator sets these for the one task they are meant for, so an
46
+ // Nx run inside that task must not pass them on
47
+ delete res[ready_signal_1.READY_SIGNAL_SOCKET_ENV];
48
+ delete res[ready_signal_1.READY_SIGNAL_TASK_ENV];
49
+ delete res[ready_signal_1.READY_URL_ENV];
42
50
  return res;
43
51
  }
44
52
  // The orchestrator now calls this eagerly during the coordinator pre-hash
@@ -121,6 +129,11 @@ function getEnvVariablesForTask(task, taskSpecificEnv, forceColor, skipNxCache,
121
129
  // NX_ORIGINAL_FORCE_COLOR is an internal signal used by getForceColorForChild()
122
130
  // and should not leak into child processes
123
131
  delete res.NX_ORIGINAL_FORCE_COLOR;
132
+ // The orchestrator sets these for the one task they are meant for, so an
133
+ // Nx run inside that task must not pass them on
134
+ delete res[ready_signal_1.READY_SIGNAL_SOCKET_ENV];
135
+ delete res[ready_signal_1.READY_SIGNAL_TASK_ENV];
136
+ delete res[ready_signal_1.READY_URL_ENV];
124
137
  return res;
125
138
  }
126
139
  function getNxEnvVariablesForForkedProcess(forceColor, skipNxCache, captureStderr, outputPath, streamOutput) {
@@ -128,6 +141,10 @@ function getNxEnvVariablesForForkedProcess(forceColor, skipNxCache, captureStder
128
141
  FORCE_COLOR: forceColor,
129
142
  NX_WORKSPACE_ROOT: workspace_root_1.workspaceRoot,
130
143
  NX_SKIP_NX_CACHE: skipNxCache ? 'true' : undefined,
144
+ // pids of the forked process's ancestor nx processes, outermost first.
145
+ // Only an ancestor re-invoking a task is a loop — sibling nx processes
146
+ // running the same task are legitimate.
147
+ NX_INVOCATION_ANCESTOR_PIDS: appendAncestorPid(process.env.NX_INVOCATION_ANCESTOR_PIDS),
131
148
  };
132
149
  if (outputPath) {
133
150
  env.NX_TERMINAL_OUTPUT_PATH = outputPath;
@@ -140,6 +157,26 @@ function getNxEnvVariablesForForkedProcess(forceColor, skipNxCache, captureStder
140
157
  }
141
158
  return env;
142
159
  }
160
+ function appendAncestorPid(inherited) {
161
+ return inherited ? `${inherited},${process.pid}` : String(process.pid);
162
+ }
163
+ /**
164
+ * Pids of the nx processes this one is nested inside, outermost first. Empty
165
+ * for a root invocation.
166
+ */
167
+ function getInvocationAncestorPids() {
168
+ return (process.env.NX_INVOCATION_ANCESTOR_PIDS ?? '')
169
+ .split(',')
170
+ .map((pid) => Number(pid))
171
+ .filter((pid) => Number.isInteger(pid) && pid > 0);
172
+ }
173
+ /**
174
+ * Pid of the outermost nx process in this tree, which is this process when it
175
+ * is the root.
176
+ */
177
+ function getInvocationRootPid() {
178
+ return getInvocationAncestorPids()[0] ?? process.pid;
179
+ }
143
180
  function getNxEnvVariablesForTask(task, forceColor, skipNxCache, captureStderr, outputPath, streamOutput) {
144
181
  const env = {
145
182
  NX_TASK_TARGET_PROJECT: task.target.project,
@@ -153,16 +190,11 @@ function getNxEnvVariablesForTask(task, forceColor, skipNxCache, captureStderr,
153
190
  if (task.target.target === 'test') {
154
191
  env.NX_TERMINAL_CAPTURE_STDERR = 'true';
155
192
  }
156
- // Pass the root Nx process PID to nested processes for DB-based loop detection.
157
- // The root PID is used as a key in the task_invocations table to track which tasks
158
- // have been invoked across nested Nx processes.
159
193
  return {
160
194
  ...getNxEnvVariablesForForkedProcess(forceColor, skipNxCache, captureStderr, outputPath, streamOutput),
161
195
  ...env,
162
196
  // Ensure the TUI does not get spawned within the TUI if ever tasks invoke Nx again
163
197
  NX_TUI: 'false',
164
- // tracks the root PID for child nx tasks, used to verify nx is infinitely recursing through the same tasks
165
- NX_INVOCATION_ROOT_PID: process.env.NX_INVOCATION_ROOT_PID ?? String(process.pid),
166
198
  };
167
199
  }
168
200
  /**
@@ -1,24 +1,26 @@
1
1
  import { ProjectGraph } from '../config/project-graph';
2
- import { TaskGraph } from '../config/task-graph';
2
+ import { TaskGraph, TaskGraphEdge } from '../config/task-graph';
3
+ /** Task graph edges, or the project ids of the command graph. */
4
+ type Edge = string | TaskGraphEdge;
3
5
  /**
4
6
  * This function finds a cycle in the graph.
5
7
  * @returns the first cycle found, or null if no cycle is found.
6
8
  */
7
9
  export declare function findCycle(graph: {
8
- dependencies: Record<string, string[]>;
9
- continuousDependencies?: Record<string, string[]>;
10
+ dependencies: Record<string, Edge[]>;
11
+ continuousDependencies?: Record<string, Edge[]>;
10
12
  }): string[] | null;
11
13
  /**
12
14
  * This function finds all cycles in the graph.
13
15
  * @returns a list of unique task ids in all cycles found, or null if no cycle is found.
14
16
  */
15
17
  export declare function findCycles(graph: {
16
- dependencies: Record<string, string[]>;
17
- continuousDependencies?: Record<string, string[]>;
18
+ dependencies: Record<string, Edge[]>;
19
+ continuousDependencies?: Record<string, Edge[]>;
18
20
  }): Set<string> | null;
19
21
  export declare function makeAcyclic(graph: {
20
22
  roots: string[];
21
- dependencies: Record<string, string[]>;
23
+ dependencies: Record<string, Edge[]>;
22
24
  }): void;
23
25
  export declare function validateNoAtomizedTasks(taskGraph: TaskGraph, projectGraph: ProjectGraph): void;
24
26
  export declare function assertTaskGraphDoesNotContainInvalidTargets(taskGraph: TaskGraph): void;
@@ -28,3 +30,4 @@ export declare function getLeafTasks(taskGraph: TaskGraph): Set<string>;
28
30
  * Considers both dependencies and continuousDependencies.
29
31
  */
30
32
  export declare function walkTaskGraph(taskGraph: TaskGraph, walkFn: (rootTaskIds: string[]) => Promise<void>): Promise<void>;
33
+ export {};
@@ -8,6 +8,9 @@ exports.assertTaskGraphDoesNotContainInvalidTargets = assertTaskGraphDoesNotCont
8
8
  exports.getLeafTasks = getLeafTasks;
9
9
  exports.walkTaskGraph = walkTaskGraph;
10
10
  const output_1 = require("../utils/output");
11
+ function edgeId(edge) {
12
+ return typeof edge === 'string' ? edge : edge.id;
13
+ }
11
14
  function _findCycle(graph, id, visited, path) {
12
15
  if (visited[id])
13
16
  return null;
@@ -15,7 +18,7 @@ function _findCycle(graph, id, visited, path) {
15
18
  for (const d of [
16
19
  ...graph.dependencies[id],
17
20
  ...(graph.continuousDependencies?.[id] ?? []),
18
- ]) {
21
+ ].map(edgeId)) {
19
22
  if (path.includes(d))
20
23
  return [...path, d];
21
24
  const cycle = _findCycle(graph, d, visited, [...path, d]);
@@ -64,13 +67,13 @@ function _makeAcyclic(graph, id, visited, path) {
64
67
  visited[id] = true;
65
68
  const deps = graph.dependencies[id];
66
69
  const continuousDeps = graph.continuousDependencies?.[id] ?? [];
67
- for (const d of [...deps, ...continuousDeps]) {
70
+ for (const d of [...deps, ...continuousDeps].map(edgeId)) {
68
71
  if (path.includes(d)) {
69
- const depsIdx = deps.indexOf(d);
72
+ const depsIdx = deps.findIndex((edge) => edgeId(edge) === d);
70
73
  if (depsIdx >= 0) {
71
74
  deps.splice(depsIdx, 1);
72
75
  }
73
- const continuousIdx = continuousDeps.indexOf(d);
76
+ const continuousIdx = continuousDeps.findIndex((edge) => edgeId(edge) === d);
74
77
  if (continuousIdx >= 0) {
75
78
  continuousDeps.splice(continuousIdx, 1);
76
79
  }
@@ -131,7 +134,7 @@ function assertTaskGraphDoesNotContainInvalidTargets(taskGraph) {
131
134
  taskGraph.continuousDependencies[task.id].length > 0) {
132
135
  nonParallelTasksThatDependOnContinuousTasks.push(task);
133
136
  }
134
- for (const dependency of taskGraph.continuousDependencies[task.id]) {
137
+ for (const { id: dependency } of taskGraph.continuousDependencies[task.id]) {
135
138
  if (taskGraph.tasks[dependency].parallelism === false) {
136
139
  nonParallelContinuousTasksThatAreDependedOn.push(taskGraph.tasks[dependency]);
137
140
  }
@@ -148,7 +151,9 @@ class NonParallelTaskDependsOnContinuousTasksError extends Error {
148
151
  constructor(invalidTasks, taskGraph) {
149
152
  let message = 'The following tasks do not support parallelism but depend on continuous tasks:';
150
153
  for (const task of invalidTasks) {
151
- message += `\n - ${task.id} -> ${taskGraph.continuousDependencies[task.id].join(', ')}`;
154
+ message += `\n - ${task.id} -> ${taskGraph.continuousDependencies[task.id]
155
+ .map((edge) => edge.id)
156
+ .join(', ')}`;
152
157
  }
153
158
  super(message);
154
159
  this.invalidTasks = invalidTasks;
@@ -159,7 +164,7 @@ class DependingOnNonParallelContinuousTaskError extends Error {
159
164
  constructor(invalidTasks, taskGraph) {
160
165
  let message = 'The following continuous tasks do not support parallelism but are depended on:';
161
166
  for (const task of invalidTasks) {
162
- const dependents = Object.keys(taskGraph.continuousDependencies).filter((parentTaskId) => taskGraph.continuousDependencies[parentTaskId].includes(task.id));
167
+ const dependents = Object.keys(taskGraph.continuousDependencies).filter((parentTaskId) => taskGraph.continuousDependencies[parentTaskId].some((edge) => edge.id === task.id));
163
168
  message += `\n - ${task.id} <- ${dependents.join(', ')}`;
164
169
  }
165
170
  message +=
@@ -185,13 +190,13 @@ function reverseTaskGraph(taskGraph) {
185
190
  dependencies: Object.fromEntries(Object.entries(taskGraph.tasks).map(([taskId]) => [taskId, []])),
186
191
  };
187
192
  for (const [taskId, dependencies] of Object.entries(taskGraph.dependencies)) {
188
- for (const dependency of dependencies) {
189
- reversed.dependencies[dependency].push(taskId);
193
+ for (const { id: dependency } of dependencies) {
194
+ reversed.dependencies[dependency].push({ id: taskId });
190
195
  }
191
196
  }
192
197
  for (const [taskId, dependencies] of Object.entries(taskGraph.continuousDependencies)) {
193
- for (const dependency of dependencies) {
194
- reversed.dependencies[dependency].push(taskId);
198
+ for (const { id: dependency } of dependencies) {
199
+ reversed.dependencies[dependency].push({ id: taskId });
195
200
  }
196
201
  }
197
202
  return reversed;
@@ -213,7 +218,7 @@ async function walkTaskGraph(taskGraph, walkFn) {
213
218
  await walkFn(currentRoots);
214
219
  const nextRoots = [];
215
220
  for (const id of currentRoots) {
216
- for (const depId of reversed.dependencies[id] ?? []) {
221
+ for (const { id: depId } of reversed.dependencies[id] ?? []) {
217
222
  inDegree[depId]--;
218
223
  if (inDegree[depId] === 0) {
219
224
  nextRoots.push(depId);