@rsdk/yarn.constraints 6.0.0-next.39 → 6.0.0-next.40

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 (118) hide show
  1. package/DEPENDENCY_MODEL.md +452 -0
  2. package/README.MD +24 -0
  3. package/__tests__/compatibility.test.ts +321 -0
  4. package/__tests__/engine.test.ts +1002 -0
  5. package/__tests__/fixtures/imports/bin.js +4 -0
  6. package/__tests__/fixtures/imports/export-entry.mjs +1 -0
  7. package/__tests__/fixtures/imports/root-entry.js +3 -0
  8. package/__tests__/fixtures/imports/src/common.cjs +3 -0
  9. package/__tests__/fixtures/imports/src/common.cts +3 -0
  10. package/__tests__/fixtures/imports/src/component.tsx +4 -0
  11. package/__tests__/fixtures/imports/src/index.ts +13 -0
  12. package/__tests__/fixtures/imports/src/module.mjs +3 -0
  13. package/__tests__/fixtures/imports/src/module.mts +3 -0
  14. package/__tests__/fixtures/imports/src/plain.js +3 -0
  15. package/__tests__/fixtures/imports/src/test-only-usage.ts +1 -0
  16. package/__tests__/imports.test.ts +206 -0
  17. package/__tests__/manifest-writer.test.ts +157 -0
  18. package/dist/ansi.d.ts +9 -0
  19. package/dist/ansi.js +24 -0
  20. package/dist/ansi.js.map +1 -0
  21. package/dist/bin/depdoc.d.ts +2 -0
  22. package/dist/bin/depdoc.js +157 -0
  23. package/dist/bin/depdoc.js.map +1 -0
  24. package/dist/collectors/config.d.ts +2 -0
  25. package/dist/collectors/config.js +25 -0
  26. package/dist/collectors/config.js.map +1 -0
  27. package/dist/collectors/external-metadata.d.ts +5 -0
  28. package/dist/collectors/external-metadata.js +110 -0
  29. package/dist/collectors/external-metadata.js.map +1 -0
  30. package/dist/collectors/package-extensions.d.ts +3 -0
  31. package/dist/collectors/package-extensions.js +43 -0
  32. package/dist/collectors/package-extensions.js.map +1 -0
  33. package/dist/collectors/type-providers.d.ts +3 -0
  34. package/dist/collectors/type-providers.js +46 -0
  35. package/dist/collectors/type-providers.js.map +1 -0
  36. package/dist/collectors/workspaces.d.ts +2 -0
  37. package/dist/collectors/workspaces.js +88 -0
  38. package/dist/collectors/workspaces.js.map +1 -0
  39. package/dist/dependency-model.d.ts +11 -0
  40. package/dist/dependency-model.js +18 -0
  41. package/dist/dependency-model.js.map +1 -0
  42. package/dist/index.d.ts +9 -5
  43. package/dist/index.js +13 -33
  44. package/dist/index.js.map +1 -1
  45. package/dist/lib/imports.d.ts +9 -0
  46. package/dist/lib/imports.js +249 -0
  47. package/dist/lib/imports.js.map +1 -0
  48. package/dist/lib/package-json.d.ts +21 -0
  49. package/dist/lib/package-json.js +32 -0
  50. package/dist/lib/package-json.js.map +1 -0
  51. package/dist/model/diagnostics.d.ts +4 -0
  52. package/dist/model/diagnostics.js +273 -0
  53. package/dist/model/diagnostics.js.map +1 -0
  54. package/dist/model/engine.d.ts +5 -0
  55. package/dist/model/engine.js +52 -0
  56. package/dist/model/engine.js.map +1 -0
  57. package/dist/model/expected.d.ts +20 -0
  58. package/dist/model/expected.js +89 -0
  59. package/dist/model/expected.js.map +1 -0
  60. package/dist/model/peer-propagation.d.ts +2 -0
  61. package/dist/model/peer-propagation.js +124 -0
  62. package/dist/model/peer-propagation.js.map +1 -0
  63. package/dist/model/placement.d.ts +9 -0
  64. package/dist/model/placement.js +205 -0
  65. package/dist/model/placement.js.map +1 -0
  66. package/dist/model/rules.d.ts +14 -0
  67. package/dist/model/rules.js +46 -0
  68. package/dist/model/rules.js.map +1 -0
  69. package/dist/model/types.d.ts +117 -0
  70. package/dist/model/types.js +9 -0
  71. package/dist/model/types.js.map +1 -0
  72. package/dist/model/versions.d.ts +3 -0
  73. package/dist/model/versions.js +73 -0
  74. package/dist/model/versions.js.map +1 -0
  75. package/dist/reporting.d.ts +3 -0
  76. package/dist/reporting.js +80 -0
  77. package/dist/reporting.js.map +1 -0
  78. package/dist/runner.d.ts +2 -0
  79. package/dist/runner.js +70 -0
  80. package/dist/runner.js.map +1 -0
  81. package/dist/writer/manifest-writer.d.ts +2 -0
  82. package/dist/writer/manifest-writer.js +72 -0
  83. package/dist/writer/manifest-writer.js.map +1 -0
  84. package/eslint.config.cjs +3 -0
  85. package/jest.config.js +1 -0
  86. package/package.json +7 -3
  87. package/src/ansi.ts +23 -0
  88. package/src/bin/depdoc.ts +213 -0
  89. package/src/collectors/config.ts +26 -0
  90. package/src/collectors/external-metadata.ts +148 -0
  91. package/src/collectors/package-extensions.ts +52 -0
  92. package/src/collectors/type-providers.ts +51 -0
  93. package/src/collectors/workspaces.ts +99 -0
  94. package/src/dependency-model.ts +26 -0
  95. package/src/index.ts +28 -45
  96. package/src/lib/imports.ts +293 -0
  97. package/src/lib/package-json.ts +46 -0
  98. package/src/model/diagnostics.ts +328 -0
  99. package/src/model/engine.ts +120 -0
  100. package/src/model/expected.ts +141 -0
  101. package/src/model/peer-propagation.ts +199 -0
  102. package/src/model/placement.ts +372 -0
  103. package/src/model/rules.ts +73 -0
  104. package/src/model/types.ts +164 -0
  105. package/src/model/versions.ts +109 -0
  106. package/src/reporting.ts +117 -0
  107. package/src/runner.ts +102 -0
  108. package/src/writer/manifest-writer.ts +111 -0
  109. package/tsconfig.build.json +1 -0
  110. package/tsconfig.json +6 -1
  111. package/dist/constraint-schema.d.ts +0 -1
  112. package/dist/constraint-schema.js +0 -17
  113. package/dist/constraint-schema.js.map +0 -1
  114. package/dist/dependency-checker.d.ts +0 -8
  115. package/dist/dependency-checker.js +0 -40
  116. package/dist/dependency-checker.js.map +0 -1
  117. package/src/constraint-schema.ts +0 -20
  118. package/src/dependency-checker.ts +0 -41
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildExpected = buildExpected;
4
+ exports.deriveDependencyModel = deriveDependencyModel;
5
+ /**
6
+ * Pure dependency model engine.
7
+ *
8
+ * The engine receives complete facts and derives expected manifests plus
9
+ * diagnostics. It must not read files, execute Yarn, or inspect `node_modules`;
10
+ * those concerns belong to collectors and the runner.
11
+ */
12
+ const diagnostics_1 = require("./diagnostics");
13
+ const expected_1 = require("./expected");
14
+ const peer_propagation_1 = require("./peer-propagation");
15
+ const placement_1 = require("./placement");
16
+ const versions_1 = require("./versions");
17
+ function buildExpected(workspaces, rules, externalPeerMetadata, externalTypeMetadata, typeProviderPackages) {
18
+ const expectedByLocation = new Map();
19
+ const root = workspaces[0];
20
+ const workspaceNames = new Set(workspaces.filter((ws) => !ws.isRoot).map((ws) => ws.name));
21
+ const workspacesByName = new Map(workspaces.filter((ws) => !ws.isRoot).map((ws) => [ws.name, ws]));
22
+ for (const workspace of workspaces) {
23
+ expectedByLocation.set(workspace.location, {
24
+ workspace,
25
+ sections: (0, expected_1.emptySections)(),
26
+ reasons: new Map(),
27
+ });
28
+ }
29
+ (0, placement_1.seedRootDevDependencies)(expectedByLocation, workspaceNames, rules);
30
+ (0, placement_1.addUsageDependencies)(expectedByLocation, root, workspaceNames, rules, externalTypeMetadata, typeProviderPackages);
31
+ (0, placement_1.addRequiredRuleDependencies)(expectedByLocation, root, workspaceNames, rules);
32
+ (0, peer_propagation_1.propagatePeers)(expectedByLocation, workspacesByName, workspaceNames, externalPeerMetadata, rules);
33
+ (0, versions_1.applyVersionRules)(expectedByLocation, root, workspaceNames, rules);
34
+ (0, placement_1.rebuildLibraryMirrors)(expectedByLocation);
35
+ return expectedByLocation;
36
+ }
37
+ function deriveDependencyModel(facts) {
38
+ const { workspaces, externalPeerMetadata, externalTypeMetadata = new Map(), typeProviderPackages = new Set(), rules, withDts = false, } = facts;
39
+ const expected = buildExpected(workspaces, rules, externalPeerMetadata, externalTypeMetadata, typeProviderPackages);
40
+ const violations = [];
41
+ const warnings = [];
42
+ (0, diagnostics_1.validateBasicShape)(workspaces, expected, rules, violations, warnings, withDts);
43
+ for (const item of expected.values())
44
+ (0, diagnostics_1.compareManifest)(item, violations);
45
+ violations.push(...(0, versions_1.collectUnconstrainedVersionViolations)(workspaces, expected, rules));
46
+ return {
47
+ violations: (0, diagnostics_1.dedupeViolations)(violations),
48
+ warnings,
49
+ expected,
50
+ };
51
+ }
52
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/model/engine.ts"],"names":[],"mappings":";;AA4BA,sCAkDC;AAED,sDAuCC;AAvHD;;;;;;GAMG;AACH,+CAAsF;AACtF,yCAA2C;AAC3C,yDAAoD;AACpD,2CAKqB;AAQrB,yCAGoB;AAEpB,SAAgB,aAAa,CAC3B,UAA4B,EAC5B,KAAuB,EACvB,oBAA6D,EAC7D,oBAA+D,EAC/D,oBAAiC;IAEjC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;IAChE,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAE,CAAC;IAC5B,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAC3D,CAAC;IACF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CACjE,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE;YACzC,SAAS;YACT,QAAQ,EAAE,IAAA,wBAAa,GAAE;YACzB,OAAO,EAAE,IAAI,GAAG,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;IAED,IAAA,mCAAuB,EAAC,kBAAkB,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IACn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QACR,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Helpers for expected dependency sections and their explanations.
3
+ *
4
+ * The model derives a fresh expected manifest for each workspace. This module
5
+ * owns the small mutation primitives for those expected sections and keeps the
6
+ * reason trail used by `depdoc explain`.
7
+ */
8
+ import type { PackageJson } from '../lib/package-json';
9
+ import { getEffectiveRule } from './rules';
10
+ import { type DependencyRule, type ExpectedWorkspace, type Reason, type SectionType, type WorkspaceFacts } from './types';
11
+ export declare function emptySections(): Record<SectionType, Map<string, string>>;
12
+ export declare function getDeclaredSection(pkg: PackageJson, depIdent: string): SectionType | null;
13
+ export declare function getDeclaredRange(pkg: PackageJson, depIdent: string): string | null;
14
+ export declare function addReason(expected: ExpectedWorkspace, depIdent: string, reason: Reason): void;
15
+ export declare function addRuleReason(expected: ExpectedWorkspace, depIdent: string, rule: ReturnType<typeof getEffectiveRule>): void;
16
+ export declare function setExpectedDependency(expected: ExpectedWorkspace, section: SectionType, depIdent: string, range: string, reason: Reason): void;
17
+ export declare function addExpectedMirrorDependency(expected: ExpectedWorkspace, depIdent: string, range: string, reason: Reason): void;
18
+ export declare function getExpectedSection(expected: ExpectedWorkspace, depIdent: string): SectionType | null;
19
+ export declare function getExpectedRange(expected: ExpectedWorkspace, depIdent: string): string | null;
20
+ export declare function getRangeSource(root: WorkspaceFacts, workspace: WorkspaceFacts, depIdent: string, rules: DependencyRule[]): string;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptySections = emptySections;
4
+ exports.getDeclaredSection = getDeclaredSection;
5
+ exports.getDeclaredRange = getDeclaredRange;
6
+ exports.addReason = addReason;
7
+ exports.addRuleReason = addRuleReason;
8
+ exports.setExpectedDependency = setExpectedDependency;
9
+ exports.addExpectedMirrorDependency = addExpectedMirrorDependency;
10
+ exports.getExpectedSection = getExpectedSection;
11
+ exports.getExpectedRange = getExpectedRange;
12
+ exports.getRangeSource = getRangeSource;
13
+ const rules_1 = require("./rules");
14
+ const types_1 = require("./types");
15
+ function emptySections() {
16
+ return {
17
+ dependencies: new Map(),
18
+ peerDependencies: new Map(),
19
+ devDependencies: new Map(),
20
+ };
21
+ }
22
+ function getDeclaredSection(pkg, depIdent) {
23
+ for (const section of types_1.SECTIONS) {
24
+ if (pkg[section]?.[depIdent] !== undefined)
25
+ return section;
26
+ }
27
+ return null;
28
+ }
29
+ function getDeclaredRange(pkg, depIdent) {
30
+ const section = getDeclaredSection(pkg, depIdent);
31
+ return section ? (pkg[section]?.[depIdent] ?? null) : null;
32
+ }
33
+ function addReason(expected, depIdent, reason) {
34
+ if (!expected.reasons.has(depIdent))
35
+ expected.reasons.set(depIdent, []);
36
+ const list = expected.reasons.get(depIdent);
37
+ if (!list.some((r) => r.kind === reason.kind && r.detail === reason.detail)) {
38
+ list.push(reason);
39
+ }
40
+ }
41
+ function addRuleReason(expected, depIdent, rule) {
42
+ const details = [];
43
+ if (rule.section)
44
+ details.push(`section: ${rule.section}`);
45
+ if (rule.version !== undefined)
46
+ details.push(`version: ${rule.version}`);
47
+ if (rule.rootOnly)
48
+ details.push('rootOnly: true');
49
+ if (rule.required)
50
+ details.push('required: true');
51
+ if (details.length === 0)
52
+ return;
53
+ addReason(expected, depIdent, {
54
+ kind: 'rule',
55
+ detail: `${depIdent} matched rule (${details.join(', ')})`,
56
+ });
57
+ }
58
+ function setExpectedDependency(expected, section, depIdent, range, reason) {
59
+ for (const other of types_1.SECTIONS) {
60
+ if (other !== section)
61
+ expected.sections[other].delete(depIdent);
62
+ }
63
+ expected.sections[section].set(depIdent, range);
64
+ addReason(expected, depIdent, reason);
65
+ }
66
+ function addExpectedMirrorDependency(expected, depIdent, range, reason) {
67
+ expected.sections.devDependencies.set(depIdent, range);
68
+ addReason(expected, depIdent, reason);
69
+ }
70
+ function getExpectedSection(expected, depIdent) {
71
+ for (const section of types_1.SECTIONS) {
72
+ if (expected.sections[section].has(depIdent))
73
+ return section;
74
+ }
75
+ return null;
76
+ }
77
+ function getExpectedRange(expected, depIdent) {
78
+ const section = getExpectedSection(expected, depIdent);
79
+ return section ? (expected.sections[section].get(depIdent) ?? null) : null;
80
+ }
81
+ function getRangeSource(root, workspace, depIdent, rules) {
82
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, workspace.name, workspace.location);
83
+ if (rule.version !== undefined)
84
+ return rule.version;
85
+ return (getDeclaredRange(workspace.pkg, depIdent) ??
86
+ getDeclaredRange(root.pkg, depIdent) ??
87
+ '*');
88
+ }
89
+ //# sourceMappingURL=expected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expected.js","sourceRoot":"","sources":["../../src/model/expected.ts"],"names":[],"mappings":";;AAmBA,sCAMC;AAED,gDASC;AAED,4CAOC;AAED,8BAUC;AAED,sCAgBC;AAED,sDAYC;AAED,kEAQC;AAED,gDASC;AAED,4CAOC;AAED,wCAmBC;AAnID,mCAA2C;AAC3C,mCAOiB;AAEjB,SAAgB,aAAa;IAC3B,OAAO;QACL,YAAY,EAAE,IAAI,GAAG,EAAE;QACvB,gBAAgB,EAAE,IAAI,GAAG,EAAE;QAC3B,eAAe,EAAE,IAAI,GAAG,EAAE;KAC3B,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAChC,GAAgB,EAChB,QAAgB;IAEhB,KAAK,MAAM,OAAO,IAAI,gBAAQ,EAAE,CAAC;QAC/B,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,gBAAgB,CAC9B,GAAgB,EAChB,QAAgB;IAEhB,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAElD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,IA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I,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,CAAC;AAED,SAAgB,cAAc,CAC5B,IAAoB,EACpB,SAAyB,EACzB,QAAgB,EAChB,KAAuB;IAEvB,MAAM,IAAI,GAAG,IAAA,wBAAgB,EAC3B,KAAK,EACL,QAAQ,EACR,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,QAAQ,CACnB,CAAC;IACF,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC;IAEpD,OAAO,CACL,gBAAgB,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;QACzC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC;QACpC,GAAG,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { DependencyRule, ExpectedWorkspace, WorkspaceFacts } from './types';
2
+ export declare function propagatePeers(expectedByLocation: Map<string, ExpectedWorkspace>, workspacesByName: Map<string, WorkspaceFacts>, workspaceNames: Set<string>, externalPeerMetadata: Map<string, Map<string, string> | null>, rules: DependencyRule[]): void;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propagatePeers = propagatePeers;
4
+ /**
5
+ * Peer propagation across dependency edges.
6
+ *
7
+ * This module applies peer requirements from local libraries and external
8
+ * packages to the current workspace. It consumes already collected peer
9
+ * metadata and does not inspect `node_modules` itself.
10
+ */
11
+ const expected_1 = require("./expected");
12
+ const rules_1 = require("./rules");
13
+ function providePeer(expected, rootExpected, workspaceNames, rules, depIdent, range, provider) {
14
+ if (workspaceNames.has(depIdent))
15
+ return false;
16
+ if (expected.sections.dependencies.has(depIdent))
17
+ return false;
18
+ const beforeSection = (0, expected_1.getExpectedSection)(expected, depIdent);
19
+ const beforeRange = (0, expected_1.getExpectedRange)(expected, depIdent);
20
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, expected.workspace.name, expected.workspace.location);
21
+ const resolvedRange = rule.version ?? range;
22
+ (0, expected_1.addRuleReason)(expected, depIdent, rule);
23
+ if (rule.rootOnly) {
24
+ (0, expected_1.setExpectedDependency)(rootExpected, 'devDependencies', depIdent, resolvedRange, {
25
+ kind: 'root-only',
26
+ detail: `${depIdent} is required by ${provider} but marked rootOnly`,
27
+ });
28
+ (0, expected_1.addReason)(expected, depIdent, {
29
+ kind: 'root-only',
30
+ detail: `${depIdent} is required by ${provider} but marked rootOnly`,
31
+ });
32
+ return false;
33
+ }
34
+ if (expected.workspace.role === 'library' &&
35
+ rule.section !== 'dependencies') {
36
+ (0, expected_1.setExpectedDependency)(expected, 'peerDependencies', depIdent, resolvedRange, {
37
+ kind: 'peer-propagation',
38
+ detail: `${depIdent} is required peer of ${provider}`,
39
+ });
40
+ (0, expected_1.addExpectedMirrorDependency)(expected, depIdent, resolvedRange, {
41
+ kind: 'mirror',
42
+ detail: `${depIdent} mirrors propagated peer`,
43
+ });
44
+ }
45
+ else {
46
+ (0, expected_1.setExpectedDependency)(expected, 'dependencies', depIdent, resolvedRange, {
47
+ kind: 'peer-propagation',
48
+ detail: `${depIdent} is required peer of ${provider}`,
49
+ });
50
+ }
51
+ return (beforeSection !== (0, expected_1.getExpectedSection)(expected, depIdent) ||
52
+ beforeRange !== (0, expected_1.getExpectedRange)(expected, depIdent));
53
+ }
54
+ function propagatePeers(expectedByLocation, workspacesByName, workspaceNames, externalPeerMetadata, rules) {
55
+ const rootExpected = expectedByLocation.get('.');
56
+ let changed = true;
57
+ let passes = 0;
58
+ while (changed && passes < 10) {
59
+ changed = false;
60
+ passes++;
61
+ for (const expected of expectedByLocation.values()) {
62
+ const workspace = expected.workspace;
63
+ const providerDeps = new Map();
64
+ for (const [depIdent, range] of expected.sections.dependencies) {
65
+ providerDeps.set(depIdent, range);
66
+ }
67
+ for (const [depIdent, range] of expected.sections.peerDependencies) {
68
+ providerDeps.set(depIdent, range);
69
+ }
70
+ if (workspace.isRoot) {
71
+ for (const [depIdent, range] of expected.sections.devDependencies) {
72
+ providerDeps.set(depIdent, range);
73
+ }
74
+ }
75
+ for (const [providerIdent] of providerDeps) {
76
+ if (workspaceNames.has(providerIdent)) {
77
+ const provider = workspacesByName.get(providerIdent);
78
+ if (!provider || provider.role !== 'library')
79
+ continue;
80
+ const providerExpected = expectedByLocation.get(provider.location);
81
+ if (!providerExpected)
82
+ continue;
83
+ for (const [peerIdent, peerRange] of providerExpected.sections
84
+ .peerDependencies) {
85
+ if (provider.pkg.peerDependenciesMeta?.[peerIdent]?.optional) {
86
+ continue;
87
+ }
88
+ if (workspaceNames.has(peerIdent))
89
+ continue;
90
+ if (workspace.isRoot) {
91
+ (0, expected_1.setExpectedDependency)(rootExpected, 'devDependencies', peerIdent, peerRange, {
92
+ kind: 'peer-propagation',
93
+ detail: `${peerIdent} is required by ${providerIdent}`,
94
+ });
95
+ }
96
+ else {
97
+ changed =
98
+ providePeer(expected, rootExpected, workspaceNames, rules, peerIdent, peerRange, providerIdent) || changed;
99
+ }
100
+ }
101
+ continue;
102
+ }
103
+ const externalPeers = externalPeerMetadata.get(providerIdent) ?? null;
104
+ if (!externalPeers)
105
+ continue;
106
+ for (const [peerIdent, peerRange] of externalPeers) {
107
+ if (workspaceNames.has(peerIdent))
108
+ continue;
109
+ if (workspace.isRoot) {
110
+ (0, expected_1.setExpectedDependency)(rootExpected, 'devDependencies', peerIdent, peerRange, {
111
+ kind: 'peer-propagation',
112
+ detail: `${peerIdent} is required by ${providerIdent}`,
113
+ });
114
+ }
115
+ else {
116
+ changed =
117
+ providePeer(expected, rootExpected, workspaceNames, rules, peerIdent, peerRange, providerIdent) || changed;
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ //# sourceMappingURL=peer-propagation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer-propagation.js","sourceRoot":"","sources":["../../src/model/peer-propagation.ts"],"names":[],"mappings":";;AA+FA,wCAuGC;AAtMD;;;;;;GAM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AC,SAAS,CAAC;4BAAE,SAAS;wBAC5C,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;4BACrB,IAAA,gCAAqB,EACnB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT;gCACE,IAAI,EAAE,kBAAkB;gCACxB,MAAM,EAAE,GAAG,SAAS,mBAAmB,aAAa,EAAE;6BACvD,CACF,CAAC;wBACJ,CAAC;6BAAM,CAAC;4BACN,OAAO;gCACL,WAAW,CACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,KAAK,EACL,SAAS,EACT,SAAS,EACT,aAAa,CACd,IAAI,OAAO,CAAC;wBACjB,CAAC;oBACH,CAAC;oBACD,SAAS;gBACX,CAAC;gBAED,MAAM,aAAa,GAAG,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;gBACtE,IAAI,CAAC,aAAa;oBAAE,SAAS;gBAE7B,KAAK,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,aAAa,EAAE,CAAC;oBACnD,IAAI,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;wBAAE,SAAS;oBAC5C,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;wBACrB,IAAA,gCAAqB,EACnB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT;4BACE,IAAI,EAAE,kBAAkB;4BACxB,MAAM,EAAE,GAAG,SAAS,mBAAmB,aAAa,EAAE;yBACvD,CACF,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,OAAO;4BACL,WAAW,CACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,KAAK,EACL,SAAS,EACT,SAAS,EACT,aAAa,CACd,IAAI,OAAO,CAAC;oBACjB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { DependencyRule, ExpectedWorkspace, WorkspaceFacts } from './types';
2
+ export declare function isExternal(depIdent: string, workspaceNames: Set<string>): boolean;
3
+ export declare function seedRootDevDependencies(expectedByLocation: Map<string, ExpectedWorkspace>, workspaceNames: Set<string>, rules: DependencyRule[]): void;
4
+ export declare function addUsageDependencies(expectedByLocation: Map<string, ExpectedWorkspace>, root: WorkspaceFacts, workspaceNames: Set<string>, rules: DependencyRule[], externalTypeMetadata: Map<string, {
5
+ hasBundledTypes: boolean;
6
+ }>, typeProviderPackages: Set<string>): void;
7
+ export declare function addRequiredRuleDependencies(expectedByLocation: Map<string, ExpectedWorkspace>, root: WorkspaceFacts, workspaceNames: Set<string>, rules: DependencyRule[]): void;
8
+ export declare function rebuildLibraryMirrors(expectedByLocation: Map<string, ExpectedWorkspace>): void;
9
+ export declare function resolveExpectedRangeAfterRulePass(root: WorkspaceFacts, expected: ExpectedWorkspace, workspaceNames: Set<string>, rules: DependencyRule[], depIdent: string, currentRange: string): string;
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExternal = isExternal;
4
+ exports.seedRootDevDependencies = seedRootDevDependencies;
5
+ exports.addUsageDependencies = addUsageDependencies;
6
+ exports.addRequiredRuleDependencies = addRequiredRuleDependencies;
7
+ exports.rebuildLibraryMirrors = rebuildLibraryMirrors;
8
+ exports.resolveExpectedRangeAfterRulePass = resolveExpectedRangeAfterRulePass;
9
+ /**
10
+ * Dependency placement rules.
11
+ *
12
+ * This module converts source and `.d.ts` usage facts into expected manifest
13
+ * sections. It is pure: it receives workspace facts, rules, type metadata, and
14
+ * local workspace names, then mutates only the in-memory expected graph.
15
+ */
16
+ const expected_1 = require("./expected");
17
+ const rules_1 = require("./rules");
18
+ function isTestFile(file) {
19
+ return /(^|[/.])(__test__|__tests__|test|tests|spec|e2e)([/.]|$)|\.(spec|test|e2e)\.[cm]?[tj]sx?$/.test(file);
20
+ }
21
+ function isExternal(depIdent, workspaceNames) {
22
+ return !workspaceNames.has(depIdent);
23
+ }
24
+ function getDefinitelyTypedProvider(depIdent) {
25
+ if (depIdent.startsWith('@types/'))
26
+ return null;
27
+ if (depIdent.startsWith('@')) {
28
+ const [scope, name] = depIdent.slice(1).split('/');
29
+ if (!scope || !name)
30
+ return null;
31
+ return `@types/${scope}__${name}`;
32
+ }
33
+ return `@types/${depIdent}`;
34
+ }
35
+ function shouldAddDefinitelyTypedProvider(depIdent, externalTypeMetadata, typeProviderPackages) {
36
+ const provider = getDefinitelyTypedProvider(depIdent);
37
+ if (!provider || !typeProviderPackages.has(provider))
38
+ return null;
39
+ if (externalTypeMetadata.get(depIdent)?.hasBundledTypes)
40
+ return null;
41
+ return provider;
42
+ }
43
+ function getConcreteRuleMatches(rule) {
44
+ const matches = Array.isArray(rule.match) ? rule.match : [rule.match];
45
+ return matches.filter((match) => !match.includes('*'));
46
+ }
47
+ function addPublicDependency(expected, rootExpected, root, workspaceNames, rules, depIdent, reason, options = {}) {
48
+ const workspace = expected.workspace;
49
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, workspace.name, workspace.location);
50
+ const isLocal = workspaceNames.has(depIdent);
51
+ const range = isLocal
52
+ ? 'workspace:*'
53
+ : (0, expected_1.getRangeSource)(root, workspace, depIdent, rules);
54
+ (0, expected_1.addRuleReason)(expected, depIdent, rule);
55
+ if (rule.rootOnly && !isLocal && !options.allowRootOnly) {
56
+ (0, expected_1.setExpectedDependency)(rootExpected, 'devDependencies', depIdent, range, {
57
+ kind: 'root-only',
58
+ detail: `${depIdent} is marked rootOnly`,
59
+ });
60
+ (0, expected_1.addReason)(expected, depIdent, reason);
61
+ (0, expected_1.addReason)(expected, depIdent, {
62
+ kind: 'root-only',
63
+ detail: `${depIdent} is marked rootOnly and cannot be used by ${workspace.name}`,
64
+ });
65
+ return;
66
+ }
67
+ if (isLocal) {
68
+ (0, expected_1.setExpectedDependency)(expected, 'dependencies', depIdent, 'workspace:*', {
69
+ kind: reason.kind,
70
+ detail: `${reason.detail}; local workspace edge`,
71
+ });
72
+ return;
73
+ }
74
+ if (workspace.role === 'library' &&
75
+ rule.section !== 'dependencies' &&
76
+ rule.section !== 'devDependencies') {
77
+ (0, expected_1.setExpectedDependency)(expected, 'peerDependencies', depIdent, range, reason);
78
+ (0, expected_1.addExpectedMirrorDependency)(expected, depIdent, range, {
79
+ kind: 'mirror',
80
+ detail: `${depIdent} mirrors peerDependencies in devDependencies`,
81
+ });
82
+ return;
83
+ }
84
+ (0, expected_1.setExpectedDependency)(expected, 'dependencies', depIdent, range, reason);
85
+ }
86
+ function addPrivateDependency(rootExpected, root, requester, workspaceNames, rules, depIdent, reason) {
87
+ const workspace = requester.workspace;
88
+ if (workspaceNames.has(depIdent))
89
+ return;
90
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, workspace.name, workspace.location);
91
+ const range = (0, expected_1.getRangeSource)(root, workspace, depIdent, rules);
92
+ (0, expected_1.addRuleReason)(rootExpected, depIdent, rule);
93
+ (0, expected_1.addRuleReason)(requester, depIdent, rule);
94
+ if (rule.rootOnly) {
95
+ (0, expected_1.addReason)(requester, depIdent, {
96
+ kind: 'root-only',
97
+ detail: `${depIdent} is marked rootOnly and cannot be used by ${workspace.name}`,
98
+ });
99
+ }
100
+ (0, expected_1.setExpectedDependency)(rootExpected, 'devDependencies', depIdent, range, reason);
101
+ }
102
+ function seedRootDevDependencies(expectedByLocation, workspaceNames, rules) {
103
+ const rootExpected = expectedByLocation.get('.');
104
+ for (const [depIdent, declaredRange] of Object.entries(rootExpected.workspace.pkg.devDependencies ?? {})) {
105
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, rootExpected.workspace.name, rootExpected.workspace.location);
106
+ const range = workspaceNames.has(depIdent)
107
+ ? 'workspace:*'
108
+ : (rule.version ?? declaredRange);
109
+ (0, expected_1.setExpectedDependency)(rootExpected, 'devDependencies', depIdent, range, {
110
+ kind: 'declared',
111
+ detail: `${depIdent} is declared in root devDependencies baseline`,
112
+ });
113
+ (0, expected_1.addRuleReason)(rootExpected, depIdent, rule);
114
+ }
115
+ }
116
+ function addUsageDependencies(expectedByLocation, root, workspaceNames, rules, externalTypeMetadata, typeProviderPackages) {
117
+ const rootExpected = expectedByLocation.get('.');
118
+ for (const expected of expectedByLocation.values()) {
119
+ const workspace = expected.workspace;
120
+ if (workspace.isRoot)
121
+ continue;
122
+ for (const [depIdent, usage] of workspace.sourceUsage) {
123
+ const publicType = workspace.dtsImports.has(depIdent);
124
+ const runtime = [...usage.runtimeFiles].some((file) => !isTestFile(file));
125
+ const allTestOnly = [...usage.files].every(isTestFile);
126
+ if (runtime || publicType) {
127
+ addPublicDependency(expected, rootExpected, root, workspaceNames, rules, depIdent, {
128
+ kind: publicType ? 'source-public-type' : 'source-runtime',
129
+ detail: publicType
130
+ ? `${depIdent} appears in emitted .d.ts`
131
+ : `${depIdent} is imported at runtime`,
132
+ });
133
+ }
134
+ else {
135
+ addPrivateDependency(rootExpected, root, expected, workspaceNames, rules, depIdent, {
136
+ kind: 'source-private-dev',
137
+ detail: allTestOnly
138
+ ? `${depIdent} is only used by test files in ${workspace.name}`
139
+ : `${depIdent} is only used as private type/tooling dependency in ${workspace.name}`,
140
+ });
141
+ }
142
+ }
143
+ for (const depIdent of workspace.dtsImports) {
144
+ addPublicDependency(expected, rootExpected, root, workspaceNames, rules, depIdent, {
145
+ kind: 'source-public-type',
146
+ detail: `${depIdent} appears in emitted .d.ts`,
147
+ });
148
+ const typeProvider = shouldAddDefinitelyTypedProvider(depIdent, externalTypeMetadata, typeProviderPackages);
149
+ if (!typeProvider)
150
+ continue;
151
+ addPublicDependency(expected, rootExpected, root, workspaceNames, rules, typeProvider, {
152
+ kind: 'dts-provider',
153
+ detail: `${typeProvider} provides public types for ${depIdent}`,
154
+ }, { allowRootOnly: true });
155
+ }
156
+ }
157
+ }
158
+ function addRequiredRuleDependencies(expectedByLocation, root, workspaceNames, rules) {
159
+ const rootExpected = expectedByLocation.get('.');
160
+ const candidates = new Set();
161
+ for (const rule of rules) {
162
+ if (rule.required === undefined)
163
+ continue;
164
+ for (const depIdent of getConcreteRuleMatches(rule)) {
165
+ candidates.add(depIdent);
166
+ }
167
+ }
168
+ for (const expected of expectedByLocation.values()) {
169
+ const workspace = expected.workspace;
170
+ if (workspace.isRoot)
171
+ continue;
172
+ for (const depIdent of candidates) {
173
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, workspace.name, workspace.location);
174
+ if (!rule.required)
175
+ continue;
176
+ addPublicDependency(expected, rootExpected, root, workspaceNames, rules, depIdent, {
177
+ kind: 'required-rule',
178
+ detail: `${depIdent} is marked required by dependency rule`,
179
+ });
180
+ }
181
+ }
182
+ }
183
+ function rebuildLibraryMirrors(expectedByLocation) {
184
+ for (const expected of expectedByLocation.values()) {
185
+ if (expected.workspace.role !== 'library')
186
+ continue;
187
+ expected.sections.devDependencies = new Map(expected.sections.peerDependencies);
188
+ for (const [depIdent] of expected.sections.devDependencies) {
189
+ (0, expected_1.addReason)(expected, depIdent, {
190
+ kind: 'mirror',
191
+ detail: `${depIdent} mirrors peerDependencies in devDependencies`,
192
+ });
193
+ }
194
+ }
195
+ }
196
+ function resolveExpectedRangeAfterRulePass(root, expected, workspaceNames, rules, depIdent, currentRange) {
197
+ const rule = (0, rules_1.getEffectiveRule)(rules, depIdent, expected.workspace.name, expected.workspace.location);
198
+ return workspaceNames.has(depIdent)
199
+ ? 'workspace:*'
200
+ : (rule.version ??
201
+ (0, expected_1.getDeclaredRange)(expected.workspace.pkg, depIdent) ??
202
+ (0, expected_1.getDeclaredRange)(root.pkg, depIdent) ??
203
+ currentRange);
204
+ }
205
+ //# sourceMappingURL=placement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/model/placement.ts"],"names":[],"mappings":";;AA6BA,gCAKC;AAwID,0DA0BC;AAED,oDAwFC;AAED,kEA2CC;AAED,sDAeC;AAED,8EAqBC;AAnXD;;;;;;GAMG;AACH,yCAOoB;AACpB,mCAA2C;AAQ3C,SAAS,UAAU,CAAC,IAAY;IAC9B,OAA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wBAAgB,EAC3B,KAAK,EACL,QAAQ,EACR,QAAQ,CAAC,SAAS,CAAC,IAAI,EACvB,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAC5B,CAAC;IAEF,OAAO,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;QACjC,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;YACb,IAAA,2BAAgB,EAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;YAClD,IAAA,2BAAgB,EAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC;YACpC,YAAY,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Rule matching and precedence.
3
+ *
4
+ * Dependency rules are the explicit override surface for the model: versions,
5
+ * section overrides, root-only constraints, and workspace-specific exceptions.
6
+ * The helpers here are pure and apply the documented "last matching rule wins"
7
+ * semantics.
8
+ */
9
+ import type { DependencyRule, EffectiveRule, WorkspaceRole } from './types';
10
+ export declare function matchesGlob(value: string, pattern: string): boolean;
11
+ export declare function matchesPatterns(value: string, pattern: string | string[]): boolean;
12
+ export declare function getEffectiveRule(rules: DependencyRule[], depIdent: string, wsIdent: string, wsCwd: string): EffectiveRule;
13
+ export declare function hasGlobalVersionRule(rules: DependencyRule[], depIdent: string): boolean;
14
+ export declare function isWorkspaceRole(value: string | undefined): value is WorkspaceRole;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchesGlob = matchesGlob;
4
+ exports.matchesPatterns = matchesPatterns;
5
+ exports.getEffectiveRule = getEffectiveRule;
6
+ exports.hasGlobalVersionRule = hasGlobalVersionRule;
7
+ exports.isWorkspaceRole = isWorkspaceRole;
8
+ function matchesGlob(value, pattern) {
9
+ if (!pattern.includes('*'))
10
+ return value === pattern;
11
+ const escaped = pattern.replaceAll(/[-[\]{}()+?.,\\^$|#\s]/g, String.raw `\$&`);
12
+ return new RegExp('^' + escaped.replaceAll('**', '.*').replaceAll('*', '[^/]*') + '$').test(value);
13
+ }
14
+ function matchesPatterns(value, pattern) {
15
+ const patterns = Array.isArray(pattern) ? pattern : [pattern];
16
+ return patterns.some((p) => matchesGlob(value, p));
17
+ }
18
+ function getEffectiveRule(rules, depIdent, wsIdent, wsCwd) {
19
+ const effective = { rootOnly: false };
20
+ for (const rule of rules) {
21
+ if (!matchesPatterns(depIdent, rule.match))
22
+ continue;
23
+ if (rule.workspace &&
24
+ !matchesPatterns(wsIdent, rule.workspace) &&
25
+ !matchesPatterns(wsCwd, rule.workspace))
26
+ continue;
27
+ if (rule.section)
28
+ effective.section = rule.section;
29
+ if (rule.version !== undefined)
30
+ effective.version = rule.version;
31
+ if (rule.rootOnly !== undefined)
32
+ effective.rootOnly = rule.rootOnly;
33
+ if (rule.required !== undefined)
34
+ effective.required = rule.required;
35
+ }
36
+ return effective;
37
+ }
38
+ function hasGlobalVersionRule(rules, depIdent) {
39
+ return rules.some((rule) => !rule.workspace &&
40
+ rule.version !== undefined &&
41
+ matchesPatterns(depIdent, rule.match));
42
+ }
43
+ function isWorkspaceRole(value) {
44
+ return value === 'library' || value === 'service' || value === 'cli';
45
+ }
46
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/model/rules.ts"],"names":[],"mappings":";;AAUA,kCAUC;AAED,0CAOC;AAED,4CAuBC;AAED,oDAUC;AAED,0CAIC;AA9DD,SAAgB,WAAW,CAAC,KAAa,EAAE,OAAe;IACxD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,KAAK,OAAO,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAChC,yBAAyB,EACzB,MAAM,CAAC,GAAG,CAAA,KAAK,CAChB,CAAC;IAEF,OAAO,IAAI,MAAM,CACf,GAAG,GAAG,OAAO,CAAC,UAAU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