@angular-modernizer/adapter-mcp 1.2.0 → 2.1.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 +688 -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 +10 -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 +55 -4
- package/dist/tools/analyze-project.js +104 -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/compare-health.d.ts +40 -4
- package/dist/tools/compare-health.js +22 -5
- 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 +25 -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/health-delta.d.ts +6 -0
- package/dist/tools/helpers/health-delta.js +4 -1
- package/dist/tools/helpers/library-import-warning.d.ts +33 -0
- package/dist/tools/helpers/library-import-warning.js +38 -0
- package/dist/tools/helpers/library-imports.d.ts +38 -14
- package/dist/tools/helpers/library-imports.js +128 -23
- package/dist/tools/helpers/output-contract.d.ts +64 -0
- package/dist/tools/helpers/output-contract.js +67 -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 +631 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +117 -5
- package/dist/tools/helpers/scan-cache.js +179 -6
- package/dist/tools/helpers/scan-engine.d.ts +43 -6
- package/dist/tools/helpers/scan-engine.js +141 -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 +37 -15
- package/dist/tools/scan-all.js +76 -115
- package/dist/tools/scan-angular.d.ts +33 -14
- package/dist/tools/scan-angular.js +77 -94
- package/dist/tools/scan-architecture.d.ts +37 -12
- package/dist/tools/scan-architecture.js +220 -139
- package/dist/tools/scan-solid.d.ts +33 -14
- package/dist/tools/scan-solid.js +80 -91
- 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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { existsSync, readFileSync } from 'node:fs';
|
|
11
11
|
import { isAbsolute, relative, resolve } from 'node:path';
|
|
12
12
|
import { Project } from 'ts-morph';
|
|
13
|
-
import { ConfigLoader, DependencyGraphBuilder, buildViolationPlan, } from '@angular-modernizer/core';
|
|
13
|
+
import { ConfigLoader, DependencyGraphBuilder, buildViolationPlan, addReadableSourceFiles, tsConfigFileNames, unreadableFilesWarning, } from '@angular-modernizer/core';
|
|
14
14
|
import { LayerPathMatcher, loadLayersFromSource, } from '@angular-modernizer/plugin-architecture';
|
|
15
15
|
import { findTsConfig } from './find-ts-config.js';
|
|
16
16
|
function isRecord(value) {
|
|
@@ -71,6 +71,20 @@ function isScanViolation(value) {
|
|
|
71
71
|
typeof value['ruleId'] === 'string' &&
|
|
72
72
|
typeof value['severity'] === 'string');
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Project of a tsconfig with its program files, added one by one: an
|
|
76
|
+
* unreadable file is left out and named in `warnings` instead of failing the
|
|
77
|
+
* plan.
|
|
78
|
+
*/
|
|
79
|
+
function loadProgram(tsConfigPath, warnings) {
|
|
80
|
+
const project = new Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
|
|
81
|
+
const warning = unreadableFilesWarning(addReadableSourceFiles(project, tsConfigFileNames(tsConfigPath)));
|
|
82
|
+
if (warning !== undefined) {
|
|
83
|
+
warnings.push(warning);
|
|
84
|
+
}
|
|
85
|
+
project.resolveSourceFileDependencies();
|
|
86
|
+
return project;
|
|
87
|
+
}
|
|
74
88
|
/**
|
|
75
89
|
* Build the file-level plan for violations that carry a file path.
|
|
76
90
|
*/
|
|
@@ -81,7 +95,7 @@ export async function buildScanPlan(options) {
|
|
|
81
95
|
if (!tsConfigPath) {
|
|
82
96
|
throw new Error(`tsconfig.json not found in project: ${projectRoot}`);
|
|
83
97
|
}
|
|
84
|
-
const project = (await options.loadProject?.(tsConfigPath)) ??
|
|
98
|
+
const project = (await options.loadProject?.(tsConfigPath)) ?? loadProgram(tsConfigPath, warnings);
|
|
85
99
|
const graph = new DependencyGraphBuilder(project, { templateEdges: true });
|
|
86
100
|
await graph.buildGraph();
|
|
87
101
|
const { layers, source } = await loadLayers(projectRoot, warnings);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the source maps of bundle stack frames (`main.js`) for the api
|
|
3
|
+
* `StackTraceParser`.
|
|
4
|
+
*
|
|
5
|
+
* Order per bundle: a map on disk first (the bundle resolved under the project
|
|
6
|
+
* root or a build output folder `dist/<app>/browser`, its `sourceMappingURL`
|
|
7
|
+
* comment or `<bundle>.map`), then, when allowed, one HTTP fetch of
|
|
8
|
+
* `<bundle url>.map` from a loopback host (dev server). Other hosts are never
|
|
9
|
+
* contacted.
|
|
10
|
+
*/
|
|
11
|
+
import { type SourceMapLookup } from '@angular-modernizer/api';
|
|
12
|
+
/** Fetches a URL as text; `undefined` on any failure. Called only for loopback URLs. */
|
|
13
|
+
export type SourceMapFetcher = (url: string, timeoutMs: number) => Promise<string | undefined>;
|
|
14
|
+
/** Timeout of one source map fetch. */
|
|
15
|
+
export declare const SOURCE_MAP_FETCH_TIMEOUT_MS = 2000;
|
|
16
|
+
/** Where the map of one bundle came from, or why there is none. */
|
|
17
|
+
export interface SourceMapOrigin {
|
|
18
|
+
/** Bundle as the frames name it (without query). */
|
|
19
|
+
bundle: string;
|
|
20
|
+
/** Path or URL of the map; absent when none was found. */
|
|
21
|
+
map?: string;
|
|
22
|
+
/** `disk` or `http`; absent when none was found. */
|
|
23
|
+
from?: 'disk' | 'http';
|
|
24
|
+
/** Why no map was used, when none was found. */
|
|
25
|
+
reason?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Options of {@link loadSourceMaps}. */
|
|
28
|
+
export interface SourceMapLoadOptions {
|
|
29
|
+
/** Absolute project root; disk lookups stay inside it. */
|
|
30
|
+
projectRoot: string;
|
|
31
|
+
/** `false` skips the HTTP step. */
|
|
32
|
+
fetchSourceMaps: boolean;
|
|
33
|
+
/** HTTP fetcher (injected in tests). */
|
|
34
|
+
fetchText: SourceMapFetcher;
|
|
35
|
+
}
|
|
36
|
+
/** Result of {@link loadSourceMaps}. */
|
|
37
|
+
export interface SourceMapLoadResult {
|
|
38
|
+
/** Lookup for the parser. */
|
|
39
|
+
lookup: SourceMapLookup;
|
|
40
|
+
/** One entry per requested bundle. */
|
|
41
|
+
origins: SourceMapOrigin[];
|
|
42
|
+
}
|
|
43
|
+
/** `true` for `http(s)://` URLs on localhost, 127.0.0.1 or ::1. */
|
|
44
|
+
export declare function isLoopbackUrl(url: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Default {@link SourceMapFetcher}: global `fetch` with a timeout. Refuses
|
|
47
|
+
* anything but loopback URLs as a second guard.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchLoopbackText(url: string, timeoutMs: number): Promise<string | undefined>;
|
|
50
|
+
/**
|
|
51
|
+
* Loads the maps of the given bundles (keys from `StackTraceParser.sourceMapBundles`).
|
|
52
|
+
* At most one fetch per bundle; bundles are distinct.
|
|
53
|
+
*/
|
|
54
|
+
export declare function loadSourceMaps(bundles: readonly string[], options: SourceMapLoadOptions): Promise<SourceMapLoadResult>;
|
|
55
|
+
//# sourceMappingURL=source-map-loader.d.ts.map
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the source maps of bundle stack frames (`main.js`) for the api
|
|
3
|
+
* `StackTraceParser`.
|
|
4
|
+
*
|
|
5
|
+
* Order per bundle: a map on disk first (the bundle resolved under the project
|
|
6
|
+
* root or a build output folder `dist/<app>/browser`, its `sourceMappingURL`
|
|
7
|
+
* comment or `<bundle>.map`), then, when allowed, one HTTP fetch of
|
|
8
|
+
* `<bundle url>.map` from a loopback host (dev server). Other hosts are never
|
|
9
|
+
* contacted.
|
|
10
|
+
*/
|
|
11
|
+
import { closeSync, openSync, readFileSync, readSync, readdirSync, statSync } from 'node:fs';
|
|
12
|
+
import { dirname, isAbsolute, join, normalize, resolve, sep } from 'node:path';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { parseSourceMap, } from '@angular-modernizer/api';
|
|
15
|
+
/** Hosts a source map may be fetched from. */
|
|
16
|
+
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]']);
|
|
17
|
+
/** Timeout of one source map fetch. */
|
|
18
|
+
export const SOURCE_MAP_FETCH_TIMEOUT_MS = 2000;
|
|
19
|
+
/** Maps above this size are not read (disk) or not kept (HTTP). */
|
|
20
|
+
const MAX_MAP_BYTES = 64 * 1024 * 1024;
|
|
21
|
+
/** Bytes read from the end of a bundle to find its `sourceMappingURL` comment. */
|
|
22
|
+
const BUNDLE_TAIL_BYTES = 4096;
|
|
23
|
+
/** Build output folders below `dist/` looked at per bundle. */
|
|
24
|
+
const MAX_DIST_FOLDERS = 20;
|
|
25
|
+
const SOURCE_MAPPING_URL = /\/\/[#@]\s*sourceMappingURL=(\S+)\s*$/;
|
|
26
|
+
const INLINE_MAP = /^data:application\/json(?:;charset=[^;,]+)?;base64,/i;
|
|
27
|
+
/** `true` for `http(s)://` URLs on localhost, 127.0.0.1 or ::1. */
|
|
28
|
+
export function isLoopbackUrl(url) {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = new URL(url);
|
|
31
|
+
return ((parsed.protocol === 'http:' || parsed.protocol === 'https:') &&
|
|
32
|
+
LOOPBACK_HOSTS.has(parsed.hostname));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Default {@link SourceMapFetcher}: global `fetch` with a timeout. Refuses
|
|
40
|
+
* anything but loopback URLs as a second guard.
|
|
41
|
+
*/
|
|
42
|
+
export async function fetchLoopbackText(url, timeoutMs) {
|
|
43
|
+
if (!isLoopbackUrl(url)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(url, {
|
|
48
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
49
|
+
redirect: 'error',
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const text = await response.text();
|
|
55
|
+
return text.length > MAX_MAP_BYTES ? undefined : text;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Loads the maps of the given bundles (keys from `StackTraceParser.sourceMapBundles`).
|
|
63
|
+
* At most one fetch per bundle; bundles are distinct.
|
|
64
|
+
*/
|
|
65
|
+
export async function loadSourceMaps(bundles, options) {
|
|
66
|
+
const loaded = new Map();
|
|
67
|
+
const origins = [];
|
|
68
|
+
const root = resolve(options.projectRoot);
|
|
69
|
+
const distFolders = listDistFolders(root);
|
|
70
|
+
for (const bundle of bundles) {
|
|
71
|
+
const fromDisk = loadFromDisk(bundle, root, distFolders);
|
|
72
|
+
if (fromDisk !== undefined) {
|
|
73
|
+
loaded.set(bundle, fromDisk);
|
|
74
|
+
origins.push({ bundle, map: fromDisk.url, from: 'disk' });
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const origin = await loadOverHttp(bundle, options, loaded);
|
|
78
|
+
origins.push(origin);
|
|
79
|
+
}
|
|
80
|
+
return { lookup: { get: (bundle) => loaded.get(bundle) }, origins };
|
|
81
|
+
}
|
|
82
|
+
async function loadOverHttp(bundle, options, loaded) {
|
|
83
|
+
if (!/^https?:\/\//.test(bundle)) {
|
|
84
|
+
return { bundle, reason: 'no map on disk' };
|
|
85
|
+
}
|
|
86
|
+
if (!options.fetchSourceMaps) {
|
|
87
|
+
return { bundle, reason: 'no map on disk, fetchSourceMaps is false' };
|
|
88
|
+
}
|
|
89
|
+
if (!isLoopbackUrl(bundle)) {
|
|
90
|
+
return { bundle, reason: 'no map on disk, host is not loopback (not fetched)' };
|
|
91
|
+
}
|
|
92
|
+
const mapUrl = `${bundle}.map`;
|
|
93
|
+
const text = await options.fetchText(mapUrl, SOURCE_MAP_FETCH_TIMEOUT_MS);
|
|
94
|
+
const map = text === undefined ? undefined : parseSourceMap(text);
|
|
95
|
+
if (map === undefined) {
|
|
96
|
+
return { bundle, reason: `no map on disk, ${mapUrl} not available` };
|
|
97
|
+
}
|
|
98
|
+
loaded.set(bundle, { map, url: mapUrl });
|
|
99
|
+
return { bundle, map: mapUrl, from: 'http' };
|
|
100
|
+
}
|
|
101
|
+
function isInside(root, path) {
|
|
102
|
+
return path === root || path.startsWith(root + sep);
|
|
103
|
+
}
|
|
104
|
+
function isFile(path) {
|
|
105
|
+
try {
|
|
106
|
+
return statSync(path).isFile();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function listDistFolders(root) {
|
|
113
|
+
try {
|
|
114
|
+
return readdirSync(join(root, 'dist'), { withFileTypes: true })
|
|
115
|
+
.filter((entry) => entry.isDirectory())
|
|
116
|
+
.map((entry) => entry.name)
|
|
117
|
+
.sort()
|
|
118
|
+
.slice(0, MAX_DIST_FOLDERS);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Absolute bundle paths under the root a bundle key may stand for. */
|
|
125
|
+
function bundleCandidates(bundle, root, distFolders) {
|
|
126
|
+
let urlPath;
|
|
127
|
+
try {
|
|
128
|
+
if (bundle.startsWith('file://')) {
|
|
129
|
+
return [fileURLToPath(bundle)];
|
|
130
|
+
}
|
|
131
|
+
if (isAbsolute(bundle) && !/^https?:\/\//.test(bundle)) {
|
|
132
|
+
return [bundle];
|
|
133
|
+
}
|
|
134
|
+
urlPath = decodeURIComponent(new URL(bundle).pathname);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
if (urlPath.startsWith('/@fs/')) {
|
|
140
|
+
return [urlPath.slice('/@fs'.length)];
|
|
141
|
+
}
|
|
142
|
+
const relative = urlPath.replace(/^\/+/, '');
|
|
143
|
+
return [
|
|
144
|
+
join(root, relative),
|
|
145
|
+
join(root, 'dist', relative),
|
|
146
|
+
...distFolders.flatMap((folder) => [
|
|
147
|
+
join(root, 'dist', folder, 'browser', relative),
|
|
148
|
+
join(root, 'dist', folder, relative),
|
|
149
|
+
]),
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
function loadFromDisk(bundle, root, distFolders) {
|
|
153
|
+
for (const candidate of bundleCandidates(bundle, root, distFolders)) {
|
|
154
|
+
const path = normalize(candidate);
|
|
155
|
+
if (!isInside(root, path)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const map = isFile(path) ? mapOfBundleFile(path, root) : undefined;
|
|
159
|
+
const fallback = map ?? readMapFile(`${path}.map`, root);
|
|
160
|
+
if (fallback !== undefined) {
|
|
161
|
+
return fallback;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
/** The map a bundle file names in its `sourceMappingURL` comment. */
|
|
167
|
+
function mapOfBundleFile(path, root) {
|
|
168
|
+
const reference = sourceMappingUrlOf(path);
|
|
169
|
+
if (reference === undefined) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
if (INLINE_MAP.test(reference)) {
|
|
173
|
+
const text = Buffer.from(reference.replace(INLINE_MAP, ''), 'base64').toString('utf8');
|
|
174
|
+
const map = parseSourceMap(text);
|
|
175
|
+
return map === undefined ? undefined : { map, url: path };
|
|
176
|
+
}
|
|
177
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(reference)) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
let target;
|
|
181
|
+
try {
|
|
182
|
+
target = join(dirname(path), decodeURIComponent(reference));
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
return readMapFile(target, root);
|
|
188
|
+
}
|
|
189
|
+
function sourceMappingUrlOf(path) {
|
|
190
|
+
let fd;
|
|
191
|
+
try {
|
|
192
|
+
const size = statSync(path).size;
|
|
193
|
+
const length = Math.min(size, BUNDLE_TAIL_BYTES);
|
|
194
|
+
const buffer = Buffer.alloc(length);
|
|
195
|
+
fd = openSync(path, 'r');
|
|
196
|
+
readSync(fd, buffer, 0, length, size - length);
|
|
197
|
+
const tail = buffer.toString('utf8').trimEnd();
|
|
198
|
+
return SOURCE_MAPPING_URL.exec(tail)?.[1];
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
if (fd !== undefined) {
|
|
205
|
+
closeSync(fd);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function readMapFile(path, root) {
|
|
210
|
+
const normalized = normalize(path);
|
|
211
|
+
if (!isInside(root, normalized)) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const stat = statSync(normalized);
|
|
216
|
+
if (!stat.isFile() || stat.size > MAX_MAP_BYTES) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
const map = parseSourceMap(readFileSync(normalized, 'utf8'));
|
|
220
|
+
return map === undefined ? undefined : { map, url: normalized };
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=source-map-loader.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular template check of transform-code: when a call changed a template
|
|
3
|
+
* (a `templateUrl` file or the text of an inline `template`), the Angular
|
|
4
|
+
* compiler of the target project compares the template errors (NG codes) of
|
|
5
|
+
* the affected components before and after the call. A new error fails the
|
|
6
|
+
* transformation like a new type error.
|
|
7
|
+
*/
|
|
8
|
+
import { type Project } from 'ts-morph';
|
|
9
|
+
import { type TransformedFile } from './transform-safety.js';
|
|
10
|
+
/** One template error, without position, so lists before and after compare. */
|
|
11
|
+
export interface TemplateDiagnostic {
|
|
12
|
+
/** File the compiler reports it in (a component or its template file). */
|
|
13
|
+
file: string;
|
|
14
|
+
/** `NG<code>: <message>`, or `TS<code>: <message>` for a template type error. */
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
/** What a {@link TemplateChecker} compiles. */
|
|
18
|
+
export interface TemplateCheckRequest {
|
|
19
|
+
/** Root of the target project; its `@angular/compiler-cli` compiles. */
|
|
20
|
+
projectRoot: string;
|
|
21
|
+
/** tsconfig of the project (compiler options and `angularCompilerOptions`). */
|
|
22
|
+
tsConfigPath: string;
|
|
23
|
+
/** Component files whose template the call changed: the programs' root names. */
|
|
24
|
+
components: string[];
|
|
25
|
+
/** Text of every changed file before the call; `undefined` for a created file. */
|
|
26
|
+
oldTexts: ReadonlyMap<string, string | undefined>;
|
|
27
|
+
}
|
|
28
|
+
/** Template errors of the components at the old and at the current texts. */
|
|
29
|
+
export interface TemplateCheckOutcome {
|
|
30
|
+
/** `false` when the project has no Angular compiler; `reason` says why. */
|
|
31
|
+
available: boolean;
|
|
32
|
+
/** Why the check could not run. */
|
|
33
|
+
reason?: string;
|
|
34
|
+
/** Errors with the old texts. */
|
|
35
|
+
before: TemplateDiagnostic[];
|
|
36
|
+
/** Errors with the texts on disk. */
|
|
37
|
+
after: TemplateDiagnostic[];
|
|
38
|
+
}
|
|
39
|
+
/** Compiles the templates of a call before and after it (injectable for tests). */
|
|
40
|
+
export type TemplateChecker = (request: TemplateCheckRequest) => Promise<TemplateCheckOutcome>;
|
|
41
|
+
/** Outcome of the template check of one call or batch. */
|
|
42
|
+
export interface TemplateCheckResult {
|
|
43
|
+
/** `skipped` when no Angular compiler could be loaded. */
|
|
44
|
+
status: 'passed' | 'failed' | 'skipped';
|
|
45
|
+
/** New errors (`<file>: NG<code>: <message>`) with the changed files that caused them. */
|
|
46
|
+
introduced: {
|
|
47
|
+
error: string;
|
|
48
|
+
changedFiles: string[];
|
|
49
|
+
}[];
|
|
50
|
+
/** Why the check was skipped. */
|
|
51
|
+
warning?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The default checker: two small Angular programs (`NgtscProgram` of the
|
|
55
|
+
* project's `@angular/compiler-cli`, loaded with `createRequire` from its
|
|
56
|
+
* `package.json`) with the changed components as root names, one reading the
|
|
57
|
+
* old texts. Without `@angular/compiler-cli` it reports `available: false`.
|
|
58
|
+
*/
|
|
59
|
+
export declare const angularTemplateChecker: TemplateChecker;
|
|
60
|
+
/**
|
|
61
|
+
* Components whose template the changed files changed, each with the
|
|
62
|
+
* changed files that changed it: owners of a changed template file, and
|
|
63
|
+
* TypeScript files whose inline `template` text changed.
|
|
64
|
+
*/
|
|
65
|
+
export declare function changedTemplateComponents(project: Project, changed: readonly TransformedFile[]): Map<string, string[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Runs the template check for the changed files; `undefined` when they
|
|
68
|
+
* changed no template. New errors are the multiset difference of the error
|
|
69
|
+
* lists; each is attributed to the changed file it is reported in, else to
|
|
70
|
+
* the changed files of its component, else to every changed template.
|
|
71
|
+
*/
|
|
72
|
+
export declare function checkChangedTemplates(project: Project, changed: readonly TransformedFile[], target: {
|
|
73
|
+
projectRoot: string;
|
|
74
|
+
tsConfigPath: string;
|
|
75
|
+
}, checker: TemplateChecker): Promise<TemplateCheckResult | undefined>;
|
|
76
|
+
//# sourceMappingURL=template-check.d.ts.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular template check of transform-code: when a call changed a template
|
|
3
|
+
* (a `templateUrl` file or the text of an inline `template`), the Angular
|
|
4
|
+
* compiler of the target project compares the template errors (NG codes) of
|
|
5
|
+
* the affected components before and after the call. A new error fails the
|
|
6
|
+
* transformation like a new type error.
|
|
7
|
+
*/
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
11
|
+
import { ts } from 'ts-morph';
|
|
12
|
+
import { findTemplateOwnerClasses } from '@angular-modernizer/api';
|
|
13
|
+
import { introducedTypeErrors } from './transform-safety.js';
|
|
14
|
+
/** `@angular/compiler-cli` installed in the project, or `undefined`. */
|
|
15
|
+
async function loadCompilerCli(projectRoot) {
|
|
16
|
+
let entry;
|
|
17
|
+
try {
|
|
18
|
+
entry = createRequire(join(projectRoot, 'package.json')).resolve('@angular/compiler-cli');
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return (await import(pathToFileURL(entry).href));
|
|
24
|
+
}
|
|
25
|
+
/** `NG<code>` for Angular's own codes (`-99<code>`), `TS<code>` for template type errors. */
|
|
26
|
+
function diagnosticCode(code) {
|
|
27
|
+
const text = String(code);
|
|
28
|
+
return text.startsWith('-99') ? `NG${text.slice(3)}` : `TS${text}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Template errors of `rootNames` with `texts` in place of the files on disk
|
|
32
|
+
* (a path mapped to `undefined` does not exist).
|
|
33
|
+
*/
|
|
34
|
+
async function ngDiagnostics(ngc, rootNames, options, texts) {
|
|
35
|
+
const host = ngc.createCompilerHost({ options });
|
|
36
|
+
if (texts !== undefined) {
|
|
37
|
+
// The TypeScript host reads source files through readFile, the Angular
|
|
38
|
+
// compiler reads templates through it too
|
|
39
|
+
const readFile = host.readFile.bind(host);
|
|
40
|
+
const fileExists = host.fileExists.bind(host);
|
|
41
|
+
host.readFile = (fileName) => (texts.has(resolve(fileName)) ? texts.get(resolve(fileName)) : readFile(fileName));
|
|
42
|
+
host.fileExists = (fileName) => texts.has(resolve(fileName)) ? texts.get(resolve(fileName)) !== undefined : fileExists(fileName);
|
|
43
|
+
}
|
|
44
|
+
const program = new ngc.NgtscProgram(rootNames, options, host);
|
|
45
|
+
await program.loadNgStructureAsync();
|
|
46
|
+
return [...program.getNgStructuralDiagnostics(), ...program.getNgSemanticDiagnostics()]
|
|
47
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Error)
|
|
48
|
+
.map((d) => ({
|
|
49
|
+
file: d.file === undefined ? '' : resolve(d.file.fileName),
|
|
50
|
+
message: `${diagnosticCode(d.code)}: ${ts.flattenDiagnosticMessageText(d.messageText, ' ')}`,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The default checker: two small Angular programs (`NgtscProgram` of the
|
|
55
|
+
* project's `@angular/compiler-cli`, loaded with `createRequire` from its
|
|
56
|
+
* `package.json`) with the changed components as root names, one reading the
|
|
57
|
+
* old texts. Without `@angular/compiler-cli` it reports `available: false`.
|
|
58
|
+
*/
|
|
59
|
+
export const angularTemplateChecker = async (request) => {
|
|
60
|
+
const ngc = await loadCompilerCli(request.projectRoot);
|
|
61
|
+
if (ngc === undefined) {
|
|
62
|
+
return {
|
|
63
|
+
available: false,
|
|
64
|
+
reason: `@angular/compiler-cli is not installed in ${request.projectRoot}`,
|
|
65
|
+
before: [],
|
|
66
|
+
after: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const options = { ...ngc.readConfiguration(request.tsConfigPath).options, noEmit: true };
|
|
70
|
+
const existedBefore = request.components.filter((c) => request.oldTexts.get(c) !== undefined || !request.oldTexts.has(c));
|
|
71
|
+
return {
|
|
72
|
+
available: true,
|
|
73
|
+
before: await ngDiagnostics(ngc, existedBefore, options, request.oldTexts),
|
|
74
|
+
after: await ngDiagnostics(ngc, request.components, options),
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/** Texts of the `template` properties in decorators of a TypeScript text. */
|
|
78
|
+
function inlineTemplateTexts(fileName, text) {
|
|
79
|
+
// Parse only texts that can hold an inline template
|
|
80
|
+
if (text === undefined || !/\btemplate\s*:/.test(text)) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const sourceFile = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true);
|
|
84
|
+
const found = [];
|
|
85
|
+
const visit = (node, inDecorator) => {
|
|
86
|
+
const decorated = inDecorator || ts.isDecorator(node);
|
|
87
|
+
if (decorated && ts.isPropertyAssignment(node) && node.name.getText(sourceFile) === 'template') {
|
|
88
|
+
found.push(node.initializer.getText(sourceFile));
|
|
89
|
+
}
|
|
90
|
+
ts.forEachChild(node, (child) => visit(child, decorated));
|
|
91
|
+
};
|
|
92
|
+
visit(sourceFile, false);
|
|
93
|
+
return found;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Components whose template the changed files changed, each with the
|
|
97
|
+
* changed files that changed it: owners of a changed template file, and
|
|
98
|
+
* TypeScript files whose inline `template` text changed.
|
|
99
|
+
*/
|
|
100
|
+
export function changedTemplateComponents(project, changed) {
|
|
101
|
+
const components = new Map();
|
|
102
|
+
const add = (component, changedFile) => {
|
|
103
|
+
components.set(component, [...new Set([...(components.get(component) ?? []), changedFile])]);
|
|
104
|
+
};
|
|
105
|
+
for (const file of changed) {
|
|
106
|
+
// A deleted template or component has nothing left to check; a moved
|
|
107
|
+
// one is checked at its new place
|
|
108
|
+
if (file.deleted === true) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (file.plain === true) {
|
|
112
|
+
for (const owner of findTemplateOwnerClasses(project, file.filePath)) {
|
|
113
|
+
add(owner.getSourceFile().getFilePath(), file.filePath);
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const before = inlineTemplateTexts(file.filePath, file.before);
|
|
118
|
+
const after = inlineTemplateTexts(file.filePath, file.after);
|
|
119
|
+
if (before.join('\0') !== after.join('\0')) {
|
|
120
|
+
add(file.filePath, file.filePath);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return components;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Runs the template check for the changed files; `undefined` when they
|
|
127
|
+
* changed no template. New errors are the multiset difference of the error
|
|
128
|
+
* lists; each is attributed to the changed file it is reported in, else to
|
|
129
|
+
* the changed files of its component, else to every changed template.
|
|
130
|
+
*/
|
|
131
|
+
export async function checkChangedTemplates(project, changed, target, checker) {
|
|
132
|
+
const components = changedTemplateComponents(project, changed);
|
|
133
|
+
if (components.size === 0) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const outcome = await checker({
|
|
137
|
+
...target,
|
|
138
|
+
components: [...components.keys()],
|
|
139
|
+
oldTexts: new Map(changed.map((f) => [f.filePath, f.before])),
|
|
140
|
+
});
|
|
141
|
+
if (!outcome.available) {
|
|
142
|
+
return {
|
|
143
|
+
status: 'skipped',
|
|
144
|
+
introduced: [],
|
|
145
|
+
warning: `Template check skipped: ${outcome.reason ?? 'no Angular compiler'}`,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const key = (d) => `${d.file}: ${d.message}`;
|
|
149
|
+
const changedPaths = new Set(changed.map((f) => f.filePath));
|
|
150
|
+
const allSources = [...new Set([...components.values()].flat())];
|
|
151
|
+
const introduced = introducedTypeErrors(outcome.before.map(key), outcome.after.map(key)).map((error) => {
|
|
152
|
+
const file = outcome.after.find((d) => key(d) === error)?.file ?? '';
|
|
153
|
+
const changedFiles = changedPaths.has(file) ? [file] : (components.get(file) ?? allSources);
|
|
154
|
+
return { error, changedFiles };
|
|
155
|
+
});
|
|
156
|
+
return { status: introduced.length > 0 ? 'failed' : 'passed', introduced };
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=template-check.js.map
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* now and gets no cache config there.
|
|
7
7
|
*/
|
|
8
8
|
import { CacheManager } from '@angular-modernizer/core';
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Opens `.angular-modernizer-cache/<tool>/` of `rootPath`.
|
|
11
|
+
*
|
|
12
|
+
* @param version - Cache version; entries written with another version are
|
|
13
|
+
* stale. Defaults to the core default.
|
|
14
|
+
*/
|
|
15
|
+
export declare function openToolCache(rootPath: string, tool: 'solid' | 'angular' | 'architecture', version?: string): Promise<CacheManager>;
|
|
11
16
|
//# sourceMappingURL=tool-cache.d.ts.map
|
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
* now and gets no cache config there.
|
|
7
7
|
*/
|
|
8
8
|
import { CacheManager, RealFileSystemAdapter, createToolCacheConfig, } from '@angular-modernizer/core';
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Opens `.angular-modernizer-cache/<tool>/` of `rootPath`.
|
|
11
|
+
*
|
|
12
|
+
* @param version - Cache version; entries written with another version are
|
|
13
|
+
* stale. Defaults to the core default.
|
|
14
|
+
*/
|
|
15
|
+
export async function openToolCache(rootPath, tool, version) {
|
|
16
|
+
const config = createToolCacheConfig(rootPath, tool);
|
|
17
|
+
const cache = new CacheManager(new RealFileSystemAdapter(), version === undefined ? config : { ...config, version });
|
|
12
18
|
await cache.initialize();
|
|
13
19
|
return cache;
|
|
14
20
|
}
|
|
@@ -17,6 +17,14 @@ export declare function throttleProgress(send: ProgressFn, intervalMs?: number,
|
|
|
17
17
|
* the event loop a turn. Long loops therefore call this once per file.
|
|
18
18
|
*/
|
|
19
19
|
export declare function yieldIfCancellable(signal: AbortSignal | undefined): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Lets the event loop read stdin before `signal` is checked after a long
|
|
22
|
+
* synchronous block (a batch's type check): data that arrived meanwhile
|
|
23
|
+
* takes two turns to abort the signal, one to read it and one to dispatch
|
|
24
|
+
* the cancel, as the server's own read before an answer does. Without a
|
|
25
|
+
* signal it returns at once.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readCancelAfterBlock(signal: AbortSignal | undefined): Promise<void>;
|
|
20
28
|
/** Progress message of a file loop: `12/40 files, 3 violations`. */
|
|
21
29
|
export declare function fileProgressMessage(analyzed: number, total: number, violations: number): string;
|
|
22
30
|
/**
|
|
@@ -24,6 +32,16 @@ export declare function fileProgressMessage(analyzed: number, total: number, vio
|
|
|
24
32
|
* `undefined` without progress, so the loop does no extra work.
|
|
25
33
|
*/
|
|
26
34
|
export declare function fileProgress(progress: ProgressFn | undefined): ((analyzed: number, total: number, violations: number) => void) | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Last progress value of a file loop that ended (not cancelled): `total` of
|
|
37
|
+
* `total`, so the throttle lets it through and the client sees the scan end.
|
|
38
|
+
* Files that could not be loaded, or that a time budget skipped, produce no
|
|
39
|
+
* file event; without this the last value stayed below the total. A scan
|
|
40
|
+
* served entirely from the cache sends only this value. The message says how
|
|
41
|
+
* many files were analyzed. Nothing is sent for an empty scope or when
|
|
42
|
+
* `lastReported`, the last value the loop sent, already is the total.
|
|
43
|
+
*/
|
|
44
|
+
export declare function finalFileProgress(progress: ProgressFn | undefined, total: number, analyzed: number, violations: number, lastReported: number | undefined): void;
|
|
27
45
|
/** Execution details of a scan the client cancelled. */
|
|
28
46
|
export interface CancelledExecution {
|
|
29
47
|
/** Time budget of the scan in milliseconds, when the tool has one. */
|
|
@@ -32,6 +32,19 @@ export async function yieldIfCancellable(signal) {
|
|
|
32
32
|
}
|
|
33
33
|
await new Promise((resolve) => setImmediate(resolve));
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Lets the event loop read stdin before `signal` is checked after a long
|
|
37
|
+
* synchronous block (a batch's type check): data that arrived meanwhile
|
|
38
|
+
* takes two turns to abort the signal, one to read it and one to dispatch
|
|
39
|
+
* the cancel, as the server's own read before an answer does. Without a
|
|
40
|
+
* signal it returns at once.
|
|
41
|
+
*/
|
|
42
|
+
export async function readCancelAfterBlock(signal) {
|
|
43
|
+
if (signal === undefined) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await new Promise((resolve) => setImmediate(() => setImmediate(resolve)));
|
|
47
|
+
}
|
|
35
48
|
/** Progress message of a file loop: `12/40 files, 3 violations`. */
|
|
36
49
|
export function fileProgressMessage(analyzed, total, violations) {
|
|
37
50
|
return `${analyzed}/${total} files, ${violations} violation${violations === 1 ? '' : 's'}`;
|
|
@@ -48,6 +61,22 @@ export function fileProgress(progress) {
|
|
|
48
61
|
progress(analyzed, total, fileProgressMessage(analyzed, total, violations));
|
|
49
62
|
};
|
|
50
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Last progress value of a file loop that ended (not cancelled): `total` of
|
|
66
|
+
* `total`, so the throttle lets it through and the client sees the scan end.
|
|
67
|
+
* Files that could not be loaded, or that a time budget skipped, produce no
|
|
68
|
+
* file event; without this the last value stayed below the total. A scan
|
|
69
|
+
* served entirely from the cache sends only this value. The message says how
|
|
70
|
+
* many files were analyzed. Nothing is sent for an empty scope or when
|
|
71
|
+
* `lastReported`, the last value the loop sent, already is the total.
|
|
72
|
+
*/
|
|
73
|
+
export function finalFileProgress(progress, total, analyzed, violations, lastReported) {
|
|
74
|
+
if (progress === undefined || total === 0 || lastReported === total) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const message = fileProgressMessage(analyzed, total, violations);
|
|
78
|
+
progress(total, total, analyzed >= total ? message : `${message}; ${total - analyzed} not analyzed`);
|
|
79
|
+
}
|
|
51
80
|
/**
|
|
52
81
|
* Execution details of a scan the client cancelled after `analyzed` files.
|
|
53
82
|
* The SDK does not send the result of a cancelled request; it still has to
|