react-native-ota-hot-update 2.0.1 → 2.0.3
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.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# react-native-ota-hot-update
|
|
2
2
|
|
|
3
|
-
A React Native module that allows you to control hot update same as Code Push, less config than Code Push, you can control version manager, hosting bundle js by your self, this library just control install the hot update after bundle js downloaded from your side. As we know, Code push is going to retirement
|
|
3
|
+
A React Native module that allows you to control hot update same as Code Push, less config than Code Push, you can control version manager, hosting bundle js by your self, this library just control install the hot update after bundle js downloaded from your side. As we know, Code push is going to retirement soon, that why i create that library for you can control bundle js from your backend side.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
iOS GIF | Android GIF
|
|
@@ -12,7 +12,7 @@ iOS GIF | Android GIF
|
|
|
12
12
|
|
|
13
13
|
## New architecture supported
|
|
14
14
|
|
|
15
|
-
New architecture backward compatibility supported from version 2, it also supported old architecture, for source code of
|
|
15
|
+
New architecture backward compatibility supported from version 2, it also supported old architecture, for source code of version 1.x.x please refer to branch `oldArch`, you might need install version 1.x.x if you are using react native < 0.70
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -86,29 +86,31 @@ android:requestLegacyExternalStorage="true"
|
|
|
86
86
|
`
|
|
87
87
|
|
|
88
88
|
## That's it, can check the example code
|
|
89
|
+
`Remember hot update just work at release mode, debug mode won't working`
|
|
90
|
+
|
|
89
91
|
|
|
90
92
|
Here is the guideline to control bundle js by yourself, in here i am using Firebase storage to store bundlejs file and a json file that announce new version is comming:
|
|
91
93
|
|
|
92
|
-
#### 1.Add these script into your package.json to export bundlejs file:
|
|
94
|
+
#### 1.Add these script into your package.json to export bundlejs file and source map file:
|
|
93
95
|
|
|
94
96
|
- For react native CLI:
|
|
95
97
|
```bash
|
|
96
98
|
"scripts": {
|
|
97
|
-
"export-android": "mkdir -p android/output && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/output/index.android.bundle --assets-dest android/output
|
|
98
|
-
"export-ios": "mkdir -p ios/output && react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/output/main.jsbundle --assets-dest ios/output && cd ios && find output -type f | zip main.jsbundle.zip -@ && cd .. && rm -rf ios/output"
|
|
99
|
+
"export-android": "mkdir -p android/output && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/output/index.android.bundle --assets-dest android/output --sourcemap-output android/sourcemap.js && cd android && find output -type f | zip index.android.bundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf android/output && rm -rf android/sourcemap.js",
|
|
100
|
+
"export-ios": "mkdir -p ios/output && react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/output/main.jsbundle --assets-dest ios/output --sourcemap-output ios/sourcemap.js && cd ios && find output -type f | zip main.jsbundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf ios/output && rm -rf ios/sourcemap.js"
|
|
99
101
|
}
|
|
100
102
|
```
|
|
101
103
|
- For expo / expo bare project:
|
|
102
104
|
|
|
103
105
|
```bash
|
|
104
106
|
"scripts": {
|
|
105
|
-
"export-android": "mkdir -p android/output && npx expo export:embed --platform android --entry-file node_modules/expo/AppEntry.js --bundle-output android/output/index.android.bundle --dev false --assets-dest android/output && cd android && find output -type f | zip index.android.bundle.zip -@ && cd .. && rm -rf android/output",
|
|
106
|
-
"export-ios": "mkdir -p ios/output && npx expo export:embed --platform ios --entry-file node_modules/expo/AppEntry.js --bundle-output ios/output/main.jsbundle --dev false --assets-dest ios/output && cd ios && find output -type f | zip main.jsbundle.zip -@ && cd .. && rm -rf ios/output"
|
|
107
|
+
"export-android": "mkdir -p android/output && npx expo export:embed --platform android --entry-file node_modules/expo/AppEntry.js --bundle-output android/output/index.android.bundle --dev false --assets-dest android/output --sourcemap-output android/sourcemap.js && cd android && find output -type f | zip index.android.bundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf android/output && rm -rf android/sourcemap.js",
|
|
108
|
+
"export-ios": "mkdir -p ios/output && npx expo export:embed --platform ios --entry-file node_modules/expo/AppEntry.js --bundle-output ios/output/main.jsbundle --dev false --assets-dest ios/output --sourcemap-output ios/sourcemap.js && cd ios && find output -type f | zip main.jsbundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf ios/output && rm -rf ios/sourcemap.js"
|
|
107
109
|
}
|
|
108
110
|
```
|
|
109
111
|
For expo you might need check path of `--entry-file node_modules/expo/AppEntry.js`, get it from package.json / main
|
|
110
112
|
|
|
111
|
-
These commands are export bundle file and compress it as a zip file, one for android and one for ios. You can create your own script that export and auto upload to your server.
|
|
113
|
+
These commands are export bundle file and source map file then compress it as a zip file, one for android and one for ios. You can create your own script that export and auto upload to your server. For source map file you can ignore or use that with your purpose to debug in release mode.
|
|
112
114
|
|
|
113
115
|
Then create an json file: `update.json` like that:
|
|
114
116
|
```bash
|
|
@@ -191,4 +193,8 @@ The same method as `react-native-blob-util` or `rn-fetch-blob`
|
|
|
191
193
|
|
|
192
194
|
## License
|
|
193
195
|
|
|
194
|
-
[MIT](LICENSE
|
|
196
|
+
[MIT](LICENSE)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
### Sponsor this project
|
|
200
|
+
https://paypal.me/vantuan88291
|
|
@@ -84,17 +84,21 @@ class OtaHotUpdateModule internal constructor(context: ReactApplicationContext)
|
|
|
84
84
|
@ReactMethod
|
|
85
85
|
override fun setupBundlePath(path: String?, extension: String?, promise: Promise) {
|
|
86
86
|
if (path != null) {
|
|
87
|
-
deleteOldBundleIfneeded()
|
|
88
87
|
val file = File(path)
|
|
89
88
|
if (file.exists() && file.isFile) {
|
|
89
|
+
deleteOldBundleIfneeded()
|
|
90
90
|
val fileUnzip = extractZipFile(file, extension ?: ".bundle")
|
|
91
|
-
Log.d("setupBundlePath----: ", fileUnzip!!)
|
|
92
91
|
if (fileUnzip != null) {
|
|
92
|
+
Log.d("setupBundlePath----: ", fileUnzip)
|
|
93
93
|
file.delete()
|
|
94
94
|
val sharedPrefs = SharedPrefs(reactApplicationContext)
|
|
95
95
|
sharedPrefs.putString(PATH, fileUnzip)
|
|
96
96
|
promise.resolve(true)
|
|
97
97
|
} else {
|
|
98
|
+
file.delete()
|
|
99
|
+
deleteDirectory(file.parentFile)
|
|
100
|
+
val sharedPrefs = SharedPrefs(reactApplicationContext)
|
|
101
|
+
sharedPrefs.putString(PATH, "")
|
|
98
102
|
promise.resolve(false)
|
|
99
103
|
}
|
|
100
104
|
} else {
|
package/ios/OtaHotUpdate.mm
CHANGED
|
@@ -171,8 +171,8 @@ RCT_EXPORT_METHOD(setupBundlePath:(NSString *)path extension:(NSString *)extensi
|
|
|
171
171
|
[self removeBundleIfNeeded];
|
|
172
172
|
//Unzip file
|
|
173
173
|
NSString *extractedFilePath = [self unzipFileAtPath:path extension:(extension != nil) ? extension : @".jsbundle"];
|
|
174
|
-
NSLog(@"file extraction----- %@", extractedFilePath);
|
|
175
174
|
if (extractedFilePath) {
|
|
175
|
+
NSLog(@"file extraction----- %@", extractedFilePath);
|
|
176
176
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
177
177
|
[defaults setObject:extractedFilePath forKey:@"PATH"];
|
|
178
178
|
[defaults synchronize];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-ota-hot-update",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Hot update for react native",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -46,9 +46,15 @@
|
|
|
46
46
|
"release": "release-it"
|
|
47
47
|
},
|
|
48
48
|
"keywords": [
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
49
|
+
"hot-update",
|
|
50
|
+
"ota",
|
|
51
|
+
"code-push",
|
|
52
|
+
"update",
|
|
53
|
+
"react-native-hotupdate",
|
|
54
|
+
"react-native-codepush",
|
|
55
|
+
"ota-hot-update",
|
|
56
|
+
"custom-ota",
|
|
57
|
+
"rn-hotupdate"
|
|
52
58
|
],
|
|
53
59
|
"repository": {
|
|
54
60
|
"type": "git",
|