react-native-mmkv 1.6.0 → 1.6.1

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.
@@ -2,6 +2,24 @@ import groovy.json.JsonSlurper
2
2
  import org.apache.tools.ant.filters.ReplaceTokens
3
3
  import java.nio.file.Paths
4
4
 
5
+ static def findNodeModules(baseDir) {
6
+ def basePath = baseDir.toPath().normalize()
7
+ // Node's module resolution algorithm searches up to the root directory,
8
+ // after which the base path will be null
9
+ while (basePath) {
10
+ def nodeModulesPath = Paths.get(basePath.toString(), "node_modules")
11
+ def reactNativePath = Paths.get(nodeModulesPath.toString(), "react-native")
12
+ if (nodeModulesPath.toFile().exists() && reactNativePath.toFile().exists()) {
13
+ return nodeModulesPath.toString()
14
+ }
15
+ basePath = basePath.getParent()
16
+ }
17
+ throw new GradleException("MMKV: Failed to find node_modules/ path!")
18
+ }
19
+
20
+ def nodeModules = findNodeModules(projectDir)
21
+ logger.warn("MMKV: node_modules/ found at: ${nodeModules}")
22
+
5
23
  buildscript {
6
24
  repositories {
7
25
  google()
@@ -28,7 +46,6 @@ def getExtOrIntegerDefault(name) {
28
46
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['Mmkv_' + name]).toInteger()
29
47
  }
30
48
 
31
- def found = false
32
49
  def defaultDir = null
33
50
  def androidSourcesDir = null
34
51
  def androidSourcesName = 'React Native sources'
@@ -37,44 +54,18 @@ if (rootProject.ext.has('reactNativeAndroidRoot')) {
37
54
  defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
38
55
  androidSourcesDir = defaultDir.parentFile.toString()
39
56
  } else {
40
- defaultDir = new File(
41
- projectDir,
42
- '/../../../node_modules/react-native/android'
43
- )
57
+ defaultDir = file("$nodeModules/react-native/android")
44
58
  androidSourcesDir = defaultDir.parentFile.toString()
45
59
  }
46
60
 
47
- if (defaultDir.exists()) {
48
- found = true
49
- } else {
50
- def parentDir = rootProject.projectDir
51
- defaultDir = new File(parentDir, '../node_modules/react-native/android')
52
-
53
- 1.upto(5, {
54
- if (found) return true
55
- parentDir = parentDir.parentFile
56
-
57
- androidSourcesDir = new File(
58
- parentDir,
59
- 'node_modules/react-native'
60
- )
61
-
62
- def androidPrebuiltBinaryDir = new File(
63
- parentDir,
64
- 'node_modules/react-native/android'
61
+ if (!defaultDir.exists()) {
62
+ throw new GradleException(
63
+ "${project.name}: React Native android directory (node_modules/react-native/android) does not exist! Resolved node_modules to: ${nodeModules}"
65
64
  )
66
-
67
- if (androidPrebuiltBinaryDir.exists()) {
68
- found = true
69
- } else if (androidSourcesDir.exists()) {
70
- found = true
71
- }
72
- })
73
65
  }
74
66
 
75
-
76
67
  def reactProperties = new Properties()
77
- file("$projectDir/../node_modules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
68
+ file("$nodeModules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
78
69
  def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME").split("\\.")[1].toInteger()
79
70
 
80
71
  android {
@@ -93,7 +84,7 @@ android {
93
84
  abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
94
85
  arguments '-DANDROID_STL=c++_shared',
95
86
  "-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION}",
96
- "-DNODE_MODULES_DIR=${defaultDir.parentFile.parentFile.toString()}"
87
+ "-DNODE_MODULES_DIR=${nodeModules}"
97
88
  }
98
89
  }
99
90
  }
@@ -135,41 +126,9 @@ repositories {
135
126
  mavenCentral()
136
127
  google()
137
128
 
138
- if (defaultDir.exists()) {
139
- maven {
140
- url defaultDir.toString()
141
- name androidSourcesName
142
- }
143
-
144
- logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
145
- } else {
146
- def parentDir = rootProject.projectDir
147
- defaultDir = new File(parentDir, '../node_modules/react-native/android')
148
-
149
- 1.upto(5, {
150
- if (androidPrebuiltBinaryDir.exists()) {
151
- maven {
152
- url androidPrebuiltBinaryDir.toString()
153
- name androidSourcesName
154
- }
155
-
156
- logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
157
- } else if (androidSourcesDir.exists()) {
158
- maven {
159
- url androidSourcesDir.toString()
160
- name androidSourcesName
161
- }
162
-
163
- logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
164
- }
165
- })
166
- }
167
-
168
- if (!found) {
169
- throw new GradleException(
170
- "${project.name}: unable to locate React Native android sources. " +
171
- "Ensure you have you installed React Native as a dependency in your project and try again."
172
- )
129
+ maven {
130
+ url defaultDir.toString()
131
+ name androidSourcesName
173
132
  }
174
133
  }
175
134
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-mmkv",
3
- "version": "1.6.0",
4
- "description": "An efficient, small mobile key-value storage framework developed by WeChat. Works on Android and iOS.",
3
+ "version": "1.6.1",
4
+ "description": "The fastest key/value storage for React Native. ~30x faster than AsyncStorage! Works on Android, iOS and Web.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/index.d.ts",
@@ -28,7 +28,8 @@
28
28
  "typescript": "tsc --noEmit",
29
29
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
30
30
  "lint-ci": "yarn lint -f ./node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js",
31
- "build": "git submodule update --init --recursive && bob build",
31
+ "prepare": "git submodule update --init --recursive",
32
+ "build": "bob build",
32
33
  "update-submodule": "git submodule update --remote --merge",
33
34
  "release": "release-it",
34
35
  "example": "yarn --cwd example",