@bymaksym/loadline 0.1.0 → 1.0.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 +66 -7
- package/dist/cli/cli/args.js +33 -3
- package/dist/cli/cli/declared.js +52 -0
- package/dist/cli/cli/html-report.js +107 -0
- package/dist/cli/cli/locate.js +60 -0
- package/dist/cli/cli/main.js +118 -5
- package/dist/cli/cli/memory.js +78 -0
- package/dist/cli/cli/read-build.js +8 -4
- package/dist/cli/cli/render-json.js +8 -5
- package/dist/cli/cli/render-markdown.js +1 -1
- package/dist/cli/cli/render-pr.js +5 -3
- package/dist/cli/cli/render-sarif.js +3 -3
- package/dist/cli/cli/render-text.js +63 -28
- package/dist/cli/cli/report.js +9 -3
- package/dist/cli/cli/since-last.js +45 -0
- package/dist/cli/cli/text.js +54 -19
- package/dist/cli/src/app/core/analysis/analysis.js +8 -4
- package/dist/cli/src/app/core/analysis/barrels.js +9 -2
- package/dist/cli/src/app/core/analysis/entries.js +41 -6
- package/dist/cli/src/app/core/analysis/metafile.types.js +14 -6
- package/dist/cli/src/app/core/analysis/split-drift.js +12 -6
- package/dist/cli/src/app/core/assets/assets.js +4 -2
- package/dist/cli/src/app/core/caching/caching.js +3 -3
- package/dist/cli/src/app/core/deps/deps.js +37 -7
- package/dist/cli/src/app/core/deps/pins.js +63 -0
- package/dist/cli/src/app/core/export/summary.js +27 -9
- package/dist/cli/src/app/core/findings/actions.js +63 -6
- package/dist/cli/src/app/core/findings/assets.js +30 -5
- package/dist/cli/src/app/core/findings/boot-single.js +76 -0
- package/dist/cli/src/app/core/findings/caching.js +1 -1
- package/dist/cli/src/app/core/findings/dupes.js +65 -0
- package/dist/cli/src/app/core/findings/effort.js +2 -0
- package/dist/cli/src/app/core/findings/finding-html.js +14 -1
- package/dist/cli/src/app/core/findings/finding-text.js +104 -31
- package/dist/cli/src/app/core/findings/finding.types.js +1 -0
- package/dist/cli/src/app/core/findings/findings.js +22 -38
- package/dist/cli/src/app/core/findings/graph.js +4 -4
- package/dist/cli/src/app/core/findings/scan.js +13 -3
- package/dist/cli/src/app/core/findings/shipped.js +3 -5
- package/dist/cli/src/app/core/format/format.utils.js +16 -9
- package/dist/cli/src/app/core/i18n/en.js +108 -48
- package/dist/cli/src/app/core/i18n/es.js +114 -50
- package/dist/cli/src/app/core/intake/bundle-graph.js +6 -5
- package/dist/cli/src/app/core/intake/dist-files.js +5 -2
- package/dist/cli/src/app/core/intake/embedded.js +46 -0
- package/dist/cli/src/app/core/intake/index-html.js +66 -16
- package/dist/cli/src/app/core/project/budget-advice.js +14 -10
- package/dist/cli/src/app/core/project/project-context.js +74 -16
- package/dist/cli/src/app/core/scan/scan.js +59 -21
- package/dist/cli/src/app/core/scan/secrets.js +0 -0
- package/dist/cli/src/app/core/situation/situation.js +3 -4
- package/dist/cli/src/app/state/report-messages.utils.js +1 -4
- package/loadline.html +22 -24
- package/package.json +60 -30
|
@@ -51,19 +51,23 @@ const budgetAdvice = (initialRawBytes, headroom = 0.15) => {
|
|
|
51
51
|
};
|
|
52
52
|
exports.budgetAdvice = budgetAdvice;
|
|
53
53
|
/**
|
|
54
|
-
* The
|
|
54
|
+
* The budget on what any one script may weigh.
|
|
55
55
|
*
|
|
56
|
-
* Angular's `
|
|
57
|
-
*
|
|
58
|
-
* to
|
|
59
|
-
*
|
|
56
|
+
* Angular's `bundle` budgets are per named bundle, which hashed chunk names make useless. What is
|
|
57
|
+
* worth writing is `anyScript`, and **it applies to every script the build emits, the bootstrap's
|
|
58
|
+
* included**. It used to be suggested over the heaviest screen's own code — 20/30 kB on a build
|
|
59
|
+
* whose bootstrap chunks were 137 and 284 kB — which is a budget that fails the very next build on
|
|
60
|
+
* files nobody touched. It is suggested above the largest script instead, so that it starts green
|
|
61
|
+
* and fires when any file grows past what the biggest one is today.
|
|
62
|
+
*
|
|
63
|
+
* @param largestScriptRawBytes the heaviest script of the build, raw, wherever it lands.
|
|
60
64
|
*/
|
|
61
|
-
const screenBudgetAdvice = (
|
|
62
|
-
if (
|
|
65
|
+
const screenBudgetAdvice = (largestScriptRawBytes, headroom = 0.15) => {
|
|
66
|
+
if (largestScriptRawBytes <= 0) {
|
|
63
67
|
return null;
|
|
64
68
|
}
|
|
65
|
-
const warningKb = roundKb(
|
|
66
|
-
const errorKb = roundKb(
|
|
69
|
+
const warningKb = roundKb(largestScriptRawBytes * (1 + headroom));
|
|
70
|
+
const errorKb = roundKb(largestScriptRawBytes * (1 + headroom) * 1.3);
|
|
67
71
|
const snippet = [
|
|
68
72
|
'{',
|
|
69
73
|
' "type": "anyScript",',
|
|
@@ -71,6 +75,6 @@ const screenBudgetAdvice = (heaviestOwnRawBytes, headroom = 0.25) => {
|
|
|
71
75
|
` "maximumError": "${errorKb}kB"`,
|
|
72
76
|
'}',
|
|
73
77
|
].join('\n');
|
|
74
|
-
return { warningKb, errorKb, currentBytes:
|
|
78
|
+
return { warningKb, errorKb, currentBytes: largestScriptRawBytes, snippet };
|
|
75
79
|
};
|
|
76
80
|
exports.screenBudgetAdvice = screenBudgetAdvice;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* tolerant, and every guess is reported with the command it came from so it can be checked.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.pipelineKnown = exports.configurationBudgets = exports.readPipeline = exports.resolveBuildCommand = exports.isZoneless = exports.readPackageJson = exports.readAngularJson = exports.isInitialBudget = exports.parseSize = exports.EMPTY_CONTEXT = void 0;
|
|
14
|
+
exports.pipelineKnown = exports.configurationBudgets = exports.readPipeline = exports.resolveBuildCommand = exports.isZoneless = exports.readPackageJson = exports.repoPathOf = exports.repoPathsOf = exports.readAngularJson = exports.isInitialBudget = exports.parseSize = exports.EMPTY_CONTEXT = void 0;
|
|
15
15
|
exports.EMPTY_CONTEXT = { angular: null, pkg: null, pipelines: [] };
|
|
16
16
|
const KB = 1024;
|
|
17
17
|
const UNITS = { b: 1, kb: KB, mb: KB * KB, gb: KB * KB * KB };
|
|
@@ -26,7 +26,7 @@ const parseSize = (value) => {
|
|
|
26
26
|
if (typeof value !== 'string') {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
const match = /^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)
|
|
29
|
+
const match = /^\s*(\d+(?:\.\d+)?)\s*(?:(b|kb|mb|gb)\s*)?$/i.exec(value);
|
|
30
30
|
if (!match?.[1]) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
@@ -49,14 +49,38 @@ const readBudgets = (value) => {
|
|
|
49
49
|
/** The budgets that bound the initial download. `initial` is the one Angular CLI writes by default. */
|
|
50
50
|
const isInitialBudget = (budget) => budget.type === 'initial' || budget.type === 'all';
|
|
51
51
|
exports.isInitialBudget = isInitialBudget;
|
|
52
|
+
const trimSlashes = (path) => path.replaceAll('\\', '/').replaceAll(/^\.?\/+|\/+$/g, '');
|
|
53
|
+
/**
|
|
54
|
+
* `build.options.assets`, in both spellings Angular accepts: a path, copied to the same path under
|
|
55
|
+
* the output (`src/assets` → `assets/`, the old default), or `{ glob, input, output }`, copied from
|
|
56
|
+
* `input` to `output` (a `glob` over `public`, landing at the root, the default since v17).
|
|
57
|
+
*/
|
|
58
|
+
const assetFoldersOf = (assets) => {
|
|
59
|
+
if (!Array.isArray(assets)) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
return assets.flatMap((entry) => {
|
|
63
|
+
if (typeof entry === 'string') {
|
|
64
|
+
const input = trimSlashes(entry);
|
|
65
|
+
// `src/assets` lands as `assets`: Angular drops the source root from a plain path.
|
|
66
|
+
return input ? [{ input, output: input.replace(/^src\//, '') }] : [];
|
|
67
|
+
}
|
|
68
|
+
if (entry && typeof entry === 'object') {
|
|
69
|
+
const { input, output } = entry;
|
|
70
|
+
return typeof input === 'string'
|
|
71
|
+
? [{ input: trimSlashes(input), output: typeof output === 'string' ? trimSlashes(output) : '' }]
|
|
72
|
+
: [];
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
});
|
|
76
|
+
};
|
|
52
77
|
const polyfillsHaveZone = (polyfills) => {
|
|
53
78
|
if (typeof polyfills === 'string') {
|
|
54
79
|
return polyfills.includes('zone.js');
|
|
55
80
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return null;
|
|
81
|
+
return Array.isArray(polyfills)
|
|
82
|
+
? polyfills.some(entry => typeof entry === 'string' && entry.includes('zone.js'))
|
|
83
|
+
: null;
|
|
60
84
|
};
|
|
61
85
|
/**
|
|
62
86
|
* Reads one application of an `angular.json`, and lists the rest.
|
|
@@ -100,9 +124,44 @@ const readAngularJson = (json, pick = null) => {
|
|
|
100
124
|
configurations,
|
|
101
125
|
defaultConfiguration: typeof build.defaultConfiguration === 'string' ? build.defaultConfiguration : null,
|
|
102
126
|
zonePolyfill: polyfillsHaveZone(build.options?.polyfills),
|
|
127
|
+
assetFolders: assetFoldersOf(build.options?.assets),
|
|
103
128
|
};
|
|
104
129
|
};
|
|
105
130
|
exports.readAngularJson = readAngularJson;
|
|
131
|
+
/**
|
|
132
|
+
* Where in the repository a file of the build folder comes from, when an `assets` entry of
|
|
133
|
+
* `angular.json` copies it there. Unverified on its own: the page has `angular.json` and not the
|
|
134
|
+
* repository, so it says "comes from"; the command can look on disk and drop what is not there.
|
|
135
|
+
*
|
|
136
|
+
* @param path the file's path inside the build folder, `/`-separated.
|
|
137
|
+
*/
|
|
138
|
+
const repoPathsOf = (files, folders) => {
|
|
139
|
+
if (folders.length === 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const found = new Map();
|
|
143
|
+
for (const { path } of files) {
|
|
144
|
+
const repo = (0, exports.repoPathOf)(path, folders);
|
|
145
|
+
if (repo) {
|
|
146
|
+
found.set(path, repo);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return found;
|
|
150
|
+
};
|
|
151
|
+
exports.repoPathsOf = repoPathsOf;
|
|
152
|
+
const repoPathOf = (path, folders) => {
|
|
153
|
+
const clean = trimSlashes(path);
|
|
154
|
+
// The most specific folder first: `assets/icons` before the root.
|
|
155
|
+
const match = folders
|
|
156
|
+
.filter(folder => folder.output === '' || clean === folder.output || clean.startsWith(`${folder.output}/`))
|
|
157
|
+
.toSorted((a, b) => b.output.length - a.output.length)[0];
|
|
158
|
+
if (!match) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const rest = match.output === '' ? clean : clean.slice(match.output.length).replace(/^\//, '');
|
|
162
|
+
return `${match.input}/${rest}`;
|
|
163
|
+
};
|
|
164
|
+
exports.repoPathOf = repoPathOf;
|
|
106
165
|
const buildTargetOf = (project) => project.architect?.['build'] ?? project.targets?.['build'];
|
|
107
166
|
const readPackageJson = (json) => {
|
|
108
167
|
if (!json || typeof json !== 'object') {
|
|
@@ -137,10 +196,7 @@ const isZoneless = (context) => {
|
|
|
137
196
|
if (context.angular?.zonePolyfill !== null && context.angular?.zonePolyfill !== undefined) {
|
|
138
197
|
return !context.angular.zonePolyfill;
|
|
139
198
|
}
|
|
140
|
-
|
|
141
|
-
return !context.pkg.zoneDependency;
|
|
142
|
-
}
|
|
143
|
-
return null;
|
|
199
|
+
return context.pkg ? !context.pkg.zoneDependency : null;
|
|
144
200
|
};
|
|
145
201
|
exports.isZoneless = isZoneless;
|
|
146
202
|
// --- Pipeline ---------------------------------------------------------------------------------
|
|
@@ -163,7 +219,9 @@ const BUILD_COMMANDS = [
|
|
|
163
219
|
/\brsbuild\s+build\b([^&|;]*)/,
|
|
164
220
|
// esbuild has no `build` subcommand, so it is only recognised when it is being invoked with
|
|
165
221
|
// flags. Matching the bare word would turn `pnpm add esbuild` into a build of the application.
|
|
166
|
-
|
|
222
|
+
// Both conditions are lookaheads so the whitespace after the word is read once: written as
|
|
223
|
+
// `\s+` followed by the flags, the two could trade spaces and a long run of them backtracked.
|
|
224
|
+
/\besbuild(?=\s)(?=[^&|;]+--[\w-])([^&|;]+)/,
|
|
167
225
|
];
|
|
168
226
|
/** The flags of a build command, when one of them is a build command. `null` when none is. */
|
|
169
227
|
const buildFlagsIn = (command) => {
|
|
@@ -230,22 +288,22 @@ exports.resolveBuildCommand = resolveBuildCommand;
|
|
|
230
288
|
* a file nobody recognises is still read line by line rather than skipped.
|
|
231
289
|
*/
|
|
232
290
|
const kindOf = (fileName, text) => {
|
|
233
|
-
if (
|
|
291
|
+
if (fileName.includes('gitlab-ci')) {
|
|
234
292
|
return 'gitlab';
|
|
235
293
|
}
|
|
236
|
-
if (
|
|
294
|
+
if (fileName.includes('azure-pipelines') || /^\s*vmImage:/m.test(text)) {
|
|
237
295
|
return 'azure';
|
|
238
296
|
}
|
|
239
|
-
if (
|
|
297
|
+
if (fileName.includes('bitbucket-pipelines') || /^pipelines:/m.test(text)) {
|
|
240
298
|
return 'bitbucket';
|
|
241
299
|
}
|
|
242
|
-
if (
|
|
300
|
+
if (fileName.includes('circleci') || /^workflows:/m.test(text)) {
|
|
243
301
|
return 'circleci';
|
|
244
302
|
}
|
|
245
303
|
if (/jenkinsfile/i.test(fileName)) {
|
|
246
304
|
return 'jenkins';
|
|
247
305
|
}
|
|
248
|
-
if (/^jobs:/m.test(text) &&
|
|
306
|
+
if (/^jobs:/m.test(text) && text.includes('runs-on:')) {
|
|
249
307
|
return 'github';
|
|
250
308
|
}
|
|
251
309
|
return /^stages:/m.test(text) ? 'gitlab' : 'unknown';
|
|
@@ -16,7 +16,7 @@ const json_utils_1 = require("../json/json.utils");
|
|
|
16
16
|
const catalog_1 = require("./catalog");
|
|
17
17
|
const secrets_1 = require("./secrets");
|
|
18
18
|
/** The legal comments a minifier keeps on purpose: `/*!` and anything with `@license`. */
|
|
19
|
-
const LEGAL_COMMENT = /\/\*[!*][\S
|
|
19
|
+
const LEGAL_COMMENT = /\/\*[!*][\s\S]*?\*\//g;
|
|
20
20
|
/**
|
|
21
21
|
* Licence identifiers, and how each one has to be treated.
|
|
22
22
|
*
|
|
@@ -56,7 +56,7 @@ const LICENCES = [
|
|
|
56
56
|
*/
|
|
57
57
|
const DEV_MARKERS = [
|
|
58
58
|
{ kind: 'consoleLogs', pattern: /\bconsole\.log\(/g },
|
|
59
|
-
{ kind: 'debugger', pattern: /\bdebugger\
|
|
59
|
+
{ kind: 'debugger', pattern: /\bdebugger\s*[;}]/g },
|
|
60
60
|
];
|
|
61
61
|
/**
|
|
62
62
|
* Leftovers read from the **inputs** the metafile names: a fact about what was compiled rather than
|
|
@@ -105,18 +105,17 @@ const licencesOf = (texts) => {
|
|
|
105
105
|
};
|
|
106
106
|
return [...found.values()].toSorted((a, b) => rank[a.class] - rank[b.class]);
|
|
107
107
|
};
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
/**
|
|
109
|
+
* One reader per chunk, built on first use and only for a chunk something matched in, so a build
|
|
110
|
+
* nobody has anything to attribute in pays nothing for it.
|
|
111
|
+
*/
|
|
112
|
+
const mapReaders = (texts, maps) => {
|
|
110
113
|
const readers = new Map();
|
|
111
|
-
|
|
112
|
-
* Where a position of a chunk came from, when the chunk has a map next to it. Built once per
|
|
113
|
-
* chunk and only for a chunk something matched in, so a build nobody has a leftover in pays
|
|
114
|
-
* nothing for this.
|
|
115
|
-
*/
|
|
116
|
-
const readerFor = (chunk, text) => {
|
|
114
|
+
return (chunk) => {
|
|
117
115
|
if (readers.has(chunk)) {
|
|
118
116
|
return readers.get(chunk) ?? null;
|
|
119
117
|
}
|
|
118
|
+
const text = texts.get(chunk) ?? '';
|
|
120
119
|
const map = maps.find(entry => entry.name === `${chunk}.map`);
|
|
121
120
|
let reader = null;
|
|
122
121
|
try {
|
|
@@ -151,6 +150,41 @@ const leftoversOf = (texts, modules, maps) => {
|
|
|
151
150
|
readers.set(chunk, reader);
|
|
152
151
|
return reader;
|
|
153
152
|
};
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Which package a `process.env.X` left in a chunk belongs to.
|
|
156
|
+
*
|
|
157
|
+
* With a source map, the position says it outright. Without one, the metafile still says which
|
|
158
|
+
* packages are inside that chunk, and a variable named after one of them is that package reading
|
|
159
|
+
* its own switch: `process.env.DEBUG` in a chunk carrying `debug` is the `debug` package, not a
|
|
160
|
+
* variable of the project that the build forgot to substitute. Anything else stays unattributed —
|
|
161
|
+
* guessing an author is the thing this file refuses to do everywhere else.
|
|
162
|
+
*/
|
|
163
|
+
const envOwners = (modules, readerFor) => {
|
|
164
|
+
const packagesIn = new Map();
|
|
165
|
+
for (const module of modules) {
|
|
166
|
+
const pkg = module.pkg ?? (0, format_utils_1.packageOf)(module.path);
|
|
167
|
+
if (!pkg) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
for (const place of module.places) {
|
|
171
|
+
const name = (0, format_utils_1.baseName)(place.chunk);
|
|
172
|
+
packagesIn.set(name, (packagesIn.get(name) ?? new Set()).add(pkg));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return (chunk, index, match) => {
|
|
176
|
+
const source = readerFor(chunk)?.(index) ?? null;
|
|
177
|
+
if (source !== null) {
|
|
178
|
+
return source.includes('node_modules') ? (0, format_utils_1.packageOf)(source.replace(/^(?:\.\.\/)+/, '')) : null;
|
|
179
|
+
}
|
|
180
|
+
const variable = match.replace(/^process\.env\./, '').toLowerCase();
|
|
181
|
+
const candidates = new Set([variable, variable.replaceAll('_', '-')]);
|
|
182
|
+
const inside = packagesIn.get(chunk) ?? new Set();
|
|
183
|
+
return [...inside].find(pkg => candidates.has(pkg.replace(/^@[^/]+\//, ''))) ?? null;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const leftoversOf = (texts, modules, readerFor) => {
|
|
187
|
+
const found = [];
|
|
154
188
|
/**
|
|
155
189
|
* How many of a marker's matches in one chunk are the project's own, and whether that could be
|
|
156
190
|
* decided at all. Without a map the honest answer is "all of them, and I do not know whose".
|
|
@@ -160,7 +194,7 @@ const leftoversOf = (texts, modules, maps) => {
|
|
|
160
194
|
if (hits.length === 0) {
|
|
161
195
|
return { count: 0, attributed: true };
|
|
162
196
|
}
|
|
163
|
-
const reader = readerFor(chunk
|
|
197
|
+
const reader = readerFor(chunk);
|
|
164
198
|
if (!reader) {
|
|
165
199
|
return { count: hits.length, attributed: false };
|
|
166
200
|
}
|
|
@@ -177,10 +211,11 @@ const leftoversOf = (texts, modules, maps) => {
|
|
|
177
211
|
for (const [chunk, text] of texts) {
|
|
178
212
|
const hits = countIn(chunk, text, pattern);
|
|
179
213
|
attributed &&= hits.attributed;
|
|
180
|
-
if (hits.count > 0) {
|
|
181
|
-
|
|
182
|
-
where.push(chunk);
|
|
214
|
+
if (!(hits.count > 0)) {
|
|
215
|
+
continue;
|
|
183
216
|
}
|
|
217
|
+
count += hits.count;
|
|
218
|
+
where.push(chunk);
|
|
184
219
|
}
|
|
185
220
|
if (count > 0) {
|
|
186
221
|
found.push({ kind, count, where, attributed });
|
|
@@ -270,11 +305,14 @@ const exposureOf = (maps) => {
|
|
|
270
305
|
return { maps: maps.length, ownFiles: paths.size, hasContent, paths: [...paths], envReferences };
|
|
271
306
|
};
|
|
272
307
|
exports.exposureOf = exposureOf;
|
|
273
|
-
const scanBuild = (input) =>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
308
|
+
const scanBuild = (input) => {
|
|
309
|
+
const readerFor = mapReaders(input.texts, input.maps);
|
|
310
|
+
return {
|
|
311
|
+
secrets: (0, secrets_1.findSecrets)(input.texts, envOwners(input.modules, readerFor)),
|
|
312
|
+
leftovers: leftoversOf(input.texts, input.modules, readerFor),
|
|
313
|
+
licences: licencesOf(input.texts),
|
|
314
|
+
thirdParty: thirdPartyOf(input.modules, input.boot),
|
|
315
|
+
exposure: (0, exports.exposureOf)(input.maps),
|
|
316
|
+
};
|
|
317
|
+
};
|
|
280
318
|
exports.scanBuild = scanBuild;
|
|
Binary file
|
|
@@ -174,10 +174,9 @@ exports.importsChannel = importsChannel;
|
|
|
174
174
|
const OPTIONS = new Map(exports.QUESTIONS.map(question => [question.key, new Set([...question.options, 'unknown'])]));
|
|
175
175
|
const RAW_LIMITS = { screensPerSession: 1000, deploysPerWeek: 1000, returningPct: 100 };
|
|
176
176
|
const readNumber = (value, key) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return value;
|
|
177
|
+
return typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > (RAW_LIMITS[key] ?? 0)
|
|
178
|
+
? null
|
|
179
|
+
: value;
|
|
181
180
|
};
|
|
182
181
|
const readText = (value) => typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
|
|
183
182
|
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -24,10 +24,7 @@ const foreignMessage = (format, t) => {
|
|
|
24
24
|
if (format === 'viteManifest') {
|
|
25
25
|
return t.errViteManifest;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
return t.errVisualizer;
|
|
29
|
-
}
|
|
30
|
-
return t.errNotMetafile;
|
|
27
|
+
return format === 'visualizer' ? t.errVisualizer : t.errNotMetafile;
|
|
31
28
|
};
|
|
32
29
|
exports.foreignMessage = foreignMessage;
|
|
33
30
|
/**
|