@amplytools/react-native-amply-sdk 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,62 @@ def amplySdkVersion = project.findProperty('amplySdkVersion') ?: System.getenv('
19
19
  group = 'tools.amply'
20
20
  version = amplySdkVersion
21
21
 
22
- def reactNativeRootDir = file("$projectDir/../node_modules/react-native")
22
+ // Locate node_modules/react-native. Mirrors the resolution order used by
23
+ // react-native-reanimated and react-native-screens:
24
+ // 1. Explicit override (REACT_NATIVE_NODE_MODULES_DIR) — gradle.properties,
25
+ // -P flag, or ext set by the consumer app.
26
+ // 2. Path-shape candidates — fast, covers standard RN apps + 1-2 level
27
+ // monorepos + this repo's own examples.
28
+ // 3. `node --print require.resolve(...)` — last-resort, handles pnpm and
29
+ // any non-standard hoisting.
30
+ def safeAppExtGet(prop, fallback) {
31
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
32
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
33
+ }
34
+
35
+ def resolveReactNativeDirectory() {
36
+ def userDefined = project.findProperty("REACT_NATIVE_NODE_MODULES_DIR") ?:
37
+ rootProject.findProperty("REACT_NATIVE_NODE_MODULES_DIR") ?:
38
+ safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
39
+
40
+ if (userDefined != null) {
41
+ return file(userDefined)
42
+ }
43
+
44
+ def candidates = [
45
+ file("${rootProject.projectDir}/../node_modules/react-native"), // standard RN app
46
+ file("$projectDir/../node_modules/react-native"), // nested (dev/legacy)
47
+ file("${rootProject.projectDir}/../../node_modules/react-native"), // 1-level monorepo
48
+ file("${rootProject.projectDir}/../../../node_modules/react-native"), // 2-level monorepo
49
+ ]
50
+
51
+ def found = candidates.find { it.exists() }
52
+ if (found != null) {
53
+ return found
54
+ }
55
+
56
+ def stdout = new ByteArrayOutputStream()
57
+ def result = exec {
58
+ workingDir(rootProject.projectDir)
59
+ commandLine("node", "--print", "require.resolve('react-native/package.json')")
60
+ standardOutput = stdout
61
+ ignoreExitValue = true
62
+ }
63
+
64
+ if (result.exitValue == 0) {
65
+ def pkg = file(stdout.toString().trim())
66
+ if (pkg.exists()) {
67
+ return pkg.parentFile
68
+ }
69
+ }
70
+
71
+ throw new GradleException(
72
+ "Could not find node_modules/react-native. " +
73
+ "Set -PREACT_NATIVE_NODE_MODULES_DIR=/abs/path/to/node_modules/react-native"
74
+ )
75
+ }
76
+
77
+ def reactNativeRootDir = resolveReactNativeDirectory()
23
78
  def reactNativeArchitectures =
24
79
  project.hasProperty("reactNativeArchitectures") ?
25
80
  project.getProperty("reactNativeArchitectures").split(",") :
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplytools/react-native-amply-sdk",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "React Native SDK for Amply: Mobile SDK to orchestrate in-app experiences and campaigns remotely, without app releases",
5
5
  "license": "MIT",
6
6
  "repository": {