@smoothbricks/nx-plugin 0.4.25 → 0.4.27

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 (348) hide show
  1. package/README.md +1078 -98
  2. package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
  3. package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-bound-failures.js +31 -0
  5. package/dist/bin/smoo-nx-cargo-hash.js +28 -3
  6. package/dist/bin/smoo-nx-exec.js +16 -85
  7. package/dist/bin/smoo-nx-failures.d.ts +3 -0
  8. package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
  9. package/dist/bin/smoo-nx-failures.js +3 -0
  10. package/dist/bin/smoo-nx-nextest-extract.js +3 -2
  11. package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
  12. package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
  13. package/dist/bin/smoo-nx-test-walks.js +34 -0
  14. package/dist/bounded-test-policy.d.ts +7 -1
  15. package/dist/bounded-test-policy.d.ts.map +1 -1
  16. package/dist/bounded-test-policy.js +101 -40
  17. package/dist/build-state-output-policy.d.ts +25 -0
  18. package/dist/build-state-output-policy.d.ts.map +1 -0
  19. package/dist/build-state-output-policy.js +64 -0
  20. package/dist/cargo-closure-input.d.ts +16 -17
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +37 -44
  23. package/dist/cargo-dev-profile.d.ts +37 -0
  24. package/dist/cargo-dev-profile.d.ts.map +1 -0
  25. package/dist/cargo-dev-profile.js +108 -0
  26. package/dist/cargo-source-hash.d.ts +50 -8
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +691 -71
  29. package/dist/cargo-toolchain-policy.d.ts +4 -0
  30. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  31. package/dist/cargo-toolchain-policy.js +5 -0
  32. package/dist/cargo-workspace.d.ts +108 -12
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +299 -18
  35. package/dist/cross-check-policy.d.ts +21 -3
  36. package/dist/cross-check-policy.d.ts.map +1 -1
  37. package/dist/cross-check-policy.js +24 -6
  38. package/dist/disk-command-policy.d.ts +7 -0
  39. package/dist/disk-command-policy.d.ts.map +1 -0
  40. package/dist/disk-command-policy.js +98 -0
  41. package/dist/ensure-built-receipt.d.ts +25 -0
  42. package/dist/ensure-built-receipt.d.ts.map +1 -0
  43. package/dist/ensure-built-receipt.js +261 -0
  44. package/dist/ensure-built-witness.d.ts +57 -0
  45. package/dist/ensure-built-witness.d.ts.map +1 -0
  46. package/dist/ensure-built-witness.js +412 -0
  47. package/dist/ensure-built.d.ts +213 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +624 -177
  50. package/dist/eslint-file-set.d.ts +7 -0
  51. package/dist/eslint-file-set.d.ts.map +1 -0
  52. package/dist/eslint-file-set.js +12 -0
  53. package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
  54. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
  55. package/dist/executors/bounded-exec/cpu-pool.js +379 -0
  56. package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
  57. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
  58. package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
  59. package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
  60. package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/disk-lease.js +91 -0
  62. package/dist/executors/bounded-exec/executor.d.ts +45 -2
  63. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  64. package/dist/executors/bounded-exec/executor.js +447 -52
  65. package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
  66. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
  67. package/dist/executors/bounded-exec/gateway-lease.js +143 -0
  68. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
  69. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
  70. package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
  71. package/dist/executors/bounded-exec/progress.d.ts +35 -0
  72. package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/progress.js +79 -0
  74. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
  75. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
  76. package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
  77. package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
  78. package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
  79. package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
  80. package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
  81. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
  82. package/dist/executors/bounded-exec/ram-temp.js +1528 -0
  83. package/dist/executors/bounded-exec/schema.d.ts +29 -11
  84. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  85. package/dist/executors/bounded-exec/verdict.d.ts +162 -0
  86. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/verdict.js +318 -0
  88. package/dist/executors/shard-timings/executor.d.ts +14 -0
  89. package/dist/executors/shard-timings/executor.d.ts.map +1 -0
  90. package/dist/executors/shard-timings/executor.js +25 -0
  91. package/dist/executors/shard-timings/schema.d.ts +4 -0
  92. package/dist/executors/shard-timings/schema.d.ts.map +1 -0
  93. package/dist/executors/shard-timings/schema.js +1 -0
  94. package/dist/failure-summary.d.ts +5 -0
  95. package/dist/failure-summary.d.ts.map +1 -0
  96. package/dist/failure-summary.js +118 -0
  97. package/dist/generators/create-package/generator.d.ts.map +1 -1
  98. package/dist/generators/create-package/generator.js +6 -2
  99. package/dist/index.d.ts +14 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +435 -230
  102. package/dist/managed-assets.d.ts +6 -0
  103. package/dist/managed-assets.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.d.ts +13 -0
  105. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  106. package/dist/managed-files/ci-workflow.js +44 -13
  107. package/dist/managed-files/files.d.ts +7 -1
  108. package/dist/managed-files/files.d.ts.map +1 -1
  109. package/dist/managed-files/files.js +62 -8
  110. package/dist/managed-files/json-edit.d.ts +21 -0
  111. package/dist/managed-files/json-edit.d.ts.map +1 -0
  112. package/dist/managed-files/json-edit.js +295 -0
  113. package/dist/managed-files/managed-format.d.ts +33 -1
  114. package/dist/managed-files/managed-format.d.ts.map +1 -1
  115. package/dist/managed-files/managed-format.js +82 -2
  116. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  117. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  119. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  120. package/dist/managed-files/publish-workflow.js +231 -48
  121. package/dist/managed-files/tree.d.ts +5 -0
  122. package/dist/managed-files/tree.d.ts.map +1 -1
  123. package/dist/managed-files/tree.js +5 -3
  124. package/dist/manifest-hash.js +3 -2
  125. package/dist/nextest-code-bound.d.ts +62 -0
  126. package/dist/nextest-code-bound.d.ts.map +1 -0
  127. package/dist/nextest-code-bound.js +154 -0
  128. package/dist/nextest-extraction.d.ts +24 -8
  129. package/dist/nextest-extraction.d.ts.map +1 -1
  130. package/dist/nextest-extraction.js +42 -7
  131. package/dist/package-target-policy.d.ts.map +1 -1
  132. package/dist/package-target-policy.js +3 -5
  133. package/dist/release-config-policy.d.ts.map +1 -1
  134. package/dist/release-config-policy.js +3 -5
  135. package/dist/runtime-input.d.ts +14 -0
  136. package/dist/runtime-input.d.ts.map +1 -0
  137. package/dist/runtime-input.js +15 -0
  138. package/dist/rust-tokens.d.ts +11 -0
  139. package/dist/rust-tokens.d.ts.map +1 -0
  140. package/dist/rust-tokens.js +81 -0
  141. package/dist/task-results.d.ts +6 -0
  142. package/dist/task-results.d.ts.map +1 -0
  143. package/dist/task-results.js +61 -0
  144. package/dist/test-program.d.ts +54 -0
  145. package/dist/test-program.d.ts.map +1 -0
  146. package/dist/test-program.js +292 -0
  147. package/dist/test-timings.d.ts +71 -0
  148. package/dist/test-timings.d.ts.map +1 -0
  149. package/dist/test-timings.js +393 -0
  150. package/dist/test-walk-policy.d.ts +103 -0
  151. package/dist/test-walk-policy.d.ts.map +1 -0
  152. package/dist/test-walk-policy.js +657 -0
  153. package/dist/testing.d.ts +177 -0
  154. package/dist/testing.d.ts.map +1 -0
  155. package/dist/testing.js +824 -0
  156. package/dist/type-guards.d.ts +3 -0
  157. package/dist/type-guards.d.ts.map +1 -0
  158. package/dist/type-guards.js +4 -0
  159. package/dist/typecheck-test-policy.d.ts +8 -5
  160. package/dist/typecheck-test-policy.d.ts.map +1 -1
  161. package/dist/typecheck-test-policy.js +113 -100
  162. package/dist/workspace-config-policy.d.ts +8 -0
  163. package/dist/workspace-config-policy.d.ts.map +1 -1
  164. package/dist/workspace-config-policy.js +175 -63
  165. package/dist/workspace-index.d.ts +12 -0
  166. package/dist/workspace-index.d.ts.map +1 -0
  167. package/dist/workspace-index.js +17 -0
  168. package/dist/workspace-manifest.d.ts +37 -1
  169. package/dist/workspace-manifest.d.ts.map +1 -1
  170. package/executors.json +5 -0
  171. package/loader.js +13 -11
  172. package/managed/raw/envrc +33 -62
  173. package/managed/raw/git-format-staged.yml +30 -35
  174. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  175. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  176. package/managed/raw/tooling/direnv/developer-links.ts +607 -17
  177. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -92
  178. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  179. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  180. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  181. package/managed/raw/tooling/direnv/repo-path +14 -2
  182. package/managed/raw/tooling/direnv/setup-environment.ts +1009 -118
  183. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  184. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  185. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  186. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  187. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  188. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  189. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  190. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  191. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  192. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  194. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  196. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  197. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  198. package/managed/templates/github/workflows/managed-files.yml +1 -2
  199. package/nextest.toml +8 -75
  200. package/package.json +75 -13
  201. package/runtime-input.sh +81 -0
  202. package/src/__tests__/counted-cargo-process.ts +286 -0
  203. package/src/__tests__/counted-cargo.ts +730 -0
  204. package/src/__tests__/fixture-cargo-home.ts +36 -0
  205. package/src/__tests__/fixture-nx-env.ts +157 -2
  206. package/src/__tests__/progress-clock.ts +43 -0
  207. package/src/__tests__/runtime-input.ts +23 -0
  208. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  209. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  210. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  211. package/src/bin/smoo-nx-exec.ts +17 -86
  212. package/src/bin/smoo-nx-failures.ts +4 -0
  213. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  214. package/src/bin/smoo-nx-test-walks.ts +42 -0
  215. package/src/bounded-test-policy.test.ts +268 -22
  216. package/src/bounded-test-policy.ts +114 -42
  217. package/src/build-state-output-policy.test.ts +115 -0
  218. package/src/build-state-output-policy.ts +90 -0
  219. package/src/bun-bootstrap.test.ts +57 -3
  220. package/src/bun-file-packages.test.ts +47 -0
  221. package/src/cargo-closure-input.test.ts +432 -62
  222. package/src/cargo-closure-input.ts +51 -57
  223. package/src/cargo-dev-profile.ts +137 -0
  224. package/src/cargo-resolve-cache.test.ts +1044 -0
  225. package/src/cargo-source-hash.test.ts +203 -93
  226. package/src/cargo-source-hash.ts +762 -75
  227. package/src/cargo-toolchain-policy.ts +6 -0
  228. package/src/cargo-workspace.test.ts +320 -0
  229. package/src/cargo-workspace.ts +344 -18
  230. package/src/cross-check-policy.test.ts +59 -1
  231. package/src/cross-check-policy.ts +25 -6
  232. package/src/disk-command-policy.test.ts +61 -0
  233. package/src/disk-command-policy.ts +107 -0
  234. package/src/ensure-built-receipt.test.ts +184 -0
  235. package/src/ensure-built-receipt.ts +263 -0
  236. package/src/ensure-built-witness.test.ts +344 -0
  237. package/src/ensure-built-witness.ts +252 -0
  238. package/src/ensure-built.test.ts +1043 -483
  239. package/src/ensure-built.ts +870 -197
  240. package/src/eslint-file-set.ts +9 -0
  241. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  242. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  243. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  244. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  245. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  246. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  247. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  248. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  249. package/src/executors/bounded-exec/executor.ts +565 -67
  250. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  251. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  252. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  253. package/src/executors/bounded-exec/progress.test.ts +79 -0
  254. package/src/executors/bounded-exec/progress.ts +118 -0
  255. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  256. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  257. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  258. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  259. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  260. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  261. package/src/executors/bounded-exec/schema.json +11 -5
  262. package/src/executors/bounded-exec/schema.ts +27 -11
  263. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  264. package/src/executors/bounded-exec/verdict.ts +433 -0
  265. package/src/executors/shard-timings/executor.ts +36 -0
  266. package/src/executors/shard-timings/schema.json +21 -0
  267. package/src/executors/shard-timings/schema.ts +4 -0
  268. package/src/failure-summary.ts +119 -0
  269. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  270. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  271. package/src/generators/create-package/generator.test.ts +6 -0
  272. package/src/generators/create-package/generator.ts +6 -2
  273. package/src/host-controller-wiring.test.ts +31 -0
  274. package/src/index.test.ts +1070 -360
  275. package/src/index.ts +524 -255
  276. package/src/linked-snapshots.nx.test.ts +172 -0
  277. package/src/managed-assets.ts +12 -0
  278. package/src/managed-files/ci-workflow.ts +54 -13
  279. package/src/managed-files/files.ts +65 -9
  280. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  281. package/src/managed-files/generator.test.ts +60 -1
  282. package/src/managed-files/json-edit.test.ts +216 -0
  283. package/src/managed-files/json-edit.ts +290 -0
  284. package/src/managed-files/managed-format-json.test.ts +308 -0
  285. package/src/managed-files/managed-format.ts +90 -2
  286. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  287. package/src/managed-files/publish-workflow.ts +285 -67
  288. package/src/managed-files/repo-path.test.ts +129 -0
  289. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  290. package/src/managed-files/tree.ts +11 -3
  291. package/src/manifest-hash.ts +3 -2
  292. package/src/nextest-code-bound.test.ts +155 -0
  293. package/src/nextest-code-bound.ts +195 -0
  294. package/src/nextest-extraction.test.ts +37 -5
  295. package/src/nextest-extraction.ts +51 -9
  296. package/src/nextest-partitions.test.ts +495 -0
  297. package/src/nx-cache-bound.test.ts +109 -0
  298. package/src/nx-cache-restore-mtime.test.ts +170 -0
  299. package/src/nx-daemon-claim.test.ts +277 -0
  300. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  301. package/src/nx-daemon-idle-policy.test.ts +51 -0
  302. package/src/nx-daemon-ignore-files.test.ts +210 -0
  303. package/src/nx-daemon-root-normalization.test.ts +105 -0
  304. package/src/nx-daemon-validity.test.ts +925 -0
  305. package/src/nx-dot-input-policy.test.ts +353 -0
  306. package/src/nx-failure-life-cycles.test.ts +207 -0
  307. package/src/nx-files-archive-racy.test.ts +97 -0
  308. package/src/nx-foreign-workspace-env.test.ts +329 -0
  309. package/src/nx-incomplete-run-summary.test.ts +70 -0
  310. package/src/nx-plugin-load-errors.test.ts +120 -0
  311. package/src/nx-project-resolution-cache.test.ts +176 -0
  312. package/src/nx-raw-inputs.test.ts +166 -0
  313. package/src/nx-resident-graph-workers.test.ts +112 -0
  314. package/src/nx-run-information.test.ts +118 -0
  315. package/src/nx-skipped-task-exit.test.ts +180 -0
  316. package/src/nx-state-location.test.ts +63 -0
  317. package/src/nx-store-resolution.test.ts +99 -0
  318. package/src/nx-task-graph-cycles.test.ts +148 -0
  319. package/src/nx-task-output-lease.test.ts +414 -0
  320. package/src/nx-use-local.test.ts +103 -0
  321. package/src/package-target-policy.ts +3 -6
  322. package/src/release-config-policy.ts +3 -6
  323. package/src/runtime-input.test.ts +215 -0
  324. package/src/runtime-input.ts +17 -0
  325. package/src/rust-tokens.ts +78 -0
  326. package/src/serial-group-wiring.test.ts +326 -0
  327. package/src/task-history-namespace.test.ts +181 -0
  328. package/src/task-results.test.ts +226 -0
  329. package/src/task-results.ts +75 -0
  330. package/src/test-program.test.ts +303 -0
  331. package/src/test-program.ts +341 -0
  332. package/src/test-timings.test.ts +240 -0
  333. package/src/test-timings.ts +311 -0
  334. package/src/test-walk-policy.test.ts +585 -0
  335. package/src/test-walk-policy.ts +731 -0
  336. package/src/testing.test.ts +509 -0
  337. package/src/testing.ts +922 -0
  338. package/src/type-guards.ts +4 -0
  339. package/src/typecheck-test-policy.test.ts +496 -11
  340. package/src/typecheck-test-policy.ts +137 -103
  341. package/src/workspace-config-policy.test.ts +212 -13
  342. package/src/workspace-config-policy.ts +101 -73
  343. package/src/workspace-index.ts +18 -0
  344. package/src/workspace-manifest.ts +41 -1
  345. package/test-timings.json +85 -28
  346. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -615
  347. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
  348. package/src/__tests__/in-process-nx-index.ts +0 -9
@@ -50,6 +50,10 @@ export declare const CARGO_TOOLCHAIN_PIN_INPUTS: readonly string[];
50
50
  * token that cannot drift from what the plugin attaches.
51
51
  */
52
52
  export declare const CARGO_TOOLCHAIN_NAMED_INPUT = "cargoToolchain";
53
+ /** The toolchain versions `command` prints, from the directory whose rust-toolchain selects them. */
54
+ export declare function cargoRuntimeInput(projectRoot: string, command: string): {
55
+ runtime: string;
56
+ };
53
57
  /**
54
58
  * Does one resolved input string carry the toolchain identity?
55
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-toolchain-policy.d.ts","sourceRoot":"","sources":["../src/cargo-toolchain-policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAGvD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D"}
1
+ {"version":3,"file":"cargo-toolchain-policy.d.ts","sourceRoot":"","sources":["../src/cargo-toolchain-policy.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAGvD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAE5D,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D"}
@@ -1,3 +1,4 @@
1
+ import { runtimeInput, shellWord } from './runtime-input.js';
1
2
  /**
2
3
  * The toolchain half of a cargo task's identity, shared by the two things that
3
4
  * must agree about it: target inference, which attaches it, and the monorepo
@@ -53,6 +54,10 @@ export const CARGO_TOOLCHAIN_PIN_INPUTS = [
53
54
  * token that cannot drift from what the plugin attaches.
54
55
  */
55
56
  export const CARGO_TOOLCHAIN_NAMED_INPUT = 'cargoToolchain';
57
+ /** The toolchain versions `command` prints, from the directory whose rust-toolchain selects them. */
58
+ export function cargoRuntimeInput(projectRoot, command) {
59
+ return runtimeInput(`sh -c ${shellWord(`cd "$0" && ${command}`)} ${shellWord(projectRoot)}`);
60
+ }
56
61
  /**
57
62
  * Does one resolved input string carry the toolchain identity?
58
63
  *
@@ -1,4 +1,5 @@
1
1
  import { type TomlTable } from 'smol-toml';
2
+ import { type CompiledCargoInput } from './cargo-source-hash.js';
2
3
  export interface CargoWorkspacePackage {
3
4
  name: string;
4
5
  dir: string;
@@ -52,6 +53,7 @@ export interface CargoPackageTestInputsOptions {
52
53
  export interface CargoInputsCache {
53
54
  readonly manifests: Map<string, Promise<TomlTable>>;
54
55
  readonly nestedCrateDirs: Map<string, string[]>;
56
+ readonly compiledInFiles: Map<string, CompiledCargoInput[]>;
55
57
  readonly results: Map<string, Promise<string[]>>;
56
58
  }
57
59
  export declare function createCargoInputsCache(): CargoInputsCache;
@@ -77,8 +79,10 @@ export declare const CARGO_TEST_ARCHIVE_TARGET = "cargo-test-archive";
77
79
  * does NOT create this parent directory and fails the whole build when it is
78
80
  * missing ("error writing to archive ... No such file or directory"), so the
79
81
  * target mkdir's it first.
82
+ * The archive is an Nx-restored output, so it lives on the source volume, never
83
+ * beneath Cargo's symlinked target directory (16_build_volumes.md).
80
84
  */
81
- export declare const CARGO_TEST_ARCHIVE_FILE = "target/nextest/archive.tar.zst";
85
+ export declare const CARGO_TEST_ARCHIVE_FILE = ".cache/nextest/archive.tar.zst";
82
86
  /**
83
87
  * One foreign target triple this cargo workspace also archives its tests for.
84
88
  */
@@ -115,33 +119,41 @@ export interface CargoCrossTestTarget {
115
119
  */
116
120
  export declare function listCargoCrossTestTargets(absoluteProjectRoot: string): CargoCrossTestTarget[];
117
121
  /**
118
- * Tests that nextest.toml singles out are pinned to this suffix instead of
119
- * being sharded. Only a sharded crate has one: an unsharded crate runs its
120
- * whole suite in a single nextest process, which is all the pin restores.
122
+ * Tests that nextest.toml singles out use this suffix before their shard name.
123
+ * The class is hash-partitioned by the same declared count as the ordinary
124
+ * shards, so it never sits in one run that outgrows the target's bound.
121
125
  */
122
126
  export declare const CARGO_TEST_EXCEPTIONS_SUFFIX = "exceptions";
127
+ /** Name prefix of the runner a serial test group gets; see `serialTestGroups`. */
128
+ export declare const CARGO_TEST_GROUP_PREFIX = "cargo-test-group-";
123
129
  /**
124
130
  * A crate on one target keeps the bare name; a split crate suffixes the piece,
125
131
  * so `cargo-test-example-core-shard2` still reads as "example-core's tests".
126
132
  */
127
133
  export declare function cargoTestPackageTargetName(packageName: string, piece?: string): string;
134
+ /**
135
+ * A serial group's runner. It selects by filter across the whole workspace, so
136
+ * it is no crate: `packageNameFromCargoTestTarget` reads it as none.
137
+ */
138
+ export declare function cargoTestGroupTargetName(group: string): string;
128
139
  /**
129
140
  * Inverse of `cargoTestPackageTargetName`, used by the reachability policy to
130
141
  * check that the per-crate targets cover every workspace member. Pieces of one
131
142
  * crate collapse back to that crate, so a split crate counts as covered once.
132
143
  *
133
- * The two workspace-wide `cargo-test-*` targets are not crates: reading them as
134
- * one would invent members named "compile" and "archive" and report every real
135
- * crate's coverage against a set that can never match.
144
+ * The workspace-wide `cargo-test-*` targets are not crates: reading them as one
145
+ * would invent members named "compile" and "archive", and a serial group's runner
146
+ * would invent one named after its group. Each reports every crate's coverage
147
+ * against a set that can never match.
136
148
  */
137
149
  export declare function packageNameFromCargoTestTarget(targetName: string): string | null;
138
150
  /**
139
151
  * The tests nextest.toml singles out with an override, as one filterset.
140
152
  *
141
- * Overrides can encode constraints that must survive sharding: a test group
142
- * limits concurrency within one nextest run, while a raised slow timeout can
143
- * identify expensive tests that should not delay an otherwise bounded shard.
144
- * Keep the configured exceptions in one run so group limits remain effective.
153
+ * An override can give a test a bound of its own: a raised slow timeout
154
+ * identifies an expensive test that should not delay an otherwise bounded
155
+ * shard. Partition those tests separately, so every target keeps its time
156
+ * bound and each class runs beside the ordinary shards.
145
157
  *
146
158
  * Deriving this from the config that declares the classes, rather than
147
159
  * restating their filters, means adding an override there is the whole change —
@@ -150,6 +162,80 @@ export declare function packageNameFromCargoTestTarget(targetName: string): stri
150
162
  * Returns null when nothing is singled out, the "nothing to pin" case.
151
163
  */
152
164
  export declare function exceptionalTestFilter(nextestConfigPath: string): string | null;
165
+ /**
166
+ * The only `platform` a serial group's overrides may declare: nextest's cfg for macOS. The group
167
+ * runs on macOS hosts only, a host decision made by the planner, never a cfg parse here.
168
+ */
169
+ export declare const SERIAL_TEST_GROUP_PLATFORM = "cfg(target_os=\"macos\")";
170
+ /**
171
+ * Which workspace members a serial group's filter can select tests from: exactly the named
172
+ * packages when every clause of the filter is scoped to one, otherwise every member.
173
+ */
174
+ export type SerialTestGroupScope = {
175
+ readonly kind: 'packages';
176
+ readonly packages: readonly string[];
177
+ } | {
178
+ readonly kind: 'workspace';
179
+ };
180
+ /**
181
+ * One nextest test group capped at a single thread, and the tests its overrides
182
+ * assign it.
183
+ */
184
+ export interface SerialTestGroup {
185
+ /** The group's name, as `[test-groups]` declares it. */
186
+ group: string;
187
+ /** Every default-profile override filter that names the group, as one filterset. */
188
+ filter: string;
189
+ /** The members the filter can select from, which are the members whose sources its runner hashes. */
190
+ scope: SerialTestGroupScope;
191
+ }
192
+ /**
193
+ * The repository's test groups capped at one thread (`max-threads = 1`), each
194
+ * with the tests its default-profile overrides assign it.
195
+ *
196
+ * A serial group is declared exactly once, in `.config/nextest.toml`: the name
197
+ * under `[test-groups]` plus the overrides that name it. Its runner's filter is
198
+ * derived from those overrides rather than restated, so the runner and the
199
+ * per-crate exclusions cannot drift from what nextest actually serializes.
200
+ *
201
+ * Each group also carries the `scope` of its filter (`filterScope`): the members its runner hashes.
202
+ * A group whose every clause is scoped to a `package(<name>)` reruns only when those crates or their
203
+ * local dependencies change; any other group is scoped to the whole workspace. Nothing here orders one
204
+ * group against another: they are separate runners, and a repository that needs two never concurrent
205
+ * declares the edge between their targets itself.
206
+ *
207
+ * Every override naming a serial group must declare `SERIAL_TEST_GROUP_PLATFORM`.
208
+ * This plugin has no cfg evaluator, so it honours exactly that platform and
209
+ * refuses any other rather than guessing where the group applies.
210
+ *
211
+ * Returns [] when the file is absent or declares no serial group, so a workspace
212
+ * without one keeps exactly its existing targets.
213
+ */
214
+ export declare function serialTestGroups(nextestConfigPath: string): SerialTestGroup[];
215
+ /**
216
+ * The packages `filter` can select tests from, read off its `package(<name>)` predicates. The scope is
217
+ * never narrower than the selection: whatever this does not read with certainty is the whole workspace.
218
+ *
219
+ * The filter is read as nextest reads it, with nextest's precedence — parentheses, then `not` and `!`,
220
+ * then `and`, `&` and `-`, then `or`, `|` and `+`, each level left to right — and with nextest's blanks,
221
+ * which are spaces and line endings. Each expression is bounded by the packages it can select from:
222
+ *
223
+ * - `package(<name>)` and `package(=<name>)`, for a plain Cargo name, bound it to that package. A glob,
224
+ * `~contains`, `/regex/` or `#glob` name can match any package, so it bounds nothing.
225
+ * - Every other predicate bounds nothing, and nor does `not`: `not package(a)` selects from every other
226
+ * package, and `deps` and `rdeps` reach beyond the package they name.
227
+ * - `a and b` selects only what both select, so it is bounded by the narrower of the two bounds, and
228
+ * `a - b`, which is `a and not b`, by `a`. `a or b` is bounded by both together, so one unbounded
229
+ * clause leaves the union unbounded however the union is spelled.
230
+ *
231
+ * A predicate's argument ends where nextest ends it: a regex at its closing `/`, any other matcher at its
232
+ * first `)`. Only arguments that need none of nextest's escape sequences are read: a backslash, or a comma
233
+ * outside a regex, makes where the predicate ends depend on escapes this does not implement. Those, a
234
+ * filter that does not parse, and one whose packages exclude each other have no bound.
235
+ */
236
+ export declare function filterScope(filter: string): SerialTestGroupScope;
237
+ /** The plugin's nextest.toml as the workspace root's `node_modules` links it. */
238
+ export declare const PLUGIN_NEXTEST_CONFIG_PATH = "node_modules/@smoothbricks/nx-plugin/nextest.toml";
153
239
  /**
154
240
  * The plugin's own nextest settings, as a config layer BENEATH the repository's.
155
241
  *
@@ -168,8 +254,18 @@ export declare function exceptionalTestFilter(nextestConfigPath: string): string
168
254
  * (`bounded-exec`, which spawns with `shell: true`) go through a shell — so the
169
255
  * command text stays identical everywhere. Quoted, because a workspace path may
170
256
  * contain spaces.
257
+ *
258
+ * The file is named through the workspace root's `node_modules` link, as
259
+ * `NEXTEST_EXTRACT_BIN` is, never through where the plugin really lives: a
260
+ * plugin linked from a checkout outside the workspace sits a different number
261
+ * of `../` away from each workspace depending on how deep that workspace is,
262
+ * and that count re-keyed every target of every Cargo project — and every
263
+ * dependent task — in each workspace that sat at a new depth.
264
+ *
265
+ * `projectRoot` is the Cargo workspace's root relative to the Nx workspace
266
+ * root, which is the directory these commands run in.
171
267
  */
172
- export declare function nextestToolConfigArg(workspaceRoot: string, projectRoot: string, configAbs: string): string;
268
+ export declare function nextestToolConfigArg(projectRoot: string): string;
173
269
  /** The repository's own nextest config, which now layers over the plugin's. */
174
270
  export declare const NEXTEST_REPO_CONFIG_PATH = ".config/nextest.toml";
175
271
  //# sourceMappingURL=cargo-workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-workspace.d.ts","sourceRoot":"","sources":["../src/cargo-workspace.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,+BAAgC,SAAQ,qBAAqB;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,0BAA0B,CAAC,mBAAmB,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAkF/F;AA0ED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,SAAS,qBAAqB,EAAE,EAC1C,QAAQ,EAAE,SAAS,qBAAqB,EAAE,GACzC,+BAA+B,EAAE,CAgBnC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAE/D,MAAM,WAAW,6BAA6B;IAC5C,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,gBA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,7 @@ import { readFile } from 'node:fs/promises';
3
3
  import { dirname, isAbsolute, join, normalize, posix, relative, resolve, sep } from 'node:path';
4
4
  import { readNxJson } from 'nx/src/config/nx-json.js';
5
5
  import { parse as parseToml } from 'smol-toml';
6
+ import { compiledInFiles } from './cargo-source-hash.js';
6
7
  export function listCargoWorkspacePackages(absoluteProjectRoot) {
7
8
  const workspaceTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
8
9
  if (!existsSync(workspaceTomlPath)) {
@@ -170,7 +171,7 @@ export function attributeCargoWorkspacePackages(packages, projects) {
170
171
  */
171
172
  export const EXTERNAL_RUST_CRATES_INPUT = 'externalRustCrates';
172
173
  export function createCargoInputsCache() {
173
- return { manifests: new Map(), nestedCrateDirs: new Map(), results: new Map() };
174
+ return { manifests: new Map(), nestedCrateDirs: new Map(), compiledInFiles: new Map(), results: new Map() };
174
175
  }
175
176
  export function cargoPackageTestInputs(options) {
176
177
  const cache = options.cache ?? createCargoInputsCache();
@@ -294,6 +295,13 @@ async function deriveCargoPackageTestInputs({ workspaceRoot, absoluteProjectRoot
294
295
  if (!dirs.has(childDir))
295
296
  exclusions.add(`!${inputPath(child)}/**`);
296
297
  }
298
+ // `include_str!("../../../skills/SKILL.md")` compiles a file the package's own
299
+ // fileset does not reach; a target that does not hash it serves a binary
300
+ // built from the file's old bytes.
301
+ for (const { file } of compiledInFiles(absoluteDir, cache.compiledInFiles)) {
302
+ if (isOutsideRoot(relative(absoluteDir, file)))
303
+ declaredSources.add(file);
304
+ }
297
305
  }
298
306
  for (const source of [...declaredSources].sort()) {
299
307
  const sourceRelative = relative(workspaceRoot, source);
@@ -505,8 +513,10 @@ export const CARGO_TEST_ARCHIVE_TARGET = 'cargo-test-archive';
505
513
  * does NOT create this parent directory and fails the whole build when it is
506
514
  * missing ("error writing to archive ... No such file or directory"), so the
507
515
  * target mkdir's it first.
516
+ * The archive is an Nx-restored output, so it lives on the source volume, never
517
+ * beneath Cargo's symlinked target directory (16_build_volumes.md).
508
518
  */
509
- export const CARGO_TEST_ARCHIVE_FILE = 'target/nextest/archive.tar.zst';
519
+ export const CARGO_TEST_ARCHIVE_FILE = '.cache/nextest/archive.tar.zst';
510
520
  /**
511
521
  * Foreign target triples this cargo workspace archives tests for, from
512
522
  * `[workspace.metadata.smoothbricks.test] cross-targets`. An entry is either
@@ -567,46 +577,62 @@ export function listCargoCrossTestTargets(absoluteProjectRoot) {
567
577
  return crossTargets;
568
578
  }
569
579
  /**
570
- * Tests that nextest.toml singles out are pinned to this suffix instead of
571
- * being sharded. Only a sharded crate has one: an unsharded crate runs its
572
- * whole suite in a single nextest process, which is all the pin restores.
580
+ * Tests that nextest.toml singles out use this suffix before their shard name.
581
+ * The class is hash-partitioned by the same declared count as the ordinary
582
+ * shards, so it never sits in one run that outgrows the target's bound.
573
583
  */
574
584
  export const CARGO_TEST_EXCEPTIONS_SUFFIX = 'exceptions';
585
+ /** Name prefix of the runner a serial test group gets; see `serialTestGroups`. */
586
+ export const CARGO_TEST_GROUP_PREFIX = 'cargo-test-group-';
575
587
  /**
576
588
  * A crate on one target keeps the bare name; a split crate suffixes the piece,
577
589
  * so `cargo-test-example-core-shard2` still reads as "example-core's tests".
578
590
  */
579
591
  export function cargoTestPackageTargetName(packageName, piece) {
580
592
  const base = `cargo-test-${packageName}`;
581
- return piece === undefined ? base : `${base}-${piece}`;
593
+ const name = piece === undefined ? base : `${base}-${piece}`;
594
+ // A crate named `group-*` would take the name of a serial group's runner.
595
+ if (name.startsWith(CARGO_TEST_GROUP_PREFIX)) {
596
+ throw new Error(`cargo crate ${packageName} would be named ${name}, reserved for a nextest test group runner`);
597
+ }
598
+ return name;
599
+ }
600
+ /**
601
+ * A serial group's runner. It selects by filter across the whole workspace, so
602
+ * it is no crate: `packageNameFromCargoTestTarget` reads it as none.
603
+ */
604
+ export function cargoTestGroupTargetName(group) {
605
+ return `${CARGO_TEST_GROUP_PREFIX}${group}`;
582
606
  }
583
607
  /**
584
608
  * Inverse of `cargoTestPackageTargetName`, used by the reachability policy to
585
609
  * check that the per-crate targets cover every workspace member. Pieces of one
586
610
  * crate collapse back to that crate, so a split crate counts as covered once.
587
611
  *
588
- * The two workspace-wide `cargo-test-*` targets are not crates: reading them as
589
- * one would invent members named "compile" and "archive" and report every real
590
- * crate's coverage against a set that can never match.
612
+ * The workspace-wide `cargo-test-*` targets are not crates: reading them as one
613
+ * would invent members named "compile" and "archive", and a serial group's runner
614
+ * would invent one named after its group. Each reports every crate's coverage
615
+ * against a set that can never match.
591
616
  */
592
617
  export function packageNameFromCargoTestTarget(targetName) {
593
618
  if (!targetName.startsWith('cargo-test-') ||
594
619
  targetName === CARGO_TEST_COMPILE_TARGET ||
595
- targetName === CARGO_TEST_ARCHIVE_TARGET) {
620
+ targetName === CARGO_TEST_ARCHIVE_TARGET ||
621
+ targetName.startsWith(CARGO_TEST_GROUP_PREFIX)) {
596
622
  return null;
597
623
  }
598
624
  const name = targetName
599
625
  .slice('cargo-test-'.length)
600
- .replace(new RegExp(`-(shard[1-9][0-9]*|${CARGO_TEST_EXCEPTIONS_SUFFIX})$`), '');
626
+ .replace(new RegExp(`-(shard[1-9][0-9]*|${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard[1-9][0-9]*)$`), '');
601
627
  return name.length === 0 ? null : name;
602
628
  }
603
629
  /**
604
630
  * The tests nextest.toml singles out with an override, as one filterset.
605
631
  *
606
- * Overrides can encode constraints that must survive sharding: a test group
607
- * limits concurrency within one nextest run, while a raised slow timeout can
608
- * identify expensive tests that should not delay an otherwise bounded shard.
609
- * Keep the configured exceptions in one run so group limits remain effective.
632
+ * An override can give a test a bound of its own: a raised slow timeout
633
+ * identifies an expensive test that should not delay an otherwise bounded
634
+ * shard. Partition those tests separately, so every target keeps its time
635
+ * bound and each class runs beside the ordinary shards.
610
636
  *
611
637
  * Deriving this from the config that declares the classes, rather than
612
638
  * restating their filters, means adding an override there is the whole change —
@@ -632,9 +658,255 @@ export function exceptionalTestFilter(nextestConfigPath) {
632
658
  }
633
659
  }
634
660
  }
661
+ return filterUnion(filters);
662
+ }
663
+ /** The filters as one filterset that any of them matches, or null for none. */
664
+ function filterUnion(filters) {
635
665
  const unique = [...new Set(filters)];
636
666
  return unique.length === 0 ? null : unique.map((filter) => `(${filter})`).join(' or ');
637
667
  }
668
+ /**
669
+ * The only `platform` a serial group's overrides may declare: nextest's cfg for macOS. The group
670
+ * runs on macOS hosts only, a host decision made by the planner, never a cfg parse here.
671
+ */
672
+ export const SERIAL_TEST_GROUP_PLATFORM = 'cfg(target_os="macos")';
673
+ /**
674
+ * The repository's test groups capped at one thread (`max-threads = 1`), each
675
+ * with the tests its default-profile overrides assign it.
676
+ *
677
+ * A serial group is declared exactly once, in `.config/nextest.toml`: the name
678
+ * under `[test-groups]` plus the overrides that name it. Its runner's filter is
679
+ * derived from those overrides rather than restated, so the runner and the
680
+ * per-crate exclusions cannot drift from what nextest actually serializes.
681
+ *
682
+ * Each group also carries the `scope` of its filter (`filterScope`): the members its runner hashes.
683
+ * A group whose every clause is scoped to a `package(<name>)` reruns only when those crates or their
684
+ * local dependencies change; any other group is scoped to the whole workspace. Nothing here orders one
685
+ * group against another: they are separate runners, and a repository that needs two never concurrent
686
+ * declares the edge between their targets itself.
687
+ *
688
+ * Every override naming a serial group must declare `SERIAL_TEST_GROUP_PLATFORM`.
689
+ * This plugin has no cfg evaluator, so it honours exactly that platform and
690
+ * refuses any other rather than guessing where the group applies.
691
+ *
692
+ * Returns [] when the file is absent or declares no serial group, so a workspace
693
+ * without one keeps exactly its existing targets.
694
+ */
695
+ export function serialTestGroups(nextestConfigPath) {
696
+ if (!existsSync(nextestConfigPath)) {
697
+ return [];
698
+ }
699
+ const parsed = parseToml(readFileSync(nextestConfigPath, 'utf-8'));
700
+ if (!isRecord(parsed)) {
701
+ return [];
702
+ }
703
+ const declaredValue = parsed['test-groups'];
704
+ const declaredGroups = isRecord(declaredValue) ? declaredValue : {};
705
+ const serial = Object.keys(declaredGroups)
706
+ .filter((name) => {
707
+ const declared = declaredGroups[name];
708
+ return isRecord(declared) && declared['max-threads'] === 1;
709
+ })
710
+ .sort((left, right) => left.localeCompare(right));
711
+ const profiles = isRecord(parsed.profile) ? parsed.profile : {};
712
+ const defaults = isRecord(profiles.default) ? profiles.default : {};
713
+ const overridesValue = defaults.overrides;
714
+ const overrides = Array.isArray(overridesValue) ? overridesValue : [];
715
+ return serial.flatMap((group) => {
716
+ const filters = [];
717
+ for (const override of overrides) {
718
+ if (!isRecord(override) || override['test-group'] !== group) {
719
+ continue;
720
+ }
721
+ if (override.platform !== SERIAL_TEST_GROUP_PLATFORM) {
722
+ throw new Error(`${nextestConfigPath}: test-group "${group}" overrides must declare platform = '${SERIAL_TEST_GROUP_PLATFORM}' ` +
723
+ `(the only platform a serial group runs on here), got ${JSON.stringify(override.platform ?? null)}`);
724
+ }
725
+ if (typeof override.filter === 'string' && override.filter.length > 0) {
726
+ filters.push(override.filter);
727
+ }
728
+ }
729
+ const filter = filterUnion(filters);
730
+ return filter === null ? [] : [{ group, filter, scope: filterScope(filter) }];
731
+ });
732
+ }
733
+ /**
734
+ * The packages `filter` can select tests from, read off its `package(<name>)` predicates. The scope is
735
+ * never narrower than the selection: whatever this does not read with certainty is the whole workspace.
736
+ *
737
+ * The filter is read as nextest reads it, with nextest's precedence — parentheses, then `not` and `!`,
738
+ * then `and`, `&` and `-`, then `or`, `|` and `+`, each level left to right — and with nextest's blanks,
739
+ * which are spaces and line endings. Each expression is bounded by the packages it can select from:
740
+ *
741
+ * - `package(<name>)` and `package(=<name>)`, for a plain Cargo name, bound it to that package. A glob,
742
+ * `~contains`, `/regex/` or `#glob` name can match any package, so it bounds nothing.
743
+ * - Every other predicate bounds nothing, and nor does `not`: `not package(a)` selects from every other
744
+ * package, and `deps` and `rdeps` reach beyond the package they name.
745
+ * - `a and b` selects only what both select, so it is bounded by the narrower of the two bounds, and
746
+ * `a - b`, which is `a and not b`, by `a`. `a or b` is bounded by both together, so one unbounded
747
+ * clause leaves the union unbounded however the union is spelled.
748
+ *
749
+ * A predicate's argument ends where nextest ends it: a regex at its closing `/`, any other matcher at its
750
+ * first `)`. Only arguments that need none of nextest's escape sequences are read: a backslash, or a comma
751
+ * outside a regex, makes where the predicate ends depend on escapes this does not implement. Those, a
752
+ * filter that does not parse, and one whose packages exclude each other have no bound.
753
+ */
754
+ export function filterScope(filter) {
755
+ const read = readUnion(filter, 0);
756
+ if (read === null || skipBlank(filter, read.end) !== filter.length || read.bound === 'any' || read.bound.size === 0) {
757
+ return { kind: 'workspace' };
758
+ }
759
+ return { kind: 'packages', packages: [...read.bound].sort((left, right) => left.localeCompare(right)) };
760
+ }
761
+ /** nextest's loosest-binding level: `or`, `|` and `+` between chains of `and`. */
762
+ function readUnion(text, from) {
763
+ let left = readIntersection(text, from);
764
+ while (left !== null) {
765
+ const operatorEnd = skipUnionOperator(text, left.end);
766
+ if (operatorEnd === null)
767
+ return left;
768
+ const right = readIntersection(text, operatorEnd);
769
+ if (right === null)
770
+ return null;
771
+ const bound = left.bound === 'any' || right.bound === 'any' ? 'any' : new Set([...left.bound, ...right.bound]);
772
+ left = { bound, end: right.end };
773
+ }
774
+ return null;
775
+ }
776
+ /** A chain of `and`, `&` and `-`, which bind tighter than a union, left to right. */
777
+ function readIntersection(text, from) {
778
+ let left = readOperand(text, from);
779
+ while (left !== null) {
780
+ const operator = readIntersectionOperator(text, left.end);
781
+ if (operator === null)
782
+ return left;
783
+ const right = readOperand(text, operator.end);
784
+ left =
785
+ right === null
786
+ ? null
787
+ : { bound: operator.difference ? left.bound : boundIntersection(left.bound, right.bound), end: right.end };
788
+ }
789
+ return null;
790
+ }
791
+ /** A negation, a parenthesised filterset, or one predicate. */
792
+ function readOperand(text, from) {
793
+ const at = skipBlank(text, from);
794
+ const word = readWord(text, at, 'not');
795
+ const negated = word ?? (text.charAt(at) === '!' ? at + 1 : null);
796
+ if (negated !== null) {
797
+ const operand = readOperand(text, negated);
798
+ return operand === null ? null : { bound: 'any', end: operand.end };
799
+ }
800
+ if (text.charAt(at) !== '(')
801
+ return readPredicate(text, at);
802
+ const inner = readUnion(text, at + 1);
803
+ if (inner === null)
804
+ return null;
805
+ const close = skipBlank(text, inner.end);
806
+ return text.charAt(close) === ')' ? { bound: inner.bound, end: close + 1 } : null;
807
+ }
808
+ /** What follows a predicate's `(`: nothing, or a name matcher. */
809
+ const PREDICATE_ARGUMENTS = {
810
+ all: 'none',
811
+ none: 'none',
812
+ default: 'none',
813
+ test: 'matcher',
814
+ group: 'matcher',
815
+ package: 'matcher',
816
+ deps: 'matcher',
817
+ rdeps: 'matcher',
818
+ binary_id: 'matcher',
819
+ kind: 'matcher',
820
+ binary: 'matcher',
821
+ platform: 'matcher',
822
+ };
823
+ /** One predicate: `all()` and its kin, or a name followed by its parenthesised matcher. */
824
+ function readPredicate(text, at) {
825
+ const identifier = /[a-z_]+/y;
826
+ identifier.lastIndex = at;
827
+ const predicate = identifier.exec(text)?.[0];
828
+ if (predicate === undefined)
829
+ return null;
830
+ const open = skipBlank(text, at + predicate.length);
831
+ if (text.charAt(open) !== '(')
832
+ return null;
833
+ const argument = Object.hasOwn(PREDICATE_ARGUMENTS, predicate) ? PREDICATE_ARGUMENTS[predicate] : undefined;
834
+ if (argument === undefined)
835
+ return null;
836
+ if (argument === 'none') {
837
+ const close = skipBlank(text, open + 1);
838
+ return text.charAt(close) === ')' ? { bound: 'any', end: close + 1 } : null;
839
+ }
840
+ const matcher = readMatcher(text, open + 1);
841
+ return matcher === null
842
+ ? null
843
+ : { bound: predicate === 'package' ? packageBound(matcher.text) : 'any', end: matcher.end };
844
+ }
845
+ /**
846
+ * The argument of a predicate whose `(` ends just before `from`, as written between its parentheses, and
847
+ * the offset past its `)`; null when it cannot be delimited exactly as nextest delimits it.
848
+ */
849
+ function readMatcher(text, from) {
850
+ const start = skipBlank(text, from);
851
+ const close = text.charAt(start) === '/' ? regexMatcherClose(text, start) : plainMatcherClose(text, start);
852
+ return close === null ? null : { text: text.slice(from, close), end: close + 1 };
853
+ }
854
+ /** The `)` that follows the `/regex/` starting at `start`, when the regex holds no backslash. */
855
+ function regexMatcherClose(text, start) {
856
+ const slash = text.indexOf('/', start + 1);
857
+ if (slash < 0 || text.slice(start, slash).includes('\\'))
858
+ return null;
859
+ const close = skipBlank(text, slash + 1);
860
+ return text.charAt(close) === ')' ? close : null;
861
+ }
862
+ /** The first `)` at or after `start`, when nothing before it is a backslash or a comma. */
863
+ function plainMatcherClose(text, start) {
864
+ const close = text.indexOf(')', start);
865
+ return close < 0 || /[,\\]/.test(text.slice(start, close)) ? null : close;
866
+ }
867
+ /** A plain Cargo package name, with or without nextest's `=` prefix: nothing a glob can widen. */
868
+ const PLAIN_PACKAGE_NAME = /^=?([A-Za-z0-9_-]+)$/;
869
+ function packageBound(matcher) {
870
+ const name = PLAIN_PACKAGE_NAME.exec(matcher)?.[1];
871
+ return name === undefined ? 'any' : new Set([name]);
872
+ }
873
+ function boundIntersection(left, right) {
874
+ if (left === 'any')
875
+ return right;
876
+ if (right === 'any')
877
+ return left;
878
+ return new Set([...left].filter((name) => right.has(name)));
879
+ }
880
+ /** The offset of the first character at or after `from` that nextest does not read as blank. */
881
+ function skipBlank(text, from) {
882
+ const blank = /(?: |\r?\n)*/y;
883
+ blank.lastIndex = from;
884
+ return from + (blank.exec(text)?.[0].length ?? 0);
885
+ }
886
+ /** `word` at `at`, read as nextest reads an operator word: not the start of a longer identifier. */
887
+ function readWord(text, at, word) {
888
+ const end = at + word.length;
889
+ return text.startsWith(word, at) && !/[A-Za-z0-9_]/.test(text.charAt(end)) ? end : null;
890
+ }
891
+ /** The offset past the `or`, `|` or `+` that follows `from` after any blanks, or null. */
892
+ function skipUnionOperator(text, from) {
893
+ const at = skipBlank(text, from);
894
+ const character = text.charAt(at);
895
+ return readWord(text, at, 'or') ?? (character === '|' || character === '+' ? at + 1 : null);
896
+ }
897
+ /** The `and`, `&` or `-` that follows `from` after any blanks: where it ends, and whether it subtracts. */
898
+ function readIntersectionOperator(text, from) {
899
+ const at = skipBlank(text, from);
900
+ const word = readWord(text, at, 'and');
901
+ if (word !== null)
902
+ return { end: word, difference: false };
903
+ const character = text.charAt(at);
904
+ if (character === '&')
905
+ return { end: at + 1, difference: false };
906
+ return character === '-' ? { end: at + 1, difference: true } : null;
907
+ }
908
+ /** The plugin's nextest.toml as the workspace root's `node_modules` links it. */
909
+ export const PLUGIN_NEXTEST_CONFIG_PATH = 'node_modules/@smoothbricks/nx-plugin/nextest.toml';
638
910
  /**
639
911
  * The plugin's own nextest settings, as a config layer BENEATH the repository's.
640
912
  *
@@ -653,10 +925,19 @@ export function exceptionalTestFilter(nextestConfigPath) {
653
925
  * (`bounded-exec`, which spawns with `shell: true`) go through a shell — so the
654
926
  * command text stays identical everywhere. Quoted, because a workspace path may
655
927
  * contain spaces.
928
+ *
929
+ * The file is named through the workspace root's `node_modules` link, as
930
+ * `NEXTEST_EXTRACT_BIN` is, never through where the plugin really lives: a
931
+ * plugin linked from a checkout outside the workspace sits a different number
932
+ * of `../` away from each workspace depending on how deep that workspace is,
933
+ * and that count re-keyed every target of every Cargo project — and every
934
+ * dependent task — in each workspace that sat at a new depth.
935
+ *
936
+ * `projectRoot` is the Cargo workspace's root relative to the Nx workspace
937
+ * root, which is the directory these commands run in.
656
938
  */
657
- export function nextestToolConfigArg(workspaceRoot, projectRoot, configAbs) {
658
- const rel = relative(join(workspaceRoot, projectRoot), configAbs);
659
- const path = rel.length === 0 ? configAbs : rel.split(sep).join('/');
939
+ export function nextestToolConfigArg(projectRoot) {
940
+ const path = posix.join(posix.relative(projectRoot, '.'), PLUGIN_NEXTEST_CONFIG_PATH);
660
941
  return `--tool-config-file "smoo:$PWD/${path}"`;
661
942
  }
662
943
  /** The repository's own nextest config, which now layers over the plugin's. */