@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
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SeriallyRunningTasks = exports.ParallelRunningTasks = void 0;
4
4
  exports.runSingleCommandWithPseudoTerminal = runSingleCommandWithPseudoTerminal;
5
+ exports.calculateCwd = calculateCwd;
6
+ exports.processEnv = processEnv;
5
7
  const tslib_1 = require("tslib");
6
8
  const pc = tslib_1.__importStar(require("picocolors"));
7
9
  const child_process_1 = require("child_process");
@@ -10,6 +12,7 @@ const path_1 = require("path");
10
12
  const native_1 = require("../../native");
11
13
  const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
12
14
  const task_env_1 = require("../../tasks-runner/task-env");
15
+ const tokens_1 = require("../../tasks-runner/tokens");
13
16
  const task_io_service_1 = require("../../tasks-runner/task-io-service");
14
17
  const exit_codes_1 = require("../../utils/exit-codes");
15
18
  const output_1 = require("../../utils/output");
@@ -38,15 +41,23 @@ function streamChunk(chunk, streamOutput, target = process.stdout) {
38
41
  function commandExitedNonZeroWarning(command) {
39
42
  return `Warning: command "${command}" exited with non-zero status code`;
40
43
  }
44
+ function commandsExitedBeforeReadyWarning(commands, readyWhenStatus) {
45
+ const exited = commands.length === 1 ? `command "${commands[0].command}"` : 'all commands';
46
+ const missing = readyWhenStatus
47
+ .filter(({ found }) => !found)
48
+ .map(({ stringToMatch }) => `"${stringToMatch}"`)
49
+ .join(', ');
50
+ return `Warning: ${exited} exited before printing the readyWhen text ${missing}`;
51
+ }
41
52
  class ParallelRunningTasks {
42
- constructor(options, context, task) {
53
+ constructor(options, context, task, baseEnv) {
43
54
  this.exitCallbacks = [];
44
55
  this.outputCallbacks = [];
45
56
  // Memoized exit so late getResults()/onExit() callers don't hang.
46
57
  this.exited = false;
47
58
  this.exitCode = 0;
48
59
  this.exitTerminalOutput = '';
49
- this.childProcesses = options.commands.map((commandConfig) => new RunningNodeProcess(commandConfig, options.color, calculateCwd(options.cwd, context), options.env ?? {}, options.readyWhenStatus, options.streamOutput, options.envFile, task));
60
+ this.childProcesses = options.commands.map((commandConfig) => new RunningNodeProcess(commandConfig, options.color, calculateCwd(options.cwd, context), options.env ?? {}, options.readyWhenStatus, options.streamOutput, options.envFile, task, baseEnv));
50
61
  this.readyWhenStatus = options.readyWhenStatus;
51
62
  this.streamOutput = options.streamOutput;
52
63
  this.run();
@@ -91,19 +102,32 @@ class ParallelRunningTasks {
91
102
  }
92
103
  async run() {
93
104
  if (this.readyWhenStatus.length) {
94
- let { childProcess, result: { code, terminalOutput }, } = await Promise.race(this.childProcesses.map((childProcess) => new Promise((res) => {
95
- childProcess.onOutput((terminalOutput) => {
96
- for (const cb of this.outputCallbacks) {
97
- cb(terminalOutput);
98
- }
99
- });
100
- childProcess.onExit((code, terminalOutput) => {
101
- res({
102
- childProcess,
103
- result: { code, terminalOutput },
105
+ const settled = await Promise.race([
106
+ ...this.childProcesses.map((childProcess) => new Promise((res) => {
107
+ childProcess.onOutput((terminalOutput) => {
108
+ for (const cb of this.outputCallbacks) {
109
+ cb(terminalOutput);
110
+ }
104
111
  });
105
- });
106
- })));
112
+ childProcess.onExit((code, terminalOutput) => {
113
+ res({
114
+ childProcess,
115
+ result: { code, terminalOutput },
116
+ });
117
+ });
118
+ })),
119
+ Promise.all(this.childProcesses.map((childProcess) => childProcess.outputWhenClosed())).then((outputs) => ({ outputsOfExitedCommands: outputs })),
120
+ ]);
121
+ if ('outputsOfExitedCommands' in settled) {
122
+ const warning = commandsExitedBeforeReadyWarning(this.childProcesses, this.readyWhenStatus);
123
+ for (const cb of this.outputCallbacks) {
124
+ cb(warning);
125
+ }
126
+ streamChunk(warning, this.streamOutput, process.stderr);
127
+ this.emitExit(1, settled.outputsOfExitedCommands.join('\r\n') + warning);
128
+ return;
129
+ }
130
+ let { childProcess, result: { code, terminalOutput }, } = settled;
107
131
  if (code !== 0) {
108
132
  const warning = commandExitedNonZeroWarning(childProcess.command);
109
133
  terminalOutput += warning;
@@ -156,9 +180,10 @@ class ParallelRunningTasks {
156
180
  }
157
181
  exports.ParallelRunningTasks = ParallelRunningTasks;
158
182
  class SeriallyRunningTasks {
159
- constructor(options, context, tuiEnabled, task) {
183
+ constructor(options, context, tuiEnabled, task, baseEnv) {
160
184
  this.tuiEnabled = tuiEnabled;
161
185
  this.task = task;
186
+ this.baseEnv = baseEnv;
162
187
  this.terminalOutputChunks = [];
163
188
  this.currentProcess = null;
164
189
  this.exitCallbacks = [];
@@ -225,11 +250,11 @@ class SeriallyRunningTasks {
225
250
  }
226
251
  async run(options, context) {
227
252
  for (const c of options.commands) {
228
- const childProcess = await this.createProcess(c, options.color, calculateCwd(options.cwd, context), options.processEnv ?? options.env ?? {}, this.task, options.usePty, options.streamOutput, options.tty, options.envFile);
253
+ const childProcess = await this.createProcess(c, options.color, calculateCwd(options.cwd, context), options.processEnv ?? options.env ?? {}, this.task, options.usePty, options.streamOutput, options.tty, options.envFile, this.baseEnv);
229
254
  this.currentProcess = childProcess;
230
- childProcess.onOutput((output) => {
255
+ childProcess.onOutput((output, isCommandHeader) => {
231
256
  for (const cb of this.outputCallbacks) {
232
- cb(output);
257
+ cb(output, isCommandHeader);
233
258
  }
234
259
  });
235
260
  let { code, terminalOutput } = await childProcess.getResults();
@@ -244,7 +269,7 @@ class SeriallyRunningTasks {
244
269
  }
245
270
  }
246
271
  }
247
- async createProcess(commandConfig, color, cwd, env, task, usePty = true, streamOutput = true, tty, envFile) {
272
+ async createProcess(commandConfig, color, cwd, env, task, usePty = true, streamOutput = true, tty, envFile, baseEnv) {
248
273
  // The rust runCommand is always a tty, so it will not look nice in parallel and if we need prefixes
249
274
  // currently does not work properly in windows
250
275
  if (process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
@@ -253,7 +278,7 @@ class SeriallyRunningTasks {
253
278
  pseudo_terminal_1.PseudoTerminal.isSupported()) {
254
279
  const pseudoTerminal = (0, pseudo_terminal_1.createPseudoTerminal)();
255
280
  registerProcessListener(this, pseudoTerminal);
256
- const pseudoTtyProcess = await createProcessWithPseudoTty(pseudoTerminal, commandConfig, color, cwd, env, streamOutput, tty, envFile);
281
+ const pseudoTtyProcess = await createProcessWithPseudoTty(pseudoTerminal, commandConfig, color, cwd, env, streamOutput, tty, envFile, baseEnv);
257
282
  // Register process for metrics collection (direct run-commands execution)
258
283
  // Skip registration if we're in a forked executor - the fork wrapper already registered
259
284
  const pid = pseudoTtyProcess.getPid();
@@ -262,16 +287,55 @@ class SeriallyRunningTasks {
262
287
  }
263
288
  return pseudoTtyProcess;
264
289
  }
265
- return new RunningNodeProcess(commandConfig, color, cwd, env, [], streamOutput, envFile, task);
290
+ return new RunningNodeProcess(commandConfig, color, cwd, env, [], streamOutput, envFile, task, baseEnv);
266
291
  }
267
292
  }
268
293
  exports.SeriallyRunningTasks = SeriallyRunningTasks;
294
+ // Running children share one process listener per event instead of adding one
295
+ // each. The listeners are removed once the last child exits: a signal handler
296
+ // left behind would stop a forked executor from exiting on that signal.
297
+ const runningNodeProcesses = new Set();
298
+ function killRunningNodeProcessesOnExit() {
299
+ for (const runningNodeProcess of runningNodeProcesses) {
300
+ runningNodeProcess.killOnExit();
301
+ }
302
+ }
303
+ function terminateRunningNodeProcesses() {
304
+ for (const runningNodeProcess of runningNodeProcesses) {
305
+ runningNodeProcess.kill('SIGTERM');
306
+ }
307
+ }
308
+ function trackRunningNodeProcess(runningNodeProcess) {
309
+ if (runningNodeProcesses.size === 0) {
310
+ process.on('exit', killRunningNodeProcessesOnExit);
311
+ // In the direct path, detached children don't get OS SIGINT (own process
312
+ // group via setsid); the orchestrator's cleanup() sends SIGTERM via
313
+ // killProcessTreeGraceful. Signal handlers here are only needed in the
314
+ // forked path where there's no orchestrator to dispatch signals.
315
+ if (process.env.NX_FORKED_TASK_EXECUTOR) {
316
+ process.on('SIGINT', terminateRunningNodeProcesses);
317
+ process.on('SIGTERM', terminateRunningNodeProcesses);
318
+ process.on('SIGHUP', terminateRunningNodeProcesses);
319
+ }
320
+ }
321
+ runningNodeProcesses.add(runningNodeProcess);
322
+ }
323
+ function untrackRunningNodeProcess(runningNodeProcess) {
324
+ if (!runningNodeProcesses.delete(runningNodeProcess) ||
325
+ runningNodeProcesses.size > 0) {
326
+ return;
327
+ }
328
+ process.removeListener('exit', killRunningNodeProcessesOnExit);
329
+ process.removeListener('SIGINT', terminateRunningNodeProcesses);
330
+ process.removeListener('SIGTERM', terminateRunningNodeProcesses);
331
+ process.removeListener('SIGHUP', terminateRunningNodeProcesses);
332
+ }
269
333
  class RunningNodeProcess {
270
334
  /** This class's writes, funnelled through {@link streamChunk}. */
271
335
  stream(chunk, target = process.stdout) {
272
336
  streamChunk(chunk, this.streamOutput, target);
273
337
  }
274
- constructor(commandConfig, color, cwd, env, readyWhenStatus, streamOutput = true, envFile, task) {
338
+ constructor(commandConfig, color, cwd, env, readyWhenStatus, streamOutput = true, envFile, task, baseEnv) {
275
339
  this.readyWhenStatus = readyWhenStatus;
276
340
  this.streamOutput = streamOutput;
277
341
  this.task = task;
@@ -283,7 +347,7 @@ class RunningNodeProcess {
283
347
  this.exited = false;
284
348
  this.exitCode = 0;
285
349
  this.exitTerminalOutput = '';
286
- env = processEnv(color, cwd, env, envFile);
350
+ env = processEnv(color, cwd, env, envFile, baseEnv);
287
351
  this.command = commandConfig.command;
288
352
  const header = pc.dim('> ') + commandConfig.command + '\r\n\r\n';
289
353
  this.terminalOutputChunks.push(header);
@@ -334,6 +398,10 @@ class RunningNodeProcess {
334
398
  send(message) {
335
399
  this.childProcess.send(message);
336
400
  }
401
+ async outputWhenClosed() {
402
+ await this.closedPromise;
403
+ return this.terminalOutputChunks.join('');
404
+ }
337
405
  emitExit(code, terminalOutput) {
338
406
  if (this.exited)
339
407
  return;
@@ -361,46 +429,30 @@ class RunningNodeProcess {
361
429
  ]));
362
430
  return this.killPromise;
363
431
  }
432
+ // Last resort on process exit, so it has to be sync. A graceful kill in
433
+ // progress tracks cleanup subprocesses that this must not interfere with.
434
+ killOnExit() {
435
+ if (this.childProcess.pid && !this.killPromise) {
436
+ (0, native_1.killProcessTree)(this.childProcess.pid);
437
+ }
438
+ }
364
439
  triggerOutputListeners(output) {
365
440
  for (const cb of this.outputCallbacks) {
366
441
  cb(output);
367
442
  }
368
443
  }
369
444
  addListeners(commandConfig) {
370
- // Named handlers so they can be removed when the child exits.
371
- // Otherwise each RunningNodeProcess leaks process listeners; with
372
- // many run-commands tasks this triggers MaxListenersExceededWarning.
373
- const isForked = !!process.env.NX_FORKED_TASK_EXECUTOR;
374
- const onProcessExit = () => {
375
- if (this.childProcess.pid && !this.killPromise) {
376
- (0, native_1.killProcessTree)(this.childProcess.pid);
377
- }
378
- };
379
- const onSigInt = () => {
380
- this.kill('SIGTERM');
381
- };
382
- const onSigTerm = () => {
383
- this.kill('SIGTERM');
384
- };
385
- const onSigHup = () => {
386
- this.kill('SIGTERM');
387
- };
388
- const removeProcessListeners = () => {
389
- process.removeListener('exit', onProcessExit);
390
- if (isForked) {
391
- process.removeListener('SIGINT', onSigInt);
392
- process.removeListener('SIGTERM', onSigTerm);
393
- process.removeListener('SIGHUP', onSigHup);
394
- }
395
- };
396
445
  this.childProcess.stdout.setEncoding('utf8');
397
446
  this.childProcess.stderr.setEncoding('utf8');
447
+ // Separate matchers, so a ready string never spans stdout and stderr
448
+ const stdoutReady = readyWhenMatcher(this.readyWhenStatus);
449
+ const stderrReady = readyWhenMatcher(this.readyWhenStatus);
398
450
  this.childProcess.stdout.on('data', (data) => {
399
451
  const output = addColorAndPrefix(data, commandConfig);
400
452
  this.terminalOutputChunks.push(output);
401
453
  this.triggerOutputListeners(output);
402
454
  this.stream(output);
403
- if (this.readyWhenStatus.length && isReady(this.readyWhenStatus, data)) {
455
+ if (this.readyWhenStatus.length && stdoutReady(data)) {
404
456
  for (const cb of this.exitCallbacks) {
405
457
  cb(0, this.terminalOutputChunks.join(''));
406
458
  }
@@ -411,9 +463,9 @@ class RunningNodeProcess {
411
463
  this.terminalOutputChunks.push(output);
412
464
  this.triggerOutputListeners(output);
413
465
  this.stream(output, process.stderr);
414
- if (this.readyWhenStatus.length && isReady(this.readyWhenStatus, err)) {
466
+ if (this.readyWhenStatus.length && stderrReady(err)) {
415
467
  for (const cb of this.exitCallbacks) {
416
- cb(1, this.terminalOutputChunks.join(''));
468
+ cb(0, this.terminalOutputChunks.join(''));
417
469
  }
418
470
  }
419
471
  });
@@ -423,44 +475,31 @@ class RunningNodeProcess {
423
475
  this.stream(output, process.stderr);
424
476
  const terminalOutput = this.terminalOutputChunks.join('');
425
477
  this.terminalOutputChunks = [];
426
- removeProcessListeners();
478
+ untrackRunningNodeProcess(this);
427
479
  this.emitExit(1, terminalOutput);
428
480
  });
429
481
  this.childProcess.on('exit', (code, signal) => {
430
482
  if (code === null) {
431
483
  code = (0, exit_codes_1.signalToCode)(signal);
432
484
  }
433
- removeProcessListeners();
485
+ untrackRunningNodeProcess(this);
486
+ if (code === 0 &&
487
+ this.readyWhenStatus.length &&
488
+ !isReady(this.readyWhenStatus)) {
489
+ // A parallel companion may still print the readyWhen text. Keep the
490
+ // output for ParallelRunningTasks, which decides once all have closed.
491
+ return;
492
+ }
434
493
  const terminalOutput = this.terminalOutputChunks.join('');
435
494
  this.terminalOutputChunks = [];
436
- if (!this.readyWhenStatus.length || isReady(this.readyWhenStatus)) {
437
- this.emitExit(code, terminalOutput);
438
- }
439
- else if (code !== 0) {
440
- // Process crashed before readyWhen matched; surface the failure so
441
- // awaiters unblock. A clean exit (code 0) is left as-is — a parallel
442
- // companion command may still produce the readyWhen output.
443
- this.emitExit(code, terminalOutput);
444
- }
495
+ this.emitExit(code, terminalOutput);
445
496
  });
446
- // Terminate any task processes on exit (sync, last resort).
447
- // Skip if graceful kill is already in progress — it tracks cleanup
448
- // subprocesses and we must not interfere with them.
449
- process.on('exit', onProcessExit);
450
- // In the direct path, detached children don't get OS SIGINT (own process
451
- // group via setsid); the orchestrator's cleanup() sends SIGTERM via
452
- // killProcessTreeGraceful. Signal handlers here are only needed in the
453
- // forked path where there's no orchestrator to dispatch signals.
454
- if (isForked) {
455
- process.on('SIGINT', onSigInt);
456
- process.on('SIGTERM', onSigTerm);
457
- process.on('SIGHUP', onSigHup);
458
- }
497
+ trackRunningNodeProcess(this);
459
498
  }
460
499
  }
461
- async function runSingleCommandWithPseudoTerminal(normalized, context, task) {
500
+ async function runSingleCommandWithPseudoTerminal(normalized, context, task, baseEnv) {
462
501
  const pseudoTerminal = (0, pseudo_terminal_1.createPseudoTerminal)();
463
- const pseudoTtyProcess = await createProcessWithPseudoTty(pseudoTerminal, normalized.commands[0], normalized.color, calculateCwd(normalized.cwd, context), normalized.env, normalized.streamOutput, pseudoTerminal ? normalized.isTTY : false, normalized.envFile);
502
+ const pseudoTtyProcess = await createProcessWithPseudoTty(pseudoTerminal, normalized.commands[0], normalized.color, calculateCwd(normalized.cwd, context), normalized.env, normalized.streamOutput, pseudoTerminal ? normalized.isTTY : false, normalized.envFile, baseEnv);
464
503
  // Register process for metrics collection (direct run-commands execution)
465
504
  // Skip registration if we're in a forked executor - the fork wrapper already registered
466
505
  const pid = pseudoTtyProcess.getPid();
@@ -470,10 +509,10 @@ async function runSingleCommandWithPseudoTerminal(normalized, context, task) {
470
509
  registerProcessListener(pseudoTtyProcess, pseudoTerminal);
471
510
  return pseudoTtyProcess;
472
511
  }
473
- async function createProcessWithPseudoTty(pseudoTerminal, commandConfig, color, cwd, env, streamOutput = true, tty, envFile) {
512
+ async function createProcessWithPseudoTty(pseudoTerminal, commandConfig, color, cwd, env, streamOutput = true, tty, envFile, baseEnv) {
474
513
  return pseudoTerminal.runCommand(commandConfig.command, {
475
514
  cwd,
476
- jsEnv: processEnv(color, cwd, env, envFile),
515
+ jsEnv: processEnv(color, cwd, env, envFile, baseEnv),
477
516
  quiet: !streamOutput,
478
517
  tty,
479
518
  });
@@ -511,15 +550,15 @@ function calculateCwd(cwd, context) {
511
550
  * Env variables are processed in the following order:
512
551
  * - env option from executor options
513
552
  * - env file from envFile option if provided
514
- * - local env variables
553
+ * - local env variables, read from `baseEnv`
515
554
  */
516
- function processEnv(color, cwd, envOptionFromExecutor, envFile) {
517
- let localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() });
555
+ function processEnv(color, cwd, envOptionFromExecutor, envFile, baseEnv = process.env) {
556
+ let localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd(), env: baseEnv });
518
557
  localEnv = {
519
- ...process.env,
558
+ ...baseEnv,
520
559
  ...localEnv,
521
560
  };
522
- if (process.env.NX_LOAD_DOT_ENV_FILES !== 'false' && envFile) {
561
+ if ((0, tokens_1.readEnv)(baseEnv, 'NX_LOAD_DOT_ENV_FILES') !== 'false' && envFile) {
523
562
  loadEnvVarsFile(envFile, localEnv);
524
563
  }
525
564
  let res = {
@@ -539,17 +578,31 @@ function processEnv(color, cwd, envOptionFromExecutor, envFile) {
539
578
  delete res.NX_PREFIX_OUTPUT;
540
579
  return res;
541
580
  }
542
- function isReady(readyWhenStatus = [], data) {
543
- if (data) {
544
- for (const readyWhenElement of readyWhenStatus) {
545
- if (data.toString().indexOf(readyWhenElement.stringToMatch) > -1) {
546
- readyWhenElement.found = true;
547
- break;
548
- }
549
- }
550
- }
581
+ function isReady(readyWhenStatus) {
551
582
  return readyWhenStatus.every((readyWhenElement) => readyWhenElement.found);
552
583
  }
584
+ // The output as printed, kept across chunks, matches strings that hold escape
585
+ // sequences. LogMatcher, absent from the WASM binding, matches text with
586
+ // escapes inside it.
587
+ function readyWhenMatcher(readyWhenStatus) {
588
+ const matchers = readyWhenStatus.map((status) => ({
589
+ status,
590
+ matcher: native_1.IS_WASM ? null : new native_1.LogMatcher([status.stringToMatch]),
591
+ tail: '',
592
+ }));
593
+ return (chunk) => {
594
+ for (const entry of matchers) {
595
+ const { status, matcher } = entry;
596
+ if (status.found)
597
+ continue;
598
+ const printed = entry.tail + chunk;
599
+ status.found =
600
+ printed.includes(status.stringToMatch) || !!matcher?.feed(chunk);
601
+ entry.tail = printed.slice(Math.max(0, printed.length - status.stringToMatch.length + 1));
602
+ }
603
+ return isReady(readyWhenStatus);
604
+ };
605
+ }
553
606
  function loadEnvVarsFile(path, env = {}) {
554
607
  (0, task_env_1.unloadDotEnvFile)(path, env);
555
608
  const result = (0, task_env_1.loadAndExpandDotEnvFile)(path, env);
@@ -574,7 +627,7 @@ function registerProcessListener(runningTask, pseudoTerminal) {
574
627
  }
575
628
  });
576
629
  // Terminate any task processes on exit (sync, last resort).
577
- // The per-child exit handlers and PseudoTerminal.shutdown() use the
630
+ // killRunningNodeProcessesOnExit and PseudoTerminal.shutdown() use the
578
631
  // sync killProcessTree for this path. We call kill() here as a
579
632
  // best-effort fallback — it returns a Promise but on 'exit' only
580
633
  // synchronous work runs, so the initial signal is sent but the
@@ -123,7 +123,7 @@
123
123
  "x-priority": "important"
124
124
  },
125
125
  "readyWhen": {
126
- "description": "String or array of strings to appear in `stdout` or `stderr` that indicate that the task is done. When running multiple commands, this option can only be used when `parallel` is set to `true`. If not specified, the task is done when all the child processes complete.",
126
+ "description": "String or array of strings to appear in `stdout` or `stderr` that indicate that the task is done. Unless the target is `continuous`, the task fails if every command exits before printing them. When running multiple commands, this option can only be used when `parallel` is set to `true`. If not specified, the task is done when all the child processes complete.",
127
127
  "oneOf": [
128
128
  { "type": "string" },
129
129
  { "type": "array", "items": { "type": "string" } }
@@ -128,10 +128,7 @@ function getUnresolvedOutputs(taskId, projectGraph) {
128
128
  ? targetConfig.configurations?.[configuration]
129
129
  : undefined),
130
130
  };
131
- return (targetConfig.outputs ?? []).filter((output) => [...output.matchAll(/\{options\.([^}]+)\}/g)].some(([, key]) => {
132
- const value = key.split('.').reduce((acc, k) => acc?.[k], options);
133
- return value === undefined;
134
- }));
131
+ return (targetConfig.outputs ?? []).filter((output) => /{options.*}/.test((0, utils_1.interpolateOutput)(output, projectNode, options)));
135
132
  }
136
133
  function getTaskGraph(taskId, projectGraph) {
137
134
  const cached = taskGraphCache.get(taskId);
@@ -154,14 +151,14 @@ function getDepsOutputs(taskId, { projectGraph, nxJson }) {
154
151
  function collectUpstreamTaskIds(taskGraph, rootTaskId, transitive) {
155
152
  const direct = taskGraph.dependencies[rootTaskId] ?? [];
156
153
  if (!transitive)
157
- return [...direct];
154
+ return direct.map((dep) => dep.id);
158
155
  const collected = new Set();
159
156
  const walk = (id) => {
160
157
  for (const dep of taskGraph.dependencies[id] ?? []) {
161
- if (collected.has(dep))
158
+ if (collected.has(dep.id))
162
159
  continue;
163
- collected.add(dep);
164
- walk(dep);
160
+ collected.add(dep.id);
161
+ walk(dep.id);
165
162
  }
166
163
  };
167
164
  walk(rootTaskId);
@@ -3,21 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hashArray = hashArray;
4
4
  exports.hashObject = hashObject;
5
5
  exports.hashFile = hashFile;
6
+ // Loaded on first use; a top-level import breaks unit tests in the Nx repo.
7
+ // Cached because each `require` call re-resolves the module.
8
+ let native;
9
+ function getNative() {
10
+ return (native ??= require('../native'));
11
+ }
6
12
  function hashArray(content) {
7
- // Import as needed. There is also an issue running unit tests in Nx repo if this is a top-level import.
8
- const { hashArray } = require('../native');
9
- return hashArray(content);
13
+ return getNative().hashArray(content);
10
14
  }
11
15
  function hashObject(obj) {
12
- const { hashArray } = require('../native');
13
16
  const parts = [];
14
17
  for (const key of Object.keys(obj ?? {}).sort()) {
15
18
  parts.push(key);
16
19
  parts.push(JSON.stringify(obj[key]));
17
20
  }
18
- return hashArray(parts);
21
+ return getNative().hashArray(parts);
19
22
  }
20
23
  function hashFile(filePath) {
21
- const { hashFile } = require('../native');
22
- return hashFile(filePath);
24
+ return getNative().hashFile(filePath);
23
25
  }
@@ -9,6 +9,7 @@ const native_1 = require("../native");
9
9
  const project_graph_1 = require("../project-graph/project-graph");
10
10
  const task_io_service_1 = require("../tasks-runner/task-io-service");
11
11
  const task_env_1 = require("../tasks-runner/task-env");
12
+ // TODO(v25): remove custom hasher support.
12
13
  const utils_1 = require("../tasks-runner/utils");
13
14
  const db_connection_1 = require("../utils/db-connection");
14
15
  const task_hasher_1 = require("./task-hasher");
@@ -32,6 +33,7 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
32
33
  ? new Set((0, native_1.getUltracacheDeferredTaskIds)(ultracacheConfigurations, taskGraph))
33
34
  : null;
34
35
  const tasks = Object.values(taskGraph.tasks);
36
+ // TODO(v25): remove custom hasher support.
35
37
  const tasksWithHashers = await Promise.all(tasks.map(async (task) => {
36
38
  const customHasher = (0, utils_1.getCustomHasher)(task, projects);
37
39
  return { task, customHasher };
@@ -81,6 +83,7 @@ function readsDependencyOutputs(task, taskGraph, projectGraph, nxJson) {
81
83
  async function hashTask(hasher, projectGraph, taskGraph, task, env, taskDetails) {
82
84
  performance.mark('hashSingleTask:start');
83
85
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
86
+ // TODO(v25): remove custom hasher support.
84
87
  const customHasher = (0, utils_1.getCustomHasher)(task, projectsConfigurations.projects);
85
88
  const { value, details, inputs } = await (customHasher
86
89
  ? customHasher(task, {
@@ -126,6 +129,7 @@ async function hashTasks(hasher, projectGraph, taskGraph, perTaskEnvs, taskDetai
126
129
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
127
130
  const nxJson = (0, nx_json_1.readNxJson)();
128
131
  const tasks = (tasksToHashOverride ?? Object.values(taskGraph.tasks)).filter((task) => !task.hash);
132
+ // TODO(v25): remove custom hasher support.
129
133
  // Separate tasks with custom hashers from those without
130
134
  const tasksWithCustomHashers = [];
131
135
  const tasksWithoutCustomHashers = [];
@@ -98,7 +98,9 @@ function taskGraphFingerprint(taskGraph, ultracacheConfigurations) {
98
98
  ];
99
99
  for (const id of Object.keys(taskGraph.tasks).sort()) {
100
100
  const task = taskGraph.tasks[id];
101
- parts.push(id, task.target.project, task.target.target, task.target.configuration ?? '', (task.outputs ?? []).join(','), (taskGraph.dependencies[id] ?? []).join(','), (taskGraph.continuousDependencies[id] ?? []).join(','));
101
+ parts.push(id, task.target.project, task.target.target, task.target.configuration ?? '', (task.outputs ?? []).join(','), (taskGraph.dependencies[id] ?? []).map((edge) => edge.id).join(','), (taskGraph.continuousDependencies[id] ?? [])
102
+ .map((edge) => JSON.stringify([edge.id, edge.inputs === false]))
103
+ .join(','));
102
104
  }
103
105
  return (0, native_1.hashArray)(parts);
104
106
  }
@@ -142,6 +142,7 @@ export declare function getInputs(task: Task, projectGraph: ProjectGraph, nxJson
142
142
  projectInputs: {
143
143
  input: string;
144
144
  projects: string[];
145
+ dependencies?: true;
145
146
  }[];
146
147
  depsFilesets: {
147
148
  fileset: string;
@@ -158,6 +159,7 @@ export declare function splitInputsIntoSelfAndDependencies(inputs: ReadonlyArray
158
159
  projectInputs: {
159
160
  input: string;
160
161
  projects: string[];
162
+ dependencies?: true;
161
163
  }[];
162
164
  selfInputs: ExpandedSelfInput[];
163
165
  depsOutputs: ExpandedDepsOutput[];
@@ -200,7 +200,7 @@ function splitInputsIntoSelfAndDependencies(inputs, namedInputs) {
200
200
  }
201
201
  else if ('input' in d &&
202
202
  !('fileset' in d) &&
203
- (('dependencies' in d && d.dependencies) ||
203
+ (('dependencies' in d && d.dependencies && !('projects' in d)) ||
204
204
  // Todo(@AgentEnder): Remove check in v17
205
205
  ('projects' in d &&
206
206
  typeof d.projects === 'string' &&
@@ -219,6 +219,9 @@ function splitInputsIntoSelfAndDependencies(inputs, namedInputs) {
219
219
  projectInputs.push({
220
220
  input: d.input,
221
221
  projects: Array.isArray(d.projects) ? d.projects : [d.projects],
222
+ ...('dependencies' in d && d.dependencies
223
+ ? { dependencies: true }
224
+ : {}),
222
225
  });
223
226
  }
224
227
  else {
@@ -6,7 +6,6 @@ import { Tree } from '../../generators/tree';
6
6
  * via `cacheableOperations`; Nx 23 removed that derivation and those targets
7
7
  * silently stopped being cacheable.
8
8
  *
9
- * Write the intent into the executor key so it no longer depends on the
10
- * deprecated fallback that restores the old behavior at run time.
9
+ * Write the intent into the executor key, which is where Nx reads `cache` from.
11
10
  */
12
11
  export default function update(tree: Tree): Promise<void>;
@@ -6,9 +6,6 @@ const format_changed_files_1 = require("../../generators/internal-utils/format-c
6
6
  const json_1 = require("../../generators/utils/json");
7
7
  const project_configuration_1 = require("../../generators/utils/project-configuration");
8
8
  const path_1 = require("../../utils/path");
9
- // TODO(v24): remove this migration alongside the runtime fallback it exists to
10
- // retire (`isLegacyCachedTarget` in `target-normalization.ts`), along with its
11
- // registration in `packages/nx/migrations.json`.
12
9
  /**
13
10
  * Target defaults resolve to a single key rather than merging, so an executor
14
11
  * key hides the target name key entirely. Before Nx 23 a hidden `cache: true`
@@ -16,8 +13,7 @@ const path_1 = require("../../utils/path");
16
13
  * via `cacheableOperations`; Nx 23 removed that derivation and those targets
17
14
  * silently stopped being cacheable.
18
15
  *
19
- * Write the intent into the executor key so it no longer depends on the
20
- * deprecated fallback that restores the old behavior at run time.
16
+ * Write the intent into the executor key, which is where Nx reads `cache` from.
21
17
  */
22
18
  async function update(tree) {
23
19
  const nxJson = (0, project_configuration_1.readNxJson)(tree);
@@ -77,8 +73,8 @@ async function update(tree) {
77
73
  * `targets` — including any that is continuous, which makes `nx.json` fail graph
78
74
  * construction outright. The key is only safe when every target through it
79
75
  * independently wants caching and none of them can be continuous. Anything else
80
- * is left to the runtime fallback, which decides per target after normalization
81
- * and can therefore see continuity this migration cannot.
76
+ * is left unchanged, so those targets stay uncached until someone sets `cache`
77
+ * on the key by hand.
82
78
  */
83
79
  function canEnableCache(targetDefaults, key, targets, workspaceRoot, projectsMap) {
84
80
  // Targets written with `command` are rewritten to `nx:run-commands` and
@@ -126,9 +122,9 @@ function canEnableCache(targetDefaults, key, targets, workspaceRoot, projectsMap
126
122
  }
127
123
  /**
128
124
  * Whether the target name key declares `cache: true` on an entry that always
129
- * applies. Mirrors `declaresCacheTrue` in `target-normalization.ts`: a filtered
130
- * entry declaring `cache` makes the value unknowable without project context,
131
- * so nothing is claimed. Among unfiltered entries the last wins.
125
+ * applies. A filtered entry declaring `cache` makes the value unknowable
126
+ * without project context, so nothing is claimed. Among unfiltered entries the
127
+ * last wins.
132
128
  */
133
129
  function declaresCacheTrue(value) {
134
130
  if (!value) {
@@ -239,7 +235,6 @@ function executorDeclaresContinuous(executor, workspaceRoot, projectsMap) {
239
235
  }
240
236
  /**
241
237
  * Target names the pre-23 `longRunningTask` guard excluded from caching.
242
- * Mirrors `isLongRunningTarget` in `target-normalization.ts`.
243
238
  */
244
239
  function isLongRunningTargetName(targetName) {
245
240
  return (targetName.endsWith(':watch') ||