repometry 0.1.0 → 0.2.1
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 -2
- package/package.json +5 -4
- package/target/main/resources/report/json/config-v1.schema.json +0 -1
- package/target/main/resources/report/json/report-v2.schema.json +14 -0
- package/target/main/resources/viewer/index.html +10 -20
- package/target/main/resources/viewer/styles.css +3 -29
- package/target/main/ts/api/gh/github.js +1 -0
- package/target/main/ts/api/git/blob-batch.js +1 -0
- package/target/main/ts/api/git/changes.js +1 -0
- package/target/main/ts/api/git/commit-metadata.js +5 -6
- package/target/main/ts/api/git/git-churn.js +1 -0
- package/target/main/ts/api/git/git-reader.js +1 -0
- package/target/main/ts/api/git/git.js +1 -0
- package/target/main/ts/api/git/inspection-source.js +1 -0
- package/target/main/ts/api/git/local-sources.js +1 -0
- package/target/main/ts/api/git/local.js +1 -0
- package/target/main/ts/api/git/metabranch-worktree.js +1 -0
- package/target/main/ts/api/git/source-cache.js +1 -0
- package/target/main/ts/api/import/finding-import.js +1 -0
- package/target/main/ts/api/import/lcov-files.js +1 -0
- package/target/main/ts/api/import/profile-file.js +1 -0
- package/target/main/ts/api/worker/remote-executor.js +1 -0
- package/target/main/ts/api/worker/worker-protocol.js +1 -0
- package/target/main/ts/api/worker/worker.js +1 -0
- package/target/main/ts/cli/arguments.js +1 -0
- package/target/main/ts/cli/config.d.ts +0 -1
- package/target/main/ts/cli/config.js +3 -5
- package/target/main/ts/cli/imports.js +1 -0
- package/target/main/ts/cli/main.js +3 -2
- package/target/main/ts/cli/reporting.js +9 -13
- package/target/main/ts/cli/revisions.js +1 -0
- package/target/main/ts/cli/store.js +1 -0
- package/target/main/ts/compose/analyze-snapshot.js +1 -0
- package/target/main/ts/compose/attach-churn.js +13 -0
- package/target/main/ts/compose/diff-coverage.js +1 -0
- package/target/main/ts/compose/inspect.js +1 -0
- package/target/main/ts/compose/plugin-list.js +1 -0
- package/target/main/ts/compose/prepare-metabranch.js +1 -0
- package/target/main/ts/compose/review.js +1 -0
- package/target/main/ts/compose/sources.js +1 -0
- package/target/main/ts/core/engine/execute.js +1 -0
- package/target/main/ts/core/engine/manifest.js +1 -0
- package/target/main/ts/core/engine/plan.js +1 -0
- package/target/main/ts/core/engine/report-products.js +1 -0
- package/target/main/ts/core/model/changes.js +1 -0
- package/target/main/ts/core/model/clone-source.js +1 -0
- package/target/main/ts/core/model/code-structure.js +1 -0
- package/target/main/ts/core/model/finding-ignore.js +1 -0
- package/target/main/ts/core/model/measurement.d.ts +6 -0
- package/target/main/ts/core/model/measurement.js +6 -0
- package/target/main/ts/core/model/report.d.ts +8 -0
- package/target/main/ts/core/model/scanner-import.js +1 -0
- package/target/main/ts/core/model/snapshot.js +1 -0
- package/target/main/ts/core/ports/report.js +1 -0
- package/target/main/ts/core/ports/source-provider.js +1 -0
- package/target/main/ts/core/profile/exclusions.js +1 -0
- package/target/main/ts/core/profile/maintainability.js +1 -0
- package/target/main/ts/core/profile/profile.js +1 -0
- package/target/main/ts/core/usecases/compare.js +1 -0
- package/target/main/ts/core/usecases/diff-coverage-policy.js +1 -0
- package/target/main/ts/core/usecases/diff-coverage.js +1 -0
- package/target/main/ts/core/usecases/inspect.js +1 -0
- package/target/main/ts/core/usecases/review.js +1 -0
- package/target/main/ts/index.js +1 -0
- package/target/main/ts/plugin.js +1 -0
- package/target/main/ts/plugins/coverage/coverage.d.ts +2 -0
- package/target/main/ts/plugins/coverage/coverage.js +83 -4
- package/target/main/ts/plugins/coverage/diff-coverage.js +1 -0
- package/target/main/ts/plugins/duplication/duplication.js +1 -0
- package/target/main/ts/plugins/language-js/babel-provider.js +1 -0
- package/target/main/ts/plugins/language-js/clone-candidates.js +1 -0
- package/target/main/ts/plugins/language-js/code-lines.js +1 -0
- package/target/main/ts/plugins/language-js/function-facts.js +1 -0
- package/target/main/ts/plugins/language-js/structural-observations.js +1 -0
- package/target/main/ts/plugins/maintainability/maintainability.js +1 -0
- package/target/main/ts/plugins/maintainability/structural-smells.js +1 -0
- package/target/main/ts/plugins/source/forges.js +1 -0
- package/target/main/ts/plugins/structure/structure.js +1 -0
- package/target/main/ts/report/html/app/viewer-chart.js +5 -5
- package/target/main/ts/report/html/app/viewer-commits.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-commits.js +1 -1
- package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-data.js +4 -4
- package/target/main/ts/report/html/app/viewer-files.js +25 -8
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +3 -1
- package/target/main/ts/report/html/app/viewer-metric-registry.js +24 -6
- package/target/main/ts/report/html/app/viewer-profile.js +3 -3
- package/target/main/ts/report/html/app/viewer-trends.d.ts +0 -1
- package/target/main/ts/report/html/app/viewer-trends.js +16 -6
- package/target/main/ts/report/html/app/viewer.js +48 -107
- package/target/main/ts/report/html/site/badges.js +1 -0
- package/target/main/ts/report/html/site/export-site.d.ts +2 -1
- package/target/main/ts/report/html/site/export-site.js +17 -24
- package/target/main/ts/report/html/site/exported-server.js +1 -0
- package/target/main/ts/report/html/site/local-server.js +1 -0
- package/target/main/ts/report/html/site/projects.js +1 -0
- package/target/main/ts/report/html/site/server.js +1 -0
- package/target/main/ts/report/html/site/source-route.js +1 -0
- package/target/main/ts/report/json/projections/commit-summary.d.ts +1 -0
- package/target/main/ts/report/json/projections/commit-summary.js +7 -1
- package/target/main/ts/report/json/projections/components.js +1 -0
- package/target/main/ts/report/json/projections/file-metrics.js +1 -0
- package/target/main/ts/report/json/projections/inspection-context.js +1 -0
- package/target/main/ts/report/json/projections/inspection-details.js +1 -0
- package/target/main/ts/report/json/projections/metric-values.js +1 -0
- package/target/main/ts/report/json/projections/public-history.js +1 -0
- package/target/main/ts/report/json/store/components.js +1 -0
- package/target/main/ts/report/json/store/local-store.js +1 -0
- package/target/main/ts/report/json/store/pull-review-store.js +1 -0
- package/target/main/ts/report/json/validation/metabranch.js +1 -0
- package/target/main/ts/report/json/validation/report.js +1 -0
- package/target/main/ts/report/json/validation/summary-validation.js +1 -0
- package/target/main/ts/report.js +1 -0
- package/target/main/ts/api/gh/github-pr-comment.d.ts +0 -4
- package/target/main/ts/api/gh/github-pr-comment.js +0 -107
- package/target/main/ts/cli/github-pr-comment.d.ts +0 -1
- package/target/main/ts/cli/github-pr-comment.js +0 -12
- package/target/main/ts/report/html/app/viewer-access.d.ts +0 -19
- package/target/main/ts/report/html/app/viewer-access.js +0 -25
|
@@ -9,7 +9,6 @@ export interface TrendData {
|
|
|
9
9
|
readonly reports: readonly PublicHistoryEntry[];
|
|
10
10
|
readonly quality: Record<string, QualitySummary>;
|
|
11
11
|
readonly context: Record<string, InspectionContext> | null;
|
|
12
|
-
readonly detailed: boolean;
|
|
13
12
|
readonly compact: boolean;
|
|
14
13
|
/** Link to the Trends page for a commit, keeping or replacing the view and period. */
|
|
15
14
|
readonly link: (sha: string, view?: TrendView, period?: Period) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderBarChart, renderLineChart } from './viewer-chart.js';
|
|
2
2
|
import { splitter } from './viewer-files.js';
|
|
3
|
-
import { betterOf, definitionOf, difference, formatMetric, isMetric, isPercent, labelOf, metricValue, pluginMetrics, pluginSpec } from './viewer-metrics.js';
|
|
3
|
+
import { betterOf, definitionOf, difference, formatMetric, isMetric, isPercent, labelOf, metricLabels, metricValue, pluginMetrics, pluginSpec } from './viewer-metrics.js';
|
|
4
4
|
const statusLabels = { complete: 'Complete', partial: 'Partial', 'not-applicable': 'Not applicable' };
|
|
5
5
|
const dateTime = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' });
|
|
6
6
|
const pageRows = 50;
|
|
@@ -13,19 +13,29 @@ function viewLabel(view) {
|
|
|
13
13
|
}
|
|
14
14
|
const builtinGroups = [
|
|
15
15
|
['Maintainability', ['debt', 'debt-changes', 'duplication', 'cognitive', 'complexity', 'smells']],
|
|
16
|
-
|
|
16
|
+
// Branch and function coverage come from the registry, where the coverage report has them.
|
|
17
|
+
['Coverage', ['coverage', 'branch-coverage', 'function-coverage', 'diff-coverage']],
|
|
17
18
|
['Security', ['security']],
|
|
18
19
|
['Size', ['code-lines', 'files', 'functions', 'classes', 'comments']],
|
|
19
20
|
];
|
|
20
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* The series list: Repometry's own groups, with other plugins' metrics joining a group they name or one of their own.
|
|
23
|
+
* A registry metric the groups already place keeps its place, and is left out where this history has no such metric.
|
|
24
|
+
*/
|
|
21
25
|
function groups() {
|
|
22
|
-
const
|
|
26
|
+
const placed = new Set(builtinGroups.flatMap(([, views]) => views));
|
|
27
|
+
const keys = new Set(pluginMetrics().filter(spec => spec.trend).map(spec => spec.key));
|
|
28
|
+
const merged = new Map(builtinGroups.map(([group, views]) => [group, views.filter(view => !pluginKey(view) || keys.has(view))]));
|
|
23
29
|
for (const spec of pluginMetrics()) {
|
|
24
|
-
if (spec.trend)
|
|
30
|
+
if (spec.trend && !placed.has(spec.key))
|
|
25
31
|
merged.set(spec.group, [...merged.get(spec.group) ?? [], spec.key]);
|
|
26
32
|
}
|
|
27
33
|
return [...merged];
|
|
28
34
|
}
|
|
35
|
+
/** A view the registry names, not one the viewer draws by hand. */
|
|
36
|
+
function pluginKey(view) {
|
|
37
|
+
return view !== 'debt-changes' && view !== 'diff-coverage' && !(view in metricLabels);
|
|
38
|
+
}
|
|
29
39
|
export function isTrendView(value) {
|
|
30
40
|
return value === 'debt-changes' || value === 'diff-coverage' || (isMetric(value) && groups().some(([, views]) => views.includes(value)));
|
|
31
41
|
}
|
|
@@ -35,7 +45,7 @@ export function isPeriod(value) {
|
|
|
35
45
|
/** Views that have data in this history, in display order. */
|
|
36
46
|
export function availableViews(data) {
|
|
37
47
|
const has = (metric) => data.reports.some(report => value(data, report, metric) !== null);
|
|
38
|
-
return groups().flatMap(([, views]) => views).filter(view => view === 'diff-coverage'
|
|
48
|
+
return groups().flatMap(([, views]) => views).filter(view => view === 'diff-coverage' || (view === 'debt-changes' ? has('effort') : has(view)));
|
|
39
49
|
}
|
|
40
50
|
/** The whole curve by default; only a very long history opens on its last hundred inspections. */
|
|
41
51
|
export function defaultPeriod(total) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { loadViewerData, ViewerSummaryChanged } from './viewer-data.js';
|
|
2
2
|
import { band, bandLimits, codeSmellCategories, renderFileView, mapStub, renderSunburst, securityCategories } from './viewer-files.js';
|
|
3
|
-
import { count, difference, formatMetric, labelOf, metricValue, securityGrades, securityRisks, useCatalog } from './viewer-metrics.js';
|
|
3
|
+
import { count, difference, formatMetric, labelOf, metricValue, pluginSpec, securityGrades, securityRisks, useCatalog } from './viewer-metrics.js';
|
|
4
4
|
import { charted, commitTime, isPeriod, stableWindow, isTrendView, renderSeries, renderTrendsPage, seriesPoints, trendLegend } from './viewer-trends.js';
|
|
5
5
|
import { createCommitPicker } from './viewer-commits.js';
|
|
6
6
|
import { renderProfile } from './viewer-profile.js';
|
|
7
7
|
import { loadSource, sourcePage, useSources } from './viewer-source.js';
|
|
8
8
|
import { renderDiffCoverageTrend, renderPulls } from './viewer-pulls.js';
|
|
9
|
-
import { isDetailed, pageAccess, publicNotice, unavailableTabs } from './viewer-access.js';
|
|
10
9
|
const percent = new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 });
|
|
11
10
|
const dateTime = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' });
|
|
12
11
|
/**
|
|
@@ -19,9 +18,10 @@ const areas = {
|
|
|
19
18
|
security: { figures: ['security', 'security-high', 'security-medium', 'security-low'] },
|
|
20
19
|
complexity: { figures: ['complexity', 'functions', 'cognitive', 'code-lines'] },
|
|
21
20
|
};
|
|
21
|
+
/** Coverage kinds beyond lines, by their registry keys, in the words the Overview card uses for them. */
|
|
22
|
+
const coverageKinds = [['branch-coverage', 'Branches'], ['function-coverage', 'Functions']];
|
|
22
23
|
const pages = ['overview', 'metrics', 'hotspots', 'trends', 'issues', 'diagnostics', 'settings', 'pulls'];
|
|
23
24
|
const mode = document.querySelector('meta[name="repometry-view"]')?.content;
|
|
24
|
-
const detailed = isDetailed(mode);
|
|
25
25
|
const title = document.querySelector('meta[name="repometry-project"]')?.content.trim();
|
|
26
26
|
if (title) {
|
|
27
27
|
document.title = `${title} · Repometry`;
|
|
@@ -111,26 +111,8 @@ function start({ reports, quality, context, counts, pullReviewCount, branch, met
|
|
|
111
111
|
selectVerdict();
|
|
112
112
|
element('inspection-meta').hidden = false;
|
|
113
113
|
commit.hidden = false;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
item.hidden = false;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// A public report keeps the sections of the full one in view: picking one says how to see it.
|
|
120
|
-
for (const page of unavailableTabs) {
|
|
121
|
-
const tab = document.querySelector(`#navigation a[data-page="${page}"]`);
|
|
122
|
-
if (!tab)
|
|
123
|
-
continue;
|
|
124
|
-
tab.hidden = false;
|
|
125
|
-
tab.dataset.unavailable = '';
|
|
126
|
-
const note = document.createElement('span');
|
|
127
|
-
note.className = 'visually-hidden';
|
|
128
|
-
note.textContent = ', not in the public report';
|
|
129
|
-
tab.append(note);
|
|
130
|
-
}
|
|
131
|
-
fillPanel(element('overview-public-content'));
|
|
132
|
-
element('overview-public').hidden = false;
|
|
133
|
-
}
|
|
114
|
+
for (const item of document.querySelectorAll('[data-loaded]'))
|
|
115
|
+
item.hidden = false;
|
|
134
116
|
function route() {
|
|
135
117
|
const [rawPage = '', query = ''] = location.hash.slice(1).split('?', 2);
|
|
136
118
|
if (bySha.has(rawPage))
|
|
@@ -164,20 +146,17 @@ function start({ reports, quality, context, counts, pullReviewCount, branch, met
|
|
|
164
146
|
const version = ++revision;
|
|
165
147
|
const report = bySha.get(current.sha);
|
|
166
148
|
const inspection = context?.[current.sha];
|
|
167
|
-
const
|
|
168
|
-
const previousPage = [...pages, 'unavailable'].find(page => !element(page).hidden);
|
|
149
|
+
const previousPage = pages.find(page => !element(page).hidden);
|
|
169
150
|
const focusWasInPage = previousPage && element(previousPage).contains(document.activeElement);
|
|
170
151
|
commit.set(report.sha);
|
|
171
152
|
commit.hidden = current.page === 'pulls';
|
|
172
153
|
element('inspection-meta').hidden = current.page === 'pulls';
|
|
173
154
|
for (const page of pages)
|
|
174
|
-
element(page).hidden =
|
|
175
|
-
|
|
176
|
-
const shown = locked ? 'unavailable' : current.page;
|
|
177
|
-
if (previousPage && previousPage !== shown) {
|
|
155
|
+
element(page).hidden = page !== current.page;
|
|
156
|
+
if (previousPage && previousPage !== current.page) {
|
|
178
157
|
window.scrollTo({ top: 0 });
|
|
179
158
|
if (focusWasInPage) {
|
|
180
|
-
const section = element(
|
|
159
|
+
const section = element(current.page);
|
|
181
160
|
section.tabIndex = -1;
|
|
182
161
|
section.focus({ preventScroll: true });
|
|
183
162
|
}
|
|
@@ -193,39 +172,31 @@ function start({ reports, quality, context, counts, pullReviewCount, branch, met
|
|
|
193
172
|
document.querySelector('.brand').href = href({ page: 'overview', sha: current.sha });
|
|
194
173
|
renderInspection(report);
|
|
195
174
|
renderQuality(report, quality[report.sha]);
|
|
196
|
-
if (locked) {
|
|
197
|
-
const tab = document.querySelector(`#navigation a[data-page="${current.page}"]`);
|
|
198
|
-
element('unavailable-title').textContent = tab?.firstChild?.textContent ?? 'Not in this report';
|
|
199
|
-
fillNotice(element('unavailable-content'));
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
175
|
if (current.page === 'overview')
|
|
203
176
|
renderLead(reports, report, quality, context, chartMetric, cached.get(report.sha));
|
|
204
177
|
renderScannerContext(inspection, report.sha);
|
|
205
178
|
const needsDetail = isFilePage(current.page) || ['overview', 'settings'].includes(current.page) || !counts;
|
|
206
|
-
const detail =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
showTab('pulls', Boolean(records?.length) || current.page === 'pulls');
|
|
220
|
-
});
|
|
221
|
-
void detail?.then(asset => {
|
|
222
|
-
if (!asset || version !== revision)
|
|
223
|
-
return;
|
|
224
|
-
updateDetailsTabs(current.page, asset.inspection);
|
|
225
|
-
const latest = context[report.sha];
|
|
226
|
-
renderScannerContext(latest, report.sha);
|
|
179
|
+
const detail = needsDetail ? selectedDetails(report.sha) : undefined;
|
|
180
|
+
const row = counts?.[report.sha];
|
|
181
|
+
const cachedDetail = cached.get(report.sha);
|
|
182
|
+
if (row)
|
|
183
|
+
updateTabs(current.page, row.findingCount, row.diagnosticCount, row.componentCount);
|
|
184
|
+
else if (cachedDetail)
|
|
185
|
+
updateDetailsTabs(current.page, cachedDetail);
|
|
186
|
+
if (pullReviewCount !== undefined)
|
|
187
|
+
showTab('pulls', pullReviewCount > 0 || current.page === 'pulls');
|
|
188
|
+
else
|
|
189
|
+
void loadPulls().then(records => {
|
|
190
|
+
if (version === revision)
|
|
191
|
+
showTab('pulls', Boolean(records?.length) || current.page === 'pulls');
|
|
227
192
|
});
|
|
228
|
-
|
|
193
|
+
void detail?.then(asset => {
|
|
194
|
+
if (!asset || version !== revision)
|
|
195
|
+
return;
|
|
196
|
+
updateDetailsTabs(current.page, asset.inspection);
|
|
197
|
+
const latest = context[report.sha];
|
|
198
|
+
renderScannerContext(latest, report.sha);
|
|
199
|
+
});
|
|
229
200
|
if (current.page === 'overview')
|
|
230
201
|
renderTrend(trendData(), report, chartMetric, compact.matches);
|
|
231
202
|
if (current.page === 'trends') {
|
|
@@ -264,14 +235,14 @@ function start({ reports, quality, context, counts, pullReviewCount, branch, met
|
|
|
264
235
|
latest: { report: newest, quality: quality[newest.sha], context: context[newest.sha] },
|
|
265
236
|
});
|
|
266
237
|
draw(cached.get(report.sha));
|
|
267
|
-
if (
|
|
238
|
+
if (!cached.has(report.sha))
|
|
268
239
|
void detail?.then(asset => {
|
|
269
240
|
if (asset && version === revision)
|
|
270
241
|
draw(asset.inspection);
|
|
271
242
|
});
|
|
272
243
|
return;
|
|
273
244
|
}
|
|
274
|
-
if (!
|
|
245
|
+
if (!isFilePage(page) && page !== 'overview')
|
|
275
246
|
return;
|
|
276
247
|
const target = element(page === 'overview' ? 'overview-hotspot-list' : `${page}-content`);
|
|
277
248
|
function display(details) {
|
|
@@ -330,7 +301,7 @@ function start({ reports, quality, context, counts, pullReviewCount, branch, met
|
|
|
330
301
|
}
|
|
331
302
|
function trendData() {
|
|
332
303
|
return {
|
|
333
|
-
reports, quality, context,
|
|
304
|
+
reports, quality, context, compact: compact.matches,
|
|
334
305
|
link: (sha, view, period) => href({ page: 'trends', sha, view, period }),
|
|
335
306
|
};
|
|
336
307
|
}
|
|
@@ -367,12 +338,9 @@ function href({ page, sha, directory, file, view, period, query, group, line, ca
|
|
|
367
338
|
function isFilePage(page) {
|
|
368
339
|
return page === 'metrics' || page === 'hotspots' || page === 'issues' || page === 'diagnostics';
|
|
369
340
|
}
|
|
370
|
-
/**
|
|
371
|
-
* A detail that counts something leads to exactly what it counts, where the report has a page for it: a link in the
|
|
372
|
-
* local and private views, plain text in the public one.
|
|
373
|
-
*/
|
|
341
|
+
/** A detail that counts something leads to exactly what it counts, where the report has a page for it. */
|
|
374
342
|
function detailText(id, text, link) {
|
|
375
|
-
if (
|
|
343
|
+
if (link === undefined) {
|
|
376
344
|
element(id).textContent = text;
|
|
377
345
|
return;
|
|
378
346
|
}
|
|
@@ -398,6 +366,19 @@ function renderInspection(report) {
|
|
|
398
366
|
else
|
|
399
367
|
detailText('coverage-detail', `${coverageText(report.lineCoverage)} of ${count(report.lineCoverage.total)} lines`, coverage < 1 ? uncoveredLink(report.sha) : undefined);
|
|
400
368
|
element('coverage-mark').replaceChildren(ring(coverage));
|
|
369
|
+
// Line coverage leads; the other kinds the coverage report carries follow on a quieter line.
|
|
370
|
+
const kinds = coverageKinds.flatMap(([key, name]) => {
|
|
371
|
+
const metric = key;
|
|
372
|
+
const value = pluginSpec(metric) ? metricValue(report, metric, undefined) : null;
|
|
373
|
+
if (value === null)
|
|
374
|
+
return [];
|
|
375
|
+
// Each kind keeps its number; a narrow card wraps between kinds, never inside one.
|
|
376
|
+
const kind = document.createElement('span');
|
|
377
|
+
kind.textContent = `${name} ${formatMetric(value, metric)}`;
|
|
378
|
+
return [kind];
|
|
379
|
+
});
|
|
380
|
+
element('coverage-kinds').replaceChildren(...kinds.flatMap((kind, index) => index ? [' · ', kind] : [kind]));
|
|
381
|
+
element('coverage-kinds').hidden = kinds.length === 0;
|
|
401
382
|
}
|
|
402
383
|
function renderQuality(report, quality) {
|
|
403
384
|
const maintainability = quality?.maintainability ?? null;
|
|
@@ -447,7 +428,7 @@ function renderLead(reports, selected, quality, context, area, details) {
|
|
|
447
428
|
const destination = value === null || value <= 0 ? undefined : figureLink(metric, value, selected.sha, details);
|
|
448
429
|
if (value === null)
|
|
449
430
|
shown.textContent = '—';
|
|
450
|
-
else if (!
|
|
431
|
+
else if (!destination)
|
|
451
432
|
shown.textContent = formatMetric(value, metric);
|
|
452
433
|
else {
|
|
453
434
|
const anchor = document.createElement('a');
|
|
@@ -731,46 +712,6 @@ function overviewStub(sha) {
|
|
|
731
712
|
}
|
|
732
713
|
output.replaceChildren(list);
|
|
733
714
|
}
|
|
734
|
-
/** The public report notice in a page's place: what this report holds and the command that shows all of it. */
|
|
735
|
-
function fillNotice(container) {
|
|
736
|
-
const text = document.createElement('p');
|
|
737
|
-
text.className = 'report-notice-text';
|
|
738
|
-
const lead = document.createElement('strong');
|
|
739
|
-
lead.textContent = publicNotice.lead;
|
|
740
|
-
text.append(lead, ` ${publicNotice.text} `, commandChip(), ` ${publicNotice.tail}`);
|
|
741
|
-
container.replaceChildren(text);
|
|
742
|
-
}
|
|
743
|
-
/** The same notice in the Overview's side panel, where the hotspots sit in a detailed report. */
|
|
744
|
-
function fillPanel(container) {
|
|
745
|
-
const text = document.createElement('p');
|
|
746
|
-
text.textContent = publicNotice.panel;
|
|
747
|
-
const command = commandChip();
|
|
748
|
-
command.classList.add('public-panel-command');
|
|
749
|
-
container.replaceChildren(text, command);
|
|
750
|
-
}
|
|
751
|
-
/** The command as code, copied with one click; where the browser refuses the clipboard, it is selected instead. */
|
|
752
|
-
function commandChip() {
|
|
753
|
-
const code = document.createElement('code');
|
|
754
|
-
code.textContent = publicNotice.command;
|
|
755
|
-
if (!navigator.clipboard)
|
|
756
|
-
return code;
|
|
757
|
-
const copy = document.createElement('button');
|
|
758
|
-
copy.type = 'button';
|
|
759
|
-
copy.className = 'report-notice-command';
|
|
760
|
-
copy.title = 'Copy the command';
|
|
761
|
-
const status = document.createElement('span');
|
|
762
|
-
status.className = 'visually-hidden';
|
|
763
|
-
status.setAttribute('role', 'status');
|
|
764
|
-
copy.append(code, status);
|
|
765
|
-
copy.addEventListener('click', () => {
|
|
766
|
-
void navigator.clipboard.writeText(publicNotice.command).then(() => {
|
|
767
|
-
copy.dataset.copied = '';
|
|
768
|
-
status.textContent = 'Copied';
|
|
769
|
-
setTimeout(() => { delete copy.dataset.copied; status.textContent = ''; }, 1600);
|
|
770
|
-
}, () => window.getSelection()?.selectAllChildren(code));
|
|
771
|
-
});
|
|
772
|
-
return copy;
|
|
773
|
-
}
|
|
774
715
|
function notice(container, text) {
|
|
775
716
|
const paragraph = document.createElement('p');
|
|
776
717
|
paragraph.className = 'detail empty';
|
|
@@ -5,7 +5,8 @@ import type { PullReview } from '../../json/wire/pull-review-model.js';
|
|
|
5
5
|
import type { Component } from '../../json/projections/components.js';
|
|
6
6
|
export interface SiteOptions {
|
|
7
7
|
readonly title?: string;
|
|
8
|
-
|
|
8
|
+
/** `local` for `repometry view`, which serves details live; an export writes them as files. */
|
|
9
|
+
readonly mode?: 'local' | 'private';
|
|
9
10
|
readonly components?: readonly Component[];
|
|
10
11
|
readonly pulls?: readonly PullReview[];
|
|
11
12
|
readonly sources?: SourceLocator;
|
|
@@ -33,7 +33,7 @@ async function listAssets(directory, include) {
|
|
|
33
33
|
export function withoutFooter(html) {
|
|
34
34
|
return html.replace(/\n[ \t]*<footer class="site-footer">[\s\S]*?<\/footer>/, '');
|
|
35
35
|
}
|
|
36
|
-
export async function siteFiles(reports, { title = '', mode = '
|
|
36
|
+
export async function siteFiles(reports, { title = '', mode = 'private', components, pulls = [], sources, branch, readCommitMetadata, footer = true } = {}, indexed) {
|
|
37
37
|
const files = new Map(await Promise.all((await listViewerAssets()).map(async ([name, source]) => {
|
|
38
38
|
const bytes = await readFile(source);
|
|
39
39
|
// The published viewer keeps its existing flat URLs for static hosts and open tabs.
|
|
@@ -43,23 +43,21 @@ export async function siteFiles(reports, { title = '', mode = 'public', componen
|
|
|
43
43
|
return [name, contents];
|
|
44
44
|
})));
|
|
45
45
|
const index = files.get('index.html').toString('utf8')
|
|
46
|
-
.replace('name="repometry-view" content="
|
|
46
|
+
.replace('name="repometry-view" content="private"', `name="repometry-view" content="${mode}"`)
|
|
47
47
|
.replace('name="repometry-project" content=""', () => `name="repometry-project" content="${escapeAttribute(title)}"`);
|
|
48
48
|
files.set('index.html', Buffer.from(footer ? index : withoutFooter(index)));
|
|
49
49
|
const commits = reports.filter(report => report.subject.kind === 'commit');
|
|
50
50
|
const rows = orderSummaries(await withCommitMetadata(indexed ?? commits.map(commitSummary), readCommitMetadata));
|
|
51
|
-
const publicRows = rows.map(({ quality, counts, detail, revision, profileDigest, profileBoundary, subject, author, tags, metrics, values, privateMetrics, ...history }) => ({ ...history, subject, author
|
|
51
|
+
const publicRows = rows.map(({ quality, counts, detail, revision, profileDigest, profileBoundary, subject, author, tags, metrics, values, privateMetrics, ...history }) => ({ ...history, subject, author, tags }));
|
|
52
52
|
const history = { schema: historySchema, reports: publicRows };
|
|
53
53
|
const quality = { schema: 'urn:repometry:schema:quality-history:1',
|
|
54
54
|
reports: Object.fromEntries(rows.map(row => [row.sha, row.quality])) };
|
|
55
55
|
files.set('history.json', Buffer.from(`${JSON.stringify(history)}\n`));
|
|
56
56
|
files.set('quality-history.json', Buffer.from(`${JSON.stringify(quality)}\n`));
|
|
57
57
|
const latest = rows[0];
|
|
58
|
-
|
|
59
|
-
for (const [name, data] of badges(latest, latest?.quality, mode === 'public' ? undefined : latest?.counts?.security))
|
|
58
|
+
for (const [name, data] of badges(latest, latest?.quality, latest?.counts?.security))
|
|
60
59
|
files.set(name, data);
|
|
61
|
-
|
|
62
|
-
files.set('pulls.json', Buffer.from(`${JSON.stringify({ schema: pullReviewsSchema, reviews: pulls })}\n`));
|
|
60
|
+
files.set('pulls.json', Buffer.from(`${JSON.stringify({ schema: pullReviewsSchema, reviews: pulls })}\n`));
|
|
63
61
|
const details = new Map();
|
|
64
62
|
if (mode === 'private') {
|
|
65
63
|
for (const report of commits) {
|
|
@@ -73,11 +71,9 @@ export async function siteFiles(reports, { title = '', mode = 'public', componen
|
|
|
73
71
|
files.set('summary.json', siteSummary(rows, { mode, components, pulls, sources, branch }, details));
|
|
74
72
|
return files;
|
|
75
73
|
}
|
|
76
|
-
export function siteSummary(rows, { mode = '
|
|
74
|
+
export function siteSummary(rows, { mode = 'private', components, pulls = [], sources, branch }, details = new Map()) {
|
|
77
75
|
const ordered = orderSummaries(rows);
|
|
78
76
|
const commits = ordered.map(({ counts, detail, revision, profileDigest, profileBoundary, subject, author, tags, ...row }, index) => {
|
|
79
|
-
if (mode === 'public')
|
|
80
|
-
return { ...row, subject, author: author && { name: author.name }, tags };
|
|
81
77
|
const previous = ordered[index + 1];
|
|
82
78
|
const boundary = !previous ? undefined : !profileDigest || !previous.profileDigest ? 'unavailable'
|
|
83
79
|
: profileDigest === previous.profileDigest ? undefined : 'changed';
|
|
@@ -87,22 +83,20 @@ export function siteSummary(rows, { mode = 'public', components, pulls = [], sou
|
|
|
87
83
|
...(boundary === undefined ? {} : { profileBoundary: boundary }),
|
|
88
84
|
};
|
|
89
85
|
});
|
|
90
|
-
const summary = repositorySummary(commits,
|
|
86
|
+
const summary = repositorySummary(commits, pulls.length, true);
|
|
91
87
|
return Buffer.from(`${JSON.stringify({ ...summary, ...(branch === undefined ? {} : { source: { branch } }),
|
|
92
|
-
...(
|
|
88
|
+
...(sources ? { sources } : {}) })}\n`);
|
|
93
89
|
}
|
|
94
90
|
export async function exportSite(reader, destination, options = {}) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
await mkdir(destination, { recursive: true, mode: options.mode === 'private' ? 0o700 : 0o755 });
|
|
91
|
+
const files = await siteFiles(await reader.list(), options);
|
|
92
|
+
await mkdir(destination, { recursive: true, mode: 0o755 });
|
|
98
93
|
if (!(await lstat(destination)).isDirectory())
|
|
99
94
|
throw new Error('The viewer destination must be a directory');
|
|
100
95
|
const entries = await readdir(destination, { withFileTypes: true });
|
|
101
|
-
const
|
|
102
|
-
const oldDetails = privateExport && entries.some(entry => entry.name === 'details.json' && entry.isFile());
|
|
96
|
+
const oldDetails = entries.some(entry => entry.name === 'details.json' && entry.isFile());
|
|
103
97
|
const detailDirectory = entries.some(entry => entry.name === 'details' && entry.isDirectory());
|
|
104
98
|
if (entries.some(entry => !(entry.isFile() && files.has(entry.name))
|
|
105
|
-
&& !(
|
|
99
|
+
&& !(entry.name === 'details' && entry.isDirectory())
|
|
106
100
|
&& !(oldDetails && entry.name === 'details.json' && entry.isFile()))) {
|
|
107
101
|
throw new Error('Use a dedicated viewer destination containing only Repometry export files');
|
|
108
102
|
}
|
|
@@ -129,16 +123,14 @@ export async function exportSite(reader, destination, options = {}) {
|
|
|
129
123
|
try {
|
|
130
124
|
const hasDetails = [...files.keys()].some(name => name.startsWith('details/'));
|
|
131
125
|
if (hasDetails)
|
|
132
|
-
await mkdir(join(staging, 'details')
|
|
133
|
-
for (const [name, bytes] of files)
|
|
134
|
-
|
|
135
|
-
await writeFile(join(staging, name), bytes, { mode });
|
|
136
|
-
}
|
|
126
|
+
await mkdir(join(staging, 'details'));
|
|
127
|
+
for (const [name, bytes] of files)
|
|
128
|
+
await writeFile(join(staging, name), bytes, { mode: 0o644 });
|
|
137
129
|
const afterDependencies = ['viewer.js', 'summary.json', 'index.html'];
|
|
138
130
|
const install = (name) => rename(join(staging, name), join(destination, name));
|
|
139
131
|
await install('history.json');
|
|
140
132
|
if (hasDetails && !detailDirectory)
|
|
141
|
-
await mkdir(join(destination, 'details')
|
|
133
|
+
await mkdir(join(destination, 'details'));
|
|
142
134
|
for (const name of files.keys()) {
|
|
143
135
|
if (name !== 'history.json' && !afterDependencies.includes(name))
|
|
144
136
|
await install(name);
|
|
@@ -155,3 +147,4 @@ export async function exportSite(reader, destination, options = {}) {
|
|
|
155
147
|
function escapeAttribute(value) {
|
|
156
148
|
return value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
157
149
|
}
|
|
150
|
+
//# sourceMappingURL=export-site.js.map
|
|
@@ -5,6 +5,7 @@ export declare function commitSummary(report: Report): CommitSummary;
|
|
|
5
5
|
export declare function orderSummaries(rows: readonly CommitSummary[]): CommitSummary[];
|
|
6
6
|
export type CommitMetadata = Pick<PublicHistoryEntry, 'subject' | 'author' | 'tags'>;
|
|
7
7
|
export type ReadCommitMetadata = (revisions: readonly string[]) => Promise<ReadonlyMap<string, CommitMetadata>>;
|
|
8
|
+
/** Values recorded at analysis win; Git fills in older inspections and adds tags, which can land after analysis. */
|
|
8
9
|
export declare function withCommitMetadata(rows: readonly CommitSummary[], read?: ReadCommitMetadata): Promise<readonly CommitSummary[]>;
|
|
9
10
|
export declare function expandSummaryCatalog(summary: RepositorySummary): CommitSummary[];
|
|
10
11
|
export declare function repositorySummary(rows: readonly CommitSummary[], pullReviewCount?: number, includePrivateMetrics?: boolean): RepositorySummary;
|
|
@@ -23,6 +23,7 @@ export function commitSummary(report) {
|
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
25
|
...history,
|
|
26
|
+
...(report.commit === undefined ? {} : { subject: report.commit.subject, author: report.commit.author }),
|
|
26
27
|
revision: reportRevision(report),
|
|
27
28
|
...(profileDigest === undefined ? {} : { profileDigest }),
|
|
28
29
|
quality: qualitySummary(report),
|
|
@@ -40,11 +41,15 @@ export function commitSummary(report) {
|
|
|
40
41
|
export function orderSummaries(rows) {
|
|
41
42
|
return [...rows].sort(compareHistoryEntries);
|
|
42
43
|
}
|
|
44
|
+
/** Values recorded at analysis win; Git fills in older inspections and adds tags, which can land after analysis. */
|
|
43
45
|
export async function withCommitMetadata(rows, read) {
|
|
44
46
|
if (!read || !rows.length)
|
|
45
47
|
return rows;
|
|
46
48
|
const metadata = await read(rows.map(row => row.sha));
|
|
47
|
-
return rows.map(row =>
|
|
49
|
+
return rows.map(row => {
|
|
50
|
+
const found = metadata.get(row.sha);
|
|
51
|
+
return found === undefined ? row : { ...found, ...row, ...(found.tags === undefined ? {} : { tags: found.tags }) };
|
|
52
|
+
});
|
|
48
53
|
}
|
|
49
54
|
export function expandSummaryCatalog(summary) {
|
|
50
55
|
return orderSummaries(summary.commits).map(row => summary.metrics === undefined || row.values === undefined ? row
|
|
@@ -116,3 +121,4 @@ function commitTime(report) {
|
|
|
116
121
|
const time = Date.parse(report.committedAt ?? legacy);
|
|
117
122
|
return Number.isFinite(time) ? new Date(time).toISOString() : null;
|
|
118
123
|
}
|
|
124
|
+
//# sourceMappingURL=commit-summary.js.map
|
|
@@ -55,3 +55,4 @@ function rollup(rows, aggregate, path, directory) {
|
|
|
55
55
|
return selected.length === 0 && aggregate === 'sum' ? 0 : null;
|
|
56
56
|
return aggregate === 'sum' ? values.reduce((sum, value) => sum + value, 0) : values.reduce((max, value) => Math.max(max, value));
|
|
57
57
|
}
|
|
58
|
+
//# sourceMappingURL=metric-values.js.map
|
package/target/main/ts/report.js
CHANGED
|
@@ -3,3 +3,4 @@ export { validateSummary } from './report/json/validation/summary-validation.js'
|
|
|
3
3
|
export { historySchema } from './report/json/wire/public-history-model.js';
|
|
4
4
|
export { summarySchema } from './report/json/wire/summary-model.js';
|
|
5
5
|
export { fileMetricsSchema } from './report/json/wire/file-metrics-model.js';
|
|
6
|
+
//# sourceMappingURL=report.js.map
|