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

deps(yargs): upgrade to 17.3.1 #13590

merged 21 commits into from
Jan 26, 2022

Conversation

connorjclark
Copy link
Collaborator

Fixes #13589

Not sure on the root cause, but I noticed that the bug didn't happen with the latest yargs.

https://github.com/yargs/yargs/blob/main/CHANGELOG.md

Only necessary changes were for:

coerce: coerce is now applied before validation.

Which required having coerce fns return null (or undefined, based on what the settings type expected) to prevent some fields like skipAudits, extraHeaders from being undefined instead of null ... which was fine, but was an unnecessary change to the settings normalization.

@adamraine
Copy link
Member

Looks like we need to handle null here:

} else if (typeof extension === 'undefined') {

@connorjclark
Copy link
Collaborator Author

ok let's try to get cli-flags to return the exact same thing even with this version upgrade. We'll need some tests in cli-flags that assert things like keys not being present (as opposed to being null or explicitly undefined)


master

node lighthouse-cli/index.js https://www.example.com
{
  _: [ 'https://www.example.com' ],
  verbose: false,
  quiet: false,
  'save-assets': false,
  saveAssets: false,
  'list-all-audits': false,
  listAllAudits: false,
  'list-locales': false,
  listLocales: false,
  'list-trace-categories': false,
  listTraceCategories: false,
  'print-config': false,
  printConfig: false,
  'fraggle-rock': false,
  fraggleRock: false,
  'chrome-flags': '',
  chromeFlags: '',
  port: 0,
  hostname: '127.0.0.1',
  'enable-error-reporting': undefined,
  enableErrorReporting: undefined,
  output: [ 'html' ],
  view: false,
  channel: 'cli',
  'chrome-ignore-default-flags': false,
  chromeIgnoreDefaultFlags: false,
  '$0': 'lighthouse-cli/index.js'
}

new yargs, no changes to cli-flags

Invalid value: Argument 'screenEmulation' must be an object, specified per-property ('screenEmulation.width', 'screenEmulation.deviceScaleFactor', etc)

Specify --help for available options

new yargs, current PR state

{
  _: [ 'https://www.example.com' ],
  verbose: false,
  quiet: false,
  'save-assets': false,
  saveAssets: false,
  'list-all-audits': false,
  listAllAudits: false,
  'list-locales': false,
  listLocales: false,
  'list-trace-categories': false,
  listTraceCategories: false,
  'print-config': false,
  printConfig: false,
  'fraggle-rock': false,
  fraggleRock: false,
  'chrome-flags': '',
  chromeFlags: '',
  port: 0,
  hostname: '127.0.0.1',
  'enable-error-reporting': undefined,
  enableErrorReporting: undefined,
  output: [ 'html' ],
  view: false,
  channel: 'cli',
  'chrome-ignore-default-flags': false,
  chromeIgnoreDefaultFlags: false,
  '$0': 'lighthouse-cli/index.js',
  screenEmulation: undefined,
  'screen-emulation': undefined,
  emulatedUserAgent: undefined,
  'emulated-user-agent': undefined,
  'gather-mode': undefined,
  G: undefined,
  gatherMode: undefined,
  'audit-mode': undefined,
  A: undefined,
  auditMode: undefined,
  'only-audits': null,
  onlyAudits: null,
  'only-categories': null,
  onlyCategories: null,
  'skip-audits': null,
  skipAudits: null,
  locale: undefined,
  throttling: undefined,
  'extra-headers': null,
  extraHeaders: null,
  plugins: null
}

@connorjclark
Copy link
Collaborator Author

connorjclark commented Jan 25, 2022

Not sure on the root cause, but I noticed that the bug didn't happen with the latest yargs.

must have been this yargs/yargs#2063

esm json import

we should also update our dep on yargs-parser ... we only pass it strings for chrome-flags but still we should be on the same version

@@ -413,9 +456,6 @@ Object {
"extraHeaders": Object {
"X-Men": "wolverine",
},
"extraheaders": Object {
"xMen": "wolverine",
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems the older yargs was overzealous in how it interprets provided config files.

@connorjclark connorjclark changed the title deps: update yargs to 17.3.1 deps(yargs): upgrade to 17.3.1 Jan 26, 2022
lighthouse-cli/cli-flags.js Outdated Show resolved Hide resolved
// explicitly set to undefined, delete them from the flags object.
for (const [k, v] of Object.entries(cliFlags)) {
// This property is meant to possibly be explicitly undefined.
if (k === 'enable-error-reporting' || k === 'enableErrorReporting') continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for the special handling of this flag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the snapshot tests tho. I don't understand the comment in this flag's options anyway, @brendankenny may know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--cli-flags-path no longer works
3 participants