lighthouse 9.2.0-dev.20220125 → 9.2.0-dev.20220126

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.
@@ -178,7 +178,6 @@ function getFlags(manualArgv, options = {}) {
178
178
  },
179
179
  'enable-error-reporting': {
180
180
  type: 'boolean',
181
- default: undefined, // Explicitly `undefined` so prompted by default.
182
181
  describe: 'Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://git.io/vFFTO',
183
182
  },
184
183
  'gather-mode': {
@@ -343,19 +342,26 @@ function getFlags(manualArgv, options = {}) {
343
342
 
344
343
  // Augmenting yargs type with auto-camelCasing breaks in tsc@4.1.2 and @types/yargs@15.0.11,
345
344
  // so for now cast to add yarg's camelCase properties to type.
346
- const argv = parser.argv;
345
+ const argv = /** @type {Awaited<typeof parser.argv>} */ (parser.argv);
347
346
  const cliFlags = /** @type {typeof argv & CamelCasify<typeof argv>} */ (argv);
348
347
 
348
+ // yargs will return `undefined` for options that have a `coerce` function but
349
+ // are not actually present in the user input. Instead of passing properties
350
+ // explicitly set to undefined, delete them from the flags object.
351
+ for (const [k, v] of Object.entries(cliFlags)) {
352
+ if (v === undefined) delete cliFlags[k];
353
+ }
354
+
349
355
  return cliFlags;
350
356
  }
351
357
 
352
358
  /**
353
359
  * Support comma-separated values for some array flags by splitting on any ',' found.
354
360
  * @param {Array<string>=} strings
355
- * @return {Array<string>|undefined}
361
+ * @return {Array<string>=}
356
362
  */
357
363
  function splitCommaSeparatedValues(strings) {
358
- if (!strings) return strings;
364
+ if (!strings) return;
359
365
 
360
366
  return strings.flatMap(value => value.split(','));
361
367
  }
@@ -365,7 +371,9 @@ function splitCommaSeparatedValues(strings) {
365
371
  * @return {boolean|string|undefined}
366
372
  */
367
373
  function coerceOptionalStringBoolean(value) {
368
- if (typeof value !== 'undefined' && typeof value !== 'string' && typeof value !== 'boolean') {
374
+ if (value === undefined) return;
375
+
376
+ if (typeof value !== 'string' && typeof value !== 'boolean') {
369
377
  throw new Error('Invalid value: Argument must be a string or a boolean');
370
378
  }
371
379
  return value;
@@ -399,9 +407,11 @@ function coerceOutput(values) {
399
407
  * allowlist specific locales. Why? So we can support the user who requests 'es-MX' (unsupported)
400
408
  * and we'll fall back to 'es' (supported).
401
409
  * @param {unknown} value
402
- * @return {LH.Locale}
410
+ * @return {LH.Locale|undefined}
403
411
  */
404
412
  function coerceLocale(value) {
413
+ if (value === undefined) return;
414
+
405
415
  if (typeof value !== 'string') throw new Error(`Invalid value: Argument 'locale' must be a string`);
406
416
  return /** @type {LH.Locale} */ (value);
407
417
  }
@@ -431,9 +441,11 @@ function coerceExtraHeaders(value) {
431
441
  /**
432
442
  * Take yarg's unchecked object value and ensure it's proper throttling settings.
433
443
  * @param {unknown} value
434
- * @return {LH.ThrottlingSettings}
444
+ * @return {LH.ThrottlingSettings|undefined}
435
445
  */
436
446
  function coerceThrottling(value) {
447
+ if (value === undefined) return;
448
+
437
449
  if (!isObjectOfUnknownValues(value)) {
438
450
  throw new Error(`Invalid value: Argument 'throttling' must be an object, specified per-property ('throttling.rttMs', 'throttling.throughputKbps', etc)`);
439
451
  }
@@ -465,9 +477,11 @@ function coerceThrottling(value) {
465
477
  /**
466
478
  * Take yarg's unchecked object value and ensure it is a proper LH.screenEmulationSettings.
467
479
  * @param {unknown} value
468
- * @return {Partial<LH.ScreenEmulationSettings>}
480
+ * @return {Partial<LH.ScreenEmulationSettings>|undefined}
469
481
  */
470
482
  function coerceScreenEmulation(value) {
483
+ if (value === undefined) return;
484
+
471
485
  if (!isObjectOfUnknownValues(value)) {
472
486
  throw new Error(`Invalid value: Argument 'screenEmulation' must be an object, specified per-property ('screenEmulation.width', 'screenEmulation.deviceScaleFactor', etc)`);
473
487
  }
@@ -175,7 +175,8 @@ async function begin() {
175
175
 
176
176
  // Augmenting yargs type with auto-camelCasing breaks in tsc@4.1.2 and @types/yargs@15.0.11,
177
177
  // so for now cast to add yarg's camelCase properties to type.
178
- const argv = /** @type {typeof rawArgv & CamelCasify<typeof rawArgv>} */ (rawArgv);
178
+ const argv =
179
+ /** @type {Awaited<typeof rawArgv> & CamelCasify<Awaited<typeof rawArgv>>} */ (rawArgv);
179
180
 
180
181
  const jobs = Number.isFinite(argv.jobs) ? argv.jobs : undefined;
181
182
  const retries = Number.isFinite(argv.retries) ? argv.retries : undefined;
@@ -263,6 +263,19 @@ class Runner {
263
263
  const normalizedGatherSettings = Object.assign({}, artifacts.settings, overrides);
264
264
  const normalizedAuditSettings = Object.assign({}, settings, overrides);
265
265
 
266
+ // First, try each key individually so we can print which key differed.
267
+ const keys = new Set([
268
+ ...Object.keys(normalizedGatherSettings),
269
+ ...Object.keys(normalizedAuditSettings),
270
+ ]);
271
+ for (const k of keys) {
272
+ if (!isDeepEqual(normalizedGatherSettings[k], normalizedAuditSettings[k])) {
273
+ throw new Error(
274
+ `Cannot change settings between gathering and auditing. Difference found at: ${k}`);
275
+ }
276
+ }
277
+
278
+ // Call `isDeepEqual` on the entire thing, just in case something was missed.
266
279
  if (!isDeepEqual(normalizedGatherSettings, normalizedAuditSettings)) {
267
280
  throw new Error('Cannot change settings between gathering and auditing');
268
281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "9.2.0-dev.20220125",
3
+ "version": "9.2.0-dev.20220126",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -126,8 +126,8 @@
126
126
  "@types/semver": "^5.5.0",
127
127
  "@types/tabulator-tables": "^4.9.1",
128
128
  "@types/ws": "^7.0.0",
129
- "@types/yargs": "^16.0.0",
130
- "@types/yargs-parser": "^15.0.0",
129
+ "@types/yargs": "^17.0.8",
130
+ "@types/yargs-parser": "^20.2.1",
131
131
  "@typescript-eslint/eslint-plugin": "^5.6.0",
132
132
  "@typescript-eslint/parser": "^5.6.0",
133
133
  "acorn": "^8.5.0",
@@ -210,8 +210,8 @@
210
210
  "speedline-core": "^1.4.3",
211
211
  "third-party-web": "^0.12.7",
212
212
  "ws": "^7.0.0",
213
- "yargs": "^16.1.1",
214
- "yargs-parser": "^20.2.4"
213
+ "yargs": "^17.3.1",
214
+ "yargs-parser": "^21.0.0"
215
215
  },
216
216
  "resolutions": {
217
217
  "puppeteer/**/devtools-protocol": "0.0.963043"