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: replace inquirer with enquirer #12317

Merged

Conversation

takenspc
Copy link
Contributor

Summary

The inquirer is one of the big dependencies as it depends on rxjs. Replacing inquirer with enquirer would reduce the install size.

My motivation is to make CI setup which runs lighthouse faster so that reducing dependencies is more important than devDependencies.

Screenshots of CLI with this change

Initial rendering:

Timeout reached (rejected):

Accepted:

Related Issues/PRs

#12305

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! Confirmed the behavior in the normal flows works correctly, just two comments on ctrl-c support and a suggestion on formatting

const prompt = new Confirm({
name: 'isErrorReportingEnabled',
initial: false,
message: MESSAGE,
Copy link
Member

Choose a reason for hiding this comment

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

as mentioned in #6658 (comment), the question part of the prompt will have to be manually bolded if we want to preserve the old behavior (which I think still looks good and makes the question stand out).

I can't add a suggestion to L18 in the github UI, but it should just need to change to

  ` ${log.bold}May we anonymously report runtime exceptions to improve the tool over time?${log.reset} `; // eslint-disable-line max-len

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your kindly review 😍. I made the message bold again.

name: 'isErrorReportingEnabled',
initial: false,
message: MESSAGE,
});
Copy link
Member

@brendankenny brendankenny Apr 2, 2021

Choose a reason for hiding this comment

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

to take care of enquirer preventing ctrl-c from working, I think the best approach (based on #6658 (comment) and a quick debug session...there may be a better way but I don't see it) is adding

Suggested change
});
actions: {ctrl: {}},
});

(and types/enquirer/index.d.ts will also have to be updated)

This gets rid of all the ctrl-* key handling, but since we're only using a y/N prompt, I don't think we're going to miss any of it (e.g. if it was free-form text entry we'd probably want to keep ctrl-a and ctrl-e, but we don't have that).

It's still a bit weird. ctrl-c during the prompt still cancels the whole run, but answering yes or no and then doing ctrl-c during the lighthouse run kills the lighthouse process but not the Chrome one. That's less than ideal, but it's better than ctrl-c not doing anything, and this is only on the first run when the user is prompted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added actions to the option. Also, I updated the path of .d.ts as suggested at #12305 (comment) (from types/enquirer/index.d.ts to types/enquirer.d.ts).

@adamraine adamraine changed the title deps: replace inquirer with enquirer (#12305) deps: replace inquirer with enquirer Apr 7, 2021
@google-cla

This comment has been minimized.

@google-cla google-cla bot added cla: no and removed cla: yes labels Apr 8, 2021
@brendankenny

This comment has been minimized.

@google-cla google-cla bot added cla: yes and removed cla: no labels Apr 8, 2021
@brendankenny
Copy link
Member

I resolved the yarn.lock merge conflict due to eslint also switching from inquirer to enquirer

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

Works great! Thanks for making this change happen.

@brendankenny brendankenny changed the title deps: replace inquirer with enquirer deps: replace inquirer with latest enquirer Apr 8, 2021
@brendankenny brendankenny changed the title deps: replace inquirer with latest enquirer deps: replace inquirer with enquirer Apr 8, 2021
@devtools-bot devtools-bot merged commit 11e75c8 into GoogleChrome:master Apr 8, 2021
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.

None yet

4 participants