@smoothbricks/nx-plugin 0.5.7 → 0.6.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 (432) hide show
  1. package/README.md +1086 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  62. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  63. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  64. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  65. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/executor.js +371 -239
  67. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  68. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  70. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  71. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  73. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  74. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  75. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  76. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  77. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  79. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  80. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  82. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  83. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  84. package/dist/executors/bounded-exec/progress.js +5 -2
  85. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  86. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  88. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  89. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  90. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  91. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  92. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  93. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  94. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  95. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  96. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  97. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  98. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  100. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  101. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  102. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  104. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  105. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  106. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  107. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  108. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  109. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  110. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  111. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  112. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  113. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  114. package/dist/executors/bounded-exec/verdict.js +88 -19
  115. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  116. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  117. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  118. package/dist/executors/clean-outputs/executor.js +1 -0
  119. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  120. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  121. package/dist/executors/scriptc-native/executor.js +367 -0
  122. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  123. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  124. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  125. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  126. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/schema.js +1 -0
  128. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  129. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  130. package/dist/executors/typescript-emit/executor.js +164 -33
  131. package/dist/forbidden-spelling-policy.d.ts +56 -0
  132. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  133. package/dist/forbidden-spelling-policy.js +176 -0
  134. package/dist/generators/create-package/generator.d.ts.map +1 -1
  135. package/dist/generators/create-package/generator.js +3 -4
  136. package/dist/graph-input-contract.d.ts +14 -0
  137. package/dist/graph-input-contract.d.ts.map +1 -1
  138. package/dist/graph-input-contract.js +67 -2
  139. package/dist/index.d.ts +23 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +672 -214
  142. package/dist/managed-assets.d.ts +2 -0
  143. package/dist/managed-assets.d.ts.map +1 -1
  144. package/dist/managed-files/files.d.ts +3 -3
  145. package/dist/managed-files/files.d.ts.map +1 -1
  146. package/dist/managed-files/files.js +28 -3
  147. package/dist/managed-files/managed-format.d.ts.map +1 -1
  148. package/dist/managed-files/managed-format.js +1 -0
  149. package/dist/nextest-code-bound.js +1 -0
  150. package/dist/nextest-timings.d.ts +35 -0
  151. package/dist/nextest-timings.d.ts.map +1 -0
  152. package/dist/nextest-timings.js +168 -0
  153. package/dist/owned-installation.d.ts +6 -5
  154. package/dist/owned-installation.d.ts.map +1 -1
  155. package/dist/owned-installation.js +150 -26
  156. package/dist/package-target-policy.d.ts.map +1 -1
  157. package/dist/package-target-policy.js +2 -3
  158. package/dist/process-children.d.ts +7 -0
  159. package/dist/process-children.d.ts.map +1 -0
  160. package/dist/process-children.darwin.d.ts +7 -0
  161. package/dist/process-children.darwin.d.ts.map +1 -0
  162. package/dist/process-children.darwin.js +13 -0
  163. package/dist/process-children.js +14 -0
  164. package/dist/process-children.linux.d.ts +8 -0
  165. package/dist/process-children.linux.d.ts.map +1 -0
  166. package/dist/process-children.linux.js +25 -0
  167. package/dist/process-group.d.ts +108 -0
  168. package/dist/process-group.d.ts.map +1 -0
  169. package/dist/process-group.js +171 -0
  170. package/dist/process-listing.d.ts +7 -0
  171. package/dist/process-listing.d.ts.map +1 -0
  172. package/dist/process-listing.js +51 -0
  173. package/dist/producer-receipts.d.ts +8 -2
  174. package/dist/producer-receipts.d.ts.map +1 -1
  175. package/dist/producer-receipts.js +75 -48
  176. package/dist/task-graph-policy.d.ts +21 -0
  177. package/dist/task-graph-policy.d.ts.map +1 -0
  178. package/dist/task-graph-policy.js +91 -0
  179. package/dist/test-timings.js +4 -4
  180. package/dist/test-walk-policy.d.ts +14 -5
  181. package/dist/test-walk-policy.d.ts.map +1 -1
  182. package/dist/test-walk-policy.js +8 -2
  183. package/dist/testing.d.ts +73 -28
  184. package/dist/testing.d.ts.map +1 -1
  185. package/dist/testing.js +217 -223
  186. package/dist/tool-bins.d.ts +33 -0
  187. package/dist/tool-bins.d.ts.map +1 -0
  188. package/dist/tool-bins.js +72 -0
  189. package/dist/typecheck-test-policy.d.ts.map +1 -1
  190. package/dist/typecheck-test-policy.js +3 -4
  191. package/dist/wait-why-policy.d.ts +28 -0
  192. package/dist/wait-why-policy.d.ts.map +1 -0
  193. package/dist/wait-why-policy.js +223 -0
  194. package/dist/workspace-config-policy.d.ts +14 -8
  195. package/dist/workspace-config-policy.d.ts.map +1 -1
  196. package/dist/workspace-config-policy.js +60 -16
  197. package/dist/workspace-manifest.d.ts +41 -6
  198. package/dist/workspace-manifest.d.ts.map +1 -1
  199. package/dist/workspace-manifest.js +57 -0
  200. package/executors.json +16 -1
  201. package/loader.js +2 -0
  202. package/managed/raw/envrc +11 -0
  203. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  204. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  205. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  206. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  207. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  208. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  209. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  210. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  211. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  212. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  213. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  214. package/managed/raw/tooling/direnv/repo-path +68 -6
  215. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  216. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  217. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  218. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  219. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  220. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  221. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  222. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  223. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  224. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  225. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  226. package/package.json +77 -13
  227. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  228. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  229. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  230. package/src/bounded-test-policy.ts +12 -14
  231. package/src/build-state-output-policy.ts +458 -34
  232. package/src/bun-lock-scope.ts +108 -0
  233. package/src/cargo-build-script-env.ts +265 -0
  234. package/src/cargo-closure-input.ts +74 -7
  235. package/src/cargo-retention-hook.ts +94 -0
  236. package/src/cargo-source-hash.ts +138 -41
  237. package/src/cargo-toolchain-paths.ts +95 -0
  238. package/src/cargo-toolchain-policy.ts +49 -5
  239. package/src/cargo-workspace.ts +72 -123
  240. package/src/cross-check-policy.ts +12 -10
  241. package/src/disk-command-policy.ts +1 -0
  242. package/src/ensure-built-receipt.ts +132 -39
  243. package/src/ensure-built-witness.ts +62 -10
  244. package/src/ensure-built.ts +11 -1
  245. package/src/eslint-config-closure.ts +357 -0
  246. package/src/executors/bounded-exec/bounds.ts +76 -0
  247. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  248. package/src/executors/bounded-exec/executor.ts +423 -259
  249. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  250. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  251. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  252. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  253. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  254. package/src/executors/bounded-exec/progress.ts +9 -3
  255. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  256. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  257. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  258. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  259. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  260. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  261. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  262. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  263. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  264. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  265. package/src/executors/bounded-exec/schema.json +11 -2
  266. package/src/executors/bounded-exec/schema.ts +19 -1
  267. package/src/executors/bounded-exec/verdict.ts +137 -34
  268. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  269. package/src/executors/clean-outputs/executor.ts +1 -0
  270. package/src/executors/scriptc-native/executor.ts +394 -0
  271. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  272. package/src/executors/scriptc-native/schema.json +60 -0
  273. package/src/executors/scriptc-native/schema.ts +34 -0
  274. package/src/executors/typescript-emit/executor.ts +205 -38
  275. package/src/forbidden-spelling-policy.ts +226 -0
  276. package/src/generators/create-package/generator.ts +7 -7
  277. package/src/graph-input-contract.ts +61 -2
  278. package/src/index.ts +788 -224
  279. package/src/managed-assets.ts +3 -0
  280. package/src/managed-files/files.ts +28 -3
  281. package/src/managed-files/managed-format.ts +1 -0
  282. package/src/nextest-code-bound.ts +1 -0
  283. package/src/nextest-timings.ts +106 -0
  284. package/src/owned-installation.ts +150 -23
  285. package/src/package-target-policy.ts +2 -3
  286. package/src/process-children.darwin.ts +14 -0
  287. package/src/process-children.linux.ts +33 -0
  288. package/src/process-children.ts +22 -0
  289. package/src/process-group.ts +209 -0
  290. package/src/process-listing.ts +54 -0
  291. package/src/producer-receipts.ts +68 -45
  292. package/src/task-graph-policy.ts +98 -0
  293. package/src/test-walk-policy.ts +23 -8
  294. package/src/testing.ts +240 -232
  295. package/src/tool-bins.ts +108 -0
  296. package/src/typecheck-test-policy.ts +2 -3
  297. package/src/wait-why-policy.ts +226 -0
  298. package/src/workspace-config-policy.ts +63 -15
  299. package/src/workspace-manifest.ts +89 -6
  300. package/test-timings.json +122 -98
  301. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  302. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  303. package/dist/bin/smoo-nx-failures.js +0 -3
  304. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  305. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  306. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  307. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  308. package/dist/failure-summary.d.ts +0 -5
  309. package/dist/failure-summary.d.ts.map +0 -1
  310. package/dist/failure-summary.js +0 -118
  311. package/dist/nextest-extraction.d.ts +0 -117
  312. package/dist/nextest-extraction.d.ts.map +0 -1
  313. package/dist/nextest-extraction.js +0 -303
  314. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  315. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  316. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  317. package/src/__tests__/counted-cargo-process.ts +0 -286
  318. package/src/__tests__/counted-cargo.ts +0 -713
  319. package/src/__tests__/directory-change.ts +0 -27
  320. package/src/__tests__/fixture-cargo-home.ts +0 -36
  321. package/src/__tests__/fixture-nx-env.ts +0 -193
  322. package/src/__tests__/owned-installation.ts +0 -13
  323. package/src/__tests__/past-tick.ts +0 -12
  324. package/src/__tests__/progress-clock.ts +0 -43
  325. package/src/__tests__/runtime-input.ts +0 -23
  326. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  327. package/src/bin/smoo-nx-failures.ts +0 -4
  328. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  329. package/src/bounded-test-policy.test.ts +0 -1029
  330. package/src/build-state-output-policy.test.ts +0 -115
  331. package/src/bun-bootstrap.test.ts +0 -102
  332. package/src/bun-file-packages.test.ts +0 -47
  333. package/src/cargo-closure-filesets.test.ts +0 -63
  334. package/src/cargo-closure-input.property.test.ts +0 -50
  335. package/src/cargo-closure-input.test.ts +0 -506
  336. package/src/cargo-closure-key.test.ts +0 -240
  337. package/src/cargo-resolve-cache.test.ts +0 -1181
  338. package/src/cargo-source-hash.test.ts +0 -707
  339. package/src/cargo-workspace.test.ts +0 -615
  340. package/src/cross-check-policy.test.ts +0 -316
  341. package/src/disk-command-policy.test.ts +0 -61
  342. package/src/ensure-built-receipt.test.ts +0 -279
  343. package/src/ensure-built-witness.test.ts +0 -688
  344. package/src/ensure-built.test.ts +0 -1462
  345. package/src/executors/all-verdicts/executor.test.ts +0 -135
  346. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  347. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  348. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  349. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  350. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  351. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  352. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  353. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  354. package/src/executors/bounded-exec/progress.test.ts +0 -139
  355. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  356. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  357. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  358. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  359. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  360. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  361. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  362. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  363. package/src/executors/clean-outputs/executor.test.ts +0 -20
  364. package/src/executors/typescript-emit/executor.test.ts +0 -83
  365. package/src/failure-summary.ts +0 -119
  366. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  367. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  368. package/src/generators/create-package/generator.test.ts +0 -190
  369. package/src/generators/make-public/generator.test.ts +0 -137
  370. package/src/graph-input-contract.test.ts +0 -379
  371. package/src/host-controller-wiring.test.ts +0 -31
  372. package/src/index.test.ts +0 -3321
  373. package/src/linked-snapshots.nx.test.ts +0 -254
  374. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  375. package/src/managed-files/generator.test.ts +0 -243
  376. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  377. package/src/managed-files/json-edit.test.ts +0 -216
  378. package/src/managed-files/managed-content.test.ts +0 -166
  379. package/src/managed-files/managed-format-json.test.ts +0 -308
  380. package/src/managed-files/repo-path.test.ts +0 -172
  381. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  382. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  383. package/src/managed-files/tree-permissions.test.ts +0 -109
  384. package/src/managed-files/tree.test.ts +0 -123
  385. package/src/manifest-hash.test.ts +0 -219
  386. package/src/nextest-code-bound.test.ts +0 -161
  387. package/src/nextest-extraction.test.ts +0 -216
  388. package/src/nextest-extraction.ts +0 -371
  389. package/src/nextest-partitions.test.ts +0 -501
  390. package/src/nx-cache-bound.test.ts +0 -109
  391. package/src/nx-cache-restore-mtime.test.ts +0 -170
  392. package/src/nx-daemon-claim.test.ts +0 -279
  393. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  394. package/src/nx-daemon-idle-policy.test.ts +0 -111
  395. package/src/nx-daemon-ignore-files.test.ts +0 -210
  396. package/src/nx-daemon-root-normalization.test.ts +0 -105
  397. package/src/nx-daemon-start-never.test.ts +0 -292
  398. package/src/nx-daemon-validity.test.ts +0 -1055
  399. package/src/nx-dot-input-policy.test.ts +0 -353
  400. package/src/nx-failure-life-cycles.test.ts +0 -207
  401. package/src/nx-files-archive-racy.test.ts +0 -97
  402. package/src/nx-foreign-workspace-env.test.ts +0 -329
  403. package/src/nx-incomplete-run-summary.test.ts +0 -70
  404. package/src/nx-plugin-load-errors.test.ts +0 -120
  405. package/src/nx-project-graph-errors.test.ts +0 -70
  406. package/src/nx-project-resolution-cache.test.ts +0 -176
  407. package/src/nx-raw-inputs.test.ts +0 -166
  408. package/src/nx-resident-graph-workers.test.ts +0 -112
  409. package/src/nx-run-information.test.ts +0 -118
  410. package/src/nx-skipped-task-exit.test.ts +0 -180
  411. package/src/nx-state-location.test.ts +0 -63
  412. package/src/nx-store-resolution.test.ts +0 -81
  413. package/src/nx-task-graph-cycles.test.ts +0 -148
  414. package/src/nx-task-output-lease.test.ts +0 -550
  415. package/src/nx-use-local.test.ts +0 -105
  416. package/src/owned-installation.test.ts +0 -105
  417. package/src/package-target-policy.test.ts +0 -1014
  418. package/src/producer-receipts.test.ts +0 -285
  419. package/src/release-config-policy.test.ts +0 -311
  420. package/src/runtime-input.test.ts +0 -393
  421. package/src/serial-group-wiring.test.ts +0 -326
  422. package/src/task-history-namespace.test.ts +0 -181
  423. package/src/task-results.test.ts +0 -228
  424. package/src/test-clock-policy.test.ts +0 -338
  425. package/src/test-program.test.ts +0 -303
  426. package/src/test-timings.test.ts +0 -240
  427. package/src/test-walk-policy.test.ts +0 -620
  428. package/src/testing.test.ts +0 -509
  429. package/src/typecheck-test-policy.test.ts +0 -1468
  430. package/src/typescript-resolution.test.ts +0 -76
  431. package/src/version-actions.test.ts +0 -80
  432. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,210 +0,0 @@
1
- import { expect, it } from 'bun:test';
2
- import { spawn, spawnSync } from 'node:child_process';
3
- import { writeFileSync } from 'node:fs';
4
- import { mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
5
- import { createRequire } from 'node:module';
6
- import { join } from 'node:path';
7
- import { createInterface } from 'node:readline';
8
- import { guardEvent } from './__tests__/counted-cargo.js';
9
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
10
- import { isRunning, terminate } from './testing.js';
11
-
12
- /**
13
- * Guards the ignore-file hunk of `patches/nx@23.2.1.patch`. Nx 23.2.1's daemon stopped itself on every watcher event
14
- * for a `.gitignore` or `.nxignore`, whatever the file then held. A rewrite with the same bytes (a checkout, a
15
- * formatter) reports such an event, and so does FSEvents for a write made shortly before the daemon's stream started,
16
- * whenever fseventsd numbers it after that start. Stopping destroys every client socket at once, so a file-watcher
17
- * client lost the notification of the batch that carried the event, and a dev watcher waiting to judge an edit in that
18
- * batch waited for it forever. The patched daemon stops only when an ignore file's bytes may differ from those its
19
- * watcher's filter read.
20
- *
21
- * A file-watcher client of the fixture's daemon sees a same-bytes `.gitignore` rewrite and a tracked edit after it.
22
- * Unpatched, the daemon closes the connection instead of notifying the edit; patched, the edit arrives on the same
23
- * connection and the same daemon still serves. A `.gitignore` with new bytes still stops it.
24
- *
25
- * The filter reads its ignore files in `watch()`; the workspace context the daemon compares against reads them later.
26
- * A `.gitignore` rewritten between the two reads must still stop the daemon, though the context holds its new bytes:
27
- * the filter keeps the old rules and would drop every event under a path they no longer ignore.
28
- *
29
- * Drop the hunk, and keep this test, once the Nx version in use compares an ignore file's bytes before it stops.
30
- */
31
-
32
- const repositoryRoot = join(import.meta.dir, '../../..');
33
- const nxEntry = join(repositoryRoot, 'node_modules', '.bin', 'nx');
34
- const requireNx = createRequire(join(repositoryRoot, 'package.json'));
35
- const daemonClient = requireNx.resolve('nx/src/daemon/client/client');
36
- const daemonStart = requireNx.resolve('nx/src/daemon/server/start.js');
37
- const IGNORE = 'dist\n';
38
-
39
- /**
40
- * One line per event the client saw, its kind then its tab-separated details: `ready` once registered, `changed` and
41
- * the notified files, `reconnecting` or `closed` at the connection's end, `error` and what failed.
42
- */
43
- interface WatchEvent {
44
- readonly kind: string;
45
- readonly details: readonly string[];
46
- }
47
-
48
- // The client ends at the connection's end, before Nx's own reconnect could start another daemon.
49
- const CLIENT = `
50
- const { writeSync } = require('node:fs');
51
- const { daemonClient } = require(process.env.NX_DAEMON_CLIENT);
52
- const say = (...fields) => writeSync(1, fields.join('\\t') + '\\n');
53
- daemonClient
54
- .registerFileWatcher({ watchProjects: 'all', includeGlobalWorkspaceFiles: true }, (error, data) => {
55
- if (error === 'reconnecting' || error === 'closed') {
56
- say(error);
57
- process.exit(0);
58
- }
59
- if (error !== null) {
60
- say('error', String(error));
61
- process.exit(1);
62
- }
63
- say('changed', ...data.changedFiles.map(({ path }) => path));
64
- })
65
- .then(() => say('ready'), (error) => {
66
- say('error', String(error));
67
- process.exit(1);
68
- });
69
- `;
70
-
71
- async function recordedDaemon(workspace: string): Promise<number> {
72
- const record: unknown = JSON.parse(
73
- await readFile(join(workspace, '.nx/workspace-data/d/server-process.json'), 'utf8'),
74
- );
75
- if (typeof record !== 'object' || record === null || !('processId' in record)) {
76
- throw new Error(`the fixture daemon record names no process: ${JSON.stringify(record)}`);
77
- }
78
- return Number(record.processId);
79
- }
80
-
81
- /** A file-watcher client of the workspace's daemon, read one event at a time. */
82
- function watchClient(workspace: string, env: Record<string, string>) {
83
- const child = spawn('node', ['-e', CLIENT], {
84
- cwd: workspace,
85
- env: { ...env, NX_DAEMON_CLIENT: daemonClient },
86
- stdio: ['ignore', 'pipe', 'pipe'],
87
- });
88
- let stderr = '';
89
- child.stderr.setEncoding('utf8').on('data', (text: string) => {
90
- stderr += text;
91
- });
92
- const seen: WatchEvent[] = [];
93
- const lines = createInterface({ input: child.stdout })[Symbol.asyncIterator]();
94
- const exited = new Promise<number | null>((resolve) => child.once('exit', resolve));
95
- return {
96
- seen,
97
- /** The next event, or an error once the client has said all it will. */
98
- async next(what: string): Promise<WatchEvent> {
99
- const line = await guardEvent(lines.next(), what, () => `events so far ${JSON.stringify(seen)}\n${stderr}`);
100
- if (line.done) throw new Error(`the watch client ended before ${what}: ${JSON.stringify(seen)}\n${stderr}`);
101
- const [kind = '', ...details] = line.value.split('\t');
102
- const event = { kind, details };
103
- seen.push(event);
104
- return event;
105
- },
106
- async end(): Promise<void> {
107
- if (child.pid !== undefined && child.exitCode === null && child.signalCode === null) terminate(child.pid);
108
- await exited;
109
- },
110
- };
111
- }
112
-
113
- it('keeps serving when a watched ignore file is rewritten with the bytes the daemon started with', async () => {
114
- await withNxFixture('nx-daemon-ignore-', async ({ workspace, socketDirectory }) => {
115
- const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
116
- await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
117
- await writeFile(join(workspace, 'nx.json'), '{}\n');
118
- await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'daemon-ignore', private: true }));
119
- await writeFile(join(workspace, '.gitignore'), IGNORE);
120
- await mkdir(join(workspace, 'p'));
121
- await writeFile(join(workspace, 'p', 'project.json'), JSON.stringify({ name: 'p' }));
122
-
123
- const started = spawnSync('bun', [nxEntry, 'daemon', '--start'], { cwd: workspace, env, encoding: 'utf8' });
124
- expect(started.status, `${started.stdout}${started.stderr}`).toBe(0);
125
- const serving = await recordedDaemon(workspace);
126
-
127
- const client = watchClient(workspace, env);
128
- try {
129
- expect(await client.next('the file watcher to register')).toEqual({ kind: 'ready', details: [] });
130
-
131
- // The same bytes, then a tracked edit: the edit's notification arrives on this connection.
132
- await writeFile(join(workspace, '.gitignore'), IGNORE);
133
- await writeFile(join(workspace, 'p', 'a.txt'), 'a\n');
134
- for (;;) {
135
- const event = await client.next('the tracked edit after a same-bytes .gitignore rewrite');
136
- expect(
137
- event.kind,
138
- `the daemon closed its watcher on unchanged ignore bytes: ${JSON.stringify(client.seen)}`,
139
- ).toBe('changed');
140
- if (event.details.includes('p/a.txt')) break;
141
- }
142
- expect(await recordedDaemon(workspace)).toBe(serving);
143
- expect(isRunning(serving)).toBe(true);
144
-
145
- // Control: new bytes still change the daemon's ignore rules, so it stops and closes the connection.
146
- await writeFile(join(workspace, '.gitignore'), `${IGNORE}out\n`);
147
- await writeFile(join(workspace, 'p', 'b.txt'), 'b\n');
148
- for (;;) {
149
- const event = await client.next('the daemon to stop for a .gitignore with new bytes');
150
- if (event.kind === 'reconnecting') break;
151
- expect(event.kind, JSON.stringify(client.seen)).toBe('changed');
152
- }
153
- } finally {
154
- await client.end();
155
- }
156
- });
157
- });
158
-
159
- /** A workspace whose context walk takes long enough that a write right after `watch()` lands before it. */
160
- async function largeWorkspace(workspace: string): Promise<void> {
161
- await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
162
- await writeFile(join(workspace, 'nx.json'), '{}\n');
163
- await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'daemon-ignore-gap', private: true }));
164
- for (let directory = 0; directory < 100; directory += 1) {
165
- const files = join(workspace, 'files', `d${directory}`);
166
- await mkdir(files, { recursive: true });
167
- await Promise.all(Array.from({ length: 200 }, (_, file) => writeFile(join(files, `f${file}.txt`), `${file}\n`)));
168
- }
169
- await mkdir(join(workspace, 'z'));
170
- await writeFile(join(workspace, 'z', '.gitignore'), 'gen/\n');
171
- }
172
-
173
- it('stops when an ignore file changes after the watcher read it and before the daemon compared it', async () => {
174
- await withNxFixture('nx-daemon-ignore-gap-', async ({ workspace, socketDirectory }) => {
175
- await largeWorkspace(workspace);
176
- const env = {
177
- ...fixtureNxEnv(workspace, socketDirectory),
178
- NX_DAEMON: 'true',
179
- NX_NATIVE_LOGGING: 'nx::native::watch=debug',
180
- };
181
- // The native watcher logs `watching started` once watch() has read the ignore files and started its stream; the
182
- // daemon sets its workspace context up, walking every file, only after that. The rewrite lands in between.
183
- const daemon = spawn(process.execPath, [daemonStart], { cwd: workspace, env, stdio: ['ignore', 'pipe', 'pipe'] });
184
- let output = '';
185
- let rewritten = false;
186
- const read = (text: string) => {
187
- output += text;
188
- if (!rewritten && output.includes('watching started')) {
189
- rewritten = true;
190
- writeFileSync(join(workspace, 'z', '.gitignore'), '');
191
- }
192
- };
193
- daemon.stdout.setEncoding('utf8').on('data', read);
194
- daemon.stderr.setEncoding('utf8').on('data', read);
195
- const exited = new Promise<number | null>((resolve) => daemon.once('exit', resolve));
196
- try {
197
- // Unpatched by this repair, the event for the rewrite compares equal to the context's bytes and the daemon
198
- // serves on with the filter's stale rules.
199
- const code = await guardEvent(exited, 'the daemon to stop for the rewritten .gitignore', () => output);
200
- expect(rewritten, output).toBe(true);
201
- expect(code, output).toBe(0);
202
- expect(output).toContain('Stopping the daemon the set of ignored files changed (native)');
203
- } finally {
204
- if (daemon.pid !== undefined && daemon.exitCode === null && daemon.signalCode === null) {
205
- terminate(daemon.pid);
206
- await exited;
207
- }
208
- }
209
- });
210
- });
@@ -1,105 +0,0 @@
1
- import { expect, it } from 'bun:test';
2
- import { spawnSync } from 'node:child_process';
3
- import { mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
4
- import { createConnection } from 'node:net';
5
- import { join } from 'node:path';
6
- import type { DaemonProcessJson } from 'nx/src/daemon/cache.js';
7
- import {
8
- assertNotForeignWorkspaceMessage,
9
- isForeignWorkspaceMessage,
10
- normalizeRootString,
11
- } from 'nx/src/daemon/message-types/daemon-message.js';
12
- import { sendMessage } from 'nx/src/daemon/socket-utils.js';
13
- import { consumeMessagesFromSocket, parseMessage } from 'nx/src/utils/consume-messages-from-socket.js';
14
- import typia from 'typia';
15
- import { guardEvent } from './__tests__/counted-cargo.js';
16
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
17
-
18
- const repositoryRoot = join(import.meta.dir, '../../..');
19
- const nxEntry = join(repositoryRoot, 'node_modules', '.bin', 'nx');
20
-
21
- it('removes only redundant POSIX separators and preserves root, case and backslash components', () => {
22
- for (const [input, expected] of [
23
- ['/', '/'],
24
- ['///', '/'],
25
- ['/repo/', '/repo'],
26
- ['/repo/../repo//', '/repo'],
27
- ['/repo\\/', '/repo\\'],
28
- ]) {
29
- expect(normalizeRootString(input, 'linux')).toBe(expected);
30
- }
31
- expect(normalizeRootString('/repo', 'linux')).not.toBe(normalizeRootString('/REPO', 'linux'));
32
- });
33
-
34
- it('preserves absolute Windows drive and UNC roots while normalizing equivalent spellings', () => {
35
- for (const [input, expected] of [
36
- ['C:\\', 'c:\\'],
37
- ['C:/Repo//', 'c:\\repo'],
38
- ['C:\\Repo\\', 'c:\\repo'],
39
- ['\\\\SERVER\\SHARE', '\\\\server\\share\\'],
40
- ['\\\\SERVER\\SHARE\\', '\\\\server\\share\\'],
41
- ['\\\\SERVER\\SHARE\\Repo\\', '\\\\server\\share\\repo'],
42
- ['\\', '\\'],
43
- ]) {
44
- expect(normalizeRootString(input, 'win32')).toBe(expected);
45
- }
46
- expect(normalizeRootString('C:\\Repo', 'win32')).not.toBe(normalizeRootString('D:\\Repo', 'win32'));
47
- expect(normalizeRootString('\\\\one\\share\\', 'win32')).not.toBe(normalizeRootString('\\\\two\\share\\', 'win32'));
48
- });
49
-
50
- it('compares both roots canonically without admitting a genuinely foreign workspace', () => {
51
- expect(isForeignWorkspaceMessage({ type: 'PING', workspaceRoot: '/repo/' }, '/repo')).toBe(false);
52
- expect(isForeignWorkspaceMessage({ type: 'PING', workspaceRoot: '/repo' }, '/repo/')).toBe(false);
53
- expect(isForeignWorkspaceMessage({ type: 'PING', workspaceRoot: '/foreign/' }, '/repo')).toBe(true);
54
- expect(() => assertNotForeignWorkspaceMessage({ type: 'PING', workspaceRoot: '/foreign/' }, '/repo')).toThrow();
55
- expect(isForeignWorkspaceMessage({ type: 'PING' }, '/repo')).toBe(false);
56
- });
57
-
58
- async function ping(socketPath: string, workspaceRoot: string): Promise<unknown> {
59
- const socket = createConnection(socketPath);
60
- const { promise, resolve, reject } = Promise.withResolvers<unknown>();
61
- socket.once('error', reject);
62
- socket.once('close', () => reject(new Error('fixture daemon closed before answering')));
63
- socket.on(
64
- 'data',
65
- consumeMessagesFromSocket((message) => resolve(parseMessage(message)), reject),
66
- );
67
- socket.once('connect', () => sendMessage(socket, { type: 'PING', workspaceRoot }, 'json'));
68
- try {
69
- return await guardEvent(
70
- promise,
71
- 'the fixture daemon root RPC',
72
- () => `socket ${socketPath}; root ${workspaceRoot}`,
73
- );
74
- } finally {
75
- socket.destroy();
76
- }
77
- }
78
-
79
- it('accepts its real daemon RPC with a trailing root separator and refuses a genuinely foreign root', async () => {
80
- await withNxFixture(
81
- 'nx-root-rpc-',
82
- async ({ root, socketDirectory, workspace }) => {
83
- await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
84
- await writeFile(join(workspace, 'nx.json'), '{}\n');
85
- await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'root-rpc', private: true }));
86
- const foreign = join(root, 'foreign');
87
- await mkdir(foreign);
88
- await writeFile(join(foreign, 'nx.json'), '{}\n');
89
- const started = spawnSync('node', [nxEntry, 'daemon', '--start'], {
90
- cwd: workspace,
91
- env: { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' },
92
- encoding: 'utf8',
93
- });
94
- expect(started.status, started.stdout + started.stderr).toBe(0);
95
- const recordPath = join(workspace, '.nx/workspace-data/d/server-process.json');
96
- const record = typia.json.assertParse<DaemonProcessJson>(await readFile(recordPath, 'utf8'));
97
- expect(await ping(record.socketPath, workspace)).toBe(true);
98
- expect(await ping(record.socketPath, `${workspace}/`)).toBe(true);
99
- expect(await ping(record.socketPath, foreign)).toMatchObject({ error: expect.anything() });
100
- expect(await ping(record.socketPath, workspace)).toBe(true);
101
- expect(typia.json.assertParse<DaemonProcessJson>(await readFile(recordPath, 'utf8'))).toEqual(record);
102
- },
103
- 'workspace',
104
- );
105
- });
@@ -1,292 +0,0 @@
1
- import { expect, it } from 'bun:test';
2
- import { spawn, spawnSync } from 'node:child_process';
3
- import { mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
4
- import { createRequire } from 'node:module';
5
- import { join } from 'node:path';
6
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
7
- import { awaitExit, isRunning, processTable, terminate } from './testing.js';
8
-
9
- /**
10
- * Guards the `NX_DAEMON_START=never` hunks of `patches/nx@23.2.1.patch`. A stock client that finds no live daemon
11
- * starts one, detached into a session of its own, and the record shares it with every client of the checkout. Cowshed
12
- * ends a job's whole process tree when the job ends (`specs/cowshed/11_shell.md`), so a daemon one job's client
13
- * started would end with that job while another job's `nx run` still used it. Every cowshed job therefore runs with
14
- * `NX_DAEMON_START=never` (`specs/cowshed/04_sandbox.md`): its client uses the daemon the record names while that
15
- * runs, otherwise computes the command without one, and never starts a daemon. A daemon that stops under such a
16
- * client turns the daemon off for that process alone, and the command continues without it: its successor is its
17
- * starter's to start, and the stop is no reason to disable the checkout's daemon for anyone else.
18
- */
19
-
20
- const repositoryRoot = join(import.meta.dir, '../../..');
21
- const nxEntry = join(repositoryRoot, 'node_modules', '.bin', 'nx');
22
- const nxVersion: string = createRequire(join(repositoryRoot, 'package.json'))('nx/package.json').version;
23
-
24
- const record = (workspace: string) => join(workspace, '.nx/workspace-data/d/server-process.json');
25
-
26
- async function recordedPid(workspace: string): Promise<number | null> {
27
- const text = await readFile(record(workspace), 'utf8').catch((error: unknown) => {
28
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null;
29
- throw error;
30
- });
31
- if (text === null) return null;
32
- const parsed: unknown = JSON.parse(text);
33
- if (
34
- typeof parsed !== 'object' ||
35
- parsed === null ||
36
- !('processId' in parsed) ||
37
- typeof parsed.processId !== 'number'
38
- ) {
39
- throw new Error(`the daemon record names no process: ${text}`);
40
- }
41
- return parsed.processId;
42
- }
43
-
44
- async function fixtureWorkspace(workspace: string): Promise<void> {
45
- await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
46
- await writeFile(join(workspace, 'nx.json'), '{}\n');
47
- await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'daemon-start-never', private: true }));
48
- await mkdir(join(workspace, 'p'));
49
- await writeFile(join(workspace, 'p', 'project.json'), JSON.stringify({ name: 'p' }));
50
- }
51
-
52
- /**
53
- * Run `nx show projects --json`, require it to list the fixture's one project, and return everything it printed. The
54
- * format is asked for, never inferred: unasked, Nx prints JSON only when it detects an AI agent in the environment
55
- * (`show/command-object.js`, `isAiAgent`) and a plain name per line otherwise. The list is stdout's last line: a note
56
- * Nx prints about its daemon goes to stdout before it.
57
- */
58
- function showProjects(workspace: string, env: Record<string, string>): string {
59
- const ran = spawnSync('bun', [nxEntry, 'show', 'projects', '--json'], { cwd: workspace, env, encoding: 'utf8' });
60
- const output = `${ran.stdout}${ran.stderr}`;
61
- expect(ran.status, output).toBe(0);
62
- expect(JSON.parse(ran.stdout.trimEnd().split('\n').at(-1) ?? ''), output).toEqual(['p']);
63
- return output;
64
- }
65
-
66
- it('a client that may never start a daemon uses a running one and otherwise runs without', async () => {
67
- await withNxFixture('nx-daemon-start-never', async ({ workspace, socketDirectory }) => {
68
- await fixtureWorkspace(workspace);
69
- const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
70
- const never = { ...env, NX_DAEMON_START: 'never' };
71
-
72
- // No daemon runs: the command is computed in the client, and no daemon is started.
73
- showProjects(workspace, never);
74
- expect(await recordedPid(workspace)).toBeNull();
75
-
76
- // Control: the same client without the variable starts one, so the absence above is the variable's doing.
77
- showProjects(workspace, env);
78
- const daemon = await recordedPid(workspace);
79
- if (daemon === null) throw new Error('a client allowed to start a daemon left no record');
80
- expect(isRunning(daemon)).toBe(true);
81
-
82
- // A daemon runs: the client uses it, and it is still the one the record names.
83
- const log = join(workspace, '.nx/workspace-data/d/daemon.log');
84
- const before = (await readFile(log, 'utf8')).length;
85
- showProjects(workspace, never);
86
- expect(await recordedPid(workspace)).toBe(daemon);
87
- expect((await readFile(log, 'utf8')).length).toBeGreaterThan(before);
88
-
89
- // A record whose daemon has gone (killed, so it never cleared its record) is no daemon to use and no reason to
90
- // start one.
91
- const killed = (await processTable()).filter((entry) => entry.pid === daemon);
92
- terminate(daemon, 'SIGKILL');
93
- await awaitExit(killed, 'the killed fixture daemon');
94
- showProjects(workspace, never);
95
- expect(await recordedPid(workspace)).toBe(daemon);
96
- });
97
- });
98
-
99
- it('a client that may never start a daemon continues without one that stopped under it, and disables nothing', async () => {
100
- await withNxFixture('nx-daemon-start-gone', async ({ workspace, socketDirectory }) => {
101
- await fixtureWorkspace(workspace);
102
- const never = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true', NX_DAEMON_START: 'never' };
103
-
104
- // The record names a running process that serves no socket: a daemon that stopped answering after the client
105
- // chose to use it.
106
- const holder = spawn('sleep', ['300'], { stdio: 'ignore' });
107
- try {
108
- const pid = holder.pid;
109
- if (pid === undefined) throw new Error('sleep did not start');
110
- await mkdir(join(workspace, '.nx/workspace-data/d'), { recursive: true });
111
- await writeFile(
112
- record(workspace),
113
- JSON.stringify({ processId: pid, socketPath: join(socketDirectory, 'gone.sock'), nxVersion }),
114
- );
115
-
116
- expect(showProjects(workspace, never)).toContain('NX_DAEMON_START=never: this client never starts a daemon');
117
- expect(await recordedPid(workspace)).toBe(pid);
118
- // Not disabled for the checkout: the marker only `nx reset` clears would follow it into every terminal.
119
- await expect(readFile(join(workspace, '.nx/workspace-data/d/disabled'), 'utf8')).rejects.toMatchObject({
120
- code: 'ENOENT',
121
- });
122
- } finally {
123
- holder.kill('SIGKILL');
124
- }
125
- });
126
- });
127
-
128
- const taskOutput = (project: string) => `${project}/dist/${project}.txt`;
129
-
130
- /**
131
- * Two cacheable tasks: `p:build` runs `first` and writes its output, and `q:build` copies it. `q:build`'s inputs are
132
- * `p:build`'s outputs, so it is hashed only once `p:build` has finished, and whatever `first` did to the daemon is
133
- * behind every daemon request after it: that hash, recording outputs, the post-run hooks.
134
- */
135
- async function twoTaskWorkspace(workspace: string, first: string): Promise<void> {
136
- await fixtureWorkspace(workspace);
137
- const build = (command: string) => ({ command, outputs: ['{projectRoot}/dist'], cache: true });
138
- await writeFile(
139
- join(workspace, 'p', 'project.json'),
140
- JSON.stringify({
141
- name: 'p',
142
- targets: { build: build(`${first}; mkdir -p p/dist && echo p > ${taskOutput('p')}`) },
143
- }),
144
- );
145
- await mkdir(join(workspace, 'q'));
146
- await writeFile(
147
- join(workspace, 'q', 'project.json'),
148
- JSON.stringify({
149
- name: 'q',
150
- implicitDependencies: ['p'],
151
- targets: {
152
- build: {
153
- ...build(`mkdir -p q/dist && cp ${taskOutput('p')} ${taskOutput('q')}`),
154
- dependsOn: ['^build'],
155
- inputs: ['default', { dependentTasksOutputFiles: '**/*.txt' }],
156
- },
157
- },
158
- }),
159
- );
160
- }
161
-
162
- /** Start the fixture's daemon with a client allowed to, under `runtime`, and return the pid its record names. */
163
- async function startDaemon(workspace: string, env: Record<string, string>, runtime: string): Promise<number> {
164
- const ran = spawnSync(runtime, [nxEntry, 'show', 'projects', '--json'], { cwd: workspace, env, encoding: 'utf8' });
165
- expect(ran.status, `${ran.stdout}${ran.stderr}`).toBe(0);
166
- const daemon = await recordedPid(workspace);
167
- if (daemon === null) throw new Error('a client allowed to start a daemon left no record');
168
- return daemon;
169
- }
170
-
171
- /** `nx run-many -t build` under the job rule; requires it to succeed with `q:build` built from `p:build`. */
172
- async function runBothUnderNever(workspace: string, env: Record<string, string>, runtime: string): Promise<string> {
173
- const run = spawnSync(runtime, [nxEntry, 'run-many', '-t', 'build', '--outputStyle=static'], {
174
- cwd: workspace,
175
- env: { ...env, NX_DAEMON_START: 'never' },
176
- encoding: 'utf8',
177
- });
178
- const printed = `${run.stdout}${run.stderr}`;
179
- expect(run.status, printed).toBe(0);
180
- expect(await readFile(join(workspace, taskOutput('q')), 'utf8')).toBe('p\n');
181
- // Not disabled for the checkout: the marker only `nx reset` clears would follow it into every terminal.
182
- await expect(readFile(join(workspace, '.nx/workspace-data/d/disabled'), 'utf8')).rejects.toMatchObject({
183
- code: 'ENOENT',
184
- });
185
- return printed;
186
- }
187
-
188
- /**
189
- * The daemon stops while a run uses it, after the graph came from it: `p:build` kills it, and every daemon request
190
- * after that goes to a daemon that is gone. Each continues in the client, the run finishes, and nothing is disabled
191
- * or started.
192
- */
193
- it('a run whose daemon stops under it continues without one, and disables nothing', async () => {
194
- await withNxFixture('nx-daemon-start-midrun', async ({ workspace, socketDirectory }) => {
195
- await twoTaskWorkspace(
196
- workspace,
197
- 'kill -9 $STOP_DAEMON; while kill -0 $STOP_DAEMON 2>/dev/null; do sleep 0.05; done',
198
- );
199
- const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
200
- const daemon = await startDaemon(workspace, env, 'bun');
201
-
202
- const printed = await runBothUnderNever(workspace, { ...env, STOP_DAEMON: String(daemon) }, 'bun');
203
- expect(isRunning(daemon)).toBe(false);
204
- expect(printed).toContain(
205
- 'NX_DAEMON_START=never: this client never starts a daemon. Continuing without the daemon.',
206
- );
207
- // No successor: the record still names the daemon the task killed.
208
- expect(await recordedPid(workspace)).toBe(daemon);
209
- });
210
- });
211
-
212
- /**
213
- * The daemon restarts itself while a run uses it: `p:build` writes a lockfile, so the next request finds the daemon
214
- * outdated, and it starts its successor and ends the request's socket. The client waits for that successor and
215
- * resumes on it, as the job rule allows: its starter is the restarting daemon, not the client. The run finishes.
216
- */
217
- it('a run whose daemon restarts itself under it finishes', async () => {
218
- await withNxFixture('nx-daemon-start-restart', async ({ workspace, socketDirectory }) => {
219
- // A lockfile Nx parses: an unparsable one fails the successor's graph, which is a different failure.
220
- const lockfile = JSON.stringify({
221
- name: 'daemon-start-never',
222
- lockfileVersion: 3,
223
- requires: true,
224
- packages: { '': { name: 'daemon-start-never' } },
225
- });
226
- await twoTaskWorkspace(workspace, `echo '${lockfile}' > package-lock.json`);
227
- const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
228
- await startDaemon(workspace, env, 'node');
229
-
230
- await runBothUnderNever(workspace, env, 'node');
231
- expect(await readFile(join(workspace, '.nx/workspace-data/d/daemon.log'), 'utf8')).toContain('Restarting daemon');
232
- });
233
- });
234
-
235
- /**
236
- * A restarting daemon opens the log twice for its successor's stdout and stderr. Left to garbage collection, Node >=26
237
- * turns each collected `FileHandle` into a fatal `ERR_INVALID_STATE`, which ended a restarting daemon in a job with
238
- * the socket its clients were still writing to. Collected deliberately here, right after the restart's spawn, so the
239
- * descriptors' lifetime decides the exit rather than when a collection happens to run.
240
- */
241
- it('a restarting daemon closes the log descriptors it hands its successor', async () => {
242
- await withNxFixture('nx-daemon-restart-descriptors', async ({ workspace, socketDirectory }) => {
243
- await fixtureWorkspace(workspace);
244
- const shutdownUtils = join(repositoryRoot, 'node_modules/nx/dist/src/daemon/server/shutdown-utils.js');
245
- const restart = `const { setTimeout: sleep } = require('node:timers/promises');
246
- require(${JSON.stringify(shutdownUtils)}).startNewDaemonInBackground().then(async () => {
247
- for (let round = 0; round < 3; round++) { gc(); await sleep(50); }
248
- })`;
249
- const ran = spawnSync('node', ['--expose-gc', '-e', restart], {
250
- cwd: workspace,
251
- env: { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' },
252
- encoding: 'utf8',
253
- });
254
- expect(ran.status, `${ran.stdout}${ran.stderr}`).toBe(0);
255
- expect(ran.stderr).not.toContain('ERR_INVALID_STATE');
256
- // The successor is the fixture's to stop: wait for the record it writes once it serves.
257
- const deadline = Date.now() + 60_000;
258
- while ((await recordedPid(workspace)) === null) {
259
- if (Date.now() > deadline) throw new Error('the restarted daemon wrote no record within 60 s');
260
- await Bun.sleep(100);
261
- }
262
- });
263
- });
264
-
265
- /**
266
- * An explicit `nx daemon --start` calls the daemon start directly, past the implicit-start check above, so under the
267
- * job's rule it is refused as policy: a non-zero exit naming `NX_DAEMON_START=never` and the fixture escape, and no
268
- * daemon. The same command without the variable, which is what a test's named fixture escape runs, starts one.
269
- */
270
- it('refuses an explicit daemon start under the job rule, and starts one without it', async () => {
271
- await withNxFixture('nx-daemon-start-explicit', async ({ workspace, socketDirectory }) => {
272
- await fixtureWorkspace(workspace);
273
- const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
274
-
275
- const refused = spawnSync('bun', [nxEntry, 'daemon', '--start'], {
276
- cwd: workspace,
277
- env: { ...env, NX_DAEMON_START: 'never' },
278
- encoding: 'utf8',
279
- });
280
- const said = `${refused.stdout}${refused.stderr}`;
281
- expect(refused.status, said).toBe(1);
282
- expect(said).toContain('NX_DAEMON_START=never forbids this client starting a daemon');
283
- expect(said).toContain('FIXTURE_STARTS_ITS_OWN_DAEMON');
284
- expect(await recordedPid(workspace)).toBeNull();
285
-
286
- const started = spawnSync('bun', [nxEntry, 'daemon', '--start'], { cwd: workspace, env, encoding: 'utf8' });
287
- expect(started.status, `${started.stdout}${started.stderr}`).toBe(0);
288
- const daemon = await recordedPid(workspace);
289
- if (daemon === null) throw new Error('an explicit start without the variable left no daemon record');
290
- expect(isRunning(daemon)).toBe(true);
291
- });
292
- });