lighthouse 9.5.0-dev.20220628 → 9.5.0-dev.20220629
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/dist/report/bundle.esm.js +7 -6
- package/dist/report/flow.js +24 -24
- package/dist/report/standalone.js +19 -19
- package/flow-report/test/common-test.tsx +5 -4
- package/flow-report/test/flow-report-pptr-test.ts +4 -7
- package/flow-report/test/run-flow-report-tests.sh +20 -0
- package/flow-report/test/setup/env-setup.ts +44 -24
- package/flow-report/test/sidebar/sidebar-test.tsx +0 -1
- package/flow-report/test/topbar-test.tsx +5 -5
- package/flow-report/test/util-test.tsx +3 -3
- package/flow-report/tsconfig.json +4 -1
- package/lighthouse-cli/cli-flags.js +313 -305
- package/lighthouse-cli/test/smokehouse/report-assert-test.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +30 -5
- package/lighthouse-core/config/config-plugin.js +26 -0
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +1 -0
- package/lighthouse-core/gather/gather-runner.js +1 -0
- package/lighthouse-core/gather/gatherers/main-document-content.js +0 -2
- package/lighthouse-core/lib/lh-env.js +1 -1
- package/lighthouse-core/lib/navigation-error.js +26 -7
- package/lighthouse-core/util-commonjs.js +7 -6
- package/package.json +24 -19
- package/report/renderer/util.js +7 -6
- package/report/test/.eslintrc.cjs +4 -1
- package/report/test/clients/bundle-test.js +4 -4
- package/report/test/generator/report-generator-test.js +3 -1
- package/report/test/renderer/category-renderer-test.js +3 -3
- package/report/test/renderer/components-test.js +36 -34
- package/report/test/renderer/crc-details-renderer-test.js +2 -2
- package/report/test/renderer/details-renderer-test.js +2 -2
- package/report/test/renderer/dom-test.js +4 -4
- package/report/test/renderer/element-screenshot-renderer-test.js +3 -2
- package/report/test/renderer/performance-category-renderer-test.js +4 -4
- package/report/test/renderer/pwa-category-renderer-test.js +3 -3
- package/report/test/renderer/report-renderer-axe-test.js +6 -8
- package/report/test/renderer/report-renderer-test.js +5 -5
- package/report/test/renderer/report-ui-features-test.js +8 -8
- package/report/test/renderer/snippet-renderer-test.js +2 -2
- package/report/test/renderer/text-encoding-test.js +2 -2
- package/report/test/renderer/util-test.js +1 -1
- package/root.js +0 -18
- package/shared/localization/locales/en-US.json +3 -0
- package/shared/localization/locales/en-XL.json +3 -0
- package/shared/test/localization/.eslintrc.cjs +4 -1
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +1 -1
- package/third-party/chromium-synchronization/installability-errors-test.js +1 -3
- package/types/test.d.ts +53 -0
- package/flow-report/jest.config.js +0 -24
- package/flow-report/test/setup/global-setup.ts +0 -11
- package/jest.config.js +0 -30
- package/types/jest.d.ts +0 -25
|
@@ -16,319 +16,326 @@ import {isObjectOfUnknownValues} from '../shared/type-verifiers.js';
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @param {string=} manualArgv
|
|
19
|
-
* @param {{noExitOnFailure?: boolean}=} options
|
|
20
|
-
* @return {LH.CliFlags}
|
|
21
19
|
*/
|
|
22
|
-
function
|
|
20
|
+
function getYargsParser(manualArgv) {
|
|
23
21
|
const y = manualArgv ?
|
|
24
22
|
// @ts-expect-error - undocumented, but yargs() supports parsing a single `string`.
|
|
25
23
|
yargs(manualArgv) :
|
|
26
24
|
yargs(yargsHelpers.hideBin(process.argv));
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
26
|
+
return y.help('help')
|
|
27
|
+
.version(JSON.parse(fs.readFileSync(`${LH_ROOT}/package.json`, 'utf-8')).version)
|
|
28
|
+
.showHelpOnFail(false, 'Specify --help for available options')
|
|
29
|
+
|
|
30
|
+
.usage('lighthouse <url> <options>')
|
|
31
|
+
.example(
|
|
32
|
+
'lighthouse <url> --view', 'Opens the HTML report in a browser after the run completes')
|
|
33
|
+
.example(
|
|
34
|
+
'lighthouse <url> --config-path=./myconfig.js',
|
|
35
|
+
'Runs Lighthouse with your own configuration: custom audits, report generation, etc.')
|
|
36
|
+
.example(
|
|
37
|
+
'lighthouse <url> --output=json --output-path=./report.json --save-assets',
|
|
38
|
+
'Save trace, screenshots, and named JSON report.')
|
|
39
|
+
.example(
|
|
40
|
+
'lighthouse <url> --screenEmulation.disabled --throttling-method=provided --no-emulated-user-agent',
|
|
41
|
+
'Disable emulation and all throttling')
|
|
42
|
+
.example(
|
|
43
|
+
'lighthouse <url> --chrome-flags="--window-size=412,660"',
|
|
44
|
+
'Launch Chrome with a specific window size')
|
|
45
|
+
.example(
|
|
46
|
+
'lighthouse <url> --quiet --chrome-flags="--headless"',
|
|
47
|
+
'Launch Headless Chrome, turn off logging')
|
|
48
|
+
.example(
|
|
49
|
+
'lighthouse <url> --extra-headers "{\\"Cookie\\":\\"monster=blue\\", \\"x-men\\":\\"wolverine\\"}"',
|
|
50
|
+
'Stringify\'d JSON HTTP Header key/value pairs to send in requests')
|
|
51
|
+
.example(
|
|
52
|
+
'lighthouse <url> --extra-headers=./path/to/file.json',
|
|
53
|
+
'Path to JSON file of HTTP Header key/value pairs to send in requests')
|
|
54
|
+
.example(
|
|
55
|
+
'lighthouse <url> --only-categories=performance,pwa',
|
|
56
|
+
'Only run the specified categories. Available categories: accessibility, best-practices, performance, pwa, seo')
|
|
57
|
+
|
|
58
|
+
// We only have the single string positional argument, the url.
|
|
59
|
+
.option('_', {
|
|
60
|
+
array: true, // Always an array, but this lets the type system know.
|
|
61
|
+
type: 'string',
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Also accept a file for all of these flags. Yargs will merge in and override the file-based
|
|
66
|
+
* flags with the command-line flags.
|
|
67
|
+
*
|
|
68
|
+
* i.e. when command-line `--throttling-method=provided` and file `throttlingMethod: "devtools"`,
|
|
69
|
+
* throttlingMethod will be `provided`.
|
|
70
|
+
*
|
|
71
|
+
* @see https://github.com/yargs/yargs/blob/a6e67f15a61558d0ba28bfe53385332f0ce5d431/docs/api.md#config
|
|
72
|
+
*/
|
|
73
|
+
.option('cli-flags-path', {
|
|
74
|
+
config: true,
|
|
75
|
+
describe: 'The path to a JSON file that contains the desired CLI flags to apply. Flags specified at the command line will still override the file-based ones.',
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Logging
|
|
79
|
+
.options({
|
|
80
|
+
'verbose': {
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
default: false,
|
|
83
|
+
describe: 'Displays verbose logging',
|
|
84
|
+
},
|
|
85
|
+
'quiet': {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
default: false,
|
|
88
|
+
describe: 'Displays no progress, debug logs, or errors',
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
.group(['verbose', 'quiet'], 'Logging:')
|
|
92
|
+
|
|
93
|
+
// Configuration
|
|
94
|
+
.options({
|
|
95
|
+
'save-assets': {
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
default: false,
|
|
98
|
+
describe: 'Save the trace contents & devtools logs to disk',
|
|
99
|
+
},
|
|
100
|
+
'list-all-audits': {
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
default: false,
|
|
103
|
+
describe: 'Prints a list of all available audits and exits',
|
|
104
|
+
},
|
|
105
|
+
'list-locales': {
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
default: false,
|
|
108
|
+
describe: 'Prints a list of all supported locales and exits',
|
|
109
|
+
},
|
|
110
|
+
'list-trace-categories': {
|
|
111
|
+
type: 'boolean',
|
|
112
|
+
default: false,
|
|
113
|
+
describe: 'Prints a list of all required trace categories and exits',
|
|
114
|
+
},
|
|
115
|
+
'print-config': {
|
|
116
|
+
type: 'boolean',
|
|
117
|
+
default: false,
|
|
118
|
+
describe: 'Print the normalized config for the given config and options, then exit.',
|
|
119
|
+
},
|
|
120
|
+
'debug-navigation': {
|
|
121
|
+
type: 'boolean',
|
|
122
|
+
describe: 'Pause after page load to wait for permission to continue the run, evaluate `continueLighthouseRun` in the console to continue.',
|
|
123
|
+
},
|
|
124
|
+
'legacy-navigation': {
|
|
125
|
+
type: 'boolean',
|
|
126
|
+
default: false,
|
|
127
|
+
describe: '[DEPRECATED] Use the legacy navigation runner to gather results. Only use this if you are using a pre-10.0 custom Lighthouse config, or if Lighthouse unexpectedly fails after updating to 10.0. Please file a bug if you need this flag for Lighthouse to work.',
|
|
128
|
+
},
|
|
129
|
+
'additional-trace-categories': {
|
|
63
130
|
type: 'string',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
'
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
'
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
//
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
},
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
// Throttling settings, parsed as an object.
|
|
268
|
-
.option('throttling', {
|
|
269
|
-
coerce: coerceThrottling,
|
|
270
|
-
})
|
|
271
|
-
.describe({
|
|
272
|
-
'throttling.rttMs': 'Controls simulated network RTT (TCP layer)',
|
|
273
|
-
'throttling.throughputKbps': 'Controls simulated network download throughput',
|
|
274
|
-
'throttling.requestLatencyMs': 'Controls emulated network RTT (HTTP layer)',
|
|
275
|
-
'throttling.downloadThroughputKbps': 'Controls emulated network download throughput',
|
|
276
|
-
'throttling.uploadThroughputKbps': 'Controls emulated network upload throughput',
|
|
277
|
-
'throttling.cpuSlowdownMultiplier': 'Controls simulated + emulated CPU throttling',
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
.options({
|
|
281
|
-
'extra-headers': {
|
|
282
|
-
coerce: coerceExtraHeaders,
|
|
283
|
-
describe: 'Set extra HTTP Headers to pass with request',
|
|
284
|
-
},
|
|
285
|
-
'precomputed-lantern-data-path': {
|
|
286
|
-
type: 'string',
|
|
287
|
-
describe: 'Path to the file where lantern simulation data should be read from, overwriting the lantern observed estimates for RTT and server latency.',
|
|
288
|
-
},
|
|
289
|
-
'lantern-data-output-path': {
|
|
290
|
-
type: 'string',
|
|
291
|
-
describe: 'Path to the file where lantern simulation data should be written to, can be used in a future run with the `precomputed-lantern-data-path` flag.',
|
|
292
|
-
},
|
|
293
|
-
'plugins': {
|
|
294
|
-
array: true,
|
|
295
|
-
type: 'string',
|
|
296
|
-
coerce: splitCommaSeparatedValues,
|
|
297
|
-
describe: 'Run the specified plugins',
|
|
298
|
-
},
|
|
299
|
-
'channel': {
|
|
300
|
-
type: 'string',
|
|
301
|
-
default: 'cli',
|
|
302
|
-
},
|
|
303
|
-
'chrome-ignore-default-flags': {
|
|
304
|
-
type: 'boolean',
|
|
305
|
-
default: false,
|
|
306
|
-
},
|
|
307
|
-
})
|
|
308
|
-
|
|
309
|
-
// Choices added outside of `options()` and cast so tsc picks them up.
|
|
310
|
-
.choices('form-factor', /** @type {const} */ (['mobile', 'desktop']))
|
|
311
|
-
.choices('throttling-method', /** @type {const} */ (['devtools', 'provided', 'simulate']))
|
|
312
|
-
.choices('preset', /** @type {const} */ (['perf', 'experimental', 'desktop']))
|
|
313
|
-
|
|
314
|
-
.check(argv => {
|
|
315
|
-
// Lighthouse doesn't need a URL if...
|
|
316
|
-
// - We're just listing the available options.
|
|
317
|
-
// - We're just printing the config.
|
|
318
|
-
// - We're in auditMode (and we have artifacts already)
|
|
319
|
-
// If one of these don't apply, if no URL, stop the program and ask for one.
|
|
320
|
-
const isPrintSomethingMode = argv.listAllAudits || argv.listLocales || argv.listTraceCategories || argv.printConfig;
|
|
321
|
-
const isOnlyAuditMode = !!argv.auditMode && !argv.gatherMode;
|
|
322
|
-
if (isPrintSomethingMode || isOnlyAuditMode) {
|
|
323
|
-
return true;
|
|
324
|
-
} else if (argv._.length > 0) {
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
131
|
+
describe: 'Additional categories to capture with the trace (comma-delimited).',
|
|
132
|
+
},
|
|
133
|
+
'config-path': {
|
|
134
|
+
type: 'string',
|
|
135
|
+
describe: `The path to the config JSON.
|
|
136
|
+
An example config file: lighthouse-core/config/lr-desktop-config.js`,
|
|
137
|
+
},
|
|
138
|
+
'preset': {
|
|
139
|
+
type: 'string',
|
|
140
|
+
describe: `Use a built-in configuration.
|
|
141
|
+
WARNING: If the --config-path flag is provided, this preset will be ignored.`,
|
|
142
|
+
},
|
|
143
|
+
'chrome-flags': {
|
|
144
|
+
type: 'string',
|
|
145
|
+
default: '',
|
|
146
|
+
describe: `Custom flags to pass to Chrome (space-delimited). For a full list of flags, see https://bit.ly/chrome-flags
|
|
147
|
+
Additionally, use the CHROME_PATH environment variable to use a specific Chrome binary. Requires Chromium version 66.0 or later. If omitted, any detected Chrome Canary or Chrome stable will be used.`,
|
|
148
|
+
},
|
|
149
|
+
'port': {
|
|
150
|
+
type: 'number',
|
|
151
|
+
default: 0,
|
|
152
|
+
describe: 'The port to use for the debugging protocol. Use 0 for a random port',
|
|
153
|
+
},
|
|
154
|
+
'hostname': {
|
|
155
|
+
type: 'string',
|
|
156
|
+
default: '127.0.0.1',
|
|
157
|
+
describe: 'The hostname to use for the debugging protocol.',
|
|
158
|
+
},
|
|
159
|
+
'form-factor': {
|
|
160
|
+
type: 'string',
|
|
161
|
+
describe: 'Determines how performance metrics are scored and if mobile-only audits are skipped. For desktop, --preset=desktop instead.',
|
|
162
|
+
},
|
|
163
|
+
'screenEmulation': {
|
|
164
|
+
describe: 'Sets screen emulation parameters. See also --preset. Use --screenEmulation.disabled to disable. Otherwise set these 4 parameters individually: --screenEmulation.mobile --screenEmulation.width=360 --screenEmulation.height=640 --screenEmulation.deviceScaleFactor=2',
|
|
165
|
+
coerce: coerceScreenEmulation,
|
|
166
|
+
},
|
|
167
|
+
'emulatedUserAgent': {
|
|
168
|
+
type: 'string',
|
|
169
|
+
coerce: coerceOptionalStringBoolean,
|
|
170
|
+
describe: 'Sets useragent emulation',
|
|
171
|
+
},
|
|
172
|
+
'max-wait-for-load': {
|
|
173
|
+
type: 'number',
|
|
174
|
+
describe: 'The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue. WARNING: Very high values can lead to large traces and instability',
|
|
175
|
+
},
|
|
176
|
+
'enable-error-reporting': {
|
|
177
|
+
type: 'boolean',
|
|
178
|
+
describe: 'Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://github.com/GoogleChrome/lighthouse/blob/master/docs/error-reporting.md',
|
|
179
|
+
},
|
|
180
|
+
'gather-mode': {
|
|
181
|
+
alias: 'G',
|
|
182
|
+
coerce: coerceOptionalStringBoolean,
|
|
183
|
+
describe: 'Collect artifacts from a connected browser and save to disk. (Artifacts folder path may optionally be provided). If audit-mode is not also enabled, the run will quit early.',
|
|
184
|
+
},
|
|
185
|
+
'audit-mode': {
|
|
186
|
+
alias: 'A',
|
|
187
|
+
coerce: coerceOptionalStringBoolean,
|
|
188
|
+
describe: 'Process saved artifacts from disk. (Artifacts folder path may be provided, otherwise defaults to ./latest-run/)',
|
|
189
|
+
},
|
|
190
|
+
'only-audits': {
|
|
191
|
+
array: true,
|
|
192
|
+
type: 'string',
|
|
193
|
+
coerce: splitCommaSeparatedValues,
|
|
194
|
+
describe: 'Only run the specified audits',
|
|
195
|
+
},
|
|
196
|
+
'only-categories': {
|
|
197
|
+
array: true,
|
|
198
|
+
type: 'string',
|
|
199
|
+
coerce: splitCommaSeparatedValues,
|
|
200
|
+
describe: 'Only run the specified categories. Available categories: accessibility, best-practices, performance, pwa, seo',
|
|
201
|
+
},
|
|
202
|
+
'skip-audits': {
|
|
203
|
+
array: true,
|
|
204
|
+
type: 'string',
|
|
205
|
+
coerce: splitCommaSeparatedValues,
|
|
206
|
+
describe: 'Run everything except these audits',
|
|
207
|
+
},
|
|
208
|
+
'budget-path': {
|
|
209
|
+
type: 'string',
|
|
210
|
+
describe: 'The path to the budget.json file for LightWallet.',
|
|
211
|
+
},
|
|
212
|
+
})
|
|
213
|
+
.group([
|
|
214
|
+
'save-assets', 'list-all-audits', 'list-locales', 'list-trace-categories', 'print-config', 'additional-trace-categories',
|
|
215
|
+
'config-path', 'preset', 'chrome-flags', 'port', 'hostname', 'form-factor', 'screenEmulation', 'emulatedUserAgent',
|
|
216
|
+
'max-wait-for-load', 'enable-error-reporting', 'gather-mode', 'audit-mode',
|
|
217
|
+
'only-audits', 'only-categories', 'skip-audits', 'budget-path',
|
|
218
|
+
], 'Configuration:')
|
|
219
|
+
|
|
220
|
+
// Output
|
|
221
|
+
.options({
|
|
222
|
+
'output': {
|
|
223
|
+
type: 'array',
|
|
224
|
+
default: /** @type {const} */ (['html']),
|
|
225
|
+
coerce: coerceOutput,
|
|
226
|
+
describe: 'Reporter for the results, supports multiple values. choices: "json", "html", "csv"',
|
|
227
|
+
},
|
|
228
|
+
'output-path': {
|
|
229
|
+
type: 'string',
|
|
230
|
+
describe: `The file path to output the results. Use 'stdout' to write to stdout.
|
|
231
|
+
If using JSON output, default is stdout.
|
|
232
|
+
If using HTML or CSV output, default is a file in the working directory with a name based on the test URL and date.
|
|
233
|
+
If using multiple outputs, --output-path is appended with the standard extension for each output type. "reports/my-run" -> "reports/my-run.report.html", "reports/my-run.report.json", etc.
|
|
234
|
+
Example: --output-path=./lighthouse-results.html`,
|
|
235
|
+
},
|
|
236
|
+
'view': {
|
|
237
|
+
type: 'boolean',
|
|
238
|
+
default: false,
|
|
239
|
+
describe: 'Open HTML report in your browser',
|
|
240
|
+
},
|
|
241
|
+
})
|
|
242
|
+
.group(['output', 'output-path', 'view'], 'Output:')
|
|
243
|
+
|
|
244
|
+
// Other options.
|
|
245
|
+
.options({
|
|
246
|
+
'locale': {
|
|
247
|
+
coerce: coerceLocale,
|
|
248
|
+
describe: 'The locale/language the report should be formatted in',
|
|
249
|
+
},
|
|
250
|
+
'blocked-url-patterns': {
|
|
251
|
+
array: true,
|
|
252
|
+
type: 'string',
|
|
253
|
+
describe: 'Block any network requests to the specified URL patterns',
|
|
254
|
+
},
|
|
255
|
+
'disable-storage-reset': {
|
|
256
|
+
type: 'boolean',
|
|
257
|
+
describe: 'Disable clearing the browser cache and other storage APIs before a run',
|
|
258
|
+
},
|
|
259
|
+
'throttling-method': {
|
|
260
|
+
type: 'string',
|
|
261
|
+
describe: 'Controls throttling method',
|
|
262
|
+
},
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
// Throttling settings, parsed as an object.
|
|
266
|
+
.option('throttling', {
|
|
267
|
+
coerce: coerceThrottling,
|
|
268
|
+
})
|
|
269
|
+
.describe({
|
|
270
|
+
'throttling.rttMs': 'Controls simulated network RTT (TCP layer)',
|
|
271
|
+
'throttling.throughputKbps': 'Controls simulated network download throughput',
|
|
272
|
+
'throttling.requestLatencyMs': 'Controls emulated network RTT (HTTP layer)',
|
|
273
|
+
'throttling.downloadThroughputKbps': 'Controls emulated network download throughput',
|
|
274
|
+
'throttling.uploadThroughputKbps': 'Controls emulated network upload throughput',
|
|
275
|
+
'throttling.cpuSlowdownMultiplier': 'Controls simulated + emulated CPU throttling',
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
.options({
|
|
279
|
+
'extra-headers': {
|
|
280
|
+
coerce: coerceExtraHeaders,
|
|
281
|
+
describe: 'Set extra HTTP Headers to pass with request',
|
|
282
|
+
},
|
|
283
|
+
'precomputed-lantern-data-path': {
|
|
284
|
+
type: 'string',
|
|
285
|
+
describe: 'Path to the file where lantern simulation data should be read from, overwriting the lantern observed estimates for RTT and server latency.',
|
|
286
|
+
},
|
|
287
|
+
'lantern-data-output-path': {
|
|
288
|
+
type: 'string',
|
|
289
|
+
describe: 'Path to the file where lantern simulation data should be written to, can be used in a future run with the `precomputed-lantern-data-path` flag.',
|
|
290
|
+
},
|
|
291
|
+
'plugins': {
|
|
292
|
+
array: true,
|
|
293
|
+
type: 'string',
|
|
294
|
+
coerce: splitCommaSeparatedValues,
|
|
295
|
+
describe: 'Run the specified plugins',
|
|
296
|
+
},
|
|
297
|
+
'channel': {
|
|
298
|
+
type: 'string',
|
|
299
|
+
default: 'cli',
|
|
300
|
+
},
|
|
301
|
+
'chrome-ignore-default-flags': {
|
|
302
|
+
type: 'boolean',
|
|
303
|
+
default: false,
|
|
304
|
+
},
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
// Choices added outside of `options()` and cast so tsc picks them up.
|
|
308
|
+
.choices('form-factor', /** @type {const} */ (['mobile', 'desktop']))
|
|
309
|
+
.choices('throttling-method', /** @type {const} */ (['devtools', 'provided', 'simulate']))
|
|
310
|
+
.choices('preset', /** @type {const} */ (['perf', 'experimental', 'desktop']))
|
|
311
|
+
|
|
312
|
+
.check(argv => {
|
|
313
|
+
// Lighthouse doesn't need a URL if...
|
|
314
|
+
// - We're just listing the available options.
|
|
315
|
+
// - We're just printing the config.
|
|
316
|
+
// - We're in auditMode (and we have artifacts already)
|
|
317
|
+
// If one of these don't apply, if no URL, stop the program and ask for one.
|
|
318
|
+
const isPrintSomethingMode = argv.listAllAudits || argv.listLocales || argv.listTraceCategories || argv.printConfig;
|
|
319
|
+
const isOnlyAuditMode = !!argv.auditMode && !argv.gatherMode;
|
|
320
|
+
if (isPrintSomethingMode || isOnlyAuditMode) {
|
|
321
|
+
return true;
|
|
322
|
+
} else if (argv._.length > 0) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
throw new Error('Please provide a url');
|
|
327
|
+
})
|
|
328
|
+
.epilogue('For more information on Lighthouse, see https://developers.google.com/web/tools/lighthouse/.')
|
|
329
|
+
.wrap(y.terminalWidth());
|
|
330
|
+
}
|
|
327
331
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
+
/**
|
|
333
|
+
* @param {string=} manualArgv
|
|
334
|
+
* @param {{noExitOnFailure?: boolean}=} options
|
|
335
|
+
* @return {LH.CliFlags}
|
|
336
|
+
*/
|
|
337
|
+
function getFlags(manualArgv, options = {}) {
|
|
338
|
+
let parser = getYargsParser(manualArgv);
|
|
332
339
|
|
|
333
340
|
if (options.noExitOnFailure) {
|
|
334
341
|
// Silence console.error() logging and don't process.exit().
|
|
@@ -526,4 +533,5 @@ function coerceScreenEmulation(value) {
|
|
|
526
533
|
|
|
527
534
|
export {
|
|
528
535
|
getFlags,
|
|
536
|
+
getYargsParser,
|
|
529
537
|
};
|