@smoothbricks/nx-plugin 0.4.14 → 0.4.16

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 (119) hide show
  1. package/README.md +20 -3
  2. package/dist/deploy-policy.d.ts +26 -0
  3. package/dist/deploy-policy.d.ts.map +1 -0
  4. package/dist/deploy-policy.js +36 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +160 -37
  7. package/dist/managed-assets.d.ts +3 -0
  8. package/dist/managed-assets.d.ts.map +1 -0
  9. package/dist/managed-assets.js +3 -0
  10. package/dist/managed-files/ci-workflow.d.ts +215 -0
  11. package/dist/managed-files/ci-workflow.d.ts.map +1 -0
  12. package/dist/managed-files/ci-workflow.js +1082 -0
  13. package/dist/managed-files/context.d.ts +51 -0
  14. package/dist/managed-files/context.d.ts.map +1 -0
  15. package/dist/managed-files/context.js +206 -0
  16. package/dist/managed-files/files.d.ts +53 -0
  17. package/dist/managed-files/files.d.ts.map +1 -0
  18. package/dist/managed-files/files.js +248 -0
  19. package/dist/managed-files/generator.d.ts +16 -0
  20. package/dist/managed-files/generator.d.ts.map +1 -0
  21. package/dist/managed-files/generator.js +41 -0
  22. package/dist/managed-files/github-runs-on.d.ts +19 -0
  23. package/dist/managed-files/github-runs-on.d.ts.map +1 -0
  24. package/dist/managed-files/github-runs-on.js +48 -0
  25. package/dist/managed-files/managed-content.d.ts +45 -0
  26. package/dist/managed-files/managed-content.d.ts.map +1 -0
  27. package/dist/managed-files/managed-content.js +102 -0
  28. package/dist/managed-files/managed-format.d.ts +37 -0
  29. package/dist/managed-files/managed-format.d.ts.map +1 -0
  30. package/dist/managed-files/managed-format.js +94 -0
  31. package/dist/managed-files/paths.d.ts +8 -0
  32. package/dist/managed-files/paths.d.ts.map +1 -0
  33. package/dist/managed-files/paths.js +46 -0
  34. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +5 -0
  35. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -0
  36. package/dist/managed-files/pr-preview-cleanup-workflow.js +38 -0
  37. package/dist/managed-files/private-npm-policy.d.ts +7 -0
  38. package/dist/managed-files/private-npm-policy.d.ts.map +1 -0
  39. package/dist/managed-files/private-npm-policy.js +51 -0
  40. package/dist/managed-files/publish-workflow.d.ts +150 -0
  41. package/dist/managed-files/publish-workflow.d.ts.map +1 -0
  42. package/dist/managed-files/publish-workflow.js +989 -0
  43. package/dist/managed-files/tree.d.ts +30 -0
  44. package/dist/managed-files/tree.d.ts.map +1 -0
  45. package/dist/managed-files/tree.js +91 -0
  46. package/dist/package-target-policy.d.ts +0 -1
  47. package/dist/package-target-policy.d.ts.map +1 -1
  48. package/dist/package-target-policy.js +50 -23
  49. package/dist/platform-targets.d.ts +5 -0
  50. package/dist/platform-targets.d.ts.map +1 -0
  51. package/dist/platform-targets.js +4 -0
  52. package/dist/typecheck-test-policy.d.ts +5 -9
  53. package/dist/typecheck-test-policy.d.ts.map +1 -1
  54. package/dist/typecheck-test-policy.js +69 -99
  55. package/dist/workspace-config-policy.d.ts +23 -3
  56. package/dist/workspace-config-policy.d.ts.map +1 -1
  57. package/dist/workspace-config-policy.js +35 -3
  58. package/dist/workspace-manifest.d.ts +291 -0
  59. package/dist/workspace-manifest.d.ts.map +1 -0
  60. package/dist/workspace-manifest.js +6 -0
  61. package/dist/workspace-package-policy.d.ts +13 -0
  62. package/dist/workspace-package-policy.d.ts.map +1 -0
  63. package/dist/workspace-package-policy.js +24 -0
  64. package/generators.json +5 -0
  65. package/managed/raw/envrc +20 -0
  66. package/managed/raw/git-format-staged.yml +82 -0
  67. package/managed/raw/gitattributes +8 -0
  68. package/managed/raw/tooling/devenv +83 -0
  69. package/managed/raw/tooling/direnv/devenv.smoo.nix +422 -0
  70. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +251 -0
  71. package/managed/raw/tooling/direnv/merge-newer-pins.sh +48 -0
  72. package/managed/raw/tooling/direnv/repo-path +34 -0
  73. package/managed/raw/tooling/direnv/secret-references.ts +636 -0
  74. package/managed/raw/tooling/direnv/setup-environment.ts +585 -0
  75. package/managed/raw/tooling/direnv/toolchain-stamp.ts +88 -0
  76. package/managed/raw/tooling/git-hooks/commit-msg.sh +9 -0
  77. package/managed/raw/tooling/git-hooks/post-commit.sh +71 -0
  78. package/managed/raw/tooling/git-hooks/pre-commit.sh +18 -0
  79. package/managed/raw/tooling/git-hooks/pre-push.sh +48 -0
  80. package/managed/raw/tsconfig.lib.json +28 -0
  81. package/managed/templates/github/actions/cache-nix-devenv/action.yml +45 -0
  82. package/managed/templates/github/actions/cache-node-modules/action.yml +17 -0
  83. package/managed/templates/github/actions/cache-nx/action.yml +21 -0
  84. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
  85. package/managed/templates/github/actions/save-nix-devenv/action.yml +32 -0
  86. package/managed/templates/github/actions/setup-devenv/action.yml +241 -0
  87. package/managed/templates/github/workflows/managed-files.yml +127 -0
  88. package/package.json +89 -5
  89. package/src/bun-bootstrap.test.ts +0 -6
  90. package/src/deploy-policy.ts +40 -0
  91. package/src/index.test.ts +232 -9
  92. package/src/index.ts +187 -40
  93. package/src/managed-assets.ts +4 -0
  94. package/src/managed-files/ci-workflow.ts +1365 -0
  95. package/src/managed-files/context.ts +240 -0
  96. package/src/managed-files/files.ts +324 -0
  97. package/src/managed-files/generator.test.ts +151 -0
  98. package/src/managed-files/generator.ts +60 -0
  99. package/src/managed-files/github-runs-on.ts +51 -0
  100. package/src/managed-files/managed-content.test.ts +147 -0
  101. package/src/managed-files/managed-content.ts +121 -0
  102. package/src/managed-files/managed-format.ts +102 -0
  103. package/src/managed-files/paths.ts +44 -0
  104. package/src/managed-files/pr-preview-cleanup-workflow.ts +44 -0
  105. package/src/managed-files/private-npm-policy.ts +62 -0
  106. package/src/managed-files/publish-workflow.ts +1523 -0
  107. package/src/managed-files/schema.json +8 -0
  108. package/src/managed-files/tree-permissions.test.ts +109 -0
  109. package/src/managed-files/tree.test.ts +123 -0
  110. package/src/managed-files/tree.ts +118 -0
  111. package/src/package-target-policy.test.ts +4 -28
  112. package/src/package-target-policy.ts +55 -31
  113. package/src/platform-targets.ts +4 -0
  114. package/src/typecheck-test-policy.test.ts +28 -3
  115. package/src/typecheck-test-policy.ts +46 -121
  116. package/src/workspace-config-policy.test.ts +14 -2
  117. package/src/workspace-config-policy.ts +42 -3
  118. package/src/workspace-manifest.ts +327 -0
  119. package/src/workspace-package-policy.ts +32 -0
@@ -1,7 +1,10 @@
1
- import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
3
  import type { Tree } from 'nx/src/devkit-exports.js';
4
- import { getProjects, readJson, readProjectConfiguration, updateJson, writeJson } from 'nx/src/devkit-exports.js';
4
+ import { getProjects, readJson, readProjectConfiguration } from 'nx/src/devkit-exports.js';
5
+ import typia from 'typia';
6
+ import { ManagedContentConflict } from './managed-files/managed-content.js';
7
+ import type { ManagedFile } from './managed-files/tree.js';
5
8
 
6
9
  import type { NxPolicyIssue } from './workspace-config-policy.js';
7
10
 
@@ -41,7 +44,7 @@ export function detectPackageTestRunners(
41
44
  continue;
42
45
  }
43
46
  const options = recordProperty(target, 'options');
44
- const command = options ? stringProperty(options, 'command') : null;
47
+ const command = (options ? stringProperty(options, 'command') : null) ?? stringProperty(target, 'command');
45
48
  if (command) {
46
49
  const runner = detectTestRunnerFromCommand(command);
47
50
  if (runner) {
@@ -58,7 +61,7 @@ export function detectPackageTestRunners(
58
61
  continue;
59
62
  }
60
63
  const options = recordProperty(target, 'options');
61
- const command = options ? stringProperty(options, 'command') : null;
64
+ const command = (options ? stringProperty(options, 'command') : null) ?? stringProperty(target, 'command');
62
65
  if (command) {
63
66
  const runner = detectTestRunnerFromCommand(command);
64
67
  if (runner) {
@@ -156,13 +159,13 @@ export function applyTypecheckTestDefaults(
156
159
  tsconfigTest: Record<string, unknown>,
157
160
  options: {
158
161
  testRunners: ReadonlySet<TestRunner>;
159
- tsconfigLibExtends?: string;
162
+ tsconfigLibExtends?: string | string[];
160
163
  libCompilerOptions?: Record<string, unknown>;
161
164
  referencePaths: string[];
162
165
  },
163
166
  ): boolean {
164
- const extendsValue = options.tsconfigLibExtends ?? '../../tsconfig.base.json';
165
- let changed = setMissingStringProperty(tsconfigTest, 'extends', extendsValue);
167
+ let changed = !Object.hasOwn(tsconfigTest, 'extends');
168
+ if (changed) tsconfigTest.extends = options.tsconfigLibExtends ?? '../../tsconfig.base.json';
166
169
 
167
170
  const compilerOptions = getOrCreateRecord(tsconfigTest, 'compilerOptions');
168
171
 
@@ -275,11 +278,11 @@ export function checkTypecheckTestPolicyTree(tree: Tree): NxPolicyIssue[] {
275
278
  }
276
279
 
277
280
  /**
278
- * Fix all workspace packages' tsconfig.test.json configuration using an Nx Tree.
279
- * Returns whether any files changed.
281
+ * Render test typechecking policy from the caller's Tree. The managed generator
282
+ * owns staging, permission checks, and flushing together with its other files.
280
283
  */
281
- export function applyTypecheckTestPolicyTree(tree: Tree): boolean {
282
- let changed = false;
284
+ export function renderTypecheckTestFiles(tree: Tree): ManagedFile[] {
285
+ const files: ManagedFile[] = [];
283
286
  const workspacePackages = collectWorkspacePackagesTree(tree);
284
287
 
285
288
  for (const [projectName, config] of getProjects(tree)) {
@@ -302,39 +305,42 @@ export function applyTypecheckTestPolicyTree(tree: Tree): boolean {
302
305
  // Read lib tsconfig for extends and compiler options
303
306
  const libTsconfigPath = `${config.root}/tsconfig.lib.json`;
304
307
  const libTsconfig = tree.exists(libTsconfigPath) ? readJson<Record<string, unknown>>(tree, libTsconfigPath) : null;
305
- const tsconfigLibExtends =
306
- (libTsconfig ? stringProperty(libTsconfig, 'extends') : null) ?? '../../tsconfig.base.json';
308
+ const tsconfigLibExtends = tsconfigExtends(libTsconfig) ?? '../../tsconfig.base.json';
307
309
  const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
308
310
 
309
311
  // Collect reference paths
310
312
  const referencePaths = collectReferencePathsTree(tree, config.root, pkg, workspacePackages);
311
313
 
312
- if (
313
- applyTypecheckTestDefaults(tsconfigTest, {
314
- testRunners,
315
- tsconfigLibExtends,
316
- libCompilerOptions: libCompilerOptions ?? undefined,
317
- referencePaths,
318
- }) ||
319
- isNew
320
- ) {
321
- writeJson(tree, tsconfigTestPath, tsconfigTest);
322
- changed = true;
323
- }
314
+ const changed = applyTypecheckTestDefaults(tsconfigTest, {
315
+ testRunners,
316
+ tsconfigLibExtends,
317
+ libCompilerOptions: libCompilerOptions ?? undefined,
318
+ referencePaths,
319
+ });
320
+ files.push(renderTsconfig(tree, tsconfigTestPath, tsconfigTest, changed || isNew));
324
321
 
325
322
  // Remove test reference from tsconfig.json
326
323
  const tsconfigPath = `${config.root}/tsconfig.json`;
327
324
  if (tree.exists(tsconfigPath)) {
328
- updateJson(tree, tsconfigPath, (tsconfig: Record<string, unknown>) => {
329
- if (removeTsconfigTestReference(tsconfig)) {
330
- changed = true;
331
- }
332
- return tsconfig;
333
- });
325
+ const tsconfig = readJson<Record<string, unknown>>(tree, tsconfigPath);
326
+ files.push(renderTsconfig(tree, tsconfigPath, tsconfig, removeTsconfigTestReference(tsconfig)));
334
327
  }
335
328
  }
336
329
 
337
- return changed;
330
+ return files;
331
+ }
332
+
333
+ function renderTsconfig(tree: Tree, target: string, config: Record<string, unknown>, changed: boolean): ManagedFile {
334
+ const current = tree.read(target, 'utf8');
335
+ if (!changed) return { target, content: current };
336
+ // A documented config cannot survive JSON.stringify. Preserve its reasoning
337
+ // and refuse before the shared generator stages or flushes any managed file.
338
+ if (current !== null && hasJsonComments(current)) {
339
+ throw new ManagedContentConflict(
340
+ `${target} carries comments a rewrite would delete; apply the no-emit test typecheck policy by hand`,
341
+ );
342
+ }
343
+ return { target, content: `${JSON.stringify(config, null, 2)}\n` };
338
344
  }
339
345
 
340
346
  /**
@@ -383,7 +389,7 @@ export function checkTypecheckTestPolicy(root: string): NxPolicyIssue[] {
383
389
  issues.push(...absoluteIssues);
384
390
  if (absoluteIssues.length === 0) {
385
391
  const libTsconfig = readJsonObject(join(root, packagePath, 'tsconfig.lib.json'));
386
- const tsconfigLibExtends = stringProperty(libTsconfig ?? {}, 'extends') ?? '../../tsconfig.base.json';
392
+ const tsconfigLibExtends = tsconfigExtends(libTsconfig) ?? '../../tsconfig.base.json';
387
393
  const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
388
394
  const referencePaths = collectTsconfigTestReferencePaths(root, packagePath, pkg, workspaceNames);
389
395
  const normalized = structuredClone(tsconfig);
@@ -412,79 +418,6 @@ export function checkTypecheckTestPolicy(root: string): NxPolicyIssue[] {
412
418
  return issues;
413
419
  }
414
420
 
415
- /**
416
- * Fix all workspace packages' tsconfig.test.json configuration.
417
- * Returns whether any files changed.
418
- */
419
- export function applyTypecheckTestPolicy(root: string): boolean {
420
- const workspaceNames = getWorkspacePackageNames(root);
421
- let changed = false;
422
-
423
- for (const packageJsonPath of listWorkspacePackageJsonPaths(root)) {
424
- const pkg = readJsonObject(packageJsonPath);
425
- if (!pkg) {
426
- continue;
427
- }
428
- const packageDir = packageJsonPath.slice(0, -'/package.json'.length);
429
- const packagePath = relative(root, packageDir);
430
- if (packagePath === '' || packagePath === '.') {
431
- continue;
432
- }
433
-
434
- const testRunners = detectPackageTestRunners(pkg);
435
- if (testRunners.size === 0) {
436
- continue;
437
- }
438
-
439
- // Create/update tsconfig.test.json
440
- const tsconfigTestPath = join(root, packagePath, 'tsconfig.test.json');
441
- const existing = readJsonObject(tsconfigTestPath);
442
- const tsconfigTest = existing ?? {};
443
- let fileChanged = existing === null;
444
-
445
- // Read lib tsconfig for extends and compiler options
446
- const libTsconfig = readJsonObject(join(root, packagePath, 'tsconfig.lib.json'));
447
- const tsconfigLibExtends = stringProperty(libTsconfig ?? {}, 'extends') ?? '../../tsconfig.base.json';
448
- const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
449
-
450
- // Collect reference paths
451
- const referencePaths = collectTsconfigTestReferencePaths(root, packagePath, pkg, workspaceNames);
452
-
453
- fileChanged =
454
- applyTypecheckTestDefaults(tsconfigTest, {
455
- testRunners,
456
- tsconfigLibExtends,
457
- libCompilerOptions: libCompilerOptions ?? undefined,
458
- referencePaths,
459
- }) || fileChanged;
460
-
461
- if (fileChanged) {
462
- // A documented tsconfig cannot survive JSON.stringify, so the policy says
463
- // what it wants instead of quietly deleting the reasoning. The check
464
- // half (checkTypecheckTestPolicy) reports the same drift, so CI still
465
- // fails until a human applies it.
466
- if (existsSync(tsconfigTestPath) && hasJsonComments(readFileSync(tsconfigTestPath, 'utf8'))) {
467
- console.error(
468
- `refused ${packagePath}/tsconfig.test.json carries comments a rewrite would delete; apply the policy by hand`,
469
- );
470
- continue;
471
- }
472
- writeJsonObjectFs(tsconfigTestPath, tsconfigTest);
473
- changed = true;
474
- }
475
-
476
- // Remove ./tsconfig.test.json from tsconfig.json references if present
477
- const projectTsconfigPath = join(root, packagePath, 'tsconfig.json');
478
- const projectTsconfig = readJsonObject(projectTsconfigPath);
479
- if (projectTsconfig && removeTsconfigTestReference(projectTsconfig)) {
480
- writeJsonObjectFs(projectTsconfigPath, projectTsconfig);
481
- changed = true;
482
- }
483
- }
484
-
485
- return changed;
486
- }
487
-
488
421
  function detectTestRunnerFromCommand(command: string): TestRunner | null {
489
422
  const trimmed = parseEnvPrefixedCommand(command).command.trim();
490
423
  if (/^bun\s+test(?:\s|$)/.test(trimmed)) {
@@ -704,9 +637,8 @@ function collectTsconfigTestReferencePaths(
704
637
  * documented one. Returning null there meant "file absent", and the caller
705
638
  * regenerated it from scratch: a `lib` the test program declared, an
706
639
  * `exclude`, an extra `include` glob and every comment explaining them
707
- * disappeared on the next `smoo monorepo update`. Comments are stripped for
708
- * parsing only; a caller that intends to write back must decide what to do
709
- * about them (see writeJsonObjectFs's caller).
640
+ * disappeared on the next update. Comments are stripped for parsing only;
641
+ * renderTsconfig refuses a policy repair that would discard them.
710
642
  */
711
643
  function readJsonObject(path: string): Record<string, unknown> | null {
712
644
  if (!existsSync(path)) {
@@ -774,14 +706,15 @@ function stripJsonComments(text: string): string {
774
706
  return output.replace(/,(\s*[}\]])/g, '$1');
775
707
  }
776
708
 
777
- function writeJsonObjectFs(path: string, value: Record<string, unknown>): void {
778
- writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
779
- }
780
-
781
709
  function isRecord(value: unknown): value is Record<string, unknown> {
782
710
  return value !== null && typeof value === 'object' && !Array.isArray(value);
783
711
  }
784
712
 
713
+ /** TypeScript 5 accepts ordered base-config arrays as well as a single base. */
714
+ function tsconfigExtends(config: Record<string, unknown> | null): string | string[] | undefined {
715
+ return typia.assert<string | string[] | undefined>(config?.extends);
716
+ }
717
+
785
718
  function stringProperty(record: Record<string, unknown>, key: string): string | null {
786
719
  const value = record[key];
787
720
  return typeof value === 'string' && value.length > 0 ? value : null;
@@ -803,14 +736,6 @@ function getOrCreateRecord(record: Record<string, unknown>, key: string): Record
803
736
  return next;
804
737
  }
805
738
 
806
- function setMissingStringProperty(record: Record<string, unknown>, key: string, value: string): boolean {
807
- if (typeof record[key] === 'string') {
808
- return false;
809
- }
810
- record[key] = value;
811
- return true;
812
- }
813
-
814
739
  function setBooleanProperty(record: Record<string, unknown>, key: string, value: boolean): boolean {
815
740
  if (record[key] === value) {
816
741
  return false;
@@ -26,6 +26,7 @@ import {
26
26
  function validNxJson(): Record<string, unknown> {
27
27
  return {
28
28
  plugins: ['@smoothbricks/nx-plugin'],
29
+ sync: { globalGenerators: ['@smoothbricks/nx-plugin:managed-files'] },
29
30
  targetDefaults: validTargetDefaults(),
30
31
  namedInputs: validNamedInputs(),
31
32
  };
@@ -344,8 +345,7 @@ describe('pure core: applyWorkspaceConfig', () => {
344
345
 
345
346
  it('accepts custom precise production inputs unchanged', () => {
346
347
  const nxJson: Record<string, unknown> = {
347
- plugins: validPlugins(),
348
- targetDefaults: validTargetDefaults(),
348
+ ...validNxJson(),
349
349
  namedInputs: {
350
350
  ...validNamedInputs(),
351
351
  production: ['{projectRoot}/src/**/*.rs', '{projectRoot}/Cargo.toml', '!{projectRoot}/**/*.test.*'],
@@ -524,3 +524,15 @@ function readPluginNames(value: unknown): unknown[] {
524
524
  const plugins: unknown[] = value;
525
525
  return plugins.map((plugin) => (typeof plugin === 'string' ? plugin : expectRecord(plugin).plugin));
526
526
  }
527
+
528
+ describe('managed-file sync registration', () => {
529
+ it('preserves other generators and is idempotent', () => {
530
+ const nxJson = { sync: { applyChanges: true, globalGenerators: ['example:sync'] } };
531
+ applyWorkspaceConfig(nxJson);
532
+ expect(nxJson.sync).toEqual({
533
+ applyChanges: true,
534
+ globalGenerators: ['example:sync', '@smoothbricks/nx-plugin:managed-files'],
535
+ });
536
+ expect(applyWorkspaceConfig(nxJson)).toBe(false);
537
+ });
538
+ });
@@ -3,6 +3,10 @@ import { join } from 'node:path';
3
3
  import type { Tree } from 'nx/src/devkit-exports.js';
4
4
  import { readJson, updateJson } from 'nx/src/devkit-exports.js';
5
5
 
6
+ import { CARGO_TEST_TARGET } from './cargo-workspace.js';
7
+
8
+ export const MANAGED_FILES_SYNC_GENERATOR = '@smoothbricks/nx-plugin:managed-files';
9
+
6
10
  export interface NxPolicyIssue {
7
11
  path: string;
8
12
  message: string;
@@ -20,9 +24,38 @@ export const BUILD_OUTPUT_DEPENDENCIES = [
20
24
  '*-wasm',
21
25
  ] as const;
22
26
 
23
- export const MACOS_PLATFORM_TARGET_GLOBS = ['*-macos', '*-ios'] as const;
24
- export const LINUX_PLATFORM_TARGET_GLOBS = ['*-linux'] as const;
25
- export const PLATFORM_TARGET_GLOBS = [...MACOS_PLATFORM_TARGET_GLOBS, ...LINUX_PLATFORM_TARGET_GLOBS] as const;
27
+ export { LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, PLATFORM_TARGET_GLOBS } from './platform-targets.js';
28
+
29
+ const buildOutputTargetSuffixes = BUILD_OUTPUT_DEPENDENCIES.map((glob) => glob.slice(1));
30
+
31
+ /**
32
+ * The glob list above, spelled as a target name: a target whose name ends in a
33
+ * reserved family suffix EMITS that kind of artifact. Inference collects
34
+ * exactly these names into the `nx:noop` build aggregate, which makes this the
35
+ * same rule that decides whether a hand-declared aggregate names an edge
36
+ * inference could have produced on its own — one definition, two readers, so
37
+ * the removal policy cannot drift away from what it judges redundant.
38
+ */
39
+ export function isBuildOutputTargetName(name: string): boolean {
40
+ return buildOutputTargetSuffixes.some((suffix) => name.endsWith(suffix));
41
+ }
42
+
43
+ /**
44
+ * A target whose job is to RUN tests. `test`, anything under `test-`/`test:`,
45
+ * and the plugin's own `cargo-test-<crate>` namespace. Deliberately name-based:
46
+ * the aggregate is assembled from declared AND inferred target names, and a
47
+ * declaration carries no marker saying "this executes rather than emits".
48
+ *
49
+ * A runner collides with the families by construction whenever its name ends in
50
+ * one: a crate named `…-js` puts `cargo-test-<crate>` in the family, and a bun
51
+ * suite named `test-bun` reads as "tool=test, output=bun". Both would drag a
52
+ * test suite into `build`, so the rule is the CLASS, not one namespace.
53
+ */
54
+ export function isTestRunnerTargetName(name: string): boolean {
55
+ return (
56
+ name === 'test' || name.startsWith('test-') || name.startsWith('test:') || name.startsWith(`${CARGO_TEST_TARGET}-`)
57
+ );
58
+ }
26
59
 
27
60
  const nxJsTypescriptPlugin = '@nx/js/typescript';
28
61
  const smoothBricksNxPlugin = '@smoothbricks/nx-plugin';
@@ -121,6 +154,12 @@ export function applyWorkspaceConfig(nxJson: Record<string, unknown>): boolean {
121
154
  nxJson.plugins = nextPlugins;
122
155
  changed = true;
123
156
  }
157
+ const sync = recordProperty(nxJson, 'sync') ?? {};
158
+ const generators = Array.isArray(sync.globalGenerators) ? sync.globalGenerators : [];
159
+ if (!generators.includes(MANAGED_FILES_SYNC_GENERATOR)) {
160
+ nxJson.sync = { ...sync, globalGenerators: [...generators, MANAGED_FILES_SYNC_GENERATOR] };
161
+ changed = true;
162
+ }
124
163
  return changed;
125
164
  }
126
165