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

Allow platforms and community packages to provide additional health checks #1231

Merged
merged 10 commits into from
Sep 21, 2020

Conversation

acoates-ms
Copy link
Contributor

Summary:

Out of tree platforms, and specific community modules may have their own set of health checks that could help developers diagnose issues and be more productive. In particular I am looking at how to have react-native-windows provide checks to doctor. This change allows any out of tree platform to be able to provide their own checks.

Some talking points:

  • I added the extension point so that any package could add doctor health checks rather than just for platforms. I could see that other packages might also want to add healthChecks for any specific native dependencies, or other checks.
  • This does increase the public API for the CLI. So, there should be a discussion of the API I'm exposing.
  • I slightly modified the API for RunAutomaticFix to provide the logManualInstallation method as an arg. In addition to the Ora instance, this seems to be one of the primary APIs that RunAutomaticFixes use to interact with the CLI.
  • I did a lame copy/paste of the typings for Ora in the cli-types project. I could also just make ora a pacakge dependency of cli-types, but that seems to go against the spirit of that pacakge.

Test Plan:

I'm posting this early because I expect lots of feedback. I've run this locally with changes to react-native-windows to run through the end to end of adding health checks in react-native-windows and them showing up in doctor.

@thymikee
Copy link
Member

Nice! Kindly asking @lucasbento @molant to review :)

Copy link
Member

@lucasbento lucasbento left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long to review this, I checked this PR multiple times and I was sure that I had already submitted a review.

I don't really have much to comment here besides that this is an awesome initiative.

The thing that we would need to work on the most is the documentation, I think the API can get pretty confusing to understand without some visuals (screenshots of the list, the loading part, how errors are printed out, etc).

I would love to have this merged soon as it's a major contribution and will increase the value of react-native doctor greatly.

Comment on lines +12 to +29
```js
module.exports = {
healthChecks: [
{
label: 'Foo',
healthchecks: [
label: 'bar-installed',
getDiagnostics: async () => ({
needsToBeFixed: !isBarInstalled()
}),
runAutomaticFix: async ({loader}) => {
await installBar();
loader.succeed();
},
}
],
};
```
Copy link
Member

Choose a reason for hiding this comment

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

This is so awesome.

packages/cli/src/commands/doctor/healthchecks/index.ts Outdated Show resolved Hide resolved
@acoates-ms
Copy link
Contributor Author

I added a little more documentation, but I think its probably something we can add to later. Hopefully once this merges+publishes I can add links to samples etc to at least react-native-windows where we will have a bunch of additional health checks.

npm: AvailableInformation;
Watchman: AvailableInformation;
};
SDKs: {
Copy link
Contributor

Choose a reason for hiding this comment

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

is the idea that this is what will get asked of envinfo? if so, please make sure that info continues to report the windows properties we care about: Windows SDKs, VS installs, dev mode reg keys.

Copy link
Member

@grabbou grabbou left a comment

Choose a reason for hiding this comment

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

Love this feautre. LGTM. Just a quick question on the type defs itself (left somewhere in the review) and this one is good to go from my side!

@grabbou
Copy link
Member

grabbou commented Sep 17, 2020

PS. Looks like a little rebase to resolve conflicts might be needed

@grabbou grabbou merged commit be37d64 into react-native-community:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants