codepush.gradle : Must use react properties to identify node_modules and node binary path
Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):
Description
codepush.gradle should consider the use of some project.ext.react properties.
project.ext.react = [
// override which node gets called and with what additional arguments
nodeExecutableAndArgs: ["/usr/local/bin/node"],
// the root of your project, i.e. where "package.json" lives
root: "$rootDir/../../react-native-apps/YOURPROJECTINANOTHEDIRECTORY/",
The actual file checks where is the node_modules like this:
if (project.hasProperty('nodeModulesPath')) {
nodeModulesPath = project.nodeModulesPath
} else {
nodeModulesPath = "../../node_modules";
}
And runs node like this:
// Make this task run right before the bundle task
def recordFilesBeforeBundleCommand = tasks.create(
name: "recordFilesBeforeBundleCommand${targetName}",
type: Exec) {
commandLine "**node**", "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir
}
// Make this task run right after the bundle task
def generateBundledResourcesHash = tasks.create(
name: "generateBundledResourcesHash${targetName}",
type: Exec) {
commandLine "**node**", "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, "$jsBundleDir/$bundleAssetName", jsBundleDir
}
Bu They should use the mentioned variables as well.
Additional Information
- react-native-code-push version: 1.17.3-beta
- react-native version: 0.42
- iOS/Android/Windows version:
- Does this reproduce on a debug build or release build?
- Does this reproduce on a simulator, or only on a physical device?
Hi @guilharj, thanks for reaching us and sorry for late reply. @iacopo87 has implemented node binary path configuration, please verify. As for identify node_modules – as I can remember I’ve experienced a lot of issues with changing node_modules location due to react-native architecture, so I don’t think if we should configure it, but I could be wrong. Please let me know what do you think.
Ho @sergey-akhalkov thanks for the reply. For sure we have a good case to explain when it's necessary to change the node_modules path. I'm using react-native in the "browfield", I mean that we have our current app in pure android and now we are including some features in react-native.
We've organized the project like this:
- PROJECT_HOME_DIR
--> android app
---->
--> react-native-modules -----> main_project ( this is the project that we generate the bundle and configure code-push) -------->android -------->index.android.js ----->custom_module1 (react-native project imported in main_project) ----->custom_module2 (react-native project imported in main_project)
So in this situation, the NATIVE project that goes to the play store is not main_project/android, it is "android app". And I need to apply the gradle plugin of code-push in that build.gradle , and note inside main_project/android/build.gradle. But the node_modules that I use inside "android app", is located at "../react-native-modules/main_project/node_modules"
That is why I should modify the path: Browfiled projects situation :) Tell me if I was not clear enough.
Thanks again for the reply!.
Hi @guilharj, I've published https://github.com/Microsoft/react-native-code-push/pull/869, could you please have a chance to look at this and verify if it works as expected?
Closing the issue due to fix is merged and verified, thank you @guilharj for your help with this.