@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
@@ -0,0 +1,30 @@
1
+ import type { Tree } from 'nx/src/devkit-exports.js';
2
+ /** Rendered template input. A disabled descriptor never authorizes deletion. */
3
+ export interface ManagedFile {
4
+ target: string;
5
+ content: string | null;
6
+ executable?: boolean;
7
+ }
8
+ /** Only facts Tree cannot expose. File contents always come from Tree. */
9
+ export interface ManagedPathInfo {
10
+ symlink?: boolean;
11
+ executable?: boolean;
12
+ error?: string;
13
+ }
14
+ /** User-facing diagnostics, not a second representation of Tree's file changes. */
15
+ export interface FileResult {
16
+ target: string;
17
+ action: 'created' | 'updated' | 'unchanged' | 'skipped' | 'skipped-symlink' | 'drifted' | 'ok-symlink';
18
+ reason?: string;
19
+ }
20
+ export declare function isManagedTarget(target: string): boolean;
21
+ /** Pure ownership rule; retain exact existing bytes when only permissions need repair. */
22
+ export declare function mergeManagedContent(current: string, desired: string): string;
23
+ /**
24
+ * Stage updates in Nx's virtual filesystem. No disk, process, graph, or network
25
+ * access. The caller decides whether to inspect or flush Tree.listChanges().
26
+ * A conflict may leave earlier edits staged; neither caller may flush that Tree.
27
+ */
28
+ export declare function stageManagedFiles(tree: Tree, files: readonly ManagedFile[], paths?: ReadonlyMap<string, ManagedPathInfo>): FileResult[];
29
+ export declare function assertNoManagedConflicts(results: readonly FileResult[]): void;
30
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/managed-files/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAQjE,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;IACvG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvD;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM5E;AASD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAa,GACtD,UAAU,EAAE,CA8Cd;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAO7E"}
@@ -0,0 +1,91 @@
1
+ import { extractInlineLocalBlocks, ManagedContentConflict, reinsertInlineLocalBlocks, splitLocalSection, } from './managed-content.js';
2
+ export function isManagedTarget(target) {
3
+ return (target.length > 0 &&
4
+ !/[\0\\:]/.test(target) &&
5
+ target.split('/').every((part) => part !== '' && part !== '.' && part !== '..'));
6
+ }
7
+ /** Pure ownership rule; retain exact existing bytes when only permissions need repair. */
8
+ export function mergeManagedContent(current, desired) {
9
+ const { managed, localTail } = splitLocalSection(current);
10
+ const { withoutInline, blocks } = extractInlineLocalBlocks(managed);
11
+ const rendered = reinsertInlineLocalBlocks(desired, blocks);
12
+ if (withoutInline === desired || (localTail !== '' && withoutInline === `${desired}\n`))
13
+ return current;
14
+ return localTail === '' ? rendered : `${rendered}\n${localTail}`;
15
+ }
16
+ /** Pending Nx edits override disk facts; updates without a mode retain the disk mode. */
17
+ function stagedExecutable(change, onDisk) {
18
+ const mode = change?.options?.mode;
19
+ if (mode === undefined)
20
+ return change?.type === 'CREATE' ? false : onDisk;
21
+ return ((typeof mode === 'string' ? Number.parseInt(mode, 8) : mode) & 0o100) !== 0;
22
+ }
23
+ /**
24
+ * Stage updates in Nx's virtual filesystem. No disk, process, graph, or network
25
+ * access. The caller decides whether to inspect or flush Tree.listChanges().
26
+ * A conflict may leave earlier edits staged; neither caller may flush that Tree.
27
+ */
28
+ export function stageManagedFiles(tree, files, paths = new Map()) {
29
+ const seen = new Set();
30
+ const pending = new Map(tree.listChanges().map((change) => [change.path, change]));
31
+ const targets = new Set(files.map((file) => file.target));
32
+ return files.map(({ target, content, executable = false }) => {
33
+ const conflict = (reason) => ({ target, action: 'drifted', reason });
34
+ if (!isManagedTarget(target))
35
+ return conflict('expected a canonical workspace-relative path');
36
+ if (seen.has(target))
37
+ return conflict('duplicate managed target');
38
+ seen.add(target);
39
+ const parts = target.split('/');
40
+ if (parts.some((_, i) => i > 0 && targets.has(parts.slice(0, i).join('/')))) {
41
+ return conflict('a managed file is also declared as a parent directory');
42
+ }
43
+ if (content === null)
44
+ return { target, action: 'skipped' };
45
+ const path = paths.get(target);
46
+ if (path?.error)
47
+ return conflict(path.error);
48
+ for (let i = 1; i < parts.length; i++) {
49
+ if (tree.isFile(parts.slice(0, i).join('/')))
50
+ return conflict('parent path is a file');
51
+ }
52
+ if (tree.exists(target) && !tree.isFile(target))
53
+ return conflict('target is not a regular file');
54
+ const current = tree.read(target, 'utf8');
55
+ if (current === null && tree.exists(target))
56
+ return conflict('target cannot be read');
57
+ try {
58
+ const rendered = current === null ? content : mergeManagedContent(current, content);
59
+ const currentExecutable = stagedExecutable(pending.get(target), path?.executable);
60
+ const modeMatches = currentExecutable === undefined || currentExecutable === executable;
61
+ if (path?.symlink) {
62
+ return current === rendered && modeMatches
63
+ ? { target, action: 'ok-symlink' }
64
+ : conflict('symlink content or executable mode differs; update its source explicitly');
65
+ }
66
+ const mode = executable ? 0o755 : 0o644;
67
+ if (current !== rendered)
68
+ tree.write(target, rendered);
69
+ // A write reverting a prior generator's edit to the on-disk content can
70
+ // erase its pending mode too. Stage permissions after every content write,
71
+ // as well as for permission-only repairs, using Nx's dedicated API.
72
+ if (current !== rendered || !modeMatches)
73
+ tree.changePermissions(target, mode);
74
+ return {
75
+ target,
76
+ action: current === null ? 'created' : current !== rendered || !modeMatches ? 'updated' : 'unchanged',
77
+ };
78
+ }
79
+ catch (error) {
80
+ if (!(error instanceof ManagedContentConflict))
81
+ throw error;
82
+ return conflict(error.message);
83
+ }
84
+ });
85
+ }
86
+ export function assertNoManagedConflicts(results) {
87
+ const conflicts = results.filter((result) => result.reason !== undefined);
88
+ if (conflicts.length > 0) {
89
+ throw new ManagedContentConflict(`Managed-file update refused before writing:\n${conflicts.map(({ target, reason }) => `${target}: ${reason}`).join('\n')}`);
90
+ }
91
+ }
@@ -5,7 +5,6 @@ export type { NxPolicyIssue };
5
5
  export interface ResolvedProjectTargets {
6
6
  root?: string;
7
7
  targets: ReadonlySet<string>;
8
- buildDependsOn?: readonly string[];
9
8
  targetDependencies?: ReadonlyMap<string, readonly string[]>;
10
9
  targetExecutors?: ReadonlyMap<string, string>;
11
10
  targetOptions?: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"package-target-policy.d.ts","sourceRoot":"","sources":["../src/package-target-policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,IAAI,EAAc,MAAM,0BAA0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B,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EACnC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAO,GAC1F,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAoBhH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA8BxG"}
@@ -3,7 +3,7 @@ import { join } from 'node:path';
3
3
  import { getProjects, readJson, updateJson } from 'nx/src/devkit-exports.js';
4
4
  import { boundedTestScriptAlias } from './bounded-test-policy.js';
5
5
  import { isNonSourceDirectory } from './source-directories.js';
6
- import { BUILD_OUTPUT_DEPENDENCIES, LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, } from './workspace-config-policy.js';
6
+ import { BUILD_OUTPUT_DEPENDENCIES, isBuildOutputTargetName, isTestRunnerTargetName, LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, } from './workspace-config-policy.js';
7
7
  export { BUILD_OUTPUT_DEPENDENCIES, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
8
8
  const workspaceDependencyFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
9
9
  function isRecord(value) {
@@ -126,12 +126,6 @@ function resolvedProjectTargetNames(resolvedProject) {
126
126
  }
127
127
  return isResolvedProjectTargets(resolvedProject) ? resolvedProject.targets : resolvedProject;
128
128
  }
129
- function resolvedProjectBuildDependsOn(resolvedProject) {
130
- if (!isResolvedProjectTargets(resolvedProject)) {
131
- return undefined;
132
- }
133
- return resolvedProject.buildDependsOn;
134
- }
135
129
  function resolvedProjectTargetExecutor(resolvedProject, targetName) {
136
130
  return isResolvedProjectTargets(resolvedProject) ? resolvedProject.targetExecutors?.get(targetName) : undefined;
137
131
  }
@@ -198,34 +192,67 @@ function isNoopTarget(target) {
198
192
  const options = recordProperty(target, 'options');
199
193
  return !options || stringProperty(options, 'command') === null;
200
194
  }
201
- function targetDependenciesMatchResolvedBuild(target, resolvedBuildDependsOn) {
202
- if (!Array.isArray(target.dependsOn)) {
195
+ /**
196
+ * Properties the inferred aggregate already sets to exactly these values. A
197
+ * declaration carrying anything else — `inputs`, `outputs`, `cache: false`, a
198
+ * `configurations` block — is CHANGING the aggregate, not restating it.
199
+ */
200
+ const inferredNoopBuildProperties = { executor: true, cache: true, dependsOn: true };
201
+ /**
202
+ * Can the build-aggregate inference produce this edge on its own?
203
+ *
204
+ * The inferred aggregate is `^build` plus the project's own build-output
205
+ * targets — `isBuildOutputTargetName`, test runners excluded — and
206
+ * `BUILD_OUTPUT_DEPENDENCIES` is the glob spelling of that same list. Anything
207
+ * else is an edge only the declaration carries: a project-local target outside
208
+ * the families (`build-cli`), or a `project:target` edge to a sibling target
209
+ * that is not named `build`, which `^build` never visits.
210
+ */
211
+ function isInferredBuildDependency(dependency, resolvedTargets) {
212
+ if (typeof dependency !== 'string') {
213
+ return false;
214
+ }
215
+ if (dependency === '^build' || isBuildOutputDependencyPattern(dependency)) {
216
+ return true;
217
+ }
218
+ return isBuildOutputTargetName(dependency) && !isTestRunnerTargetName(dependency) && resolvedTargets.has(dependency);
219
+ }
220
+ function isRedundantBuildDeclaration(build, resolvedTargets) {
221
+ if (!Object.keys(build).every((key) => inferredNoopBuildProperties[key] === true)) {
203
222
  return false;
204
223
  }
205
- const expected = new Set(resolvedBuildDependsOn);
206
- if (target.dependsOn.length !== expected.size) {
224
+ if ('cache' in build && build.cache !== true) {
207
225
  return false;
208
226
  }
209
- return target.dependsOn.every((dependency) => {
210
- if (typeof dependency !== 'string') {
211
- return false;
212
- }
213
- return expected.has(dependency);
214
- });
227
+ // An empty list is a deliberate cut — "this aggregate waits for nothing" —
228
+ // and restoring the inferred edges by deleting it is a behaviour change.
229
+ return (Array.isArray(build.dependsOn) &&
230
+ build.dependsOn.length > 0 &&
231
+ build.dependsOn.every((dependency) => isInferredBuildDependency(dependency, resolvedTargets)));
215
232
  }
233
+ /**
234
+ * A hand-declared `build` is deleted only when inference provably rebuilds it.
235
+ *
236
+ * Deliberately NOT decided against the resolved project graph. Nx replaces a
237
+ * named property of an inferred target with the declared one, so the resolved
238
+ * `build.dependsOn` IS the declaration: comparing them answered "redundant"
239
+ * for every noop aggregate anyone ever wrote. AxE's `containium` lost seven
240
+ * edges that way — four of them targets no inference can reach — and a clean
241
+ * checkout then built it without its producers. The question this has to
242
+ * answer is what inference yields WITHOUT the declaration, so the test is
243
+ * structural: every declared edge must be one the aggregate already collects.
244
+ */
216
245
  function removeRedundantNoopBuildTarget(pkg, resolvedProject) {
217
246
  const resolvedTargets = resolvedProjectTargetNames(resolvedProject);
218
- const resolvedBuildDependsOn = resolvedProjectBuildDependsOn(resolvedProject);
219
- if (!resolvedTargets?.has('build') || !resolvedBuildDependsOn) {
247
+ // No build-output target in the project, no inferred aggregate to fall back
248
+ // on: deleting the declaration would leave it with no `build` at all.
249
+ if (!resolvedTargets?.has('build') || ![...resolvedTargets].some(isBuildOutputTargetName)) {
220
250
  return false;
221
251
  }
222
252
  const nx = recordProperty(pkg, 'nx');
223
253
  const targets = nx ? recordProperty(nx, 'targets') : null;
224
254
  const build = targets ? recordProperty(targets, 'build') : null;
225
- if (!targets ||
226
- !build ||
227
- !isNoopTarget(build) ||
228
- !targetDependenciesMatchResolvedBuild(build, resolvedBuildDependsOn)) {
255
+ if (!targets || !build || !isNoopTarget(build) || !isRedundantBuildDeclaration(build, resolvedTargets)) {
229
256
  return false;
230
257
  }
231
258
  delete targets.build;
@@ -0,0 +1,5 @@
1
+ /** Shared artifact target naming conventions; no graph construction or filesystem access. */
2
+ export declare const MACOS_PLATFORM_TARGET_GLOBS: readonly ['*-macos', '*-ios'];
3
+ export declare const LINUX_PLATFORM_TARGET_GLOBS: readonly ['*-linux'];
4
+ export declare const PLATFORM_TARGET_GLOBS: readonly ["*-macos", "*-ios", "*-linux"];
5
+ //# sourceMappingURL=platform-targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-targets.d.ts","sourceRoot":"","sources":["../src/platform-targets.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,eAAO,MAAM,2BAA2B,YAAI,SAAS,EAAE,OAAO,CAAU,CAAC;AACzE,eAAO,MAAM,2BAA2B,YAAI,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,qBAAqB,0CAA4E,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Shared artifact target naming conventions; no graph construction or filesystem access. */
2
+ export const MACOS_PLATFORM_TARGET_GLOBS = ['*-macos', '*-ios'];
3
+ export const LINUX_PLATFORM_TARGET_GLOBS = ['*-linux'];
4
+ export const PLATFORM_TARGET_GLOBS = [...MACOS_PLATFORM_TARGET_GLOBS, ...LINUX_PLATFORM_TARGET_GLOBS];
@@ -1,4 +1,5 @@
1
1
  import type { Tree } from 'nx/src/devkit-exports.js';
2
+ import type { ManagedFile } from './managed-files/tree.js';
2
3
  import type { NxPolicyIssue } from './workspace-config-policy.js';
3
4
  export type TestRunner = 'bun' | 'vitest';
4
5
  /**
@@ -21,7 +22,7 @@ export declare function checkTsconfigTestReference(projectTsconfig: Record<strin
21
22
  */
22
23
  export declare function applyTypecheckTestDefaults(tsconfigTest: Record<string, unknown>, options: {
23
24
  testRunners: ReadonlySet<TestRunner>;
24
- tsconfigLibExtends?: string;
25
+ tsconfigLibExtends?: string | string[];
25
26
  libCompilerOptions?: Record<string, unknown>;
26
27
  referencePaths: string[];
27
28
  }): boolean;
@@ -35,10 +36,10 @@ export declare function removeTsconfigTestReference(projectTsconfig: Record<stri
35
36
  */
36
37
  export declare function checkTypecheckTestPolicyTree(tree: Tree): NxPolicyIssue[];
37
38
  /**
38
- * Fix all workspace packages' tsconfig.test.json configuration using an Nx Tree.
39
- * Returns whether any files changed.
39
+ * Render test typechecking policy from the caller's Tree. The managed generator
40
+ * owns staging, permission checks, and flushing together with its other files.
40
41
  */
41
- export declare function applyTypecheckTestPolicyTree(tree: Tree): boolean;
42
+ export declare function renderTypecheckTestFiles(tree: Tree): ManagedFile[];
42
43
  /**
43
44
  * Check all workspace packages for typecheck test policy compliance.
44
45
  *
@@ -48,9 +49,4 @@ export declare function applyTypecheckTestPolicyTree(tree: Tree): boolean;
48
49
  * - tsconfig.json must NOT reference ./tsconfig.test.json
49
50
  */
50
51
  export declare function checkTypecheckTestPolicy(root: string): NxPolicyIssue[];
51
- /**
52
- * Fix all workspace packages' tsconfig.test.json configuration.
53
- * Returns whether any files changed.
54
- */
55
- export declare function applyTypecheckTestPolicy(root: string): boolean;
56
52
  //# sourceMappingURL=typecheck-test-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAI1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EA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,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC/C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAYjB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GACA,OAAO,CAsDT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAO7F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAwCxE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,EAAE,CA+ClE;AAeD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAiEtE"}
@@ -1,6 +1,9 @@
1
- import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import * as _assertGuard_1 from "typia/lib/internal/_assertGuard";
2
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
3
  import { join, relative } from 'node:path';
3
- 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';
4
7
  const workspaceDependencyFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
5
8
  /**
6
9
  * Detect test runners from a package.json object and optional project targets
@@ -29,7 +32,7 @@ export function detectPackageTestRunners(pkg, projectTargets) {
29
32
  continue;
30
33
  }
31
34
  const options = recordProperty(target, 'options');
32
- const command = options ? stringProperty(options, 'command') : null;
35
+ const command = (options ? stringProperty(options, 'command') : null) ?? stringProperty(target, 'command');
33
36
  if (command) {
34
37
  const runner = detectTestRunnerFromCommand(command);
35
38
  if (runner) {
@@ -45,7 +48,7 @@ export function detectPackageTestRunners(pkg, projectTargets) {
45
48
  continue;
46
49
  }
47
50
  const options = recordProperty(target, 'options');
48
- const command = options ? stringProperty(options, 'command') : null;
51
+ const command = (options ? stringProperty(options, 'command') : null) ?? stringProperty(target, 'command');
49
52
  if (command) {
50
53
  const runner = detectTestRunnerFromCommand(command);
51
54
  if (runner) {
@@ -126,8 +129,9 @@ export function checkTsconfigTestReference(projectTsconfig, packagePath) {
126
129
  * Returns whether anything changed.
127
130
  */
128
131
  export function applyTypecheckTestDefaults(tsconfigTest, options) {
129
- const extendsValue = options.tsconfigLibExtends ?? '../../tsconfig.base.json';
130
- let changed = setMissingStringProperty(tsconfigTest, 'extends', extendsValue);
132
+ let changed = !Object.hasOwn(tsconfigTest, 'extends');
133
+ if (changed)
134
+ tsconfigTest.extends = options.tsconfigLibExtends ?? '../../tsconfig.base.json';
131
135
  const compilerOptions = getOrCreateRecord(tsconfigTest, 'compilerOptions');
132
136
  // Fill from the lib tsconfig only what the test program has NOT declared. A
133
137
  // test program that names its own `lib` is stating a fact the lib program
@@ -224,11 +228,11 @@ export function checkTypecheckTestPolicyTree(tree) {
224
228
  return issues;
225
229
  }
226
230
  /**
227
- * Fix all workspace packages' tsconfig.test.json configuration using an Nx Tree.
228
- * Returns whether any files changed.
231
+ * Render test typechecking policy from the caller's Tree. The managed generator
232
+ * owns staging, permission checks, and flushing together with its other files.
229
233
  */
230
- export function applyTypecheckTestPolicyTree(tree) {
231
- let changed = false;
234
+ export function renderTypecheckTestFiles(tree) {
235
+ const files = [];
232
236
  const workspacePackages = collectWorkspacePackagesTree(tree);
233
237
  for (const [projectName, config] of getProjects(tree)) {
234
238
  const pkgPath = `${config.root}/package.json`;
@@ -249,32 +253,36 @@ export function applyTypecheckTestPolicyTree(tree) {
249
253
  // Read lib tsconfig for extends and compiler options
250
254
  const libTsconfigPath = `${config.root}/tsconfig.lib.json`;
251
255
  const libTsconfig = tree.exists(libTsconfigPath) ? readJson(tree, libTsconfigPath) : null;
252
- const tsconfigLibExtends = (libTsconfig ? stringProperty(libTsconfig, 'extends') : null) ?? '../../tsconfig.base.json';
256
+ const tsconfigLibExtends = tsconfigExtends(libTsconfig) ?? '../../tsconfig.base.json';
253
257
  const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
254
258
  // Collect reference paths
255
259
  const referencePaths = collectReferencePathsTree(tree, config.root, pkg, workspacePackages);
256
- if (applyTypecheckTestDefaults(tsconfigTest, {
260
+ const changed = applyTypecheckTestDefaults(tsconfigTest, {
257
261
  testRunners,
258
262
  tsconfigLibExtends,
259
263
  libCompilerOptions: libCompilerOptions ?? undefined,
260
264
  referencePaths,
261
- }) ||
262
- isNew) {
263
- writeJson(tree, tsconfigTestPath, tsconfigTest);
264
- changed = true;
265
- }
265
+ });
266
+ files.push(renderTsconfig(tree, tsconfigTestPath, tsconfigTest, changed || isNew));
266
267
  // Remove test reference from tsconfig.json
267
268
  const tsconfigPath = `${config.root}/tsconfig.json`;
268
269
  if (tree.exists(tsconfigPath)) {
269
- updateJson(tree, tsconfigPath, (tsconfig) => {
270
- if (removeTsconfigTestReference(tsconfig)) {
271
- changed = true;
272
- }
273
- return tsconfig;
274
- });
270
+ const tsconfig = readJson(tree, tsconfigPath);
271
+ files.push(renderTsconfig(tree, tsconfigPath, tsconfig, removeTsconfigTestReference(tsconfig)));
275
272
  }
276
273
  }
277
- return changed;
274
+ return files;
275
+ }
276
+ function renderTsconfig(tree, target, config, changed) {
277
+ const current = tree.read(target, 'utf8');
278
+ if (!changed)
279
+ return { target, content: current };
280
+ // A documented config cannot survive JSON.stringify. Preserve its reasoning
281
+ // and refuse before the shared generator stages or flushes any managed file.
282
+ if (current !== null && hasJsonComments(current)) {
283
+ throw new ManagedContentConflict(`${target} carries comments a rewrite would delete; apply the no-emit test typecheck policy by hand`);
284
+ }
285
+ return { target, content: `${JSON.stringify(config, null, 2)}\n` };
278
286
  }
279
287
  /**
280
288
  * Check all workspace packages for typecheck test policy compliance.
@@ -319,7 +327,7 @@ export function checkTypecheckTestPolicy(root) {
319
327
  issues.push(...absoluteIssues);
320
328
  if (absoluteIssues.length === 0) {
321
329
  const libTsconfig = readJsonObject(join(root, packagePath, 'tsconfig.lib.json'));
322
- const tsconfigLibExtends = stringProperty(libTsconfig ?? {}, 'extends') ?? '../../tsconfig.base.json';
330
+ const tsconfigLibExtends = tsconfigExtends(libTsconfig) ?? '../../tsconfig.base.json';
323
331
  const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
324
332
  const referencePaths = collectTsconfigTestReferencePaths(root, packagePath, pkg, workspaceNames);
325
333
  const normalized = structuredClone(tsconfig);
@@ -344,67 +352,6 @@ export function checkTypecheckTestPolicy(root) {
344
352
  }
345
353
  return issues;
346
354
  }
347
- /**
348
- * Fix all workspace packages' tsconfig.test.json configuration.
349
- * Returns whether any files changed.
350
- */
351
- export function applyTypecheckTestPolicy(root) {
352
- const workspaceNames = getWorkspacePackageNames(root);
353
- let changed = false;
354
- for (const packageJsonPath of listWorkspacePackageJsonPaths(root)) {
355
- const pkg = readJsonObject(packageJsonPath);
356
- if (!pkg) {
357
- continue;
358
- }
359
- const packageDir = packageJsonPath.slice(0, -'/package.json'.length);
360
- const packagePath = relative(root, packageDir);
361
- if (packagePath === '' || packagePath === '.') {
362
- continue;
363
- }
364
- const testRunners = detectPackageTestRunners(pkg);
365
- if (testRunners.size === 0) {
366
- continue;
367
- }
368
- // Create/update tsconfig.test.json
369
- const tsconfigTestPath = join(root, packagePath, 'tsconfig.test.json');
370
- const existing = readJsonObject(tsconfigTestPath);
371
- const tsconfigTest = existing ?? {};
372
- let fileChanged = existing === null;
373
- // Read lib tsconfig for extends and compiler options
374
- const libTsconfig = readJsonObject(join(root, packagePath, 'tsconfig.lib.json'));
375
- const tsconfigLibExtends = stringProperty(libTsconfig ?? {}, 'extends') ?? '../../tsconfig.base.json';
376
- const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
377
- // Collect reference paths
378
- const referencePaths = collectTsconfigTestReferencePaths(root, packagePath, pkg, workspaceNames);
379
- fileChanged =
380
- applyTypecheckTestDefaults(tsconfigTest, {
381
- testRunners,
382
- tsconfigLibExtends,
383
- libCompilerOptions: libCompilerOptions ?? undefined,
384
- referencePaths,
385
- }) || fileChanged;
386
- if (fileChanged) {
387
- // A documented tsconfig cannot survive JSON.stringify, so the policy says
388
- // what it wants instead of quietly deleting the reasoning. The check
389
- // half (checkTypecheckTestPolicy) reports the same drift, so CI still
390
- // fails until a human applies it.
391
- if (existsSync(tsconfigTestPath) && hasJsonComments(readFileSync(tsconfigTestPath, 'utf8'))) {
392
- console.error(`refused ${packagePath}/tsconfig.test.json carries comments a rewrite would delete; apply the policy by hand`);
393
- continue;
394
- }
395
- writeJsonObjectFs(tsconfigTestPath, tsconfigTest);
396
- changed = true;
397
- }
398
- // Remove ./tsconfig.test.json from tsconfig.json references if present
399
- const projectTsconfigPath = join(root, packagePath, 'tsconfig.json');
400
- const projectTsconfig = readJsonObject(projectTsconfigPath);
401
- if (projectTsconfig && removeTsconfigTestReference(projectTsconfig)) {
402
- writeJsonObjectFs(projectTsconfigPath, projectTsconfig);
403
- changed = true;
404
- }
405
- }
406
- return changed;
407
- }
408
355
  function detectTestRunnerFromCommand(command) {
409
356
  const trimmed = parseEnvPrefixedCommand(command).command.trim();
410
357
  if (/^bun\s+test(?:\s|$)/.test(trimmed)) {
@@ -597,9 +544,8 @@ function collectTsconfigTestReferencePaths(root, packagePath, pkg, workspaceName
597
544
  * documented one. Returning null there meant "file absent", and the caller
598
545
  * regenerated it from scratch: a `lib` the test program declared, an
599
546
  * `exclude`, an extra `include` glob and every comment explaining them
600
- * disappeared on the next `smoo monorepo update`. Comments are stripped for
601
- * parsing only; a caller that intends to write back must decide what to do
602
- * about them (see writeJsonObjectFs's caller).
547
+ * disappeared on the next update. Comments are stripped for parsing only;
548
+ * renderTsconfig refuses a policy repair that would discard them.
603
549
  */
604
550
  function readJsonObject(path) {
605
551
  if (!existsSync(path)) {
@@ -669,12 +615,43 @@ function stripJsonComments(text) {
669
615
  }
670
616
  return output.replace(/,(\s*[}\]])/g, '$1');
671
617
  }
672
- function writeJsonObjectFs(path, value) {
673
- writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
674
- }
675
618
  function isRecord(value) {
676
619
  return value !== null && typeof value === 'object' && !Array.isArray(value);
677
620
  }
621
+ /** TypeScript 5 accepts ordered base-config arrays as well as a single base. */
622
+ function tsconfigExtends(config) {
623
+ return (() => {
624
+ const __is = input => null !== input && (undefined === input || "string" === typeof input || Array.isArray(input) && input.every(elem => "string" === typeof elem));
625
+ let _errorFactory;
626
+ return (input, errorFactory) => {
627
+ if (false === __is(input)) {
628
+ _errorFactory = errorFactory;
629
+ ((input, _path, _exceptionable = true) => (null !== input || _assertGuard_1._assertGuard(true, {
630
+ method: "typia.assert",
631
+ path: _path + "",
632
+ expected: "(Array<string> | string | undefined)",
633
+ value: input
634
+ }, _errorFactory)) && (undefined === input || "string" === typeof input || (Array.isArray(input) || _assertGuard_1._assertGuard(true, {
635
+ method: "typia.assert",
636
+ path: _path + "",
637
+ expected: "(Array<string> | string | undefined)",
638
+ value: input
639
+ }, _errorFactory)) && input.every((elem, _index2) => "string" === typeof elem || _assertGuard_1._assertGuard(true, {
640
+ method: "typia.assert",
641
+ path: _path + "[" + _index2 + "]",
642
+ expected: "string",
643
+ value: elem
644
+ }, _errorFactory)) || _assertGuard_1._assertGuard(true, {
645
+ method: "typia.assert",
646
+ path: _path + "",
647
+ expected: "(Array<string> | string | undefined)",
648
+ value: input
649
+ }, _errorFactory)))(input, "$input", true);
650
+ }
651
+ return input;
652
+ };
653
+ })()(config?.extends);
654
+ }
678
655
  function stringProperty(record, key) {
679
656
  const value = record[key];
680
657
  return typeof value === 'string' && value.length > 0 ? value : null;
@@ -694,13 +671,6 @@ function getOrCreateRecord(record, key) {
694
671
  record[key] = next;
695
672
  return next;
696
673
  }
697
- function setMissingStringProperty(record, key, value) {
698
- if (typeof record[key] === 'string') {
699
- return false;
700
- }
701
- record[key] = value;
702
- return true;
703
- }
704
674
  function setBooleanProperty(record, key, value) {
705
675
  if (record[key] === value) {
706
676
  return false;
@@ -1,12 +1,32 @@
1
1
  import type { Tree } from 'nx/src/devkit-exports.js';
2
+ export declare const MANAGED_FILES_SYNC_GENERATOR = "@smoothbricks/nx-plugin:managed-files";
2
3
  export interface NxPolicyIssue {
3
4
  path: string;
4
5
  message: string;
5
6
  }
6
7
  export declare const BUILD_OUTPUT_DEPENDENCIES: readonly ['*-js', '*-web', '*-html', '*-css', '*-android', '*-native', '*-napi', '*-bun', '*-wasm'];
7
- export declare const MACOS_PLATFORM_TARGET_GLOBS: readonly ['*-macos', '*-ios'];
8
- export declare const LINUX_PLATFORM_TARGET_GLOBS: readonly ['*-linux'];
9
- export declare const PLATFORM_TARGET_GLOBS: readonly ["*-macos", "*-ios", "*-linux"];
8
+ export { LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, PLATFORM_TARGET_GLOBS } from './platform-targets.js';
9
+ /**
10
+ * The glob list above, spelled as a target name: a target whose name ends in a
11
+ * reserved family suffix EMITS that kind of artifact. Inference collects
12
+ * exactly these names into the `nx:noop` build aggregate, which makes this the
13
+ * same rule that decides whether a hand-declared aggregate names an edge
14
+ * inference could have produced on its own — one definition, two readers, so
15
+ * the removal policy cannot drift away from what it judges redundant.
16
+ */
17
+ export declare function isBuildOutputTargetName(name: string): boolean;
18
+ /**
19
+ * A target whose job is to RUN tests. `test`, anything under `test-`/`test:`,
20
+ * and the plugin's own `cargo-test-<crate>` namespace. Deliberately name-based:
21
+ * the aggregate is assembled from declared AND inferred target names, and a
22
+ * declaration carries no marker saying "this executes rather than emits".
23
+ *
24
+ * A runner collides with the families by construction whenever its name ends in
25
+ * one: a crate named `…-js` puts `cargo-test-<crate>` in the family, and a bun
26
+ * suite named `test-bun` reads as "tool=test, output=bun". Both would drag a
27
+ * test suite into `build`, so the rule is the CLASS, not one namespace.
28
+ */
29
+ export declare function isTestRunnerTargetName(name: string): boolean;
10
30
  /**
11
31
  * Check workspace config policy on an in-memory nx.json object.
12
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-config-policy.d.ts","sourceRoot":"","sources":["../src/workspace-config-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,yBAAyB,YACpC,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,CACA,CAAC;AAEX,eAAO,MAAM,2BAA2B,YAAI,SAAS,EAAE,OAAO,CAAU,CAAC;AACzE,eAAO,MAAM,2BAA2B,YAAI,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,qBAAqB,0CAA4E,CAAC;AAgB/G;;GAEG;AACH,w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