Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps(yargs): upgrade to 17.3.1 #13590

Merged
merged 21 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update
  • Loading branch information
connorjclark committed Jan 25, 2022
commit 479879694382cfde1ce811be9f37ddccbce55f24
16 changes: 12 additions & 4 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ function splitCommaSeparatedValues(strings) {
* @return {boolean|string|undefined}
*/
function coerceOptionalStringBoolean(value) {
if (typeof value !== 'undefined' && typeof value !== 'string' && typeof value !== 'boolean') {
if (value === undefined) return;

if (typeof value !== 'string' && typeof value !== 'boolean') {
throw new Error('Invalid value: Argument must be a string or a boolean');
}
return value;
Expand Down Expand Up @@ -399,9 +401,11 @@ function coerceOutput(values) {
* allowlist specific locales. Why? So we can support the user who requests 'es-MX' (unsupported)
* and we'll fall back to 'es' (supported).
* @param {unknown} value
* @return {LH.Locale}
* @return {LH.Locale|undefined}
*/
function coerceLocale(value) {
if (value === undefined) return;

if (typeof value !== 'string') throw new Error(`Invalid value: Argument 'locale' must be a string`);
return /** @type {LH.Locale} */ (value);
}
Expand Down Expand Up @@ -431,9 +435,11 @@ function coerceExtraHeaders(value) {
/**
* Take yarg's unchecked object value and ensure it's proper throttling settings.
* @param {unknown} value
* @return {LH.ThrottlingSettings}
* @return {LH.ThrottlingSettings|undefined}
*/
function coerceThrottling(value) {
if (value === undefined) return;

if (!isObjectOfUnknownValues(value)) {
throw new Error(`Invalid value: Argument 'throttling' must be an object, specified per-property ('throttling.rttMs', 'throttling.throughputKbps', etc)`);
}
Expand Down Expand Up @@ -465,9 +471,11 @@ function coerceThrottling(value) {
/**
* Take yarg's unchecked object value and ensure it is a proper LH.screenEmulationSettings.
* @param {unknown} value
* @return {Partial<LH.ScreenEmulationSettings>}
* @return {Partial<LH.ScreenEmulationSettings>|undefined}
*/
function coerceScreenEmulation(value) {
if (value === undefined) return;

if (!isObjectOfUnknownValues(value)) {
throw new Error(`Invalid value: Argument 'screenEmulation' must be an object, specified per-property ('screenEmulation.width', 'screenEmulation.deviceScaleFactor', etc)`);
}
Expand Down
15 changes: 13 additions & 2 deletions lighthouse-cli/test/cli/cli-flags-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ describe('CLI flags', function() {
Object.keys(optionGroups).forEach(key => {
allOptions.push(...optionGroups[key]);
});
// @ts-expect-error - getUsageInstance is private
const optionsWithDescriptions = Object.keys(yargs.getUsageInstance().getDescriptions());
const optionsWithDescriptions =
// @ts-expect-error - getUsageInstance is private
Object.keys(yargs.getInternalMethods().getUsageInstance().getDescriptions());

allOptions.forEach(opt => {
assert.ok(optionsWithDescriptions.includes(opt), `cli option '${opt}' has no description`);
Expand All @@ -54,6 +55,16 @@ describe('CLI flags', function() {
});
});

it('settings are accepted from a file path (inlined budgets)', () => {
const flags = getFlags([
'http://www.example.com',
// eslint-disable-next-line max-len
`--cli-flags-path="${LH_ROOT}/lighthouse-cli/test/fixtures/cli-flags-path-inline-budgets.json"`,
].join(' '));

expect(flags.budgets).toMatchObject([{'anything': 'works'}]);
});

it('array values support csv when appropriate', () => {
const flags = getFlags([
'http://www.example.com',
Expand Down
11 changes: 11 additions & 0 deletions lighthouse-cli/test/fixtures/cli-flags-path-inline-budgets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"budgets": [{"anything": "works"}],
"onlyCategories": ["performance", "seo"],
"chromeFlags": "--window-size 800,600",
"extraHeaders": {"X-Men": "wolverine"},
"throttling-method": "devtools",
"throttling": {
"requestLatencyMs": 700,
"cpuSlowdownMultiplier": 6
}
}
9 changes: 9 additions & 0 deletions lighthouse-core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,19 @@ class Runner {
output: undefined,
channel: undefined,
budgets: undefined,
skipAudits: undefined,
onlyAudits: undefined,
onlyCategories: undefined,
extraHeaders: undefined,
};
const normalizedGatherSettings = Object.assign({}, artifacts.settings, overrides);
const normalizedAuditSettings = Object.assign({}, settings, overrides);

for (const k of Object.keys(normalizedGatherSettings)) {
if (!isDeepEqual(normalizedGatherSettings[k], normalizedAuditSettings[k])) {
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('Cannot change settings between gathering and auditing: ' + k);
}
}
if (!isDeepEqual(normalizedGatherSettings, normalizedAuditSettings)) {
throw new Error('Cannot change settings between gathering and auditing');
}
Expand Down
6 changes: 1 addition & 5 deletions lighthouse-core/test/results/artifacts/artifacts.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@
"locale": "en-US",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
"precomputedLanternData": null,
"onlyAudits": null,
"onlyCategories": null,
"skipAudits": null
"precomputedLanternData": null
},
"URL": {
"requestedUrl": "http://localhost:10200/dobetterweb/dbw_tester.html",
Expand Down
6 changes: 1 addition & 5 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5892,11 +5892,7 @@
"locale": "en-US",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
"precomputedLanternData": null,
"onlyAudits": null,
"onlyCategories": null,
"skipAudits": null
"precomputedLanternData": null
},
"categories": {
"performance": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"third-party-web": "^0.12.7",
"update-notifier": "^4.1.0",
"ws": "^7.0.0",
"yargs": "^16.1.1",
"yargs": "^17.3.1",
"yargs-parser": "^20.2.4"
},
"resolutions": {
Expand Down
20 changes: 19 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7591,7 +7591,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0:
string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -8486,6 +8486,11 @@ yargs-parser@^20.0.0, yargs-parser@^20.2.2, yargs-parser@^20.2.4:
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==

yargs-parser@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.0.tgz#a485d3966be4317426dd56bdb6a30131b281dc55"
integrity sha512-z9kApYUOCwoeZ78rfRYYWdiU/iNL6mwwYlkkZfJoyMR1xps+NEBX5X7XmRpxkZHhXJ6+Ey00IwKxBBSW9FIjyA==

yargs@^15.0.0:
version "15.4.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
Expand Down Expand Up @@ -8516,6 +8521,19 @@ yargs@^16.0.0, yargs@^16.0.3, yargs@^16.1.1, yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.3.1:
version "17.3.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.3.1.tgz#da56b28f32e2fd45aefb402ed9c26f42be4c07b9"
integrity sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==
dependencies:
cliui "^7.0.2"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.3"
y18n "^5.0.5"
yargs-parser "^21.0.0"

yauzl@^2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
Expand Down