@domainlang/language 0.5.2 → 0.7.0
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.
- package/README.md +1 -1
- package/out/domain-lang-module.js +5 -1
- package/out/domain-lang-module.js.map +1 -1
- package/out/generated/ast.d.ts +24 -0
- package/out/generated/ast.js.map +1 -1
- package/out/generated/grammar.js +22 -32
- package/out/generated/grammar.js.map +1 -1
- package/out/index.d.ts +2 -5
- package/out/index.js +10 -6
- package/out/index.js.map +1 -1
- package/out/lsp/domain-lang-code-actions.js +14 -8
- package/out/lsp/domain-lang-code-actions.js.map +1 -1
- package/out/lsp/domain-lang-completion.d.ts +3 -0
- package/out/lsp/domain-lang-completion.js +41 -13
- package/out/lsp/domain-lang-completion.js.map +1 -1
- package/out/lsp/domain-lang-formatter.js +24 -18
- package/out/lsp/domain-lang-formatter.js.map +1 -1
- package/out/lsp/domain-lang-index-manager.d.ts +170 -0
- package/out/lsp/domain-lang-index-manager.js +389 -0
- package/out/lsp/domain-lang-index-manager.js.map +1 -0
- package/out/lsp/domain-lang-scope-provider.d.ts +67 -0
- package/out/lsp/domain-lang-scope-provider.js +95 -0
- package/out/lsp/domain-lang-scope-provider.js.map +1 -0
- package/out/lsp/domain-lang-scope.js +31 -17
- package/out/lsp/domain-lang-scope.js.map +1 -1
- package/out/lsp/domain-lang-workspace-manager.d.ts +76 -9
- package/out/lsp/domain-lang-workspace-manager.js +176 -54
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
- package/out/lsp/hover/domain-lang-hover.d.ts +45 -1
- package/out/lsp/hover/domain-lang-hover.js +308 -232
- package/out/lsp/hover/domain-lang-hover.js.map +1 -1
- package/out/lsp/hover/domain-lang-keywords.d.ts +3 -7
- package/out/lsp/hover/domain-lang-keywords.js +115 -38
- package/out/lsp/hover/domain-lang-keywords.js.map +1 -1
- package/out/lsp/manifest-diagnostics.js +95 -50
- package/out/lsp/manifest-diagnostics.js.map +1 -1
- package/out/main.js +204 -17
- package/out/main.js.map +1 -1
- package/out/services/import-resolver.d.ts +39 -2
- package/out/services/import-resolver.js +77 -12
- package/out/services/import-resolver.js.map +1 -1
- package/out/services/types.d.ts +2 -2
- package/out/services/workspace-manager.d.ts +33 -31
- package/out/services/workspace-manager.js +92 -148
- package/out/services/workspace-manager.js.map +1 -1
- package/out/utils/document-utils.d.ts +41 -0
- package/out/utils/document-utils.js +64 -0
- package/out/utils/document-utils.js.map +1 -0
- package/out/utils/import-utils.d.ts +0 -17
- package/out/utils/import-utils.js +2 -32
- package/out/utils/import-utils.js.map +1 -1
- package/out/utils/manifest-utils.d.ts +56 -0
- package/out/utils/manifest-utils.js +119 -0
- package/out/utils/manifest-utils.js.map +1 -0
- package/out/validation/constants.d.ts +13 -0
- package/out/validation/constants.js +18 -0
- package/out/validation/constants.js.map +1 -1
- package/out/validation/import.d.ts +12 -2
- package/out/validation/import.js +95 -22
- package/out/validation/import.js.map +1 -1
- package/out/validation/maps.js +51 -2
- package/out/validation/maps.js.map +1 -1
- package/package.json +1 -1
- package/src/domain-lang-module.ts +6 -1
- package/src/domain-lang.langium +37 -13
- package/src/generated/ast.ts +24 -0
- package/src/generated/grammar.ts +22 -32
- package/src/index.ts +12 -6
- package/src/lsp/domain-lang-code-actions.ts +13 -8
- package/src/lsp/domain-lang-completion.ts +61 -13
- package/src/lsp/domain-lang-formatter.ts +28 -23
- package/src/lsp/domain-lang-index-manager.ts +447 -0
- package/src/lsp/domain-lang-scope-provider.ts +134 -0
- package/src/lsp/domain-lang-scope.ts +29 -17
- package/src/lsp/domain-lang-workspace-manager.ts +201 -53
- package/src/lsp/hover/domain-lang-hover.ts +332 -226
- package/src/lsp/hover/domain-lang-keywords.ts +129 -43
- package/src/lsp/manifest-diagnostics.ts +100 -59
- package/src/main.ts +258 -16
- package/src/services/import-resolver.ts +91 -12
- package/src/services/types.ts +2 -2
- package/src/services/workspace-manager.ts +101 -175
- package/src/utils/document-utils.ts +80 -0
- package/src/utils/import-utils.ts +2 -40
- package/src/utils/manifest-utils.ts +132 -0
- package/src/validation/constants.ts +24 -0
- package/src/validation/import.ts +107 -24
- package/src/validation/maps.ts +59 -2
- package/out/lsp/hover/ddd-pattern-explanations.d.ts +0 -50
- package/out/lsp/hover/ddd-pattern-explanations.js +0 -196
- package/out/lsp/hover/ddd-pattern-explanations.js.map +0 -1
- package/out/services/dependency-analyzer.d.ts +0 -58
- package/out/services/dependency-analyzer.js +0 -254
- package/out/services/dependency-analyzer.js.map +0 -1
- package/out/services/dependency-resolver.d.ts +0 -146
- package/out/services/dependency-resolver.js +0 -452
- package/out/services/dependency-resolver.js.map +0 -1
- package/out/services/git-url-resolver.browser.d.ts +0 -10
- package/out/services/git-url-resolver.browser.js +0 -19
- package/out/services/git-url-resolver.browser.js.map +0 -1
- package/out/services/git-url-resolver.d.ts +0 -158
- package/out/services/git-url-resolver.js +0 -416
- package/out/services/git-url-resolver.js.map +0 -1
- package/out/services/governance-validator.d.ts +0 -44
- package/out/services/governance-validator.js +0 -153
- package/out/services/governance-validator.js.map +0 -1
- package/out/services/semver.d.ts +0 -98
- package/out/services/semver.js +0 -195
- package/out/services/semver.js.map +0 -1
- package/src/lsp/hover/ddd-pattern-explanations.ts +0 -237
- package/src/services/dependency-analyzer.ts +0 -321
- package/src/services/dependency-resolver.ts +0 -551
- package/src/services/git-url-resolver.browser.ts +0 -26
- package/src/services/git-url-resolver.ts +0 -517
- package/src/services/governance-validator.ts +0 -177
- package/src/services/semver.ts +0 -213
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DDD Pattern Explanations for Hover Documentation
|
|
3
|
-
*
|
|
4
|
-
* Provides plain-English explanations for DDD integration patterns,
|
|
5
|
-
* relationship types, and decision categories.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Explanations for DDD integration role patterns (e.g., PL, ACL, SK).
|
|
9
|
-
*/
|
|
10
|
-
export const rolePatternExplanations = {
|
|
11
|
-
'PL': `**Published Language (PL)**
|
|
12
|
-
|
|
13
|
-
The upstream context provides a well-documented, stable API/model that downstream contexts consume.
|
|
14
|
-
|
|
15
|
-
\`\`\`domain-lang
|
|
16
|
-
[PL] UpstreamContext -> DownstreamContext
|
|
17
|
-
\`\`\`
|
|
18
|
-
|
|
19
|
-
*Use when:* Multiple consumers need a shared, stable interface.`,
|
|
20
|
-
'ACL': `**Anti-Corruption Layer (ACL)**
|
|
21
|
-
|
|
22
|
-
Protects downstream from upstream changes by translating between models.
|
|
23
|
-
|
|
24
|
-
\`\`\`domain-lang
|
|
25
|
-
UpstreamContext -> [ACL] DownstreamContext
|
|
26
|
-
\`\`\`
|
|
27
|
-
|
|
28
|
-
*Use when:* You don't trust upstream stability or want isolation.`,
|
|
29
|
-
'SK': `**Shared Kernel (SK)**
|
|
30
|
-
|
|
31
|
-
Both contexts share common domain model code requiring coordination.
|
|
32
|
-
|
|
33
|
-
\`\`\`domain-lang
|
|
34
|
-
[SK] Context1 <-> [SK] Context2 : SharedKernel
|
|
35
|
-
\`\`\`
|
|
36
|
-
|
|
37
|
-
*Use when:* Contexts are tightly coupled and teams can coordinate.`,
|
|
38
|
-
'CF': `**Conformist (CF)**
|
|
39
|
-
|
|
40
|
-
Downstream accepts upstream model without translation.
|
|
41
|
-
|
|
42
|
-
\`\`\`domain-lang
|
|
43
|
-
UpstreamContext -> [CF] DownstreamContext
|
|
44
|
-
\`\`\`
|
|
45
|
-
|
|
46
|
-
*Use when:* Upstream model is acceptable and translation isn't worth it.`,
|
|
47
|
-
'OHS': `**Open Host Service (OHS)**
|
|
48
|
-
|
|
49
|
-
Upstream defines a protocol/API for easy integration.
|
|
50
|
-
|
|
51
|
-
\`\`\`domain-lang
|
|
52
|
-
[OHS, PL] ApiContext -> ConsumerContext
|
|
53
|
-
\`\`\`
|
|
54
|
-
|
|
55
|
-
*Use when:* Multiple downstream contexts need integration.`,
|
|
56
|
-
'P': `**Partnership (P)**
|
|
57
|
-
|
|
58
|
-
Teams coordinate development and align releases.
|
|
59
|
-
|
|
60
|
-
\`\`\`domain-lang
|
|
61
|
-
Context1 <-> Context2 : Partnership
|
|
62
|
-
\`\`\`
|
|
63
|
-
|
|
64
|
-
*Use when:* Mutual success dependency exists.`,
|
|
65
|
-
'BBoM': `**Big Ball of Mud (BBoM)**
|
|
66
|
-
|
|
67
|
-
No clear boundaries - tangled models needing refactoring.
|
|
68
|
-
|
|
69
|
-
\`\`\`domain-lang
|
|
70
|
-
[BBoM] LegacySystem -> ModernContext
|
|
71
|
-
\`\`\`
|
|
72
|
-
|
|
73
|
-
*Use when:* Documenting legacy systems.`
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Explanations for relationship types (e.g., Partnership, CustomerSupplier).
|
|
77
|
-
*/
|
|
78
|
-
export const relationshipTypeExplanations = {
|
|
79
|
-
'Partnership': '**Partnership**\n\nTwo contexts with mutual success dependency. Teams plan together and coordinate releases.\n\n*Example:* Sales and Order Fulfillment contexts that must evolve in sync.',
|
|
80
|
-
'SharedKernel': '**Shared Kernel**\n\nTwo contexts share a subset of code/model. Changes require agreement from both teams.\n\n*Example:* Two closely related contexts sharing common domain entities.',
|
|
81
|
-
'CustomerSupplier': '**Customer/Supplier**\n\nDownstream (customer) context depends on upstream (supplier) context. Supplier meets customer\'s needs through negotiation.\n\n*Example:* Payment context (customer) depends on Billing context (supplier).',
|
|
82
|
-
'UpstreamDownstream': '**Upstream/Downstream**\n\nUpstream context influences downstream context, but not vice versa. Downstream adapts to upstream changes.\n\n*Example:* Inventory (upstream) provides data to Reporting (downstream).',
|
|
83
|
-
'SeparateWays': '**Separate Ways**\n\nNo connection between contexts - they duplicate functionality rather than integrate.\n\n*Use when:* Integration cost exceeds benefit of sharing.'
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Explanations for relationship arrows.
|
|
87
|
-
*/
|
|
88
|
-
export const arrowExplanations = {
|
|
89
|
-
'<->': 'Bidirectional relationship - both contexts influence each other',
|
|
90
|
-
'->': 'Downstream dependency - right depends on left (left is upstream)',
|
|
91
|
-
'<-': 'Upstream dependency - left depends on right (right is upstream)',
|
|
92
|
-
'><': 'Separate Ways - no integration between contexts',
|
|
93
|
-
'U/D': 'Upstream/Downstream - shorthand for upstream → downstream flow',
|
|
94
|
-
'u/d': 'Upstream/Downstream - shorthand for upstream → downstream flow',
|
|
95
|
-
'C/S': 'Customer/Supplier - shorthand for customer ← supplier relationship',
|
|
96
|
-
'c/s': 'Customer/Supplier - shorthand for customer ← supplier relationship'
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Explanations for decision categories.
|
|
100
|
-
*/
|
|
101
|
-
export const decisionCategoryExplanations = {
|
|
102
|
-
'architectural': '**Architectural Decision**\n\nConcerns system structure, technology choices, or cross-cutting patterns.\n\n*Examples:* Microservices vs monolith, event sourcing, CQRS',
|
|
103
|
-
'arch': 'Short for "architectural" - concerns system structure and technology choices',
|
|
104
|
-
'business': '**Business Decision**\n\nConcerns business rules, policies, or domain logic.\n\n*Examples:* Pricing rules, refund policies, eligibility criteria',
|
|
105
|
-
'biz': 'Short for "business" - concerns business rules and domain logic',
|
|
106
|
-
'technical': '**Technical Decision**\n\nConcerns implementation details, algorithms, or technical constraints.\n\n*Examples:* Caching strategy, data structures, optimization approach',
|
|
107
|
-
'tech': 'Short for "technical" - concerns implementation details',
|
|
108
|
-
'compliance': '**Compliance Decision**\n\nConcerns legal, regulatory, or compliance requirements.\n\n*Examples:* GDPR data retention, SOX audit trails, HIPAA privacy',
|
|
109
|
-
'security': '**Security Decision**\n\nConcerns security, authentication, authorization, or data protection.\n\n*Examples:* OAuth vs JWT, encryption at rest, access control',
|
|
110
|
-
'operational': '**Operational Decision**\n\nConcerns deployment, monitoring, or operational procedures.\n\n*Examples:* Blue/green deployment, monitoring strategy, backup policy',
|
|
111
|
-
'ops': 'Short for "operational" - concerns deployment and operations'
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Explanations for common DDD classifications.
|
|
115
|
-
*/
|
|
116
|
-
export const classificationExplanations = {
|
|
117
|
-
'Core': '**Core Domain**\n\nThe primary differentiator for your business - this is where you create unique value.\n\n*Invest heavily:* Best team, careful design, deep modeling.\n\n*Example:* Recommendation engine for Netflix, search for Google',
|
|
118
|
-
'Supporting': '**Supporting Subdomain**\n\nNecessary for the business but not a differentiator. Custom implementation needed but not the main focus.\n\n*Invest moderately:* Good team, solid implementation.\n\n*Example:* Inventory management, invoicing',
|
|
119
|
-
'Generic': '**Generic Subdomain**\n\nSolved problem - could use off-the-shelf solution. No competitive advantage.\n\n*Buy or reuse:* Use existing solutions when possible.\n\n*Example:* User authentication, email sending, payment processing',
|
|
120
|
-
'Strategic': '**Strategic** (Wardley Evolution)\n\nNovel, custom-built, competitive advantage. High value, low maturity.\n\n*Similar to Core Domain.*',
|
|
121
|
-
'Custom': '**Custom-Built** (Wardley Evolution)\n\nSpecialized solution, some precedent exists. Medium-high value, medium maturity.',
|
|
122
|
-
'Product': '**Product/Rental** (Wardley Evolution)\n\nStandardized product with features. Medium value, medium-high maturity.\n\n*Example:* SaaS tools, commercial software',
|
|
123
|
-
'Commodity': '**Commodity/Utility** (Wardley Evolution)\n\nUbiquitous, interchangeable, fully standardized. Low value, high maturity.\n\n*Example:* Cloud compute, email services'
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* Get explanation for a role pattern.
|
|
127
|
-
*/
|
|
128
|
-
export function explainRolePattern(role) {
|
|
129
|
-
return rolePatternExplanations[role];
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get explanation for a relationship type.
|
|
133
|
-
*/
|
|
134
|
-
export function explainRelationshipType(type) {
|
|
135
|
-
return relationshipTypeExplanations[type];
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Get explanation for an arrow symbol.
|
|
139
|
-
*/
|
|
140
|
-
export function explainArrow(arrow) {
|
|
141
|
-
return arrowExplanations[arrow];
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Get explanation for a decision category.
|
|
145
|
-
*/
|
|
146
|
-
export function explainDecisionCategory(category) {
|
|
147
|
-
return decisionCategoryExplanations[category];
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get explanation for a classification.
|
|
151
|
-
*/
|
|
152
|
-
export function explainClassification(name) {
|
|
153
|
-
return classificationExplanations[name];
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Generate relationship explanation from roles and type.
|
|
157
|
-
*/
|
|
158
|
-
export function generateRelationshipExplanation(leftRoles, arrow, rightRoles, type) {
|
|
159
|
-
const parts = [];
|
|
160
|
-
// Arrow explanation
|
|
161
|
-
if (arrow) {
|
|
162
|
-
const arrowExp = explainArrow(arrow);
|
|
163
|
-
if (arrowExp) {
|
|
164
|
-
parts.push(`**Arrow:** ${arrowExp}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// Left roles
|
|
168
|
-
if (leftRoles && leftRoles.length > 0) {
|
|
169
|
-
parts.push('**Left Context Patterns:**');
|
|
170
|
-
leftRoles.forEach(role => {
|
|
171
|
-
const exp = explainRolePattern(role);
|
|
172
|
-
if (exp) {
|
|
173
|
-
parts.push(exp);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
// Right roles
|
|
178
|
-
if (rightRoles && rightRoles.length > 0) {
|
|
179
|
-
parts.push('**Right Context Patterns:**');
|
|
180
|
-
rightRoles.forEach(role => {
|
|
181
|
-
const exp = explainRolePattern(role);
|
|
182
|
-
if (exp) {
|
|
183
|
-
parts.push(exp);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
// Relationship type
|
|
188
|
-
if (type) {
|
|
189
|
-
const typeExp = explainRelationshipType(type);
|
|
190
|
-
if (typeExp) {
|
|
191
|
-
parts.push(typeExp);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return parts.join('\n\n---\n\n');
|
|
195
|
-
}
|
|
196
|
-
//# sourceMappingURL=ddd-pattern-explanations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ddd-pattern-explanations.js","sourceRoot":"","sources":["../../../src/lsp/hover/ddd-pattern-explanations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC3D,IAAI,EAAE;;;;;;;;gEAQsD;IAE5D,KAAK,EAAE;;;;;;;;kEAQuD;IAE9D,IAAI,EAAE;;;;;;;;mEAQyD;IAE/D,IAAI,EAAE;;;;;;;;yEAQ+D;IAErE,KAAK,EAAE;;;;;;;;2DAQgD;IAEvD,GAAG,EAAE;;;;;;;;8CAQqC;IAE1C,MAAM,EAAE;;;;;;;;wCAQ4B;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA2B;IAChE,aAAa,EAAE,2LAA2L;IAE1M,cAAc,EAAE,uLAAuL;IAEvM,kBAAkB,EAAE,sOAAsO;IAE1P,oBAAoB,EAAE,mNAAmN;IAEzO,cAAc,EAAE,uKAAuK;CAC1L,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACrD,KAAK,EAAE,iEAAiE;IACxE,IAAI,EAAE,kEAAkE;IACxE,IAAI,EAAE,iEAAiE;IACvE,IAAI,EAAE,iDAAiD;IACvD,KAAK,EAAE,gEAAgE;IACvE,KAAK,EAAE,gEAAgE;IACvE,KAAK,EAAE,oEAAoE;IAC3E,KAAK,EAAE,oEAAoE;CAC9E,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA2B;IAChE,eAAe,EAAE,wKAAwK;IACzL,MAAM,EAAE,8EAA8E;IAEtF,UAAU,EAAE,kJAAkJ;IAC9J,KAAK,EAAE,iEAAiE;IAExE,WAAW,EAAE,0KAA0K;IACvL,MAAM,EAAE,yDAAyD;IAEjE,YAAY,EAAE,wJAAwJ;IAEtK,UAAU,EAAE,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I,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACzC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACrB,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,GAAG,EAAE,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,cAAc;IACd,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC1C,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACtB,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,GAAG,EAAE,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,oBAAoB;IACpB,IAAI,IAAI,EAAE,CAAC;QACP,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,OAAO,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency Analysis Service
|
|
3
|
-
*
|
|
4
|
-
* Provides tools for visualizing and analyzing dependency relationships:
|
|
5
|
-
* - Dependency tree visualization
|
|
6
|
-
* - Impact analysis (reverse dependencies)
|
|
7
|
-
* - Circular dependency detection
|
|
8
|
-
* - Version policy enforcement
|
|
9
|
-
*/
|
|
10
|
-
import type { LockFile, DependencyTreeNode, ReverseDependency, VersionPolicy } from './types.js';
|
|
11
|
-
/**
|
|
12
|
-
* Analyzes dependency relationships and provides visualization/analysis tools.
|
|
13
|
-
*/
|
|
14
|
-
export declare class DependencyAnalyzer {
|
|
15
|
-
/**
|
|
16
|
-
* Builds a dependency tree from a lock file.
|
|
17
|
-
*
|
|
18
|
-
* @param lockFile - The lock file to analyze
|
|
19
|
-
* @param workspaceRoot - Workspace root to load dependency metadata
|
|
20
|
-
* @returns Root nodes of the dependency tree
|
|
21
|
-
*/
|
|
22
|
-
buildDependencyTree(lockFile: LockFile, workspaceRoot: string): Promise<DependencyTreeNode[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Recursively builds a dependency tree node.
|
|
25
|
-
*/
|
|
26
|
-
private buildTreeNode;
|
|
27
|
-
/**
|
|
28
|
-
* Finds all packages that depend on a given package.
|
|
29
|
-
*
|
|
30
|
-
* @param targetPackage - Package to analyze
|
|
31
|
-
* @param lockFile - Lock file with all dependencies
|
|
32
|
-
* @param workspaceRoot - Workspace root
|
|
33
|
-
* @returns List of reverse dependencies
|
|
34
|
-
*/
|
|
35
|
-
findReverseDependencies(targetPackage: string, lockFile: LockFile, workspaceRoot: string): Promise<ReverseDependency[]>;
|
|
36
|
-
/**
|
|
37
|
-
* Formats a dependency tree as a readable string.
|
|
38
|
-
*/
|
|
39
|
-
formatDependencyTree(nodes: DependencyTreeNode[], options?: {
|
|
40
|
-
showCommits?: boolean;
|
|
41
|
-
}): string;
|
|
42
|
-
/**
|
|
43
|
-
* Detects circular dependencies in a dependency graph.
|
|
44
|
-
*/
|
|
45
|
-
detectCircularDependencies(lockFile: LockFile): Promise<string[][]>;
|
|
46
|
-
/**
|
|
47
|
-
* Resolves ref policies (latest, stable) to concrete refs.
|
|
48
|
-
*/
|
|
49
|
-
resolveVersionPolicy(_packageKey: string, policy: string, availableRefs: string[]): Promise<VersionPolicy>;
|
|
50
|
-
/**
|
|
51
|
-
* Gets the cache directory for a package.
|
|
52
|
-
*/
|
|
53
|
-
private getCacheDir;
|
|
54
|
-
/**
|
|
55
|
-
* Loads dependencies from a cached package.
|
|
56
|
-
*/
|
|
57
|
-
private loadPackageDependencies;
|
|
58
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency Analysis Service
|
|
3
|
-
*
|
|
4
|
-
* Provides tools for visualizing and analyzing dependency relationships:
|
|
5
|
-
* - Dependency tree visualization
|
|
6
|
-
* - Impact analysis (reverse dependencies)
|
|
7
|
-
* - Circular dependency detection
|
|
8
|
-
* - Version policy enforcement
|
|
9
|
-
*/
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import fs from 'node:fs/promises';
|
|
12
|
-
import os from 'node:os';
|
|
13
|
-
import YAML from 'yaml';
|
|
14
|
-
import { sortVersionsDescending, isPreRelease } from './semver.js';
|
|
15
|
-
/**
|
|
16
|
-
* Analyzes dependency relationships and provides visualization/analysis tools.
|
|
17
|
-
*/
|
|
18
|
-
export class DependencyAnalyzer {
|
|
19
|
-
/**
|
|
20
|
-
* Builds a dependency tree from a lock file.
|
|
21
|
-
*
|
|
22
|
-
* @param lockFile - The lock file to analyze
|
|
23
|
-
* @param workspaceRoot - Workspace root to load dependency metadata
|
|
24
|
-
* @returns Root nodes of the dependency tree
|
|
25
|
-
*/
|
|
26
|
-
async buildDependencyTree(lockFile, workspaceRoot) {
|
|
27
|
-
const manifestPath = path.join(workspaceRoot, 'model.yaml');
|
|
28
|
-
// Load root manifest to get direct dependencies
|
|
29
|
-
const rootDeps = {};
|
|
30
|
-
try {
|
|
31
|
-
const content = await fs.readFile(manifestPath, 'utf-8');
|
|
32
|
-
const manifest = YAML.parse(content);
|
|
33
|
-
if (manifest.dependencies) {
|
|
34
|
-
for (const [, dep] of Object.entries(manifest.dependencies)) {
|
|
35
|
-
rootDeps[dep.source] = dep.version;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// No manifest or parse error
|
|
41
|
-
}
|
|
42
|
-
// Build tree for each direct dependency
|
|
43
|
-
const rootNodes = [];
|
|
44
|
-
const visited = new Set();
|
|
45
|
-
for (const packageKey of Object.keys(rootDeps)) {
|
|
46
|
-
const node = await this.buildTreeNode(packageKey, lockFile, workspaceRoot, 0, visited);
|
|
47
|
-
if (node) {
|
|
48
|
-
rootNodes.push(node);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return rootNodes;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Recursively builds a dependency tree node.
|
|
55
|
-
*/
|
|
56
|
-
async buildTreeNode(packageKey, lockFile, workspaceRoot, depth, visited) {
|
|
57
|
-
const locked = lockFile.dependencies[packageKey];
|
|
58
|
-
if (!locked) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
// Prevent infinite recursion
|
|
62
|
-
if (visited.has(packageKey)) {
|
|
63
|
-
return {
|
|
64
|
-
packageKey,
|
|
65
|
-
ref: locked.ref,
|
|
66
|
-
commit: locked.commit,
|
|
67
|
-
dependencies: [], // Don't recurse into already visited
|
|
68
|
-
depth,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
visited.add(packageKey);
|
|
72
|
-
// Load package dependencies from cache
|
|
73
|
-
const cacheDir = this.getCacheDir(packageKey, locked.commit);
|
|
74
|
-
const packageDeps = await this.loadPackageDependencies(cacheDir);
|
|
75
|
-
// Build child nodes
|
|
76
|
-
const children = [];
|
|
77
|
-
for (const depKey of Object.keys(packageDeps)) {
|
|
78
|
-
const childNode = await this.buildTreeNode(depKey, lockFile, workspaceRoot, depth + 1, new Set(visited));
|
|
79
|
-
if (childNode) {
|
|
80
|
-
children.push(childNode);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
packageKey,
|
|
85
|
-
ref: locked.ref,
|
|
86
|
-
commit: locked.commit,
|
|
87
|
-
dependencies: children,
|
|
88
|
-
depth,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Finds all packages that depend on a given package.
|
|
93
|
-
*
|
|
94
|
-
* @param targetPackage - Package to analyze
|
|
95
|
-
* @param lockFile - Lock file with all dependencies
|
|
96
|
-
* @param workspaceRoot - Workspace root
|
|
97
|
-
* @returns List of reverse dependencies
|
|
98
|
-
*/
|
|
99
|
-
async findReverseDependencies(targetPackage, lockFile, workspaceRoot) {
|
|
100
|
-
const reverseDeps = [];
|
|
101
|
-
const manifestPath = path.join(workspaceRoot, 'model.yaml');
|
|
102
|
-
// Check if target is a direct dependency of root
|
|
103
|
-
try {
|
|
104
|
-
const content = await fs.readFile(manifestPath, 'utf-8');
|
|
105
|
-
const manifest = YAML.parse(content);
|
|
106
|
-
if (manifest.dependencies) {
|
|
107
|
-
for (const [, dep] of Object.entries(manifest.dependencies)) {
|
|
108
|
-
if (dep.source === targetPackage) {
|
|
109
|
-
reverseDeps.push({
|
|
110
|
-
dependentPackage: 'root',
|
|
111
|
-
ref: 'workspace',
|
|
112
|
-
type: 'direct',
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
// Ignore
|
|
120
|
-
}
|
|
121
|
-
// Check all other packages in lock file
|
|
122
|
-
for (const [packageKey, locked] of Object.entries(lockFile.dependencies)) {
|
|
123
|
-
if (packageKey === targetPackage) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
const cacheDir = this.getCacheDir(packageKey, locked.commit);
|
|
127
|
-
const packageDeps = await this.loadPackageDependencies(cacheDir);
|
|
128
|
-
if (packageDeps[targetPackage]) {
|
|
129
|
-
reverseDeps.push({
|
|
130
|
-
dependentPackage: packageKey,
|
|
131
|
-
ref: locked.ref,
|
|
132
|
-
type: 'direct',
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return reverseDeps;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Formats a dependency tree as a readable string.
|
|
140
|
-
*/
|
|
141
|
-
formatDependencyTree(nodes, options = {}) {
|
|
142
|
-
const lines = [];
|
|
143
|
-
const formatNode = (node, prefix, isLast) => {
|
|
144
|
-
const branch = isLast ? '└── ' : '├── ';
|
|
145
|
-
const refStr = options.showCommits
|
|
146
|
-
? `${node.ref} (${node.commit.substring(0, 7)})`
|
|
147
|
-
: node.ref;
|
|
148
|
-
lines.push(`${prefix}${branch}${node.packageKey}@${refStr}`);
|
|
149
|
-
const childPrefix = prefix + (isLast ? ' ' : '│ ');
|
|
150
|
-
node.dependencies.forEach((child, index) => {
|
|
151
|
-
const isLastChild = index === node.dependencies.length - 1;
|
|
152
|
-
formatNode(child, childPrefix, isLastChild);
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
nodes.forEach((node, index) => {
|
|
156
|
-
formatNode(node, '', index === nodes.length - 1);
|
|
157
|
-
});
|
|
158
|
-
return lines.join('\n');
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Detects circular dependencies in a dependency graph.
|
|
162
|
-
*/
|
|
163
|
-
async detectCircularDependencies(lockFile) {
|
|
164
|
-
const cycles = [];
|
|
165
|
-
const visiting = new Set();
|
|
166
|
-
const completed = new Set();
|
|
167
|
-
const dfs = async (packageKey, path) => {
|
|
168
|
-
if (visiting.has(packageKey)) {
|
|
169
|
-
const cycleStart = path.indexOf(packageKey);
|
|
170
|
-
const cycle = cycleStart >= 0
|
|
171
|
-
? [...path.slice(cycleStart), packageKey]
|
|
172
|
-
: [...path, packageKey];
|
|
173
|
-
cycles.push(cycle);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (completed.has(packageKey)) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
visiting.add(packageKey);
|
|
180
|
-
const locked = lockFile.dependencies[packageKey];
|
|
181
|
-
if (locked) {
|
|
182
|
-
const cacheDir = this.getCacheDir(packageKey, locked.commit);
|
|
183
|
-
const deps = await this.loadPackageDependencies(cacheDir);
|
|
184
|
-
for (const depKey of Object.keys(deps)) {
|
|
185
|
-
await dfs(depKey, [...path, packageKey]);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
visiting.delete(packageKey);
|
|
189
|
-
completed.add(packageKey);
|
|
190
|
-
};
|
|
191
|
-
for (const packageKey of Object.keys(lockFile.dependencies)) {
|
|
192
|
-
await dfs(packageKey, []);
|
|
193
|
-
}
|
|
194
|
-
return cycles;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Resolves ref policies (latest, stable) to concrete refs.
|
|
198
|
-
*/
|
|
199
|
-
async resolveVersionPolicy(_packageKey, policy, availableRefs) {
|
|
200
|
-
if (policy === 'latest') {
|
|
201
|
-
// Return the most recent ref
|
|
202
|
-
const sorted = sortVersionsDescending(availableRefs);
|
|
203
|
-
return {
|
|
204
|
-
policy: 'latest',
|
|
205
|
-
ref: sorted[0] || 'main',
|
|
206
|
-
availableRefs: sorted,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
if (policy === 'stable') {
|
|
210
|
-
// Return the most recent stable ref (exclude pre-release)
|
|
211
|
-
const stable = availableRefs.filter(v => !isPreRelease(v));
|
|
212
|
-
const sorted = sortVersionsDescending(stable);
|
|
213
|
-
return {
|
|
214
|
-
policy: 'stable',
|
|
215
|
-
ref: sorted[0] || 'main',
|
|
216
|
-
availableRefs: sorted,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
// Pinned ref
|
|
220
|
-
return {
|
|
221
|
-
policy: 'pinned',
|
|
222
|
-
ref: policy,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Gets the cache directory for a package.
|
|
227
|
-
*/
|
|
228
|
-
getCacheDir(packageKey, commit) {
|
|
229
|
-
const [owner, repo] = packageKey.split('/');
|
|
230
|
-
return path.join(os.homedir(), '.dlang', 'cache', 'github', // Assume GitHub for now
|
|
231
|
-
owner, repo, commit);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Loads dependencies from a cached package.
|
|
235
|
-
*/
|
|
236
|
-
async loadPackageDependencies(cacheDir) {
|
|
237
|
-
const manifestPath = path.join(cacheDir, 'model.yaml');
|
|
238
|
-
try {
|
|
239
|
-
const content = await fs.readFile(manifestPath, 'utf-8');
|
|
240
|
-
const manifest = YAML.parse(content);
|
|
241
|
-
const deps = {};
|
|
242
|
-
if (manifest.dependencies) {
|
|
243
|
-
for (const [, dep] of Object.entries(manifest.dependencies)) {
|
|
244
|
-
deps[dep.source] = dep.version;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return deps;
|
|
248
|
-
}
|
|
249
|
-
catch {
|
|
250
|
-
return {};
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
//# sourceMappingURL=dependency-analyzer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-analyzer.js","sourceRoot":"","sources":["../../src/services/dependency-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC3B;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,QAAkB,EAAE,aAAqB;QAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAE5D,gDAAgD;QAChD,MAAM,QAAQ,GAA2B,EAAE,CAAC;QAC5C,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAA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AuB,CAAC,QAAgB;QAClD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEvD,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAElC,CAAC;YAEF,MAAM,IAAI,GAA2B,EAAE,CAAC;YACxC,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;gBACxB,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC1D,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;gBACnC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency Resolution Service
|
|
3
|
-
*
|
|
4
|
-
* Discovers and resolves transitive dependencies for DomainLang packages.
|
|
5
|
-
* Generates lock files for reproducible builds.
|
|
6
|
-
*
|
|
7
|
-
* Algorithm:
|
|
8
|
-
* 1. Parse root model.yaml
|
|
9
|
-
* 2. Download all direct dependencies
|
|
10
|
-
* 3. Parse each dependency's model.yaml
|
|
11
|
-
* 4. Recursively discover transitive dependencies
|
|
12
|
-
* 5. Resolve version constraints using "Latest Wins" strategy
|
|
13
|
-
* 6. Generate lock file with pinned commit hashes
|
|
14
|
-
*
|
|
15
|
-
* Resolution Strategy ("Latest Wins"):
|
|
16
|
-
* - SemVer tags (same major): Pick highest compatible version
|
|
17
|
-
* - Same branch: No conflict, resolve once
|
|
18
|
-
* - Commit pins: Error (explicit pins are intentional)
|
|
19
|
-
* - Major version mismatch: Error
|
|
20
|
-
* - Tag vs Branch: Error (incompatible intent)
|
|
21
|
-
*/
|
|
22
|
-
import { GitUrlResolver } from './git-url-resolver.js';
|
|
23
|
-
import type { LockFile } from './types.js';
|
|
24
|
-
export declare class DependencyResolver {
|
|
25
|
-
private gitResolver;
|
|
26
|
-
private workspaceRoot;
|
|
27
|
-
constructor(workspaceRoot: string, gitResolver?: GitUrlResolver);
|
|
28
|
-
/**
|
|
29
|
-
* Resolves all dependencies for a workspace.
|
|
30
|
-
*
|
|
31
|
-
* Process:
|
|
32
|
-
* 1. Load root model.yaml
|
|
33
|
-
* 2. Build dependency graph (discover transitive deps)
|
|
34
|
-
* 3. Resolve version constraints
|
|
35
|
-
* 4. Generate lock file
|
|
36
|
-
* 5. Download all dependencies to cache
|
|
37
|
-
*
|
|
38
|
-
* @returns Generated lock file
|
|
39
|
-
*/
|
|
40
|
-
resolveDependencies(): Promise<LockFile>;
|
|
41
|
-
/**
|
|
42
|
-
* Applies ref overrides from model.yaml to resolve conflicts explicitly.
|
|
43
|
-
*
|
|
44
|
-
* Overrides take precedence over all other constraints.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```yaml
|
|
48
|
-
* overrides:
|
|
49
|
-
* domainlang/core: v2.0.0
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
private applyOverrides;
|
|
53
|
-
/** Override messages for CLI output */
|
|
54
|
-
private overrideMessages;
|
|
55
|
-
/**
|
|
56
|
-
* Returns any override messages from the last dependency resolution.
|
|
57
|
-
*/
|
|
58
|
-
getOverrideMessages(): string[];
|
|
59
|
-
/**
|
|
60
|
-
* Builds the complete dependency graph by recursively discovering transitive dependencies.
|
|
61
|
-
*/
|
|
62
|
-
private buildDependencyGraph;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves ref constraints to specific commits.
|
|
65
|
-
*
|
|
66
|
-
* Simple algorithm: Use the ref specified in the constraint.
|
|
67
|
-
* Detects refType (tag, branch, or commit) based on format.
|
|
68
|
-
*/
|
|
69
|
-
private resolveVersions;
|
|
70
|
-
/**
|
|
71
|
-
* Extracts a ref from a constraint string.
|
|
72
|
-
*
|
|
73
|
-
* Examples:
|
|
74
|
-
* - "^1.0.0" → "1.0.0" (treated as tag)
|
|
75
|
-
* - "~2.3.0" → "2.3.0" (treated as tag)
|
|
76
|
-
* - "1.5.0" → "1.5.0" (treated as tag)
|
|
77
|
-
* - "main" → "main" (treated as branch)
|
|
78
|
-
* - "abc123def" → "abc123def" (treated as commit)
|
|
79
|
-
* - "owner/repo@1.0.0" → "1.0.0"
|
|
80
|
-
*/
|
|
81
|
-
private extractRefFromConstraint;
|
|
82
|
-
/**
|
|
83
|
-
* Resolves a version (tag/branch) to a commit hash using git ls-remote.
|
|
84
|
-
*/
|
|
85
|
-
private resolveCommitHash;
|
|
86
|
-
/**
|
|
87
|
-
* Generates a lock file from the resolved dependency graph.
|
|
88
|
-
*/
|
|
89
|
-
private generateLockFile;
|
|
90
|
-
/**
|
|
91
|
-
* Loads and parses a package's model.yaml file.
|
|
92
|
-
*/
|
|
93
|
-
private loadPackageConfig;
|
|
94
|
-
/**
|
|
95
|
-
* Parses model.yaml content.
|
|
96
|
-
*
|
|
97
|
-
* Expected structure:
|
|
98
|
-
* model:
|
|
99
|
-
* name: package-name
|
|
100
|
-
* version: 1.0.0
|
|
101
|
-
* entry: index.dlang
|
|
102
|
-
*
|
|
103
|
-
* dependencies:
|
|
104
|
-
* package-name:
|
|
105
|
-
* source: owner/repo
|
|
106
|
-
* ref: v1.0.0
|
|
107
|
-
*/
|
|
108
|
-
private parseYaml;
|
|
109
|
-
/**
|
|
110
|
-
* Detects ref conflicts and applies "Latest Wins" resolution strategy.
|
|
111
|
-
*
|
|
112
|
-
* Resolution Rules:
|
|
113
|
-
* - SemVer tags (same major): Pick highest version automatically
|
|
114
|
-
* - Same branch refs: No conflict, use single resolution
|
|
115
|
-
* - Commit SHA conflicts: Error (explicit pins are intentional)
|
|
116
|
-
* - Major version mismatch: Error (breaking change)
|
|
117
|
-
* - Tag vs Branch: Error (incompatible intent)
|
|
118
|
-
*
|
|
119
|
-
* Modifies graph nodes in-place to set the resolved constraint.
|
|
120
|
-
* Throws an error only for unresolvable conflicts.
|
|
121
|
-
*/
|
|
122
|
-
private detectVersionConflicts;
|
|
123
|
-
/**
|
|
124
|
-
* Throws a formatted conflict error with actionable hints.
|
|
125
|
-
*/
|
|
126
|
-
private throwConflictError;
|
|
127
|
-
/** Resolution messages from "Latest Wins" auto-resolution */
|
|
128
|
-
private resolutionMessages;
|
|
129
|
-
/**
|
|
130
|
-
* Returns any resolution messages from the last dependency resolution.
|
|
131
|
-
* Useful for CLI output to inform users about auto-resolved conflicts.
|
|
132
|
-
*/
|
|
133
|
-
getResolutionMessages(): string[];
|
|
134
|
-
/**
|
|
135
|
-
* Detects package-level cycles in the dependency graph and throws a clear error.
|
|
136
|
-
*/
|
|
137
|
-
private detectPackageCycles;
|
|
138
|
-
/**
|
|
139
|
-
* Loads an existing lock file from disk.
|
|
140
|
-
*/
|
|
141
|
-
static loadLockFile(workspaceRoot: string): Promise<LockFile | undefined>;
|
|
142
|
-
/**
|
|
143
|
-
* Parses a lock file from JSON format.
|
|
144
|
-
*/
|
|
145
|
-
static parseLockFile(content: string): LockFile;
|
|
146
|
-
}
|