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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/README.md +7 -18
  2. package/changes.json +9 -53
  3. package/dist/bin/init-local.js +7 -1
  4. package/dist/nx-cloud-internals.d.ts +1 -0
  5. package/dist/nx-cloud-internals.js +9 -0
  6. package/dist/plugins/package-json.js +1 -1
  7. package/dist/src/command-line/add/add.js +5 -1
  8. package/dist/src/command-line/affected/affected.js +70 -9
  9. package/dist/src/command-line/affected/command-object.js +1 -1
  10. package/dist/src/command-line/format/format.js +2 -18
  11. package/dist/src/command-line/graph/graph.d.ts +31 -0
  12. package/dist/src/command-line/graph/graph.js +113 -20
  13. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  15. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  16. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  17. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  18. package/dist/src/command-line/init/implementation/format.js +2 -3
  19. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  20. package/dist/src/command-line/init/implementation/utils.js +6 -9
  21. package/dist/src/command-line/init/init-v2.js +0 -3
  22. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  23. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  24. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  25. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  26. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  27. package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
  28. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  29. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  30. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  31. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  32. package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
  33. package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
  34. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
  35. package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
  36. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  37. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  38. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
  39. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
  40. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  41. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
  42. package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
  43. package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
  44. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
  45. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
  46. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  47. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  48. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  49. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  50. package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
  51. package/dist/src/command-line/migrate/agentic/runner.js +57 -239
  52. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  53. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  54. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  55. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  56. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  57. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  58. package/dist/src/command-line/migrate/command-object.d.ts +2 -0
  59. package/dist/src/command-line/migrate/command-object.js +11 -1
  60. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  61. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  62. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  63. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  64. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  65. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  66. package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
  67. package/dist/src/command-line/migrate/migrate-commits.js +16 -6
  68. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  69. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  70. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  71. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  72. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  73. package/dist/src/command-line/migrate/migrate.js +183 -46
  74. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  75. package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
  76. package/dist/src/command-line/migrate/run/agent-output.js +21 -2
  77. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  78. package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
  79. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  80. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  81. package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
  82. package/dist/src/command-line/migrate/run/broker.js +568 -0
  83. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  84. package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
  85. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  86. package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
  87. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  88. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  89. package/dist/src/command-line/migrate/run/index.d.ts +9 -6
  90. package/dist/src/command-line/migrate/run/index.js +21 -2
  91. package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
  92. package/dist/src/command-line/migrate/run/issues.js +1121 -0
  93. package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
  94. package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
  95. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  96. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  97. package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
  98. package/dist/src/command-line/migrate/run/run-state.js +263 -32
  99. package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
  100. package/dist/src/command-line/migrate/run/runbook.js +118 -0
  101. package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
  102. package/dist/src/command-line/migrate/run/state-lock.js +128 -2
  103. package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
  104. package/dist/src/command-line/migrate/run/state-machine.js +339 -26
  105. package/dist/src/command-line/migrate/run/util.d.ts +3 -1
  106. package/dist/src/command-line/migrate/run/util.js +24 -3
  107. package/dist/src/command-line/migrate/run/worker.js +290 -129
  108. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  109. package/dist/src/command-line/migrate/step-actions.js +7 -1
  110. package/dist/src/command-line/migrate/text.d.ts +6 -0
  111. package/dist/src/command-line/migrate/text.js +25 -0
  112. package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
  113. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  114. package/dist/src/command-line/release/publish.js +11 -8
  115. package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
  116. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  117. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
  118. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  119. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
  120. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
  121. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  122. package/dist/src/command-line/reset/reset.js +10 -4
  123. package/dist/src/command-line/run/run-one.js +5 -1
  124. package/dist/src/command-line/run-many/run-many.js +6 -12
  125. package/dist/src/command-line/show/command-object.js +1 -1
  126. package/dist/src/command-line/show/projects.js +52 -1
  127. package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
  128. package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
  129. package/dist/src/config/task-graph.d.ts +1 -1
  130. package/dist/src/config/workspace-json-project-json.d.ts +23 -1
  131. package/dist/src/core/graph/main.js +1 -1
  132. package/dist/src/core/graph/runtime.js +1 -1
  133. package/dist/src/core/graph/styles.js +1 -1
  134. package/dist/src/daemon/client/client.d.ts +14 -8
  135. package/dist/src/daemon/client/client.js +41 -12
  136. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  137. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  138. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  139. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
  140. package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
  141. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  142. package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
  143. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
  144. package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
  145. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  146. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  147. package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
  148. package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
  149. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
  150. package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
  151. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  152. package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
  153. package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
  154. package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
  155. package/dist/src/daemon/server/outputs-tracking.js +7 -107
  156. package/dist/src/daemon/server/planning-context.d.ts +8 -0
  157. package/dist/src/daemon/server/planning-context.js +18 -0
  158. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  159. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
  160. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  161. package/dist/src/daemon/server/restart-checks.js +77 -0
  162. package/dist/src/daemon/server/server.d.ts +1 -0
  163. package/dist/src/daemon/server/server.js +54 -30
  164. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  165. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  166. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  167. package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
  168. package/dist/src/devkit-internals.d.ts +3 -1
  169. package/dist/src/devkit-internals.js +8 -3
  170. package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
  171. package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
  172. package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
  173. package/dist/src/executors/run-commands/running-tasks.js +13 -13
  174. package/dist/src/hasher/create-task-hasher.d.ts +8 -1
  175. package/dist/src/hasher/create-task-hasher.js +13 -3
  176. package/dist/src/hasher/hash-plan-inspector.js +2 -2
  177. package/dist/src/hasher/hash-task.d.ts +2 -2
  178. package/dist/src/hasher/hash-task.js +28 -17
  179. package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
  180. package/dist/src/hasher/native-task-hasher-impl.js +75 -9
  181. package/dist/src/hasher/task-hasher.d.ts +24 -7
  182. package/dist/src/hasher/task-hasher.js +27 -8
  183. package/dist/src/hasher/task-planning-context.d.ts +13 -0
  184. package/dist/src/hasher/task-planning-context.js +12 -0
  185. package/dist/src/native/index.d.ts +582 -21
  186. package/dist/src/native/index.js +3 -3
  187. package/dist/src/native/native-bindings.js +13 -1
  188. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  189. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  190. package/dist/src/native/transform-objects.d.ts +11 -2
  191. package/dist/src/native/transform-objects.js +46 -0
  192. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
  193. package/dist/src/nx-cloud/update-manager.d.ts +3 -0
  194. package/dist/src/nx-cloud/update-manager.js +19 -13
  195. package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
  196. package/dist/src/nx-cloud/utilities/client.js +1 -1
  197. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
  198. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  199. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  200. package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
  201. package/dist/src/plugins/js/index.js +45 -64
  202. package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
  203. package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
  204. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
  205. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
  206. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
  207. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
  208. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
  209. package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
  210. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
  211. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
  212. package/dist/src/plugins/js/utils/register.js +13 -4
  213. package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
  214. package/dist/src/plugins/package-json/create-nodes.js +13 -13
  215. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
  216. package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
  217. package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
  218. package/dist/src/project-graph/affected/affected-projects.js +42 -0
  219. package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
  220. package/dist/src/project-graph/affected/affected-reasons.js +459 -0
  221. package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
  222. package/dist/src/project-graph/affected/affected-tasks.js +386 -0
  223. package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
  224. package/dist/src/project-graph/affected/print-explanation.js +44 -0
  225. package/dist/src/project-graph/error-types.d.ts +5 -0
  226. package/dist/src/project-graph/error-types.js +44 -5
  227. package/dist/src/project-graph/file-utils.d.ts +2 -0
  228. package/dist/src/project-graph/file-utils.js +12 -3
  229. package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
  230. package/dist/src/project-graph/nx-deps-cache.js +4 -4
  231. package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
  232. package/dist/src/project-graph/plugins/get-plugins.js +60 -82
  233. package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
  234. package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
  235. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
  236. package/dist/src/project-graph/plugins/isolation/index.js +3 -1
  237. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
  238. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
  239. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
  240. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
  241. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
  242. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
  243. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
  244. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
  245. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  246. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  247. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  248. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  249. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
  250. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
  251. package/dist/src/project-graph/project-graph.js +43 -42
  252. package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
  253. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
  254. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
  255. package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
  256. package/dist/src/tasks-runner/batch/run-batch.js +15 -0
  257. package/dist/src/tasks-runner/cache.d.ts +37 -2
  258. package/dist/src/tasks-runner/cache.js +42 -1
  259. package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
  260. package/dist/src/tasks-runner/create-task-graph.js +57 -2
  261. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  262. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  263. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
  264. package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
  265. package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
  266. package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
  267. package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
  268. package/dist/src/tasks-runner/life-cycle.js +7 -0
  269. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  270. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  271. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  272. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  273. package/dist/src/tasks-runner/run-command.d.ts +41 -5
  274. package/dist/src/tasks-runner/run-command.js +98 -22
  275. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
  276. package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
  277. package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
  278. package/dist/src/tasks-runner/task-io-service.js +14 -5
  279. package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
  280. package/dist/src/tasks-runner/task-orchestrator.js +266 -66
  281. package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
  282. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  283. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  284. package/dist/src/tasks-runner/utils.d.ts +5 -0
  285. package/dist/src/tasks-runner/utils.js +14 -2
  286. package/dist/src/ultracache/config.d.ts +21 -0
  287. package/dist/src/ultracache/config.js +29 -0
  288. package/dist/src/ultracache/fetch.d.ts +21 -0
  289. package/dist/src/ultracache/fetch.js +43 -0
  290. package/dist/src/ultracache/overrides.d.ts +17 -0
  291. package/dist/src/ultracache/overrides.js +61 -0
  292. package/dist/src/ultracache/report.d.ts +13 -0
  293. package/dist/src/ultracache/report.js +62 -0
  294. package/dist/src/ultracache/store.d.ts +41 -0
  295. package/dist/src/ultracache/store.js +158 -0
  296. package/dist/src/utils/ab-testing.d.ts +4 -1
  297. package/dist/src/utils/ab-testing.js +22 -19
  298. package/dist/src/utils/chunkify.d.ts +1 -7
  299. package/dist/src/utils/chunkify.js +2 -8
  300. package/dist/src/utils/command-line-utils.d.ts +20 -0
  301. package/dist/src/utils/command-line-utils.js +10 -3
  302. package/dist/src/utils/create-cli-options.d.ts +6 -0
  303. package/dist/src/utils/create-cli-options.js +29 -0
  304. package/dist/src/utils/db-connection.d.ts +2 -0
  305. package/dist/src/utils/db-connection.js +2 -0
  306. package/dist/src/utils/formatters/index.d.ts +6 -0
  307. package/dist/src/utils/formatters/index.js +5 -0
  308. package/dist/src/utils/formatters/prettier.d.ts +0 -8
  309. package/dist/src/utils/formatters/prettier.js +4 -26
  310. package/dist/src/utils/git-utils.d.ts +19 -0
  311. package/dist/src/utils/git-utils.js +97 -39
  312. package/dist/src/utils/handle-errors.js +5 -43
  313. package/dist/src/utils/http-client.d.ts +27 -0
  314. package/dist/src/utils/http-client.js +193 -0
  315. package/dist/src/utils/installed-nx-version.js +2 -48
  316. package/dist/src/utils/json-diff.d.ts +4 -2
  317. package/dist/src/utils/json-diff.js +6 -94
  318. package/dist/src/utils/min-release-age/packument.js +1 -1
  319. package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
  320. package/dist/src/utils/nx-cloud-utils.js +6 -1
  321. package/dist/src/utils/output.d.ts +22 -3
  322. package/dist/src/utils/output.js +28 -5
  323. package/dist/src/utils/package-json.d.ts +25 -0
  324. package/dist/src/utils/package-json.js +49 -6
  325. package/dist/src/utils/package-manager.d.ts +6 -0
  326. package/dist/src/utils/package-manager.js +10 -0
  327. package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
  328. package/dist/src/utils/project-graph-utils.d.ts +2 -0
  329. package/dist/src/utils/project-graph-utils.js +12 -0
  330. package/dist/src/utils/provenance.js +20 -4
  331. package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
  332. package/dist/src/utils/workspace-context.d.ts +51 -3
  333. package/dist/src/utils/workspace-context.js +174 -10
  334. package/package.json +36 -98
  335. package/schemas/nx-schema.json +38 -0
  336. package/schemas/project-schema.json +35 -0
  337. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  338. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  339. package/dist/src/daemon/server/watcher.d.ts +0 -18
  340. package/dist/src/daemon/server/watcher.js +0 -126
  341. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  342. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  343. package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
  344. package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
  345. package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
  346. package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
  347. package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
  348. package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
  349. package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
  350. package/dist/src/utils/collapse-expanded-outputs.js +0 -72
@@ -1,120 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._recordOutputsHash = _recordOutputsHash;
4
- exports._outputsHashesMatch = _outputsHashesMatch;
5
- exports.processFileChangesInOutputs = processFileChangesInOutputs;
6
3
  exports.outputsHashesMatchBatch = outputsHashesMatchBatch;
7
4
  exports.recordOutputsHashBatch = recordOutputsHashBatch;
8
- exports.disableOutputsTracking = disableOutputsTracking;
9
- const path_1 = require("path");
10
- const native_1 = require("../../native");
11
- const collapse_expanded_outputs_1 = require("../../utils/collapse-expanded-outputs");
5
+ const workspace_context_1 = require("../../utils/workspace-context");
12
6
  const workspace_root_1 = require("../../utils/workspace-root");
13
- let disabled = false;
14
- const dirsContainingOutputs = {};
15
- const recordedHashes = {};
16
- const timestamps = {};
17
- const numberOfExpandedOutputs = {};
18
- function _recordOutputsHash(outputs, hash) {
19
- numberOfExpandedOutputs[hash] = outputs.length;
20
- for (const output of outputs) {
21
- recordedHashes[output] = hash;
22
- timestamps[output] = new Date().getTime();
23
- let current = output;
24
- while (current != (0, path_1.dirname)(current)) {
25
- if (!dirsContainingOutputs[current]) {
26
- dirsContainingOutputs[current] = new Set();
27
- }
28
- dirsContainingOutputs[current].add(output);
29
- current = (0, path_1.dirname)(current);
30
- }
31
- }
32
- }
33
- function _outputsHashesMatch(outputs, hash) {
34
- if (outputs.length !== numberOfExpandedOutputs[hash]) {
35
- return false;
36
- }
37
- else {
38
- for (const output of outputs) {
39
- if (recordedHashes[output] !== hash) {
40
- return false;
41
- }
42
- }
43
- }
44
- return true;
45
- }
46
- function processFileChangesInOutputs(changeEvents, now = undefined) {
47
- if (!now) {
48
- now = new Date().getTime();
49
- }
50
- for (let e of changeEvents) {
51
- let current = e.path;
52
- // the path is either an output itself or a parent
53
- if (dirsContainingOutputs[current]) {
54
- dirsContainingOutputs[current].forEach((output) => {
55
- if (now - timestamps[output] > 2000) {
56
- recordedHashes[output] = undefined;
57
- }
58
- });
59
- continue;
60
- }
61
- // the path is a child of some output or unrelated
62
- while (current != (0, path_1.dirname)(current)) {
63
- if (recordedHashes[current] && now - timestamps[current] > 2000) {
64
- recordedHashes[current] = undefined;
65
- break;
66
- }
67
- current = (0, path_1.dirname)(current);
68
- }
69
- }
70
- }
71
7
  /**
72
- * Check whether the on-disk outputs of each entry still match the hash
73
- * the daemon recorded for them. Uses Rayon-parallel filesystem scanning
74
- * for uncached entries.
8
+ * Whether the on-disk outputs of each entry are still what the daemon
9
+ * recorded for its hash, so the cache copy can be skipped.
75
10
  */
76
11
  function outputsHashesMatchBatch(entries) {
77
- if (disabled)
78
- return entries.map(() => false);
79
- // Fast path: skip filesystem scan for entries with no recorded hash.
80
- // _outputsHashesMatch will return false immediately if the hash isn't
81
- // in numberOfExpandedOutputs, so scanning the filesystem is wasted work.
82
- const needsScan = [];
83
- const results = new Array(entries.length);
84
- for (let i = 0; i < entries.length; i++) {
85
- if (numberOfExpandedOutputs[entries[i].hash] === undefined) {
86
- results[i] = false;
87
- }
88
- else {
89
- needsScan.push(i);
90
- }
91
- }
92
- if (needsScan.length > 0) {
93
- // Only scan outputs for entries that have recorded hashes
94
- const outputsBatch = needsScan.map((i) => entries[i].outputs);
95
- const expandedBatch = (0, native_1.getFilesForOutputsBatch)(workspace_root_1.workspaceRoot, outputsBatch);
96
- for (let j = 0; j < needsScan.length; j++) {
97
- const expanded = (0, collapse_expanded_outputs_1.collapseExpandedOutputs)(expandedBatch[j]);
98
- results[needsScan[j]] = _outputsHashesMatch(expanded, entries[needsScan[j]].hash);
99
- }
100
- }
101
- return results;
12
+ return (0, workspace_context_1.outputsUnchangedInContext)(workspace_root_1.workspaceRoot, entries);
102
13
  }
103
14
  /**
104
- * Record the hash of each entry's on-disk outputs so future
105
- * outputsHashesMatchBatch calls can skip redundant cache copies.
106
- * Uses Rayon-parallel filesystem scanning.
15
+ * Record each entry's outputs (the files it carries, or else what is on disk)
16
+ * so future outputsHashesMatchBatch calls can skip redundant cache copies.
107
17
  */
108
18
  function recordOutputsHashBatch(entries) {
109
- if (disabled)
110
- return;
111
- const outputsBatch = entries.map((e) => e.outputs);
112
- const expandedBatch = (0, native_1.getFilesForOutputsBatch)(workspace_root_1.workspaceRoot, outputsBatch);
113
- for (let i = 0; i < entries.length; i++) {
114
- const expanded = (0, collapse_expanded_outputs_1.collapseExpandedOutputs)(expandedBatch[i]);
115
- _recordOutputsHash(expanded, entries[i].hash);
116
- }
117
- }
118
- function disableOutputsTracking() {
119
- disabled = true;
19
+ (0, workspace_context_1.recordOutputsInContext)(workspace_root_1.workspaceRoot, entries);
120
20
  }
@@ -0,0 +1,8 @@
1
+ import type { NxJsonConfiguration } from '../../config/nx-json';
2
+ import type { ProjectGraph } from '../../config/project-graph';
3
+ import { TaskPlanningContext } from '../../hasher/task-planning-context';
4
+ /**
5
+ * One planner per daemon project graph, shared by affected selection and task
6
+ * hashing, so hashing reuses the plans selection made.
7
+ */
8
+ export declare function planningContextFor(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): TaskPlanningContext;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.planningContextFor = planningContextFor;
4
+ const task_planning_context_1 = require("../../hasher/task-planning-context");
5
+ let stored = null;
6
+ /**
7
+ * One planner per daemon project graph, shared by affected selection and task
8
+ * hashing, so hashing reuses the plans selection made.
9
+ */
10
+ function planningContextFor(projectGraph, nxJson) {
11
+ if (stored?.projectGraph !== projectGraph) {
12
+ stored = {
13
+ projectGraph,
14
+ context: (0, task_planning_context_1.createTaskPlanningContext)(projectGraph, nxJson),
15
+ };
16
+ }
17
+ return stored.context;
18
+ }
@@ -1,6 +1,7 @@
1
1
  import { Socket } from 'net';
2
2
  import { FileMap, ProjectGraph } from '../../config/project-graph';
3
3
  import { NxWorkspaceFilesExternals } from '../../native';
4
+ import type { ChangeBatch } from '../../native';
4
5
  import { FileMapCache } from '../../project-graph/nx-deps-cache';
5
6
  import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration/source-maps';
6
7
  interface SerializedProjectGraph {
@@ -20,7 +21,28 @@ export declare let currentProjectFileMapCache: FileMapCache | undefined;
20
21
  export declare let currentProjectGraph: ProjectGraph | undefined;
21
22
  export declare let currentSourceMaps: ConfigurationSourceMaps | undefined;
22
23
  export declare function getCachedSerializedProjectGraphPromise(socket?: Socket): Promise<SerializedProjectGraph>;
24
+ /**
25
+ * Takes in changes the workspace context handed out: restarts the daemon if
26
+ * an ignore file changed, otherwise schedules the recomputation.
27
+ */
28
+ export declare function routeAppliedChanges(batch: ChangeBatch): void;
29
+ /**
30
+ * Applies everything the file-change stream has seen and routes what changed.
31
+ * Call before serving a cached project graph, so a change the watcher already
32
+ * saw is never missed.
33
+ */
34
+ export declare function flushPendingWorkspaceChanges(): Promise<void>;
35
+ /**
36
+ * Applies changes a caller learned of on its own to the workspace context,
37
+ * then schedules the recomputation as for a batch the context applied.
38
+ *
39
+ * The caller is a sync generator, whose writes the watch would report anyway;
40
+ * this makes them visible before the generator returns rather than by the next
41
+ * settle. Whether that guarantee is still needed is NXC-4996.
42
+ */
23
43
  export declare function scheduleProjectGraphRecomputation(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): void;
44
+ /** Computes the first project graph, unless one is already on its way. */
45
+ export declare function scheduleInitialProjectGraphComputation(): void;
24
46
  export declare function registerProjectGraphRecomputationListener(listener: (projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, error: Error | null) => void): void;
25
47
  /**
26
48
  * Discards the cached graph when a graph input outside the file watcher's view
@@ -37,11 +59,4 @@ export declare function invalidateGraphCache(): void;
37
59
  * event arrived.
38
60
  */
39
61
  export declare function getRecomputationGeneration(): number;
40
- /**
41
- * Whether the ignore-filtered workspace file map knows `path`. The workspace
42
- * watcher applies the same ignore rules, so a change to a known file also
43
- * reaches scheduleProjectGraphRecomputation; an unknown file is either
44
- * ignored, or created since the last recompute committed.
45
- */
46
- export declare function isKnownWorkspaceFile(path: string): boolean;
47
62
  export {};
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.currentSourceMaps = exports.currentProjectGraph = exports.currentProjectFileMapCache = exports.fileMapWithFiles = void 0;
4
4
  exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraphPromise;
5
+ exports.routeAppliedChanges = routeAppliedChanges;
6
+ exports.flushPendingWorkspaceChanges = flushPendingWorkspaceChanges;
5
7
  exports.scheduleProjectGraphRecomputation = scheduleProjectGraphRecomputation;
8
+ exports.scheduleInitialProjectGraphComputation = scheduleInitialProjectGraphComputation;
6
9
  exports.registerProjectGraphRecomputationListener = registerProjectGraphRecomputationListener;
7
10
  exports.invalidateGraphCache = invalidateGraphCache;
8
11
  exports.getRecomputationGeneration = getRecomputationGeneration;
9
- exports.isKnownWorkspaceFile = isKnownWorkspaceFile;
10
12
  const perf_hooks_1 = require("perf_hooks");
11
13
  const nx_json_1 = require("../../config/nx-json");
12
14
  const file_hasher_1 = require("../../hasher/file-hasher");
@@ -25,7 +27,7 @@ const dotenv_graph_changes_1 = require("./dotenv-graph-changes");
25
27
  const file_change_events_1 = require("./file-watching/file-change-events");
26
28
  const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
27
29
  const project_graph_listener_sockets_1 = require("./project-graph-listener-sockets");
28
- const watcher_1 = require("./watcher");
30
+ const restart_checks_1 = require("./restart-checks");
29
31
  const logger_1 = require("../logger");
30
32
  let cachedSerializedProjectGraphPromise;
31
33
  // Maps file path to a version counter that increments on each modification.
@@ -136,7 +138,7 @@ async function getCachedSerializedProjectGraphPromise(socket) {
136
138
  // that already arrived in the watcher's accumulator but hasn't
137
139
  // flushed past IDLE_WINDOW yet would be invisible to the staleness
138
140
  // check below — the daemon would return a stale graph.
139
- await (0, watcher_1.flushPendingWorkspaceChanges)();
141
+ await flushPendingWorkspaceChanges();
140
142
  await resetInternalStateIfNxDepsMissing();
141
143
  // Yield one macrotask boundary so any TSFN-queued watcher callbacks
142
144
  // run before we read collected*. Without this, an event that left
@@ -146,8 +148,8 @@ async function getCachedSerializedProjectGraphPromise(socket) {
146
148
  // separates them.
147
149
  await new Promise(setImmediate);
148
150
  // The queue can hold evidence against the settled cached graph itself: a
149
- // tracked dotenv edit only the outputs watcher has delivered yet queues
150
- // without invalidating, and the workspace watcher's recomputation may lag
151
+ // tracked dotenv edit only the raw-event stream has delivered yet queues
152
+ // without invalidating, and the file-change stream's recomputation may lag
151
153
  // this request. Classified against the exact graph the cache serves; an
152
154
  // in-flight computation needs no check here because its own pre-serve
153
155
  // replay consumes the queue. Content hashes are dropped before the
@@ -222,38 +224,96 @@ async function getCachedSerializedProjectGraphPromise(socket) {
222
224
  }
223
225
  }
224
226
  }
227
+ const SUMMARY_CAP = 10;
228
+ function summarize(files) {
229
+ if (files.length === 0)
230
+ return '(none)';
231
+ const listed = files.slice(0, SUMMARY_CAP).map((f) => ` - ${f}`);
232
+ if (files.length > SUMMARY_CAP) {
233
+ listed.push(` ... and ${files.length - SUMMARY_CAP} more`);
234
+ }
235
+ return listed.join('\n');
236
+ }
237
+ /**
238
+ * Takes in changes the workspace context handed out: restarts the daemon if
239
+ * an ignore file changed, otherwise schedules the recomputation.
240
+ */
241
+ function routeAppliedChanges(batch) {
242
+ if (!(0, workspace_context_1.isEmptyBatch)(batch)) {
243
+ if ((0, restart_checks_1.restartDaemonIfIgnoreFilesChanged)((0, restart_checks_1.changedPaths)(batch))) {
244
+ return;
245
+ }
246
+ logger_1.serverLogger.watcherLog(`File changes detected (seq ${batch.seq}):\n` +
247
+ `Created:\n${summarize((0, restart_checks_1.fileNames)(batch.createdFiles))}\n` +
248
+ `Updated:\n${summarize((0, restart_checks_1.fileNames)(batch.updatedFiles))}\n` +
249
+ `Deleted:\n${summarize(batch.deletedFiles)}`);
250
+ }
251
+ scheduleAppliedChanges(batch);
252
+ }
253
+ /**
254
+ * Applies everything the file-change stream has seen and routes what changed.
255
+ * Call before serving a cached project graph, so a change the watcher already
256
+ * saw is never missed.
257
+ */
258
+ async function flushPendingWorkspaceChanges() {
259
+ if (!(0, workspace_context_1.isWatchingWorkspaceContext)())
260
+ return;
261
+ const batch = (0, workspace_context_1.settleWorkspaceContext)(workspace_root_1.workspaceRoot);
262
+ // An empty settle must not reach the routing: it would schedule the first
263
+ // graph computation here rather than where the request handler reports it.
264
+ if ((0, workspace_context_1.isEmptyBatch)(batch)) {
265
+ return;
266
+ }
267
+ routeAppliedChanges(batch);
268
+ }
269
+ /**
270
+ * Applies changes a caller learned of on its own to the workspace context,
271
+ * then schedules the recomputation as for a batch the context applied.
272
+ *
273
+ * The caller is a sync generator, whose writes the watch would report anyway;
274
+ * this makes them visible before the generator returns rather than by the next
275
+ * settle. Whether that guarantee is still needed is NXC-4996.
276
+ */
225
277
  function scheduleProjectGraphRecomputation(createdFiles, updatedFiles, deletedFiles) {
278
+ if (!createdFiles.length && !updatedFiles.length && !deletedFiles.length) {
279
+ return;
280
+ }
281
+ // Hashed once here, not inside the recompute, so a stale retry does not see
282
+ // "no change" after the first pass already updated the context.
283
+ perf_hooks_1.performance.mark('hash-reported-changes-start');
284
+ const batch = (0, workspace_context_1.updateFilesInContext)(workspace_root_1.workspaceRoot, [...createdFiles, ...updatedFiles], deletedFiles);
285
+ perf_hooks_1.performance.mark('hash-reported-changes-end');
286
+ perf_hooks_1.performance.measure('hash reported file changes', 'hash-reported-changes-start', 'hash-reported-changes-end');
287
+ // A watching context hands every applied change out once, from one place.
288
+ routeAppliedChanges((0, workspace_context_1.isWatchingWorkspaceContext)()
289
+ ? (0, workspace_context_1.takeAppliedWorkspaceChanges)(workspace_root_1.workspaceRoot)
290
+ : batch);
291
+ }
292
+ /**
293
+ * Schedules a recomputation for changes the workspace context has applied:
294
+ * no-op rewrites are already dropped, deleted directories expanded, and every
295
+ * created or updated file carries its hash.
296
+ */
297
+ function scheduleAppliedChanges(batch) {
226
298
  ++fileChangeCounter;
227
- // Hash the changed files up front and drop no-op rewrites before they can
228
- // trigger an expensive recompute. Restoring a cached task output, a
229
- // `git checkout` back to the same content, or a formatter that changes
230
- // nothing all rewrite a file (new inode) the watcher reports as changed
231
- // even though the bytes are identical. updateFilesInContext updates the
232
- // workspace context and returns only the files whose content actually
233
- // changed. Hashing here — once per watcher batch — rather than inside the
234
- // recompute keeps it off the stale-retry path, which would otherwise see
235
- // "no change" after the first pass already updated the context hashes.
236
- perf_hooks_1.performance.mark('hash-watched-changes-start');
237
- const changedFileHashes = createdFiles.length > 0 ||
238
- updatedFiles.length > 0 ||
239
- deletedFiles.length > 0
240
- ? ((0, workspace_context_1.updateFilesInContext)(workspace_root_1.workspaceRoot, [...createdFiles, ...updatedFiles], deletedFiles) ?? {})
241
- : {};
242
- perf_hooks_1.performance.mark('hash-watched-changes-end');
243
- perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
244
- for (const [f, hash] of Object.entries(changedFileHashes)) {
245
- collectedDeletedFiles.delete(f);
246
- collectedUpdatedFiles.set(f, { version: fileChangeCounter, hash });
299
+ const { createdFiles, updatedFiles, deletedFiles } = batch;
300
+ for (const { file, hash } of [...createdFiles, ...updatedFiles]) {
301
+ collectedDeletedFiles.delete(file);
302
+ collectedUpdatedFiles.set(file, { version: fileChangeCounter, hash });
247
303
  }
248
- for (let f of deletedFiles) {
249
- collectedUpdatedFiles.delete(f);
250
- collectedDeletedFiles.set(f, fileChangeCounter);
304
+ for (const file of deletedFiles) {
305
+ collectedUpdatedFiles.delete(file);
306
+ collectedDeletedFiles.set(file, fileChangeCounter);
251
307
  }
252
- // The native watcher already coalesces a burst of events into one batch,
253
- // so socket + listener notifications dispatch immediately.
254
- if (Object.keys(changedFileHashes).length > 0 || deletedFiles.length > 0) {
255
- (0, file_change_events_1.notifyFileChangeListeners)({ createdFiles, updatedFiles, deletedFiles });
256
- (0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFiles, updatedFiles, deletedFiles);
308
+ if (!(0, workspace_context_1.isEmptyBatch)(batch)) {
309
+ const createdFileNames = (0, restart_checks_1.fileNames)(createdFiles);
310
+ const updatedFileNames = (0, restart_checks_1.fileNames)(updatedFiles);
311
+ (0, file_change_events_1.notifyFileChangeListeners)({
312
+ createdFiles: createdFileNames,
313
+ updatedFiles: updatedFileNames,
314
+ deletedFiles,
315
+ });
316
+ (0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFileNames, updatedFileNames, deletedFiles);
257
317
  // Bump generation synchronously so any in-flight compute fails its
258
318
  // next isStale() check and chains to the newer one. kickOffRecompute
259
319
  // would also bump on first resume, but only after its first await —
@@ -262,10 +322,14 @@ function scheduleProjectGraphRecomputation(createdFiles, updatedFiles, deletedFi
262
322
  kickOffRecompute();
263
323
  }
264
324
  else {
265
- // First call (initial startup) — no events but we still need a graph.
266
- if (!cachedSerializedProjectGraphPromise) {
267
- kickOffRecompute();
268
- }
325
+ // Nothing changed, but a daemon with no graph yet still needs one.
326
+ scheduleInitialProjectGraphComputation();
327
+ }
328
+ }
329
+ /** Computes the first project graph, unless one is already on its way. */
330
+ function scheduleInitialProjectGraphComputation() {
331
+ if (!cachedSerializedProjectGraphPromise) {
332
+ kickOffRecompute();
269
333
  }
270
334
  }
271
335
  function registerProjectGraphRecomputationListener(listener) {
@@ -337,36 +401,6 @@ function invalidateGraphCache() {
337
401
  function getRecomputationGeneration() {
338
402
  return recomputationGeneration;
339
403
  }
340
- // isKnownWorkspaceFile's membership set, derived lazily from the map object it
341
- // was built from; every `fileMapWithFiles` write clears it, so a replaced map
342
- // generation is not retained through the memo.
343
- let knownWorkspaceFiles;
344
- let knownWorkspaceFilesSource;
345
- /**
346
- * Whether the ignore-filtered workspace file map knows `path`. The workspace
347
- * watcher applies the same ignore rules, so a change to a known file also
348
- * reaches scheduleProjectGraphRecomputation; an unknown file is either
349
- * ignored, or created since the last recompute committed.
350
- */
351
- function isKnownWorkspaceFile(path) {
352
- if (!exports.fileMapWithFiles) {
353
- return false;
354
- }
355
- if (knownWorkspaceFilesSource !== exports.fileMapWithFiles) {
356
- const { projectFileMap, nonProjectFiles } = exports.fileMapWithFiles.fileMap;
357
- knownWorkspaceFiles = new Set();
358
- for (const { file } of nonProjectFiles) {
359
- knownWorkspaceFiles.add(file);
360
- }
361
- for (const files of Object.values(projectFileMap)) {
362
- for (const { file } of files) {
363
- knownWorkspaceFiles.add(file);
364
- }
365
- }
366
- knownWorkspaceFilesSource = exports.fileMapWithFiles;
367
- }
368
- return knownWorkspaceFiles.has(path);
369
- }
370
404
  async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
371
405
  const plugins = [
372
406
  ...separatedPlugins.specifiedPlugins,
@@ -442,8 +476,6 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
442
476
  // chainToLatest above without touching `fileMapWithFiles`, so they
443
477
  // can't clobber a newer compute's write.
444
478
  exports.fileMapWithFiles = fileMapUpdate.fileMap;
445
- knownWorkspaceFiles = undefined;
446
- knownWorkspaceFilesSource = undefined;
447
479
  storedWorkspaceConfigHash = fileMapUpdate.configHash;
448
480
  if (fileMapUpdate.knownExternalNodes) {
449
481
  knownExternalNodes = fileMapUpdate.knownExternalNodes;
@@ -508,8 +540,8 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
508
540
  // against the graph about to be served. Runs after the last staleness
509
541
  // gate so a stale compute leaves the queue for its successor, and only
510
542
  // on the success path: an error result is never notified or persisted.
511
- // Queue evidence is decisive here even for files the workspace watcher
512
- // tracks: the two watchers deliver independently, so tracking alone does
543
+ // Queue evidence is decisive here even for files the file-change stream
544
+ // covers: the two streams deliver independently, so tracking alone does
513
545
  // not prove that watcher's recomputation was already scheduled.
514
546
  let staleDotEnv;
515
547
  try {
@@ -556,7 +588,7 @@ function persistProjectGraphToDisk(result) {
556
588
  !result.sourceMaps) {
557
589
  return;
558
590
  }
559
- (0, nx_deps_cache_1.writeCache)(result.projectFileMapCache, result.projectGraph, result.sourceMaps, extractErrors(result.error));
591
+ (0, nx_deps_cache_1.writeCache)(result.projectFileMapCache, result.projectGraph, result.sourceMaps, extractErrors(result.error), Date.now());
560
592
  cacheHasBeenPersisted = true;
561
593
  }
562
594
  function copyFileData(d) {
@@ -616,8 +648,6 @@ async function resetInternalState() {
616
648
  servedGraphState = null;
617
649
  servedGraphCandidate = null;
618
650
  exports.fileMapWithFiles = undefined;
619
- knownWorkspaceFiles = undefined;
620
- knownWorkspaceFilesSource = undefined;
621
651
  exports.currentProjectFileMapCache = undefined;
622
652
  exports.currentProjectGraph = undefined;
623
653
  exports.currentSourceMaps = undefined;
@@ -0,0 +1,22 @@
1
+ import type { Server, Socket } from 'net';
2
+ import type { ChangeBatch, FileData, WatchEvent } from '../../native';
3
+ export declare function registerDaemonForRestartChecks(server: Server, sockets: Iterable<Socket>): void;
4
+ /**
5
+ * The daemon's own process file, workspace-relative. It lives under the
6
+ * hardcoded-ignored .nx/workspace-data, so the watch admits it explicitly;
7
+ * that is how a daemon learns it has been replaced.
8
+ */
9
+ export declare const relativeServerProcess: string;
10
+ /** The paths out of a list of files and their hashes. */
11
+ export declare function fileNames(files: FileData[]): string[];
12
+ export declare function changedPaths(batch: ChangeBatch): string[];
13
+ /**
14
+ * The watch's ignore rules are fixed when it starts, so an ignore-file edit
15
+ * needs a daemon restart to take effect. True when it stopped the daemon.
16
+ */
17
+ export declare function restartDaemonIfIgnoreFilesChanged(paths: string[]): boolean;
18
+ /**
19
+ * Stops this daemon when the events show another process has written the
20
+ * daemon's process file. True when it stopped the daemon.
21
+ */
22
+ export declare function stopDaemonIfReplaced(events: WatchEvent[]): boolean;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relativeServerProcess = void 0;
4
+ exports.registerDaemonForRestartChecks = registerDaemonForRestartChecks;
5
+ exports.fileNames = fileNames;
6
+ exports.changedPaths = changedPaths;
7
+ exports.restartDaemonIfIgnoreFilesChanged = restartDaemonIfIgnoreFilesChanged;
8
+ exports.stopDaemonIfReplaced = stopDaemonIfReplaced;
9
+ const path_1 = require("path");
10
+ const path_2 = require("../../utils/path");
11
+ const workspace_root_1 = require("../../utils/workspace-root");
12
+ const cache_1 = require("../cache");
13
+ const shutdown_utils_1 = require("./shutdown-utils");
14
+ // Kept apart from server.ts: the recomputation module needs these, and
15
+ // importing server.ts starts a server.
16
+ let daemon;
17
+ function registerDaemonForRestartChecks(server, sockets) {
18
+ daemon = { server, sockets };
19
+ }
20
+ /**
21
+ * The daemon's own process file, workspace-relative. It lives under the
22
+ * hardcoded-ignored .nx/workspace-data, so the watch admits it explicitly;
23
+ * that is how a daemon learns it has been replaced.
24
+ */
25
+ exports.relativeServerProcess = (0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, cache_1.serverProcessJsonPath));
26
+ /** The paths out of a list of files and their hashes. */
27
+ function fileNames(files) {
28
+ return files.map(({ file }) => file);
29
+ }
30
+ function changedPaths(batch) {
31
+ return [
32
+ ...fileNames(batch.createdFiles),
33
+ ...fileNames(batch.updatedFiles),
34
+ ...batch.deletedFiles,
35
+ ];
36
+ }
37
+ // Mirrors the per-directory ignore files create_filter reads (watch_filterer.rs).
38
+ // The sources it honours that cannot trigger a restart from here — because they
39
+ // are never watched — only take effect on the next daemon start: .git/info/exclude
40
+ // (under the hardcoded-ignored .git), the global core.excludesFile (outside the
41
+ // tree), and parent .gitignore files above the workspace root.
42
+ const IGNORE_FILE_NAMES = ['.gitignore', '.nxignore'];
43
+ /**
44
+ * The watch's ignore rules are fixed when it starts, so an ignore-file edit
45
+ * needs a daemon restart to take effect. True when it stopped the daemon.
46
+ */
47
+ function restartDaemonIfIgnoreFilesChanged(paths) {
48
+ for (const path of paths) {
49
+ const basename = path.slice(path.lastIndexOf('/') + 1);
50
+ if (IGNORE_FILE_NAMES.includes(basename)) {
51
+ stopDaemon('Stopping the daemon the set of ignored files changed (native)');
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ }
57
+ /**
58
+ * Stops this daemon when the events show another process has written the
59
+ * daemon's process file. True when it stopped the daemon.
60
+ */
61
+ function stopDaemonIfReplaced(events) {
62
+ const replaced = events.some((event) => event.path === exports.relativeServerProcess &&
63
+ (0, cache_1.getDaemonProcessIdSync)() !== process.pid);
64
+ if (replaced) {
65
+ stopDaemon('this process is no longer the current daemon (native)');
66
+ }
67
+ return replaced;
68
+ }
69
+ function stopDaemon(reason) {
70
+ if (!daemon)
71
+ return;
72
+ (0, shutdown_utils_1.handleServerProcessTermination)({
73
+ server: daemon.server,
74
+ reason,
75
+ sockets: daemon.sockets,
76
+ });
77
+ }
@@ -6,5 +6,6 @@ export type HandlerResult = {
6
6
  response?: string | object | boolean;
7
7
  };
8
8
  export declare const openSockets: Set<Socket>;
9
+ export declare function handleMessage(socket: Socket, data: Buffer): Promise<void>;
9
10
  export declare function handleResult(socket: Socket, type: string, hrFn: () => Promise<HandlerResult>, mode: 'json' | 'v8'): Promise<void>;
10
11
  export declare function startServer(): Promise<Server>;