@repometry/cli 0.5.0 → 0.6.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 -0
- package/package.json +2 -2
- package/target/main/resources/report/json/report-v2.schema.json +1 -0
- package/target/main/resources/report/json/repository-summary-v1.schema.json +12 -0
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +31 -0
- package/target/main/resources/viewer/index.html +9 -9
- package/target/main/resources/viewer/styles.css +8 -8
- package/target/main/ts/cli/imports.js +21 -17
- package/target/main/ts/compose/analysis-inventory.d.ts +12 -0
- package/target/main/ts/compose/analysis-inventory.js +18 -0
- package/target/main/ts/compose/analysis-report.js +3 -16
- package/target/main/ts/compose/analysis-results.d.ts +1 -0
- package/target/main/ts/compose/analysis-results.js +14 -12
- package/target/main/ts/compose/built-ins.d.ts +2 -2
- package/target/main/ts/compose/built-ins.js +2 -2
- package/target/main/ts/compose/load-plugins.js +9 -6
- package/target/main/ts/plugins/built-in.d.ts +2 -0
- package/target/main/ts/plugins/built-in.js +2 -1
- package/target/main/ts/plugins/json-spans.js +56 -42
- package/target/main/ts/plugins/legal/composer-lock.js +1 -1
- package/target/main/ts/plugins/legal/cyclonedx.d.ts +2 -0
- package/target/main/ts/plugins/legal/cyclonedx.js +61 -0
- package/target/main/ts/plugins/legal/dependencies.d.ts +53 -7
- package/target/main/ts/plugins/legal/dependencies.js +34 -14
- package/target/main/ts/plugins/legal/expression.d.ts +2 -0
- package/target/main/ts/plugins/legal/expression.js +69 -0
- package/target/main/ts/plugins/legal/licenses.d.ts +1 -0
- package/target/main/ts/plugins/legal/licenses.js +55 -28
- package/target/main/ts/plugins/legal/npm-lock.js +2 -1
- package/target/main/ts/plugins/legal/policy.d.ts +7 -11
- package/target/main/ts/plugins/legal/policy.js +23 -102
- package/target/main/ts/plugins/legal/sbom-model.d.ts +7 -0
- package/target/main/ts/plugins/legal/sbom-model.js +11 -0
- package/target/main/ts/plugins/legal/sbom.js +2 -116
- package/target/main/ts/plugins/legal/spdx-catalog.d.ts +9 -0
- package/target/main/ts/plugins/legal/spdx-catalog.js +28 -0
- package/target/main/ts/plugins/legal/spdx-sbom.d.ts +2 -0
- package/target/main/ts/plugins/legal/spdx-sbom.js +65 -0
- package/target/main/ts/report/html/app/viewer-metric-format.d.ts +2 -0
- package/target/main/ts/report/html/app/viewer-metric-format.js +17 -0
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +1 -2
- package/target/main/ts/report/html/app/viewer-metrics.js +1 -17
- package/target/main/ts/report/html/app/viewer-overview-cards.js +15 -19
- package/target/main/ts/report/html/app/viewer-overview-lead.js +1 -1
- package/target/main/ts/report/html/site/asset-versions.d.ts +2 -0
- package/target/main/ts/report/html/site/asset-versions.js +36 -0
- package/target/main/ts/report/html/site/badges.d.ts +5 -1
- package/target/main/ts/report/html/site/badges.js +17 -11
- package/target/main/ts/report/html/site/export-site.js +2 -1
- package/target/main/ts/report/html/site/local-server.js +2 -0
- package/target/main/ts/report/html/site/projects.js +4 -3
- package/target/main/ts/report/json/projections/inspection-details.js +3 -0
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +2 -0
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/maintainability.svg" alt="Maintainability"></a>
|
|
12
12
|
<a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/coverage.svg" alt="Coverage"></a>
|
|
13
13
|
<a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/security.svg" alt="Security"></a>
|
|
14
|
+
<a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/legal.svg" alt="Legal"></a>
|
|
14
15
|
</p>
|
|
15
16
|
|
|
16
17
|
Git can serve as a project’s single source of truth for code, tests, docs, and CI configuration. Repometry lets you keep coverage and maintainability metrics alongside your code, commit by commit.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repometry/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Track repository metrics without SaaS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@babel/parser": "7.29.15",
|
|
69
69
|
"@babel/types": "7.29.15",
|
|
70
|
-
"@repometry/core": "0.
|
|
70
|
+
"@repometry/core": "0.8.0",
|
|
71
71
|
"ajv": "8.20.0",
|
|
72
72
|
"semver": "7.8.6"
|
|
73
73
|
},
|
|
@@ -77,6 +77,18 @@
|
|
|
77
77
|
"grade": { "enum": ["A", "B", "C", "D", "F"] },
|
|
78
78
|
"checked": { "type": "integer", "minimum": 0 },
|
|
79
79
|
"inputs": { "type": "integer", "minimum": 1 },
|
|
80
|
+
"unknownLicenses": { "type": "integer", "minimum": 0 },
|
|
81
|
+
"deniedLicenses": { "type": "integer", "minimum": 0 },
|
|
82
|
+
"licenseKinds": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"required": ["osi", "other", "unknown"],
|
|
85
|
+
"additionalProperties": false,
|
|
86
|
+
"properties": {
|
|
87
|
+
"osi": { "type": "integer", "minimum": 0 },
|
|
88
|
+
"other": { "type": "integer", "minimum": 0 },
|
|
89
|
+
"unknown": { "type": "integer", "minimum": 0 }
|
|
90
|
+
}
|
|
91
|
+
},
|
|
80
92
|
"low": { "type": "integer", "minimum": 0 },
|
|
81
93
|
"medium": { "type": "integer", "minimum": 0 },
|
|
82
94
|
"high": { "type": "integer", "minimum": 0 },
|
|
@@ -44,6 +44,37 @@
|
|
|
44
44
|
"diagnostics": {
|
|
45
45
|
"$ref": "urn:repometry:schema:report:2#/properties/diagnostics"
|
|
46
46
|
},
|
|
47
|
+
"licenseInputs": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"required": ["path", "checked", "groups", "licenseKinds"],
|
|
52
|
+
"additionalProperties": false,
|
|
53
|
+
"properties": {
|
|
54
|
+
"path": { "type": "string" },
|
|
55
|
+
"checked": { "type": "integer", "minimum": 0 },
|
|
56
|
+
"licenseKinds": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": ["osi", "other", "unknown"],
|
|
59
|
+
"additionalProperties": false,
|
|
60
|
+
"properties": {
|
|
61
|
+
"osi": { "type": "integer", "minimum": 0 },
|
|
62
|
+
"other": { "type": "integer", "minimum": 0 },
|
|
63
|
+
"unknown": { "type": "integer", "minimum": 0 }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"groups": {
|
|
67
|
+
"type": "array",
|
|
68
|
+
"items": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"required": ["name", "count"],
|
|
71
|
+
"additionalProperties": false,
|
|
72
|
+
"properties": { "name": { "type": "string", "minLength": 1 }, "count": { "type": "integer", "minimum": 0 } }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
47
78
|
"findings": {
|
|
48
79
|
"$ref": "urn:repometry:schema:report:2#/properties/findings"
|
|
49
80
|
},
|
|
@@ -50,20 +50,20 @@
|
|
|
50
50
|
<div class="card verdict-card">
|
|
51
51
|
<div class="verdicts" role="tablist" aria-label="Quality area">
|
|
52
52
|
<div class="verdict">
|
|
53
|
-
<span id="maintainability" class="mark grade"
|
|
54
|
-
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="debt" aria-controls="trend" aria-describedby="maintainability maintainability-detail
|
|
53
|
+
<span id="maintainability" class="mark grade" data-grade="none">–</span>
|
|
54
|
+
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="debt" aria-controls="trend" aria-describedby="maintainability maintainability-detail">Maintainability</button><span id="maintainability-detail" class="verdict-detail">Not measured</span></span>
|
|
55
55
|
</div>
|
|
56
56
|
<div class="verdict">
|
|
57
|
-
<span id="coverage-mark" class="mark ring" aria-hidden="true"
|
|
58
|
-
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="coverage" aria-controls="trend" aria-describedby="coverage-detail">Coverage</button><span id="coverage-detail" class="verdict-detail"
|
|
57
|
+
<span id="coverage-mark" class="mark ring" data-grade="none" aria-hidden="true">–</span>
|
|
58
|
+
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="coverage" aria-controls="trend" aria-describedby="coverage-detail">Coverage</button><span id="coverage-detail" class="verdict-detail">Not measured</span></span>
|
|
59
59
|
</div>
|
|
60
|
-
<div class="verdict" id="security-verdict"
|
|
61
|
-
<span id="security-mark" class="mark severity"
|
|
62
|
-
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="security" aria-controls="trend" aria-describedby="security-mark security-detail">Security</button><span id="security-detail" class="verdict-detail"
|
|
60
|
+
<div class="verdict" id="security-verdict">
|
|
61
|
+
<span id="security-mark" class="mark severity" data-severity="none">–</span>
|
|
62
|
+
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="security" aria-controls="trend" aria-describedby="security-mark security-detail">Security</button><span id="security-detail" class="verdict-detail">Not measured</span></span>
|
|
63
63
|
</div>
|
|
64
64
|
<div class="verdict" id="legal-verdict">
|
|
65
|
-
<span id="legal-mark" class="mark grade"
|
|
66
|
-
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="legal" aria-controls="trend" aria-describedby="legal-mark legal-detail
|
|
65
|
+
<span id="legal-mark" class="mark grade" data-grade="none">–</span>
|
|
66
|
+
<span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="legal" aria-controls="trend" aria-describedby="legal-mark legal-detail">Legal</button><span id="legal-detail" class="verdict-detail">Not measured</span></span>
|
|
67
67
|
</div>
|
|
68
68
|
</div>
|
|
69
69
|
<section id="trend" class="trend" role="tabpanel" aria-labelledby="trend-title">
|
|
@@ -269,8 +269,6 @@ main:focus { outline: none; }
|
|
|
269
269
|
.verdict-tab:focus-visible { outline: none; }
|
|
270
270
|
.verdict:has(.verdict-tab:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
|
|
271
271
|
.verdict-detail { color: var(--secondary); font-size: .875rem; overflow-wrap: anywhere; }
|
|
272
|
-
/* The coverage kinds beyond lines: a quieter second line under the headline's detail. */
|
|
273
|
-
.verdict-more { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
274
272
|
/* A detail that counts something leads to exactly what it counts. */
|
|
275
273
|
.verdict-detail a { position: relative; z-index: 1; color: inherit; text-decoration-color: var(--rule-strong); }
|
|
276
274
|
@container (min-width: 33rem) and (max-width: 49rem) {
|
|
@@ -280,13 +278,14 @@ main:focus { outline: none; }
|
|
|
280
278
|
}
|
|
281
279
|
.verdict-detail a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
|
|
282
280
|
.mark { flex: none; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 8px; font-size: 1.25rem; font-weight: 650; color: #fff; font-variant-numeric: tabular-nums; }
|
|
283
|
-
.grade { background: var(--grade-
|
|
281
|
+
.grade, .severity { background: var(--grade-none); }
|
|
282
|
+
.grade[data-grade="A"], .severity[data-severity="clear"] { background: var(--grade-a); }
|
|
284
283
|
.grade[data-grade="B"] { background: var(--grade-b); }
|
|
285
284
|
.grade[data-grade="C"] { background: var(--grade-c); }
|
|
286
285
|
.grade[data-grade="D"] { background: var(--grade-d); }
|
|
287
286
|
.grade[data-grade="F"] { background: var(--grade-f); }
|
|
288
|
-
.grade[data-grade="none"] { background: var(--grade-none); }
|
|
289
287
|
.ring { color: var(--ink); }
|
|
288
|
+
.ring[data-grade="none"] { border: .25rem solid var(--rule); border-radius: 50%; }
|
|
290
289
|
.ring svg { width: 2.5rem; height: 2.5rem; }
|
|
291
290
|
.ring-track { fill: none; stroke: var(--rule); stroke-width: 4.5; }
|
|
292
291
|
.ring-arc { fill: none; stroke: var(--grade-a); stroke-width: 4.5; stroke-linecap: butt; transform: rotate(-90deg); transform-origin: 20px 20px; }
|
|
@@ -296,13 +295,13 @@ main:focus { outline: none; }
|
|
|
296
295
|
.ring[data-grade="D"] .ring-arc { stroke: var(--grade-d); }
|
|
297
296
|
.ring[data-grade="F"] .ring-arc { stroke: var(--grade-f); }
|
|
298
297
|
.ring-label { fill: var(--ink); font-size: 12.5px; font-weight: 650; text-anchor: middle; }
|
|
299
|
-
.severity {
|
|
300
|
-
.severity[data-severity="none"] { background: var(--grade-none); }
|
|
298
|
+
.severity { font-size: 1.125rem; }
|
|
301
299
|
.severity[data-severity="low"] { background: var(--grade-b); }
|
|
302
300
|
.severity[data-severity="medium"] { background: var(--grade-c); }
|
|
303
301
|
.severity[data-severity="high"] { background: var(--grade-d); }
|
|
304
302
|
.severity[data-severity="critical"] { background: var(--grade-f); }
|
|
305
303
|
@media (prefers-color-scheme: dark) { .mark:not(.ring) { color: #0d1117; } }
|
|
304
|
+
.grade[data-grade="none"], .severity[data-severity="none"] { color: var(--ink); }
|
|
306
305
|
|
|
307
306
|
.trend { padding: 1rem 1.25rem .5rem; }
|
|
308
307
|
.chart { min-width: 0; margin-top: .5rem; }
|
|
@@ -576,8 +575,9 @@ body > main { flex: 1 0 auto; width: 100%; box-sizing: border-box; padding-botto
|
|
|
576
575
|
.chip-level[data-level="3"] { background: var(--grade-d); }
|
|
577
576
|
.chip-level[data-level="4"] { background: var(--grade-f); }
|
|
578
577
|
@media (prefers-color-scheme: dark) { .chip-level { color: #0d1117; } }
|
|
579
|
-
/* An area with no chart says so once, in the
|
|
580
|
-
.verdict-card:has(#trend[data-empty="true"]
|
|
578
|
+
/* An area with no chart says so once, in the area's own words and what to do about it, not the chart's generic line. */
|
|
579
|
+
.verdict-card:has(.lead-empty) #trend[data-empty="true"] .empty { display: none; }
|
|
580
|
+
.verdict-card:has(#trend[data-empty="true"]) .lead:has(.lead-empty) { border-top: 0; }
|
|
581
581
|
/* A lead figure that counts findings, files or a function leads to them, with a quiet underline. */
|
|
582
582
|
.figure-value a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: .15em; }
|
|
583
583
|
.figure-value a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
|
|
@@ -15,27 +15,31 @@ export function readInputs(base, inputs) {
|
|
|
15
15
|
const cobertura = [];
|
|
16
16
|
const findings = [];
|
|
17
17
|
const licenseInputs = [];
|
|
18
|
+
const coverageInputs = new Map([['lcov', lcov], ['go-cover', goCover], ['cobertura', cobertura]]);
|
|
18
19
|
for (const value of inputs) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
throw new Error('Use --import FORMAT=PATH');
|
|
24
|
-
if (format === 'lcov')
|
|
25
|
-
lcov.push(resolve(base, file));
|
|
26
|
-
else if (format === 'go-cover')
|
|
27
|
-
goCover.push(resolve(base, file));
|
|
28
|
-
else if (format === 'cobertura')
|
|
29
|
-
cobertura.push(resolve(base, file));
|
|
20
|
+
const { format, file } = importInput(base, value);
|
|
21
|
+
const coverage = coverageInputs.get(format);
|
|
22
|
+
if (coverage !== undefined)
|
|
23
|
+
coverage.push(file);
|
|
30
24
|
else if (format === 'cyclonedx' || format === 'spdx')
|
|
31
|
-
licenseInputs.push({ format, file
|
|
32
|
-
else
|
|
33
|
-
|
|
34
|
-
throw new Error(`Unknown import format: ${format}. Choose ${importerIds.join(', ')}.`);
|
|
35
|
-
findings.push({ ...scanners[format], file: resolve(base, file) });
|
|
36
|
-
}
|
|
25
|
+
licenseInputs.push({ format, file });
|
|
26
|
+
else
|
|
27
|
+
findings.push(scannerInput(format, file));
|
|
37
28
|
}
|
|
38
29
|
return { lcov: lcov.length ? lcov : undefined, goCover: goCover.length ? goCover : undefined,
|
|
39
30
|
cobertura: cobertura.length ? cobertura : undefined, findings, ...(licenseInputs.length ? { licenseInputs } : {}) };
|
|
40
31
|
}
|
|
32
|
+
function importInput(base, value) {
|
|
33
|
+
const equal = value.indexOf('=');
|
|
34
|
+
const format = value.slice(0, equal);
|
|
35
|
+
const file = value.slice(equal + 1);
|
|
36
|
+
if (equal < 1 || !/^[a-z][a-z0-9-]*$/.test(format) || file === '')
|
|
37
|
+
throw new Error('Use --import FORMAT=PATH');
|
|
38
|
+
return { format, file: resolve(base, file) };
|
|
39
|
+
}
|
|
40
|
+
function scannerInput(format, file) {
|
|
41
|
+
if (!Object.hasOwn(scanners, format))
|
|
42
|
+
throw new Error('Unknown import format: ' + format + '. Choose ' + importerIds.join(', ') + '.');
|
|
43
|
+
return { ...scanners[format], file };
|
|
44
|
+
}
|
|
41
45
|
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SourceSnapshot } from '@repometry/core/internal/model/source.js';
|
|
2
|
+
import type { AnalysisResults } from './analysis-results.js';
|
|
3
|
+
import type { AnalysisSources } from './phases.js';
|
|
4
|
+
export declare function reportInventory(snapshot: SourceSnapshot, sources: AnalysisSources, results: AnalysisResults): {
|
|
5
|
+
path: string;
|
|
6
|
+
lines: number | null;
|
|
7
|
+
bytes?: number | undefined;
|
|
8
|
+
language: string;
|
|
9
|
+
analysed: boolean;
|
|
10
|
+
provider?: string | undefined;
|
|
11
|
+
unmeasured?: readonly ("classes" | "codeLines" | "cognitiveComplexity" | "commentLines" | "cyclomaticComplexity" | "duplication" | "functions" | "structuralRules")[] | undefined;
|
|
12
|
+
}[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { structureMeasures } from '@repometry/core/internal/model/code-structure.js';
|
|
2
|
+
import { fileTypeId } from '@repometry/core/internal/model/file-types.js';
|
|
3
|
+
import { comparePaths, textLineCount } from '@repometry/core/internal/model/snapshot.js';
|
|
4
|
+
export function reportInventory(snapshot, sources, results) {
|
|
5
|
+
const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
|
|
6
|
+
for (const { path, bytes } of snapshot.files) {
|
|
7
|
+
if (!inventory.has(path))
|
|
8
|
+
inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
|
|
9
|
+
}
|
|
10
|
+
return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
|
|
11
|
+
const provider = sources.providersByPath.get(path);
|
|
12
|
+
const unmeasured = sources.unavailableFiles.has(path) ? structureMeasures : results.unmeasured.get(path);
|
|
13
|
+
return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? fileTypeId(path),
|
|
14
|
+
analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }),
|
|
15
|
+
...(unmeasured === undefined ? {} : { unmeasured }) };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=analysis-inventory.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { codeStructure, codeStructures
|
|
1
|
+
import { codeStructure, codeStructures } from '@repometry/core/internal/model/code-structure.js';
|
|
2
2
|
import { pluginRegistration } from './registered-plugin.js';
|
|
3
3
|
import { pluginScope } from './plugin-scope.js';
|
|
4
4
|
import { checkedDependencies } from '@repometry/core/internal/model/license-evidence.js';
|
|
5
5
|
import { definitions } from '@repometry/core/internal/model/measurement.js';
|
|
6
6
|
import { debtModel } from '@repometry/core/internal/model/quality-summary.js';
|
|
7
7
|
import { reportSchema } from '@repometry/core/internal/model/report.js';
|
|
8
|
-
import {
|
|
8
|
+
import { digest, sourceDirectoriesExcluded } from '@repometry/core/internal/model/snapshot.js';
|
|
9
|
+
import { reportInventory } from './analysis-inventory.js';
|
|
9
10
|
import { defaultSourceExclusions, generatedSourcePolicy } from '@repometry/core/internal/profile/exclusions.js';
|
|
10
11
|
import { duplicationSettings, structuralRules } from '@repometry/core/internal/profile/maintainability.js';
|
|
11
12
|
import { fileTypeId } from '@repometry/core/internal/model/file-types.js';
|
|
@@ -118,18 +119,4 @@ function inspectionStatus(hasSources, results) {
|
|
|
118
119
|
return 'partial';
|
|
119
120
|
return !hasSources && !results.completedInspection ? 'not-applicable' : 'complete';
|
|
120
121
|
}
|
|
121
|
-
function reportInventory(snapshot, sources, results) {
|
|
122
|
-
const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
|
|
123
|
-
for (const { path, bytes } of snapshot.files) {
|
|
124
|
-
if (!inventory.has(path))
|
|
125
|
-
inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
|
|
126
|
-
}
|
|
127
|
-
return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
|
|
128
|
-
const provider = sources.providersByPath.get(path);
|
|
129
|
-
const unmeasured = sources.unavailableFiles.has(path) ? structureMeasures : results.unmeasured.get(path);
|
|
130
|
-
return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? fileTypeId(path),
|
|
131
|
-
analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }),
|
|
132
|
-
...(unmeasured === undefined ? {} : { unmeasured }) };
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
122
|
//# sourceMappingURL=analysis-report.js.map
|
|
@@ -32,6 +32,7 @@ export declare class AnalysisResults {
|
|
|
32
32
|
}[];
|
|
33
33
|
record(task: PlannedOperation, outcome: Outcome, path?: string, paths?: readonly string[]): void;
|
|
34
34
|
hasBlockingDiagnostics(): boolean;
|
|
35
|
+
private recordFindings;
|
|
35
36
|
private recordRecovery;
|
|
36
37
|
private recordInspection;
|
|
37
38
|
}
|
|
@@ -53,18 +53,8 @@ export class AnalysisResults {
|
|
|
53
53
|
const stored = this.products.record(task, outcome.product, path);
|
|
54
54
|
this.recordRecovery(task, outcome.product.value, path);
|
|
55
55
|
this.recordInspection(task, outcome.diagnostics ?? [], path, paths);
|
|
56
|
-
if (stored)
|
|
57
|
-
|
|
58
|
-
this.measurements.push(measurement);
|
|
59
|
-
const reasons = new Map(stored.ignored?.map(({ index, reason }) => [index, reason]));
|
|
60
|
-
for (const [index, finding] of stored.findings.entries()) {
|
|
61
|
-
const reason = reasons.get(index);
|
|
62
|
-
if (reason === undefined)
|
|
63
|
-
this.findings.push(finding);
|
|
64
|
-
else
|
|
65
|
-
this.ignoredFindings.push({ finding, reason });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
56
|
+
if (stored)
|
|
57
|
+
this.recordFindings(stored);
|
|
68
58
|
}
|
|
69
59
|
catch (error) {
|
|
70
60
|
this.diagnostics.push({ operation: task.key, state: 'failed', path, message: error instanceof Error ? error.message : String(error) });
|
|
@@ -73,6 +63,18 @@ export class AnalysisResults {
|
|
|
73
63
|
hasBlockingDiagnostics() {
|
|
74
64
|
return this.diagnostics.some(row => row.path === undefined || this.recovered.get(row.path) !== row);
|
|
75
65
|
}
|
|
66
|
+
recordFindings(stored) {
|
|
67
|
+
for (const measurement of stored.measurements)
|
|
68
|
+
this.measurements.push(measurement);
|
|
69
|
+
const reasons = new Map(stored.ignored?.map(({ index, reason }) => [index, reason]));
|
|
70
|
+
for (const [index, finding] of stored.findings.entries()) {
|
|
71
|
+
const reason = reasons.get(index);
|
|
72
|
+
if (reason === undefined)
|
|
73
|
+
this.findings.push(finding);
|
|
74
|
+
else
|
|
75
|
+
this.ignoredFindings.push({ finding, reason });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
76
78
|
recordRecovery(task, value, path) {
|
|
77
79
|
if (path === undefined || this.recovered.has(path) || !this.recoveryOperations.has(task.key))
|
|
78
80
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
|
|
2
|
-
import { builtInConfigurations, builtInPlugins } from '../plugins/built-in.js';
|
|
3
|
-
export { builtInConfigurations, builtInPlugins };
|
|
2
|
+
import { builtInConfigurations, builtInOptionChecks, builtInPlugins } from '../plugins/built-in.js';
|
|
3
|
+
export { builtInConfigurations, builtInOptionChecks, builtInPlugins };
|
|
4
4
|
export declare const builtInPluginIds: ReadonlySet<string>;
|
|
5
5
|
/** Configured built-ins replace their defaults in registration order. */
|
|
6
6
|
export declare function registeredPlugins(additional: readonly Plugin[]): readonly Plugin[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pluginRegistration } from './registered-plugin.js';
|
|
2
|
-
import { builtInConfigurations, builtInPlugins } from '../plugins/built-in.js';
|
|
2
|
+
import { builtInConfigurations, builtInOptionChecks, builtInPlugins } from '../plugins/built-in.js';
|
|
3
3
|
// The one edge from compose to plugins: everything else in compose reads the built-ins from here.
|
|
4
|
-
export { builtInConfigurations, builtInPlugins };
|
|
4
|
+
export { builtInConfigurations, builtInOptionChecks, builtInPlugins };
|
|
5
5
|
export const builtInPluginIds = new Set(builtInPlugins.map(({ id }) => id));
|
|
6
6
|
/** Configured built-ins replace their defaults in registration order. */
|
|
7
7
|
export function registeredPlugins(additional) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, resolve } from 'node:path';
|
|
2
|
-
import { builtInConfigurations, builtInPlugins } from './built-ins.js';
|
|
2
|
+
import { builtInConfigurations, builtInOptionChecks, builtInPlugins } from './built-ins.js';
|
|
3
3
|
import { installedModule, javaScriptManifest, localModule } from './js-plugin.js';
|
|
4
4
|
import { validatePluginOptions } from './plugin-options.js';
|
|
5
5
|
import { dockerPluginFile, dockerPluginImage } from './process-plugins.js';
|
|
@@ -50,16 +50,13 @@ async function resolvePlugin(input, entry, folder, context, builtIns) {
|
|
|
50
50
|
return { ...await dockerPluginImage(use.slice(7), entry, { base, packageUrl: context.distribution?.packageUrl }), builtIn: false };
|
|
51
51
|
}
|
|
52
52
|
if (use.startsWith('./') || use.startsWith('../') || use.startsWith('/')) {
|
|
53
|
-
|
|
54
|
-
if (path.endsWith('.json')) {
|
|
55
|
-
return { ...await dockerPluginFile(path, entry, { base, packageUrl: context.distribution?.packageUrl }), builtIn: false };
|
|
56
|
-
}
|
|
57
|
-
return { ...await localModule(path, entry, context), builtIn: false };
|
|
53
|
+
return resolvePluginFile(resolve(folder, use), entry, context);
|
|
58
54
|
}
|
|
59
55
|
const pkg = use.startsWith('npm:') ? use.slice(4) : use;
|
|
60
56
|
const alias = pkg.startsWith('@repometry/language-') ? builtIns.get(pkg.slice('@repometry/'.length)) : undefined;
|
|
61
57
|
const builtIn = builtIns.get(use) ?? alias;
|
|
62
58
|
if (builtIn !== undefined) {
|
|
59
|
+
builtInOptionChecks.get(builtIn.id)?.(entry.options);
|
|
63
60
|
validatePluginOptions(builtIn.config, entry.options, base);
|
|
64
61
|
const configure = builtInConfigurations.get(builtIn.id);
|
|
65
62
|
const plugin = configure && entry.options !== undefined ? configure(entry.options) : builtIn;
|
|
@@ -70,4 +67,10 @@ async function resolvePlugin(input, entry, folder, context, builtIns) {
|
|
|
70
67
|
? { ...installed.plugin, languageProvenanceRequiresSource: true } : installed.plugin;
|
|
71
68
|
return { ...installed, plugin, builtIn: false };
|
|
72
69
|
}
|
|
70
|
+
async function resolvePluginFile(path, entry, context) {
|
|
71
|
+
if (path.endsWith('.json')) {
|
|
72
|
+
return { ...await dockerPluginFile(path, entry, { base: context.base, packageUrl: context.distribution?.packageUrl }), builtIn: false };
|
|
73
|
+
}
|
|
74
|
+
return { ...await localModule(path, entry, context), builtIn: false };
|
|
75
|
+
}
|
|
73
76
|
//# sourceMappingURL=load-plugins.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { JsonValue } from '@repometry/core/internal/model/plugin-data.js';
|
|
2
|
+
import { rejectRemovedLicenseOptions } from './legal/licenses.js';
|
|
2
3
|
import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
|
|
4
|
+
export declare const builtInOptionChecks: Map<string, typeof rejectRemovedLicenseOptions>;
|
|
3
5
|
export declare const builtInConfigurations: Map<string, (options: JsonValue) => Plugin>;
|
|
4
6
|
/** The built-in plugins in run order. The first language plugin is the default provider. */
|
|
5
7
|
export declare const builtInPlugins: readonly Plugin[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { licenses } from './legal/licenses.js';
|
|
1
|
+
import { licenses, rejectRemovedLicenseOptions } from './legal/licenses.js';
|
|
2
2
|
import { bundledPlugin } from '@repometry/core/internal/engine/plugin-manifest.js';
|
|
3
3
|
import { coverage } from './coverage/coverage.js';
|
|
4
4
|
import { diffCoverage } from './coverage/diff-coverage.js';
|
|
@@ -14,6 +14,7 @@ import { githubSource, gitlabSource, localSource } from './source/forges.js';
|
|
|
14
14
|
import { structure } from './structure/structure.js';
|
|
15
15
|
// The review path uses the importer kind, which is also part of existing inspection profiles.
|
|
16
16
|
const licensePlugin = licenses();
|
|
17
|
+
export const builtInOptionChecks = new Map([[licensePlugin.id, rejectRemovedLicenseOptions]]);
|
|
17
18
|
export const builtInConfigurations = new Map([[licensePlugin.id, licenses]]);
|
|
18
19
|
const lcov = { ...bundledPlugin(coverage), kinds: ['coverage', 'import'] };
|
|
19
20
|
/** The built-in plugins in run order. The first language plugin is the default provider. */
|
|
@@ -22,50 +22,64 @@ export function locateJsonSpans(text, wanted, depth) {
|
|
|
22
22
|
if (path !== undefined && wanted.has(path))
|
|
23
23
|
spans.set(path, { line: start, endLine: line });
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else if (char === '"') {
|
|
41
|
-
const end = stringEnd(text, index);
|
|
42
|
-
const parent = stack.at(-1);
|
|
43
|
-
if (parent && !parent.array && parent.expectKey) {
|
|
44
|
-
const raw = text.slice(index + 1, end);
|
|
45
|
-
parent.key = raw.includes('\\') ? JSON.parse(text.slice(index, end + 1)) : raw;
|
|
46
|
-
parent.keyLine = line;
|
|
47
|
-
parent.expectKey = false;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
scalar();
|
|
51
|
-
}
|
|
52
|
-
index = end + 1;
|
|
53
|
-
}
|
|
54
|
-
else if (char === '{' || char === '[') {
|
|
55
|
-
const { path, line: start } = child();
|
|
56
|
-
stack.push({ path, line: start, array: char === '[', index: 0, key: '', keyLine: line, expectKey: char === '{' });
|
|
57
|
-
index++;
|
|
58
|
-
}
|
|
59
|
-
else if (char === '}' || char === ']') {
|
|
60
|
-
const frame = stack.pop();
|
|
61
|
-
if (frame?.path !== undefined && wanted.has(frame.path))
|
|
62
|
-
spans.set(frame.path, { line: frame.line, endLine: line });
|
|
63
|
-
index++;
|
|
25
|
+
const nextMember = () => {
|
|
26
|
+
const parent = stack.at(-1);
|
|
27
|
+
if (parent?.array)
|
|
28
|
+
parent.index++;
|
|
29
|
+
else if (parent)
|
|
30
|
+
parent.expectKey = true;
|
|
31
|
+
};
|
|
32
|
+
const readString = (index) => {
|
|
33
|
+
const end = stringEnd(text, index);
|
|
34
|
+
const parent = stack.at(-1);
|
|
35
|
+
if (parent && !parent.array && parent.expectKey) {
|
|
36
|
+
const raw = text.slice(index + 1, end);
|
|
37
|
+
parent.key = raw.includes('\\') ? JSON.parse(text.slice(index, end + 1)) : raw;
|
|
38
|
+
parent.keyLine = line;
|
|
39
|
+
parent.expectKey = false;
|
|
64
40
|
}
|
|
65
|
-
else
|
|
41
|
+
else
|
|
66
42
|
scalar();
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
return end + 1;
|
|
44
|
+
};
|
|
45
|
+
const open = (array) => {
|
|
46
|
+
const { path, line: start } = child();
|
|
47
|
+
stack.push({ path, line: start, array, index: 0, key: '', keyLine: line, expectKey: !array });
|
|
48
|
+
};
|
|
49
|
+
const close = () => {
|
|
50
|
+
const frame = stack.pop();
|
|
51
|
+
if (frame?.path !== undefined && wanted.has(frame.path))
|
|
52
|
+
spans.set(frame.path, { line: frame.line, endLine: line });
|
|
53
|
+
};
|
|
54
|
+
for (let index = 0; index < text.length; index++) {
|
|
55
|
+
const char = text[index];
|
|
56
|
+
switch (char) {
|
|
57
|
+
case '\n':
|
|
58
|
+
line++;
|
|
59
|
+
break;
|
|
60
|
+
case ' ':
|
|
61
|
+
case '\t':
|
|
62
|
+
case '\r':
|
|
63
|
+
case ':':
|
|
64
|
+
break;
|
|
65
|
+
case ',':
|
|
66
|
+
nextMember();
|
|
67
|
+
break;
|
|
68
|
+
case '"':
|
|
69
|
+
index = readString(index) - 1;
|
|
70
|
+
break;
|
|
71
|
+
case '{':
|
|
72
|
+
case '[':
|
|
73
|
+
open(char === '[');
|
|
74
|
+
break;
|
|
75
|
+
case '}':
|
|
76
|
+
case ']':
|
|
77
|
+
close();
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
scalar();
|
|
81
|
+
while (index + 1 < text.length && !/[\s,\]}]/.test(text[index + 1]))
|
|
82
|
+
index++;
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
return spans;
|
|
@@ -12,7 +12,7 @@ export function readComposerLock(text) {
|
|
|
12
12
|
if (!isRecord(entry) || typeof entry.name !== 'string' || !entry.name.trim())
|
|
13
13
|
return [];
|
|
14
14
|
const license = declaredLicense(entry.license);
|
|
15
|
-
return [{ at: pointer([section, index]), name: entry.name,
|
|
15
|
+
return [{ at: pointer([section, index]), name: entry.name, groups: [section],
|
|
16
16
|
...(typeof entry.version === 'string' ? { version: entry.version } : {}),
|
|
17
17
|
...(license === undefined ? {} : { license }) }];
|
|
18
18
|
}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isRecord } from '@repometry/core/internal/engine/plugin.js';
|
|
2
|
+
import { entries, text } from './sbom-model.js';
|
|
3
|
+
export function cyclone(value) {
|
|
4
|
+
if (value.bomFormat !== 'CycloneDX' || !['1.4', '1.5', '1.6'].some(version => version === value.specVersion)) {
|
|
5
|
+
throw new Error('Expected CycloneDX JSON version 1.4, 1.5 or 1.6');
|
|
6
|
+
}
|
|
7
|
+
const root = isRecord(value.metadata) && isRecord(value.metadata.component) ? value.metadata.component : undefined;
|
|
8
|
+
const rootId = text(root?.['bom-ref']);
|
|
9
|
+
const stack = [];
|
|
10
|
+
addComponents(stack, root?.components, ['metadata', 'component', 'components']);
|
|
11
|
+
addComponents(stack, value.components, ['components']);
|
|
12
|
+
const dependencies = [];
|
|
13
|
+
const seen = new Set(rootId === undefined ? [] : [rootId]);
|
|
14
|
+
while (stack.length) {
|
|
15
|
+
const { entry, at } = stack.pop();
|
|
16
|
+
if (!isRecord(entry))
|
|
17
|
+
throw new Error('A CycloneDX component must be an object');
|
|
18
|
+
addComponents(stack, entry.components, [...at, 'components']);
|
|
19
|
+
const component = readComponent(entry, at, seen);
|
|
20
|
+
if (component)
|
|
21
|
+
dependencies.push(component);
|
|
22
|
+
}
|
|
23
|
+
return dependencies;
|
|
24
|
+
}
|
|
25
|
+
function addComponents(stack, components, prefix) {
|
|
26
|
+
const array = entries(components, 'CycloneDX components');
|
|
27
|
+
for (let index = array.length - 1; index >= 0; index--)
|
|
28
|
+
stack.push({ entry: array[index], at: [...prefix, index] });
|
|
29
|
+
}
|
|
30
|
+
function readComponent(entry, at, seen) {
|
|
31
|
+
const name = text(entry.name);
|
|
32
|
+
if (name === undefined)
|
|
33
|
+
throw new Error('A CycloneDX component needs a name');
|
|
34
|
+
const id = text(entry['bom-ref']);
|
|
35
|
+
if (id !== undefined && seen.has(id))
|
|
36
|
+
return undefined;
|
|
37
|
+
if (id !== undefined)
|
|
38
|
+
seen.add(id);
|
|
39
|
+
const group = text(entry.group);
|
|
40
|
+
const version = text(entry.version);
|
|
41
|
+
const license = cycloneLicense(entry.licenses);
|
|
42
|
+
const scope = text(entry.scope);
|
|
43
|
+
return { at, name: group && !name.startsWith(group + '/') ? group + '/' + name : name,
|
|
44
|
+
...(version === undefined ? {} : { version }), ...(license === undefined ? {} : { license }), groups: scope === undefined ? [] : [scope] };
|
|
45
|
+
}
|
|
46
|
+
function cycloneLicense(value) {
|
|
47
|
+
const licenses = entries(value, 'CycloneDX licenses');
|
|
48
|
+
const declarations = new Set(licenses.flatMap(entry => {
|
|
49
|
+
if (!isRecord(entry))
|
|
50
|
+
return [];
|
|
51
|
+
if (isRecord(entry.license)) {
|
|
52
|
+
const license = entry.license;
|
|
53
|
+
const value = text(license.id) ?? text(license.name);
|
|
54
|
+
return license.acknowledgement !== 'concluded' && value !== undefined ? [value] : [];
|
|
55
|
+
}
|
|
56
|
+
const expression = text(entry.expression);
|
|
57
|
+
return entry.acknowledgement !== 'concluded' && expression !== undefined ? [expression] : [];
|
|
58
|
+
}));
|
|
59
|
+
return declarations.size ? [...declarations].join(', ') : undefined;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=cyclonedx.js.map
|