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

Properly configuring cli #717

Closed
tbergquist-godaddy opened this issue Sep 12, 2019 · 4 comments · Fixed by #768
Closed

Properly configuring cli #717

tbergquist-godaddy opened this issue Sep 12, 2019 · 4 comments · Fixed by #768
Labels
question Further information is requested

Comments

@tbergquist-godaddy
Copy link

Question was originally asked here, but I still have no answer, so I will make a new issue for it instead.

I am also getting this error("Text must not be null or empty"), and I cannot seem to configure it correctly with the current options(I am hoping there is something I missed 😊 )

currently we have a structure like

root/
  node_modules/
  apps/
      web/
      rn-app-1/
      rn-app-2/
  packages/
      shared-components/

Setting root to the project root, it will try to run node ./node_modules/react-native/cli.js config in the project root, and report error on this line : this.packageName = json["project"]["android"]["packageName"].

Setting the root to rn-app-1, gives error on this line def json = new JsonSlurper().parseText(reactNativeConfigOutput)

Both errors makes sense, since the project root does not contain an rn app, and ./node_modules/react-native/cli.js is not a valid path from the workspace root.

What does work is keeping the root at the rn-app-1 workspace and change the command to /node_modules/.bin/react-native config.

I know there is an option using the nohoist of react-native, but I would rather not, since DX is quite bad, we had it before, and upgrading dependencies could take up to 15 minutes ⌛️

So, is there some setting I have missed, or would there be a possibility to add some config to tell rn-cli where to look for the rn-app config?

@tbergquist-godaddy tbergquist-godaddy added the question Further information is requested label Sep 12, 2019
@thymikee
Copy link
Member

We're still working on better story for monorepos, as current support is quite tricky to get and it seems like we lack some documentation around it as well.

@tbergquist-godaddy
Copy link
Author

Might I suggest that you add some config for where the actual react-native project lives? So that we can get the config correctly from the workspace we want to target?

For now, we have no other way than replacing the line in your code with /node_modules/.bin/react-native config, and I feel that solution is quite 💩

@tbergquist-godaddy
Copy link
Author

Ok, I figured out how to make this work.

In this line you have function loadConfig(projectRoot: string = process.cwd()) which is being called from setupAndRun like this const ctx = loadConfig();

If I replace process.cwd() with /apps/rn-app-1 then the project builds and runs as expected.

So, if you in applyNativeModulesAppBuildGradle and applyNativeModulesSettingsGradle add an extra parameter to where it should load the config, and pass it down to loadConfig we can make it work for monorepos.

@grabbou
Copy link
Member

grabbou commented Oct 10, 2019

This issue will be closed once my PR is merged, which describes how to properly configure the CLI in a monorepo-like environments.

Thanks for the investigation here and time spent! It was really helpful while working on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
3 participants