@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,737 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
3
- import { tmpdir } from 'node:os';
4
- import { dirname, join } from 'node:path';
5
-
6
- import { readJson, writeJson } from 'nx/src/devkit-exports.js';
7
- import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports.js';
8
-
9
- import {
10
- applyWorkspaceConfig,
11
- applyWorkspaceConfigPolicy,
12
- applyWorkspaceConfigTree,
13
- BUILD_OUTPUT_DEPENDENCIES,
14
- checkWorkspaceConfig,
15
- checkWorkspaceConfigPolicy,
16
- checkWorkspaceConfigTree,
17
- LINUX_PLATFORM_TARGET_GLOBS,
18
- MACOS_PLATFORM_TARGET_GLOBS,
19
- PLATFORM_TARGET_GLOBS,
20
- } from './workspace-config-policy.js';
21
-
22
- // ---------------------------------------------------------------------------
23
- // Helpers
24
- // ---------------------------------------------------------------------------
25
-
26
- function validNxJson(): Record<string, unknown> {
27
- return {
28
- cacheDirectory: '.nx/cache',
29
- plugins: ['@smoothbricks/nx-plugin'],
30
- sync: { globalGenerators: ['@smoothbricks/nx-plugin:managed-files'] },
31
- targetDefaults: validTargetDefaults(),
32
- namedInputs: validNamedInputs(),
33
- };
34
- }
35
-
36
- function validTargetDefaults(): Record<string, unknown> {
37
- return {
38
- build: { cache: true },
39
- clean: { executor: '@smoothbricks/nx-plugin:clean-outputs', cache: false },
40
- };
41
- }
42
-
43
- const MARKDOWN = '!{projectRoot}/**/*.md';
44
-
45
- function validNamedInputs(): Record<string, unknown> {
46
- return {
47
- default: ['{projectRoot}/**/*', MARKDOWN],
48
- production: [
49
- '{projectRoot}/src/**/*',
50
- '{projectRoot}/package.json',
51
- '!{projectRoot}/**/__tests__/**',
52
- '!{projectRoot}/**/*.test.*',
53
- '!{projectRoot}/**/*.spec.*',
54
- MARKDOWN,
55
- ],
56
- };
57
- }
58
-
59
- function validPlugins(): unknown[] {
60
- return ['@smoothbricks/nx-plugin'];
61
- }
62
-
63
- // ---------------------------------------------------------------------------
64
- // Layer 1: Pure core function tests
65
- // ---------------------------------------------------------------------------
66
-
67
- describe('target family conventions', () => {
68
- it('separates platform-only families from ordinary build outputs', () => {
69
- expect(MACOS_PLATFORM_TARGET_GLOBS).toEqual(['*-macos', '*-ios']);
70
- expect(LINUX_PLATFORM_TARGET_GLOBS).toEqual(['*-linux']);
71
- expect(PLATFORM_TARGET_GLOBS).toEqual(['*-macos', '*-ios', '*-linux']);
72
- expect(BUILD_OUTPUT_DEPENDENCIES).toEqual([
73
- '*-js',
74
- '*-web',
75
- '*-html',
76
- '*-css',
77
- '*-android',
78
- '*-native',
79
- '*-napi',
80
- '*-bun',
81
- '*-wasm',
82
- ]);
83
- });
84
- });
85
-
86
- describe('pure core: checkWorkspaceConfig', () => {
87
- it('returns no issues for valid config', () => {
88
- const issues = checkWorkspaceConfig(validNxJson());
89
- expect(issues).toEqual([]);
90
- });
91
-
92
- it('uses nx.json as path in issues', () => {
93
- const issues = checkWorkspaceConfig({});
94
- for (const issue of issues) {
95
- expect(issue.path).toBe('nx.json');
96
- }
97
- });
98
-
99
- it('detects missing plugins', () => {
100
- const issues = checkWorkspaceConfig({
101
- cacheDirectory: '.nx/cache',
102
- plugins: [],
103
- targetDefaults: validTargetDefaults(),
104
- namedInputs: validNamedInputs(),
105
- });
106
- expect(issues.length).toBe(1);
107
- expect(issues.some((i) => i.message.includes('plugins must include @smoothbricks/nx-plugin'))).toBe(true);
108
- });
109
-
110
- it('detects colon target defaults', () => {
111
- const issues = checkWorkspaceConfig({
112
- ...validNxJson(),
113
- targetDefaults: {
114
- ...validTargetDefaults(),
115
- 'build:wasm': { cache: true },
116
- },
117
- });
118
- expect(issues.some((i) => i.message.includes('build:wasm'))).toBe(true);
119
- expect(issues.some((i) => i.message.includes('must not use colon target names'))).toBe(true);
120
- });
121
-
122
- it('rejects static test typecheck defaults that override per-project inference', () => {
123
- const issues = checkWorkspaceConfig({
124
- ...validNxJson(),
125
- targetDefaults: {
126
- ...validTargetDefaults(),
127
- 'typecheck-tests': {
128
- dependsOn: ['typecheck'],
129
- options: { command: 'ttsc -p tsconfig.test.json --noEmit' },
130
- },
131
- },
132
- });
133
-
134
- expect(
135
- issues.some((issue) => issue.message.includes('targetDefaults.typecheck-tests must not be configured')),
136
- ).toBe(true);
137
- });
138
-
139
- it('detects native TypeScript inference', () => {
140
- const issues = checkWorkspaceConfig({
141
- plugins: ['@nx/js/typescript', '@smoothbricks/nx-plugin'],
142
- targetDefaults: validTargetDefaults(),
143
- namedInputs: validNamedInputs(),
144
- });
145
- expect(issues.some((issue) => issue.message.includes('plugins must not configure @nx/js/typescript'))).toBe(true);
146
- });
147
-
148
- it('detects imprecise production inputs', () => {
149
- const issues = checkWorkspaceConfig({
150
- plugins: validPlugins(),
151
- targetDefaults: validTargetDefaults(),
152
- namedInputs: {
153
- ...validNamedInputs(),
154
- production: ['default'],
155
- },
156
- });
157
- expect(issues.some((i) => i.message.includes('enumerate precise production inputs'))).toBe(true);
158
- });
159
-
160
- it('detects missing build cache', () => {
161
- const issues = checkWorkspaceConfig({
162
- plugins: validPlugins(),
163
- targetDefaults: {
164
- build: { cache: false },
165
- clean: { executor: '@smoothbricks/nx-plugin:clean-outputs', cache: false },
166
- },
167
- namedInputs: validNamedInputs(),
168
- });
169
- expect(issues.some((i) => i.message.includes('build.cache must be true'))).toBe(true);
170
- expect(issues.some((i) => i.message.includes('build.outputs'))).toBe(false);
171
- });
172
-
173
- it('rejects a build outputs default that would clobber the inferred aggregate', () => {
174
- const issues = checkWorkspaceConfig({
175
- plugins: validPlugins(),
176
- targetDefaults: {
177
- ...validTargetDefaults(),
178
- build: { cache: true, outputs: ['{projectRoot}/dist'] },
179
- },
180
- namedInputs: validNamedInputs(),
181
- });
182
- expect(issues.some((i) => i.message.includes('targetDefaults.build.outputs must not be set'))).toBe(true);
183
- });
184
-
185
- it('rejects a build dependsOn default that would clobber the inferred aggregate', () => {
186
- const issues = checkWorkspaceConfig({
187
- plugins: validPlugins(),
188
- targetDefaults: {
189
- ...validTargetDefaults(),
190
- build: { cache: true, dependsOn: ['^build'] },
191
- },
192
- namedInputs: validNamedInputs(),
193
- });
194
- expect(issues.some((i) => i.message.includes('targetDefaults.build.dependsOn must not be set'))).toBe(true);
195
- });
196
-
197
- it('rejects a test dependsOn default that would clobber inferred cargo-test', () => {
198
- const issues = checkWorkspaceConfig({
199
- plugins: validPlugins(),
200
- targetDefaults: {
201
- ...validTargetDefaults(),
202
- test: { cache: true, dependsOn: ['^build', 'build'] },
203
- },
204
- namedInputs: validNamedInputs(),
205
- });
206
- expect(issues.some((i) => i.message.includes('targetDefaults.test.dependsOn must not be set'))).toBe(true);
207
- });
208
-
209
- it('accepts absent or custom non-CI shared globals', () => {
210
- for (const globals of [undefined, [], ['{workspaceRoot}/config/shared.json']]) {
211
- const nxJson = validNxJson();
212
- nxJson.namedInputs = {
213
- ...validNamedInputs(),
214
- ...(globals === undefined
215
- ? {}
216
- : { default: ['{projectRoot}/**/*', 'sharedGlobals', MARKDOWN], sharedGlobals: globals }),
217
- };
218
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
219
- }
220
- });
221
-
222
- it('rejects CI-only shared globals in default but allows explicit workflow inputs', () => {
223
- const nxJson = validNxJson();
224
- nxJson.namedInputs = {
225
- ...validNamedInputs(),
226
- default: ['{projectRoot}/**/*', 'sharedGlobals'],
227
- sharedGlobals: ['{workspaceRoot}/.github/workflows/ci.yml'],
228
- };
229
- expect(checkWorkspaceConfig(nxJson).some((issue) => issue.message.includes('CI-only sharedGlobals'))).toBe(true);
230
- nxJson.namedInputs = {
231
- ...validNamedInputs(),
232
- sharedGlobals: ['{workspaceRoot}/.github/workflows/ci.yml'],
233
- };
234
- nxJson.targetDefaults = { ...validTargetDefaults(), workflowLint: { inputs: ['sharedGlobals'] } };
235
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
236
- });
237
-
238
- it("requires the checkout's own Nx cache directory", () => {
239
- for (const cacheDirectory of [undefined, '/tmp/nx-cache', '.cache/nx']) {
240
- const issues = checkWorkspaceConfig({ ...validNxJson(), cacheDirectory });
241
- expect(issues.map((issue) => issue.message)).toEqual([
242
- 'cacheDirectory must be ".nx/cache". ' +
243
- "Without it Nx keeps the task cache and its database in a per-user ~/.nx/<id> shared by every checkout, not in the checkout's own .nx.",
244
- ]);
245
- }
246
- });
247
- });
248
-
249
- describe('pure core: applyWorkspaceConfig', () => {
250
- it("sets the checkout's own Nx cache directory, once", () => {
251
- for (const cacheDirectory of [undefined, '/tmp/nx-cache']) {
252
- const nxJson: Record<string, unknown> = { ...validNxJson(), cacheDirectory };
253
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
254
- expect(nxJson.cacheDirectory).toBe('.nx/cache');
255
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
256
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
257
- }
258
- });
259
-
260
- it('removes workspace-wide lint commands while preserving shared cache policy', () => {
261
- const nxJson = {
262
- ...validNxJson(),
263
- targetDefaults: {
264
- ...validTargetDefaults(),
265
- lint: {
266
- cache: true,
267
- executor: 'nx:run-commands',
268
- dependsOn: ['typecheck-tests', 'cargo-lint'],
269
- inputs: ['default'],
270
- outputs: ['dist'],
271
- options: { command: 'eslint packages/*/src' },
272
- },
273
- },
274
- };
275
- expect(checkWorkspaceConfig(nxJson).some((issue) => issue.message.includes('targetDefaults.lint.'))).toBe(true);
276
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
277
- expect(nxJson.targetDefaults.lint).toMatchObject({ cache: true });
278
- expect(Object.keys(nxJson.targetDefaults.lint)).toEqual(['cache']);
279
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
280
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
281
- });
282
-
283
- it('preserves lint input extensions that retain inferred inputs and dependency declarations', () => {
284
- const inputs = ['...', '^production', '{workspaceRoot}/tooling/lint-extra/**/*'];
285
- const nxJson = {
286
- ...validNxJson(),
287
- targetDefaults: { ...validTargetDefaults(), lint: { cache: true, inputs } },
288
- };
289
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
290
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
291
- expect(nxJson.targetDefaults.lint.inputs).toEqual(inputs);
292
- for (const invalidInputs of [['^production'], ['...', 'default'], ['default', '^production']]) {
293
- const invalid = {
294
- ...validNxJson(),
295
- targetDefaults: { ...validTargetDefaults(), lint: { cache: true, inputs: invalidInputs } },
296
- };
297
- expect(checkWorkspaceConfig(invalid).some((issue) => issue.message.includes('targetDefaults.lint.inputs'))).toBe(
298
- true,
299
- );
300
- expect(applyWorkspaceConfig(invalid)).toBe(true);
301
- expect(Object.keys(invalid.targetDefaults.lint)).toEqual(['cache']);
302
- }
303
- });
304
-
305
- it('returns false for already-valid config', () => {
306
- const nxJson = validNxJson();
307
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
308
- });
309
-
310
- it('strips a build outputs default so the inferred aggregate claims nothing', () => {
311
- const nxJson = {
312
- ...validNxJson(),
313
- targetDefaults: {
314
- ...validTargetDefaults(),
315
- build: { cache: true, outputs: ['{projectRoot}/dist', '{projectRoot}/dist-node'] },
316
- },
317
- };
318
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
319
- const build = expectRecord(expectRecord(nxJson.targetDefaults).build);
320
- expect(build).toEqual({ cache: true });
321
- });
322
-
323
- it('strips a build dependsOn default so the inferred host-aware edge survives', () => {
324
- const nxJson = {
325
- ...validNxJson(),
326
- targetDefaults: {
327
- ...validTargetDefaults(),
328
- build: { cache: true, dependsOn: ['^build'] },
329
- },
330
- };
331
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
332
- const build = expectRecord(expectRecord(nxJson.targetDefaults).build);
333
- expect(build).toEqual({ cache: true });
334
- });
335
-
336
- it('strips a test dependsOn default so inferred cargo-test survives', () => {
337
- const nxJson = {
338
- ...validNxJson(),
339
- targetDefaults: {
340
- ...validTargetDefaults(),
341
- test: { cache: true, dependsOn: ['^build', 'build'] },
342
- },
343
- };
344
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
345
- const test = expectRecord(expectRecord(nxJson.targetDefaults).test);
346
- expect(test).toEqual({ cache: true });
347
- });
348
-
349
- it('fixes missing plugins', () => {
350
- const nxJson: Record<string, unknown> = {
351
- plugins: [],
352
- targetDefaults: validTargetDefaults(),
353
- namedInputs: validNamedInputs(),
354
- };
355
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
356
- const pluginNames = readPluginNames(nxJson.plugins);
357
- expect(pluginNames).not.toContain('@nx/js/typescript');
358
- expect(pluginNames).toContain('@smoothbricks/nx-plugin');
359
- });
360
-
361
- it('keeps configured plugin entries and their order through two policy runs', () => {
362
- const configured = {
363
- plugin: '@smoothbricks/nx-plugin',
364
- options: { custom: { owner: 'declared-owner', enabled: true } },
365
- include: ['packages/owned/**'],
366
- exclude: ['packages/foreign/**'],
367
- };
368
- const scoped = { ...configured, include: ['targets/owned/**'] };
369
- const plugins = ['example:before', configured, scoped, 'example:after'];
370
- const original = JSON.stringify(plugins);
371
- const nxJson = { ...validNxJson(), plugins };
372
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
373
- expect(JSON.stringify(nxJson.plugins)).toBe(original);
374
- expect(nxJson.plugins[1]).toBe(configured);
375
- expect(nxJson.plugins[2]).toBe(scoped);
376
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
377
- expect(JSON.stringify(nxJson.plugins)).toBe(original);
378
- });
379
-
380
- it('removes colon target defaults', () => {
381
- const nxJson = {
382
- ...validNxJson(),
383
- targetDefaults: {
384
- ...validTargetDefaults(),
385
- 'build:wasm': { cache: true },
386
- },
387
- };
388
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
389
- expect(expectRecord(nxJson.targetDefaults)['build:wasm']).toBeUndefined();
390
- });
391
-
392
- it('removes static test typecheck defaults so inference owns clean-output prerequisites', () => {
393
- const nxJson = {
394
- ...validNxJson(),
395
- targetDefaults: {
396
- ...validTargetDefaults(),
397
- 'typecheck-tests': {
398
- dependsOn: ['typecheck'],
399
- options: { command: 'ttsc -p tsconfig.test.json --noEmit' },
400
- },
401
- },
402
- };
403
-
404
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
405
- expect(expectRecord(nxJson.targetDefaults)['typecheck-tests']).toBeUndefined();
406
- });
407
-
408
- it('fixes imprecise production inputs', () => {
409
- const nxJson: Record<string, unknown> = {
410
- plugins: validPlugins(),
411
- targetDefaults: validTargetDefaults(),
412
- namedInputs: {
413
- ...validNamedInputs(),
414
- production: ['default', '{projectRoot}/**/*'],
415
- },
416
- };
417
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
418
- const namedInputs = expectRecord(nxJson.namedInputs);
419
- expect(namedInputs.production).toEqual([
420
- '{projectRoot}/src/**/*',
421
- '{projectRoot}/package.json',
422
- '!{projectRoot}/**/__tests__/**',
423
- '!{projectRoot}/**/*.test.*',
424
- '!{projectRoot}/**/*.spec.*',
425
- MARKDOWN,
426
- ]);
427
- });
428
-
429
- // A README or spec edit re-keyed every task of its project and, through `^default`/`^production`, of every
430
- // project depending on it: 39 tasks for one package README in this repository.
431
- it('keeps Markdown out of default and production, appending the exclusion to custom definitions', () => {
432
- const nxJson = validNxJson();
433
- nxJson.namedInputs = {
434
- default: ['{projectRoot}/**/*', 'custom'],
435
- production: ['{projectRoot}/src/**/*.rs', '{projectRoot}/Cargo.toml'],
436
- custom: ['{workspaceRoot}/config/shared.json'],
437
- };
438
- expect(checkWorkspaceConfig(nxJson).map((issue) => issue.message)).toEqual([
439
- "namedInputs.default must exclude {projectRoot}/**/*.md: Markdown is no task's input unless a target names it.",
440
- "namedInputs.production must exclude {projectRoot}/**/*.md: Markdown is no task's input unless a target names it.",
441
- ]);
442
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
443
- expect(nxJson.namedInputs).toEqual({
444
- default: ['{projectRoot}/**/*', 'custom', MARKDOWN],
445
- production: ['{projectRoot}/src/**/*.rs', '{projectRoot}/Cargo.toml', MARKDOWN],
446
- custom: ['{workspaceRoot}/config/shared.json'],
447
- });
448
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
449
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
450
-
451
- const fresh: Record<string, unknown> = { plugins: validPlugins(), targetDefaults: validTargetDefaults() };
452
- applyWorkspaceConfig(fresh);
453
- expect(fresh.namedInputs).toEqual(validNamedInputs());
454
- });
455
-
456
- it('accepts custom precise production inputs unchanged', () => {
457
- const nxJson: Record<string, unknown> = {
458
- ...validNxJson(),
459
- namedInputs: {
460
- ...validNamedInputs(),
461
- production: ['{projectRoot}/src/**/*.rs', '{projectRoot}/Cargo.toml', '!{projectRoot}/**/*.test.*', MARKDOWN],
462
- },
463
- };
464
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
465
- });
466
- it('migrates only a CI-only sharedGlobals reference and retains explicit workflow targets', () => {
467
- const nxJson = validNxJson();
468
- nxJson.namedInputs = {
469
- ...validNamedInputs(),
470
- default: ['{projectRoot}/**/*', 'sharedGlobals', 'custom', MARKDOWN],
471
- sharedGlobals: ['{workspaceRoot}/.github/workflows/ci.yml'],
472
- custom: ['{workspaceRoot}/config/shared.json'],
473
- lint: ['sharedGlobals'],
474
- };
475
- nxJson.targetDefaults = { ...validTargetDefaults(), workflowLint: { inputs: ['sharedGlobals'] } };
476
- expect(applyWorkspaceConfig(nxJson)).toBe(true);
477
- expect(expectRecord(nxJson.namedInputs)).toEqual({
478
- ...validNamedInputs(),
479
- default: ['{projectRoot}/**/*', 'custom', MARKDOWN],
480
- sharedGlobals: ['{workspaceRoot}/.github/workflows/ci.yml'],
481
- custom: ['{workspaceRoot}/config/shared.json'],
482
- lint: ['sharedGlobals'],
483
- });
484
- expect(expectRecord(nxJson.targetDefaults).workflowLint).toEqual({ inputs: ['sharedGlobals'] });
485
- expect(expectRecord(nxJson.namedInputs).lint).toEqual(['sharedGlobals']);
486
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
487
- expect(checkWorkspaceConfig(nxJson)).toEqual([]);
488
- });
489
-
490
- it('preserves a custom non-CI sharedGlobals definition and its default reference', () => {
491
- const nxJson = validNxJson();
492
- nxJson.namedInputs = {
493
- ...validNamedInputs(),
494
- default: ['{projectRoot}/**/*', 'sharedGlobals', MARKDOWN],
495
- sharedGlobals: ['{workspaceRoot}/config/shared.json'],
496
- };
497
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
498
- expect(expectRecord(nxJson.namedInputs).sharedGlobals).toEqual(['{workspaceRoot}/config/shared.json']);
499
- expect(expectRecord(nxJson.namedInputs).default).toEqual(['{projectRoot}/**/*', 'sharedGlobals', MARKDOWN]);
500
- });
501
- });
502
-
503
- // ---------------------------------------------------------------------------
504
- // Layer 2: Tree-based function tests
505
- // ---------------------------------------------------------------------------
506
-
507
- describe('Tree: checkWorkspaceConfigTree', () => {
508
- it('returns issue when nx.json missing', () => {
509
- const tree = createTreeWithEmptyWorkspace();
510
- // createTreeWithEmptyWorkspace creates an nx.json, remove it
511
- tree.delete('nx.json');
512
- const issues = checkWorkspaceConfigTree(tree);
513
- expect(issues).toHaveLength(1);
514
- expect(issues[0].message).toBe('nx.json not found');
515
- });
516
-
517
- it('detects missing plugins', () => {
518
- const tree = createTreeWithEmptyWorkspace();
519
- writeJson(tree, 'nx.json', {
520
- cacheDirectory: '.nx/cache',
521
- plugins: [],
522
- targetDefaults: validTargetDefaults(),
523
- namedInputs: validNamedInputs(),
524
- });
525
-
526
- const issues = checkWorkspaceConfigTree(tree);
527
- expect(issues.length).toBe(1);
528
- expect(issues.some((i) => i.message.includes('plugins must include @smoothbricks/nx-plugin'))).toBe(true);
529
- });
530
-
531
- it('returns no issues for valid config', () => {
532
- const tree = createTreeWithEmptyWorkspace();
533
- writeJson(tree, 'nx.json', validNxJson());
534
-
535
- expect(checkWorkspaceConfigTree(tree)).toEqual([]);
536
- });
537
- });
538
-
539
- describe('Tree: applyWorkspaceConfigTree', () => {
540
- it('returns false when nx.json missing', () => {
541
- const tree = createTreeWithEmptyWorkspace();
542
- tree.delete('nx.json');
543
- expect(applyWorkspaceConfigTree(tree)).toBe(false);
544
- });
545
-
546
- it('fixes missing plugins and writes back to tree', () => {
547
- const tree = createTreeWithEmptyWorkspace();
548
- writeJson(tree, 'nx.json', {
549
- plugins: [],
550
- targetDefaults: validTargetDefaults(),
551
- namedInputs: validNamedInputs(),
552
- });
553
-
554
- expect(applyWorkspaceConfigTree(tree)).toBe(true);
555
-
556
- const nxJson = readJson(tree, 'nx.json');
557
- const pluginNames = readPluginNames(nxJson.plugins);
558
- expect(pluginNames).not.toContain('@nx/js/typescript');
559
- expect(pluginNames).toContain('@smoothbricks/nx-plugin');
560
-
561
- // Tree version now passes check
562
- expect(checkWorkspaceConfigTree(tree)).toEqual([]);
563
- });
564
-
565
- it('preserves configured plugin options and filters in the real Nx tree through two updates', () => {
566
- const tree = createTreeWithEmptyWorkspace();
567
- const configured = {
568
- plugin: '@smoothbricks/nx-plugin',
569
- options: { custom: { owner: 'declared-owner', enabled: true } },
570
- include: ['packages/owned/**'],
571
- exclude: ['packages/foreign/**'],
572
- };
573
- const plugins = ['example:before', configured, 'example:after'];
574
- writeJson(tree, 'nx.json', { ...validNxJson(), plugins });
575
- const original = tree.read('nx.json', 'utf8');
576
- expect(applyWorkspaceConfigTree(tree)).toBe(false);
577
- expect(applyWorkspaceConfigTree(tree)).toBe(false);
578
- expect(tree.read('nx.json', 'utf8')).toBe(original);
579
- expect(readJson(tree, 'nx.json').plugins).toEqual(plugins);
580
- });
581
-
582
- it('does not serialize an unchanged raw JSONC configuration or remove its comments', () => {
583
- const tree = createTreeWithEmptyWorkspace();
584
- const configured = {
585
- plugin: '@smoothbricks/nx-plugin',
586
- options: { custom: { owner: 'declared-owner', enabled: true } },
587
- include: ['packages/owned/**'],
588
- exclude: ['packages/foreign/**'],
589
- };
590
- const raw = JSON.stringify({ ...validNxJson(), plugins: [configured] }, null, 2).replace(
591
- '"plugin":',
592
- '/* scoped plugin options must remain authored */ "plugin":',
593
- );
594
- tree.write('nx.json', `${raw}\n`);
595
- const original = tree.read('nx.json', 'utf8');
596
- expect(applyWorkspaceConfigTree(tree)).toBe(false);
597
- expect(applyWorkspaceConfigTree(tree)).toBe(false);
598
- expect(tree.read('nx.json', 'utf8')).toBe(original);
599
- });
600
-
601
- it('reports malformed plugin values and never replaces them with a default entry', () => {
602
- for (const plugins of [
603
- null,
604
- 'not-an-array',
605
- [{ plugin: 42 }],
606
- [{ plugin: '@smoothbricks/nx-plugin', include: 42 }],
607
- ]) {
608
- const nxJson = { ...validNxJson(), plugins };
609
- const original = JSON.stringify(plugins);
610
- expect(checkWorkspaceConfig(nxJson).some((issue) => issue.message.startsWith('plugins is malformed:'))).toBe(
611
- true,
612
- );
613
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
614
- expect(JSON.stringify(nxJson.plugins)).toBe(original);
615
- }
616
- });
617
-
618
- it('returns false when config already valid', () => {
619
- const tree = createTreeWithEmptyWorkspace();
620
- writeJson(tree, 'nx.json', validNxJson());
621
-
622
- expect(applyWorkspaceConfigTree(tree)).toBe(false);
623
- });
624
-
625
- it('fixes build target defaults via tree', () => {
626
- const tree = createTreeWithEmptyWorkspace();
627
- writeJson(tree, 'nx.json', {
628
- plugins: validPlugins(),
629
- targetDefaults: { build: { cache: false, outputs: ['{projectRoot}/dist'] } },
630
- namedInputs: validNamedInputs(),
631
- });
632
-
633
- expect(applyWorkspaceConfigTree(tree)).toBe(true);
634
-
635
- const nxJson = readJson(tree, 'nx.json');
636
- expect(expectRecord(nxJson.targetDefaults).build).toEqual({ cache: true });
637
- expect(expectRecord(nxJson.targetDefaults).clean).toEqual({
638
- executor: '@smoothbricks/nx-plugin:clean-outputs',
639
- cache: false,
640
- });
641
- });
642
- });
643
-
644
- // ---------------------------------------------------------------------------
645
- // Layer 3: Filesystem wrapper integration test
646
- // ---------------------------------------------------------------------------
647
-
648
- describe('filesystem: checkWorkspaceConfigPolicy / applyWorkspaceConfigPolicy', () => {
649
- it('round-trips check/apply on real temp directory', async () => {
650
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-ws-policy-'));
651
- try {
652
- await writeJsonFile(join(root, 'nx.json'), {
653
- plugins: [],
654
- targetDefaults: {
655
- build: { cache: false },
656
- 'typecheck-tests': {
657
- dependsOn: ['typecheck'],
658
- options: { command: 'ttsc -p tsconfig.test.json --noEmit' },
659
- },
660
- },
661
- namedInputs: validNamedInputs(),
662
- });
663
-
664
- const issues = checkWorkspaceConfigPolicy(root);
665
- expect(issues.length).toBeGreaterThan(0);
666
- // Filesystem wrapper uses absolute paths
667
- expect(issues[0].path).toBe(join(root, 'nx.json'));
668
-
669
- expect(applyWorkspaceConfigPolicy(root)).toBe(true);
670
-
671
- const nxJson = expectRecord(JSON.parse(await readFile(join(root, 'nx.json'), 'utf8')));
672
- const pluginNames = readPluginNames(nxJson.plugins);
673
- expect(pluginNames).not.toContain('@nx/js/typescript');
674
- expect(expectRecord(nxJson.targetDefaults)['typecheck-tests']).toBeUndefined();
675
- expect(nxJson.cacheDirectory).toBe('.nx/cache');
676
-
677
- // No issues after fix
678
- expect(checkWorkspaceConfigPolicy(root)).toEqual([]);
679
- expect(applyWorkspaceConfigPolicy(root)).toBe(false);
680
- } finally {
681
- await rm(root, { recursive: true, force: true });
682
- }
683
- });
684
-
685
- it('reports issue when nx.json is missing', async () => {
686
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-ws-policy-'));
687
- try {
688
- const issues = checkWorkspaceConfigPolicy(root);
689
- expect(issues).toHaveLength(1);
690
- expect(issues[0].message).toBe('nx.json not found or invalid');
691
-
692
- expect(applyWorkspaceConfigPolicy(root)).toBe(false);
693
- } finally {
694
- await rm(root, { recursive: true, force: true });
695
- }
696
- });
697
- });
698
-
699
- // ---------------------------------------------------------------------------
700
- // Test-local file helper (for filesystem integration tests only)
701
- // ---------------------------------------------------------------------------
702
-
703
- async function writeJsonFile(path: string, value: unknown): Promise<void> {
704
- await mkdir(dirname(path), { recursive: true });
705
- await writeFile(path, `${JSON.stringify(value, null, 2)}\n`);
706
- }
707
-
708
- function expectRecord(value: unknown): Record<string, unknown> {
709
- if (!isRecord(value)) {
710
- throw new Error('expected object');
711
- }
712
- return value;
713
- }
714
-
715
- function isRecord(value: unknown): value is Record<string, unknown> {
716
- return value !== null && typeof value === 'object' && !Array.isArray(value);
717
- }
718
-
719
- function readPluginNames(value: unknown): unknown[] {
720
- if (!Array.isArray(value)) {
721
- throw new Error('expected plugins array');
722
- }
723
- const plugins: unknown[] = value;
724
- return plugins.map((plugin) => (typeof plugin === 'string' ? plugin : expectRecord(plugin).plugin));
725
- }
726
-
727
- describe('managed-file sync registration', () => {
728
- it('preserves other generators and is idempotent', () => {
729
- const nxJson = { sync: { applyChanges: true, globalGenerators: ['example:sync'] } };
730
- applyWorkspaceConfig(nxJson);
731
- expect(nxJson.sync).toEqual({
732
- applyChanges: true,
733
- globalGenerators: ['example:sync', '@smoothbricks/nx-plugin:managed-files'],
734
- });
735
- expect(applyWorkspaceConfig(nxJson)).toBe(false);
736
- });
737
- });