@angular-modernizer/adapter-mcp 1.2.0 → 2.0.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/CHANGELOG.md +662 -0
- package/README.md +84 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/dist/scan-host/scan-host.d.ts +7 -0
- package/dist/scan-host/scan-host.js +73 -10
- package/dist/scan-host/scan-protocol.d.ts +2 -0
- package/dist/scan-host/scan-worker.js +14 -8
- package/dist/server/limited-stdio-transport.d.ts +6 -3
- package/dist/server/limited-stdio-transport.js +26 -9
- package/dist/server/mcp-server.js +1 -1
- package/dist/server/sdk-server.d.ts +14 -3
- package/dist/server/sdk-server.js +54 -6
- package/dist/server/tool-registry.d.ts +3 -1
- package/dist/server/tool-registry.js +8 -3
- package/dist/streaming/progress-store.d.ts +19 -7
- package/dist/streaming/progress-store.js +19 -8
- package/dist/tools/analyze-build-impact.d.ts +7 -4
- package/dist/tools/analyze-build-impact.js +8 -3
- package/dist/tools/analyze-core-to-shared.d.ts +10 -6
- package/dist/tools/analyze-core-to-shared.js +63 -60
- package/dist/tools/analyze-parser-performance.d.ts +57 -13
- package/dist/tools/analyze-parser-performance.js +67 -6
- package/dist/tools/analyze-project.d.ts +30 -4
- package/dist/tools/analyze-project.js +99 -15
- package/dist/tools/check-incremental-compatibility.d.ts +30 -41
- package/dist/tools/check-incremental-compatibility.js +32 -264
- package/dist/tools/collect-feedback.js +15 -2
- package/dist/tools/extract-libraries.js +42 -27
- package/dist/tools/find-angular-symbol.js +3 -2
- package/dist/tools/find-component-hosts.js +3 -2
- package/dist/tools/find-usages.js +21 -12
- package/dist/tools/get-call-graph.js +15 -2
- package/dist/tools/get-operation-progress-tool.d.ts +1 -1
- package/dist/tools/get-operation-progress-tool.js +2 -2
- package/dist/tools/get-operation-progress.d.ts +4 -1
- package/dist/tools/get-operation-progress.js +6 -2
- package/dist/tools/helpers/analysis-output.d.ts +32 -1
- package/dist/tools/helpers/analysis-output.js +22 -1
- package/dist/tools/helpers/build-cache.d.ts +27 -0
- package/dist/tools/helpers/build-cache.js +86 -0
- package/dist/tools/helpers/class-filter.d.ts +18 -0
- package/dist/tools/helpers/class-filter.js +30 -0
- package/dist/tools/helpers/cli-arguments.d.ts +23 -0
- package/dist/tools/helpers/cli-arguments.js +35 -0
- package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
- package/dist/tools/helpers/feedback-catalog.js +196 -0
- package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
- package/dist/tools/helpers/feedback-sidecar.js +381 -0
- package/dist/tools/helpers/file-type-check.d.ts +34 -0
- package/dist/tools/helpers/file-type-check.js +56 -0
- package/dist/tools/helpers/output-contract.d.ts +42 -0
- package/dist/tools/helpers/output-contract.js +54 -0
- package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
- package/dist/tools/helpers/pattern-anonymizer.js +159 -0
- package/dist/tools/helpers/project-cache.d.ts +5 -4
- package/dist/tools/helpers/project-cache.js +21 -16
- package/dist/tools/helpers/project-decorators.d.ts +11 -4
- package/dist/tools/helpers/project-decorators.js +13 -6
- package/dist/tools/helpers/refresh-apply.d.ts +94 -0
- package/dist/tools/helpers/refresh-apply.js +460 -0
- package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
- package/dist/tools/helpers/refresh-inventory.js +610 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +74 -5
- package/dist/tools/helpers/scan-cache.js +134 -6
- package/dist/tools/helpers/scan-engine.d.ts +30 -6
- package/dist/tools/helpers/scan-engine.js +131 -22
- package/dist/tools/helpers/scan-plan.js +16 -2
- package/dist/tools/helpers/source-map-loader.d.ts +55 -0
- package/dist/tools/helpers/source-map-loader.js +226 -0
- package/dist/tools/helpers/template-check.d.ts +76 -0
- package/dist/tools/helpers/template-check.js +158 -0
- package/dist/tools/helpers/tool-cache.d.ts +7 -2
- package/dist/tools/helpers/tool-cache.js +9 -3
- package/dist/tools/helpers/tool-context.d.ts +18 -0
- package/dist/tools/helpers/tool-context.js +29 -0
- package/dist/tools/helpers/transform-safety.d.ts +151 -1
- package/dist/tools/helpers/transform-safety.js +357 -4
- package/dist/tools/inspect-form-group.js +5 -0
- package/dist/tools/inspect-i18n.d.ts +1 -1
- package/dist/tools/inspect-template.js +8 -2
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +1 -1
- package/dist/tools/orchestrate-migration.d.ts +19 -1
- package/dist/tools/orchestrate-migration.js +52 -10
- package/dist/tools/parse-stack-trace.d.ts +48 -1
- package/dist/tools/parse-stack-trace.js +108 -9
- package/dist/tools/plan-migration.js +22 -10
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.js +10 -3
- package/dist/tools/review-feedback.d.ts +42 -7
- package/dist/tools/review-feedback.js +24 -17
- package/dist/tools/rollback-changes.d.ts +5 -0
- package/dist/tools/rollback-changes.js +7 -2
- package/dist/tools/run-angular-cli.js +36 -22
- package/dist/tools/run-build.d.ts +33 -28
- package/dist/tools/run-build.js +136 -438
- package/dist/tools/run-schematic.d.ts +8 -2
- package/dist/tools/run-schematic.js +80 -50
- package/dist/tools/scan-all.d.ts +31 -15
- package/dist/tools/scan-all.js +75 -109
- package/dist/tools/scan-angular.d.ts +27 -14
- package/dist/tools/scan-angular.js +70 -92
- package/dist/tools/scan-architecture.d.ts +29 -12
- package/dist/tools/scan-architecture.js +205 -135
- package/dist/tools/scan-solid.d.ts +27 -14
- package/dist/tools/scan-solid.js +73 -89
- package/dist/tools/search-codebase.d.ts +6 -1
- package/dist/tools/search-codebase.js +13 -7
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.js +3 -2
- package/dist/tools/transform-code-batch.d.ts +9 -9
- package/dist/tools/transform-code.d.ts +161 -12
- package/dist/tools/transform-code.js +715 -206
- package/dist/tools/validate-before-transform.js +2 -1
- package/dist/tools/validate-project-compatibility.d.ts +28 -55
- package/dist/tools/validate-project-compatibility.js +33 -225
- package/dist/tools/validate-transformation.d.ts +40 -26
- package/dist/tools/validate-transformation.js +115 -294
- package/dist/tools/verify-citations.js +8 -2
- package/dist/types.d.ts +9 -9
- package/dist/utils/format-tool-response.d.ts +3 -1
- package/dist/utils/format-tool-response.js +8 -3
- package/package.json +14 -13
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
import { Project } from 'ts-morph';
|
|
2
|
-
import { IncompatibilityDetector, } from '@angular-modernizer/core';
|
|
3
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
2
|
import { join } from 'node:path';
|
|
5
3
|
import { INCOMPATIBILITY_ISSUES_SCHEMA } from './helpers/build-schemas.js';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const blockers = detected.filter((i) => i.severity === 'blocker');
|
|
10
|
-
const verdict = !output.compatible
|
|
11
|
-
? 'Not compatible with incremental builds'
|
|
12
|
-
: output.recommendation === 'use-with-caution'
|
|
13
|
-
? 'Compatible with incremental builds, with caution'
|
|
14
|
-
: 'Compatible with incremental builds';
|
|
15
|
-
const lines = [
|
|
16
|
-
`${verdict} (Angular ${output.angularVersion ?? 'not detected'}); recommendation ${output.recommendation}; ` +
|
|
17
|
-
`${blockers.length} blocker(s), ${detected.length - blockers.length} warning(s)` +
|
|
18
|
-
(output.estimatedSpeedup === null
|
|
19
|
-
? '.'
|
|
20
|
-
: `; estimated speedup ${output.estimatedSpeedup}x.`),
|
|
21
|
-
];
|
|
22
|
-
for (const issue of detected) {
|
|
23
|
-
lines.push(`- ${issue.severity} ${issue.type}: ${issue.message} ${issue.recommendation}`);
|
|
24
|
-
}
|
|
25
|
-
return lines.join('\n');
|
|
26
|
-
}
|
|
4
|
+
/** What the tool answers on every call. */
|
|
5
|
+
const DEPRECATION_MESSAGE = 'check-incremental-compatibility is deprecated and checks nothing: run-build and validate-transformation always run the full build command of the project (the Angular CLI has no file-scoped build). ' +
|
|
6
|
+
'Use analyze-build-impact for the files a change affects and scan-architecture for import cycles.';
|
|
27
7
|
/**
|
|
28
|
-
* MCP tool
|
|
29
|
-
*
|
|
30
|
-
*
|
|
8
|
+
* Deprecated MCP tool that used to check a project for incremental build
|
|
9
|
+
* validation. run-build and validate-transformation have one build path, so
|
|
10
|
+
* there is nothing to check; the tool stays registered in 2.x and answers at
|
|
11
|
+
* once with a deprecation notice, without loading the project.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Use analyze-build-impact for the affected files; removal planned for 3.0.
|
|
31
14
|
*/
|
|
32
15
|
export class CheckIncrementalCompatibilityTool {
|
|
33
16
|
name = 'check-incremental-compatibility';
|
|
34
|
-
title = 'Check Incremental Build Compatibility';
|
|
17
|
+
title = 'Check Incremental Build Compatibility (deprecated)';
|
|
35
18
|
annotations = {
|
|
36
19
|
readOnlyHint: true,
|
|
37
20
|
destructiveHint: false,
|
|
38
21
|
idempotentHint: true,
|
|
39
22
|
openWorldHint: false,
|
|
40
23
|
};
|
|
41
|
-
description = '
|
|
42
|
-
'
|
|
24
|
+
description = 'Deprecated, checks nothing: run-build and validate-transformation always run the full build command of the project. Answers compatible false, recommendation use-full and no issues. ' +
|
|
25
|
+
'Use analyze-build-impact for the files a change affects and scan-architecture for import cycles.';
|
|
43
26
|
/**
|
|
44
27
|
* JSON Schema of the tool arguments.
|
|
45
28
|
* @hidden
|
|
@@ -50,22 +33,22 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
50
33
|
properties: {
|
|
51
34
|
projectPath: {
|
|
52
35
|
type: 'string',
|
|
53
|
-
description: 'Project root path
|
|
36
|
+
description: 'Project root path',
|
|
54
37
|
},
|
|
55
38
|
maxCircularDeps: {
|
|
56
39
|
type: 'number',
|
|
57
|
-
description: '
|
|
58
|
-
|
|
40
|
+
description: 'Deprecated, no effect',
|
|
41
|
+
deprecated: true,
|
|
59
42
|
},
|
|
60
43
|
minAngularVersion: {
|
|
61
44
|
type: 'string',
|
|
62
|
-
description: '
|
|
63
|
-
|
|
45
|
+
description: 'Deprecated, no effect',
|
|
46
|
+
deprecated: true,
|
|
64
47
|
},
|
|
65
48
|
maxInterProjectDeps: {
|
|
66
49
|
type: 'number',
|
|
67
|
-
description: '
|
|
68
|
-
|
|
50
|
+
description: 'Deprecated, no effect',
|
|
51
|
+
deprecated: true,
|
|
69
52
|
},
|
|
70
53
|
},
|
|
71
54
|
required: ['projectPath'],
|
|
@@ -85,6 +68,7 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
85
68
|
enum: ['use-incremental', 'use-full', 'use-with-caution'],
|
|
86
69
|
},
|
|
87
70
|
estimatedSpeedup: { type: ['number', 'null'] },
|
|
71
|
+
deprecated: { type: 'boolean' },
|
|
88
72
|
message: { type: 'string' },
|
|
89
73
|
summary: { type: 'string' },
|
|
90
74
|
},
|
|
@@ -103,49 +87,19 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
103
87
|
if (!params.projectPath) {
|
|
104
88
|
throw new Error('projectPath is required');
|
|
105
89
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
skipAddingFilesFromTsConfig: false,
|
|
119
|
-
});
|
|
120
|
-
// Create IncompatibilityDetector with optional config
|
|
121
|
-
const detector = new IncompatibilityDetector(project, projectPath, {
|
|
122
|
-
maxCircularDeps: params.maxCircularDeps,
|
|
123
|
-
minAngularVersion: params.minAngularVersion,
|
|
124
|
-
maxInterProjectDeps: params.maxInterProjectDeps,
|
|
125
|
-
});
|
|
126
|
-
// Run compatibility checks
|
|
127
|
-
const issues = await detector.checkProjectCompatibility();
|
|
128
|
-
// Extract Angular version
|
|
129
|
-
const angularVersion = this.extractAngularVersion(projectPath);
|
|
130
|
-
// Determine compatibility (no blockers detected)
|
|
131
|
-
const blockers = issues.filter((issue) => issue.severity === 'blocker' && issue.detected);
|
|
132
|
-
const warnings = issues.filter((issue) => issue.severity === 'warning' && issue.detected);
|
|
133
|
-
const compatible = blockers.length === 0;
|
|
134
|
-
// Determine recommendation
|
|
135
|
-
const recommendation = this.determineRecommendation(blockers, warnings);
|
|
136
|
-
// Calculate estimated speedup
|
|
137
|
-
const estimatedSpeedup = compatible ? this.calculateSpeedup(project) : null;
|
|
138
|
-
// Format user-facing message
|
|
139
|
-
const message = this.formatMessage(compatible, angularVersion, issues, recommendation, estimatedSpeedup);
|
|
140
|
-
const output = {
|
|
141
|
-
compatible,
|
|
142
|
-
angularVersion,
|
|
143
|
-
issues,
|
|
144
|
-
recommendation,
|
|
145
|
-
estimatedSpeedup,
|
|
146
|
-
message,
|
|
90
|
+
if (!existsSync(params.projectPath)) {
|
|
91
|
+
throw new Error(`Project path does not exist: ${params.projectPath}`);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
compatible: false,
|
|
95
|
+
angularVersion: this.extractAngularVersion(params.projectPath),
|
|
96
|
+
issues: [],
|
|
97
|
+
recommendation: 'use-full',
|
|
98
|
+
estimatedSpeedup: null,
|
|
99
|
+
deprecated: true,
|
|
100
|
+
message: DEPRECATION_MESSAGE,
|
|
101
|
+
summary: DEPRECATION_MESSAGE,
|
|
147
102
|
};
|
|
148
|
-
return { ...output, summary: describeCompatibility(output) };
|
|
149
103
|
}
|
|
150
104
|
/**
|
|
151
105
|
* Extracts Angular version from package.json
|
|
@@ -171,191 +125,5 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
171
125
|
return null;
|
|
172
126
|
}
|
|
173
127
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Determines recommendation based on blockers and warnings
|
|
176
|
-
*/
|
|
177
|
-
determineRecommendation(blockers, warnings) {
|
|
178
|
-
if (blockers.length > 0) {
|
|
179
|
-
return 'use-full';
|
|
180
|
-
}
|
|
181
|
-
if (warnings.length > 0) {
|
|
182
|
-
return 'use-with-caution';
|
|
183
|
-
}
|
|
184
|
-
return 'use-incremental';
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Calculates estimated speedup for incremental builds
|
|
188
|
-
*
|
|
189
|
-
* Estimates based on:
|
|
190
|
-
* - Project size (number of files)
|
|
191
|
-
* - Typical change patterns (10-20% of files modified)
|
|
192
|
-
* - Build time heuristics
|
|
193
|
-
*
|
|
194
|
-
* Returns speedup factor (e.g., 5.2 = 5.2x faster)
|
|
195
|
-
*/
|
|
196
|
-
calculateSpeedup(project) {
|
|
197
|
-
const sourceFiles = project.getSourceFiles();
|
|
198
|
-
const fileCount = sourceFiles.length;
|
|
199
|
-
// Estimate full build time based on file count
|
|
200
|
-
// Heuristic: 50 files = 30s, 500 files = 4min (240s)
|
|
201
|
-
// Linear interpolation with some diminishing returns at scale
|
|
202
|
-
let fullBuildTimeSeconds;
|
|
203
|
-
if (fileCount <= 50) {
|
|
204
|
-
fullBuildTimeSeconds = 30;
|
|
205
|
-
}
|
|
206
|
-
else if (fileCount <= 500) {
|
|
207
|
-
// Linear interpolation: 30s to 240s
|
|
208
|
-
const ratio = (fileCount - 50) / (500 - 50);
|
|
209
|
-
fullBuildTimeSeconds = 30 + ratio * (240 - 30);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
// Large projects: 240s + additional time
|
|
213
|
-
const extraFiles = fileCount - 500;
|
|
214
|
-
fullBuildTimeSeconds = 240 + extraFiles * 0.3; // 0.3s per extra file
|
|
215
|
-
}
|
|
216
|
-
// Estimate incremental build time
|
|
217
|
-
// Typically validates 10-20% of files for small changes
|
|
218
|
-
// Heuristic: 10-15% of full build time + 5s overhead
|
|
219
|
-
const incrementalBuildTimeSeconds = fullBuildTimeSeconds * 0.12 + 5;
|
|
220
|
-
// Calculate speedup ratio
|
|
221
|
-
const speedup = fullBuildTimeSeconds / incrementalBuildTimeSeconds;
|
|
222
|
-
// Round to 1 decimal place
|
|
223
|
-
return Math.round(speedup * 10) / 10;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Formats user-facing message with compatibility status, issues, and recommendations
|
|
227
|
-
*/
|
|
228
|
-
formatMessage(compatible, angularVersion, issues, recommendation, estimatedSpeedup) {
|
|
229
|
-
const lines = [];
|
|
230
|
-
// Status header
|
|
231
|
-
if (compatible && recommendation === 'use-incremental') {
|
|
232
|
-
lines.push('✅ Incremental build compatible with this project');
|
|
233
|
-
}
|
|
234
|
-
else if (compatible && recommendation === 'use-with-caution') {
|
|
235
|
-
lines.push('⚠️ Incremental build compatible with caution');
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
lines.push('❌ Incremental build not compatible with this project');
|
|
239
|
-
}
|
|
240
|
-
lines.push('');
|
|
241
|
-
// Angular version
|
|
242
|
-
if (angularVersion) {
|
|
243
|
-
const versionStatus = this.getVersionStatus(angularVersion);
|
|
244
|
-
lines.push(`Angular version: ${angularVersion} ${versionStatus}`);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
lines.push('Angular version: Not detected');
|
|
248
|
-
}
|
|
249
|
-
lines.push('');
|
|
250
|
-
// Issues section
|
|
251
|
-
const blockers = issues.filter((issue) => issue.severity === 'blocker' && issue.detected);
|
|
252
|
-
const warnings = issues.filter((issue) => issue.severity === 'warning' && issue.detected);
|
|
253
|
-
if (blockers.length > 0 || warnings.length > 0) {
|
|
254
|
-
lines.push('Issues:');
|
|
255
|
-
blockers.forEach((issue) => {
|
|
256
|
-
lines.push(` [BLOCKER] ${issue.message}`);
|
|
257
|
-
lines.push(` → ${issue.recommendation}`);
|
|
258
|
-
if (issue.details) {
|
|
259
|
-
const detailsStr = this.formatDetails(issue.details);
|
|
260
|
-
if (detailsStr) {
|
|
261
|
-
lines.push(` ${detailsStr}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
lines.push('');
|
|
265
|
-
});
|
|
266
|
-
warnings.forEach((issue) => {
|
|
267
|
-
lines.push(` [WARNING] ${issue.message}`);
|
|
268
|
-
lines.push(` → ${issue.recommendation}`);
|
|
269
|
-
if (issue.details) {
|
|
270
|
-
const detailsStr = this.formatDetails(issue.details);
|
|
271
|
-
if (detailsStr) {
|
|
272
|
-
lines.push(` ${detailsStr}`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
lines.push('');
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
lines.push('No compatibility issues detected');
|
|
280
|
-
lines.push('');
|
|
281
|
-
}
|
|
282
|
-
// Recommendation
|
|
283
|
-
lines.push('Recommendation:');
|
|
284
|
-
switch (recommendation) {
|
|
285
|
-
case 'use-incremental':
|
|
286
|
-
lines.push(' Use incremental build mode for faster validation');
|
|
287
|
-
if (estimatedSpeedup) {
|
|
288
|
-
lines.push(` Estimated speedup: ${estimatedSpeedup}x faster on incremental changes`);
|
|
289
|
-
}
|
|
290
|
-
break;
|
|
291
|
-
case 'use-with-caution':
|
|
292
|
-
lines.push(' Incremental build may work, but test thoroughly');
|
|
293
|
-
lines.push(' Consider using full build if issues occur');
|
|
294
|
-
if (estimatedSpeedup) {
|
|
295
|
-
lines.push(` Potential speedup: ${estimatedSpeedup}x faster (if warnings resolved)`);
|
|
296
|
-
}
|
|
297
|
-
break;
|
|
298
|
-
case 'use-full':
|
|
299
|
-
lines.push(' Use full build mode for this project');
|
|
300
|
-
lines.push(' Address blockers above to enable incremental builds');
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
return lines.join('\n');
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Gets version status indicator (supported/too old)
|
|
307
|
-
*/
|
|
308
|
-
getVersionStatus(version) {
|
|
309
|
-
const majorVersion = Number.parseInt(version.split('.')[0] ?? '0', 10);
|
|
310
|
-
if (majorVersion >= 12) {
|
|
311
|
-
return '(supported)';
|
|
312
|
-
}
|
|
313
|
-
else if (majorVersion >= 10) {
|
|
314
|
-
return '(old, upgrade recommended)';
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
return '(too old, upgrade required)';
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Formats issue details for display
|
|
322
|
-
*/
|
|
323
|
-
formatDetails(details) {
|
|
324
|
-
const parts = [];
|
|
325
|
-
const count = details['count'];
|
|
326
|
-
if (count !== undefined &&
|
|
327
|
-
(typeof count === 'number' || typeof count === 'string')) {
|
|
328
|
-
parts.push(`Count: ${count}`);
|
|
329
|
-
}
|
|
330
|
-
if (details['examples'] && Array.isArray(details['examples'])) {
|
|
331
|
-
const examples = details['examples'].slice(0, 2);
|
|
332
|
-
if (examples.length > 0) {
|
|
333
|
-
parts.push(`Examples: ${examples.join('; ')}`);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const currentVersion = details['currentVersion'];
|
|
337
|
-
if (currentVersion !== undefined && typeof currentVersion === 'string') {
|
|
338
|
-
parts.push(`Current: ${currentVersion}`);
|
|
339
|
-
}
|
|
340
|
-
const minVersion = details['minVersion'];
|
|
341
|
-
if (minVersion !== undefined && typeof minVersion === 'string') {
|
|
342
|
-
parts.push(`Required: ${minVersion}`);
|
|
343
|
-
}
|
|
344
|
-
const projectCount = details['projectCount'];
|
|
345
|
-
if (projectCount !== undefined &&
|
|
346
|
-
(typeof projectCount === 'number' || typeof projectCount === 'string')) {
|
|
347
|
-
parts.push(`Projects: ${projectCount}`);
|
|
348
|
-
}
|
|
349
|
-
const interProjectDeps = details['interProjectDeps'];
|
|
350
|
-
if (interProjectDeps !== undefined &&
|
|
351
|
-
(typeof interProjectDeps === 'number' ||
|
|
352
|
-
typeof interProjectDeps === 'string')) {
|
|
353
|
-
parts.push(`Inter-project deps: ${interProjectDeps}`);
|
|
354
|
-
}
|
|
355
|
-
if (details['configs'] && Array.isArray(details['configs'])) {
|
|
356
|
-
parts.push(`Configs: ${details['configs'].join(', ')}`);
|
|
357
|
-
}
|
|
358
|
-
return parts.length > 0 ? parts.join(', ') : '';
|
|
359
|
-
}
|
|
360
128
|
}
|
|
361
129
|
//# sourceMappingURL=check-incremental-compatibility.js.map
|
|
@@ -632,8 +632,7 @@ export class CollectFeedbackTool {
|
|
|
632
632
|
storageLocations,
|
|
633
633
|
learnings,
|
|
634
634
|
validationResult: {
|
|
635
|
-
valid: validationResult
|
|
636
|
-
.length === 0,
|
|
635
|
+
valid: isValidFeedback(validationResult, config),
|
|
637
636
|
score: validationResult.score,
|
|
638
637
|
issues: validationResult.issues.map((issue) => ({
|
|
639
638
|
type: ValidationType.SCHEMA, // Use ValidationType enum for validation module
|
|
@@ -798,6 +797,20 @@ async function estimateComplexity(filePath) {
|
|
|
798
797
|
return { linesOfCode: 100, complexity: 5 };
|
|
799
798
|
}
|
|
800
799
|
}
|
|
800
|
+
/**
|
|
801
|
+
* Whether collected feedback counts as valid: no errors, and the
|
|
802
|
+
* `tools['collect-feedback']` checks that are set (`strictMode`: no warnings
|
|
803
|
+
* either, `minCompletenessScore`: at least that score). Unset, only errors
|
|
804
|
+
* count, as before the fields were read.
|
|
805
|
+
*/
|
|
806
|
+
function isValidFeedback(result, config) {
|
|
807
|
+
const hasErrors = result.issues.some((issue) => issue.severity === 'error');
|
|
808
|
+
const hasStrictWarnings = config.strictMode === true &&
|
|
809
|
+
result.issues.some((issue) => issue.severity === 'warning');
|
|
810
|
+
const belowMinimum = config.minCompletenessScore !== undefined &&
|
|
811
|
+
result.score < config.minCompletenessScore;
|
|
812
|
+
return !hasErrors && !hasStrictWarnings && !belowMinimum;
|
|
813
|
+
}
|
|
801
814
|
/**
|
|
802
815
|
* Type guard to validate if a parsed value matches the StructuredDiff interface.
|
|
803
816
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
2
|
-
import { Kernel, loadConfig } from '@angular-modernizer/core';
|
|
3
|
-
import { LibraryExtractionAnalysisRule } from '@angular-modernizer/plugin-architecture';
|
|
2
|
+
import { Kernel, applySuppressionComments, loadConfig } from '@angular-modernizer/core';
|
|
3
|
+
import { LIBRARY_EXTRACTION_DEFAULTS, LibraryExtractionAnalysisRule } from '@angular-modernizer/plugin-architecture';
|
|
4
4
|
import { ContextFactory } from '@angular-modernizer/plugin-system';
|
|
5
5
|
import { createPublicApi } from '@angular-modernizer/api';
|
|
6
6
|
import { glob } from 'glob';
|
|
@@ -8,32 +8,45 @@ import { resolve, extname } from 'node:path';
|
|
|
8
8
|
import { countList, pageNote } from './helpers/analysis-output.js';
|
|
9
9
|
import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
10
10
|
/**
|
|
11
|
-
* Default folders scanned for candidates
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Default folders scanned for candidates, shared with the
|
|
12
|
+
* `architecture:library-extraction-opportunity` rule
|
|
13
|
+
* (['shared', 'common', 'core', 'libs']). Data-only foundations in `models` or
|
|
14
|
+
* `interfaces` are found when those folders are passed as `targetFolders`.
|
|
14
15
|
*/
|
|
15
|
-
const DEFAULT_TARGET_FOLDERS =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'interfaces',
|
|
22
|
-
'projects',
|
|
23
|
-
];
|
|
16
|
+
const DEFAULT_TARGET_FOLDERS = LIBRARY_EXTRACTION_DEFAULTS.targetFolders;
|
|
17
|
+
/**
|
|
18
|
+
* Default minimum reusability (0-100), shared with the
|
|
19
|
+
* `architecture:library-extraction-opportunity` rule (40).
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_MIN_REUSABILITY = LIBRARY_EXTRACTION_DEFAULTS.minReusabilityScore;
|
|
24
22
|
/**
|
|
25
|
-
* Default minimum
|
|
26
|
-
*
|
|
27
|
-
* dependencies, barrel export or importers) without demanding 2+ importers
|
|
28
|
-
* AND a barrel export like the former 60 did. The scanner itself uses 20.
|
|
23
|
+
* Default minimum cohesion (0-1), shared with the
|
|
24
|
+
* `architecture:library-extraction-opportunity` rule (0.5).
|
|
29
25
|
*/
|
|
30
|
-
const
|
|
26
|
+
const DEFAULT_MIN_COHESION = LIBRARY_EXTRACTION_DEFAULTS.minCohesionScore;
|
|
27
|
+
/**
|
|
28
|
+
* Files that never become library artifacts: tests, e2e code, tool configs and
|
|
29
|
+
* declaration files, matched against the path relative to the project root.
|
|
30
|
+
* The scanner's `**\/` also matches no folder; the root-level forms stay for
|
|
31
|
+
* readability.
|
|
32
|
+
*/
|
|
33
|
+
const NON_LIBRARY_PATTERNS = [
|
|
34
|
+
'*.spec.ts',
|
|
35
|
+
'**/*.spec.ts',
|
|
36
|
+
'*.test.ts',
|
|
37
|
+
'**/*.test.ts',
|
|
38
|
+
'e2e/**',
|
|
39
|
+
'**/e2e/**',
|
|
40
|
+
'*.config.ts',
|
|
41
|
+
'**/*.config.ts',
|
|
42
|
+
'*.d.ts',
|
|
43
|
+
'**/*.d.ts',
|
|
44
|
+
];
|
|
31
45
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* cluster spread over more than one sub-folder. The scanner itself uses 0.3.
|
|
46
|
+
* Files not loaded into the project at all. Spec and test files stay loaded:
|
|
47
|
+
* the scanner counts an artifact's spec file as test evidence.
|
|
35
48
|
*/
|
|
36
|
-
const
|
|
49
|
+
const NOT_LOADED_PATTERNS = ['**/e2e/**', '**/*.config.ts'];
|
|
37
50
|
/** Candidates spelled out in the summary; the rest is in `opportunities`. */
|
|
38
51
|
const SUMMARY_CANDIDATES = 5;
|
|
39
52
|
/**
|
|
@@ -102,7 +115,7 @@ export class ExtractLibrariesTool {
|
|
|
102
115
|
targetFolders: {
|
|
103
116
|
type: 'array',
|
|
104
117
|
items: { type: 'string' },
|
|
105
|
-
description: "Folders to scan for extraction candidates. Default: ['shared', 'common', 'core', 'libs',
|
|
118
|
+
description: "Folders to scan for extraction candidates (whole path segments). Default: ['shared', 'common', 'core', 'libs'], the default of the architecture:library-extraction-opportunity rule; pass models, interfaces or other folders here to scan them.",
|
|
106
119
|
},
|
|
107
120
|
minReusabilityScore: {
|
|
108
121
|
type: 'number',
|
|
@@ -202,7 +215,7 @@ export class ExtractLibrariesTool {
|
|
|
202
215
|
}
|
|
203
216
|
const startTime = Date.now();
|
|
204
217
|
const projectRoot = resolve(params.rootPath);
|
|
205
|
-
const targetFolders = params.targetFolders ?? DEFAULT_TARGET_FOLDERS;
|
|
218
|
+
const targetFolders = params.targetFolders ?? [...DEFAULT_TARGET_FOLDERS];
|
|
206
219
|
const minReusabilityScore = params.minReusabilityScore ?? DEFAULT_MIN_REUSABILITY;
|
|
207
220
|
const minCohesionScore = params.minCohesionScore ?? DEFAULT_MIN_COHESION;
|
|
208
221
|
const maxResults = params.maxResults ?? 1000;
|
|
@@ -228,9 +241,11 @@ export class ExtractLibrariesTool {
|
|
|
228
241
|
'**/dist/**',
|
|
229
242
|
'**/build/**',
|
|
230
243
|
'**/.git/**',
|
|
244
|
+
...NOT_LOADED_PATTERNS,
|
|
231
245
|
...(params.excludePatterns ?? []),
|
|
232
246
|
],
|
|
233
247
|
absolute: true,
|
|
248
|
+
nodir: true,
|
|
234
249
|
});
|
|
235
250
|
const tsFiles = allFiles.filter((f) => extname(f) === '.ts');
|
|
236
251
|
for (const filePath of tsFiles) {
|
|
@@ -256,7 +271,7 @@ export class ExtractLibrariesTool {
|
|
|
256
271
|
targetFolders,
|
|
257
272
|
minReusabilityScore,
|
|
258
273
|
minCohesionScore,
|
|
259
|
-
excludePatterns: params.excludePatterns ?? [],
|
|
274
|
+
excludePatterns: [...NON_LIBRARY_PATTERNS, ...(params.excludePatterns ?? [])],
|
|
260
275
|
});
|
|
261
276
|
const context = ContextFactory.createAnalysisContext({
|
|
262
277
|
sourceFile: entrySourceFile,
|
|
@@ -264,7 +279,7 @@ export class ExtractLibrariesTool {
|
|
|
264
279
|
api,
|
|
265
280
|
config: extractRulesConfig,
|
|
266
281
|
});
|
|
267
|
-
const rawResults = await extractionRule.analyze(context);
|
|
282
|
+
const rawResults = applySuppressionComments(await extractionRule.analyze(context), extractionRule.id, extractRulesConfig, project);
|
|
268
283
|
// Cast and paginate results
|
|
269
284
|
const allOpportunities = rawResults;
|
|
270
285
|
const paginated = allOpportunities.slice(resultOffset, resultOffset + maxResults);
|
|
@@ -140,11 +140,12 @@ export class FindAngularSymbolTool {
|
|
|
140
140
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
141
141
|
}
|
|
142
142
|
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
143
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
143
144
|
const finder = new AngularSymbolFinder(project, {
|
|
144
|
-
componentDecorators:
|
|
145
|
+
componentDecorators: decorators.componentDecorators,
|
|
145
146
|
});
|
|
146
147
|
const results = finder.findSymbol(params.query, params.type);
|
|
147
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
148
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
148
149
|
const countsByType = {};
|
|
149
150
|
for (const r of results) {
|
|
150
151
|
countsByType[r.angularType] = (countsByType[r.angularType] ?? 0) + 1;
|
|
@@ -315,8 +315,9 @@ export class FindComponentHostsTool {
|
|
|
315
315
|
const file = params.file === undefined || isAbsolute(params.file)
|
|
316
316
|
? params.file
|
|
317
317
|
: resolve(params.projectRoot, params.file);
|
|
318
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
318
319
|
const finder = new ComponentHostFinder((await acquireProject(this.projects, tsConfigPath, ctx)), {
|
|
319
|
-
componentDecorators:
|
|
320
|
+
componentDecorators: decorators.componentDecorators,
|
|
320
321
|
includeTestHosts: params.includeTestHosts === true,
|
|
321
322
|
includeDynamic: params.includeDynamic !== false,
|
|
322
323
|
});
|
|
@@ -327,7 +328,7 @@ export class FindComponentHostsTool {
|
|
|
327
328
|
});
|
|
328
329
|
const { hosts, coverage, dynamicHosts, candidateHosts, ...rest } = result;
|
|
329
330
|
const summary = this.buildSummary(params, result);
|
|
330
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
331
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
331
332
|
if (compact.summaryOnly) {
|
|
332
333
|
return withWarnings({
|
|
333
334
|
...rest,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UsageFinder, } from '@angular-modernizer/api';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
4
5
|
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
5
6
|
import { COMPACT_OUTPUT_SCHEMA, countByDirectory, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
@@ -69,7 +70,7 @@ export class FindUsagesTool {
|
|
|
69
70
|
},
|
|
70
71
|
file: {
|
|
71
72
|
type: 'string',
|
|
72
|
-
description: 'Only report usages located in this file (absolute
|
|
73
|
+
description: 'Only report usages located in this file (absolute, or relative to projectRoot; .ts or .html). ' +
|
|
73
74
|
'The symbol declaration may live in any file. Optional.',
|
|
74
75
|
},
|
|
75
76
|
usageType: {
|
|
@@ -166,11 +167,15 @@ export class FindUsagesTool {
|
|
|
166
167
|
// The shared ProjectCache: a fresh Project cost 4 to 6 s per call on a
|
|
167
168
|
// large workspace and sat next to the cached one while the search ran.
|
|
168
169
|
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
170
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
169
171
|
const finder = new UsageFinder(project, {
|
|
170
|
-
componentDecorators:
|
|
172
|
+
componentDecorators: decorators.componentDecorators,
|
|
171
173
|
});
|
|
174
|
+
const file = params.file === undefined || isAbsolute(params.file)
|
|
175
|
+
? params.file
|
|
176
|
+
: resolve(params.projectRoot, params.file);
|
|
172
177
|
const usages = finder.findUsages(params.symbol, {
|
|
173
|
-
file
|
|
178
|
+
file,
|
|
174
179
|
usageType: params.usageType,
|
|
175
180
|
includeTemplates: params.includeTemplates !== false,
|
|
176
181
|
includeUnresolved: params.includeUnresolved !== false,
|
|
@@ -181,19 +186,19 @@ export class FindUsagesTool {
|
|
|
181
186
|
}
|
|
182
187
|
const countsByDirectory = countByDirectory(usages.map((u) => u.file), params.projectRoot, DIRECTORY_DEPTH);
|
|
183
188
|
const shown = limitList(usages, compact.maxResults);
|
|
184
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
189
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
185
190
|
if (compact.summaryOnly) {
|
|
186
191
|
return withWarnings({
|
|
187
192
|
totalCount: usages.length,
|
|
188
193
|
truncated: false,
|
|
189
|
-
summary: this.buildCompactSummary(params.symbol, usages, countsByType, countsByDirectory, params.
|
|
194
|
+
summary: this.buildCompactSummary(params.symbol, usages, countsByType, countsByDirectory, file, params.usageType),
|
|
190
195
|
countsByType,
|
|
191
196
|
countsByDirectory,
|
|
192
197
|
tsConfigPath,
|
|
193
198
|
}, warnings);
|
|
194
199
|
}
|
|
195
200
|
const note = truncationNote(shown.items.length, usages.length, 'usages');
|
|
196
|
-
const summary = this.buildSummary(params.symbol, shown.items, params.
|
|
201
|
+
const summary = this.buildSummary(params.symbol, shown.items, file, params.usageType);
|
|
197
202
|
return withWarnings({
|
|
198
203
|
usages: shown.items,
|
|
199
204
|
totalCount: usages.length,
|
|
@@ -204,9 +209,9 @@ export class FindUsagesTool {
|
|
|
204
209
|
tsConfigPath,
|
|
205
210
|
}, warnings);
|
|
206
211
|
}
|
|
207
|
-
buildCompactSummary(symbol, usages, countsByType, countsByDirectory, file) {
|
|
212
|
+
buildCompactSummary(symbol, usages, countsByType, countsByDirectory, file, usageType) {
|
|
208
213
|
if (usages.length === 0) {
|
|
209
|
-
return this.buildSummary(symbol, usages, file);
|
|
214
|
+
return this.buildSummary(symbol, usages, file, usageType);
|
|
210
215
|
}
|
|
211
216
|
const fileCount = new Set(usages.map((u) => u.file)).size;
|
|
212
217
|
const types = Object.entries(countsByType)
|
|
@@ -214,7 +219,7 @@ export class FindUsagesTool {
|
|
|
214
219
|
.join(', ');
|
|
215
220
|
const directories = Object.entries(countsByDirectory);
|
|
216
221
|
const lines = [
|
|
217
|
-
`Found ${usages.length} usage(s) of '${symbol}' in ${fileCount} file(s). By type: ${types}.`,
|
|
222
|
+
`Found ${usages.length} usage(s)${ofType(usageType)} of '${symbol}' in ${fileCount} file(s). By type: ${types}.`,
|
|
218
223
|
'Top directories:',
|
|
219
224
|
...directories
|
|
220
225
|
.slice(0, SUMMARY_TOP_DIRECTORIES)
|
|
@@ -225,10 +230,10 @@ export class FindUsagesTool {
|
|
|
225
230
|
}
|
|
226
231
|
return lines.join('\n');
|
|
227
232
|
}
|
|
228
|
-
buildSummary(symbol, usages, file) {
|
|
233
|
+
buildSummary(symbol, usages, file, usageType) {
|
|
229
234
|
if (usages.length === 0) {
|
|
230
235
|
const scope = file ? `in ${file}` : 'across the project';
|
|
231
|
-
return (`No usages of '${symbol}' found ${scope}. Only files in the tsconfig program ` +
|
|
236
|
+
return (`No usages${ofType(usageType)} of '${symbol}' found ${scope}. Only files in the tsconfig program ` +
|
|
232
237
|
'and component templates were searched; verify with search-codebase (text mode) ' +
|
|
233
238
|
'before treating this as proof of absence.');
|
|
234
239
|
}
|
|
@@ -239,7 +244,7 @@ export class FindUsagesTool {
|
|
|
239
244
|
byFile.set(u.file, list);
|
|
240
245
|
}
|
|
241
246
|
const lines = [
|
|
242
|
-
`Found ${usages.length} usage(s) of '${symbol}' across ${byFile.size} file(s):`,
|
|
247
|
+
`Found ${usages.length} usage(s)${ofType(usageType)} of '${symbol}' across ${byFile.size} file(s):`,
|
|
243
248
|
];
|
|
244
249
|
for (const [filePath, fileUsages] of byFile) {
|
|
245
250
|
lines.push(` ${filePath} (${fileUsages.length})`);
|
|
@@ -256,4 +261,8 @@ export class FindUsagesTool {
|
|
|
256
261
|
return lines.join('\n');
|
|
257
262
|
}
|
|
258
263
|
}
|
|
264
|
+
/** Names the `usageType` filter in the summary (` of type call`), empty without one. */
|
|
265
|
+
function ofType(usageType) {
|
|
266
|
+
return usageType === undefined ? '' : ` of type ${usageType}`;
|
|
267
|
+
}
|
|
259
268
|
//# sourceMappingURL=find-usages.js.map
|