-
Notifications
You must be signed in to change notification settings - Fork 904
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
feat: add react-native doctor
#532
feat: add react-native doctor
#532
Conversation
Wow, this looks awesome! |
Oh my god, I must say, we need that! |
@Inovassist-dev: thanks for the feedback on this, that's what we are aiming for! This week I'm pretty busy, gonna get back to work on this by next week 🙂 |
Hey @lucasbento, this is amazing! I'd love to help you get this through, let me know what you need! |
This would be great, thanks for getting it started! Thoughts on building this in such a way that we can compose it with other tools and IDEs (e.g. support JSON output instead of logging direct to console). cc @thymikee |
Can we call this |
@cpojer I don't think that the name "fix" would be a great idea. |
@sahrens definitely open to that |
I'd love to see this landed and iterated upon. How many features do we need to wait for this to have before landing an MVP? |
Those are the installations that I would like to have in: Platform agnostic
Android
iOS
Totally discussable though, I would like to have this on @rickhanlonii @sahrens: a review on the source would be very much appreciated, I'm trying to build something as modular as possible, the JSON output was already asked on #51 and I'm definitely on board with that. The first thing that I need help with is a little review and adding more installation checks, if anyone of you want to help with that then let's do it! |
I realize that you are looking to add more functionality in the future, but right now this is exactly the feature set of Solidarity https://github.com/infinitered/solidarity Might we consider using this and combining efforts on the automatic fix part on the wishlist? |
@tabrindle Aolidariy is great! Will support things like checking for IDE installations, android SDKs, xcode versions, vscode/intellij/android studio plugins? |
Solidarity can do anything envinfo does, as it uses it under the hood. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great, I really like the way the health checks are handled so that it's easy to add a new check. I think we can go with this and iterate 👍
}; | ||
|
||
const doesSoftwareNeedToBeFixed = ({version, versionRange}) => | ||
version === 'Not Found' || !semver.satisfies(version, versionRange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that semver can throw here if for some reason one of the versions are invalid. e.g. for me, I'm getting the string "Using globally installed version of Yarn"
We'll at least need to try/catch here, but in the catch we may want to log a quality error and consider crashing because if we don't get a semver by this point that the individual issue needs to diagnose why they don't have a semver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you install yarn? I want to reproduce that locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably npm install -g yarn
|
||
export default (async function runDoctor() { | ||
const Loader = getLoader(); | ||
const loader = new Loader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: naming this a "loader" when it's not really showing a loading message and is mostly only a logger is hard to read (I recognize that this is called a loader elsewhere so we should either change all usages or stay consistent)
try { | ||
await issueToFix.runAutomaticFix({loader: issueSpinner}); | ||
} catch (error) { | ||
// TODO: log the error in a meaningful way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would console.error be better than nothing for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't pay much attention to this part yet, it's hard to log an error right now as the loader is on top of everything, so first it needs to stop the loader, log an error and then continue to the next automatic fix.
@tabrindle, I think it would be nice to have something like Solidarity already integrated with React Native, dont you think? |
@rickhanlonii: thank you so much for the review! gonna check it out.
@tabrindle: I checked solidarity before starting this and I struggled to understand how it would be used on the core of the CLI, perhaps we should discuss its possibilities somewhere else? |
@lucasbento do you want to get this in an start iterating? |
I like the direction where it's going. Let's make sure to mark it as experimental (e.g. in the description and the docs, or add docs later) and it doesn't break stable commands. And ship it |
runAutomaticFix: async ({loader}) => { | ||
try { | ||
// First attempt to install `cocoapods` | ||
await execa('gem', ['install', 'cocoapods']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rely on Homebrew/MacPorts to avoid having to invoke sudo
? Or at least use them if they are installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a helper function for that, let's use it :) https://github.com/react-native-community/cli/blob/master/packages/cli/src/tools/installPods.js
|
||
process.exit(0); | ||
} catch (err) { | ||
// TODO: log error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to be done now or in a separate PR?
// or if we can't identify that the user uses yarn or npm | ||
visible: | ||
packageManager === PACKAGE_MANAGERS.YARN || packageManager === undefined, | ||
runAutomaticFix: () => console.log('should fix node'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? Isn't Yarn installed separately?
versionRange: versionRanges.WATCHMAN, | ||
}), | ||
}), | ||
runAutomaticFix: () => console.log('should fix watchman'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this placeholder text?
|
||
const label = 'ANDROID_HOME'; | ||
|
||
const iosDeploy = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename
import versionRanges from '../versionRanges'; | ||
import {doesSoftwareNeedToBeFixed} from '../checkInstallation'; | ||
|
||
const iosDeploy = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename
import versionRanges from '../versionRanges'; | ||
import {doesSoftwareNeedToBeFixed} from '../checkInstallation'; | ||
|
||
const iosDeploy = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename
|
||
// List of answers on how to set `ANDROID_HOME` for each platform | ||
const URLS = { | ||
darwin: 'https://stackoverflow.com/a/28296325/4252781', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be smart to inline these answers
5770c61
to
4f3f016
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the remaining stuff in followup PRs 👍
Summary:
This PR fixes #51, it adds a
doctor
command to verify the softwares/libraries/tools that we depend on and make sure that they match the minimum requirements needed by react-native.The version for
Node.js
is not correct as I put it there for testing purposes.Test Plan:
cocoapods
orios-deploy
(easiest ones to try);doctor
commandTODOS:
--fix
argument that should go directly to fixing it--dry-run
option--contributor
option to only show Android NDK if specified