@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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What to read when the command is pointed at the root of a build rather than at one of its files.
|
|
4
|
+
*
|
|
5
|
+
* `ng build` writes `dist/<app>/browser/` and, with `--stats-json`, the metafile next to it — called
|
|
6
|
+
* `stats.json` up to Angular 22.1 and `browser-stats.json` from 22.2, when the server half got a file
|
|
7
|
+
* of its own (`server-stats.json`). Read in @angular/build itself: 22.1.8 writes `stats.json` with or
|
|
8
|
+
* without a server, 22.2.0 writes `browser-stats.json` even when there is none. Asking for both paths by hand was the first thing anybody had to get right, and the
|
|
9
|
+
* README naming only the old file sent people looking for something that was not there. Pointed at
|
|
10
|
+
* `dist/<app>`, the command now finds both on its own and says which it found.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.locateBuild = void 0;
|
|
14
|
+
const promises_1 = require("node:fs/promises");
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const index_html_1 = require("../../src/app/core/build-text/index-html");
|
|
17
|
+
const dist_files_1 = require("../../src/app/core/intake/dist-files");
|
|
18
|
+
const read_build_1 = require("./read-build");
|
|
19
|
+
/**
|
|
20
|
+
* The stats files' names that mark a folder as a build. Vue CLI's `report.json` is looked for only
|
|
21
|
+
* inside the folder that was named: a name this plain is no sign of a build anywhere else.
|
|
22
|
+
*/
|
|
23
|
+
const MARKS_A_BUILD = dist_files_1.STATS_NAMES.filter(name => name !== 'report.json');
|
|
24
|
+
/**
|
|
25
|
+
* Folders no build is written to, and the ones that make the walk slow. `public/` and `static/`
|
|
26
|
+
* hold the files a build copies, an `index.html` template among them; `src/` holds the code.
|
|
27
|
+
*/
|
|
28
|
+
const NOT_A_BUILD = new Set(['node_modules', 'src', 'public', 'static', 'e2e', 'test', 'tests', 'coverage']);
|
|
29
|
+
/**
|
|
30
|
+
* How deep under a project a build is looked for: `dist/<app>/browser`, `build/esm-bundled`, and a
|
|
31
|
+
* workspace's `apps/admin/dist`, which at three was one level out of reach: `loadline .` at the root
|
|
32
|
+
* of a monorepo said there was no build in it.
|
|
33
|
+
*/
|
|
34
|
+
const BUILD_DEPTH = 4;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a folder is walked into. Nitro's `.output/public` is a build although it is called
|
|
37
|
+
* `public`: Nuxt writes the site there, and `loadline .` in a Nuxt project found nothing.
|
|
38
|
+
*/
|
|
39
|
+
const walked = (parent, name) => (!name.startsWith('.') || name === '.output') &&
|
|
40
|
+
(!NOT_A_BUILD.has(name) || (name === 'public' && (0, node_path_1.basename)(parent) === '.output'));
|
|
41
|
+
const isFile = async (path) => {
|
|
42
|
+
try {
|
|
43
|
+
const info = await (0, promises_1.stat)(path);
|
|
44
|
+
return info.isFile();
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const isDirectory = async (path) => {
|
|
51
|
+
try {
|
|
52
|
+
const info = await (0, promises_1.stat)(path);
|
|
53
|
+
return info.isDirectory();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A folder that is a build: a metafile in it, or a page naming a script that is there below it.
|
|
61
|
+
*
|
|
62
|
+
* The page has to name one. A folder of sources with an `index.html` template is no build — ember's
|
|
63
|
+
* `app/` names `{{rootURL}}assets/vendor.js`, which nothing below it is, and Vite's root names
|
|
64
|
+
* `/src/main.ts` — and taken for one it was offered as "also found".
|
|
65
|
+
*/
|
|
66
|
+
const isBuild = async (folder, names) => {
|
|
67
|
+
if (MARKS_A_BUILD.some(name => names.includes(name))) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
const page = names.find(name => /^index(?:\.[\w-]+)?\.html$/i.test(name));
|
|
71
|
+
if (!page) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const scripts = (0, index_html_1.scriptsIn)(await (0, promises_1.readFile)((0, node_path_1.join)(folder, page), 'utf8'));
|
|
76
|
+
const named = new Set([...scripts.names, ...scripts.entries, ...scripts.legacy]);
|
|
77
|
+
const below = await (0, promises_1.readdir)(folder, { recursive: true });
|
|
78
|
+
return below.some(path => named.has((0, node_path_1.basename)(path)) && !path.includes('node_modules'));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Whether the page of a build starts it as ES modules: the build a current browser runs, when a
|
|
86
|
+
* project writes several at once — Polymer's `esm-bundled`, `es6-bundled` and `es5-bundled` come
|
|
87
|
+
* out of one command within the same second, and which of them was read was down to the clock.
|
|
88
|
+
*/
|
|
89
|
+
const servesModules = async (folder) => {
|
|
90
|
+
try {
|
|
91
|
+
return /<script\s[^>]*\btype\s*=\s*["']?module/i.test(await (0, promises_1.readFile)((0, node_path_1.join)(folder, 'index.html'), 'utf8'));
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
/** Builds written this close together were written by one command: the time does not choose between them. */
|
|
98
|
+
const SAME_BUILD_MS = 5000;
|
|
99
|
+
/** When the page or the metafile of a build was last written: the newest build is the one meant. */
|
|
100
|
+
const writtenAt = async (folder, names) => {
|
|
101
|
+
const marker = [...MARKS_A_BUILD, 'index.html'].find(name => names.includes(name));
|
|
102
|
+
if (!marker) {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const info = await (0, promises_1.stat)((0, node_path_1.join)(folder, marker));
|
|
107
|
+
return info.mtimeMs;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The builds inside a project folder, newest first.
|
|
115
|
+
*
|
|
116
|
+
* `loadline .` in the root of a project is the first thing anybody types, and it read the project as
|
|
117
|
+
* a build: a walk through `node_modules` that took 51 seconds on an Angular 8 project, then the
|
|
118
|
+
* `index.html` template of the root — or none — and a message saying the folder had no page. A build
|
|
119
|
+
* is wherever a page sits with scripts beside it, or a metafile, whatever the tool called the folder:
|
|
120
|
+
* `dist`, `build`, `www`, `out`, `__sapper__/export`, `dist/<app>`, `build/esm-bundled`. Not a list
|
|
121
|
+
* of names, so a tool that does not exist yet is found the same way.
|
|
122
|
+
*/
|
|
123
|
+
const buildsUnder = async (project) => {
|
|
124
|
+
const found = [];
|
|
125
|
+
let level = [project];
|
|
126
|
+
for (let depth = 0; depth < BUILD_DEPTH && level.length > 0; depth++) {
|
|
127
|
+
const next = [];
|
|
128
|
+
for (const folder of level) {
|
|
129
|
+
let entries;
|
|
130
|
+
try {
|
|
131
|
+
entries = await (0, promises_1.readdir)(folder, { withFileTypes: true });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const names = entries.filter(entry => entry.isFile()).map(entry => entry.name);
|
|
137
|
+
if (folder !== project && (await isBuild(folder, names))) {
|
|
138
|
+
found.push({ folder, at: await writtenAt(folder, names), modules: await servesModules(folder) });
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
for (const entry of entries) {
|
|
142
|
+
if (entry.isDirectory() && walked(folder, entry.name)) {
|
|
143
|
+
next.push((0, node_path_1.join)(folder, entry.name));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
level = next;
|
|
148
|
+
}
|
|
149
|
+
const newest = Math.max(...found.map(entry => entry.at));
|
|
150
|
+
const recent = (entry) => newest - entry.at < SAME_BUILD_MS;
|
|
151
|
+
// The builds of the last command first, the one a current browser runs first among them, then
|
|
152
|
+
// the rest by age; the path settles what is left, so the same folders always give the same answer.
|
|
153
|
+
return found
|
|
154
|
+
.toSorted((a, b) => Number(recent(b)) - Number(recent(a)) ||
|
|
155
|
+
(recent(a) ? Number(b.modules) - Number(a.modules) : 0) ||
|
|
156
|
+
b.at - a.at ||
|
|
157
|
+
a.folder.localeCompare(b.folder))
|
|
158
|
+
.map(entry => entry.folder);
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* @param target what was typed: a metafile, a browser folder or the root of a build.
|
|
162
|
+
* @param dist `--dist`, when it was given. Anything typed by hand wins: nothing is looked up then.
|
|
163
|
+
*/
|
|
164
|
+
const locateBuild = async (target, dist) => {
|
|
165
|
+
// The page of the build named instead of its folder: what was meant is the folder it sits in,
|
|
166
|
+
// and reading the HTML as a stats file answered "is not valid JSON".
|
|
167
|
+
if (!dist && /\.html?$/i.test(target) && (await isFile(target))) {
|
|
168
|
+
const folder = (0, node_path_1.dirname)(target);
|
|
169
|
+
const located = await (0, exports.locateBuild)(folder, null);
|
|
170
|
+
return { ...located, found: located.found.length > 0 ? located.found : [folder] };
|
|
171
|
+
}
|
|
172
|
+
if (dist || !(await isDirectory(target))) {
|
|
173
|
+
return { target, dist, found: [] };
|
|
174
|
+
}
|
|
175
|
+
const browser = (0, node_path_1.join)(target, 'browser');
|
|
176
|
+
const hasBrowser = await isDirectory(browser);
|
|
177
|
+
let stats = null;
|
|
178
|
+
for (const name of dist_files_1.STATS_NAMES) {
|
|
179
|
+
const candidate = (0, node_path_1.join)(target, name);
|
|
180
|
+
if (await isFile(candidate)) {
|
|
181
|
+
stats = candidate;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (stats) {
|
|
186
|
+
// webpack writes its stats inside the folder it builds — Angular 8 `dist/stats-es2015.json`,
|
|
187
|
+
// Create React App `build/bundle-stats.json` — and that folder is the one to weigh. Taken
|
|
188
|
+
// for a folder with nothing but the stats in it, an Angular 8 build was read in raw bytes.
|
|
189
|
+
const home = (await isFile((0, node_path_1.join)(target, 'index.html'))) ? target : null;
|
|
190
|
+
const folder = hasBrowser ? browser : home;
|
|
191
|
+
return { target: stats, dist: folder, found: folder ? [stats, folder] : [stats] };
|
|
192
|
+
}
|
|
193
|
+
// No metafile: the browser folder is read as a graph, the way a folder always has been.
|
|
194
|
+
if (hasBrowser) {
|
|
195
|
+
return { target: browser, dist: null, found: [browser] };
|
|
196
|
+
}
|
|
197
|
+
// The root of a project rather than of a build: the build is somewhere inside it.
|
|
198
|
+
if (await isFile((0, node_path_1.join)(target, 'package.json'))) {
|
|
199
|
+
const [newest, ...others] = await buildsUnder(target);
|
|
200
|
+
if (newest) {
|
|
201
|
+
const located = await (0, exports.locateBuild)(newest, null);
|
|
202
|
+
return {
|
|
203
|
+
...located,
|
|
204
|
+
found: located.found.length > 0 ? located.found : [newest],
|
|
205
|
+
...(others.length > 0 && { others }),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (!(await isFile((0, node_path_1.join)(target, 'index.html'))) || (await isDirectory((0, node_path_1.join)(target, 'node_modules')))) {
|
|
209
|
+
throw new read_build_1.InputError(t => t.projectNotBuilt(target));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return { target, dist, found: [] };
|
|
213
|
+
};
|
|
214
|
+
exports.locateBuild = locateBuild;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* the terminal stays in one file.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.readCriteria = exports.readProject = exports.readBaseline = exports.readDepsFiles = exports.readDist = exports.isFolder = exports.readStats = exports.
|
|
8
|
+
exports.readCriteria = exports.readProject = exports.readBaseline = exports.nearestPackageName = exports.readDepsFiles = exports.readDist = exports.isFolder = exports.readStats = exports.readJson = exports.exists = exports.InputError = void 0;
|
|
9
9
|
const node_crypto_1 = require("node:crypto");
|
|
10
10
|
const node_fs_1 = require("node:fs");
|
|
11
11
|
const promises_1 = require("node:fs/promises");
|
|
@@ -13,41 +13,36 @@ const node_path_1 = require("node:path");
|
|
|
13
13
|
const node_stream_1 = require("node:stream");
|
|
14
14
|
const promises_2 = require("node:stream/promises");
|
|
15
15
|
const node_zlib_1 = require("node:zlib");
|
|
16
|
-
const analysis_1 = require("
|
|
17
|
-
const metafile_types_1 = require("
|
|
18
|
-
const sourcemap_1 = require("
|
|
19
|
-
const assets_1 = require("
|
|
20
|
-
const baseline_1 = require("
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
16
|
+
const analysis_1 = require("../../src/app/core/analysis/analysis");
|
|
17
|
+
const metafile_types_1 = require("../../src/app/core/analysis/metafile.types");
|
|
18
|
+
const sourcemap_1 = require("../../src/app/core/analysis/sourcemap/sourcemap");
|
|
19
|
+
const assets_1 = require("../../src/app/core/assets/assets");
|
|
20
|
+
const baseline_1 = require("../../src/app/core/baseline/baseline");
|
|
21
|
+
const index_html_1 = require("../../src/app/core/build-text/index-html");
|
|
22
|
+
const config_text_1 = require("../../src/app/core/config/config-text");
|
|
23
|
+
const config_values_1 = require("../../src/app/core/config/config-values");
|
|
24
|
+
const loadline_config_1 = require("../../src/app/core/config/loadline-config");
|
|
25
|
+
const deps_1 = require("../../src/app/core/deps/deps");
|
|
26
|
+
const bundle_graph_1 = require("../../src/app/core/intake/bundle-graph");
|
|
27
|
+
const dist_files_1 = require("../../src/app/core/intake/dist-files");
|
|
28
|
+
const webpack_stats_1 = require("../../src/app/core/intake/webpack-stats");
|
|
29
|
+
const project_context_1 = require("../../src/app/core/project/project-context");
|
|
30
|
+
const report_messages_utils_1 = require("../../src/app/state/report-messages.utils");
|
|
31
|
+
const text_errors_1 = require("../text/text-errors");
|
|
29
32
|
/** Something the person can fix by editing the command line, as opposed to a bug in the tool. */
|
|
30
|
-
class InputError extends Error {
|
|
31
|
-
}
|
|
32
|
-
exports.InputError = InputError;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* Found rather than required on purpose: the file is meant to be committed next to the code, and a
|
|
37
|
-
* tool that only reads its configuration when told to is a tool whose configuration drifts. An
|
|
38
|
-
* explicit `--config` that does not exist **is** an error — somebody asked for a file — while a
|
|
39
|
-
* missing one in the working directory is simply the ordinary case.
|
|
34
|
+
* A failure of what was given, not of Loadline: exit 2. `say` words it in the language of the run,
|
|
35
|
+
* and `message` is the English, for anything that prints an error without asking which language.
|
|
40
36
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
class InputError extends Error {
|
|
38
|
+
say;
|
|
39
|
+
constructor(say) {
|
|
40
|
+
const said = typeof say === 'string' ? () => say : say;
|
|
41
|
+
super(said(text_errors_1.ERROR_TEXT.en));
|
|
42
|
+
this.say = said;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return { config, problems, name: config ? path : null };
|
|
49
|
-
};
|
|
50
|
-
exports.readLoadlineConfig = readLoadlineConfig;
|
|
44
|
+
}
|
|
45
|
+
exports.InputError = InputError;
|
|
51
46
|
const exists = async (path) => {
|
|
52
47
|
try {
|
|
53
48
|
await (0, promises_1.stat)(path);
|
|
@@ -57,28 +52,30 @@ const exists = async (path) => {
|
|
|
57
52
|
return false;
|
|
58
53
|
}
|
|
59
54
|
};
|
|
55
|
+
exports.exists = exists;
|
|
60
56
|
const readJson = async (path) => {
|
|
61
57
|
let text;
|
|
62
58
|
try {
|
|
63
59
|
text = await (0, promises_1.readFile)(path, 'utf8');
|
|
64
60
|
}
|
|
65
61
|
catch {
|
|
66
|
-
throw new InputError(
|
|
62
|
+
throw new InputError(t => t.cannotRead(path));
|
|
67
63
|
}
|
|
68
64
|
try {
|
|
69
65
|
return JSON.parse(text);
|
|
70
66
|
}
|
|
71
67
|
catch {
|
|
72
|
-
throw new InputError(
|
|
68
|
+
throw new InputError(t => t.notJson(path));
|
|
73
69
|
}
|
|
74
70
|
};
|
|
71
|
+
exports.readJson = readJson;
|
|
75
72
|
const filesUnder = async (folder) => {
|
|
76
73
|
let entries;
|
|
77
74
|
try {
|
|
78
75
|
entries = await (0, promises_1.readdir)(folder, { withFileTypes: true, recursive: true });
|
|
79
76
|
}
|
|
80
77
|
catch {
|
|
81
|
-
throw new InputError(
|
|
78
|
+
throw new InputError(t => t.cannotReadFolder(folder));
|
|
82
79
|
}
|
|
83
80
|
return entries.filter(entry => entry.isFile()).map(entry => (0, node_path_1.join)(entry.parentPath, entry.name));
|
|
84
81
|
};
|
|
@@ -89,11 +86,12 @@ const filesUnder = async (folder) => {
|
|
|
89
86
|
* command used to answer all three with "not an esbuild metafile", which is true and useless.
|
|
90
87
|
*/
|
|
91
88
|
const readStats = async (path, t) => {
|
|
92
|
-
const parsed = await readJson(path);
|
|
93
|
-
|
|
89
|
+
const parsed = await (0, exports.readJson)(path);
|
|
90
|
+
const meta = (0, webpack_stats_1.metafileOf)(parsed);
|
|
91
|
+
if (!meta) {
|
|
94
92
|
throw new InputError(`${path}: ${(0, report_messages_utils_1.foreignMessage)((0, metafile_types_1.foreignFormat)(parsed), t)} ${t.errExpected}`);
|
|
95
93
|
}
|
|
96
|
-
return
|
|
94
|
+
return meta;
|
|
97
95
|
};
|
|
98
96
|
exports.readStats = readStats;
|
|
99
97
|
/** Whether what was named is a folder, which is what decides between the two ways of reading. */
|
|
@@ -142,28 +140,37 @@ const bundleFilesOf = (folder, paths) => Promise.all(paths.map(async (path) => {
|
|
|
142
140
|
* @param derive also read the import graph out of the chunks, for a build with no stats file. It
|
|
143
141
|
* reads every source map on the way, so the maps are never parsed twice.
|
|
144
142
|
*/
|
|
145
|
-
const readDist = async (folder, derive = false) => {
|
|
143
|
+
const readDist = async (folder, derive = false, hints = {}) => {
|
|
146
144
|
const paths = await filesUnder(folder);
|
|
147
145
|
const gzip = new Map();
|
|
148
|
-
const
|
|
146
|
+
const found = new Map();
|
|
147
|
+
// The same figures by path inside the folder, for the files that share a name with another.
|
|
148
|
+
const gzipByPath = new Map();
|
|
149
|
+
const foundByPath = new Map();
|
|
150
|
+
const inside = (path) => (0, node_path_1.relative)(folder, path).replaceAll('\\', '/');
|
|
149
151
|
for (const path of paths) {
|
|
150
152
|
const name = (0, node_path_1.basename)(path);
|
|
151
153
|
const compressed = /^(.*\.(?:m?js|css))\.(?:br|brotli)$/i.exec(name);
|
|
152
154
|
if (compressed?.[1]) {
|
|
153
155
|
const info = await (0, promises_1.stat)(path);
|
|
154
|
-
|
|
156
|
+
found.set(compressed[1], info.size);
|
|
157
|
+
foundByPath.set(inside(path).replace(/\.(?:br|brotli)$/i, ''), info.size);
|
|
155
158
|
}
|
|
156
159
|
else if (/\.(?:m?js|css)$/i.test(name)) {
|
|
157
|
-
|
|
160
|
+
const size = await gzipSizeOf(path);
|
|
161
|
+
gzip.set(name, size);
|
|
162
|
+
gzipByPath.set(inside(path), size);
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
if (gzip.size === 0) {
|
|
161
|
-
throw new InputError(
|
|
166
|
+
throw new InputError(t => t.noAssets(folder));
|
|
162
167
|
}
|
|
168
|
+
const brotli = (0, dist_files_1.withGzipFallback)(found, gzip);
|
|
163
169
|
// The page of the build says which chunks the browser asks for straight away, which is the one
|
|
164
170
|
// thing the import graph cannot work out on its own.
|
|
165
|
-
|
|
166
|
-
const
|
|
171
|
+
// Named by its path inside the folder, which is how `build.page` of `loadline.json` names it.
|
|
172
|
+
const page = (0, index_html_1.indexHtmlOf)(paths.map(path => ({ name: (0, node_path_1.basename)(path), path: (0, node_path_1.relative)(folder, path), file: path })), hints.page);
|
|
173
|
+
const html = page ? await (0, promises_1.readFile)(page.file, 'utf8') : null;
|
|
167
174
|
// What the page asks for besides the code. A render-blocking stylesheet is the strictest
|
|
168
175
|
// "downloaded before anything appears" there is, and it was the one thing the headline of this
|
|
169
176
|
// tool left out.
|
|
@@ -197,7 +204,7 @@ const readDist = async (folder, derive = false) => {
|
|
|
197
204
|
for (const path of paths) {
|
|
198
205
|
// Only what a duplicate would be: a font, a picture, a video. Hashing every chunk would
|
|
199
206
|
// compare files whose names already carry a content hash, which answers nothing.
|
|
200
|
-
const uninteresting = new Set(['script', '
|
|
207
|
+
const uninteresting = new Set(['script', 'map']);
|
|
201
208
|
if (uninteresting.has((0, assets_1.kindOf)((0, node_path_1.basename)(path)))) {
|
|
202
209
|
continue;
|
|
203
210
|
}
|
|
@@ -207,8 +214,10 @@ const readDist = async (folder, derive = false) => {
|
|
|
207
214
|
.update(await (0, promises_1.readFile)(path))
|
|
208
215
|
.digest('hex'));
|
|
209
216
|
}
|
|
210
|
-
const named = html
|
|
211
|
-
|
|
217
|
+
const named = html
|
|
218
|
+
? (0, index_html_1.assetsIn)(html)
|
|
219
|
+
: { referenced: [], preloaded: [], prefetched: [], hrefs: [], icons: [], alternates: [] };
|
|
220
|
+
const assetInput = {
|
|
212
221
|
files: assetFiles,
|
|
213
222
|
html,
|
|
214
223
|
texts,
|
|
@@ -216,15 +225,30 @@ const readDist = async (folder, derive = false) => {
|
|
|
216
225
|
inPage: new Set([...named.referenced, ...(html ? (0, index_html_1.announcedIn)(html) : []), ...(html ? (0, index_html_1.stylesIn)(html) : [])]),
|
|
217
226
|
preloaded: new Set(named.preloaded),
|
|
218
227
|
prefetched: new Set(named.prefetched),
|
|
228
|
+
icons: new Set(named.icons),
|
|
219
229
|
bootChunks: new Set(),
|
|
220
230
|
// The same figures the rest of the report is in, so the first trip and the headline are
|
|
221
231
|
// not the same bytes quoted in two units.
|
|
222
232
|
weigh: brotli.size > 0 ? brotli : gzip,
|
|
223
|
-
|
|
233
|
+
weighPath: brotli.size > 0 ? (0, dist_files_1.withGzipFallback)(foundByPath, gzipByPath) : gzipByPath,
|
|
234
|
+
};
|
|
235
|
+
const assets = (0, assets_1.readAssets)(assetInput);
|
|
236
|
+
// The first trip in every unit the folder can give, because which one the report is in is only
|
|
237
|
+
// decided later, by `--mode`.
|
|
238
|
+
// The scripts written inside the page, compressed the way the page itself would travel.
|
|
239
|
+
const inline = html ? (0, index_html_1.inlineScriptsIn)(html) : '';
|
|
240
|
+
const inlineBytes = inline
|
|
241
|
+
? { raw: Buffer.byteLength(inline), gzip: (0, node_zlib_1.gzipSync)(inline).length, brotli: (0, node_zlib_1.brotliCompressSync)(inline).length }
|
|
242
|
+
: { raw: 0, gzip: 0, brotli: 0 };
|
|
243
|
+
const firstTrips = {
|
|
244
|
+
raw: (0, assets_1.firstTripIn)(assetInput, null, null, inlineBytes.raw),
|
|
245
|
+
gzip: (0, assets_1.firstTripIn)(assetInput, gzip, gzipByPath, inlineBytes.gzip),
|
|
246
|
+
...(brotli.size > 0 && { brotli: (0, assets_1.firstTripIn)(assetInput, brotli, assetInput.weighPath, inlineBytes.brotli) }),
|
|
247
|
+
};
|
|
224
248
|
const bundle = derive ? await bundleFilesOf(folder, paths) : [];
|
|
225
|
-
const graph = derive ? await (0, bundle_graph_1.
|
|
249
|
+
const graph = derive ? await (0, bundle_graph_1.readFolderGraph)(bundle, html, hints) : null;
|
|
226
250
|
const mapped = paths
|
|
227
|
-
.filter(path => /\.m?js(
|
|
251
|
+
.filter(path => /\.m?js$/.test(path) || (0, sourcemap_1.isScriptMapName)(path))
|
|
228
252
|
.map(path => ({ name: (0, node_path_1.basename)(path), text: () => (0, promises_1.readFile)(path, 'utf8') }));
|
|
229
253
|
const splits = graph?.splits ?? (await (0, sourcemap_1.readSourceMaps)(mapped));
|
|
230
254
|
return {
|
|
@@ -235,13 +259,19 @@ const readDist = async (folder, derive = false) => {
|
|
|
235
259
|
graph,
|
|
236
260
|
pageCss,
|
|
237
261
|
assets,
|
|
262
|
+
firstTrips,
|
|
263
|
+
pageTitle: html ? (0, index_html_1.titleIn)(html) : null,
|
|
238
264
|
hrefs: named.hrefs,
|
|
239
265
|
pageOrigins: html ? (0, index_html_1.originsIn)(html) : null,
|
|
240
266
|
// The chunk texts are already in memory for the reference search; they are handed on rather
|
|
241
267
|
// than read a second time. The maps are read here for the same reason.
|
|
242
|
-
|
|
268
|
+
// The page too, for what its inline scripts carry: they are downloaded like any chunk.
|
|
269
|
+
texts: new Map([
|
|
270
|
+
...[...texts].filter(([name]) => /\.(?:m?js|css)$/i.test(name)),
|
|
271
|
+
...(page && html ? [[page.name, html]] : []),
|
|
272
|
+
]),
|
|
243
273
|
maps: await Promise.all(paths
|
|
244
|
-
.filter(path =>
|
|
274
|
+
.filter(path => (0, sourcemap_1.isScriptMapName)(path))
|
|
245
275
|
.map(async (path) => ({ name: (0, node_path_1.basename)(path), text: await (0, promises_1.readFile)(path, 'utf8') }))),
|
|
246
276
|
};
|
|
247
277
|
};
|
|
@@ -256,47 +286,84 @@ exports.readDist = readDist;
|
|
|
256
286
|
*/
|
|
257
287
|
const readDepsFiles = async (lockPath, auditPath) => {
|
|
258
288
|
let lock = null;
|
|
289
|
+
let lockDirect = null;
|
|
259
290
|
if (lockPath) {
|
|
260
291
|
const text = await (0, promises_1.readFile)(lockPath, 'utf8').catch(() => null);
|
|
261
292
|
if (text === null) {
|
|
262
|
-
throw new InputError(
|
|
293
|
+
throw new InputError(t => t.cannotRead(lockPath));
|
|
263
294
|
}
|
|
264
295
|
lock = (0, deps_1.readLock)((0, node_path_1.basename)(lockPath), text);
|
|
265
296
|
if (!lock) {
|
|
266
|
-
throw new InputError(
|
|
297
|
+
throw new InputError(t => t.notLock(lockPath));
|
|
267
298
|
}
|
|
299
|
+
// What the project asked for by name, from the package.json every lock file sits next to.
|
|
300
|
+
// Without it "shipped but never asked for" needed --project too, the help did not say so,
|
|
301
|
+
// and --lock on its own changed nothing anybody could see.
|
|
302
|
+
const manifest = await (0, promises_1.readFile)((0, node_path_1.join)((0, node_path_1.dirname)(lockPath), 'package.json'), 'utf8').catch(() => null);
|
|
303
|
+
const pkg = manifest === null ? null : (0, project_context_1.readPackageJson)(safeParse(manifest));
|
|
304
|
+
lockDirect = pkg ? pkg.dependencies : null;
|
|
268
305
|
}
|
|
269
306
|
let advisories = null;
|
|
270
307
|
if (auditPath) {
|
|
271
308
|
const text = await (0, promises_1.readFile)(auditPath, 'utf8').catch(() => null);
|
|
272
309
|
if (text === null) {
|
|
273
|
-
throw new InputError(
|
|
310
|
+
throw new InputError(t => t.cannotRead(auditPath));
|
|
274
311
|
}
|
|
275
312
|
advisories = (0, deps_1.readAudit)(text);
|
|
276
313
|
if (!advisories) {
|
|
277
|
-
throw new InputError(
|
|
314
|
+
throw new InputError(t => t.notAudit(auditPath));
|
|
278
315
|
}
|
|
279
316
|
}
|
|
280
|
-
return { lock, advisories };
|
|
317
|
+
return { lock, advisories, lockDirect };
|
|
281
318
|
};
|
|
282
319
|
exports.readDepsFiles = readDepsFiles;
|
|
320
|
+
/**
|
|
321
|
+
* The `name` of the `package.json` the build sits under, to call the report by. A few levels up and
|
|
322
|
+
* no further: a build lives inside its project — `dist/app/browser` — and a folder copied somewhere
|
|
323
|
+
* else would otherwise be named after whatever `package.json` the walk happened to reach.
|
|
324
|
+
*/
|
|
325
|
+
const nearestPackageName = async (from) => {
|
|
326
|
+
let folder = from;
|
|
327
|
+
for (let level = 0; level < 4; level++) {
|
|
328
|
+
const manifest = await (0, promises_1.readFile)((0, node_path_1.join)(folder, 'package.json'), 'utf8').catch(() => null);
|
|
329
|
+
if (manifest !== null) {
|
|
330
|
+
return (0, project_context_1.readPackageJson)(safeParse(manifest))?.name ?? null;
|
|
331
|
+
}
|
|
332
|
+
const parent = (0, node_path_1.dirname)(folder);
|
|
333
|
+
if (parent === folder) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
folder = parent;
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
};
|
|
340
|
+
exports.nearestPackageName = nearestPackageName;
|
|
341
|
+
const safeParse = (text) => {
|
|
342
|
+
try {
|
|
343
|
+
return JSON.parse(text);
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
};
|
|
283
349
|
/**
|
|
284
350
|
* The baseline: an analysis exported from Loadline, which carries the unit it was measured in, or a
|
|
285
351
|
* previous `stats.json`, which can only be compared raw because nothing there says what its files
|
|
286
352
|
* compressed to.
|
|
287
353
|
*/
|
|
288
354
|
const readBaseline = async (path) => {
|
|
289
|
-
const parsed = await readJson(path);
|
|
355
|
+
const parsed = await (0, exports.readJson)(path);
|
|
290
356
|
if ((0, baseline_1.isSnapshot)(parsed)) {
|
|
291
357
|
return parsed;
|
|
292
358
|
}
|
|
293
|
-
|
|
294
|
-
|
|
359
|
+
const meta = (0, webpack_stats_1.metafileOf)(parsed);
|
|
360
|
+
if (!meta) {
|
|
361
|
+
throw new InputError(t => t.notStats(path));
|
|
295
362
|
}
|
|
296
363
|
const info = await (0, promises_1.stat)(path);
|
|
297
364
|
// Named by the path it was given rather than by its file name: two builds compared in CI are
|
|
298
365
|
// both called stats.json, and "compared against stats.json" says nothing.
|
|
299
|
-
return (0, baseline_1.snapshotOf)((0, analysis_1.analyze)(
|
|
366
|
+
return (0, baseline_1.snapshotOf)((0, analysis_1.analyze)(meta, null), 'raw', path, info.mtime);
|
|
300
367
|
};
|
|
301
368
|
exports.readBaseline = readBaseline;
|
|
302
369
|
/**
|
|
@@ -322,16 +389,17 @@ const pipelinePaths = async (folder) => {
|
|
|
322
389
|
const found = [];
|
|
323
390
|
for (const name of PIPELINE_NAMES) {
|
|
324
391
|
const path = (0, node_path_1.join)(folder, name);
|
|
325
|
-
if (await exists(path)) {
|
|
392
|
+
if (await (0, exports.exists)(path)) {
|
|
326
393
|
found.push(path);
|
|
327
394
|
}
|
|
328
395
|
}
|
|
329
396
|
for (const segments of PIPELINE_FOLDERS) {
|
|
330
397
|
const directory = (0, node_path_1.join)(folder, ...segments);
|
|
331
|
-
if (await exists(directory)) {
|
|
332
|
-
|
|
333
|
-
found.push(...paths.filter(path => /\.ya?ml$/i.test(path)));
|
|
398
|
+
if (!(await (0, exports.exists)(directory))) {
|
|
399
|
+
continue;
|
|
334
400
|
}
|
|
401
|
+
const paths = await filesUnder(directory);
|
|
402
|
+
found.push(...paths.filter(path => /\.ya?ml$/i.test(path)));
|
|
335
403
|
}
|
|
336
404
|
return found;
|
|
337
405
|
};
|
|
@@ -343,40 +411,41 @@ const readProject = async (folder) => {
|
|
|
343
411
|
const angularPath = (0, node_path_1.join)(folder, 'angular.json');
|
|
344
412
|
const packagePath = (0, node_path_1.join)(folder, 'package.json');
|
|
345
413
|
// `package.json` first: the build commands of the pipeline resolve through its scripts.
|
|
346
|
-
const pkg = (await exists(packagePath)) ? (0, project_context_1.readPackageJson)(await readJson(packagePath)) : null;
|
|
347
|
-
const angular = (await exists(angularPath)) ? (0, project_context_1.readAngularJson)(await readJson(angularPath)) : null;
|
|
414
|
+
const pkg = (await (0, exports.exists)(packagePath)) ? (0, project_context_1.readPackageJson)(await (0, exports.readJson)(packagePath)) : null;
|
|
415
|
+
const angular = (await (0, exports.exists)(angularPath)) ? (0, project_context_1.readAngularJson)(await (0, exports.readJson)(angularPath)) : null;
|
|
348
416
|
const pipelines = [];
|
|
349
417
|
const paths = await pipelinePaths(folder);
|
|
350
418
|
for (const path of paths) {
|
|
351
419
|
pipelines.push((0, project_context_1.readPipeline)((0, node_path_1.basename)(path), await (0, promises_1.readFile)(path, 'utf8'), pkg?.scripts ?? {}));
|
|
352
420
|
}
|
|
353
421
|
if (!pkg && !angular && pipelines.length === 0) {
|
|
354
|
-
throw new InputError(
|
|
422
|
+
throw new InputError(t => t.noProject(folder));
|
|
355
423
|
}
|
|
356
424
|
return { ...project_context_1.EMPTY_CONTEXT, angular, pkg, pipelines };
|
|
357
425
|
};
|
|
358
426
|
exports.readProject = readProject;
|
|
359
427
|
/**
|
|
360
|
-
* A thresholds file: the same keys the page edits,
|
|
361
|
-
*
|
|
362
|
-
*
|
|
428
|
+
* A thresholds file: the same keys the page edits, either as a bare object or as the `criteria`
|
|
429
|
+
* block of a `loadline.json`. Values are written as in `loadline.json` — `"170kB"` or bytes,
|
|
430
|
+
* `"25%"` or a fraction. Every key is optional and replaces one recommended value; anything that
|
|
431
|
+
* cannot be read is rejected rather than ignored, because a typo that silently does nothing is the
|
|
432
|
+
* worst way for a gate to be wrong.
|
|
363
433
|
*/
|
|
364
|
-
const readCriteria = async (path) => {
|
|
365
|
-
const parsed = await readJson(path);
|
|
366
|
-
|
|
367
|
-
|
|
434
|
+
const readCriteria = async (path, lang = 'en') => {
|
|
435
|
+
const parsed = await (0, exports.readJson)(path);
|
|
436
|
+
const block = (0, loadline_config_1.isLoadlineConfig)(parsed) ? parsed.criteria : parsed;
|
|
437
|
+
if (!block || typeof block !== 'object' || Array.isArray(block)) {
|
|
438
|
+
throw new InputError(t => t.notThresholds(path));
|
|
368
439
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
criteria[key] = value;
|
|
440
|
+
// Without "the recommended value stays", which is what `loadline.json` does with a value it
|
|
441
|
+
// cannot read: here the run stops, and the sentence promised a report that never came.
|
|
442
|
+
const { criteria, problems } = (0, config_values_1.readCriteriaBlock)(block, {
|
|
443
|
+
...config_text_1.CONFIG_TEXT[lang],
|
|
444
|
+
recommendedStays: problem => problem,
|
|
445
|
+
});
|
|
446
|
+
if (problems[0]) {
|
|
447
|
+
throw new InputError(`${path}: ${problems[0]}`);
|
|
379
448
|
}
|
|
380
|
-
return criteria;
|
|
449
|
+
return criteria ?? {};
|
|
381
450
|
};
|
|
382
451
|
exports.readCriteria = readCriteria;
|