@smoothbricks/nx-plugin 0.5.6 → 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 (440) hide show
  1. package/README.md +1095 -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/all-verdicts/executor.d.ts +35 -0
  59. package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
  60. package/dist/executors/all-verdicts/executor.js +133 -0
  61. package/dist/executors/all-verdicts/schema.d.ts +10 -0
  62. package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
  63. package/dist/executors/all-verdicts/schema.js +2 -0
  64. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  65. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  66. package/dist/executors/bounded-exec/bounds.js +43 -0
  67. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  68. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  70. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  71. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/executor.js +371 -239
  73. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  74. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  75. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  76. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  77. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  78. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  79. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  80. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  82. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  83. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  84. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  85. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  86. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  88. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  89. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  90. package/dist/executors/bounded-exec/progress.js +5 -2
  91. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  92. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  93. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  94. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  95. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  96. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  97. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  98. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  100. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  101. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  102. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  103. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  104. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  105. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  106. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  107. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  108. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  109. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  110. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  111. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  112. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  113. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  114. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  115. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  116. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  117. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  118. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  119. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  120. package/dist/executors/bounded-exec/verdict.js +88 -19
  121. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  122. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  123. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  124. package/dist/executors/clean-outputs/executor.js +1 -0
  125. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  126. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/executor.js +367 -0
  128. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  129. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  130. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  131. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  132. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  133. package/dist/executors/scriptc-native/schema.js +1 -0
  134. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  135. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  136. package/dist/executors/typescript-emit/executor.js +164 -33
  137. package/dist/forbidden-spelling-policy.d.ts +56 -0
  138. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  139. package/dist/forbidden-spelling-policy.js +176 -0
  140. package/dist/generators/create-package/generator.d.ts.map +1 -1
  141. package/dist/generators/create-package/generator.js +3 -4
  142. package/dist/graph-input-contract.d.ts +14 -0
  143. package/dist/graph-input-contract.d.ts.map +1 -1
  144. package/dist/graph-input-contract.js +67 -2
  145. package/dist/index.d.ts +23 -6
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +676 -215
  148. package/dist/managed-assets.d.ts +2 -0
  149. package/dist/managed-assets.d.ts.map +1 -1
  150. package/dist/managed-files/files.d.ts +3 -3
  151. package/dist/managed-files/files.d.ts.map +1 -1
  152. package/dist/managed-files/files.js +28 -3
  153. package/dist/managed-files/managed-format.d.ts.map +1 -1
  154. package/dist/managed-files/managed-format.js +1 -0
  155. package/dist/nextest-code-bound.js +1 -0
  156. package/dist/nextest-timings.d.ts +35 -0
  157. package/dist/nextest-timings.d.ts.map +1 -0
  158. package/dist/nextest-timings.js +168 -0
  159. package/dist/owned-installation.d.ts +6 -5
  160. package/dist/owned-installation.d.ts.map +1 -1
  161. package/dist/owned-installation.js +150 -26
  162. package/dist/package-target-policy.d.ts.map +1 -1
  163. package/dist/package-target-policy.js +2 -3
  164. package/dist/process-children.d.ts +7 -0
  165. package/dist/process-children.d.ts.map +1 -0
  166. package/dist/process-children.darwin.d.ts +7 -0
  167. package/dist/process-children.darwin.d.ts.map +1 -0
  168. package/dist/process-children.darwin.js +13 -0
  169. package/dist/process-children.js +14 -0
  170. package/dist/process-children.linux.d.ts +8 -0
  171. package/dist/process-children.linux.d.ts.map +1 -0
  172. package/dist/process-children.linux.js +25 -0
  173. package/dist/process-group.d.ts +108 -0
  174. package/dist/process-group.d.ts.map +1 -0
  175. package/dist/process-group.js +171 -0
  176. package/dist/process-listing.d.ts +7 -0
  177. package/dist/process-listing.d.ts.map +1 -0
  178. package/dist/process-listing.js +51 -0
  179. package/dist/producer-receipts.d.ts +8 -2
  180. package/dist/producer-receipts.d.ts.map +1 -1
  181. package/dist/producer-receipts.js +75 -48
  182. package/dist/task-graph-policy.d.ts +21 -0
  183. package/dist/task-graph-policy.d.ts.map +1 -0
  184. package/dist/task-graph-policy.js +91 -0
  185. package/dist/test-timings.js +4 -4
  186. package/dist/test-walk-policy.d.ts +14 -5
  187. package/dist/test-walk-policy.d.ts.map +1 -1
  188. package/dist/test-walk-policy.js +8 -2
  189. package/dist/testing.d.ts +73 -28
  190. package/dist/testing.d.ts.map +1 -1
  191. package/dist/testing.js +217 -223
  192. package/dist/tool-bins.d.ts +33 -0
  193. package/dist/tool-bins.d.ts.map +1 -0
  194. package/dist/tool-bins.js +72 -0
  195. package/dist/typecheck-test-policy.d.ts.map +1 -1
  196. package/dist/typecheck-test-policy.js +3 -4
  197. package/dist/wait-why-policy.d.ts +28 -0
  198. package/dist/wait-why-policy.d.ts.map +1 -0
  199. package/dist/wait-why-policy.js +223 -0
  200. package/dist/workspace-config-policy.d.ts +14 -8
  201. package/dist/workspace-config-policy.d.ts.map +1 -1
  202. package/dist/workspace-config-policy.js +60 -16
  203. package/dist/workspace-manifest.d.ts +41 -6
  204. package/dist/workspace-manifest.d.ts.map +1 -1
  205. package/dist/workspace-manifest.js +57 -0
  206. package/executors.json +21 -1
  207. package/loader.js +2 -0
  208. package/managed/raw/envrc +11 -0
  209. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  210. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  211. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  212. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  213. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  214. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  215. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  216. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  217. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  218. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  219. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  220. package/managed/raw/tooling/direnv/repo-path +68 -6
  221. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  222. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  223. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  224. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  225. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  226. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  227. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  228. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  229. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  230. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  231. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  232. package/package.json +77 -13
  233. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  234. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  235. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  236. package/src/bounded-test-policy.ts +12 -14
  237. package/src/build-state-output-policy.ts +458 -34
  238. package/src/bun-lock-scope.ts +108 -0
  239. package/src/cargo-build-script-env.ts +265 -0
  240. package/src/cargo-closure-input.ts +74 -7
  241. package/src/cargo-retention-hook.ts +94 -0
  242. package/src/cargo-source-hash.ts +138 -41
  243. package/src/cargo-toolchain-paths.ts +95 -0
  244. package/src/cargo-toolchain-policy.ts +49 -5
  245. package/src/cargo-workspace.ts +72 -123
  246. package/src/cross-check-policy.ts +12 -10
  247. package/src/disk-command-policy.ts +1 -0
  248. package/src/ensure-built-receipt.ts +132 -39
  249. package/src/ensure-built-witness.ts +62 -10
  250. package/src/ensure-built.ts +11 -1
  251. package/src/eslint-config-closure.ts +357 -0
  252. package/src/executors/all-verdicts/executor.ts +164 -0
  253. package/src/executors/all-verdicts/schema.json +22 -0
  254. package/src/executors/all-verdicts/schema.ts +10 -0
  255. package/src/executors/bounded-exec/bounds.ts +76 -0
  256. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  257. package/src/executors/bounded-exec/executor.ts +423 -259
  258. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  259. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  260. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  261. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  262. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  263. package/src/executors/bounded-exec/progress.ts +9 -3
  264. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  265. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  266. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  267. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  268. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  269. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  270. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  271. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  272. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  273. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  274. package/src/executors/bounded-exec/schema.json +11 -2
  275. package/src/executors/bounded-exec/schema.ts +19 -1
  276. package/src/executors/bounded-exec/verdict.ts +137 -34
  277. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  278. package/src/executors/clean-outputs/executor.ts +1 -0
  279. package/src/executors/scriptc-native/executor.ts +394 -0
  280. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  281. package/src/executors/scriptc-native/schema.json +60 -0
  282. package/src/executors/scriptc-native/schema.ts +34 -0
  283. package/src/executors/typescript-emit/executor.ts +205 -38
  284. package/src/forbidden-spelling-policy.ts +226 -0
  285. package/src/generators/create-package/generator.ts +7 -7
  286. package/src/graph-input-contract.ts +61 -2
  287. package/src/index.ts +792 -225
  288. package/src/managed-assets.ts +3 -0
  289. package/src/managed-files/files.ts +28 -3
  290. package/src/managed-files/managed-format.ts +1 -0
  291. package/src/nextest-code-bound.ts +1 -0
  292. package/src/nextest-timings.ts +106 -0
  293. package/src/owned-installation.ts +150 -23
  294. package/src/package-target-policy.ts +2 -3
  295. package/src/process-children.darwin.ts +14 -0
  296. package/src/process-children.linux.ts +33 -0
  297. package/src/process-children.ts +22 -0
  298. package/src/process-group.ts +209 -0
  299. package/src/process-listing.ts +54 -0
  300. package/src/producer-receipts.ts +68 -45
  301. package/src/task-graph-policy.ts +98 -0
  302. package/src/test-walk-policy.ts +23 -8
  303. package/src/testing.ts +240 -232
  304. package/src/tool-bins.ts +108 -0
  305. package/src/typecheck-test-policy.ts +2 -3
  306. package/src/wait-why-policy.ts +226 -0
  307. package/src/workspace-config-policy.ts +63 -15
  308. package/src/workspace-manifest.ts +89 -6
  309. package/test-timings.json +123 -98
  310. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  311. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  312. package/dist/bin/smoo-nx-failures.js +0 -3
  313. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  314. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  315. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  316. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  317. package/dist/failure-summary.d.ts +0 -5
  318. package/dist/failure-summary.d.ts.map +0 -1
  319. package/dist/failure-summary.js +0 -118
  320. package/dist/nextest-extraction.d.ts +0 -117
  321. package/dist/nextest-extraction.d.ts.map +0 -1
  322. package/dist/nextest-extraction.js +0 -303
  323. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  324. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  325. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  326. package/src/__tests__/counted-cargo-process.ts +0 -286
  327. package/src/__tests__/counted-cargo.ts +0 -713
  328. package/src/__tests__/directory-change.ts +0 -27
  329. package/src/__tests__/fixture-cargo-home.ts +0 -36
  330. package/src/__tests__/fixture-nx-env.ts +0 -193
  331. package/src/__tests__/owned-installation.ts +0 -13
  332. package/src/__tests__/past-tick.ts +0 -12
  333. package/src/__tests__/progress-clock.ts +0 -43
  334. package/src/__tests__/runtime-input.ts +0 -23
  335. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  336. package/src/bin/smoo-nx-failures.ts +0 -4
  337. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  338. package/src/bounded-test-policy.test.ts +0 -1029
  339. package/src/build-state-output-policy.test.ts +0 -115
  340. package/src/bun-bootstrap.test.ts +0 -102
  341. package/src/bun-file-packages.test.ts +0 -47
  342. package/src/cargo-closure-filesets.test.ts +0 -63
  343. package/src/cargo-closure-input.property.test.ts +0 -50
  344. package/src/cargo-closure-input.test.ts +0 -506
  345. package/src/cargo-closure-key.test.ts +0 -240
  346. package/src/cargo-resolve-cache.test.ts +0 -1181
  347. package/src/cargo-source-hash.test.ts +0 -707
  348. package/src/cargo-workspace.test.ts +0 -615
  349. package/src/cross-check-policy.test.ts +0 -316
  350. package/src/disk-command-policy.test.ts +0 -61
  351. package/src/ensure-built-receipt.test.ts +0 -279
  352. package/src/ensure-built-witness.test.ts +0 -688
  353. package/src/ensure-built.test.ts +0 -1462
  354. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  355. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  356. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  357. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  358. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  359. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  360. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  361. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  362. package/src/executors/bounded-exec/progress.test.ts +0 -139
  363. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  364. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  365. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  366. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  367. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  368. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  369. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  370. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  371. package/src/executors/clean-outputs/executor.test.ts +0 -20
  372. package/src/executors/typescript-emit/executor.test.ts +0 -83
  373. package/src/failure-summary.ts +0 -119
  374. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  375. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  376. package/src/generators/create-package/generator.test.ts +0 -190
  377. package/src/generators/make-public/generator.test.ts +0 -137
  378. package/src/graph-input-contract.test.ts +0 -379
  379. package/src/host-controller-wiring.test.ts +0 -31
  380. package/src/index.test.ts +0 -3319
  381. package/src/linked-snapshots.nx.test.ts +0 -254
  382. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  383. package/src/managed-files/generator.test.ts +0 -243
  384. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  385. package/src/managed-files/json-edit.test.ts +0 -216
  386. package/src/managed-files/managed-content.test.ts +0 -166
  387. package/src/managed-files/managed-format-json.test.ts +0 -308
  388. package/src/managed-files/repo-path.test.ts +0 -172
  389. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  390. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  391. package/src/managed-files/tree-permissions.test.ts +0 -109
  392. package/src/managed-files/tree.test.ts +0 -123
  393. package/src/manifest-hash.test.ts +0 -219
  394. package/src/nextest-code-bound.test.ts +0 -161
  395. package/src/nextest-extraction.test.ts +0 -216
  396. package/src/nextest-extraction.ts +0 -371
  397. package/src/nextest-partitions.test.ts +0 -501
  398. package/src/nx-cache-bound.test.ts +0 -109
  399. package/src/nx-cache-restore-mtime.test.ts +0 -170
  400. package/src/nx-daemon-claim.test.ts +0 -279
  401. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  402. package/src/nx-daemon-idle-policy.test.ts +0 -111
  403. package/src/nx-daemon-ignore-files.test.ts +0 -210
  404. package/src/nx-daemon-root-normalization.test.ts +0 -105
  405. package/src/nx-daemon-start-never.test.ts +0 -292
  406. package/src/nx-daemon-validity.test.ts +0 -1055
  407. package/src/nx-dot-input-policy.test.ts +0 -353
  408. package/src/nx-failure-life-cycles.test.ts +0 -207
  409. package/src/nx-files-archive-racy.test.ts +0 -97
  410. package/src/nx-foreign-workspace-env.test.ts +0 -329
  411. package/src/nx-incomplete-run-summary.test.ts +0 -70
  412. package/src/nx-plugin-load-errors.test.ts +0 -120
  413. package/src/nx-project-graph-errors.test.ts +0 -70
  414. package/src/nx-project-resolution-cache.test.ts +0 -176
  415. package/src/nx-raw-inputs.test.ts +0 -166
  416. package/src/nx-resident-graph-workers.test.ts +0 -112
  417. package/src/nx-run-information.test.ts +0 -118
  418. package/src/nx-skipped-task-exit.test.ts +0 -180
  419. package/src/nx-state-location.test.ts +0 -63
  420. package/src/nx-store-resolution.test.ts +0 -81
  421. package/src/nx-task-graph-cycles.test.ts +0 -148
  422. package/src/nx-task-output-lease.test.ts +0 -550
  423. package/src/nx-use-local.test.ts +0 -105
  424. package/src/owned-installation.test.ts +0 -105
  425. package/src/package-target-policy.test.ts +0 -1014
  426. package/src/producer-receipts.test.ts +0 -285
  427. package/src/release-config-policy.test.ts +0 -311
  428. package/src/runtime-input.test.ts +0 -393
  429. package/src/serial-group-wiring.test.ts +0 -326
  430. package/src/task-history-namespace.test.ts +0 -181
  431. package/src/task-results.test.ts +0 -228
  432. package/src/test-clock-policy.test.ts +0 -338
  433. package/src/test-program.test.ts +0 -303
  434. package/src/test-timings.test.ts +0 -240
  435. package/src/test-walk-policy.test.ts +0 -620
  436. package/src/testing.test.ts +0 -509
  437. package/src/typecheck-test-policy.test.ts +0 -1468
  438. package/src/typescript-resolution.test.ts +0 -76
  439. package/src/version-actions.test.ts +0 -80
  440. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,24 +1,146 @@
1
+ import { lstatSync, readdirSync, statSync } from 'node:fs';
1
2
  import { posix } from 'node:path';
3
+ import { Minimatch } from 'minimatch';
2
4
  import { getOutputsForTargetAndConfiguration, interpolate } from 'nx/src/tasks-runner/utils';
5
+ /** `project:target[:configuration]`, as Nx names the task. */
6
+ function taskName({ project, target, configuration, }) {
7
+ return `${project}:${target}${configuration ? `:${configuration}` : ''}`;
8
+ }
3
9
  export class BuildStateOutputError extends Error {
4
10
  findings;
5
11
  constructor(findings) {
6
12
  super(`Nx outputs must not cover cowshed build-state paths:\n${findings
7
- .map(({ project, target, configuration, output, buildStatePath }) => ` ${project}:${target}${configuration ? `:${configuration}` : ''}: ${JSON.stringify(output)} covers ${JSON.stringify(buildStatePath)}`)
13
+ .map((finding) => ` ${taskName(finding)}: ${JSON.stringify(finding.output)} covers ${JSON.stringify(finding.buildStatePath)}`)
8
14
  .join('\n')}`);
9
15
  this.findings = findings;
10
16
  this.name = 'BuildStateOutputError';
11
17
  }
12
18
  }
19
+ /** A target whose outputs Nx refuses to interpolate, named: Nx's own error names only the output. */
20
+ export class OutputDeclarationError extends Error {
21
+ project;
22
+ target;
23
+ configuration;
24
+ constructor(project, target, configuration, cause) {
25
+ super(`${taskName({ project, target, configuration })}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
26
+ this.project = project;
27
+ this.target = target;
28
+ this.configuration = configuration;
29
+ this.name = 'OutputDeclarationError';
30
+ }
31
+ }
32
+ export class OutputOverlapError extends Error {
33
+ overlaps;
34
+ constructor(overlaps) {
35
+ super(`Each Nx output path has one producing task; these tasks declare one path or pattern, or one inside another:\n${overlaps
36
+ .map(({ left, right }) => ` ${taskName(left)}: ${JSON.stringify(left.output)} overlaps ${taskName(right)}: ${JSON.stringify(right.output)}`)
37
+ .join('\n')}`);
38
+ this.overlaps = overlaps;
39
+ this.name = 'OutputOverlapError';
40
+ }
41
+ }
42
+ export class OutputKindError extends Error {
43
+ findings;
44
+ constructor(findings) {
45
+ super(`Each Nx output declaration states its kind: a directory output ends in \`/\`, a file output does not. These contradict the built tree:\n${findings
46
+ .map((finding) => ` ${taskName(finding)}: ${JSON.stringify(finding.output)} is declared a ${finding.kind} but is a ${finding.onDisk} on disk`)
47
+ .join('\n')}`);
48
+ this.findings = findings;
49
+ this.name = 'OutputKindError';
50
+ }
51
+ }
52
+ /** Task outputs naming the workspace root itself or a path outside it: no file of the checkout is theirs to name. */
53
+ export class OutputEscapeError extends Error {
54
+ findings;
55
+ constructor(findings) {
56
+ super(`Each Nx output names a path inside its workspace, below the root; these do not:\n${findings
57
+ .map((finding) => ` ${taskName(finding)}: ${JSON.stringify(finding.output)}`)
58
+ .join('\n')}`);
59
+ this.findings = findings;
60
+ this.name = 'OutputEscapeError';
61
+ }
62
+ }
63
+ /** A path segment holding glob syntax, read conservatively: any character that may start a pattern. */
64
+ const GLOB_PART = /[*?[\]{}()!]/;
13
65
  function contains(parent, child) {
14
66
  return parent === child || child.startsWith(parent.endsWith('/') ? parent : `${parent}/`);
15
67
  }
16
68
  /** The non-glob directory prefix, conservatively including every possible glob match. */
17
69
  function staticPrefix(output) {
18
70
  const parts = output.replaceAll('\\', '/').split('/');
19
- const firstGlob = parts.findIndex((part) => /[*?[\]{}()!]/.test(part));
71
+ const firstGlob = parts.findIndex((part) => GLOB_PART.test(part));
20
72
  return firstGlob < 0 ? parts.join('/') : parts.slice(0, firstGlob).join('/') || '.';
21
73
  }
74
+ function absoluteRoot(workspaceRoot) {
75
+ const root = workspaceRoot.replaceAll('\\', '/');
76
+ if (!posix.isAbsolute(root))
77
+ throw new Error('Nx output validation requires an absolute workspace root');
78
+ return root;
79
+ }
80
+ /**
81
+ * What one target declares under one configuration. Nx's task helper rejects root globs and absolute declarations
82
+ * before expanding them, and its interpolation throws on a misplaced `{workspaceRoot}` without naming the target; the
83
+ * declarations are interpolated here, so those outputs are judged too and a refusal names its target.
84
+ */
85
+ function targetOutputs(project, target, options, configuration, node, root) {
86
+ try {
87
+ return options.outputs
88
+ ? options.outputs
89
+ .map((output) => ({
90
+ output: interpolate(output, {
91
+ workspaceRoot: root,
92
+ projectRoot: node.data.root,
93
+ projectName: node.name,
94
+ project: { ...node.data, name: node.name },
95
+ options: { ...options.options, ...(configuration ? options.configurations?.[configuration] : {}) },
96
+ }),
97
+ kind: declaredKind(output),
98
+ }))
99
+ .filter(({ output }) => output && !/{(projectRoot|workspaceRoot|(options.*))}/.test(output))
100
+ : // A target declaring no outputs takes Nx's fallback: its options' outputPath, or for build and prepare the
101
+ // legacy dist, build and public directories. Each names a directory, and no declaration states otherwise.
102
+ getOutputsForTargetAndConfiguration({ project, target, configuration }, {}, node).map((output) => ({
103
+ output,
104
+ kind: 'directory',
105
+ }));
106
+ }
107
+ catch (error) {
108
+ // Nx tests a template against a module-level global regex before it throws, leaving that regex's lastIndex past
109
+ // the first placeholder; the next interpolation in this process would then skip its placeholders and drop its
110
+ // output. One interpolation rewinds it: a test that fails resets lastIndex.
111
+ interpolate('', {});
112
+ throw new OutputDeclarationError(project, target, configuration, error);
113
+ }
114
+ }
115
+ function declaredKind(declaration) {
116
+ return declaration.endsWith('/') ? 'directory' : 'file';
117
+ }
118
+ /**
119
+ * The configurations a target's tasks run under: each named one, and the run naming none. Nx resolves that run to the
120
+ * target's `defaultConfiguration` when it has one, so the target's own options are a task only without one.
121
+ */
122
+ export function taskConfigurations({ defaultConfiguration, configurations, }) {
123
+ const named = Object.keys(configurations ?? {});
124
+ return defaultConfiguration ? [...new Set([defaultConfiguration, ...named])] : [undefined, ...named];
125
+ }
126
+ /**
127
+ * Every output of every task in the resolved graph (project overrides included), as Nx interpolates it: one task per
128
+ * configuration a target runs under. A target declaring no outputs yields Nx's fallback outputs. Pass the absolute
129
+ * workspace root. This is the one reading of what a task writes: every output policy takes its declarations from here.
130
+ */
131
+ export function declaredOutputs(graph, root) {
132
+ const declared = [];
133
+ for (const [project, node] of Object.entries(graph.nodes)) {
134
+ for (const [target, options] of Object.entries(node.data.targets ?? {})) {
135
+ for (const configuration of taskConfigurations(options)) {
136
+ for (const output of targetOutputs(project, target, options, configuration, node, root)) {
137
+ declared.push({ project, target, configuration, ...output });
138
+ }
139
+ }
140
+ }
141
+ }
142
+ return declared;
143
+ }
22
144
  /**
23
145
  * Enforce spec 16 at the consuming repository's Nx lint boundary, using its already resolved
24
146
  * graph (including project overrides). Never construct a graph during cowshed job admission.
@@ -26,39 +148,255 @@ function staticPrefix(output) {
26
148
  * prefixes are unsafe too: they can replace the fixed links even without naming a tool's files.
27
149
  */
28
150
  export function refuseOutputsUnderBuildState(graph, buildStatePaths, workspaceRoot) {
29
- const root = workspaceRoot.replaceAll('\\', '/');
30
- if (!posix.isAbsolute(root))
31
- throw new Error('build-state output validation requires an absolute workspace root');
151
+ const root = absoluteRoot(workspaceRoot);
32
152
  const paths = buildStatePaths.map(({ checkout }) => ({ checkout, absolute: posix.resolve(root, checkout) }));
33
153
  const findings = [];
34
- for (const [project, node] of Object.entries(graph.nodes)) {
35
- for (const [target, options] of Object.entries(node.data.targets ?? {})) {
36
- const configurations = [undefined, ...Object.keys(options.configurations ?? {})];
37
- for (const configuration of configurations) {
38
- // Nx's task helper rejects root globs and absolute declarations before expanding
39
- // them. This lint must name the overlapping build path even for those declarations.
40
- const outputs = options.outputs
41
- ? options.outputs
42
- .map((output) => interpolate(output, {
43
- workspaceRoot: root,
44
- projectRoot: node.data.root,
45
- projectName: node.name,
46
- project: { ...node.data, name: node.name },
47
- options: { ...options.options, ...(configuration ? options.configurations?.[configuration] : {}) },
48
- }))
49
- .filter((output) => output && !/{(projectRoot|workspaceRoot|(options.*))}/.test(output))
50
- : getOutputsForTargetAndConfiguration({ project, target, configuration }, {}, node);
51
- for (const output of outputs) {
52
- const prefix = posix.resolve(root, staticPrefix(output));
53
- for (const path of paths) {
54
- if (contains(prefix, path.absolute) || contains(path.absolute, prefix)) {
55
- findings.push({ project, target, configuration, output, buildStatePath: path.checkout });
56
- }
57
- }
58
- }
154
+ for (const declared of declaredOutputs(graph, root)) {
155
+ const prefix = posix.resolve(root, staticPrefix(declared.output));
156
+ for (const path of paths) {
157
+ if (contains(prefix, path.absolute) || contains(path.absolute, prefix)) {
158
+ findings.push({ ...declared, buildStatePath: path.checkout });
59
159
  }
60
160
  }
61
161
  }
62
162
  if (findings.length)
63
163
  throw new BuildStateOutputError(findings);
64
164
  }
165
+ /**
166
+ * Each task's declared outputs once per distinct path and declared kind; a negation claims nothing. A task is a target
167
+ * under one configuration, and the configuration is part of the identity: two configurations declaring one path are
168
+ * two claims, and each is judged. So is the kind: a path a task declares as both a file and a directory is two claims.
169
+ */
170
+ function outputClaims(declared, root) {
171
+ const seen = new Set();
172
+ const claims = [];
173
+ for (const output of declared) {
174
+ if (output.output.startsWith('!'))
175
+ continue;
176
+ const absolute = posix.resolve(root, output.output);
177
+ const key = JSON.stringify([output.project, output.target, output.configuration, absolute, output.kind]);
178
+ if (seen.has(key))
179
+ continue;
180
+ seen.add(key);
181
+ const relative = posix.relative(root, absolute);
182
+ claims.push(GLOB_PART.test(relative)
183
+ ? {
184
+ form: 'glob',
185
+ declared: output,
186
+ prefix: posix.resolve(root, staticPrefix(relative)),
187
+ // Nx's own matcher, as Nx pins it. Dotfiles match: a restore writes them like any other file.
188
+ matcher: new Minimatch(relative, { dot: true }),
189
+ }
190
+ : { form: 'path', declared: output, absolute, relative });
191
+ }
192
+ return claims;
193
+ }
194
+ /**
195
+ * A pattern conflicts with a path at or above its static prefix, a path it matches, or a directory it can reach inside.
196
+ * Reaching is minimatch's partial match: it expands braces before it splits segments, so an alternative that crosses a
197
+ * slash is walked whole, and a directory whose every segment matches the pattern's leading segments is one the pattern
198
+ * can write under. A file the pattern does not match below its prefix is not written by it, whatever the pattern writes
199
+ * beside it; a file at or above the prefix collides by kind, since the pattern needs a directory there to write into.
200
+ */
201
+ function patternMeetsPath(pattern, path) {
202
+ return (contains(path.absolute, pattern.prefix) ||
203
+ pattern.matcher.match(path.relative) ||
204
+ (path.declared.kind === 'directory' && pattern.matcher.match(path.relative, true)));
205
+ }
206
+ /**
207
+ * Two paths conflict at, under or above each other. Two patterns conflict only as one pattern named twice, which
208
+ * matches the same files: Nx restores a pattern file by file, so two different patterns collide only on a file both
209
+ * match, and that cannot be named without the tree.
210
+ */
211
+ function conflicts(left, right) {
212
+ if (left.form === 'path') {
213
+ return right.form === 'path'
214
+ ? contains(left.absolute, right.absolute) || contains(right.absolute, left.absolute)
215
+ : patternMeetsPath(right, left);
216
+ }
217
+ return right.form === 'path' ? patternMeetsPath(left, right) : left.matcher.pattern === right.matcher.pattern;
218
+ }
219
+ /**
220
+ * One producing task per output path: refuse any task whose output is at, under or above another task's output. A task
221
+ * is a target under one configuration (`project:target[:configuration]`, as Nx names it): two targets conflict, and so
222
+ * do two configurations of one target. `outputs` belongs to the target, so only an options placeholder
223
+ * (`{options.out}`) that the configurations set apart gives each its own. A task's own outputs never conflict with
224
+ * each other. Nx restores a directory output as one tree, so a second task writing inside it makes the first task's
225
+ * tree differ from its cache artifact after every build: each run restores one producer over the other, and neither is
226
+ * ever a cache hit.
227
+ */
228
+ export function refuseOverlappingOutputs(graph, workspaceRoot) {
229
+ const root = absoluteRoot(workspaceRoot);
230
+ const claims = outputClaims(declaredOutputs(graph, root), root);
231
+ const overlaps = [];
232
+ for (const [index, left] of claims.entries()) {
233
+ for (const right of claims.slice(index + 1)) {
234
+ const sameTask = left.declared.project === right.declared.project &&
235
+ left.declared.target === right.declared.target &&
236
+ left.declared.configuration === right.declared.configuration;
237
+ if (!sameTask && conflicts(left, right))
238
+ overlaps.push({ left: left.declared, right: right.declared });
239
+ }
240
+ }
241
+ if (overlaps.length)
242
+ throw new OutputOverlapError(overlaps);
243
+ }
244
+ /** The kind of `path` on disk, following links as a restore's reader does; a path under a file is absent. */
245
+ export function outputOnDisk(path) {
246
+ try {
247
+ const stats = statSync(path, { throwIfNoEntry: false });
248
+ return stats === undefined ? 'absent' : stats.isDirectory() ? 'directory' : 'file';
249
+ }
250
+ catch (error) {
251
+ if (error instanceof Error && 'code' in error && error.code === 'ENOTDIR')
252
+ return 'absent';
253
+ throw error;
254
+ }
255
+ }
256
+ /**
257
+ * Hold every literal output's declared kind to the built tree under `workspaceRoot`: a directory output must be a
258
+ * directory and a file output a file. Run where the outputs exist after a build; an output absent on disk is not judged,
259
+ * and a pattern names its files by matching, so it states no kind to hold. The overlap policy reads the declared kind
260
+ * alone; this keeps that declaration honest.
261
+ */
262
+ export function refuseMisdeclaredOutputKinds(graph, workspaceRoot) {
263
+ const root = absoluteRoot(workspaceRoot);
264
+ const findings = [];
265
+ for (const claim of outputClaims(declaredOutputs(graph, root), root)) {
266
+ if (claim.form !== 'path')
267
+ continue;
268
+ const onDisk = outputOnDisk(claim.absolute);
269
+ if (onDisk !== 'absent' && onDisk !== claim.declared.kind)
270
+ findings.push({ ...claim.declared, onDisk });
271
+ }
272
+ if (findings.length)
273
+ throw new OutputKindError(findings);
274
+ }
275
+ /** A path that is gone, or that runs through a file: what an output not written yet reads as. */
276
+ function isAbsent(error) {
277
+ return error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR');
278
+ }
279
+ /** The failure a read under `existingOutputFiles` raises: the operation and the workspace-relative path it read. */
280
+ function readError(operation, relative, cause) {
281
+ return new Error(`existingOutputFiles: ${operation} ${JSON.stringify(relative)} failed: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
282
+ }
283
+ /** What the workspace-relative path itself is under `root`, without following a link at it. */
284
+ function entryKind(root, relative) {
285
+ try {
286
+ const stats = lstatSync(posix.join(root, relative), { throwIfNoEntry: false });
287
+ return stats === undefined ? 'absent' : stats.isDirectory() ? 'directory' : stats.isFile() ? 'file' : 'other';
288
+ }
289
+ catch (error) {
290
+ if (isAbsent(error))
291
+ return 'absent';
292
+ throw readError('lstat', relative, error);
293
+ }
294
+ }
295
+ /** The entries of the directory at the workspace-relative path, each read as written; none once it is gone. */
296
+ function directoryEntries(root, relative) {
297
+ try {
298
+ return readdirSync(posix.join(root, relative), { withFileTypes: true });
299
+ }
300
+ catch (error) {
301
+ if (isAbsent(error))
302
+ return [];
303
+ throw readError('readdir', relative, error);
304
+ }
305
+ }
306
+ /**
307
+ * An output as stock Nx's expansion reads it: relative to `root`, a negation keeping its `!`. `undefined` when the
308
+ * output names `root` itself or a path outside it.
309
+ */
310
+ function outputEntry(output, root) {
311
+ const negated = output.startsWith('!');
312
+ const relative = posix.relative(root, posix.resolve(root, negated ? output.slice(1) : output));
313
+ if (relative === '' || relative === '..' || relative.startsWith('../'))
314
+ return undefined;
315
+ return negated ? `!${relative}` : relative;
316
+ }
317
+ /**
318
+ * Whether some ancestor of `relative` below `root` is not a directory as written, a symbolic link above all: a path
319
+ * reached only through one is never listed under that spelling.
320
+ */
321
+ function throughNonDirectory(root, relative) {
322
+ const parts = relative.split('/');
323
+ let ancestor = '';
324
+ for (const [index, part] of parts.entries()) {
325
+ if (index === parts.length - 1)
326
+ break;
327
+ ancestor = ancestor === '' ? part : `${ancestor}/${part}`;
328
+ if (entryKind(root, ancestor) !== 'directory')
329
+ return true;
330
+ }
331
+ return false;
332
+ }
333
+ /** Add every regular file beneath the directory `relative` to `files`, never descending a symbolic link. */
334
+ function collectDirectory(root, relative, files) {
335
+ for (const entry of directoryEntries(root, relative)) {
336
+ const child = `${relative}/${entry.name}`;
337
+ if (entry.isFile())
338
+ files.add(child);
339
+ else if (entry.isDirectory())
340
+ collectDirectory(root, child, files);
341
+ }
342
+ }
343
+ /**
344
+ * Add what one path stock Nx's expansion returned contributes to `files`: a regular file itself, every regular file
345
+ * beneath a directory, and nothing for a symbolic link, any other kind, an absent path, or a path reached through a
346
+ * link above it.
347
+ */
348
+ function collectExpanded(root, relative, files) {
349
+ if (throughNonDirectory(root, relative))
350
+ return;
351
+ const kind = entryKind(root, relative);
352
+ if (kind === 'file')
353
+ files.add(relative);
354
+ else if (kind === 'directory')
355
+ collectDirectory(root, relative, files);
356
+ }
357
+ /**
358
+ * Every regular file the resolved graph's outputs name under `workspaceRoot`, workspace-relative, sorted and once each.
359
+ * Every task counts, whether or not a run selected it: each target under each configuration it runs under, Nx's
360
+ * fallback outputs of a target declaring none included (`declaredOutputs`).
361
+ *
362
+ * Each task's outputs are expanded on their own with stock Nx's `expandOutputs` (`expand`, from the caller's workspace Nx), the native expansion Nx's cache uses,
363
+ * so a task's negation drops only its own matches, never a path another task claims. An expanded regular file is
364
+ * listed; an expanded directory contributes every regular file beneath it, read without descending a symbolic link at,
365
+ * above or below it; a symbolic link or other entry is skipped, and an absent path contributes nothing. Any other
366
+ * read failure throws, naming the operation and the workspace-relative path, so an unreadable directory beneath a
367
+ * literal directory output is refused rather than passed over. Stock expansion silently drops entries it cannot read
368
+ * while matching a glob; that is Nx's behaviour, and it is accepted here. An undeclared generated build input is
369
+ * outside this contract: only a file some task's declared output names is listed. An output naming the workspace root
370
+ * or a path outside it throws an `OutputEscapeError` naming every such task, before any disk access.
371
+ */
372
+ export function existingOutputFiles(graph, workspaceRoot, expand) {
373
+ const root = absoluteRoot(workspaceRoot);
374
+ const tasks = new Map();
375
+ const escapes = [];
376
+ for (const declared of declaredOutputs(graph, root)) {
377
+ const entry = outputEntry(declared.output, root);
378
+ if (entry === undefined) {
379
+ escapes.push(declared);
380
+ continue;
381
+ }
382
+ const task = JSON.stringify([declared.project, declared.target, declared.configuration]);
383
+ const entries = tasks.get(task);
384
+ if (entries)
385
+ entries.push(entry);
386
+ else
387
+ tasks.set(task, [entry]);
388
+ }
389
+ if (escapes.length)
390
+ throw new OutputEscapeError(escapes);
391
+ const files = new Set();
392
+ const collected = new Set();
393
+ for (const entries of tasks.values()) {
394
+ for (const expanded of expand(root, entries)) {
395
+ if (collected.has(expanded))
396
+ continue;
397
+ collected.add(expanded);
398
+ collectExpanded(root, expanded, files);
399
+ }
400
+ }
401
+ return [...files].sort();
402
+ }
@@ -0,0 +1,44 @@
1
+ import { type CreateDependenciesContext, type ProjectGraphExternalNode, type RawProjectGraphDependency } from 'nx/src/devkit-exports.js';
2
+ /**
3
+ * Every bun lock-scope node's name starts with this; the rest is the root of
4
+ * the project whose manifest it stands for, `.` for the workspace root.
5
+ *
6
+ * A lock-scope node is the part of bun.lock one manifest reaches: what the
7
+ * package can load. Its edges go to the npm nodes the manifest's dependencies
8
+ * resolve to; a member's also go to the node of each workspace member it
9
+ * depends on and to the root's, since a member's `node_modules` lookup ends in
10
+ * the root's. The root's node has no member edges: every member reaches it, so
11
+ * one would key every member on the packages of whichever members the root
12
+ * manifest lists, which a member loads only through its own declaration (or an
13
+ * import Nx turns into a project edge, which a `^` input follows). Nx's
14
+ * lockfile parser links each npm node to the packages it depends on, so a
15
+ * target naming a node in its `externalDependencies` is keyed on every package
16
+ * of that closure by the hash bun.lock records for it, and on nothing else in
17
+ * the lockfile. That replaces bun.lock as a file input: a lockfile edit re-keys
18
+ * the tasks that can load what changed.
19
+ *
20
+ * The nodes carry no content of their own; Nx hashes a node's version and the
21
+ * nodes it reaches.
22
+ */
23
+ export declare const BUN_LOCK_NODE_PREFIX = "bun-lock:";
24
+ /** The lock-scope node of the project at `projectRoot`. */
25
+ export declare function bunLockNodeName(projectRoot: string): string;
26
+ /** The node of the workspace root manifest, which every member's node reaches. */
27
+ export declare const BUN_ROOT_LOCK_NODE: string;
28
+ /** The input that keys a target on the bun.lock entries its project's manifest reaches. */
29
+ export declare function bunLockInput(projectRoot: string): {
30
+ externalDependencies: string[];
31
+ };
32
+ /** The node itself, published by its project; {@link bunLockDependencies} gives it its edges. */
33
+ export declare function bunLockNode(projectRoot: string): ProjectGraphExternalNode;
34
+ /**
35
+ * The edges of every published bun lock-scope node. A manifest's dependencies
36
+ * are resolved exactly as Nx resolves a project's own package edges
37
+ * (`buildExplicitPackageJsonDependencies`, one `TargetProjectLocator` over
38
+ * the same projects and lockfile nodes): an installed package becomes an edge
39
+ * to its npm node, a workspace member (outside the root manifest) an edge to
40
+ * that member's node, and a package that resolves to no node is skipped
41
+ * exactly as Nx skips it.
42
+ */
43
+ export declare function bunLockDependencies(context: CreateDependenciesContext): RawProjectGraphDependency[];
44
+ //# sourceMappingURL=bun-lock-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-lock-scope.d.ts","sourceRoot":"","sources":["../src/bun-lock-scope.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,yBAAyB,EAE9B,KAAK,wBAAwB,EAE7B,KAAK,yBAAyB,EAE/B,MAAM,0BAA0B,CAAC;AAGlC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,QAAuB,CAAC;AAEvD,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG;IAAE,oBAAoB,EAAE,MAAM,EAAE,CAAA;CAAE,CAEpF;AAED,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,wBAAwB,CAGzE;AAKD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,yBAAyB,GAAG,yBAAyB,EAAE,CAwCnG"}
@@ -0,0 +1,97 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join, posix } from 'node:path';
3
+ import { DependencyType, readJsonFile, } from 'nx/src/devkit-exports.js';
4
+ import { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.js';
5
+ /**
6
+ * Every bun lock-scope node's name starts with this; the rest is the root of
7
+ * the project whose manifest it stands for, `.` for the workspace root.
8
+ *
9
+ * A lock-scope node is the part of bun.lock one manifest reaches: what the
10
+ * package can load. Its edges go to the npm nodes the manifest's dependencies
11
+ * resolve to; a member's also go to the node of each workspace member it
12
+ * depends on and to the root's, since a member's `node_modules` lookup ends in
13
+ * the root's. The root's node has no member edges: every member reaches it, so
14
+ * one would key every member on the packages of whichever members the root
15
+ * manifest lists, which a member loads only through its own declaration (or an
16
+ * import Nx turns into a project edge, which a `^` input follows). Nx's
17
+ * lockfile parser links each npm node to the packages it depends on, so a
18
+ * target naming a node in its `externalDependencies` is keyed on every package
19
+ * of that closure by the hash bun.lock records for it, and on nothing else in
20
+ * the lockfile. That replaces bun.lock as a file input: a lockfile edit re-keys
21
+ * the tasks that can load what changed.
22
+ *
23
+ * The nodes carry no content of their own; Nx hashes a node's version and the
24
+ * nodes it reaches.
25
+ */
26
+ export const BUN_LOCK_NODE_PREFIX = 'bun-lock:';
27
+ /** The lock-scope node of the project at `projectRoot`. */
28
+ export function bunLockNodeName(projectRoot) {
29
+ return `${BUN_LOCK_NODE_PREFIX}${posix.normalize(projectRoot === '' ? '.' : projectRoot)}`;
30
+ }
31
+ /** The node of the workspace root manifest, which every member's node reaches. */
32
+ export const BUN_ROOT_LOCK_NODE = bunLockNodeName('.');
33
+ /** The input that keys a target on the bun.lock entries its project's manifest reaches. */
34
+ export function bunLockInput(projectRoot) {
35
+ return { externalDependencies: [bunLockNodeName(projectRoot)] };
36
+ }
37
+ /** The node itself, published by its project; {@link bunLockDependencies} gives it its edges. */
38
+ export function bunLockNode(projectRoot) {
39
+ const name = bunLockNodeName(projectRoot);
40
+ return { type: 'bun', name, data: { packageName: name, version: '0.0.0' } };
41
+ }
42
+ /** The manifest sections Nx reads a project's package dependencies from, in the order it lets them override. */
43
+ const DEPENDENCY_SECTIONS = ['optionalDependencies', 'peerDependencies', 'devDependencies', 'dependencies'];
44
+ /**
45
+ * The edges of every published bun lock-scope node. A manifest's dependencies
46
+ * are resolved exactly as Nx resolves a project's own package edges
47
+ * (`buildExplicitPackageJsonDependencies`, one `TargetProjectLocator` over
48
+ * the same projects and lockfile nodes): an installed package becomes an edge
49
+ * to its npm node, a workspace member (outside the root manifest) an edge to
50
+ * that member's node, and a package that resolves to no node is skipped
51
+ * exactly as Nx skips it.
52
+ */
53
+ export function bunLockDependencies(context) {
54
+ const externalNodes = context.externalNodes ?? {};
55
+ const nodes = {};
56
+ for (const [name, data] of Object.entries(context.projects)) {
57
+ nodes[name] = { name, type: data.projectType === 'application' ? 'app' : 'lib', data };
58
+ }
59
+ const locator = new TargetProjectLocator(nodes, externalNodes);
60
+ const nodeOfMember = (member) => {
61
+ const root = context.projects[member]?.root;
62
+ return root === undefined ? null : bunLockNodeName(root);
63
+ };
64
+ const dependencies = [];
65
+ for (const project of Object.values(context.projects).sort((left, right) => left.root < right.root ? -1 : left.root > right.root ? 1 : 0)) {
66
+ const source = bunLockNodeName(project.root);
67
+ if (externalNodes[source] === undefined)
68
+ continue;
69
+ const manifestPath = posix.join(project.root, 'package.json');
70
+ if (!existsSync(join(context.workspaceRoot, manifestPath)))
71
+ continue;
72
+ const manifest = readJsonFile(join(context.workspaceRoot, manifestPath));
73
+ const specifiers = new Map();
74
+ for (const section of DEPENDENCY_SECTIONS) {
75
+ const declared = manifest[section];
76
+ if (typeof declared !== 'object' || declared === null)
77
+ continue;
78
+ for (const [name, specifier] of Object.entries(declared)) {
79
+ if (typeof specifier === 'string')
80
+ specifiers.set(name, specifier);
81
+ }
82
+ }
83
+ const targets = new Set(source === BUN_ROOT_LOCK_NODE ? [] : [BUN_ROOT_LOCK_NODE]);
84
+ for (const [name, specifier] of specifiers) {
85
+ const member = locator.findDependencyInWorkspaceProjects(manifestPath, name, specifier);
86
+ if (member !== null && source === BUN_ROOT_LOCK_NODE)
87
+ continue;
88
+ const target = member === null ? locator.findNpmProjectFromImport(name, manifestPath) : nodeOfMember(member);
89
+ if (target !== null && target !== source && externalNodes[target] !== undefined)
90
+ targets.add(target);
91
+ }
92
+ for (const target of [...targets].sort()) {
93
+ dependencies.push({ source, target, type: DependencyType.static });
94
+ }
95
+ }
96
+ return dependencies;
97
+ }
@@ -0,0 +1,49 @@
1
+ import { type Result } from '@smoothbricks/cargo-retain';
2
+ /** One variable whose recorded value differs from the value Cargo would see now, and the runs that recorded it. */
3
+ export interface EnvironmentDrift {
4
+ readonly variable: string;
5
+ /** What the runs recorded; `null` is unset. */
6
+ readonly recorded: string | null;
7
+ /** What Cargo would see now; `null` is unset. */
8
+ readonly current: string | null;
9
+ /** The packages whose build scripts recorded it, sorted, each once. */
10
+ readonly packages: readonly string[];
11
+ /** How many build-script runs recorded it: a package's script runs once per profile, target and feature set. */
12
+ readonly runs: number;
13
+ }
14
+ /** The value Cargo would give a variable now; `null` is unset. */
15
+ export type CargoSees = (variable: string) => string | null;
16
+ /**
17
+ * The drift between the build-script runs recorded under `profile` (a target directory's `debug`, say) and what
18
+ * `sees` gives each recorded variable, one entry per variable and recorded value, sorted by variable. Variables Cargo
19
+ * sets for the processes it runs are not compared. A missing profile directory has nothing to compare.
20
+ */
21
+ export declare function buildScriptEnvironmentDrift(profile: string, sees: CargoSees): Result<EnvironmentDrift[], string>;
22
+ /** One Cargo configuration file: its text, and the directory its `relative` paths resolve against. */
23
+ export interface CargoConfigFile {
24
+ readonly path: string;
25
+ /** The parent of the `.cargo` directory holding the file (for `$CARGO_HOME/config.toml`, `$CARGO_HOME`'s parent). */
26
+ readonly root: string;
27
+ readonly text: string;
28
+ }
29
+ /**
30
+ * The configuration files a Cargo invoked in `directory` reads, deepest first: each ancestor's `.cargo/config.toml`
31
+ * (or `.cargo/config`, which Cargo prefers when both exist) up to `/`, then `$CARGO_HOME/config.toml` unless the walk
32
+ * already read it.
33
+ */
34
+ export declare function cargoConfigFiles(directory: string, cargoHome: string): Result<CargoConfigFile[], string>;
35
+ /**
36
+ * What Cargo sees for a variable under `files` (deepest first, as `cargoConfigFiles` lists them) with `environment`
37
+ * its own: the deepest `[env]` entry for it decides; a forced entry wins, else the environment's value, else the
38
+ * entry's; a `relative` entry's value is a path under its file's root.
39
+ */
40
+ export declare function cargoSees(files: readonly CargoConfigFile[], environment: Readonly<Record<string, string | undefined>>): Result<CargoSees, string>;
41
+ /** One line for a drift: the variable, both values, and the runs Cargo reruns for it. */
42
+ export declare function describeDrift(drift: EnvironmentDrift): string;
43
+ /**
44
+ * `<checkout>`: print each drift between `<checkout>/target/debug`'s build-script runs and what a Cargo invoked in
45
+ * `<checkout>` with this process's environment would see, one line each. Exits 0 when it could compare, drift or not;
46
+ * 1 when a record or a configuration file cannot be read; 64 on a usage error.
47
+ */
48
+ export declare function runBuildScriptEnvironmentDrift(args: readonly string[]): number;
49
+ //# sourceMappingURL=cargo-build-script-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cargo-build-script-env.d.ts","sourceRoot":"","sources":["../src/cargo-build-script-env.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,MAAM,EAAwB,MAAM,4BAA4B,CAAC;AAI/E,mHAAmH;AACnH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,gHAAgH;IAChH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,kEAAkE;AAClE,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;AAsE5D;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,gBAAgB,EAAE,EAAE,MAAM,CAAC,CA4ChH;AAED,sGAAsG;AACtG,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qHAAqH;IACrH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,MAAM,CAAC,CA2BxG;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACxD,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CA+B3B;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAK7D;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAgB9E"}