@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
|
@@ -9,60 +9,23 @@
|
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.renderText = void 0;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
? { bold: code(1), dim: code(90), good: code(32), warn: code(33), bad: code(31) }
|
|
28
|
-
: { bold: plain, dim: plain, good: plain, warn: plain, bad: plain };
|
|
29
|
-
/** Length as the terminal shows it: padding a coloured string by its raw length breaks the column. */
|
|
30
|
-
const visible = (value) => value.replaceAll(ANSI, '').length;
|
|
31
|
-
const pad = (value, width, right) => {
|
|
32
|
-
const filler = ' '.repeat(Math.max(0, width - visible(value)));
|
|
33
|
-
return right ? `${filler}${value}` : `${value}${filler}`;
|
|
34
|
-
};
|
|
12
|
+
const tool_1 = require("../../src/app/core/analysis/tool");
|
|
13
|
+
const assets_1 = require("../../src/app/core/assets/assets");
|
|
14
|
+
const criteria_1 = require("../../src/app/core/criteria/criteria");
|
|
15
|
+
const actions_1 = require("../../src/app/core/findings/actions");
|
|
16
|
+
const finding_plain_1 = require("../../src/app/core/findings/text/finding-plain");
|
|
17
|
+
const format_utils_1 = require("../../src/app/core/format/format.utils");
|
|
18
|
+
const ui_1 = require("../../src/app/core/i18n/ui");
|
|
19
|
+
const budget_advice_1 = require("../../src/app/core/project/budget-advice");
|
|
20
|
+
const timing_1 = require("../../src/app/core/timing/timing");
|
|
21
|
+
const defer_1 = require("../../src/app/core/whatif/defer");
|
|
22
|
+
const gates_1 = require("../gates");
|
|
23
|
+
const since_last_1 = require("../since-last");
|
|
24
|
+
const text_1 = require("../text/text");
|
|
25
|
+
const render_asked_1 = require("./render-asked");
|
|
26
|
+
const terminal_1 = require("./terminal");
|
|
35
27
|
const verdictPaint = (palette, verdict) => verdict === 'good' ? palette.good : verdict === 'ok' ? palette.warn : palette.bad;
|
|
36
28
|
const severityPaint = (palette, severity) => severity === 'high' ? palette.bad : severity === 'mid' ? palette.warn : palette.dim;
|
|
37
|
-
/** Wraps at word boundaries. A signal is a sentence, and a sentence cut mid-word is harder to read. */
|
|
38
|
-
const wrap = (value, width) => {
|
|
39
|
-
const lines = [];
|
|
40
|
-
const words = value.split(/\s+/).filter(Boolean);
|
|
41
|
-
let current = '';
|
|
42
|
-
for (const word of words) {
|
|
43
|
-
if (current && current.length + word.length + 1 > width) {
|
|
44
|
-
lines.push(current);
|
|
45
|
-
current = word;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
current = current ? `${current} ${word}` : word;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (current) {
|
|
52
|
-
lines.push(current);
|
|
53
|
-
}
|
|
54
|
-
return lines;
|
|
55
|
-
};
|
|
56
|
-
/** A table sized to its own content: nothing truncated, nothing padded to a guess. */
|
|
57
|
-
const table = (columns, rows, palette) => {
|
|
58
|
-
const widths = columns.map((column, index) => Math.max(column.head.length, ...rows.map(row => visible(row[index] ?? ''))));
|
|
59
|
-
const line = (cells) => cells.map((value, index) => pad(value, widths[index] ?? 0, columns[index]?.right ?? false)).join(' ');
|
|
60
|
-
return [
|
|
61
|
-
palette.dim(line(columns.map(column => column.head))),
|
|
62
|
-
palette.dim(widths.map(width => '-'.repeat(width)).join(' ')),
|
|
63
|
-
...rows.map(row => line(row)),
|
|
64
|
-
];
|
|
65
|
-
};
|
|
66
29
|
/**
|
|
67
30
|
* What the first load costs in round trips, under the bootstrap figure. Empty without `--dist`:
|
|
68
31
|
* `index.html` is the only file that tells a preloaded chunk from one the browser has to discover
|
|
@@ -78,30 +41,85 @@ const startupLines = (report, palette) => {
|
|
|
78
41
|
late: startup.discovered.length,
|
|
79
42
|
chunks: report.analysis.bootFiles,
|
|
80
43
|
});
|
|
81
|
-
return
|
|
44
|
+
return (0, terminal_1.wrap)(note, terminal_1.WIDTH).map(line => palette.dim(line));
|
|
82
45
|
};
|
|
83
46
|
/**
|
|
84
47
|
* Everything the page asks for before anything appears, or — without a folder to read — just the
|
|
85
48
|
* stylesheets, which is as much of it as a page alone can say.
|
|
86
49
|
*/
|
|
50
|
+
/** The heaviest few of a list, by name and weight, and how many more there are. */
|
|
51
|
+
const fewOf = (entries) => {
|
|
52
|
+
const shown = entries.slice(0, 3).map(entry => `${entry.label} ${(0, format_utils_1.formatBytes)(entry.bytes)}`);
|
|
53
|
+
return entries.length > 3 ? `${shown.join(', ')}, +${entries.length - 3}` : shown.join(', ');
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* What loads lazily and has no row in the table above, under it — where HOW-IT-WORKS always said
|
|
57
|
+
* these lists were. Only the JSON carried them, so a build whose lazy parts are features rather
|
|
58
|
+
* than routes read as having five screens and nothing else.
|
|
59
|
+
*/
|
|
60
|
+
const notScreenLines = (report, palette) => {
|
|
61
|
+
const text = text_1.CLI_TEXT[report.lang];
|
|
62
|
+
const { analysis } = report;
|
|
63
|
+
const kinds = [
|
|
64
|
+
['blocks', analysis.deferredBlocks],
|
|
65
|
+
['groupers', analysis.routeGroupers],
|
|
66
|
+
['packages', analysis.lazyPackages],
|
|
67
|
+
['data', analysis.lazyData],
|
|
68
|
+
['workers', analysis.lazyWorkers],
|
|
69
|
+
['onDemand', analysis.lazyOnDemand],
|
|
70
|
+
];
|
|
71
|
+
const parts = kinds
|
|
72
|
+
.filter(([, entries]) => entries.length > 0)
|
|
73
|
+
.map(([kind, entries]) => text.notScreensPart[kind](entries.length, fewOf(entries)));
|
|
74
|
+
// Said only where it could have been found: a stats file carries no code to look in.
|
|
75
|
+
const untabled = analysis.routeTable === false && analysis.screens.length > 0 ? [text.noRouteTable] : [];
|
|
76
|
+
return [...(parts.length > 0 ? [text.notScreens(parts)] : []), ...untabled].flatMap(line => (0, terminal_1.wrap)(line, terminal_1.WIDTH).map(part => palette.dim(part)));
|
|
77
|
+
};
|
|
78
|
+
/** The stylesheets of the lazy routes, named under the table: see `routeStylesOf`. */
|
|
79
|
+
const routeCssLines = (report, palette) => {
|
|
80
|
+
const own = report.assets ? (0, assets_1.routeStylesOf)(report.assets) : [];
|
|
81
|
+
if (own.length === 0) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const list = own.length > 3 ? `${own.slice(0, 3).join(', ')}, +${own.length - 3}` : own.join(', ');
|
|
85
|
+
return (0, terminal_1.wrap)(text_1.CLI_TEXT[report.lang].routeCss(own.length, list), terminal_1.WIDTH).map(line => palette.dim(line));
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* A screen's name with the routes that open it, when they say something its name does not: `Home ·
|
|
89
|
+
* global-feed, my-feed +1`. The router's name for a page is what the team calls it.
|
|
90
|
+
*/
|
|
91
|
+
const withRoutes = (label, routes) => {
|
|
92
|
+
const other = routes.filter(route => route !== label);
|
|
93
|
+
if (other.length === 0) {
|
|
94
|
+
return label;
|
|
95
|
+
}
|
|
96
|
+
const shown = other.slice(0, 2).join(', ');
|
|
97
|
+
const cell = `${label} · ${other.length > 2 ? `${shown} +${other.length - 2}` : shown}`;
|
|
98
|
+
// The routes are a hint beside the name, not a column: a path that runs on is cut, never the table.
|
|
99
|
+
return cell.length > ROUTES_CELL ? `${cell.slice(0, ROUTES_CELL - 1)}…` : cell;
|
|
100
|
+
};
|
|
101
|
+
/** Widest a screen's name gets with its routes beside it. */
|
|
102
|
+
const ROUTES_CELL = 48;
|
|
87
103
|
const firstTripLines = (report, palette) => {
|
|
88
104
|
const text = text_1.CLI_TEXT[report.lang];
|
|
89
105
|
const trip = report.assets?.firstTrip;
|
|
90
106
|
if (trip && trip.total > 0) {
|
|
107
|
+
// The parts that are there: "0 B fonts" is a part of nothing.
|
|
91
108
|
const parts = [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]
|
|
97
|
-
|
|
109
|
+
[trip.scripts, trip.inline > 0 ? `JS ${text.tripInline((0, format_utils_1.formatBytes)(trip.inline))}` : 'JS'],
|
|
110
|
+
[trip.styles, 'CSS'],
|
|
111
|
+
[trip.fonts, text.tripFonts],
|
|
112
|
+
[trip.images, text.tripImages],
|
|
113
|
+
]
|
|
114
|
+
.filter(([bytes]) => bytes > 0)
|
|
115
|
+
.map(([bytes, label]) => `${(0, format_utils_1.formatBytes)(bytes)} ${label}`)
|
|
116
|
+
.join(' + ');
|
|
117
|
+
return (0, terminal_1.wrap)(text.firstTrip((0, format_utils_1.formatBytes)(trip.total), trip.files, parts), terminal_1.WIDTH).map(line => palette.warn(line));
|
|
98
118
|
}
|
|
99
119
|
if (report.pageCssBytes === null) {
|
|
100
120
|
return [];
|
|
101
121
|
}
|
|
102
|
-
return
|
|
103
|
-
palette.warn(text.pageCss((0, format_utils_1.formatBytes)(report.pageCssBytes), report.pageCssFiles, (0, format_utils_1.formatBytes)(report.analysis.bootBytes + report.pageCssBytes))),
|
|
104
|
-
];
|
|
122
|
+
return (0, terminal_1.wrap)(text.pageCss((0, format_utils_1.formatBytes)(report.pageCssBytes), report.pageCssFiles, (0, format_utils_1.formatBytes)(report.analysis.bootBytes + report.pageCssBytes)), terminal_1.WIDTH).map(line => palette.warn(line));
|
|
105
123
|
};
|
|
106
124
|
const screensTable = (report, palette) => {
|
|
107
125
|
const strings = ui_1.UI[report.lang];
|
|
@@ -114,33 +132,49 @@ const screensTable = (report, palette) => {
|
|
|
114
132
|
{ head: strings.colTotal, right: true },
|
|
115
133
|
{ head: strings.colWaves, right: true },
|
|
116
134
|
];
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
// Against the explicit baseline when there is one; otherwise against the last run, so the table
|
|
136
|
+
// says which screen moved without anybody having asked for a comparison.
|
|
137
|
+
const against = comparison ?? report.sinceLast;
|
|
138
|
+
if (against) {
|
|
139
|
+
columns.push({
|
|
140
|
+
head: comparison ? `${strings.colDelta} ${comparison.baselineName}` : strings.colDelta,
|
|
141
|
+
right: true,
|
|
142
|
+
});
|
|
119
143
|
}
|
|
120
144
|
const rows = analysis.screens.map(screen => {
|
|
121
145
|
const verdict = (0, criteria_1.rate)(screen.total, criteria.screenOk, criteria.screenBad);
|
|
122
146
|
const cells = [
|
|
123
|
-
screen.label,
|
|
147
|
+
withRoutes(screen.label, screen.routes ?? []),
|
|
124
148
|
(0, format_utils_1.formatBytes)(screen.boot),
|
|
125
149
|
(0, format_utils_1.formatBytes)(screen.shared),
|
|
126
150
|
(0, format_utils_1.formatBytes)(screen.own),
|
|
127
151
|
verdictPaint(palette, verdict)((0, format_utils_1.formatBytes)(screen.total)),
|
|
128
152
|
String(screen.waves),
|
|
129
153
|
];
|
|
130
|
-
if (
|
|
131
|
-
const delta =
|
|
154
|
+
if (against) {
|
|
155
|
+
const delta = against.screens.get(screen.source);
|
|
132
156
|
cells.push(delta ? (0, format_utils_1.formatDelta)(delta.total.diff) : strings.compareNew);
|
|
133
157
|
}
|
|
134
158
|
return cells;
|
|
135
159
|
});
|
|
136
|
-
return table(columns, rows, palette);
|
|
160
|
+
return (0, terminal_1.table)(columns, rows, palette);
|
|
137
161
|
};
|
|
138
|
-
const signalBlock = (finding, palette, fixLabel) => {
|
|
139
|
-
|
|
162
|
+
const signalBlock = (finding, palette, fixLabel, severity) => {
|
|
163
|
+
// The name `accepted` in loadline.json takes, in grey after the chip: living with a signal
|
|
164
|
+
// used to start with guessing its kind and key.
|
|
165
|
+
const key = finding.target?.key;
|
|
166
|
+
const name = palette.dim(`[${finding.kind}${key ? ` · ${key}` : ''}]`);
|
|
167
|
+
const head = `${severityPaint(palette, finding.severity)(`${severity[finding.severity].padEnd(5)} · ${(0, finding_plain_1.plainText)(finding.chip)}`)} ${name}`;
|
|
140
168
|
const indent = (line) => ` ${line}`;
|
|
141
|
-
const body = wrap((0, finding_plain_1.plainText)(finding.body), WIDTH - 6).map(element => indent(element));
|
|
142
|
-
const fix = finding.fix ? wrap(`${fixLabel}: ${(0, finding_plain_1.plainText)(finding.fix)}`, WIDTH - 6).map(l => indent(l)) : [];
|
|
143
|
-
return [
|
|
169
|
+
const body = (0, terminal_1.wrap)((0, finding_plain_1.plainText)(finding.body), terminal_1.WIDTH - 6).map(element => indent(element));
|
|
170
|
+
const fix = finding.fix ? (0, terminal_1.wrap)(`${fixLabel}: ${(0, finding_plain_1.plainText)(finding.fix)}`, terminal_1.WIDTH - 6).map(l => indent(l)) : [];
|
|
171
|
+
return [
|
|
172
|
+
'',
|
|
173
|
+
` ${head}`,
|
|
174
|
+
` ${palette.bold((0, finding_plain_1.plainText)(finding.title))}`,
|
|
175
|
+
...body,
|
|
176
|
+
...(fix.length > 0 ? ['', ...fix] : []),
|
|
177
|
+
];
|
|
144
178
|
};
|
|
145
179
|
/**
|
|
146
180
|
* What to fix first: the signals ranked by bytes per unit of effort, then what doing all of it is
|
|
@@ -156,28 +190,35 @@ const actionsBlock = (report, palette) => {
|
|
|
156
190
|
// equal jobs, and the eye has to go down to Signals to learn that the fourth is an `info`
|
|
157
191
|
// and the first is not. The saving cell stays plain on purpose: one colour per row, or the
|
|
158
192
|
// colour stops meaning anything.
|
|
193
|
+
const scale = (0, actions_1.unitScale)(report.analysis);
|
|
159
194
|
const rows = actions.map((action, index) => [
|
|
160
195
|
`${index + 1}.`,
|
|
161
|
-
severityPaint(palette, action.finding.severity)(action.finding.title),
|
|
162
|
-
text.savingCell(action.saving > 0 ? (0,
|
|
196
|
+
severityPaint(palette, action.finding.severity)((0, finding_plain_1.plainText)(action.finding.title)),
|
|
197
|
+
text.savingCell(action.saving > 0 ? (0, actions_1.formatSaving)(action.saving, scale) : ''),
|
|
163
198
|
text.effortLabel[action.effort],
|
|
164
199
|
]);
|
|
165
200
|
const total = (0, actions_1.totalSaving)(report.analysis, report.findings);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
201
|
+
// Said only when there is a figure. "No signal here names a saving that can be measured" under
|
|
202
|
+
// a table whose saving column is all dashes repeated what the column had already said.
|
|
203
|
+
const words = (0, actions_1.savingWords)(report.analysis, total);
|
|
204
|
+
// A column of dashes over chunks nobody can see into is "not known", and without a line saying
|
|
205
|
+
// so it reads as "nothing here saves anything".
|
|
206
|
+
const summary = total.counted > 0 && total.bytes > 0
|
|
207
|
+
? text.totalSaving(words.saving, words.after, total.counted, words.estimated)
|
|
208
|
+
: (0, defer_1.blindBoot)(report.analysis)
|
|
209
|
+
? text.savingUnknown
|
|
210
|
+
: null;
|
|
169
211
|
return [
|
|
170
212
|
'',
|
|
171
213
|
palette.bold(text.headActions),
|
|
172
214
|
palette.dim(text.actionsNote),
|
|
173
|
-
...table([
|
|
215
|
+
...(0, terminal_1.table)([
|
|
174
216
|
{ head: '#', right: true },
|
|
175
217
|
{ head: text.colAction, right: false },
|
|
176
218
|
{ head: text.colSaving, right: true },
|
|
177
219
|
{ head: text.colEffort, right: false },
|
|
178
220
|
], rows, palette),
|
|
179
|
-
'',
|
|
180
|
-
...wrap(summary, WIDTH).map(line => palette.dim(line)),
|
|
221
|
+
...(summary ? ['', ...(0, terminal_1.wrap)(summary, terminal_1.WIDTH).map(line => palette.dim(line))] : []),
|
|
181
222
|
];
|
|
182
223
|
};
|
|
183
224
|
/**
|
|
@@ -204,8 +245,8 @@ const timeBlock = (report, palette) => {
|
|
|
204
245
|
return [
|
|
205
246
|
'',
|
|
206
247
|
palette.bold(text.headTime),
|
|
207
|
-
...wrap(text.timeNote, WIDTH).map(line => palette.dim(line)),
|
|
208
|
-
...table([
|
|
248
|
+
...(0, terminal_1.wrap)(text.timeNote, terminal_1.WIDTH).map(line => palette.dim(line)),
|
|
249
|
+
...(0, terminal_1.table)([
|
|
209
250
|
{ head: columns.profile, right: false },
|
|
210
251
|
{ head: columns.transfer, right: true },
|
|
211
252
|
{ head: columns.latency, right: true },
|
|
@@ -224,24 +265,25 @@ const budgetBlock = (report, palette) => {
|
|
|
224
265
|
// `--project` there is nothing to say a budget is missing from.
|
|
225
266
|
const asking = new Set(['budgetNone', 'budgetTooHigh', 'budgetWarnOnly']);
|
|
226
267
|
const wanted = report.findings.some(finding => asking.has(finding.kind));
|
|
227
|
-
const advice = wanted ? (0, budget_advice_1.budgetAdvice)(report.analysis.
|
|
268
|
+
const advice = wanted ? (0, budget_advice_1.budgetAdvice)(report.analysis.initialRawBytes) : null;
|
|
228
269
|
if (!advice) {
|
|
229
270
|
return [];
|
|
230
271
|
}
|
|
231
|
-
// The second budget, for a build that has screens: `anyScript` applies to every emitted file
|
|
232
|
-
// which is what makes it useful when the names carry hashes and `bundle`
|
|
233
|
-
|
|
234
|
-
const
|
|
272
|
+
// The second budget, for a build that has screens: `anyScript` applies to every emitted file —
|
|
273
|
+
// the bootstrap's too — which is what makes it useful when the names carry hashes and `bundle`
|
|
274
|
+
// budgets cannot, and why it is set above the largest script and not above a screen.
|
|
275
|
+
const largest = report.analysis.largestScript;
|
|
276
|
+
const perScreen = report.analysis.screens.length > 0 && largest ? (0, budget_advice_1.screenBudgetAdvice)(largest.bytes) : null;
|
|
235
277
|
return [
|
|
236
278
|
'',
|
|
237
279
|
palette.bold(text.headBudget),
|
|
238
|
-
...wrap(text.budgetNote(`${advice.warningKb}kB`, `${advice.errorKb}kB`, (0, format_utils_1.formatBytes)(advice.currentBytes)), WIDTH).map(line => palette.dim(line)),
|
|
280
|
+
...(0, terminal_1.wrap)(text.budgetNote(`${advice.warningKb}kB`, `${advice.errorKb}kB`, (0, format_utils_1.formatBytes)(advice.currentBytes)), terminal_1.WIDTH).map(line => palette.dim(line)),
|
|
239
281
|
'',
|
|
240
282
|
...advice.snippet.split('\n').map(line => ` ${line}`),
|
|
241
283
|
...(perScreen
|
|
242
284
|
? [
|
|
243
285
|
'',
|
|
244
|
-
...wrap(text.screenBudgetNote(`${perScreen.warningKb}kB
|
|
286
|
+
...(0, terminal_1.wrap)(text.screenBudgetNote(`${perScreen.warningKb}kB`, largest?.name ?? '', (0, format_utils_1.formatBytes)(perScreen.currentBytes)), terminal_1.WIDTH).map(line => palette.dim(line)),
|
|
245
287
|
...perScreen.snippet.split('\n').map(line => ` ${line}`),
|
|
246
288
|
]
|
|
247
289
|
: []),
|
|
@@ -272,38 +314,6 @@ const acceptedBlock = (report, palette) => {
|
|
|
272
314
|
});
|
|
273
315
|
return ['', palette.bold(text.headAccepted), ...lines];
|
|
274
316
|
};
|
|
275
|
-
/**
|
|
276
|
-
* "What would the first load weigh without this?", for each name asked about.
|
|
277
|
-
*
|
|
278
|
-
* The saving is exact — the graph walked without those files — and the note under it says what is
|
|
279
|
-
* deliberately not recomputed, because a simulated re-chunking would produce round trips that look
|
|
280
|
-
* exactly like the measured ones and are not.
|
|
281
|
-
*/
|
|
282
|
-
const whatIfBlock = (report, palette) => {
|
|
283
|
-
if (report.whatIf.length === 0) {
|
|
284
|
-
return [];
|
|
285
|
-
}
|
|
286
|
-
const text = text_1.CLI_TEXT[report.lang];
|
|
287
|
-
const rows = report.whatIf.map(result => [
|
|
288
|
-
result.target,
|
|
289
|
-
(0, format_utils_1.formatBytes)(result.weight),
|
|
290
|
-
palette.bold((0, format_utils_1.formatBytes)(result.saved)),
|
|
291
|
-
(0, format_utils_1.formatBytes)(result.after),
|
|
292
|
-
result.screens.length > 0 ? result.screens.join(', ') : text.whatIfNobody,
|
|
293
|
-
]);
|
|
294
|
-
return [
|
|
295
|
-
'',
|
|
296
|
-
palette.bold(text.headWhatIf),
|
|
297
|
-
...wrap(text.whatIfNote, WIDTH).map(line => palette.dim(line)),
|
|
298
|
-
...table([
|
|
299
|
-
{ head: text.colWhatIf, right: false },
|
|
300
|
-
{ head: text.colSize, right: true },
|
|
301
|
-
{ head: text.colSaving, right: true },
|
|
302
|
-
{ head: text.colAfter, right: true },
|
|
303
|
-
{ head: text.colWhoPays, right: false },
|
|
304
|
-
], rows, palette),
|
|
305
|
-
];
|
|
306
|
-
};
|
|
307
317
|
const gateBlock = (violations, anyAsked, report, palette) => {
|
|
308
318
|
const text = text_1.CLI_TEXT[report.lang];
|
|
309
319
|
if (!anyAsked) {
|
|
@@ -325,17 +335,36 @@ const header = (report, palette) => {
|
|
|
325
335
|
const text = text_1.CLI_TEXT[report.lang];
|
|
326
336
|
const lines = [
|
|
327
337
|
palette.bold(report.projectName ? `Loadline · ${report.projectName}` : 'Loadline'),
|
|
328
|
-
palette.dim(text.lead(report.statsName, report.unit)),
|
|
338
|
+
palette.dim(text.lead(report.statsName, report.unit, (0, tool_1.toolLabel)(report.analysis.tool))),
|
|
329
339
|
];
|
|
330
340
|
if (report.comparison) {
|
|
331
341
|
lines.push(palette.dim(text.against(report.comparison.baselineName, report.comparison.baselineDate.slice(0, 10))));
|
|
332
342
|
}
|
|
333
343
|
if (report.comparisonBlocked) {
|
|
334
|
-
lines.push(palette.warn(text.blocked));
|
|
344
|
+
lines.push(palette.warn(text.blocked(report.baselineMode ?? 'raw', report.mode)));
|
|
345
|
+
}
|
|
346
|
+
if (report.located.length > 0) {
|
|
347
|
+
lines.push(palette.dim(text.located(report.located.join(' + '))));
|
|
348
|
+
}
|
|
349
|
+
const since = (0, since_last_1.sinceLastLine)(report);
|
|
350
|
+
if (since) {
|
|
351
|
+
lines.push(palette.bold(since));
|
|
335
352
|
}
|
|
336
353
|
if (report.analysis.splitSource === 'sourcemap') {
|
|
337
354
|
lines.push(palette.dim(text.exactSplit));
|
|
338
355
|
}
|
|
356
|
+
// In the lead and in warning colour: it changes how every figure below is read, and the signal
|
|
357
|
+
// that explains it is several cards down, where it was the only place it was said.
|
|
358
|
+
const unseen = (0, defer_1.opaqueBootChunks)(report.analysis);
|
|
359
|
+
if ((0, defer_1.blindBoot)(report.analysis)) {
|
|
360
|
+
lines.push(...(0, terminal_1.wrap)(text.opaque, terminal_1.WIDTH).map(line => palette.warn(line)));
|
|
361
|
+
}
|
|
362
|
+
else if (unseen.length > 0) {
|
|
363
|
+
// One chunk without its map in a folder that has them: named, with its weight, so it is
|
|
364
|
+
// read as the corner it is and not as the whole report going blind.
|
|
365
|
+
const named = unseen.map(chunk => `${(0, format_utils_1.baseName)(chunk)} (${(0, format_utils_1.formatBytes)(report.analysis.chunkOf(chunk)?.bytes ?? 0)})`);
|
|
366
|
+
lines.push(...(0, terminal_1.wrap)(text.opaqueSome(named.join(', '), unseen.length), terminal_1.WIDTH).map(line => palette.dim(line)));
|
|
367
|
+
}
|
|
339
368
|
// Which file the thresholds came from. A run judged by a committed file and one judged by the
|
|
340
369
|
// recommended values are different runs, and the log should not leave that to be guessed.
|
|
341
370
|
if (report.configName) {
|
|
@@ -346,10 +375,20 @@ const header = (report, palette) => {
|
|
|
346
375
|
if (report.analysis.serverOutputs > 0) {
|
|
347
376
|
lines.push(palette.dim(text.serverLeftOut(report.analysis.serverOutputs)));
|
|
348
377
|
}
|
|
378
|
+
// And the other reason the metafile names files the folder does not hold. Said once, so the
|
|
379
|
+
// difference between the two is explained rather than left for somebody to count by hand.
|
|
380
|
+
if (report.analysis.componentStyles > 0) {
|
|
381
|
+
lines.push(palette.dim(text.componentStyles(report.analysis.componentStyles)));
|
|
382
|
+
}
|
|
383
|
+
// A folder holds files the page never downloads as part of a screen, and the reader found them.
|
|
384
|
+
const { offPage } = report.analysis;
|
|
385
|
+
if (offPage.legacy + offPage.serviceWorker + offPage.server + offPage.ignored > 0) {
|
|
386
|
+
lines.push(palette.dim(text.offPageLeftOut(offPage)));
|
|
387
|
+
}
|
|
349
388
|
return lines;
|
|
350
389
|
};
|
|
351
390
|
const renderText = (report, violations, anyAsked, color) => {
|
|
352
|
-
const palette = paletteOf(color);
|
|
391
|
+
const palette = (0, terminal_1.paletteOf)(color);
|
|
353
392
|
const text = text_1.CLI_TEXT[report.lang];
|
|
354
393
|
const strings = ui_1.UI[report.lang];
|
|
355
394
|
const { analysis, criteria } = report;
|
|
@@ -372,14 +411,17 @@ const renderText = (report, violations, anyAsked, color) => {
|
|
|
372
411
|
'',
|
|
373
412
|
palette.bold(text.headScreens),
|
|
374
413
|
...(analysis.screens.length > 0 ? screensTable(report, palette) : [palette.dim(text.noScreens)]),
|
|
414
|
+
...notScreenLines(report, palette),
|
|
415
|
+
...routeCssLines(report, palette),
|
|
375
416
|
'',
|
|
376
417
|
...actionsBlock(report, palette),
|
|
377
418
|
...timeBlock(report, palette),
|
|
378
419
|
...budgetBlock(report, palette),
|
|
379
420
|
'',
|
|
380
421
|
palette.bold(text.headSignals),
|
|
381
|
-
...report.findings.flatMap(finding => signalBlock(finding, palette, text.fix)),
|
|
382
|
-
...whatIfBlock(report, palette),
|
|
422
|
+
...report.findings.flatMap(finding => signalBlock(finding, palette, text.fix, text.severity)),
|
|
423
|
+
...(0, render_asked_1.whatIfBlock)(report, palette),
|
|
424
|
+
...(0, render_asked_1.whyBlock)(report, palette),
|
|
383
425
|
...acceptedBlock(report, palette),
|
|
384
426
|
...gateBlock(violations, anyAsked, report, palette),
|
|
385
427
|
'',
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What every block of the terminal report is drawn with: the width, the colours, wrapping and
|
|
4
|
+
* tables. Apart from the blocks so that more than one file can draw one.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.table = exports.wrap = exports.pad = exports.visible = exports.paletteOf = exports.WIDTH = void 0;
|
|
8
|
+
exports.WIDTH = 96;
|
|
9
|
+
const ESC = String.fromCodePoint(27);
|
|
10
|
+
const ANSI = new RegExp(String.raw `${ESC}\[\d+m`, 'g');
|
|
11
|
+
const code = (open) => value => `${ESC}[${open}m${value}${ESC}[0m`;
|
|
12
|
+
const plain = value => value;
|
|
13
|
+
const paletteOf = (color) => color
|
|
14
|
+
? { bold: code(1), dim: code(90), good: code(32), warn: code(33), bad: code(31) }
|
|
15
|
+
: { bold: plain, dim: plain, good: plain, warn: plain, bad: plain };
|
|
16
|
+
exports.paletteOf = paletteOf;
|
|
17
|
+
/** Length as the terminal shows it: padding a coloured string by its raw length breaks the column. */
|
|
18
|
+
const visible = (value) => value.replaceAll(ANSI, '').length;
|
|
19
|
+
exports.visible = visible;
|
|
20
|
+
const pad = (value, width, right) => {
|
|
21
|
+
const filler = ' '.repeat(Math.max(0, width - (0, exports.visible)(value)));
|
|
22
|
+
return right ? `${filler}${value}` : `${value}${filler}`;
|
|
23
|
+
};
|
|
24
|
+
exports.pad = pad;
|
|
25
|
+
/** Wraps at word boundaries. A signal is a sentence, and a sentence cut mid-word is harder to read. */
|
|
26
|
+
const wrap = (value, width) => {
|
|
27
|
+
const lines = [];
|
|
28
|
+
const words = value.split(/\s+/).filter(Boolean);
|
|
29
|
+
let current = '';
|
|
30
|
+
for (const word of words) {
|
|
31
|
+
if (current && current.length + word.length + 1 > width) {
|
|
32
|
+
lines.push(current);
|
|
33
|
+
current = word;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
current = current ? `${current} ${word}` : word;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (current) {
|
|
40
|
+
lines.push(current);
|
|
41
|
+
}
|
|
42
|
+
return lines;
|
|
43
|
+
};
|
|
44
|
+
exports.wrap = wrap;
|
|
45
|
+
/** A table sized to its own content: nothing truncated, nothing padded to a guess. */
|
|
46
|
+
const table = (columns, rows, palette) => {
|
|
47
|
+
const widths = columns.map((column, index) => Math.max(column.head.length, ...rows.map(row => (0, exports.visible)(row[index] ?? ''))));
|
|
48
|
+
const line = (cells) => cells.map((value, index) => (0, exports.pad)(value, widths[index] ?? 0, columns[index]?.right ?? false)).join(' ');
|
|
49
|
+
return [
|
|
50
|
+
palette.dim(line(columns.map(column => column.head))),
|
|
51
|
+
palette.dim(widths.map(width => '-'.repeat(width)).join(' ')),
|
|
52
|
+
...rows.map(row => line(row)),
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
exports.table = table;
|