@repometry/cli 0.3.0 → 0.4.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 +3 -0
- package/package.json +2 -2
- package/target/main/resources/licenses/spdx.json +746 -0
- package/target/main/resources/report/json/config-v2.schema.json +2 -1
- package/target/main/resources/report/json/file-metrics-v1.schema.json +2 -0
- package/target/main/resources/report/json/report-v2.schema.json +6 -3
- package/target/main/resources/report/json/repository-summary-v1.schema.json +14 -0
- package/target/main/resources/viewer/index.html +4 -0
- package/target/main/resources/viewer/styles.css +7 -2
- package/target/main/ts/api/git/git.d.ts +2 -1
- package/target/main/ts/api/git/git.js +4 -4
- package/target/main/ts/api/git/inspection-source.js +2 -2
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +5 -4
- package/target/main/ts/api/import/finding-import.js +2 -9
- package/target/main/ts/api/import/license-import.d.ts +2 -0
- package/target/main/ts/api/import/license-import.js +36 -0
- package/target/main/ts/api/import/repository-path.d.ts +1 -0
- package/target/main/ts/api/import/repository-path.js +10 -0
- package/target/main/ts/cli/imports.d.ts +2 -0
- package/target/main/ts/cli/imports.js +6 -2
- package/target/main/ts/cli/run.js +10 -4
- package/target/main/ts/compose/analysis-report.js +5 -2
- package/target/main/ts/compose/analysis-results.d.ts +3 -2
- package/target/main/ts/compose/analysis-results.js +15 -6
- package/target/main/ts/compose/analysis-steps.js +3 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +1 -1
- package/target/main/ts/compose/analyze-snapshot.js +7 -4
- 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/inspect.d.ts +2 -0
- package/target/main/ts/compose/inspect.js +7 -4
- package/target/main/ts/compose/load-plugins.js +4 -2
- package/target/main/ts/compose/phases.d.ts +7 -3
- package/target/main/ts/compose/phases.js +26 -10
- package/target/main/ts/plugins/built-in.d.ts +2 -0
- package/target/main/ts/plugins/built-in.js +4 -1
- package/target/main/ts/plugins/json-spans.d.ts +11 -0
- package/target/main/ts/plugins/json-spans.js +86 -0
- package/target/main/ts/plugins/legal/composer-lock.d.ts +2 -0
- package/target/main/ts/plugins/legal/composer-lock.js +24 -0
- package/target/main/ts/plugins/legal/dependencies.d.ts +73 -0
- package/target/main/ts/plugins/legal/dependencies.js +27 -0
- package/target/main/ts/plugins/legal/licenses.d.ts +19 -0
- package/target/main/ts/plugins/legal/licenses.js +112 -0
- package/target/main/ts/plugins/legal/npm-lock.d.ts +3 -0
- package/target/main/ts/plugins/legal/npm-lock.js +30 -0
- package/target/main/ts/plugins/legal/policy.d.ts +72 -0
- package/target/main/ts/plugins/legal/policy.js +149 -0
- package/target/main/ts/plugins/legal/sbom.d.ts +3 -0
- package/target/main/ts/plugins/legal/sbom.js +131 -0
- package/target/main/ts/plugins/legal/unverified-lock.d.ts +1 -0
- package/target/main/ts/plugins/legal/unverified-lock.js +21 -0
- package/target/main/ts/plugins/security/npm-supply-chain.js +2 -86
- package/target/main/ts/report/html/app/viewer-issue-group.js +1 -1
- package/target/main/ts/report/html/app/viewer-metric-registry.js +1 -1
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +2 -1
- package/target/main/ts/report/html/app/viewer-metrics.js +7 -2
- package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +1 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.js +20 -1
- package/target/main/ts/report/html/app/viewer-overview-lead.js +4 -1
- package/target/main/ts/report/html/app/viewer-shell.js +3 -1
- package/target/main/ts/report/html/app/viewer-tokenizer.js +35 -8
- package/target/main/ts/report/html/app/viewer-trend-data.js +1 -0
- package/target/main/ts/report/html/app/viewer.js +5 -2
- package/target/main/ts/report/json/validation/report.js +2 -2
|
@@ -7,7 +7,9 @@ import { renderSeries } from './viewer-trend-series.js';
|
|
|
7
7
|
export function firstArea({ reports, quality }) {
|
|
8
8
|
if (reports.some(report => quality[report.sha]?.maintainability?.debtRatio != null))
|
|
9
9
|
return 'debt';
|
|
10
|
-
|
|
10
|
+
if (reports.some(report => report.lineCoverage !== null))
|
|
11
|
+
return 'coverage';
|
|
12
|
+
return reports.some(report => quality[report.sha]?.legal !== undefined) ? 'legal' : 'complexity';
|
|
11
13
|
}
|
|
12
14
|
/** The Overview's quality tabs: one selected and focusable, the arrows moving between the visible ones. */
|
|
13
15
|
export function verdictTabs(select) {
|
|
@@ -2,11 +2,11 @@ import { element } from './viewer-dom.js';
|
|
|
2
2
|
import { languageIdOf, syntaxOf } from './viewer-languages.js';
|
|
3
3
|
const form = (kind, start, end, multiline = false, raw = false) => ({ kind, start, end, multiline, raw });
|
|
4
4
|
/** The syntax data in the shape the scanner reads: forms longest marker first, words as sets. */
|
|
5
|
-
function grammarOf({ lineComments = [], blockComments = [], strings = [], stringPrefixes = [], keywords, regexAfter }) {
|
|
5
|
+
function grammarOf({ lineComments = [], blockComments = [], strings = [], stringPrefixes = [], keywords, regexAfter, nestedBlockComments }) {
|
|
6
6
|
const forms = [
|
|
7
7
|
...lineComments.map(start => form('c', start, '', false, true)),
|
|
8
|
-
...blockComments.map(([start, end]) => form('c', start, end, true, true)),
|
|
9
|
-
...strings.map(({ quote, multiline, raw }) => form('s', quote,
|
|
8
|
+
...blockComments.map(([start, end]) => ({ ...form('c', start, end, true, true), nested: nestedBlockComments })),
|
|
9
|
+
...strings.map(({ quote, end = quote, multiline, raw, doubleEnd }) => ({ ...form('s', quote, end, multiline, raw), doubleEnd })),
|
|
10
10
|
];
|
|
11
11
|
return {
|
|
12
12
|
// Longest marker first; the sort is stable, so on equal length a comment, listed first, wins.
|
|
@@ -21,9 +21,17 @@ function closeAt(line, from, open) {
|
|
|
21
21
|
if (!open.end)
|
|
22
22
|
return [line.length, true];
|
|
23
23
|
let at = from;
|
|
24
|
-
while (at < line.length
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
while (at < line.length) {
|
|
25
|
+
if (line.startsWith(open.end, at)) {
|
|
26
|
+
const next = at + open.end.length;
|
|
27
|
+
if (!open.doubleEnd || !line.startsWith(open.end, next))
|
|
28
|
+
return [next, true];
|
|
29
|
+
at = next + open.end.length;
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
at += !open.raw && line[at] === '\\' ? 2 : 1;
|
|
33
|
+
}
|
|
34
|
+
return [line.length, false];
|
|
27
35
|
}
|
|
28
36
|
/** Takes the run up to `stop` as one token. */
|
|
29
37
|
function take(cursor, kind, stop) {
|
|
@@ -37,15 +45,34 @@ function close(state, closed) {
|
|
|
37
45
|
}
|
|
38
46
|
/** Inside a form that an earlier line or run left open: up to its end, or the whole line. */
|
|
39
47
|
function inside(cursor, open) {
|
|
40
|
-
const [stop, closed] = closeAt(cursor.line, cursor.at, open);
|
|
48
|
+
const [stop, closed] = open.nested ? closeNested(cursor, open) : closeAt(cursor.line, cursor.at, open);
|
|
41
49
|
take(cursor, open.kind, stop);
|
|
42
50
|
if (closed)
|
|
43
51
|
close(cursor.state, open);
|
|
44
52
|
}
|
|
53
|
+
/** Scans an active block-comment pair until its last outstanding opener closes. */
|
|
54
|
+
function closeNested({ line, at, state }, open) {
|
|
55
|
+
while (at < line.length) {
|
|
56
|
+
if (line.startsWith(open.end, at)) {
|
|
57
|
+
at += open.end.length;
|
|
58
|
+
if (--state.commentDepth === 0)
|
|
59
|
+
return [at, true];
|
|
60
|
+
}
|
|
61
|
+
else if (line.startsWith(open.start, at)) {
|
|
62
|
+
state.commentDepth++;
|
|
63
|
+
at += open.start.length;
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
at++;
|
|
67
|
+
}
|
|
68
|
+
return [line.length, false];
|
|
69
|
+
}
|
|
45
70
|
/** Opens a form after `prefix` characters: a multi-line one as its start marker, left open; another to its end. */
|
|
46
71
|
function begin(cursor, opened, prefix) {
|
|
47
72
|
const body = cursor.at + prefix + opened.start.length;
|
|
48
73
|
take(cursor, opened.kind, opened.multiline ? body : closeAt(cursor.line, body, opened)[0]);
|
|
74
|
+
if (opened.nested)
|
|
75
|
+
cursor.state.commentDepth = 1;
|
|
49
76
|
if (opened.multiline)
|
|
50
77
|
cursor.state.open = opened;
|
|
51
78
|
else
|
|
@@ -177,7 +204,7 @@ function scanLine(cursor) {
|
|
|
177
204
|
}
|
|
178
205
|
}
|
|
179
206
|
function scanLines(grammar, scan) {
|
|
180
|
-
const state = { open: undefined, regexAllowed: true };
|
|
207
|
+
const state = { open: undefined, commentDepth: 0, regexAllowed: true };
|
|
181
208
|
return line => {
|
|
182
209
|
const collected = runs();
|
|
183
210
|
scan({ line, grammar, at: 0, state, push: collected.push });
|
|
@@ -16,6 +16,7 @@ const builtinGroups = [
|
|
|
16
16
|
// Branch and function coverage come from the registry, where the coverage report has them.
|
|
17
17
|
['Coverage', ['coverage', 'branch-coverage', 'function-coverage', 'diff-coverage']],
|
|
18
18
|
['Security', ['security']],
|
|
19
|
+
['Legal', ['legal']],
|
|
19
20
|
['Size', ['code-lines', 'files', 'functions', 'classes', 'comments']],
|
|
20
21
|
];
|
|
21
22
|
/** A view the registry names, not one the viewer draws by hand. */
|
|
@@ -73,11 +73,12 @@ function start(data) {
|
|
|
73
73
|
}, branch);
|
|
74
74
|
const markVerdict = verdictTabs(metric => {
|
|
75
75
|
chartMetric = metric;
|
|
76
|
+
byId('overview-hotspots').hidden = chartMetric === 'legal';
|
|
76
77
|
const { sha } = route();
|
|
77
78
|
renderTrend(trendData(), bySha.get(sha), chartMetric, compact.matches);
|
|
78
79
|
renderLead(reports, bySha.get(sha), history, chartMetric, cached.get(sha));
|
|
79
80
|
const details = cached.get(sha);
|
|
80
|
-
if (details)
|
|
81
|
+
if (details && chartMetric !== 'legal')
|
|
81
82
|
renderOverviewHotspots(details, sha, chartMetric, context[sha]?.security !== undefined);
|
|
82
83
|
});
|
|
83
84
|
markVerdict(chartMetric);
|
|
@@ -169,7 +170,8 @@ function start(data) {
|
|
|
169
170
|
}
|
|
170
171
|
// The details name the most complex function, so its figure can now lead to its line.
|
|
171
172
|
renderLead(reports, report, history, chartMetric, details);
|
|
172
|
-
|
|
173
|
+
if (chartMetric !== 'legal')
|
|
174
|
+
renderOverviewHotspots(details, report.sha, chartMetric, context[report.sha]?.security !== undefined);
|
|
173
175
|
};
|
|
174
176
|
const existing = cached.get(report.sha);
|
|
175
177
|
if (existing) {
|
|
@@ -199,6 +201,7 @@ function start(data) {
|
|
|
199
201
|
showPage(current);
|
|
200
202
|
renderInspection(report);
|
|
201
203
|
renderQuality(report, quality[report.sha]);
|
|
204
|
+
byId('overview-hotspots').hidden = chartMetric === 'legal';
|
|
202
205
|
if (page === 'overview')
|
|
203
206
|
renderLead(reports, report, history, chartMetric, cached.get(report.sha));
|
|
204
207
|
renderScannerContext(context?.[current.sha], report.sha);
|
|
@@ -59,8 +59,8 @@ export function readReport(value) {
|
|
|
59
59
|
if (value.findings?.some(finding => !isFinding(finding)))
|
|
60
60
|
throw new Error('Invalid report: inconsistent finding location');
|
|
61
61
|
const ignore = value.appliedConfig.findingIgnore;
|
|
62
|
-
if (value.ignoredFindings?.some(({ finding, matchedRule }) => !isFinding(finding)
|
|
63
|
-
|| !Array.isArray(ignore) || matchedRule >= ignore.length))
|
|
62
|
+
if (value.ignoredFindings?.some(({ finding, matchedRule, reason }) => !isFinding(finding)
|
|
63
|
+
|| (matchedRule === undefined ? !reason?.trim() : !Array.isArray(ignore) || matchedRule >= ignore.length)))
|
|
64
64
|
throw new Error('Invalid report: inconsistent ignored finding');
|
|
65
65
|
for (const item of value.measurements) {
|
|
66
66
|
if (!Object.hasOwn(value.definitions, item.definition))
|