@repometry/cli 0.4.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 +8 -5
- package/package.json +3 -3
- 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 -9
- package/target/main/ts/cli/distribution.d.ts +8 -0
- package/target/main/ts/cli/distribution.js +23 -0
- package/target/main/ts/cli/imports.js +21 -17
- package/target/main/ts/cli/run.d.ts +2 -2
- package/target/main/ts/cli/run.js +7 -4
- 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 -37
- 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
|
@@ -7,5 +7,9 @@ export interface SecurityCounts {
|
|
|
7
7
|
readonly low: number;
|
|
8
8
|
readonly unknown: number;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The README badges, all always written. A category is measured when its input exists: coverage lines,
|
|
12
|
+
* a maintainability grade, scanner counts (zero findings grade A) and a Legal summary (checked dependencies).
|
|
13
|
+
* The repometry badge shows the lowest measured grade.
|
|
14
|
+
*/
|
|
11
15
|
export declare function badges(report: PublicHistoryEntry | undefined, quality: QualitySummary | undefined, security?: SecurityCounts): Map<string, Buffer>;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { coverageGrade, securityGrade } from '@repometry/core/internal/model/quality-summary.js';
|
|
1
|
+
import { coverageGrade, lowestGrade, securityGrade } from '@repometry/core/internal/model/quality-summary.js';
|
|
2
2
|
const colors = { A: '#5ec269', B: '#74a83a', C: '#d9a400', D: '#ec8a2c', F: '#db4a3f' };
|
|
3
3
|
const unavailable = '#6b7684';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The README badges, all always written. A category is measured when its input exists: coverage lines,
|
|
6
|
+
* a maintainability grade, scanner counts (zero findings grade A) and a Legal summary (checked dependencies).
|
|
7
|
+
* The repometry badge shows the lowest measured grade.
|
|
8
|
+
*/
|
|
5
9
|
export function badges(report, quality, security) {
|
|
6
10
|
const lines = report?.lineCoverage;
|
|
7
11
|
const ratio = lines && lines.total > 0 ? lines.covered / lines.total : null;
|
|
8
|
-
const
|
|
12
|
+
const maintainability = quality?.maintainability?.grade ?? null;
|
|
9
13
|
const coverage = lines && lines.total > 0 ? `${BigInt(lines.covered) * 100n / BigInt(lines.total)}%` : '—';
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const coverageLetter = ratio === null ? null : coverageGrade(ratio);
|
|
15
|
+
const securityLetter = security ? securityGrade(security) : null;
|
|
16
|
+
const legalLetter = quality?.legal?.grade ?? null;
|
|
17
|
+
const overall = lowestGrade([maintainability, coverageLetter, securityLetter, legalLetter]);
|
|
18
|
+
return new Map([
|
|
19
|
+
['coverage.svg', badge('coverage', coverage, coverageLetter)],
|
|
20
|
+
['legal.svg', badge('legal', legalLetter ?? '—', legalLetter)],
|
|
21
|
+
['maintainability.svg', badge('maintainability', maintainability ?? '—', maintainability)],
|
|
22
|
+
['repometry.svg', badge('repometry', overall ?? '—', overall)],
|
|
23
|
+
['security.svg', badge('security', securityLetter ?? '—', securityLetter)],
|
|
13
24
|
]);
|
|
14
|
-
if (security) {
|
|
15
|
-
const grade = securityGrade(security);
|
|
16
|
-
files.set('security.svg', badge('security', grade, grade));
|
|
17
|
-
}
|
|
18
|
-
return files;
|
|
19
25
|
}
|
|
20
26
|
function badge(name, value, grade) {
|
|
21
27
|
const fill = grade ? colors[grade] : unavailable;
|
|
@@ -8,6 +8,7 @@ import { packJson } from '../../json/wire/compact-json.js';
|
|
|
8
8
|
import { comparePaths, digest } from '@repometry/core/internal/model/snapshot.js';
|
|
9
9
|
import { pullReviewsSchema } from '../../json/wire/pull-review-model.js';
|
|
10
10
|
import { badges } from './badges.js';
|
|
11
|
+
import { versionAssets } from './asset-versions.js';
|
|
11
12
|
const appDirectory = new URL('../app/', import.meta.url);
|
|
12
13
|
const wireDirectory = new URL('../../json/wire/', import.meta.url);
|
|
13
14
|
const resourceDirectory = new URL('../../../../resources/viewer/', import.meta.url);
|
|
@@ -59,7 +60,7 @@ export async function siteFiles(reports, options = {}) {
|
|
|
59
60
|
files.set(name, Buffer.from(data));
|
|
60
61
|
}
|
|
61
62
|
files.set('summary.json', siteSummary(rows, options, row => details.get(row.sha)));
|
|
62
|
-
return files;
|
|
63
|
+
return versionAssets(files);
|
|
63
64
|
}
|
|
64
65
|
export function siteSummary(rows, { components, pulls = [], sources, branch }, inspectionPath) {
|
|
65
66
|
const ordered = orderSummaries(rows);
|
|
@@ -3,6 +3,7 @@ import { siteSummary, viewerAssets } from './export-site.js';
|
|
|
3
3
|
import { inspectionAsset } from '../../json/projections/inspection-details.js';
|
|
4
4
|
import { packJson } from '../../json/wire/compact-json.js';
|
|
5
5
|
import { commitSummary, orderSummaries, withCommitMetadata } from '../../json/projections/commit-summary.js';
|
|
6
|
+
import { versionAssets } from './asset-versions.js';
|
|
6
7
|
import { serveAssets } from './server.js';
|
|
7
8
|
import { sourceResponse } from './source-route.js';
|
|
8
9
|
export async function serveSite(reader, port, options = {}, source) {
|
|
@@ -14,6 +15,7 @@ export async function serveSite(reader, port, options = {}, source) {
|
|
|
14
15
|
files.set('index.html', Buffer.from(files.get('index.html').toString('utf8')
|
|
15
16
|
.replace('name="repometry-view" content="private"', 'name="repometry-view" content="local"')));
|
|
16
17
|
files.set('summary.json', siteSummary(rows, options, liveInspectionPath));
|
|
18
|
+
versionAssets(files);
|
|
17
19
|
async function read(sha) {
|
|
18
20
|
if (!validSubjectId('commit', sha))
|
|
19
21
|
return undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { lstat, mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { versionAssets } from './asset-versions.js';
|
|
4
5
|
import { readExportedSummary } from './exported-server.js';
|
|
5
6
|
const indexMarker = '<meta name="repometry-projects" content="1">';
|
|
6
7
|
const resources = '../../../../resources/viewer/';
|
|
@@ -11,12 +12,12 @@ export async function exportProjects(directory) {
|
|
|
11
12
|
.filter(entry => entry !== null);
|
|
12
13
|
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
13
14
|
const marker = await readOptional(join(directory, 'index.html'));
|
|
14
|
-
const files = new Map([
|
|
15
|
+
const files = versionAssets(new Map([
|
|
15
16
|
['styles.css', await readFile(new URL(resources + 'styles.css', import.meta.url))],
|
|
16
17
|
['projects.js', await readFile(new URL('../app/viewer-projects.js', import.meta.url))],
|
|
17
|
-
['projects.json', JSON.stringify({ schema: 'urn:repometry:schema:projects:1', projects: entries }) + '\n'],
|
|
18
|
+
['projects.json', Buffer.from(JSON.stringify({ schema: 'urn:repometry:schema:projects:1', projects: entries }) + '\n')],
|
|
18
19
|
['index.html', await readFile(new URL(resources + 'projects.html', import.meta.url))],
|
|
19
|
-
]);
|
|
20
|
+
]));
|
|
20
21
|
if (marker !== null && !marker.includes(indexMarker))
|
|
21
22
|
throw new Error('Directory already contains another site index');
|
|
22
23
|
for (const name of files.keys()) {
|
|
@@ -3,6 +3,7 @@ import { javascriptType, typescriptType } from '@repometry/core/internal/model/f
|
|
|
3
3
|
import { isRecord } from '@repometry/core/internal/model/plugin-data.js';
|
|
4
4
|
import { legacySyntaxPlugin } from './inspection-context.js';
|
|
5
5
|
import { canonicalMetricId, definitions } from '@repometry/core/internal/model/measurement.js';
|
|
6
|
+
import { licenseInputSummaries } from '@repometry/core/internal/model/license-evidence.js';
|
|
6
7
|
import { lcovLines } from '@repometry/core/internal/model/line-coverage.js';
|
|
7
8
|
import { comparePaths } from '@repometry/core/internal/model/snapshot.js';
|
|
8
9
|
import { fileMetrics } from './file-metrics.js';
|
|
@@ -21,6 +22,7 @@ export function inspectionDetails(report, { components = [], languages } = {}) {
|
|
|
21
22
|
});
|
|
22
23
|
const metrics = display === undefined ? files : { ...files, languages: display };
|
|
23
24
|
const lineCoverage = report.pluginData?.products[lcovLines.id]?.[0]?.value;
|
|
25
|
+
const licenseInputs = licenseInputSummaries(report.pluginData?.products);
|
|
24
26
|
const profile = profileSettings(report.appliedConfig);
|
|
25
27
|
const ruleCatalog = report.pluginData?.rules.flatMap(({ plugin, rules }) => rules.map(rule => ({
|
|
26
28
|
source: plugin, kind: 'check', rule: rule.id, category: rule.category,
|
|
@@ -29,6 +31,7 @@ export function inspectionDetails(report, { components = [], languages } = {}) {
|
|
|
29
31
|
...(rule.defaults?.cost === undefined ? {} : { minutesPerExcess: rule.defaults.cost }),
|
|
30
32
|
})));
|
|
31
33
|
return { metrics, functions: complexFunctions(report), diagnostics: report.diagnostics, findings: report.findings,
|
|
34
|
+
...(licenseInputs === undefined ? {} : { licenseInputs }),
|
|
32
35
|
components: components.length ? componentFiles(components, metrics) : undefined,
|
|
33
36
|
...(lcovLines.accepts(lineCoverage) ? { lineCoverage } : {}),
|
|
34
37
|
...(profile ? { profile: { ...profile, ...(ruleCatalog?.length ? { ruleCatalog } : {}) } } : {}) };
|
|
@@ -3,12 +3,14 @@ import type { FileMetricsReport } from './file-metrics-model.js';
|
|
|
3
3
|
import type { InspectionContext } from './inspection-context-model.js';
|
|
4
4
|
import type { ComplexFunction } from './public-history-model.js';
|
|
5
5
|
import type { ComponentMetrics } from './component-model.js';
|
|
6
|
+
import type { LicenseInputSummary } from '@repometry/core/internal/model/license-evidence.js';
|
|
6
7
|
import type { LineCoverage } from '@repometry/core/internal/model/line-coverage.js';
|
|
7
8
|
export interface InspectionDetails {
|
|
8
9
|
readonly metrics: FileMetricsReport;
|
|
9
10
|
readonly functions: readonly ComplexFunction[];
|
|
10
11
|
readonly diagnostics: Report['diagnostics'];
|
|
11
12
|
readonly findings?: Report['findings'];
|
|
13
|
+
readonly licenseInputs?: readonly LicenseInputSummary[];
|
|
12
14
|
readonly components?: readonly ComponentMetrics[];
|
|
13
15
|
readonly lineCoverage?: LineCoverage;
|
|
14
16
|
/**
|