@smoothbricks/nx-plugin 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/README.md +1086 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  62. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  63. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  64. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  65. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/executor.js +371 -239
  67. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  68. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  70. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  71. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  73. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  74. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  75. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  76. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  77. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  79. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  80. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  82. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  83. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  84. package/dist/executors/bounded-exec/progress.js +5 -2
  85. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  86. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  88. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  89. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  90. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  91. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  92. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  93. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  94. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  95. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  96. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  97. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  98. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  100. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  101. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  102. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  104. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  105. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  106. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  107. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  108. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  109. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  110. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  111. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  112. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  113. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  114. package/dist/executors/bounded-exec/verdict.js +88 -19
  115. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  116. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  117. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  118. package/dist/executors/clean-outputs/executor.js +1 -0
  119. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  120. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  121. package/dist/executors/scriptc-native/executor.js +367 -0
  122. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  123. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  124. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  125. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  126. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/schema.js +1 -0
  128. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  129. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  130. package/dist/executors/typescript-emit/executor.js +164 -33
  131. package/dist/forbidden-spelling-policy.d.ts +56 -0
  132. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  133. package/dist/forbidden-spelling-policy.js +176 -0
  134. package/dist/generators/create-package/generator.d.ts.map +1 -1
  135. package/dist/generators/create-package/generator.js +3 -4
  136. package/dist/graph-input-contract.d.ts +14 -0
  137. package/dist/graph-input-contract.d.ts.map +1 -1
  138. package/dist/graph-input-contract.js +67 -2
  139. package/dist/index.d.ts +23 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +672 -214
  142. package/dist/managed-assets.d.ts +2 -0
  143. package/dist/managed-assets.d.ts.map +1 -1
  144. package/dist/managed-files/files.d.ts +3 -3
  145. package/dist/managed-files/files.d.ts.map +1 -1
  146. package/dist/managed-files/files.js +28 -3
  147. package/dist/managed-files/managed-format.d.ts.map +1 -1
  148. package/dist/managed-files/managed-format.js +1 -0
  149. package/dist/nextest-code-bound.js +1 -0
  150. package/dist/nextest-timings.d.ts +35 -0
  151. package/dist/nextest-timings.d.ts.map +1 -0
  152. package/dist/nextest-timings.js +168 -0
  153. package/dist/owned-installation.d.ts +6 -5
  154. package/dist/owned-installation.d.ts.map +1 -1
  155. package/dist/owned-installation.js +150 -26
  156. package/dist/package-target-policy.d.ts.map +1 -1
  157. package/dist/package-target-policy.js +2 -3
  158. package/dist/process-children.d.ts +7 -0
  159. package/dist/process-children.d.ts.map +1 -0
  160. package/dist/process-children.darwin.d.ts +7 -0
  161. package/dist/process-children.darwin.d.ts.map +1 -0
  162. package/dist/process-children.darwin.js +13 -0
  163. package/dist/process-children.js +14 -0
  164. package/dist/process-children.linux.d.ts +8 -0
  165. package/dist/process-children.linux.d.ts.map +1 -0
  166. package/dist/process-children.linux.js +25 -0
  167. package/dist/process-group.d.ts +108 -0
  168. package/dist/process-group.d.ts.map +1 -0
  169. package/dist/process-group.js +171 -0
  170. package/dist/process-listing.d.ts +7 -0
  171. package/dist/process-listing.d.ts.map +1 -0
  172. package/dist/process-listing.js +51 -0
  173. package/dist/producer-receipts.d.ts +8 -2
  174. package/dist/producer-receipts.d.ts.map +1 -1
  175. package/dist/producer-receipts.js +75 -48
  176. package/dist/task-graph-policy.d.ts +21 -0
  177. package/dist/task-graph-policy.d.ts.map +1 -0
  178. package/dist/task-graph-policy.js +91 -0
  179. package/dist/test-timings.js +4 -4
  180. package/dist/test-walk-policy.d.ts +14 -5
  181. package/dist/test-walk-policy.d.ts.map +1 -1
  182. package/dist/test-walk-policy.js +8 -2
  183. package/dist/testing.d.ts +73 -28
  184. package/dist/testing.d.ts.map +1 -1
  185. package/dist/testing.js +217 -223
  186. package/dist/tool-bins.d.ts +33 -0
  187. package/dist/tool-bins.d.ts.map +1 -0
  188. package/dist/tool-bins.js +72 -0
  189. package/dist/typecheck-test-policy.d.ts.map +1 -1
  190. package/dist/typecheck-test-policy.js +3 -4
  191. package/dist/wait-why-policy.d.ts +28 -0
  192. package/dist/wait-why-policy.d.ts.map +1 -0
  193. package/dist/wait-why-policy.js +223 -0
  194. package/dist/workspace-config-policy.d.ts +14 -8
  195. package/dist/workspace-config-policy.d.ts.map +1 -1
  196. package/dist/workspace-config-policy.js +60 -16
  197. package/dist/workspace-manifest.d.ts +41 -6
  198. package/dist/workspace-manifest.d.ts.map +1 -1
  199. package/dist/workspace-manifest.js +57 -0
  200. package/executors.json +16 -1
  201. package/loader.js +2 -0
  202. package/managed/raw/envrc +11 -0
  203. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  204. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  205. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  206. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  207. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  208. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  209. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  210. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  211. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  212. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  213. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  214. package/managed/raw/tooling/direnv/repo-path +68 -6
  215. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  216. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  217. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  218. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  219. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  220. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  221. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  222. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  223. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  224. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  225. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  226. package/package.json +77 -13
  227. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  228. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  229. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  230. package/src/bounded-test-policy.ts +12 -14
  231. package/src/build-state-output-policy.ts +458 -34
  232. package/src/bun-lock-scope.ts +108 -0
  233. package/src/cargo-build-script-env.ts +265 -0
  234. package/src/cargo-closure-input.ts +74 -7
  235. package/src/cargo-retention-hook.ts +94 -0
  236. package/src/cargo-source-hash.ts +138 -41
  237. package/src/cargo-toolchain-paths.ts +95 -0
  238. package/src/cargo-toolchain-policy.ts +49 -5
  239. package/src/cargo-workspace.ts +72 -123
  240. package/src/cross-check-policy.ts +12 -10
  241. package/src/disk-command-policy.ts +1 -0
  242. package/src/ensure-built-receipt.ts +132 -39
  243. package/src/ensure-built-witness.ts +62 -10
  244. package/src/ensure-built.ts +11 -1
  245. package/src/eslint-config-closure.ts +357 -0
  246. package/src/executors/bounded-exec/bounds.ts +76 -0
  247. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  248. package/src/executors/bounded-exec/executor.ts +423 -259
  249. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  250. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  251. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  252. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  253. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  254. package/src/executors/bounded-exec/progress.ts +9 -3
  255. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  256. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  257. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  258. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  259. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  260. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  261. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  262. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  263. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  264. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  265. package/src/executors/bounded-exec/schema.json +11 -2
  266. package/src/executors/bounded-exec/schema.ts +19 -1
  267. package/src/executors/bounded-exec/verdict.ts +137 -34
  268. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  269. package/src/executors/clean-outputs/executor.ts +1 -0
  270. package/src/executors/scriptc-native/executor.ts +394 -0
  271. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  272. package/src/executors/scriptc-native/schema.json +60 -0
  273. package/src/executors/scriptc-native/schema.ts +34 -0
  274. package/src/executors/typescript-emit/executor.ts +205 -38
  275. package/src/forbidden-spelling-policy.ts +226 -0
  276. package/src/generators/create-package/generator.ts +7 -7
  277. package/src/graph-input-contract.ts +61 -2
  278. package/src/index.ts +788 -224
  279. package/src/managed-assets.ts +3 -0
  280. package/src/managed-files/files.ts +28 -3
  281. package/src/managed-files/managed-format.ts +1 -0
  282. package/src/nextest-code-bound.ts +1 -0
  283. package/src/nextest-timings.ts +106 -0
  284. package/src/owned-installation.ts +150 -23
  285. package/src/package-target-policy.ts +2 -3
  286. package/src/process-children.darwin.ts +14 -0
  287. package/src/process-children.linux.ts +33 -0
  288. package/src/process-children.ts +22 -0
  289. package/src/process-group.ts +209 -0
  290. package/src/process-listing.ts +54 -0
  291. package/src/producer-receipts.ts +68 -45
  292. package/src/task-graph-policy.ts +98 -0
  293. package/src/test-walk-policy.ts +23 -8
  294. package/src/testing.ts +240 -232
  295. package/src/tool-bins.ts +108 -0
  296. package/src/typecheck-test-policy.ts +2 -3
  297. package/src/wait-why-policy.ts +226 -0
  298. package/src/workspace-config-policy.ts +63 -15
  299. package/src/workspace-manifest.ts +89 -6
  300. package/test-timings.json +122 -98
  301. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  302. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  303. package/dist/bin/smoo-nx-failures.js +0 -3
  304. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  305. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  306. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  307. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  308. package/dist/failure-summary.d.ts +0 -5
  309. package/dist/failure-summary.d.ts.map +0 -1
  310. package/dist/failure-summary.js +0 -118
  311. package/dist/nextest-extraction.d.ts +0 -117
  312. package/dist/nextest-extraction.d.ts.map +0 -1
  313. package/dist/nextest-extraction.js +0 -303
  314. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  315. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  316. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  317. package/src/__tests__/counted-cargo-process.ts +0 -286
  318. package/src/__tests__/counted-cargo.ts +0 -713
  319. package/src/__tests__/directory-change.ts +0 -27
  320. package/src/__tests__/fixture-cargo-home.ts +0 -36
  321. package/src/__tests__/fixture-nx-env.ts +0 -193
  322. package/src/__tests__/owned-installation.ts +0 -13
  323. package/src/__tests__/past-tick.ts +0 -12
  324. package/src/__tests__/progress-clock.ts +0 -43
  325. package/src/__tests__/runtime-input.ts +0 -23
  326. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  327. package/src/bin/smoo-nx-failures.ts +0 -4
  328. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  329. package/src/bounded-test-policy.test.ts +0 -1029
  330. package/src/build-state-output-policy.test.ts +0 -115
  331. package/src/bun-bootstrap.test.ts +0 -102
  332. package/src/bun-file-packages.test.ts +0 -47
  333. package/src/cargo-closure-filesets.test.ts +0 -63
  334. package/src/cargo-closure-input.property.test.ts +0 -50
  335. package/src/cargo-closure-input.test.ts +0 -506
  336. package/src/cargo-closure-key.test.ts +0 -240
  337. package/src/cargo-resolve-cache.test.ts +0 -1181
  338. package/src/cargo-source-hash.test.ts +0 -707
  339. package/src/cargo-workspace.test.ts +0 -615
  340. package/src/cross-check-policy.test.ts +0 -316
  341. package/src/disk-command-policy.test.ts +0 -61
  342. package/src/ensure-built-receipt.test.ts +0 -279
  343. package/src/ensure-built-witness.test.ts +0 -688
  344. package/src/ensure-built.test.ts +0 -1462
  345. package/src/executors/all-verdicts/executor.test.ts +0 -135
  346. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  347. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  348. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  349. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  350. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  351. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  352. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  353. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  354. package/src/executors/bounded-exec/progress.test.ts +0 -139
  355. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  356. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  357. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  358. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  359. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  360. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  361. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  362. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  363. package/src/executors/clean-outputs/executor.test.ts +0 -20
  364. package/src/executors/typescript-emit/executor.test.ts +0 -83
  365. package/src/failure-summary.ts +0 -119
  366. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  367. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  368. package/src/generators/create-package/generator.test.ts +0 -190
  369. package/src/generators/make-public/generator.test.ts +0 -137
  370. package/src/graph-input-contract.test.ts +0 -379
  371. package/src/host-controller-wiring.test.ts +0 -31
  372. package/src/index.test.ts +0 -3321
  373. package/src/linked-snapshots.nx.test.ts +0 -254
  374. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  375. package/src/managed-files/generator.test.ts +0 -243
  376. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  377. package/src/managed-files/json-edit.test.ts +0 -216
  378. package/src/managed-files/managed-content.test.ts +0 -166
  379. package/src/managed-files/managed-format-json.test.ts +0 -308
  380. package/src/managed-files/repo-path.test.ts +0 -172
  381. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  382. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  383. package/src/managed-files/tree-permissions.test.ts +0 -109
  384. package/src/managed-files/tree.test.ts +0 -123
  385. package/src/manifest-hash.test.ts +0 -219
  386. package/src/nextest-code-bound.test.ts +0 -161
  387. package/src/nextest-extraction.test.ts +0 -216
  388. package/src/nextest-extraction.ts +0 -371
  389. package/src/nextest-partitions.test.ts +0 -501
  390. package/src/nx-cache-bound.test.ts +0 -109
  391. package/src/nx-cache-restore-mtime.test.ts +0 -170
  392. package/src/nx-daemon-claim.test.ts +0 -279
  393. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  394. package/src/nx-daemon-idle-policy.test.ts +0 -111
  395. package/src/nx-daemon-ignore-files.test.ts +0 -210
  396. package/src/nx-daemon-root-normalization.test.ts +0 -105
  397. package/src/nx-daemon-start-never.test.ts +0 -292
  398. package/src/nx-daemon-validity.test.ts +0 -1055
  399. package/src/nx-dot-input-policy.test.ts +0 -353
  400. package/src/nx-failure-life-cycles.test.ts +0 -207
  401. package/src/nx-files-archive-racy.test.ts +0 -97
  402. package/src/nx-foreign-workspace-env.test.ts +0 -329
  403. package/src/nx-incomplete-run-summary.test.ts +0 -70
  404. package/src/nx-plugin-load-errors.test.ts +0 -120
  405. package/src/nx-project-graph-errors.test.ts +0 -70
  406. package/src/nx-project-resolution-cache.test.ts +0 -176
  407. package/src/nx-raw-inputs.test.ts +0 -166
  408. package/src/nx-resident-graph-workers.test.ts +0 -112
  409. package/src/nx-run-information.test.ts +0 -118
  410. package/src/nx-skipped-task-exit.test.ts +0 -180
  411. package/src/nx-state-location.test.ts +0 -63
  412. package/src/nx-store-resolution.test.ts +0 -81
  413. package/src/nx-task-graph-cycles.test.ts +0 -148
  414. package/src/nx-task-output-lease.test.ts +0 -550
  415. package/src/nx-use-local.test.ts +0 -105
  416. package/src/owned-installation.test.ts +0 -105
  417. package/src/package-target-policy.test.ts +0 -1014
  418. package/src/producer-receipts.test.ts +0 -285
  419. package/src/release-config-policy.test.ts +0 -311
  420. package/src/runtime-input.test.ts +0 -393
  421. package/src/serial-group-wiring.test.ts +0 -326
  422. package/src/task-history-namespace.test.ts +0 -181
  423. package/src/task-results.test.ts +0 -228
  424. package/src/test-clock-policy.test.ts +0 -338
  425. package/src/test-program.test.ts +0 -303
  426. package/src/test-timings.test.ts +0 -240
  427. package/src/test-walk-policy.test.ts +0 -620
  428. package/src/testing.test.ts +0 -509
  429. package/src/typecheck-test-policy.test.ts +0 -1468
  430. package/src/typescript-resolution.test.ts +0 -76
  431. package/src/version-actions.test.ts +0 -80
  432. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,1014 +0,0 @@
1
- import { beforeEach, 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 { addProjectConfiguration, readJson, type Tree } from 'nx/src/devkit-exports.js';
7
- import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports.js';
8
-
9
- import {
10
- applyPackageTargetPolicy,
11
- applyPackageTargetPolicyTree,
12
- applyPackageTargets,
13
- checkPackageTargetPolicy,
14
- checkPackageTargetPolicyTree,
15
- checkPackageTargets,
16
- nxRunAlias,
17
- packageNxProjectName,
18
- type ResolvedProjectTargets,
19
- } from './package-target-policy.js';
20
-
21
- describe('package target policy', () => {
22
- it('rejects colon-style package Nx targets', async () => {
23
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
24
- try {
25
- await writeJson(join(root, 'package.json'), {
26
- name: '@scope/root',
27
- private: true,
28
- workspaces: ['packages/*'],
29
- });
30
- await writeJson(join(root, 'packages/app/package.json'), {
31
- name: '@scope/app',
32
- nx: {
33
- name: 'app',
34
- targets: {
35
- 'build:ts': {
36
- executor: 'nx:run-commands',
37
- options: { command: 'tsc --build tsconfig.lib.json', cwd: '{projectRoot}' },
38
- },
39
- 'lint:fix': {
40
- executor: 'nx:run-commands',
41
- options: { command: 'biome check --apply', cwd: '{projectRoot}' },
42
- },
43
- },
44
- },
45
- });
46
-
47
- const issues = checkPackageTargetPolicy(root);
48
- expect(issues.length).toBeGreaterThanOrEqual(2);
49
- expect(issues.some((i) => i.message.includes('build:ts') && i.message.includes('colon target names'))).toBe(true);
50
- expect(issues.some((i) => i.message.includes('lint:fix') && i.message.includes('colon target names'))).toBe(true);
51
- } finally {
52
- await rm(root, { recursive: true, force: true });
53
- }
54
- });
55
-
56
- it('migrates colon build targets to tool-output names', async () => {
57
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
58
- try {
59
- await writeJson(join(root, 'package.json'), {
60
- name: '@scope/root',
61
- private: true,
62
- workspaces: ['packages/*'],
63
- });
64
- await writeJson(join(root, 'packages/lib/package.json'), {
65
- name: '@scope/lib',
66
- dependencies: { '@scope/other': 'workspace:*' },
67
- scripts: {
68
- 'build:ts': 'nx run lib:build:ts',
69
- },
70
- nx: {
71
- name: 'lib',
72
- targets: {
73
- 'build:ts': {
74
- executor: 'nx:run-commands',
75
- options: { command: 'tsc --build tsconfig.lib.json', cwd: '{projectRoot}' },
76
- },
77
- build: {
78
- executor: 'nx:noop',
79
- dependsOn: ['^build', 'build:ts'],
80
- },
81
- },
82
- },
83
- });
84
- await writeJson(join(root, 'packages/other/package.json'), {
85
- name: '@scope/other',
86
- });
87
-
88
- expect(applyPackageTargetPolicy(root)).toBe(true);
89
-
90
- const lib = JSON.parse(await readFile(join(root, 'packages/lib/package.json'), 'utf8'));
91
- const targets = lib.nx.targets;
92
- // build:ts should be renamed to tsc-js
93
- expect(targets['build:ts']).toBeUndefined();
94
- expect(targets['tsc-js']).toBeDefined();
95
- expect(targets['tsc-js'].options.command).toBe('tsc --build tsconfig.lib.json');
96
- // dependsOn in build target should be updated
97
- expect(targets.build.dependsOn).toContain('tsc-js');
98
- expect(targets.build.dependsOn).not.toContain('build:ts');
99
- // scripts should be updated
100
- expect(lib.scripts['build:ts']).toBe('nx run lib:tsc-js');
101
- } finally {
102
- await rm(root, { recursive: true, force: true });
103
- }
104
- });
105
-
106
- it('preserves cross-project dependsOn references in apply and check', async () => {
107
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
108
- try {
109
- await writeJson(join(root, 'package.json'), {
110
- name: '@scope/root',
111
- private: true,
112
- workspaces: ['packages/*'],
113
- });
114
- await writeJson(join(root, 'packages/lib/package.json'), {
115
- name: '@scope/lib',
116
- dependencies: { '@scope/schema': 'workspace:*' },
117
- nx: {
118
- name: 'lib',
119
- targets: {
120
- // `wire-schema:build` is Nx's project:target syntax pointing at a real
121
- // sibling project; only its suffix collides with this project's own
122
- // `build`, which is exactly what the legacy colon-name migration used
123
- // to swallow.
124
- build: {
125
- executor: 'nx:run-commands',
126
- options: { command: 'tsc --build tsconfig.lib.json', cwd: '{projectRoot}' },
127
- dependsOn: ['^build', 'wire-schema:build'],
128
- },
129
- },
130
- },
131
- });
132
- await writeJson(join(root, 'packages/schema/package.json'), {
133
- name: '@scope/schema',
134
- nx: {
135
- name: 'wire-schema',
136
- targets: {
137
- build: {
138
- executor: 'nx:run-commands',
139
- options: { command: 'bun run emit.ts', cwd: '{projectRoot}' },
140
- },
141
- },
142
- },
143
- });
144
-
145
- applyPackageTargetPolicy(root);
146
-
147
- const lib = JSON.parse(await readFile(join(root, 'packages/lib/package.json'), 'utf8'));
148
- expect(lib.nx.targets.build.dependsOn).toEqual(['^build', 'wire-schema:build']);
149
- const issues = checkPackageTargetPolicy(root);
150
- expect(issues.filter((issue) => issue.message.includes('wire-schema:build'))).toEqual([]);
151
- } finally {
152
- await rm(root, { recursive: true, force: true });
153
- }
154
- });
155
-
156
- it('removes noop aggregate build targets matching resolved plugin output', async () => {
157
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
158
- try {
159
- await writeJson(join(root, 'package.json'), {
160
- name: '@scope/root',
161
- private: true,
162
- workspaces: ['packages/*'],
163
- });
164
- await writeJson(join(root, 'packages/lib/package.json'), {
165
- name: '@scope/lib',
166
- nx: {
167
- name: 'lib',
168
- targets: {
169
- build: {
170
- executor: 'nx:noop',
171
- dependsOn: ['^build', '*-js'],
172
- },
173
- },
174
- },
175
- });
176
-
177
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
178
- ['lib', { targets: new Set(['build', 'tsc-js']) }],
179
- ]);
180
-
181
- expect(applyPackageTargetPolicy(root, { resolvedTargetsByProject })).toBe(true);
182
-
183
- const lib = JSON.parse(await readFile(join(root, 'packages/lib/package.json'), 'utf8'));
184
- expect(lib.nx.targets.build).toBeUndefined();
185
- } finally {
186
- await rm(root, { recursive: true, force: true });
187
- }
188
- });
189
-
190
- it('keeps non-noop build targets even when dependsOn matches', async () => {
191
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
192
- try {
193
- await writeJson(join(root, 'package.json'), {
194
- name: '@scope/root',
195
- private: true,
196
- workspaces: ['packages/*'],
197
- });
198
- await writeJson(join(root, 'packages/lib/package.json'), {
199
- name: '@scope/lib',
200
- nx: {
201
- name: 'lib',
202
- targets: {
203
- build: {
204
- executor: 'nx:run-commands',
205
- dependsOn: ['^build', '*-js'],
206
- options: { command: 'echo build', cwd: '{projectRoot}' },
207
- },
208
- },
209
- },
210
- });
211
-
212
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
213
- ['lib', { targets: new Set(['build', 'tsc-js']) }],
214
- ]);
215
-
216
- expect(applyPackageTargetPolicy(root, { resolvedTargetsByProject })).toBe(false);
217
-
218
- const lib = JSON.parse(await readFile(join(root, 'packages/lib/package.json'), 'utf8'));
219
- expect(lib.nx.targets.build).toBeDefined();
220
- expect(lib.nx.targets.build.options.command).toBe('echo build');
221
- } finally {
222
- await rm(root, { recursive: true, force: true });
223
- }
224
- });
225
-
226
- it('rewrites safe scripts into Nx aliases', async () => {
227
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
228
- try {
229
- await writeJson(join(root, 'package.json'), {
230
- name: '@scope/root',
231
- private: true,
232
- workspaces: ['packages/*'],
233
- });
234
- await writeJson(join(root, 'packages/web/package.json'), {
235
- name: '@scope/web',
236
- dependencies: { '@scope/lib': 'workspace:*' },
237
- scripts: {
238
- dev: 'astro dev',
239
- build: 'astro build',
240
- },
241
- nx: { name: 'web' },
242
- });
243
- await writeJson(join(root, 'packages/lib/package.json'), {
244
- name: '@scope/lib',
245
- });
246
-
247
- expect(applyPackageTargetPolicy(root)).toBe(true);
248
-
249
- const web = JSON.parse(await readFile(join(root, 'packages/web/package.json'), 'utf8'));
250
- // Vite/Astro dev servers render best with dynamic legacy output.
251
- expect(web.scripts.dev).toBe('nx run web:dev --outputStyle=dynamic-legacy');
252
- // build script should become an Nx alias without streaming flags
253
- expect(web.scripts.build).toBe('nx run web:build');
254
- // nx.targets.dev should be created with continuous flag
255
- expect(web.nx.targets.dev.continuous).toBe(true);
256
- expect(web.nx.targets.dev.executor).toBe('nx:run-commands');
257
- expect(web.nx.targets.dev.options.command).toBe('astro dev');
258
- // nx.targets.build should be created
259
- expect(web.nx.targets.build.executor).toBe('nx:run-commands');
260
- expect(web.nx.targets.build.options.command).toBe('astro build');
261
- } finally {
262
- await rm(root, { recursive: true, force: true });
263
- }
264
- });
265
-
266
- it('rejects recursive script commands', async () => {
267
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
268
- try {
269
- await writeJson(join(root, 'package.json'), {
270
- name: '@scope/root',
271
- private: true,
272
- workspaces: ['packages/*'],
273
- });
274
- await writeJson(join(root, 'packages/app/package.json'), {
275
- name: '@scope/app',
276
- dependencies: { '@scope/lib': 'workspace:*' },
277
- scripts: {
278
- dev: 'nx run app:dev --outputStyle=stream',
279
- },
280
- nx: {
281
- name: 'app',
282
- targets: {
283
- dev: {
284
- executor: 'nx:run-commands',
285
- dependsOn: ['^build'],
286
- continuous: true,
287
- options: { command: 'bun run dev', cwd: '{projectRoot}' },
288
- },
289
- },
290
- },
291
- });
292
- await writeJson(join(root, 'packages/lib/package.json'), {
293
- name: '@scope/lib',
294
- });
295
-
296
- const issues = checkPackageTargetPolicy(root);
297
- expect(issues.some((i) => i.message.includes('options.command must not call scripts.dev'))).toBe(true);
298
- } finally {
299
- await rm(root, { recursive: true, force: true });
300
- }
301
- });
302
-
303
- it('removes self-recursive scripts using resolved Nx target metadata', async () => {
304
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
305
- try {
306
- await writeJson(join(root, 'package.json'), {
307
- name: '@scope/root',
308
- private: true,
309
- workspaces: ['packages/*'],
310
- });
311
- await writeJson(join(root, 'packages/app/package.json'), {
312
- name: '@scope/app',
313
- dependencies: { '@scope/lib': 'workspace:*' },
314
- scripts: {
315
- build: 'nx run app:build',
316
- test: 'bun test',
317
- },
318
- nx: {
319
- name: 'app',
320
- targets: {
321
- 'tsdown-js': {
322
- executor: 'nx:run-commands',
323
- options: { command: 'tsdown', cwd: '{projectRoot}' },
324
- },
325
- },
326
- },
327
- });
328
- await writeJson(join(root, 'packages/lib/package.json'), {
329
- name: '@scope/lib',
330
- });
331
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
332
- [
333
- 'app',
334
- {
335
- targets: new Set(['build', 'test', 'tsdown-js']),
336
- targetExecutors: new Map([
337
- ['build', 'nx:run-script'],
338
- ['test', 'nx:run-script'],
339
- ['tsdown-js', 'nx:run-commands'],
340
- ]),
341
- targetScripts: new Map([
342
- ['build', 'build'],
343
- ['test', 'test'],
344
- ]),
345
- },
346
- ],
347
- ]);
348
-
349
- const issues = checkPackageTargetPolicy(root, { resolvedTargetsByProject });
350
- expect(issues.some((i) => i.message.includes('scripts.build recursively delegates'))).toBe(true);
351
- expect(applyPackageTargetPolicy(root, { resolvedTargetsByProject })).toBe(true);
352
-
353
- const app = JSON.parse(await readFile(join(root, 'packages/app/package.json'), 'utf8'));
354
- expect(app.scripts.build).toBeUndefined();
355
- expect(app.scripts.test).toBe('bun test');
356
- } finally {
357
- await rm(root, { recursive: true, force: true });
358
- }
359
- });
360
-
361
- it('keeps self-alias scripts when resolved target comes from project configuration', async () => {
362
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
363
- try {
364
- await writeJson(join(root, 'package.json'), {
365
- name: '@scope/root',
366
- private: true,
367
- workspaces: ['packages/*'],
368
- });
369
- await writeJson(join(root, 'packages/app/package.json'), {
370
- name: '@scope/app',
371
- dependencies: { '@scope/lib': 'workspace:*' },
372
- scripts: {
373
- build: 'nx run app:build',
374
- },
375
- nx: { name: 'app' },
376
- });
377
- await writeJson(join(root, 'packages/lib/package.json'), {
378
- name: '@scope/lib',
379
- });
380
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
381
- [
382
- 'app',
383
- {
384
- targets: new Set(['build']),
385
- targetExecutors: new Map([['build', 'nx:run-commands']]),
386
- },
387
- ],
388
- ]);
389
-
390
- expect(applyPackageTargetPolicy(root, { resolvedTargetsByProject })).toBe(false);
391
-
392
- const app = JSON.parse(await readFile(join(root, 'packages/app/package.json'), 'utf8'));
393
- expect(app.scripts.build).toBe('nx run app:build');
394
- } finally {
395
- await rm(root, { recursive: true, force: true });
396
- }
397
- });
398
-
399
- it('accepts stream output style on non-continuous nx aliases', async () => {
400
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
401
- try {
402
- await writeJson(join(root, 'package.json'), {
403
- name: '@scope/root',
404
- private: true,
405
- workspaces: ['packages/*'],
406
- });
407
- await writeJson(join(root, 'packages/app/package.json'), {
408
- name: '@scope/app',
409
- dependencies: { '@scope/lib': 'workspace:*' },
410
- scripts: {
411
- deploy: 'nx run app:deploy:production --outputStyle=stream',
412
- },
413
- nx: {
414
- name: 'app',
415
- targets: {
416
- deploy: {
417
- executor: 'nx:run-commands',
418
- options: { command: 'wrangler deploy --env production', cwd: '{projectRoot}' },
419
- configurations: {
420
- production: { command: 'wrangler deploy --env production' },
421
- },
422
- },
423
- },
424
- },
425
- });
426
- await writeJson(join(root, 'packages/lib/package.json'), {
427
- name: '@scope/lib',
428
- });
429
-
430
- const issues = checkPackageTargetPolicy(root);
431
- expect(issues.some((i) => i.message.includes('scripts.deploy must delegate'))).toBe(false);
432
- expect(applyPackageTargetPolicy(root)).toBe(false);
433
- } finally {
434
- await rm(root, { recursive: true, force: true });
435
- }
436
- });
437
-
438
- it('moves env assignments into target options', async () => {
439
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
440
- try {
441
- await writeJson(join(root, 'package.json'), {
442
- name: '@scope/root',
443
- private: true,
444
- workspaces: ['packages/*'],
445
- });
446
- await writeJson(join(root, 'packages/web/package.json'), {
447
- name: '@scope/web',
448
- dependencies: { '@scope/lib': 'workspace:*' },
449
- scripts: {
450
- dev: "NODE_OPTIONS='--max-old-space-size=4096' astro dev",
451
- },
452
- nx: { name: 'web' },
453
- });
454
- await writeJson(join(root, 'packages/lib/package.json'), {
455
- name: '@scope/lib',
456
- });
457
-
458
- expect(applyPackageTargetPolicy(root)).toBe(true);
459
-
460
- const web = JSON.parse(await readFile(join(root, 'packages/web/package.json'), 'utf8'));
461
- expect(web.nx.targets.dev.options.command).toBe('astro dev');
462
- expect(web.nx.targets.dev.options.env).toEqual({ NODE_OPTIONS: '--max-old-space-size=4096' });
463
- } finally {
464
- await rm(root, { recursive: true, force: true });
465
- }
466
- });
467
-
468
- it('requires test entrypoint when test files exist', async () => {
469
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
470
- try {
471
- await writeJson(join(root, 'package.json'), {
472
- name: '@scope/root',
473
- private: true,
474
- workspaces: ['packages/*'],
475
- });
476
- const pkgDir = join(root, 'packages/lib');
477
- const srcDir = join(pkgDir, 'src');
478
- await mkdir(srcDir, { recursive: true });
479
- await writeJson(join(pkgDir, 'package.json'), {
480
- name: '@scope/lib',
481
- nx: { name: 'lib' },
482
- });
483
- // Create a test file without a scripts.test entry
484
- await writeFile(join(srcDir, 'example.test.ts'), 'import { test } from "bun:test";\n');
485
-
486
- const issues = checkPackageTargetPolicy(root);
487
- expect(issues.some((i) => i.message.includes('test files require scripts.test or nx.targets.test'))).toBe(true);
488
- } finally {
489
- await rm(root, { recursive: true, force: true });
490
- }
491
- });
492
-
493
- it('accepts wildcard aggregate build dependencies', async () => {
494
- const root = await mkdtemp(join(tmpdir(), 'smoothbricks-pkg-target-'));
495
- try {
496
- await writeJson(join(root, 'package.json'), {
497
- name: '@scope/root',
498
- private: true,
499
- workspaces: ['packages/*'],
500
- });
501
- await writeJson(join(root, 'packages/lib/package.json'), {
502
- name: '@scope/lib',
503
- nx: {
504
- name: 'lib',
505
- targets: {
506
- build: {
507
- executor: 'nx:noop',
508
- dependsOn: ['^build', '*-js', '*-wasm'],
509
- },
510
- },
511
- },
512
- });
513
-
514
- const issues = checkPackageTargetPolicy(root);
515
- // No issue about missing targets for wildcard dependencies
516
- const buildIssues = issues.filter((i) => i.message.includes('dependsOn references missing target'));
517
- expect(buildIssues).toEqual([]);
518
- } finally {
519
- await rm(root, { recursive: true, force: true });
520
- }
521
- });
522
- });
523
-
524
- describe('per-package checkPackageTargets', () => {
525
- it('detects colon target names', () => {
526
- const pkg = {
527
- nx: {
528
- name: 'lib',
529
- targets: {
530
- 'build:ts': { executor: 'nx:run-commands', options: { command: 'tsc' } },
531
- },
532
- },
533
- };
534
- const issues = checkPackageTargets(pkg, 'packages/lib');
535
- expect(issues.some((i) => i.message.includes('build:ts') && i.message.includes('colon'))).toBe(true);
536
- });
537
-
538
- it('accepts the Nx inferred-target merge marker', () => {
539
- const pkg = {
540
- nx: {
541
- name: 'lib',
542
- targets: {
543
- build: { dependsOn: ['...', 'rust-dist'] },
544
- },
545
- },
546
- };
547
-
548
- expect(checkPackageTargets(pkg, 'packages/lib', new Set(['build', 'rust-dist']))).toEqual([]);
549
- });
550
- });
551
-
552
- describe('per-package applyPackageTargets', () => {
553
- it('limits JavaScript output targets to dependency JavaScript outputs', () => {
554
- const pkg: Record<string, unknown> = {
555
- name: '@scope/lib',
556
- dependencies: { '@scope/other': 'workspace:*' },
557
- scripts: { compile: 'tsdown' },
558
- nx: { name: 'lib' },
559
- };
560
- const workspaceNames = new Set(['@scope/lib', '@scope/other']);
561
-
562
- expect(applyPackageTargets(pkg, 'packages/lib', workspaceNames)).toBe(true);
563
- const nx = pkg.nx;
564
- if (!isRecord(nx) || !isRecord(nx.targets) || !isRecord(nx.targets['tsdown-js'])) {
565
- throw new Error('expected generated tsdown-js target');
566
- }
567
- expect(nx.targets['tsdown-js'].dependsOn).toEqual(['^*-js']);
568
- });
569
-
570
- it('migrates colon targets and rewrites scripts', () => {
571
- const pkg: Record<string, unknown> = {
572
- name: '@scope/lib',
573
- dependencies: { '@scope/other': 'workspace:*' },
574
- scripts: {
575
- 'build:ts': 'nx run lib:build:ts',
576
- },
577
- nx: {
578
- name: 'lib',
579
- targets: {
580
- 'build:ts': {
581
- executor: 'nx:run-commands',
582
- options: { command: 'tsc --build tsconfig.lib.json', cwd: '{projectRoot}' },
583
- },
584
- },
585
- },
586
- };
587
- const workspaceNames = new Set(['@scope/lib', '@scope/other']);
588
- expect(applyPackageTargets(pkg, 'packages/lib', workspaceNames)).toBe(true);
589
- const nx = pkg.nx;
590
- if (!isRecord(nx) || !isRecord(nx.targets)) {
591
- throw new Error('expected generated Nx targets');
592
- }
593
- const targets = nx.targets;
594
- expect(targets['build:ts']).toBeUndefined();
595
- expect(targets['tsc-js']).toBeDefined();
596
- });
597
- });
598
-
599
- describe('nxRunAlias', () => {
600
- it('generates streaming flags for continuous targets', () => {
601
- expect(nxRunAlias('app', 'dev', true)).toBe('nx run app:dev --outputStyle=stream');
602
- });
603
-
604
- it('uses dynamic legacy output for Astro and Vite dev targets', () => {
605
- expect(nxRunAlias('app', 'dev', true, 'astro dev')).toBe('nx run app:dev --outputStyle=dynamic-legacy');
606
- expect(nxRunAlias('app', 'serve', true, 'vite dev --host 0.0.0.0')).toBe(
607
- 'nx run app:serve --outputStyle=dynamic-legacy',
608
- );
609
- });
610
-
611
- it('generates plain alias for non-continuous targets', () => {
612
- expect(nxRunAlias('app', 'build', false)).toBe('nx run app:build');
613
- });
614
-
615
- it('delegates test targets to boundedTestScriptAlias', () => {
616
- expect(nxRunAlias('app', 'test', false)).toBe('nx run app:test --outputStyle=stream');
617
- });
618
- });
619
-
620
- describe('packageNxProjectName', () => {
621
- it('returns nx.name when present', () => {
622
- expect(packageNxProjectName({ nx: { name: 'my-lib' } })).toBe('my-lib');
623
- });
624
-
625
- it('falls back to package name', () => {
626
- expect(packageNxProjectName({ name: '@scope/my-lib' })).toBe('@scope/my-lib');
627
- });
628
-
629
- it('returns null for anonymous packages', () => {
630
- expect(packageNxProjectName({})).toBeNull();
631
- });
632
- });
633
-
634
- // ---------------------------------------------------------------------------
635
- // Tree-based tests
636
- // ---------------------------------------------------------------------------
637
-
638
- function addProject(tree: Tree, name: string, root: string, options: { keepProjectJson?: boolean } = {}): void {
639
- addProjectConfiguration(tree, name, {
640
- root,
641
- sourceRoot: `${root}/src`,
642
- projectType: 'library',
643
- targets: {},
644
- });
645
- if (!options.keepProjectJson && tree.exists(`${root}/project.json`)) {
646
- tree.delete(`${root}/project.json`);
647
- }
648
- }
649
-
650
- function writeJsonFile(tree: Tree, filePath: string, value: unknown): void {
651
- tree.write(filePath, `${JSON.stringify(value, null, 2)}\n`);
652
- }
653
-
654
- describe('checkPackageTargetPolicyTree', () => {
655
- let tree: Tree;
656
-
657
- beforeEach(() => {
658
- tree = createTreeWithEmptyWorkspace();
659
- });
660
-
661
- it('detects colon-style Nx targets', () => {
662
- addProject(tree, 'app', 'packages/app');
663
- writeJsonFile(tree, 'packages/app/package.json', {
664
- name: '@scope/app',
665
- nx: {
666
- name: 'app',
667
- targets: {
668
- 'build:ts': {
669
- executor: 'nx:run-commands',
670
- options: { command: 'tsc --build tsconfig.lib.json', cwd: '{projectRoot}' },
671
- },
672
- 'lint:fix': {
673
- executor: 'nx:run-commands',
674
- options: { command: 'biome check --apply', cwd: '{projectRoot}' },
675
- },
676
- },
677
- },
678
- });
679
-
680
- const issues = checkPackageTargetPolicyTree(tree);
681
- expect(issues.length).toBeGreaterThanOrEqual(2);
682
- expect(issues.some((i) => i.message.includes('build:ts') && i.message.includes('colon target names'))).toBe(true);
683
- expect(issues.some((i) => i.message.includes('lint:fix') && i.message.includes('colon target names'))).toBe(true);
684
- });
685
-
686
- it('requires test entrypoint when test files exist', () => {
687
- addProject(tree, 'lib', 'packages/lib');
688
- writeJsonFile(tree, 'packages/lib/package.json', {
689
- name: '@scope/lib',
690
- nx: { name: 'lib' },
691
- });
692
- tree.write('packages/lib/src/example.test.ts', 'import { test } from "bun:test";\n');
693
-
694
- const issues = checkPackageTargetPolicyTree(tree);
695
- expect(issues.some((i) => i.message.includes('test files require scripts.test or nx.targets.test'))).toBe(true);
696
- });
697
-
698
- it('accepts packages with test entrypoint', () => {
699
- addProject(tree, 'lib', 'packages/lib');
700
- writeJsonFile(tree, 'packages/lib/package.json', {
701
- name: '@scope/lib',
702
- scripts: { test: 'bun test' },
703
- nx: { name: 'lib' },
704
- });
705
- tree.write('packages/lib/src/example.test.ts', 'import { test } from "bun:test";\n');
706
-
707
- const issues = checkPackageTargetPolicyTree(tree);
708
- expect(issues.filter((i) => i.message.includes('test files require'))).toEqual([]);
709
- });
710
-
711
- it('does not read test files out of build output or dot-directories', () => {
712
- addProject(tree, 'lib', 'packages/lib');
713
- writeJsonFile(tree, 'packages/lib/package.json', {
714
- name: '@scope/lib',
715
- nx: { name: 'lib' },
716
- });
717
- // Stale emit, cargo's tree and a runtime cache all carry test-shaped files; none is a
718
- // source the package must wire a test target for.
719
- tree.write('packages/lib/dist-test/example.test.js', 'export {};\n');
720
- tree.write('packages/lib/target/debug/build/example.test.ts', 'export {};\n');
721
- tree.write('packages/lib/.runtime/cache-pin/test/example.test.ts', 'export {};\n');
722
-
723
- const issues = checkPackageTargetPolicyTree(tree);
724
- expect(issues.filter((i) => i.message.includes('test files require'))).toEqual([]);
725
- });
726
-
727
- it('accepts wildcard aggregate build dependencies', () => {
728
- addProject(tree, 'lib', 'packages/lib');
729
- writeJsonFile(tree, 'packages/lib/package.json', {
730
- name: '@scope/lib',
731
- nx: {
732
- name: 'lib',
733
- targets: {
734
- build: {
735
- executor: 'nx:noop',
736
- dependsOn: ['^build', '*-js', '*-wasm'],
737
- },
738
- },
739
- },
740
- });
741
-
742
- const issues = checkPackageTargetPolicyTree(tree);
743
- const buildIssues = issues.filter((i) => i.message.includes('dependsOn references missing target'));
744
- expect(buildIssues).toEqual([]);
745
- });
746
-
747
- it('accepts platform-only target families without an ordinary build aggregate', () => {
748
- addProject(tree, 'native', 'packages/native');
749
- writeJsonFile(tree, 'packages/native/package.json', {
750
- name: '@scope/native',
751
- nx: { name: 'native' },
752
- });
753
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
754
- [
755
- 'native',
756
- {
757
- targets: new Set(['bundle-ios', 'prepare-macos', 'bundle-linux']),
758
- targetDependencies: new Map([
759
- ['bundle-ios', ['prepare-macos', '^build']],
760
- ['prepare-macos', []],
761
- ['bundle-linux', ['^build']],
762
- ]),
763
- },
764
- ],
765
- ]);
766
-
767
- expect(checkPackageTargetPolicyTree(tree, { resolvedTargetsByProject })).toEqual([]);
768
- });
769
-
770
- it('rejects cross-family dependencies in resolved platform target closures', () => {
771
- addProject(tree, 'native', 'packages/native');
772
- writeJsonFile(tree, 'packages/native/package.json', {
773
- name: '@scope/native',
774
- nx: { name: 'native' },
775
- });
776
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
777
- [
778
- 'native',
779
- {
780
- targets: new Set(['bundle-ios', 'prepare-macos', 'compile-js', 'bundle-linux']),
781
- targetDependencies: new Map([
782
- ['bundle-ios', ['prepare-macos', '^build']],
783
- ['prepare-macos', ['compile-js']],
784
- ['bundle-linux', ['bundle-ios']],
785
- ]),
786
- },
787
- ],
788
- ]);
789
-
790
- const issues = checkPackageTargetPolicyTree(tree, { resolvedTargetsByProject });
791
-
792
- expect(
793
- issues.some(
794
- (issue) =>
795
- issue.message.includes('platform target bundle-ios dependency closure') &&
796
- issue.message.includes('non-macos sibling target compile-js'),
797
- ),
798
- ).toBe(true);
799
- expect(
800
- issues.some(
801
- (issue) =>
802
- issue.message.includes('platform target bundle-linux dependency closure') &&
803
- issue.message.includes('non-linux sibling target bundle-ios'),
804
- ),
805
- ).toBe(true);
806
- expect(issues.some((issue) => issue.message.includes('non-macos sibling target prepare-macos'))).toBe(false);
807
- });
808
-
809
- it('rejects recursive script commands', () => {
810
- addProject(tree, 'app', 'packages/app');
811
- addProject(tree, 'lib', 'packages/lib');
812
- writeJsonFile(tree, 'packages/app/package.json', {
813
- name: '@scope/app',
814
- dependencies: { '@scope/lib': 'workspace:*' },
815
- scripts: {
816
- dev: 'nx run app:dev --outputStyle=stream',
817
- },
818
- nx: {
819
- name: 'app',
820
- targets: {
821
- dev: {
822
- executor: 'nx:run-commands',
823
- dependsOn: ['^build'],
824
- continuous: true,
825
- options: { command: 'bun run dev', cwd: '{projectRoot}' },
826
- },
827
- },
828
- },
829
- });
830
- writeJsonFile(tree, 'packages/lib/package.json', {
831
- name: '@scope/lib',
832
- nx: { name: 'lib' },
833
- });
834
-
835
- const issues = checkPackageTargetPolicyTree(tree);
836
- expect(issues.some((i) => i.message.includes('options.command must not call scripts.dev'))).toBe(true);
837
- });
838
- });
839
-
840
- describe('applyPackageTargetPolicyTree', () => {
841
- let tree: Tree;
842
-
843
- beforeEach(() => {
844
- tree = createTreeWithEmptyWorkspace();
845
- });
846
-
847
- it('migrates colon build targets to tool-output names', () => {
848
- addProject(tree, 'lib', 'packages/lib');
849
- addProject(tree, 'other', 'packages/other');
850
- writeJsonFile(tree, 'packages/lib/package.json', {
851
- name: '@scope/lib',
852
- dependencies: { '@scope/other': 'workspace:*' },
853
- scripts: {
854
- 'build:ts': 'nx run lib:build:ts',
855
- },
856
- nx: {
857
- name: 'lib',
858
- targets: {
859
- 'build:ts': {
860
- executor: 'nx:run-commands',
861
- options: { command: 'tsc --build tsconfig.lib.json', cwd: '{projectRoot}' },
862
- },
863
- build: {
864
- executor: 'nx:noop',
865
- dependsOn: ['^build', 'build:ts'],
866
- },
867
- },
868
- },
869
- });
870
- writeJsonFile(tree, 'packages/other/package.json', {
871
- name: '@scope/other',
872
- });
873
-
874
- expect(applyPackageTargetPolicyTree(tree)).toBe(true);
875
-
876
- const lib = readJson(tree, 'packages/lib/package.json');
877
- const targets = lib.nx.targets;
878
- expect(targets['build:ts']).toBeUndefined();
879
- expect(targets['tsc-js']).toBeDefined();
880
- expect(targets['tsc-js'].options.command).toBe('tsc --build tsconfig.lib.json');
881
- expect(targets.build.dependsOn).toContain('tsc-js');
882
- expect(targets.build.dependsOn).not.toContain('build:ts');
883
- expect(lib.scripts['build:ts']).toBe('nx run lib:tsc-js');
884
- });
885
-
886
- it('removes noop aggregate build targets matching resolved plugin output', () => {
887
- addProject(tree, 'lib', 'packages/lib');
888
- writeJsonFile(tree, 'packages/lib/package.json', {
889
- name: '@scope/lib',
890
- nx: {
891
- name: 'lib',
892
- targets: {
893
- build: {
894
- executor: 'nx:noop',
895
- dependsOn: ['^build', '*-js'],
896
- },
897
- },
898
- },
899
- });
900
-
901
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
902
- ['lib', { targets: new Set(['build', 'tsc-js']) }],
903
- ]);
904
-
905
- expect(applyPackageTargetPolicyTree(tree, { resolvedTargetsByProject })).toBe(true);
906
-
907
- const lib = readJson(tree, 'packages/lib/package.json');
908
- expect(lib.nx.targets.build).toBeUndefined();
909
- });
910
-
911
- it('keeps non-noop build targets even when dependsOn matches', () => {
912
- addProject(tree, 'lib', 'packages/lib');
913
- writeJsonFile(tree, 'packages/lib/package.json', {
914
- name: '@scope/lib',
915
- nx: {
916
- name: 'lib',
917
- targets: {
918
- build: {
919
- executor: 'nx:run-commands',
920
- dependsOn: ['^build', '*-js'],
921
- options: { command: 'echo build', cwd: '{projectRoot}' },
922
- },
923
- },
924
- },
925
- });
926
-
927
- const resolvedTargetsByProject = new Map<string, ResolvedProjectTargets>([
928
- ['lib', { targets: new Set(['build', 'tsc-js']) }],
929
- ]);
930
-
931
- expect(applyPackageTargetPolicyTree(tree, { resolvedTargetsByProject })).toBe(false);
932
-
933
- const lib = readJson(tree, 'packages/lib/package.json');
934
- expect(lib.nx.targets.build).toBeDefined();
935
- expect(lib.nx.targets.build.options.command).toBe('echo build');
936
- });
937
-
938
- it('rewrites safe scripts into Nx aliases', () => {
939
- addProject(tree, 'web', 'packages/web');
940
- addProject(tree, 'lib', 'packages/lib');
941
- writeJsonFile(tree, 'packages/web/package.json', {
942
- name: '@scope/web',
943
- dependencies: { '@scope/lib': 'workspace:*' },
944
- scripts: {
945
- dev: 'astro dev',
946
- build: 'astro build',
947
- },
948
- nx: { name: 'web' },
949
- });
950
- writeJsonFile(tree, 'packages/lib/package.json', {
951
- name: '@scope/lib',
952
- nx: { name: 'lib' },
953
- });
954
-
955
- expect(applyPackageTargetPolicyTree(tree)).toBe(true);
956
-
957
- const web = readJson(tree, 'packages/web/package.json');
958
- expect(web.scripts.dev).toBe('nx run web:dev --outputStyle=dynamic-legacy');
959
- expect(web.scripts.build).toBe('nx run web:build');
960
- expect(web.nx.targets.dev.continuous).toBe(true);
961
- expect(web.nx.targets.dev.executor).toBe('nx:run-commands');
962
- expect(web.nx.targets.dev.options.command).toBe('astro dev');
963
- expect(web.nx.targets.build.executor).toBe('nx:run-commands');
964
- expect(web.nx.targets.build.options.command).toBe('astro build');
965
- });
966
-
967
- it('moves env assignments into target options', () => {
968
- addProject(tree, 'web', 'packages/web');
969
- addProject(tree, 'lib', 'packages/lib');
970
- writeJsonFile(tree, 'packages/web/package.json', {
971
- name: '@scope/web',
972
- dependencies: { '@scope/lib': 'workspace:*' },
973
- scripts: {
974
- dev: "NODE_OPTIONS='--max-old-space-size=4096' astro dev",
975
- },
976
- nx: { name: 'web' },
977
- });
978
- writeJsonFile(tree, 'packages/lib/package.json', {
979
- name: '@scope/lib',
980
- nx: { name: 'lib' },
981
- });
982
-
983
- expect(applyPackageTargetPolicyTree(tree)).toBe(true);
984
-
985
- const web = readJson(tree, 'packages/web/package.json');
986
- expect(web.nx.targets.dev.options.command).toBe('astro dev');
987
- expect(web.nx.targets.dev.options.env).toEqual({ NODE_OPTIONS: '--max-old-space-size=4096' });
988
- });
989
-
990
- it('returns false when no changes needed', () => {
991
- addProject(tree, 'lib', 'packages/lib');
992
- writeJsonFile(tree, 'packages/lib/package.json', {
993
- name: '@scope/lib',
994
- nx: { name: 'lib' },
995
- });
996
-
997
- expect(applyPackageTargetPolicyTree(tree)).toBe(false);
998
- });
999
-
1000
- it('skips projects without package.json', () => {
1001
- addProject(tree, 'native', 'packages/native', { keepProjectJson: true });
1002
- // No package.json written — should not throw
1003
- expect(applyPackageTargetPolicyTree(tree)).toBe(false);
1004
- });
1005
- });
1006
-
1007
- async function writeJson(path: string, value: unknown): Promise<void> {
1008
- await mkdir(dirname(path), { recursive: true });
1009
- await writeFile(path, `${JSON.stringify(value, null, 2)}\n`);
1010
- }
1011
-
1012
- function isRecord(value: unknown): value is Record<string, unknown> {
1013
- return value !== null && typeof value === 'object' && !Array.isArray(value);
1014
- }