Uh oh!
There was an error while loading. Please reload this page.
feat: run npx from JS app dir - #824
Conversation
Uh oh!
There was an error while loading. Please reload this page.
| def cmdProcess | ||
| def npx = Os.isFamily(Os.FAMILY_WINDOWS) ? "npx.cmd" : "npx" | ||
| def command = "${npx} --quiet react-native config" | ||
| def command = "${npx} --quiet --no-install react-native config" |
There was a problem hiding this comment.
Adding --no-install so we don't accidentally install react-native into local npm cache. Verified that it's already present in npx shipped with Node 8.
There was a problem hiding this comment.
Not really sure, but it's preferable to run with --no-install anyway. Feel free to send a PR, as I don't want to mix iOS and Android in this one :)
Uh oh!
There was an error while loading. Please reload this page.
AndreiCalazans
commented
Oct 26, 2019
I applied these changes inside node_modules and I"m still seeing an issue, it's no longer the same one pointed out in #793. Here is a gist of the error outputted by Gradle |
thymikee
commented
Oct 27, 2019
@AndreiCalazans it's a normal project structure, in terms of running from Android Studio. I'll need you to debug this a little deeper, as Gradle sync and build works on my machine. This is likely an environmental issue I cannot reproduce. |
grabbou
commented
Oct 29, 2019
How about simple heuristics here: if |
thymikee
commented
Oct 29, 2019
I'm not sure how to access the -p value. Cc @Salakar |
Afaik it's not possible to read this. Only properties passed via |
codestersunion
commented
Oct 29, 2019
In my testing, a |
grabbou
commented
Nov 4, 2019
Uh oh!
There was an error while loading. Please reload this page.
ifyapishore
commented
Nov 5, 2019
via email
As far as I know, module scope is better because Gradle can run task in
separate thread with different env variables and current dir. …On Tue, Nov 5, 2019, 23:04 Mike Grabowski ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/platform-android/native_modules.gradle
<#824 (comment)>
:
> this.logger = logger
+ this.jsAppDir = jsAppDir
Is this.jsAppDir needed or can be a module variable? (Gradle newbie here)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#824?email_source=notifications&email_token=AEB3SYJH4V35E53Q3IUEGITQSGKSLA5CNFSM4JEVRO22YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCKK74WA#pullrequestreview-311819864>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEB3SYLDO34SK333R3XR4MLQSGKSLANCNFSM4JEVRO2Q>
.
|
4ab5666 to
65e2275Comparelucasbento
commented
Nov 12, 2019
Bump Looking forward to v3 |
thymikee
commented
Nov 12, 2019
grabbou
commented
Nov 14, 2019
Do we know why the Windows CI is failing? It's blocking few important PRs that are good to be merged otherwise. I'd ship them all if that's not the case. |
| import org.gradle.initialization.DefaultSettings | ||
| import org.apache.tools.ant.taskdefs.condition.Os | ||
| def jsAppDir = buildscript.sourceFile.toString().split("node_modules/@react-native-community/cli-platform-android/native_modules.gradle")[0] |
There was a problem hiding this comment.
nit: I think we can just split by node_modules/@react-native-community/cli-platform-android, which is a path to the module (the gradle file at the end is not needed and may break if we refactor files).
I was thinking to go with node_modules, but that would break in case dependencies were not hoisted.
| ArrayList<HashMap<String, String>> reactNativeModules = new ArrayList<HashMap<String, String>>() | ||
| def npx = Os.isFamily(Os.FAMILY_WINDOWS) ? "npx.cmd" : "npx" | ||
| def command = "${npx} --quiet --no-install react-native config" | ||
| // Running npx from the directory of the JS app which holds this script in its node_modules. |
There was a problem hiding this comment.
nit: blank space before comment and prefer /* */?
nit: I'd rephrase the comment a bit to explain when such a case happens, in other words, when it's run with a -p flag. We can also link to this PR for further ref.
grabbou
left a comment
There was a problem hiding this comment.
Looks good. Thanks for keeping this clean. Left few commits and let's ship it.
829a685 to
a978a53Compareghost
commented
Nov 15, 2019
I believe this has broken projects running in a monorepo as the react-native config needs to be run in the package directory, however is now running in the root directory as the node_module dependencies are hoisted. |
thymikee
commented
Nov 15, 2019
@mbios could you provide a repro we could investigate? |
yields this: but works without removing the yarn.lock as that points to 3.0.0 alpha |
thymikee
commented
Nov 15, 2019
Yep, it's a regression, thanks for noticing! |
Summary:
Gradle may be run from a driectory that's outside of JS project, with a passed project dir (through
-pflag) likepath/to/app/android/gradlew bundleRelease -p ../app/android/app.Gradle CWD is usually (maybe always, but they don't give guarantees) set to the directory where it's ran from. This tricks
npx, which doesn't know where to findreact-nativebinary. To account for it, we can spawnnpxwith a CWD passed to it. We don't need an exact path to android project directory, path to the project which holds@react-native-community/cliin node_modules is just fine with current config search mechanism.I'm not 100% sure about this fix, open for discussion.
Fixes#793
Fixes#804
Test Plan:
I don't have an automated test for this, you'll need to verify on repro provided in #793.