@smoothbricks/nx-plugin 0.4.26 → 0.4.28

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 (343) hide show
  1. package/README.md +994 -117
  2. package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
  3. package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-bound-failures.js +31 -0
  5. package/dist/bin/smoo-nx-cargo-hash.js +28 -3
  6. package/dist/bin/smoo-nx-exec.js +15 -73
  7. package/dist/bin/smoo-nx-failures.d.ts +3 -0
  8. package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
  9. package/dist/bin/smoo-nx-failures.js +3 -0
  10. package/dist/bin/smoo-nx-nextest-extract.js +3 -2
  11. package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
  12. package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
  13. package/dist/bin/smoo-nx-test-walks.js +34 -0
  14. package/dist/bounded-test-policy.d.ts +7 -1
  15. package/dist/bounded-test-policy.d.ts.map +1 -1
  16. package/dist/bounded-test-policy.js +101 -40
  17. package/dist/build-state-output-policy.d.ts +25 -0
  18. package/dist/build-state-output-policy.d.ts.map +1 -0
  19. package/dist/build-state-output-policy.js +64 -0
  20. package/dist/cargo-closure-input.d.ts +3 -2
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +16 -15
  23. package/dist/cargo-dev-profile.d.ts +37 -0
  24. package/dist/cargo-dev-profile.d.ts.map +1 -0
  25. package/dist/cargo-dev-profile.js +108 -0
  26. package/dist/cargo-source-hash.d.ts +43 -6
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +309 -73
  29. package/dist/cargo-toolchain-policy.d.ts +4 -0
  30. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  31. package/dist/cargo-toolchain-policy.js +5 -0
  32. package/dist/cargo-workspace.d.ts +101 -5
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +291 -10
  35. package/dist/cross-check-policy.d.ts +21 -3
  36. package/dist/cross-check-policy.d.ts.map +1 -1
  37. package/dist/cross-check-policy.js +24 -6
  38. package/dist/disk-command-policy.d.ts +7 -0
  39. package/dist/disk-command-policy.d.ts.map +1 -0
  40. package/dist/disk-command-policy.js +98 -0
  41. package/dist/ensure-built-receipt.d.ts +25 -0
  42. package/dist/ensure-built-receipt.d.ts.map +1 -0
  43. package/dist/ensure-built-receipt.js +261 -0
  44. package/dist/ensure-built-witness.d.ts +57 -0
  45. package/dist/ensure-built-witness.d.ts.map +1 -0
  46. package/dist/ensure-built-witness.js +412 -0
  47. package/dist/ensure-built.d.ts +207 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +576 -202
  50. package/dist/eslint-file-set.d.ts +7 -0
  51. package/dist/eslint-file-set.d.ts.map +1 -0
  52. package/dist/eslint-file-set.js +12 -0
  53. package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
  54. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
  55. package/dist/executors/bounded-exec/cpu-pool.js +379 -0
  56. package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
  57. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
  58. package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
  59. package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
  60. package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/disk-lease.js +91 -0
  62. package/dist/executors/bounded-exec/executor.d.ts +45 -2
  63. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  64. package/dist/executors/bounded-exec/executor.js +447 -52
  65. package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
  66. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
  67. package/dist/executors/bounded-exec/gateway-lease.js +143 -0
  68. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
  69. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
  70. package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
  71. package/dist/executors/bounded-exec/progress.d.ts +35 -0
  72. package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/progress.js +79 -0
  74. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
  75. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
  76. package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
  77. package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
  78. package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
  79. package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
  80. package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
  81. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
  82. package/dist/executors/bounded-exec/ram-temp.js +1528 -0
  83. package/dist/executors/bounded-exec/schema.d.ts +29 -11
  84. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  85. package/dist/executors/bounded-exec/verdict.d.ts +162 -0
  86. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/verdict.js +318 -0
  88. package/dist/executors/shard-timings/executor.d.ts +14 -0
  89. package/dist/executors/shard-timings/executor.d.ts.map +1 -0
  90. package/dist/executors/shard-timings/executor.js +25 -0
  91. package/dist/executors/shard-timings/schema.d.ts +4 -0
  92. package/dist/executors/shard-timings/schema.d.ts.map +1 -0
  93. package/dist/executors/shard-timings/schema.js +1 -0
  94. package/dist/failure-summary.d.ts +5 -0
  95. package/dist/failure-summary.d.ts.map +1 -0
  96. package/dist/failure-summary.js +118 -0
  97. package/dist/generators/create-package/generator.d.ts.map +1 -1
  98. package/dist/generators/create-package/generator.js +6 -2
  99. package/dist/index.d.ts +14 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +370 -138
  102. package/dist/managed-files/ci-workflow.d.ts +13 -0
  103. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.js +44 -13
  105. package/dist/managed-files/files.d.ts +7 -1
  106. package/dist/managed-files/files.d.ts.map +1 -1
  107. package/dist/managed-files/files.js +62 -8
  108. package/dist/managed-files/json-edit.d.ts +21 -0
  109. package/dist/managed-files/json-edit.d.ts.map +1 -0
  110. package/dist/managed-files/json-edit.js +295 -0
  111. package/dist/managed-files/managed-format.d.ts +33 -1
  112. package/dist/managed-files/managed-format.d.ts.map +1 -1
  113. package/dist/managed-files/managed-format.js +82 -2
  114. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  115. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  116. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  117. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/publish-workflow.js +231 -48
  119. package/dist/managed-files/tree.d.ts +5 -0
  120. package/dist/managed-files/tree.d.ts.map +1 -1
  121. package/dist/managed-files/tree.js +5 -3
  122. package/dist/manifest-hash.d.ts.map +1 -1
  123. package/dist/manifest-hash.js +2 -5
  124. package/dist/nextest-code-bound.d.ts +62 -0
  125. package/dist/nextest-code-bound.d.ts.map +1 -0
  126. package/dist/nextest-code-bound.js +154 -0
  127. package/dist/nextest-extraction.d.ts +24 -8
  128. package/dist/nextest-extraction.d.ts.map +1 -1
  129. package/dist/nextest-extraction.js +42 -7
  130. package/dist/package-target-policy.d.ts.map +1 -1
  131. package/dist/package-target-policy.js +3 -5
  132. package/dist/release-config-policy.d.ts.map +1 -1
  133. package/dist/release-config-policy.js +3 -5
  134. package/dist/runtime-input.d.ts +14 -0
  135. package/dist/runtime-input.d.ts.map +1 -0
  136. package/dist/runtime-input.js +15 -0
  137. package/dist/rust-tokens.d.ts +11 -0
  138. package/dist/rust-tokens.d.ts.map +1 -0
  139. package/dist/rust-tokens.js +81 -0
  140. package/dist/task-results.d.ts +6 -0
  141. package/dist/task-results.d.ts.map +1 -0
  142. package/dist/task-results.js +61 -0
  143. package/dist/test-program.d.ts +54 -0
  144. package/dist/test-program.d.ts.map +1 -0
  145. package/dist/test-program.js +292 -0
  146. package/dist/test-timings.d.ts +71 -0
  147. package/dist/test-timings.d.ts.map +1 -0
  148. package/dist/test-timings.js +393 -0
  149. package/dist/test-walk-policy.d.ts +103 -0
  150. package/dist/test-walk-policy.d.ts.map +1 -0
  151. package/dist/test-walk-policy.js +657 -0
  152. package/dist/testing.d.ts +177 -0
  153. package/dist/testing.d.ts.map +1 -0
  154. package/dist/testing.js +824 -0
  155. package/dist/type-guards.d.ts +3 -0
  156. package/dist/type-guards.d.ts.map +1 -0
  157. package/dist/type-guards.js +4 -0
  158. package/dist/typecheck-test-policy.d.ts +8 -5
  159. package/dist/typecheck-test-policy.d.ts.map +1 -1
  160. package/dist/typecheck-test-policy.js +113 -100
  161. package/dist/workspace-config-policy.d.ts +8 -0
  162. package/dist/workspace-config-policy.d.ts.map +1 -1
  163. package/dist/workspace-config-policy.js +175 -63
  164. package/dist/workspace-index.d.ts +12 -0
  165. package/dist/workspace-index.d.ts.map +1 -0
  166. package/dist/workspace-index.js +17 -0
  167. package/dist/workspace-manifest.d.ts +37 -0
  168. package/dist/workspace-manifest.d.ts.map +1 -1
  169. package/executors.json +5 -0
  170. package/loader.js +13 -11
  171. package/managed/raw/envrc +33 -67
  172. package/managed/raw/git-format-staged.yml +30 -35
  173. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  174. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  175. package/managed/raw/tooling/direnv/developer-links.ts +569 -11
  176. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
  177. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  178. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  179. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  180. package/managed/raw/tooling/direnv/repo-path +14 -2
  181. package/managed/raw/tooling/direnv/setup-environment.ts +1146 -159
  182. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  183. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  184. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  185. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  186. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  187. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  188. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  189. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  190. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  191. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  192. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  194. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  196. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  197. package/managed/templates/github/workflows/managed-files.yml +1 -2
  198. package/nextest.toml +8 -41
  199. package/package.json +74 -12
  200. package/runtime-input.sh +81 -0
  201. package/src/__tests__/counted-cargo.ts +33 -14
  202. package/src/__tests__/fixture-nx-env.ts +111 -46
  203. package/src/__tests__/progress-clock.ts +43 -0
  204. package/src/__tests__/runtime-input.ts +23 -0
  205. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  206. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  207. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  208. package/src/bin/smoo-nx-exec.ts +16 -74
  209. package/src/bin/smoo-nx-failures.ts +4 -0
  210. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  211. package/src/bin/smoo-nx-test-walks.ts +42 -0
  212. package/src/bounded-test-policy.test.ts +268 -21
  213. package/src/bounded-test-policy.ts +114 -42
  214. package/src/build-state-output-policy.test.ts +115 -0
  215. package/src/build-state-output-policy.ts +90 -0
  216. package/src/bun-bootstrap.test.ts +57 -3
  217. package/src/bun-file-packages.test.ts +47 -0
  218. package/src/cargo-closure-input.test.ts +138 -66
  219. package/src/cargo-closure-input.ts +17 -15
  220. package/src/cargo-dev-profile.ts +137 -0
  221. package/src/cargo-resolve-cache.test.ts +70 -1
  222. package/src/cargo-source-hash.test.ts +193 -97
  223. package/src/cargo-source-hash.ts +345 -68
  224. package/src/cargo-toolchain-policy.ts +6 -0
  225. package/src/cargo-workspace.test.ts +320 -0
  226. package/src/cargo-workspace.ts +336 -10
  227. package/src/cross-check-policy.test.ts +59 -1
  228. package/src/cross-check-policy.ts +25 -6
  229. package/src/disk-command-policy.test.ts +61 -0
  230. package/src/disk-command-policy.ts +107 -0
  231. package/src/ensure-built-receipt.test.ts +184 -0
  232. package/src/ensure-built-receipt.ts +263 -0
  233. package/src/ensure-built-witness.test.ts +344 -0
  234. package/src/ensure-built-witness.ts +252 -0
  235. package/src/ensure-built.test.ts +1036 -578
  236. package/src/ensure-built.ts +820 -224
  237. package/src/eslint-file-set.ts +9 -0
  238. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  239. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  240. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  241. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  242. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  243. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  244. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  245. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  246. package/src/executors/bounded-exec/executor.ts +565 -67
  247. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  248. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  249. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  250. package/src/executors/bounded-exec/progress.test.ts +79 -0
  251. package/src/executors/bounded-exec/progress.ts +118 -0
  252. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  253. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  254. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  255. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  256. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  257. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  258. package/src/executors/bounded-exec/schema.json +11 -5
  259. package/src/executors/bounded-exec/schema.ts +27 -11
  260. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  261. package/src/executors/bounded-exec/verdict.ts +433 -0
  262. package/src/executors/shard-timings/executor.ts +36 -0
  263. package/src/executors/shard-timings/schema.json +21 -0
  264. package/src/executors/shard-timings/schema.ts +4 -0
  265. package/src/failure-summary.ts +119 -0
  266. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  267. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  268. package/src/generators/create-package/generator.test.ts +6 -0
  269. package/src/generators/create-package/generator.ts +6 -2
  270. package/src/host-controller-wiring.test.ts +31 -0
  271. package/src/index.test.ts +909 -295
  272. package/src/index.ts +441 -143
  273. package/src/linked-snapshots.nx.test.ts +172 -0
  274. package/src/managed-files/ci-workflow.ts +54 -13
  275. package/src/managed-files/files.ts +65 -9
  276. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  277. package/src/managed-files/generator.test.ts +60 -1
  278. package/src/managed-files/json-edit.test.ts +216 -0
  279. package/src/managed-files/json-edit.ts +290 -0
  280. package/src/managed-files/managed-format-json.test.ts +308 -0
  281. package/src/managed-files/managed-format.ts +90 -2
  282. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  283. package/src/managed-files/publish-workflow.ts +285 -67
  284. package/src/managed-files/repo-path.test.ts +129 -0
  285. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  286. package/src/managed-files/tree.ts +11 -3
  287. package/src/manifest-hash.ts +2 -6
  288. package/src/nextest-code-bound.test.ts +155 -0
  289. package/src/nextest-code-bound.ts +195 -0
  290. package/src/nextest-extraction.test.ts +37 -5
  291. package/src/nextest-extraction.ts +51 -9
  292. package/src/nextest-partitions.test.ts +427 -82
  293. package/src/nx-cache-bound.test.ts +5 -10
  294. package/src/nx-cache-restore-mtime.test.ts +170 -0
  295. package/src/nx-daemon-claim.test.ts +277 -0
  296. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  297. package/src/nx-daemon-idle-policy.test.ts +51 -0
  298. package/src/nx-daemon-ignore-files.test.ts +210 -0
  299. package/src/nx-daemon-root-normalization.test.ts +105 -0
  300. package/src/nx-daemon-validity.test.ts +925 -0
  301. package/src/nx-dot-input-policy.test.ts +353 -0
  302. package/src/nx-failure-life-cycles.test.ts +207 -0
  303. package/src/nx-files-archive-racy.test.ts +97 -0
  304. package/src/nx-foreign-workspace-env.test.ts +329 -0
  305. package/src/nx-incomplete-run-summary.test.ts +70 -0
  306. package/src/nx-plugin-load-errors.test.ts +120 -0
  307. package/src/nx-project-resolution-cache.test.ts +176 -0
  308. package/src/nx-raw-inputs.test.ts +166 -0
  309. package/src/nx-resident-graph-workers.test.ts +7 -16
  310. package/src/nx-run-information.test.ts +118 -0
  311. package/src/nx-skipped-task-exit.test.ts +180 -0
  312. package/src/nx-state-location.test.ts +63 -0
  313. package/src/nx-store-resolution.test.ts +26 -25
  314. package/src/nx-task-graph-cycles.test.ts +148 -0
  315. package/src/nx-task-output-lease.test.ts +414 -0
  316. package/src/nx-use-local.test.ts +103 -0
  317. package/src/package-target-policy.ts +3 -6
  318. package/src/release-config-policy.ts +3 -6
  319. package/src/runtime-input.test.ts +215 -0
  320. package/src/runtime-input.ts +17 -0
  321. package/src/rust-tokens.ts +78 -0
  322. package/src/serial-group-wiring.test.ts +326 -0
  323. package/src/task-history-namespace.test.ts +87 -89
  324. package/src/task-results.test.ts +226 -0
  325. package/src/task-results.ts +75 -0
  326. package/src/test-program.test.ts +303 -0
  327. package/src/test-program.ts +341 -0
  328. package/src/test-timings.test.ts +240 -0
  329. package/src/test-timings.ts +311 -0
  330. package/src/test-walk-policy.test.ts +585 -0
  331. package/src/test-walk-policy.ts +731 -0
  332. package/src/testing.test.ts +509 -0
  333. package/src/testing.ts +922 -0
  334. package/src/type-guards.ts +4 -0
  335. package/src/typecheck-test-policy.test.ts +496 -11
  336. package/src/typecheck-test-policy.ts +137 -103
  337. package/src/workspace-config-policy.test.ts +212 -13
  338. package/src/workspace-config-policy.ts +101 -73
  339. package/src/workspace-index.ts +18 -0
  340. package/src/workspace-manifest.ts +41 -0
  341. package/test-timings.json +85 -30
  342. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
  343. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
@@ -25,6 +25,7 @@ import {
25
25
 
26
26
  function validNxJson(): Record<string, unknown> {
27
27
  return {
28
+ cacheDirectory: '.nx/cache',
28
29
  plugins: ['@smoothbricks/nx-plugin'],
29
30
  sync: { globalGenerators: ['@smoothbricks/nx-plugin:managed-files'] },
30
31
  targetDefaults: validTargetDefaults(),
@@ -39,16 +40,18 @@ function validTargetDefaults(): Record<string, unknown> {
39
40
  };
40
41
  }
41
42
 
43
+ const MARKDOWN = '!{projectRoot}/**/*.md';
44
+
42
45
  function validNamedInputs(): Record<string, unknown> {
43
46
  return {
44
- default: ['{projectRoot}/**/*', 'sharedGlobals'],
45
- sharedGlobals: ['{workspaceRoot}/.github/workflows/ci.yml'],
47
+ default: ['{projectRoot}/**/*', MARKDOWN],
46
48
  production: [
47
49
  '{projectRoot}/src/**/*',
48
50
  '{projectRoot}/package.json',
49
51
  '!{projectRoot}/**/__tests__/**',
50
52
  '!{projectRoot}/**/*.test.*',
51
53
  '!{projectRoot}/**/*.spec.*',
54
+ MARKDOWN,
52
55
  ],
53
56
  };
54
57
  }
@@ -95,6 +98,7 @@ describe('pure core: checkWorkspaceConfig', () => {
95
98
 
96
99
  it('detects missing plugins', () => {
97
100
  const issues = checkWorkspaceConfig({
101
+ cacheDirectory: '.nx/cache',
98
102
  plugins: [],
99
103
  targetDefaults: validTargetDefaults(),
100
104
  namedInputs: validNamedInputs(),
@@ -202,20 +206,57 @@ describe('pure core: checkWorkspaceConfig', () => {
202
206
  expect(issues.some((i) => i.message.includes('targetDefaults.test.dependsOn must not be set'))).toBe(true);
203
207
  });
204
208
 
205
- it('detects missing sharedGlobals', () => {
206
- const issues = checkWorkspaceConfig({
207
- plugins: validPlugins(),
208
- targetDefaults: validTargetDefaults(),
209
- namedInputs: {
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 = {
210
213
  ...validNamedInputs(),
211
- sharedGlobals: [],
212
- },
213
- });
214
- expect(issues.some((i) => i.message.includes('sharedGlobals'))).toBe(true);
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
+ }
215
246
  });
216
247
  });
217
248
 
218
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
+
219
260
  it('removes workspace-wide lint commands while preserving shared cache policy', () => {
220
261
  const nxJson = {
221
262
  ...validNxJson(),
@@ -239,6 +280,28 @@ describe('pure core: applyWorkspaceConfig', () => {
239
280
  expect(applyWorkspaceConfig(nxJson)).toBe(false);
240
281
  });
241
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
+
242
305
  it('returns false for already-valid config', () => {
243
306
  const nxJson = validNxJson();
244
307
  expect(applyWorkspaceConfig(nxJson)).toBe(false);
@@ -295,6 +358,25 @@ describe('pure core: applyWorkspaceConfig', () => {
295
358
  expect(pluginNames).toContain('@smoothbricks/nx-plugin');
296
359
  });
297
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
+
298
380
  it('removes colon target defaults', () => {
299
381
  const nxJson = {
300
382
  ...validNxJson(),
@@ -340,7 +422,35 @@ describe('pure core: applyWorkspaceConfig', () => {
340
422
  '!{projectRoot}/**/__tests__/**',
341
423
  '!{projectRoot}/**/*.test.*',
342
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.",
343
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());
344
454
  });
345
455
 
346
456
  it('accepts custom precise production inputs unchanged', () => {
@@ -348,11 +458,46 @@ describe('pure core: applyWorkspaceConfig', () => {
348
458
  ...validNxJson(),
349
459
  namedInputs: {
350
460
  ...validNamedInputs(),
351
- production: ['{projectRoot}/src/**/*.rs', '{projectRoot}/Cargo.toml', '!{projectRoot}/**/*.test.*'],
461
+ production: ['{projectRoot}/src/**/*.rs', '{projectRoot}/Cargo.toml', '!{projectRoot}/**/*.test.*', MARKDOWN],
352
462
  },
353
463
  };
354
464
  expect(applyWorkspaceConfig(nxJson)).toBe(false);
355
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
+ });
356
501
  });
357
502
 
358
503
  // ---------------------------------------------------------------------------
@@ -372,6 +517,7 @@ describe('Tree: checkWorkspaceConfigTree', () => {
372
517
  it('detects missing plugins', () => {
373
518
  const tree = createTreeWithEmptyWorkspace();
374
519
  writeJson(tree, 'nx.json', {
520
+ cacheDirectory: '.nx/cache',
375
521
  plugins: [],
376
522
  targetDefaults: validTargetDefaults(),
377
523
  namedInputs: validNamedInputs(),
@@ -416,6 +562,59 @@ describe('Tree: applyWorkspaceConfigTree', () => {
416
562
  expect(checkWorkspaceConfigTree(tree)).toEqual([]);
417
563
  });
418
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
+
419
618
  it('returns false when config already valid', () => {
420
619
  const tree = createTreeWithEmptyWorkspace();
421
620
  writeJson(tree, 'nx.json', validNxJson());
@@ -472,8 +671,8 @@ describe('filesystem: checkWorkspaceConfigPolicy / applyWorkspaceConfigPolicy',
472
671
  const nxJson = expectRecord(JSON.parse(await readFile(join(root, 'nx.json'), 'utf8')));
473
672
  const pluginNames = readPluginNames(nxJson.plugins);
474
673
  expect(pluginNames).not.toContain('@nx/js/typescript');
475
- expect(pluginNames).toContain('@smoothbricks/nx-plugin');
476
674
  expect(expectRecord(nxJson.targetDefaults)['typecheck-tests']).toBeUndefined();
675
+ expect(nxJson.cacheDirectory).toBe('.nx/cache');
477
676
 
478
677
  // No issues after fix
479
678
  expect(checkWorkspaceConfigPolicy(root)).toEqual([]);
@@ -1,11 +1,15 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import type { PluginConfiguration } from 'nx/src/config/nx-json.js';
3
4
  import type { Tree } from 'nx/src/devkit-exports.js';
4
- import { readJson, updateJson } from 'nx/src/devkit-exports.js';
5
+ import { readJson, writeJson } from 'nx/src/devkit-exports.js';
6
+ import typia from 'typia';
5
7
 
6
8
  import { CARGO_TEST_TARGET } from './cargo-workspace.js';
9
+ import { writeJsonFile } from './managed-files/managed-format.js';
7
10
 
8
11
  export const MANAGED_FILES_SYNC_GENERATOR = '@smoothbricks/nx-plugin:managed-files';
12
+ const validatePlugins = typia.createValidate<PluginConfiguration[]>();
9
13
 
10
14
  export interface NxPolicyIssue {
11
15
  path: string;
@@ -65,17 +69,33 @@ export function isTestRunnerTargetName(name: string): boolean {
65
69
  const nxJsTypescriptPlugin = '@nx/js/typescript';
66
70
  const smoothBricksNxPlugin = '@smoothbricks/nx-plugin';
67
71
  const cleanOutputsExecutor = '@smoothbricks/nx-plugin:clean-outputs';
68
- const expectedSharedGlobalsNamedInput = ['{workspaceRoot}/.github/workflows/ci.yml'];
72
+ const ciWorkflowNamedInput = ['{workspaceRoot}/.github/workflows/ci.yml'];
69
73
  const inferredTestTypecheckTarget = 'typecheck-tests';
74
+ /**
75
+ * Markdown is documentation: no inferred task reads it, so a README or spec edit must not re-key every task of the
76
+ * project and, through `^default`/`^production`, of every project depending on it. A target that does read Markdown
77
+ * (a docs site build, a binary that `include_str!`s a shipped skill) names those files in its own inputs.
78
+ */
79
+ const MARKDOWN_EXCLUSION = '!{projectRoot}/**/*.md';
70
80
  const defaultProductionNamedInput = [
71
81
  '{projectRoot}/src/**/*',
72
82
  '{projectRoot}/package.json',
73
83
  '!{projectRoot}/**/__tests__/**',
74
84
  '!{projectRoot}/**/*.test.*',
75
85
  '!{projectRoot}/**/*.spec.*',
86
+ MARKDOWN_EXCLUSION,
76
87
  ];
77
88
  const impreciseProductionInputs = new Set(['default', '{projectRoot}/**/*', '{projectRoot}/**']);
78
89
 
90
+ /**
91
+ * Every checkout keeps its Nx state in its own `.nx` (specs/cowshed/16_build_volumes.md, "Every checkout has exactly
92
+ * one Nx state"). With no `NX_*_DIRECTORY` set, as in a host shell, the pinned Nx 23.2.1 otherwise moves the task cache
93
+ * and its database to a per-user `~/.nx/<id>` keyed by the repository's remote (`utils/cache-directory.js`,
94
+ * `computeSharedDataLocation`), shared by every checkout of the repository. A configured `cacheDirectory` keeps both
95
+ * local: the cache here, the task database in Nx's default `.nx/workspace-data`. nx.json has no key for the latter.
96
+ */
97
+ export const CHECKOUT_NX_CACHE_DIRECTORY = '.nx/cache';
98
+
79
99
  /**
80
100
  * Check workspace config policy on an in-memory nx.json object.
81
101
  */
@@ -119,23 +139,39 @@ export function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyI
119
139
  // Named input defaults
120
140
  validateNamedInputDefaults(nxJson, 'nx.json', issues);
121
141
 
122
- // Plugin configuration
123
- const plugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
124
- if (plugins.some(isNxJsTypescriptPlugin)) {
142
+ if (nxJson.cacheDirectory !== CHECKOUT_NX_CACHE_DIRECTORY) {
125
143
  issues.push({
126
144
  path: 'nx.json',
127
145
  message:
128
- `plugins must not configure ${nxJsTypescriptPlugin}. ` +
129
- 'Smoo owns transformer-aware TypeScript targets; Nx native inference only supports tsc/tsgo.',
146
+ `cacheDirectory must be "${CHECKOUT_NX_CACHE_DIRECTORY}". ` +
147
+ "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.",
130
148
  });
131
149
  }
132
- if (!plugins.includes(smoothBricksNxPlugin) && !plugins.some(isSmoothBricksNxPluginRecord)) {
150
+
151
+ // Plugin configuration
152
+ const plugins = validatePlugins(nxJson.plugins === undefined ? [] : nxJson.plugins);
153
+ if (!plugins.success) {
133
154
  issues.push({
134
155
  path: 'nx.json',
135
- message:
136
- `plugins must include ${smoothBricksNxPlugin}. ` +
137
- 'Smoo relies on this plugin to infer convention targets that official Nx does not provide, including typecheck-tests, non-TypeScript build-tool targets, and aggregate build/lint targets.',
156
+ message: `plugins is malformed: ${plugins.errors.map(({ path, expected }) => `${path}: expected ${expected}`).join('; ')}`,
138
157
  });
158
+ } else {
159
+ if (plugins.data.some((plugin) => nxPluginName(plugin) === nxJsTypescriptPlugin)) {
160
+ issues.push({
161
+ path: 'nx.json',
162
+ message:
163
+ `plugins must not configure ${nxJsTypescriptPlugin}. ` +
164
+ 'Smoo owns transformer-aware TypeScript targets; Nx native inference only supports tsc/tsgo.',
165
+ });
166
+ }
167
+ if (!plugins.data.some((plugin) => nxPluginName(plugin) === smoothBricksNxPlugin)) {
168
+ issues.push({
169
+ path: 'nx.json',
170
+ message:
171
+ `plugins must include ${smoothBricksNxPlugin}. ` +
172
+ 'Smoo relies on this plugin to infer convention targets that official Nx does not provide, including typecheck-tests, non-TypeScript build-tool targets, and aggregate build/lint targets.',
173
+ });
174
+ }
139
175
  }
140
176
 
141
177
  return issues;
@@ -146,18 +182,23 @@ export function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyI
146
182
  * Mutates in place, returns whether anything changed.
147
183
  */
148
184
  export function applyWorkspaceConfig(nxJson: Record<string, unknown>): boolean {
149
- let changed = removeDisallowedTargetDefaults(nxJson);
185
+ let changed = setStringProperty(nxJson, 'cacheDirectory', CHECKOUT_NX_CACHE_DIRECTORY);
186
+ changed = removeDisallowedTargetDefaults(nxJson) || changed;
150
187
  changed = applyBuildTargetDefault(nxJson) || changed;
151
188
  changed = applyTestTargetDefault(nxJson) || changed;
152
189
  changed = applyLintTargetDefault(nxJson) || changed;
153
190
  changed = applyCleanTargetDefault(nxJson) || changed;
154
191
  changed = applyNamedInputDefaults(nxJson) || changed;
155
- const currentPlugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
156
- const pluginsWithoutNxTypeScript = currentPlugins.filter((plugin) => !isNxJsTypescriptPlugin(plugin));
157
- const nextPlugins = upsertNxPlugin(pluginsWithoutNxTypeScript, smoothBricksNxPlugin);
158
- if (JSON.stringify(currentPlugins) !== JSON.stringify(nextPlugins)) {
159
- nxJson.plugins = nextPlugins;
160
- changed = true;
192
+ const plugins = validatePlugins(nxJson.plugins === undefined ? [] : nxJson.plugins);
193
+ if (plugins.success) {
194
+ const nextPlugins = plugins.data.filter((plugin) => nxPluginName(plugin) !== nxJsTypescriptPlugin);
195
+ if (!nextPlugins.some((plugin) => nxPluginName(plugin) === smoothBricksNxPlugin)) {
196
+ nextPlugins.push(smoothBricksNxPlugin);
197
+ }
198
+ if (JSON.stringify(plugins.data) !== JSON.stringify(nextPlugins)) {
199
+ nxJson.plugins = nextPlugins;
200
+ changed = true;
201
+ }
161
202
  }
162
203
  const sync = recordProperty(nxJson, 'sync') ?? {};
163
204
  const generators = Array.isArray(sync.globalGenerators) ? sync.globalGenerators : [];
@@ -186,11 +227,9 @@ export function applyWorkspaceConfigTree(tree: Tree): boolean {
186
227
  if (!tree.exists('nx.json')) {
187
228
  return false;
188
229
  }
189
- let changed = false;
190
- updateJson(tree, 'nx.json', (nxJson: Record<string, unknown>) => {
191
- changed = applyWorkspaceConfig(nxJson);
192
- return nxJson;
193
- });
230
+ const nxJson = readJson<Record<string, unknown>>(tree, 'nx.json');
231
+ const changed = applyWorkspaceConfig(nxJson);
232
+ if (changed) writeJson(tree, 'nx.json', nxJson);
194
233
  return changed;
195
234
  }
196
235
 
@@ -222,7 +261,7 @@ export function applyWorkspaceConfigPolicy(root: string): boolean {
222
261
  }
223
262
  const changed = applyWorkspaceConfig(nxJson);
224
263
  if (changed) {
225
- writeJsonObject(nxJsonPath, nxJson);
264
+ writeJsonFile(nxJsonPath, nxJson);
226
265
  }
227
266
  return changed;
228
267
  }
@@ -300,11 +339,18 @@ function validateNamedInputDefaults(
300
339
  path: nxJsonPath,
301
340
  message: 'namedInputs.default must be an array; smoo allows it to remain broad for non-production tasks.',
302
341
  });
303
- }
304
- if (!stringArrayEquals(namedInputs.sharedGlobals, expectedSharedGlobalsNamedInput)) {
342
+ } else if (!namedInputs.default.includes(MARKDOWN_EXCLUSION)) {
343
+ issues.push({ path: nxJsonPath, message: markdownExclusionMessage('default') });
344
+ }
345
+ if (
346
+ Array.isArray(namedInputs.default) &&
347
+ namedInputs.default.includes('sharedGlobals') &&
348
+ stringArrayEquals(namedInputs.sharedGlobals, ciWorkflowNamedInput)
349
+ ) {
305
350
  issues.push({
306
351
  path: nxJsonPath,
307
- message: 'namedInputs.sharedGlobals must include only {workspaceRoot}/.github/workflows/ci.yml',
352
+ message:
353
+ 'namedInputs.default must not include CI-only sharedGlobals; workflow targets may name their CI inputs explicitly.',
308
354
  });
309
355
  }
310
356
  const production = namedInputs.production;
@@ -321,9 +367,15 @@ function validateNamedInputDefaults(
321
367
  message:
322
368
  'namedInputs.production must enumerate precise production inputs. Do not include default or broad {projectRoot}/** globs; use language/tool-specific paths such as {projectRoot}/src/**/*, {projectRoot}/Cargo.toml, or {projectRoot}/pyproject.toml.',
323
369
  });
370
+ } else if (!production.includes(MARKDOWN_EXCLUSION)) {
371
+ issues.push({ path: nxJsonPath, message: markdownExclusionMessage('production') });
324
372
  }
325
373
  }
326
374
 
375
+ function markdownExclusionMessage(name: 'default' | 'production'): string {
376
+ return `namedInputs.${name} must exclude ${MARKDOWN_EXCLUSION.slice(1)}: Markdown is no task's input unless a target names it.`;
377
+ }
378
+
327
379
  function applyBuildTargetDefault(nxJson: Record<string, unknown>): boolean {
328
380
  const targetDefaults = getOrCreateRecord(nxJson, 'targetDefaults');
329
381
  const build = getOrCreateRecord(targetDefaults, 'build');
@@ -363,11 +415,15 @@ function applyTestTargetDefault(nxJson: Record<string, unknown>): boolean {
363
415
 
364
416
  const inferredLintProperties = ['executor', 'options', 'dependsOn', 'outputs', 'inputs'] as const;
365
417
 
418
+ function preservesInferredLintInputs(inputs: unknown): boolean {
419
+ return Array.isArray(inputs) && inputs.includes('...') && inputs.includes('^production');
420
+ }
421
+
366
422
  function validateLintTargetDefault(nxJson: Record<string, unknown>, nxJsonPath: string, issues: NxPolicyIssue[]): void {
367
423
  const defaults = recordProperty(nxJson, 'targetDefaults');
368
424
  const lint = defaults ? recordProperty(defaults, 'lint') : null;
369
425
  for (const property of inferredLintProperties) {
370
- if (lint !== null && property in lint) {
426
+ if (lint !== null && property in lint && !(property === 'inputs' && preservesInferredLintInputs(lint.inputs))) {
371
427
  issues.push({
372
428
  path: nxJsonPath,
373
429
  message: `targetDefaults.lint.${property} must not be set; @smoothbricks/nx-plugin infers lint from project sources`,
@@ -382,7 +438,7 @@ function applyLintTargetDefault(nxJson: Record<string, unknown>): boolean {
382
438
  if (lint === null) return false;
383
439
  let changed = false;
384
440
  for (const property of inferredLintProperties) {
385
- if (property in lint) {
441
+ if (property in lint && !(property === 'inputs' && preservesInferredLintInputs(lint.inputs))) {
386
442
  delete lint[property];
387
443
  changed = true;
388
444
  }
@@ -401,16 +457,26 @@ function applyCleanTargetDefault(nxJson: Record<string, unknown>): boolean {
401
457
  function applyNamedInputDefaults(nxJson: Record<string, unknown>): boolean {
402
458
  const namedInputs = getOrCreateRecord(nxJson, 'namedInputs');
403
459
  let changed = false;
404
- if (!Array.isArray(namedInputs.default)) {
405
- namedInputs.default = ['{projectRoot}/**/*', 'sharedGlobals'];
460
+ const defaults = namedInputs.default;
461
+ if (!Array.isArray(defaults)) {
462
+ namedInputs.default = ['{projectRoot}/**/*', MARKDOWN_EXCLUSION];
463
+ changed = true;
464
+ } else if (defaults.includes('sharedGlobals') && stringArrayEquals(namedInputs.sharedGlobals, ciWorkflowNamedInput)) {
465
+ namedInputs.default = defaults.filter((input) => input !== 'sharedGlobals');
406
466
  changed = true;
407
467
  }
408
- changed = setStringArrayProperty(namedInputs, 'sharedGlobals', expectedSharedGlobalsNamedInput) || changed;
409
468
  const production = namedInputs.production;
410
469
  if (!Array.isArray(production) || !isPreciseProductionNamedInput(production)) {
411
470
  namedInputs.production = defaultProductionNamedInput;
412
471
  changed = true;
413
472
  }
473
+ for (const name of ['default', 'production'] as const) {
474
+ const inputs = namedInputs[name];
475
+ if (Array.isArray(inputs) && !inputs.includes(MARKDOWN_EXCLUSION)) {
476
+ namedInputs[name] = [...inputs, MARKDOWN_EXCLUSION];
477
+ changed = true;
478
+ }
479
+ }
414
480
  return changed;
415
481
  }
416
482
 
@@ -446,28 +512,8 @@ function isPreciseProductionNamedInput(production: unknown[]): boolean {
446
512
  return hasPositiveProjectInput;
447
513
  }
448
514
 
449
- function upsertNxPlugin(plugins: readonly unknown[], plugin: string | Record<string, unknown>): unknown[] {
450
- const pluginName = typeof plugin === 'string' ? plugin : stringProperty(plugin, 'plugin');
451
- const next = plugins.filter((entry) => nxPluginName(entry) !== pluginName);
452
- next.push(plugin);
453
- return next;
454
- }
455
-
456
- function nxPluginName(value: unknown): string | null {
457
- if (typeof value === 'string') {
458
- return value;
459
- }
460
- return isRecord(value) ? stringProperty(value, 'plugin') : null;
461
- }
462
-
463
- function isNxJsTypescriptPlugin(value: unknown): boolean {
464
- return (
465
- value === nxJsTypescriptPlugin || (isRecord(value) && stringProperty(value, 'plugin') === nxJsTypescriptPlugin)
466
- );
467
- }
468
-
469
- function isSmoothBricksNxPluginRecord(value: unknown): boolean {
470
- return isRecord(value) && stringProperty(value, 'plugin') === smoothBricksNxPlugin;
515
+ function nxPluginName(plugin: PluginConfiguration): string {
516
+ return typeof plugin === 'string' ? plugin : plugin.plugin;
471
517
  }
472
518
 
473
519
  function readJsonObject(path: string): Record<string, unknown> | null {
@@ -482,19 +528,10 @@ function readJsonObject(path: string): Record<string, unknown> | null {
482
528
  }
483
529
  }
484
530
 
485
- function writeJsonObject(path: string, value: Record<string, unknown>): void {
486
- writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
487
- }
488
-
489
531
  function isRecord(value: unknown): value is Record<string, unknown> {
490
532
  return value !== null && typeof value === 'object' && !Array.isArray(value);
491
533
  }
492
534
 
493
- function stringProperty(record: Record<string, unknown>, key: string): string | null {
494
- const value = record[key];
495
- return typeof value === 'string' && value.length > 0 ? value : null;
496
- }
497
-
498
535
  function recordProperty(record: Record<string, unknown>, key: string): Record<string, unknown> | null {
499
536
  const value = record[key];
500
537
  return isRecord(value) ? value : null;
@@ -526,15 +563,6 @@ function setStringProperty(record: Record<string, unknown>, key: string, value:
526
563
  return true;
527
564
  }
528
565
 
529
- function setStringArrayProperty(record: Record<string, unknown>, key: string, value: string[]): boolean {
530
- const current = record[key];
531
- if (stringArrayEquals(current, value)) {
532
- return false;
533
- }
534
- record[key] = value;
535
- return true;
536
- }
537
-
538
566
  function stringArrayEquals(value: unknown, expected: readonly string[]): boolean {
539
567
  return (
540
568
  Array.isArray(value) && value.length === expected.length && value.every((entry, index) => entry === expected[index])
@@ -0,0 +1,18 @@
1
+ import { globWithWorkspaceContext, globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
2
+ import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-root.js';
3
+
4
+ /**
5
+ * The files of Nx's workspace file index that match `globs`, workspace-relative:
6
+ * .gitignore and .nxignore applied, `node_modules` never entered. These are
7
+ * exactly the files Nx's hasher can read, so a value inference derives from
8
+ * them is the same in every checkout of one tree, whatever ignored build
9
+ * output happens to be on disk.
10
+ *
11
+ * The daemon serves only its own workspace's index. Any other root, such as a
12
+ * test fixture or a foreign checkout, is indexed by this process's context.
13
+ */
14
+ export async function globIndexedFiles(workspaceRoot: string, globs: string[]): Promise<string[]> {
15
+ return workspaceRoot === daemonWorkspaceRoot
16
+ ? globWithWorkspaceContext(workspaceRoot, globs)
17
+ : globWithWorkspaceContextSync(workspaceRoot, globs);
18
+ }