@smoothbricks/nx-plugin 0.7.17 → 0.7.19

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 (199) hide show
  1. package/README.md +315 -114
  2. package/dist/.build-inputs.json +47 -38
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/bun-lock-scope.d.ts +128 -20
  5. package/dist/bun-lock-scope.d.ts.map +1 -1
  6. package/dist/bun-lock-scope.js +267 -44
  7. package/dist/cargo-closure-input.d.ts +8 -6
  8. package/dist/cargo-closure-input.d.ts.map +1 -1
  9. package/dist/cargo-closure-input.js +15 -12
  10. package/dist/cargo-source-hash.d.ts +26 -25
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +84 -105
  13. package/dist/cargo-toolchain-paths.d.ts +2 -2
  14. package/dist/cargo-toolchain-paths.js +2 -2
  15. package/dist/cargo-workspace.d.ts +20 -2
  16. package/dist/cargo-workspace.d.ts.map +1 -1
  17. package/dist/cargo-workspace.js +43 -22
  18. package/dist/ensure-built-receipt.d.ts +3 -2
  19. package/dist/ensure-built-receipt.d.ts.map +1 -1
  20. package/dist/ensure-built-receipt.js +3 -2
  21. package/dist/eslint-config-closure.d.ts +8 -3
  22. package/dist/eslint-config-closure.d.ts.map +1 -1
  23. package/dist/eslint-config-closure.js +24 -5
  24. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  25. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  27. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  28. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  29. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  30. package/dist/executors/bounded-exec/bounds.d.ts +19 -6
  31. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/bounds.js +22 -15
  33. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  34. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  35. package/dist/executors/bounded-exec/case-gate.js +342 -0
  36. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  37. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  39. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  40. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  42. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  43. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  44. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  45. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  46. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  48. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  49. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/executor.js +256 -86
  51. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  52. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  53. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  54. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  55. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  56. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  57. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
  58. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  59. package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
  60. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  61. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  62. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  63. package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
  64. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  65. package/dist/executors/bounded-exec/mbx-pool.js +45 -8
  66. package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
  67. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  68. package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
  69. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  70. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  71. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  72. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  73. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  74. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  75. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  76. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  77. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  78. package/dist/executors/bounded-exec/progress.d.ts +5 -1
  79. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  80. package/dist/executors/bounded-exec/progress.js +31 -1
  81. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  82. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  83. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  84. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  85. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  86. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  87. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  88. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  89. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  90. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  91. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  92. package/dist/executors/bounded-exec/schema.d.ts +7 -2
  93. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  94. package/dist/executors/bounded-exec/schema.js +17 -1
  95. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  96. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  97. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  98. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  99. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  100. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  101. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  102. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/test-results.js +2 -2
  104. package/dist/executors/bounded-exec/verdict.d.ts +39 -10
  105. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  106. package/dist/executors/bounded-exec/verdict.js +60 -14
  107. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  108. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  109. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +294 -152
  112. package/dist/managed-files/ci-workflow.d.ts +4 -1
  113. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  114. package/dist/managed-files/ci-workflow.js +9 -14
  115. package/dist/managed-files/files.d.ts +3 -3
  116. package/dist/managed-files/files.js +3 -3
  117. package/dist/managed-files/generator.d.ts +5 -1
  118. package/dist/managed-files/generator.d.ts.map +1 -1
  119. package/dist/managed-files/generator.js +22 -7
  120. package/dist/managed-files/render-memo.d.ts +13 -0
  121. package/dist/managed-files/render-memo.d.ts.map +1 -0
  122. package/dist/managed-files/render-memo.js +94 -0
  123. package/dist/task-results.js +2 -1
  124. package/dist/test-program.d.ts +11 -6
  125. package/dist/test-program.d.ts.map +1 -1
  126. package/dist/test-program.js +39 -35
  127. package/dist/tool-bins.d.ts +12 -0
  128. package/dist/tool-bins.d.ts.map +1 -1
  129. package/dist/tool-bins.js +31 -6
  130. package/dist/typecheck-test-policy.d.ts +10 -1
  131. package/dist/typecheck-test-policy.d.ts.map +1 -1
  132. package/dist/typecheck-test-policy.js +40 -24
  133. package/dist/workspace-config-policy.d.ts.map +1 -1
  134. package/dist/workspace-config-policy.js +135 -42
  135. package/dist/workspace-index.d.ts +14 -1
  136. package/dist/workspace-index.d.ts.map +1 -1
  137. package/dist/workspace-index.js +36 -4
  138. package/executors.json +2 -0
  139. package/managed/raw/envrc +24 -0
  140. package/managed/raw/patches/nx@24.0.3.patch +1851 -221
  141. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  142. package/managed/raw/tooling/direnv/developer-links.ts +122 -14
  143. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  144. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  145. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  146. package/package.json +68 -11
  147. package/runtime/nx-publish/.build-inputs.json +2 -2
  148. package/runtime/nx-publish/cache_adapter.js +293 -3
  149. package/runtime/nx-publish/nx_publish.js +36 -14
  150. package/src/built-output-packages.ts +1 -1
  151. package/src/bun-lock-scope.ts +293 -40
  152. package/src/cargo-closure-input.ts +20 -12
  153. package/src/cargo-source-hash.ts +119 -145
  154. package/src/cargo-toolchain-paths.ts +2 -2
  155. package/src/cargo-workspace.ts +59 -21
  156. package/src/ensure-built-receipt.ts +3 -2
  157. package/src/eslint-config-closure.ts +27 -6
  158. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  159. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  160. package/src/executors/bounded-exec/bounds.ts +41 -19
  161. package/src/executors/bounded-exec/case-gate.ts +365 -0
  162. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  163. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  164. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  165. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  166. package/src/executors/bounded-exec/executor.ts +341 -123
  167. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  168. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  169. package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
  170. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  171. package/src/executors/bounded-exec/mbx-pool.ts +57 -9
  172. package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
  173. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  174. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  175. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  176. package/src/executors/bounded-exec/progress.ts +39 -3
  177. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  178. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  179. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  180. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  181. package/src/executors/bounded-exec/schema.json +1 -1
  182. package/src/executors/bounded-exec/schema.ts +21 -2
  183. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  184. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  185. package/src/executors/bounded-exec/test-results.ts +5 -0
  186. package/src/executors/bounded-exec/verdict.ts +83 -22
  187. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  188. package/src/index.ts +357 -166
  189. package/src/managed-files/ci-workflow.ts +13 -17
  190. package/src/managed-files/files.ts +3 -3
  191. package/src/managed-files/generator.ts +21 -6
  192. package/src/managed-files/render-memo.ts +135 -0
  193. package/src/test-program.ts +36 -41
  194. package/src/tool-bins.ts +35 -6
  195. package/src/typecheck-test-policy.ts +49 -24
  196. package/src/workspace-config-policy.ts +161 -43
  197. package/src/workspace-index.ts +40 -5
  198. package/test-timings.json +157 -141
  199. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
@@ -124,6 +124,9 @@ export function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyI
124
124
 
125
125
  // Colon target defaults
126
126
  const targetDefaults = recordProperty(nxJson, 'targetDefaults');
127
+ if (nxJson.targetDefaults !== undefined && targetDefaults === null) {
128
+ issues.push({ path: 'nx.json', message: 'targetDefaults must be an object; smoo does not rewrite it' });
129
+ }
127
130
  if (targetDefaults) {
128
131
  for (const targetName of Object.keys(targetDefaults)) {
129
132
  if (targetName.includes(':')) {
@@ -142,12 +145,15 @@ export function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyI
142
145
  'Per-project inference selects current library or build outputs before test typechecking.',
143
146
  });
144
147
  }
145
- if (isRetiredCleanTargetDefault(targetDefaults, targetName)) {
148
+ if (retiredCleanEntries(targetDefaults, targetName).length !== 0) {
146
149
  issues.push({
147
150
  path: 'nx.json',
148
151
  message: `targetDefaults.clean names the retired ${retiredCleanOutputsExecutor}; run smoo monorepo update to remove it`,
149
152
  });
150
153
  }
154
+ if (targetDefault(nxJson, targetName).form === 'malformed') {
155
+ issues.push({ path: 'nx.json', message: malformedTargetDefaultMessage(targetName) });
156
+ }
151
157
  }
152
158
  }
153
159
 
@@ -293,10 +299,22 @@ function validateBuildTargetDefault(
293
299
  nxJsonPath: string,
294
300
  issues: NxPolicyIssue[],
295
301
  ): void {
296
- const targetDefaults = recordProperty(nxJson, 'targetDefaults');
297
- const build = targetDefaults ? recordProperty(targetDefaults, 'build') : null;
298
- if (build?.cache !== true) {
299
- issues.push({ path: nxJsonPath, message: 'targetDefaults.build.cache must be true' });
302
+ const build = targetDefault(nxJson, 'build');
303
+ if (build.form === 'malformed') {
304
+ return;
305
+ }
306
+ const entries = build.form === 'absent' ? [] : build.entries;
307
+ if (catchAllValue(entries, 'cache') !== true) {
308
+ issues.push({
309
+ path: nxJsonPath,
310
+ message:
311
+ build.form === 'list'
312
+ ? 'targetDefaults.build.cache must be true in an entry without a filter'
313
+ : 'targetDefaults.build.cache must be true',
314
+ });
315
+ }
316
+ if (entries.some((entry) => 'filter' in entry && 'cache' in entry && entry.cache !== true)) {
317
+ issues.push({ path: nxJsonPath, message: 'targetDefaults.build.cache must be true in every entry that sets it' });
300
318
  }
301
319
  // dependsOn and outputs are both owned by the inference plugin, and Nx gives
302
320
  // targetDefaults precedence over inferred values, so anything set here lands
@@ -319,7 +337,7 @@ function validateBuildTargetDefault(
319
337
  // `build` genuinely emits files declares its own outputs in package.json,
320
338
  // where the claim is scoped to the project that can honour it.
321
339
  for (const property of ['dependsOn', 'outputs'] as const) {
322
- if (build !== null && property in build) {
340
+ if (entries.some((entry) => property in entry)) {
323
341
  issues.push({
324
342
  path: nxJsonPath,
325
343
  message: `targetDefaults.build.${property} must not be set; @smoothbricks/nx-plugin infers the build aggregate`,
@@ -393,25 +411,45 @@ function markdownExclusionMessage(name: 'default' | 'production'): string {
393
411
  }
394
412
 
395
413
  function applyBuildTargetDefault(nxJson: Record<string, unknown>): boolean {
396
- const targetDefaults = getOrCreateRecord(nxJson, 'targetDefaults');
397
- const build = getOrCreateRecord(targetDefaults, 'build');
398
- let changed = setBooleanProperty(build, 'cache', true);
399
- for (const property of ['dependsOn', 'outputs'] as const) {
400
- if (property in build) {
401
- delete build[property];
414
+ const build = targetDefault(nxJson, 'build');
415
+ if (build.form === 'malformed') {
416
+ return false;
417
+ }
418
+ if (build.form === 'absent') {
419
+ const targetDefaults = recordProperty(nxJson, 'targetDefaults');
420
+ if (nxJson.targetDefaults !== undefined && targetDefaults === null) {
421
+ return false;
422
+ }
423
+ getOrCreateRecord(nxJson, 'targetDefaults').build = { cache: true };
424
+ return true;
425
+ }
426
+ let changed = false;
427
+ if (catchAllValue(build.entries, 'cache') !== true) {
428
+ const catchAll = build.entries.filter((entry) => !('filter' in entry)).at(-1);
429
+ if (catchAll !== undefined) {
430
+ changed = setBooleanProperty(catchAll, 'cache', true);
431
+ } else if (build.form === 'list') {
432
+ // A list with no entry for every build gets one that caches; the entries it holds stay as written.
433
+ build.list.push({ cache: true });
402
434
  changed = true;
435
+ } else {
436
+ changed = setBooleanProperty(build.record, 'cache', true);
403
437
  }
404
438
  }
405
- return changed;
439
+ for (const entry of build.entries) {
440
+ if ('filter' in entry && 'cache' in entry && entry.cache !== true) {
441
+ delete entry.cache;
442
+ changed = true;
443
+ }
444
+ }
445
+ return deleteMembers(build.entries, ['dependsOn', 'outputs']) || changed;
406
446
  }
407
447
 
408
448
  function validateTestTargetDefault(nxJson: Record<string, unknown>, nxJsonPath: string, issues: NxPolicyIssue[]): void {
409
- const targetDefaults = recordProperty(nxJson, 'targetDefaults');
410
- const test = targetDefaults ? recordProperty(targetDefaults, 'test') : null;
411
449
  // Same clobber as targetDefaults.build.dependsOn: Nx replaces an inferred
412
450
  // list rather than merging, so a workspace-wide [^build, build] unwires
413
451
  // cargo-test from every Rust test aggregate. Cache stays allowed.
414
- if (test !== null && 'dependsOn' in test) {
452
+ if (targetDefaultEntries(nxJson, 'test').some((entry) => 'dependsOn' in entry)) {
415
453
  issues.push({
416
454
  path: nxJsonPath,
417
455
  message: 'targetDefaults.test.dependsOn must not be set; @smoothbricks/nx-plugin infers the test aggregate',
@@ -420,26 +458,30 @@ function validateTestTargetDefault(nxJson: Record<string, unknown>, nxJsonPath:
420
458
  }
421
459
 
422
460
  function applyTestTargetDefault(nxJson: Record<string, unknown>): boolean {
423
- const targetDefaults = recordProperty(nxJson, 'targetDefaults');
424
- const test = targetDefaults ? recordProperty(targetDefaults, 'test') : null;
425
- if (test === null || !('dependsOn' in test)) {
426
- return false;
427
- }
428
- delete test.dependsOn;
429
- return true;
461
+ return deleteMembers(targetDefaultEntries(nxJson, 'test'), ['dependsOn']);
430
462
  }
431
463
 
432
464
  const inferredLintProperties = ['executor', 'options', 'dependsOn', 'outputs', 'inputs'] as const;
433
465
 
434
- function preservesInferredLintInputs(inputs: unknown): boolean {
435
- return Array.isArray(inputs) && inputs.includes('...') && inputs.includes('^production');
466
+ /**
467
+ * Whether an entry's inputs keep what lint infers. Every entry spreads what came before it (`...`); an entry for every
468
+ * lint target also keeps the dependency declarations (`^production`), which a filtered entry inherits by spreading it.
469
+ */
470
+ function preservesInferredLintInputs(entry: Record<string, unknown>): boolean {
471
+ const inputs = entry.inputs;
472
+ return Array.isArray(inputs) && inputs.includes('...') && ('filter' in entry || inputs.includes('^production'));
473
+ }
474
+
475
+ function offendingLintProperties(entry: Record<string, unknown>): string[] {
476
+ return inferredLintProperties.filter(
477
+ (property) => property in entry && !(property === 'inputs' && preservesInferredLintInputs(entry)),
478
+ );
436
479
  }
437
480
 
438
481
  function validateLintTargetDefault(nxJson: Record<string, unknown>, nxJsonPath: string, issues: NxPolicyIssue[]): void {
439
- const defaults = recordProperty(nxJson, 'targetDefaults');
440
- const lint = defaults ? recordProperty(defaults, 'lint') : null;
482
+ const offending = new Set(targetDefaultEntries(nxJson, 'lint').flatMap(offendingLintProperties));
441
483
  for (const property of inferredLintProperties) {
442
- if (lint !== null && property in lint && !(property === 'inputs' && preservesInferredLintInputs(lint.inputs))) {
484
+ if (offending.has(property)) {
443
485
  issues.push({
444
486
  path: nxJsonPath,
445
487
  message: `targetDefaults.lint.${property} must not be set; @smoothbricks/nx-plugin infers lint from project sources`,
@@ -449,15 +491,9 @@ function validateLintTargetDefault(nxJson: Record<string, unknown>, nxJsonPath:
449
491
  }
450
492
 
451
493
  function applyLintTargetDefault(nxJson: Record<string, unknown>): boolean {
452
- const defaults = recordProperty(nxJson, 'targetDefaults');
453
- const lint = defaults ? recordProperty(defaults, 'lint') : null;
454
- if (lint === null) return false;
455
494
  let changed = false;
456
- for (const property of inferredLintProperties) {
457
- if (property in lint && !(property === 'inputs' && preservesInferredLintInputs(lint.inputs))) {
458
- delete lint[property];
459
- changed = true;
460
- }
495
+ for (const entry of targetDefaultEntries(nxJson, 'lint')) {
496
+ changed = deleteMembers([entry], offendingLintProperties(entry)) || changed;
461
497
  }
462
498
  return changed;
463
499
  }
@@ -499,20 +535,35 @@ function removeDisallowedTargetDefaults(nxJson: Record<string, unknown>): boolea
499
535
  }
500
536
  let changed = false;
501
537
  for (const targetName of Object.keys(targetDefaults)) {
502
- if (
503
- targetName.includes(':') ||
504
- targetName === inferredTestTypecheckTarget ||
505
- isRetiredCleanTargetDefault(targetDefaults, targetName)
506
- ) {
538
+ if (targetName.includes(':') || targetName === inferredTestTypecheckTarget) {
507
539
  delete targetDefaults[targetName];
508
540
  changed = true;
541
+ continue;
542
+ }
543
+ const retired = retiredCleanEntries(targetDefaults, targetName);
544
+ if (retired.length === 0) {
545
+ continue;
546
+ }
547
+ const value = targetDefaults[targetName];
548
+ const kept = Array.isArray(value) ? value.filter((entry) => !retired.includes(entry)) : [];
549
+ if (kept.length === 0) {
550
+ delete targetDefaults[targetName];
551
+ } else {
552
+ targetDefaults[targetName] = kept;
509
553
  }
554
+ changed = true;
510
555
  }
511
556
  return changed;
512
557
  }
513
558
 
514
- function isRetiredCleanTargetDefault(targetDefaults: Record<string, unknown>, targetName: string): boolean {
515
- return targetName === 'clean' && recordProperty(targetDefaults, 'clean')?.executor === retiredCleanOutputsExecutor;
559
+ /** The entries of `targetName`'s default that name the retired clean executor, which the policy removes. */
560
+ function retiredCleanEntries(targetDefaults: Record<string, unknown>, targetName: string): Record<string, unknown>[] {
561
+ if (targetName !== 'clean') {
562
+ return [];
563
+ }
564
+ return targetDefaultEntries({ targetDefaults }, 'clean').filter(
565
+ (entry) => entry.executor === retiredCleanOutputsExecutor,
566
+ );
516
567
  }
517
568
 
518
569
  function isPreciseProductionNamedInput(production: unknown[]): boolean {
@@ -576,6 +627,73 @@ function recordProperty(record: Record<string, unknown>, key: string): Record<st
576
627
  return isRecord(value) ? value : null;
577
628
  }
578
629
 
630
+ /**
631
+ * A target default as Nx 24 reads it: one record, or a list of records merged in document order, each applying to the
632
+ * targets its optional `filter` matches; an entry without one applies to every target of the name. Anything else is
633
+ * not a target default the policy can read, and it is refused by name rather than replaced.
634
+ */
635
+ type TargetDefault =
636
+ | { readonly form: 'absent' }
637
+ | {
638
+ readonly form: 'record';
639
+ readonly entries: readonly Record<string, unknown>[];
640
+ readonly record: Record<string, unknown>;
641
+ }
642
+ | {
643
+ readonly form: 'list';
644
+ readonly entries: readonly Record<string, unknown>[];
645
+ readonly list: Record<string, unknown>[];
646
+ }
647
+ | { readonly form: 'malformed' };
648
+
649
+ function targetDefault(nxJson: Record<string, unknown>, targetName: string): TargetDefault {
650
+ const value = recordProperty(nxJson, 'targetDefaults')?.[targetName];
651
+ if (value === undefined) {
652
+ return { form: 'absent' };
653
+ }
654
+ if (isRecord(value)) {
655
+ return { form: 'record', entries: [value], record: value };
656
+ }
657
+ if (Array.isArray(value) && value.every(isRecord)) {
658
+ return { form: 'list', entries: [...value], list: value };
659
+ }
660
+ return { form: 'malformed' };
661
+ }
662
+
663
+ /** The entries of a readable target default; none for an absent or malformed one, which validation reports. */
664
+ function targetDefaultEntries(nxJson: Record<string, unknown>, targetName: string): readonly Record<string, unknown>[] {
665
+ const value = targetDefault(nxJson, targetName);
666
+ return value.form === 'record' || value.form === 'list' ? value.entries : [];
667
+ }
668
+
669
+ /** What every target of the name receives for `key` from the entries without a filter: Nx merges them, last one wins. */
670
+ function catchAllValue(entries: readonly Record<string, unknown>[], key: string): unknown {
671
+ let value: unknown;
672
+ for (const entry of entries) {
673
+ if (!('filter' in entry) && key in entry) {
674
+ value = entry[key];
675
+ }
676
+ }
677
+ return value;
678
+ }
679
+
680
+ /** Remove `members` from every entry that holds them; the entries themselves and their other members stay. */
681
+ function deleteMembers(entries: readonly Record<string, unknown>[], members: readonly string[]): boolean {
682
+ let changed = false;
683
+ for (const entry of entries) {
684
+ for (const member of members) {
685
+ if (member in entry) {
686
+ delete entry[member];
687
+ changed = true;
688
+ }
689
+ }
690
+ }
691
+ return changed;
692
+ }
693
+
694
+ function malformedTargetDefaultMessage(targetName: string): string {
695
+ return `targetDefaults.${targetName} must be an object or a list of objects; smoo does not rewrite it`;
696
+ }
579
697
  function getOrCreateRecord(record: Record<string, unknown>, key: string): Record<string, unknown> {
580
698
  const value = record[key];
581
699
  if (isRecord(value)) {
@@ -1,6 +1,7 @@
1
- import native from 'nx/src/native/index.js';
1
+ import { join } from 'node:path';
2
+ import native, { type FileData } from 'nx/src/native/index.js';
2
3
  import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
3
- import { globWithWorkspaceContext, globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
4
+ import { getAllFileDataInContext, globWithWorkspaceContext } from 'nx/src/utils/workspace-context.js';
4
5
  import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-root.js';
5
6
 
6
7
  /**
@@ -11,12 +12,15 @@ import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-roo
11
12
  * output happens to be on disk.
12
13
  *
13
14
  * The daemon serves only its own workspace's index. Any other root, such as a
14
- * test fixture or a foreign checkout, is indexed by this process's context.
15
+ * test fixture or a foreign checkout, is read from the filesystem now
16
+ * ({@link freshIndexedFiles}), under that root's own data directory: Nx's
17
+ * process context for it would resolve the inherited NX_WORKSPACE_DATA_DIRECTORY,
18
+ * this workspace's, and take its files lock and archive.
15
19
  */
16
20
  export async function globIndexedFiles(workspaceRoot: string, globs: string[]): Promise<string[]> {
17
21
  return workspaceRoot === daemonWorkspaceRoot
18
22
  ? globWithWorkspaceContext(workspaceRoot, globs)
19
- : globWithWorkspaceContextSync(workspaceRoot, globs);
23
+ : freshIndexedFiles(workspaceRoot, globs);
20
24
  }
21
25
 
22
26
  /**
@@ -26,5 +30,36 @@ export async function globIndexedFiles(workspaceRoot: string, globs: string[]):
26
30
  * runs on the files as they are asks here; what describes a graph asks {@link globIndexedFiles}.
27
31
  */
28
32
  export function freshIndexedFiles(workspaceRoot: string, globs: string[]): string[] {
29
- return new native.WorkspaceContext(workspaceRoot, workspaceDataDirectoryForWorkspace(workspaceRoot)).glob(globs);
33
+ return new native.WorkspaceContext(workspaceRoot, indexDataDirectory(workspaceRoot)).glob(globs);
34
+ }
35
+
36
+ /**
37
+ * Every file of Nx's workspace file index with Nx's content hash of it, workspace-relative: the hashes Nx's task
38
+ * hasher keys every fileset on, kept current by its watcher, so a caller can tell an unchanged file without reading
39
+ * it. The daemon serves its own workspace; any other root, such as a test fixture, is read from the filesystem now
40
+ * ({@link freshIndexedFileData}), since the daemon's answer would be about another tree.
41
+ */
42
+ export async function indexedFileData(workspaceRoot: string): Promise<FileData[]> {
43
+ return workspaceRoot === daemonWorkspaceRoot
44
+ ? getAllFileDataInContext(workspaceRoot)
45
+ : freshIndexedFileData(workspaceRoot);
46
+ }
47
+
48
+ /** Like {@link indexedFileData}, read from the filesystem now, as {@link freshIndexedFiles} lists it. */
49
+ export function freshIndexedFileData(workspaceRoot: string): FileData[] {
50
+ return new native.WorkspaceContext(workspaceRoot, indexDataDirectory(workspaceRoot)).allFileData();
51
+ }
52
+
53
+ /**
54
+ * Where a fresh native context of `workspaceRoot` keeps its files lock and archive. Nx's
55
+ * `workspaceDataDirectoryForWorkspace` answers `NX_WORKSPACE_DATA_DIRECTORY` for every root, and that variable names
56
+ * this process's workspace's data (CI points it at a shared directory outside the checkout). A walk of another root
57
+ * there takes this workspace's files lock, and when another process holds it, loads the archive that process writes,
58
+ * this workspace's files, as the other root's (CI's Lint, run 42738719423: the compiled-in fixtures found no crate).
59
+ * Any other root walks under Nx's default for it, inside itself.
60
+ */
61
+ function indexDataDirectory(workspaceRoot: string): string {
62
+ return workspaceRoot === daemonWorkspaceRoot
63
+ ? workspaceDataDirectoryForWorkspace(workspaceRoot)
64
+ : join(workspaceRoot, '.nx', 'workspace-data');
30
65
  }