@bymaksym/loadline 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +272 -45
- package/dist/cli/cli/args.js +97 -116
- package/dist/cli/cli/gates.js +80 -14
- package/dist/cli/cli/main.js +275 -31
- package/dist/cli/cli/memory.js +114 -0
- package/dist/cli/cli/read/declared.js +52 -0
- package/dist/cli/cli/read/locate.js +214 -0
- package/dist/cli/cli/{read-build.js → read/read-build.js} +156 -87
- package/dist/cli/cli/read/read-config.js +120 -0
- package/dist/cli/cli/render/html-report.js +111 -0
- package/dist/cli/cli/render/render-agent.js +114 -0
- package/dist/cli/cli/render/render-asked.js +104 -0
- package/dist/cli/cli/render/render-badge.js +140 -0
- package/dist/cli/cli/{render-json.js → render/render-json.js} +26 -10
- package/dist/cli/cli/{render-markdown.js → render/render-markdown.js} +6 -6
- package/dist/cli/cli/{render-pr.js → render/render-pr.js} +37 -15
- package/dist/cli/cli/{render-sarif.js → render/render-sarif.js} +11 -6
- package/dist/cli/cli/{render-text.js → render/render-text.js} +169 -127
- package/dist/cli/cli/render/terminal.js +55 -0
- package/dist/cli/cli/report.js +76 -29
- package/dist/cli/cli/self-check.js +19 -23
- package/dist/cli/cli/since-last.js +45 -0
- package/dist/cli/cli/text/text-errors.js +124 -0
- package/dist/cli/cli/text/text.js +343 -0
- package/dist/cli/cli/text/usage.js +240 -0
- package/dist/cli/src/app/core/analysis/analysis.js +68 -24
- package/dist/cli/src/app/core/analysis/{barrels.js → graph/barrels.js} +10 -3
- package/dist/cli/src/app/core/analysis/{blast.js → graph/blast.js} +56 -17
- package/dist/cli/src/app/core/analysis/{cycles.js → graph/cycles.js} +1 -1
- package/dist/cli/src/app/core/analysis/{importers.js → graph/importers.js} +1 -1
- package/dist/cli/src/app/core/analysis/{insights.js → graph/insights.js} +10 -4
- package/dist/cli/src/app/core/analysis/invariant.js +1 -1
- package/dist/cli/src/app/core/analysis/metafile.types.js +21 -7
- package/dist/cli/src/app/core/analysis/{delivery.js → screens/delivery.js} +1 -1
- package/dist/cli/src/app/core/analysis/{entries.js → screens/entries.js} +87 -11
- package/dist/cli/src/app/core/analysis/screens/marks.js +32 -0
- package/dist/cli/src/app/core/analysis/screens/route-files.js +116 -0
- package/dist/cli/src/app/core/analysis/{sourcemap.js → sourcemap/sourcemap.js} +106 -7
- package/dist/cli/src/app/core/analysis/{split-drift.js → sourcemap/split-drift.js} +13 -7
- package/dist/cli/src/app/core/analysis/tool.js +83 -0
- package/dist/cli/src/app/core/assets/assets.js +137 -16
- package/dist/cli/src/app/core/baseline/baseline.js +0 -0
- package/dist/cli/src/app/core/{intake → build-text}/index-html.js +234 -29
- package/dist/cli/src/app/core/build-text/route-table.js +178 -0
- package/dist/cli/src/app/core/build-text/tool-marks.js +54 -0
- package/dist/cli/src/app/core/caching/caching.js +123 -45
- package/dist/cli/src/app/core/caching/from-analysis.js +20 -4
- package/dist/cli/src/app/core/config/config-text.js +90 -0
- package/dist/cli/src/app/core/config/config-values.js +358 -0
- package/dist/cli/src/app/core/config/loadline-config.js +81 -16
- package/dist/cli/src/app/core/config/merge-config.js +98 -0
- package/dist/cli/src/app/core/deps/deps.js +141 -23
- package/dist/cli/src/app/core/deps/pins.js +63 -0
- package/dist/cli/src/app/core/export/summary.js +54 -12
- package/dist/cli/src/app/core/findings/actions.js +65 -6
- package/dist/cli/src/app/core/findings/bundle/boot-single.js +76 -0
- package/dist/cli/src/app/core/findings/bundle/dupes.js +68 -0
- package/dist/cli/src/app/core/findings/{graph.js → bundle/graph.js} +32 -20
- package/dist/cli/src/app/core/findings/{own-in-boot.js → bundle/own-in-boot.js} +9 -5
- package/dist/cli/src/app/core/findings/{requests.js → bundle/requests.js} +3 -3
- package/dist/cli/src/app/core/findings/{shipped.js → bundle/shipped.js} +30 -18
- package/dist/cli/src/app/core/findings/compose.js +6 -1
- package/dist/cli/src/app/core/findings/effort.js +4 -0
- package/dist/cli/src/app/core/findings/finding.types.js +2 -0
- package/dist/cli/src/app/core/findings/findings.js +68 -55
- package/dist/cli/src/app/core/findings/{assets.js → folder/assets.js} +65 -16
- package/dist/cli/src/app/core/findings/{caching.js → folder/caching.js} +17 -10
- package/dist/cli/src/app/core/findings/{page.js → folder/page.js} +6 -2
- package/dist/cli/src/app/core/findings/{scan.js → folder/scan.js} +37 -13
- package/dist/cli/src/app/core/findings/kind-names.js +163 -0
- package/dist/cli/src/app/core/findings/{deps.js → supplied/deps.js} +13 -8
- package/dist/cli/src/app/core/findings/supplied/forbidden.js +71 -0
- package/dist/cli/src/app/core/findings/{situation.js → supplied/situation.js} +2 -2
- package/dist/cli/src/app/core/findings/text/causes.js +39 -0
- package/dist/cli/src/app/core/findings/text/finding-html.js +33 -0
- package/dist/cli/src/app/core/findings/{finding-text.js → text/finding-text.js} +307 -103
- package/dist/cli/src/app/core/findings/text/tool-advice.js +97 -0
- package/dist/cli/src/app/core/format/format.utils.js +172 -18
- package/dist/cli/src/app/core/format/ownership.js +93 -0
- package/dist/cli/src/app/core/i18n/en.js +180 -61
- package/dist/cli/src/app/core/i18n/es.js +192 -68
- package/dist/cli/src/app/core/intake/bundle-graph.js +285 -46
- package/dist/cli/src/app/core/intake/dist-files.js +87 -16
- package/dist/cli/src/app/core/intake/embedded.js +56 -0
- package/dist/cli/src/app/core/intake/unreached.js +139 -0
- package/dist/cli/src/app/core/intake/webpack-modules.js +185 -0
- package/dist/cli/src/app/core/intake/webpack-stats.js +298 -0
- package/dist/cli/src/app/core/project/budget-advice.js +14 -10
- package/dist/cli/src/app/core/project/project-context.js +89 -19
- package/dist/cli/src/app/core/project/project-name.js +36 -0
- package/dist/cli/src/app/core/scan/scan.js +116 -39
- package/dist/cli/src/app/core/scan/secrets.js +0 -0
- package/dist/cli/src/app/core/situation/situation-text.js +23 -0
- package/dist/cli/src/app/core/situation/situation.js +9 -8
- package/dist/cli/src/app/core/timing/timing.js +5 -2
- package/dist/cli/src/app/core/whatif/defer.js +29 -4
- package/dist/cli/src/app/core/whatif/source-importers.js +58 -0
- package/dist/cli/src/app/core/whatif/why.js +102 -0
- package/dist/cli/src/app/state/report-messages.utils.js +1 -4
- package/docs/CONFIG-REFERENCE.md +230 -0
- package/docs/CONFIG.md +511 -0
- package/docs/HOW-IT-WORKS.md +286 -25
- package/loadline.html +26 -24
- package/loadline.schema.json +1209 -0
- package/package.json +71 -35
- package/dist/cli/cli/text.js +0 -180
- package/dist/cli/src/app/core/findings/finding-html.js +0 -13
- /package/dist/cli/cli/{read-build.types.js → read/read-build.types.js} +0 -0
- /package/dist/cli/cli/{render-json.types.js → render/render-json.types.js} +0 -0
- /package/dist/cli/cli/{text.types.js → text/text.types.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{exclusive.js → graph/exclusive.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{insights.types.js → graph/insights.types.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{module-graph.js → graph/module-graph.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{sourcemap.types.js → sourcemap/sourcemap.types.js} +0 -0
- /package/dist/cli/src/app/core/findings/{finding-plain.js → text/finding-plain.js} +0 -0
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
/** The report as data. Shape and its rules: `render-json.types.ts`. */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.renderJson = void 0;
|
|
5
|
-
const criteria_1 = require("
|
|
6
|
-
const actions_1 = require("
|
|
7
|
-
const finding_plain_1 = require("
|
|
8
|
-
const budget_advice_1 = require("
|
|
9
|
-
const timing_1 = require("
|
|
5
|
+
const criteria_1 = require("../../src/app/core/criteria/criteria");
|
|
6
|
+
const actions_1 = require("../../src/app/core/findings/actions");
|
|
7
|
+
const finding_plain_1 = require("../../src/app/core/findings/text/finding-plain");
|
|
8
|
+
const budget_advice_1 = require("../../src/app/core/project/budget-advice");
|
|
9
|
+
const timing_1 = require("../../src/app/core/timing/timing");
|
|
10
|
+
const defer_1 = require("../../src/app/core/whatif/defer");
|
|
10
11
|
const comparisonOf = (report) => {
|
|
11
12
|
const comparison = report.comparison;
|
|
12
13
|
if (!comparison) {
|
|
@@ -20,6 +21,7 @@ const comparisonOf = (report) => {
|
|
|
20
21
|
newScreens: comparison.newScreens.map(screen => screen.label),
|
|
21
22
|
goneScreens: comparison.goneScreens.map(screen => screen.label),
|
|
22
23
|
newBootPackages: comparison.newBootPackages,
|
|
24
|
+
bootCauses: comparison.bootCauses,
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
const screensOf = (report) => report.analysis.screens.map(screen => {
|
|
@@ -32,8 +34,10 @@ const screensOf = (report) => report.analysis.screens.map(screen => {
|
|
|
32
34
|
shared: screen.shared,
|
|
33
35
|
own: screen.own,
|
|
34
36
|
total: screen.total,
|
|
37
|
+
routes: screen.routes ?? [],
|
|
35
38
|
verdict: (0, criteria_1.rate)(screen.total, report.criteria.screenOk, report.criteria.screenBad),
|
|
36
39
|
delta: delta ? delta.total : null,
|
|
40
|
+
causes: delta?.causes ?? null,
|
|
37
41
|
};
|
|
38
42
|
});
|
|
39
43
|
/** The two lists of lazy entries that are not screens, in the order the report shows them. */
|
|
@@ -42,7 +46,7 @@ const renderJson = (report, violations, anyAsked) => {
|
|
|
42
46
|
const { analysis, criteria } = report;
|
|
43
47
|
const asking = new Set(['budgetNone', 'budgetTooHigh', 'budgetWarnOnly']);
|
|
44
48
|
const advice = report.findings.some(finding => asking.has(finding.kind))
|
|
45
|
-
? (0, budget_advice_1.budgetAdvice)(analysis.
|
|
49
|
+
? (0, budget_advice_1.budgetAdvice)(analysis.initialRawBytes)
|
|
46
50
|
: null;
|
|
47
51
|
const payload = {
|
|
48
52
|
tool: 'loadline',
|
|
@@ -52,7 +56,9 @@ const renderJson = (report, violations, anyAsked) => {
|
|
|
52
56
|
mode: report.mode,
|
|
53
57
|
unit: report.unit,
|
|
54
58
|
splitSource: analysis.splitSource,
|
|
59
|
+
builtWith: analysis.tool,
|
|
55
60
|
serverOutputs: analysis.serverOutputs,
|
|
61
|
+
offPage: analysis.offPage,
|
|
56
62
|
pageCss: report.pageCssBytes === null ? null : { bytes: report.pageCssBytes, files: report.pageCssFiles },
|
|
57
63
|
firstTrip: report.assets?.firstTrip ?? null,
|
|
58
64
|
assets: report.assets
|
|
@@ -77,6 +83,10 @@ const renderJson = (report, violations, anyAsked) => {
|
|
|
77
83
|
deferred: entriesOf(analysis.deferredBlocks),
|
|
78
84
|
groupers: entriesOf(analysis.routeGroupers),
|
|
79
85
|
data: entriesOf(analysis.lazyData),
|
|
86
|
+
packages: entriesOf(analysis.lazyPackages),
|
|
87
|
+
workers: entriesOf(analysis.lazyWorkers),
|
|
88
|
+
onDemand: entriesOf(analysis.lazyOnDemand),
|
|
89
|
+
routeTable: analysis.routeTable,
|
|
80
90
|
shared: analysis.sharedChunks.map(chunk => ({
|
|
81
91
|
file: chunk.file,
|
|
82
92
|
name: chunk.name,
|
|
@@ -86,9 +96,10 @@ const renderJson = (report, violations, anyAsked) => {
|
|
|
86
96
|
})),
|
|
87
97
|
findings: report.findings.map(finding => ({
|
|
88
98
|
kind: finding.kind,
|
|
99
|
+
...(finding.target?.key && { key: finding.target.key }),
|
|
89
100
|
severity: finding.severity,
|
|
90
|
-
chip: finding.chip,
|
|
91
|
-
title: finding.title,
|
|
101
|
+
chip: (0, finding_plain_1.plainText)(finding.chip),
|
|
102
|
+
title: (0, finding_plain_1.plainText)(finding.title),
|
|
92
103
|
body: (0, finding_plain_1.plainText)(finding.body),
|
|
93
104
|
fix: (0, finding_plain_1.plainText)(finding.fix),
|
|
94
105
|
...(finding.saving !== undefined && { saving: finding.saving }),
|
|
@@ -96,16 +107,21 @@ const renderJson = (report, violations, anyAsked) => {
|
|
|
96
107
|
})),
|
|
97
108
|
actions: (0, actions_1.rankActions)(report.findings).map(action => ({
|
|
98
109
|
kind: action.finding.kind,
|
|
99
|
-
title: action.finding.title,
|
|
110
|
+
title: (0, finding_plain_1.plainText)(action.finding.title),
|
|
100
111
|
saving: action.saving,
|
|
101
112
|
effort: action.effort,
|
|
102
113
|
})),
|
|
103
114
|
saving: (0, actions_1.totalSaving)(analysis, report.findings),
|
|
115
|
+
savingInUnit: (0, actions_1.savingInUnit)(analysis, (0, actions_1.totalSaving)(analysis, report.findings)),
|
|
116
|
+
measurable: !(0, defer_1.blindBoot)(analysis),
|
|
117
|
+
whatIf: report.whatIf,
|
|
118
|
+
why: report.why,
|
|
104
119
|
timing: (0, timing_1.timingsOf)(analysis.bootBytes + (report.pageCssBytes ?? 0), analysis.bootRawBytes, analysis.startup?.waves ?? 1, criteria.latencyMs),
|
|
105
120
|
budget: advice,
|
|
106
121
|
caching: report.caching,
|
|
107
122
|
scan: report.scan,
|
|
108
|
-
|
|
123
|
+
// Without the declared ranges: they are an input the signals already read, not a finding.
|
|
124
|
+
deps: (({ declared: _declared, ...rest }) => rest)(report.deps),
|
|
109
125
|
comparison: comparisonOf(report),
|
|
110
126
|
comparable: !report.comparisonBlocked,
|
|
111
127
|
gates: { asked: anyAsked, violations },
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.renderMarkdown = void 0;
|
|
9
|
-
const markdown_table_utils_1 = require("
|
|
10
|
-
const finding_plain_1 = require("
|
|
11
|
-
const ui_1 = require("
|
|
12
|
-
const gates_1 = require("
|
|
13
|
-
const text_1 = require("
|
|
9
|
+
const markdown_table_utils_1 = require("../../src/app/core/export/markdown-table.utils");
|
|
10
|
+
const finding_plain_1 = require("../../src/app/core/findings/text/finding-plain");
|
|
11
|
+
const ui_1 = require("../../src/app/core/i18n/ui");
|
|
12
|
+
const gates_1 = require("../gates");
|
|
13
|
+
const text_1 = require("../text/text");
|
|
14
14
|
const renderMarkdown = (report, violations, anyAsked) => {
|
|
15
15
|
const text = text_1.CLI_TEXT[report.lang];
|
|
16
16
|
const strings = ui_1.UI[report.lang];
|
|
17
17
|
const blocks = [(0, markdown_table_utils_1.markdownTable)(report.analysis, report.comparison, strings, report.unit)];
|
|
18
18
|
if (report.findings.length > 0) {
|
|
19
19
|
blocks.push(`### ${text.headSignals}`, report.findings
|
|
20
|
-
.map(finding => `- **${finding.title}** — ${(0, finding_plain_1.plainText)(finding.body)}\n ${text.fix}: ${(0, finding_plain_1.plainText)(finding.fix)}`)
|
|
20
|
+
.map(finding => `- **${(0, finding_plain_1.plainText)(finding.title)}** — ${(0, finding_plain_1.plainText)(finding.body)}\n ${text.fix}: ${(0, finding_plain_1.plainText)(finding.fix)}`)
|
|
21
21
|
.join('\n'));
|
|
22
22
|
}
|
|
23
23
|
if (anyAsked) {
|
|
@@ -14,18 +14,23 @@
|
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.renderPrComment = exports.PR_MARKER = void 0;
|
|
17
|
-
const markdown_table_utils_1 = require("
|
|
18
|
-
const actions_1 = require("
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
17
|
+
const markdown_table_utils_1 = require("../../src/app/core/export/markdown-table.utils");
|
|
18
|
+
const actions_1 = require("../../src/app/core/findings/actions");
|
|
19
|
+
const kind_names_1 = require("../../src/app/core/findings/kind-names");
|
|
20
|
+
const finding_plain_1 = require("../../src/app/core/findings/text/finding-plain");
|
|
21
|
+
const format_utils_1 = require("../../src/app/core/format/format.utils");
|
|
22
|
+
const ui_1 = require("../../src/app/core/i18n/ui");
|
|
23
|
+
const gates_1 = require("../gates");
|
|
24
|
+
const text_1 = require("../text/text");
|
|
24
25
|
/**
|
|
25
26
|
* What a bot looks for to find its own previous comment. It is an HTML comment, so it is invisible
|
|
26
27
|
* in the rendered page and survives being edited by hand.
|
|
27
28
|
*/
|
|
28
29
|
exports.PR_MARKER = '<!-- loadline-report -->';
|
|
30
|
+
/** Below GitHub's 65,536 characters for a comment, with room for what a bot adds around it. */
|
|
31
|
+
const PR_BUDGET = 60_000;
|
|
32
|
+
/** What is kept of each signal's text once the comment is over the budget. */
|
|
33
|
+
const PR_BODY_CAP = 600;
|
|
29
34
|
const details = (summary, body) => `<details>\n<summary>${summary}</summary>\n\n${body}\n\n</details>`;
|
|
30
35
|
const renderPrComment = (report, violations, anyAsked) => {
|
|
31
36
|
const text = text_1.CLI_TEXT[report.lang];
|
|
@@ -38,8 +43,13 @@ const renderPrComment = (report, violations, anyAsked) => {
|
|
|
38
43
|
// Which signals came and went. It is the line the person opening the merge request reads, and
|
|
39
44
|
// the only one that makes fixing something visible.
|
|
40
45
|
if (comparison?.findingsComparable) {
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
// By what they say, not by their internal kind: a new one is in this report and carries
|
|
47
|
+
// its chip; a fixed one is not, and is named by what that kind of signal is about.
|
|
48
|
+
const names = kind_names_1.KIND_NAMES[report.lang];
|
|
49
|
+
const chipOf = (kind, key) => report.findings.find(finding => finding.kind === kind && (finding.target?.key ?? '') === key)?.chip ??
|
|
50
|
+
names[kind];
|
|
51
|
+
const fixed = comparison.goneFindings.map(finding => `${names[finding.kind]}${finding.key ? ` (\`${finding.key}\`)` : ''}`);
|
|
52
|
+
const added = comparison.newFindings.map(finding => chipOf(finding.kind, finding.key));
|
|
43
53
|
if (fixed.length > 0 || added.length > 0) {
|
|
44
54
|
lines.push('', [
|
|
45
55
|
fixed.length > 0 ? `✅ ${text.prFixed(fixed.length)}: ${fixed.join(', ')}` : '',
|
|
@@ -52,10 +62,13 @@ const renderPrComment = (report, violations, anyAsked) => {
|
|
|
52
62
|
const actions = (0, actions_1.rankActions)(report.findings);
|
|
53
63
|
if (actions.length > 0) {
|
|
54
64
|
const total = (0, actions_1.totalSaving)(analysis, report.findings);
|
|
55
|
-
const
|
|
65
|
+
const scale = (0, actions_1.unitScale)(analysis);
|
|
66
|
+
const rows = actions.map((action, index) => `| ${index + 1} | ${(0, finding_plain_1.plainText)(action.finding.title)} | ${action.saving > 0 ? (0, actions_1.formatSaving)(action.saving, scale) : '—'} | ${text.effortLabel[action.effort]} |`);
|
|
56
67
|
lines.push('', `#### ${text.headActions}`, `| # | ${text.colAction} | ${text.colSaving} | ${text.colEffort} |`, '| --: | --- | --: | --- |', ...rows);
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
// As in the text: a total of nothing is not a figure worth a line in somebody's review.
|
|
69
|
+
if (total.counted > 0 && total.bytes > 0) {
|
|
70
|
+
const words = (0, actions_1.savingWords)(analysis, total);
|
|
71
|
+
lines.push('', `_${text.totalSaving(words.saving, words.after, total.counted, words.estimated)}_`);
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
if (anyAsked) {
|
|
@@ -63,13 +76,22 @@ const renderPrComment = (report, violations, anyAsked) => {
|
|
|
63
76
|
? `✅ ${text.passed}`
|
|
64
77
|
: [...(0, gates_1.violationLines)(violations).map(line => `- ❌ ${line}`), '', text.failed(violations.length)].join('\n'));
|
|
65
78
|
}
|
|
66
|
-
// Everything the report says, folded. Nothing is dropped: the rule is to group, never to trim
|
|
67
|
-
|
|
79
|
+
// Everything the report says, folded. Nothing is dropped: the rule is to group, never to trim —
|
|
80
|
+
// until the comment would not be posted at all. GitHub refuses one over 65,536 characters, and
|
|
81
|
+
// Excalidraw's came to 64,314, most of it one signal listing 702 paths. Over the budget, each
|
|
82
|
+
// signal's text is cut to its first lines and says where the rest is; titles and the table stay.
|
|
83
|
+
const restWith = (cap) => [
|
|
68
84
|
(0, markdown_table_utils_1.markdownTable)(analysis, comparison, strings, report.unit),
|
|
69
85
|
'',
|
|
70
86
|
`#### ${text.headSignals}`,
|
|
71
|
-
...report.findings.map(finding =>
|
|
87
|
+
...report.findings.map(finding => {
|
|
88
|
+
const body = (0, finding_plain_1.plainText)(finding.body);
|
|
89
|
+
const shown = cap !== null && body.length > cap ? `${body.slice(0, cap).trimEnd()}… ${text.prCut}` : body;
|
|
90
|
+
return `- **${(0, finding_plain_1.plainText)(finding.title)}** — ${shown}\n ${text.fix}: ${(0, finding_plain_1.plainText)(finding.fix)}`;
|
|
91
|
+
}),
|
|
72
92
|
].join('\n');
|
|
93
|
+
const full = restWith(null);
|
|
94
|
+
const rest = lines.join('\n').length + full.length > PR_BUDGET ? restWith(PR_BODY_CAP) : full;
|
|
73
95
|
lines.push('', details(text.prDetails, rest));
|
|
74
96
|
return `${lines.join('\n')}\n`;
|
|
75
97
|
};
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.renderSarif = void 0;
|
|
15
|
-
const finding_types_1 = require("
|
|
16
|
-
const finding_plain_1 = require("
|
|
15
|
+
const finding_types_1 = require("../../src/app/core/findings/finding.types");
|
|
16
|
+
const finding_plain_1 = require("../../src/app/core/findings/text/finding-plain");
|
|
17
|
+
const ownership_1 = require("../../src/app/core/format/ownership");
|
|
17
18
|
/** SARIF has three levels that matter to a code-scanning view; the report has four. */
|
|
18
19
|
const LEVEL = {
|
|
19
20
|
high: 'error',
|
|
@@ -29,8 +30,12 @@ const LEVEL = {
|
|
|
29
30
|
* which is true and checkable.
|
|
30
31
|
*/
|
|
31
32
|
const locationOf = (finding, fallback) => {
|
|
33
|
+
const ownFile = (path) => /\.[a-z]+$/i.test(path) && (0, ownership_1.isOwnFile)(path);
|
|
32
34
|
const key = finding.target?.key ?? '';
|
|
33
|
-
|
|
35
|
+
// Then the files the signal is about, which several carry when their key is a folder or a
|
|
36
|
+
// package: anchored to the build folder, 16 of 18 results of a real report pointed at nothing a
|
|
37
|
+
// code-scanning view can open, while `bigFile` named App.tsx in its own text.
|
|
38
|
+
return ownFile(key) ? key : (finding.sources?.find(source => ownFile(source)) ?? fallback);
|
|
34
39
|
};
|
|
35
40
|
const renderSarif = (report) => {
|
|
36
41
|
const fallback = report.statsName;
|
|
@@ -43,15 +48,15 @@ const renderSarif = (report) => {
|
|
|
43
48
|
return {
|
|
44
49
|
id: kind,
|
|
45
50
|
name: kind,
|
|
46
|
-
shortDescription: { text: example
|
|
47
|
-
fullDescription: { text: example
|
|
51
|
+
shortDescription: { text: example ? (0, finding_plain_1.plainText)(example.chip) : kind },
|
|
52
|
+
fullDescription: { text: example ? (0, finding_plain_1.plainText)(example.title) : kind },
|
|
48
53
|
help: { text: example ? (0, finding_plain_1.plainText)(example.fix) : '' },
|
|
49
54
|
};
|
|
50
55
|
});
|
|
51
56
|
const results = report.findings.map(finding => ({
|
|
52
57
|
ruleId: finding.kind,
|
|
53
58
|
level: LEVEL[finding.severity],
|
|
54
|
-
message: { text: `${finding.title} — ${(0, finding_plain_1.plainText)(finding.body)}` },
|
|
59
|
+
message: { text: `${(0, finding_plain_1.plainText)(finding.title)} — ${(0, finding_plain_1.plainText)(finding.body)}` },
|
|
55
60
|
locations: [
|
|
56
61
|
{
|
|
57
62
|
physicalLocation: {
|