@turbopush/react-native-code-push 10.2.5 → 10.3.0-rc.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.
- package/LICENSE.md +3 -1
- package/README.md +118 -39
- package/android/app/src/debug/AndroidManifest.xml +9 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +33 -21
- package/package.json +15 -12
- package/request-fetch-adapter.js +35 -15
- package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
- package/.azurepipelines/test-rn-code-push.yml +0 -94
- package/.config/CredScanSuppressions.json +0 -14
- package/.gitconfig +0 -6
- package/CONTRIBUTING.md +0 -134
- package/SECURITY.md +0 -41
- package/docs/api-android.md +0 -52
- package/docs/api-ios.md +0 -31
- package/docs/api-js.md +0 -592
- package/docs/multi-deployment-testing-android.md +0 -55
- package/docs/multi-deployment-testing-ios.md +0 -59
- package/docs/setup-android.md +0 -92
- package/docs/setup-ios.md +0 -138
- package/docs/setup-windows.md +0 -121
- package/expo.js +0 -324
- package/tsconfig.json +0 -17
- package/tslint.json +0 -32
- package/windows/CodePush/CodePush.def +0 -3
- package/windows/CodePush/CodePush.vcxproj +0 -198
- package/windows/CodePush/CodePush.vcxproj.filters +0 -91
- package/windows/CodePush/CodePushConfig.cpp +0 -104
- package/windows/CodePush/CodePushConfig.h +0 -66
- package/windows/CodePush/CodePushConfig.idl +0 -12
- package/windows/CodePush/CodePushDownloadHandler.cpp +0 -73
- package/windows/CodePush/CodePushDownloadHandler.h +0 -32
- package/windows/CodePush/CodePushNativeModule.cpp +0 -934
- package/windows/CodePush/CodePushNativeModule.h +0 -247
- package/windows/CodePush/CodePushPackage.cpp +0 -456
- package/windows/CodePush/CodePushPackage.h +0 -49
- package/windows/CodePush/CodePushTelemetryManager.cpp +0 -213
- package/windows/CodePush/CodePushTelemetryManager.h +0 -29
- package/windows/CodePush/CodePushUpdateUtils.cpp +0 -86
- package/windows/CodePush/CodePushUpdateUtils.h +0 -38
- package/windows/CodePush/CodePushUtils.cpp +0 -29
- package/windows/CodePush/CodePushUtils.h +0 -18
- package/windows/CodePush/FileUtils.cpp +0 -131
- package/windows/CodePush/FileUtils.h +0 -28
- package/windows/CodePush/PropertySheet.props +0 -16
- package/windows/CodePush/ReactPackageProvider.cpp +0 -15
- package/windows/CodePush/ReactPackageProvider.h +0 -22
- package/windows/CodePush/ReactPackageProvider.idl +0 -9
- package/windows/CodePush/miniz/LICENSE +0 -22
- package/windows/CodePush/miniz/miniz.c +0 -7657
- package/windows/CodePush/miniz/miniz.h +0 -1338
- package/windows/CodePush/miniz/readme.md +0 -37
- package/windows/CodePush/packages.config +0 -4
- package/windows/CodePush/pch.cpp +0 -1
- package/windows/CodePush/pch.h +0 -4
- package/windows-legacy/CodePush/CodePush.csproj +0 -128
- package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
- package/windows-legacy/CodePush/FileUtils.cs +0 -40
- package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
- package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
- package/windows-legacy/CodePush/UpdateManager.cs +0 -305
- package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
- package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
- package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
- package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
- package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
- package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
- package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
- package/windows-legacy/CodePush.Net46/packages.config +0 -5
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
- package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
- package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
- package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
- package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
- package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
- package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
- package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
- package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
- package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
- package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
- package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
- package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,44 +1,86 @@
|
|
|
1
|
-
# React Native
|
|
2
|
-
## 🌐 [Turbopush](https://turbopush.org)
|
|
3
|
-
## 🚀 [Sign up](https://accounts.turbopush.org/sign-up) to use Turbopush
|
|
4
|
-
## 📚 [Documentation](https://docs.turbopush.org) to get started
|
|
1
|
+
# Turbopush — React Native Plugin for CodePush
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@turbopush/react-native-code-push)
|
|
4
|
+
[](LICENSE.md)
|
|
5
|
+
|
|
6
|
+
## [Sign up](https://accounts.turbopush.org/sign-up?utm_source=readme) to use Turbopush | [Documentation](https://turbopush.org/docs?utm_source=readme) to get started
|
|
7
|
+
|
|
8
|
+
This plugin provides client-side integration for the [Turbopush service](https://turbopush.org/?utm_source=readme), allowing you to easily add a dynamic update experience to your React Native or Expo app(s).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
- [How does it work?](#how-does-it-work)
|
|
15
|
+
- [Key Features](#key-features)
|
|
16
|
+
- [Requirements](#requirements)
|
|
17
|
+
- [React Native Setup](#react-native-setup)
|
|
18
|
+
- [Expo Setup](#expo-setup)
|
|
19
|
+
- [Basic Usage](#basic-usage)
|
|
20
|
+
- [Store Guideline Compliance](#store-guideline-compliance)
|
|
21
|
+
- [Contributing](#contributing)
|
|
22
|
+
- [License](#license)
|
|
23
|
+
|
|
24
|
+
---
|
|
7
25
|
|
|
8
26
|
## How does it work?
|
|
9
27
|
|
|
10
28
|
A React Native app is composed of JavaScript files and any accompanying [images](https://reactnative.dev/docs/image), which are bundled together by the [metro bundler](https://github.com/facebook/metro) and distributed as part of a platform-specific binary (i.e. an `.ipa` or `.apk` file). Once the app is released, updating either the JavaScript code (e.g. making bug fixes, adding new features) or image assets, requires you to recompile and redistribute the entire binary, which of course, includes any review time associated with the store(s) you are publishing to.
|
|
11
29
|
|
|
12
|
-
The Turbopush plugin helps get product improvements in front of your end users instantly, by keeping your JavaScript and images synchronized with updates you release to the Turbopush server. This way, your app gets the benefits of an offline mobile experience, as well as the "web-like" agility of side-loading updates as soon as they are available.
|
|
30
|
+
The Turbopush plugin helps get product improvements in front of your end users instantly, by keeping your JavaScript and images synchronized with updates you release to the Turbopush server. This way, your app gets the benefits of an offline mobile experience, as well as the "web-like" agility of side-loading updates as soon as they are available.
|
|
31
|
+
|
|
32
|
+
In order to ensure that your end users always have a functioning version of your app, the Turbopush plugin maintains a copy of the previous update, so that in the event that you accidentally push an update which includes a crash, it can automatically roll back. This way, you can rest assured that your newfound release agility won't result in users becoming blocked before you have a chance to roll back on the server.
|
|
33
|
+
|
|
34
|
+
> **Note:** Any product changes which touch native code (e.g. modifying your `AppDelegate.mm`/`MainActivity.java`/`MainActivity.kt`/`AppDelegate.swift` file, adding a new plugin) cannot be distributed via Turbopush, and therefore, must be updated via the appropriate store(s).
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Key Features
|
|
39
|
+
|
|
40
|
+
- **Automatic Rollback**: If an update causes a crash, the plugin automatically rolls back to the previous working version.
|
|
41
|
+
- **Multiple Platforms**: Supports Android and iOS.
|
|
42
|
+
- **Multiple Channels**: Release updates to different groups of users via separate channels.
|
|
43
|
+
- **Multiple Environments**: Test updates in staging before releasing to all users.
|
|
44
|
+
- **Expo Support**: First-class support via our [Expo plugin](https://turbopush.org/docs/setup/expo-setup?utm_source=readme).
|
|
45
|
+
- **New Architecture**: Supports both React Native old and new architecture (Fabric/TurboModules).
|
|
46
|
+
|
|
47
|
+
---
|
|
13
48
|
|
|
14
|
-
|
|
49
|
+
## Requirements
|
|
15
50
|
|
|
16
|
-
|
|
51
|
+
- **React Native**: 0.70 or higher
|
|
52
|
+
- **iOS**: 15.5 or higher
|
|
53
|
+
- **Android**: API level 21 (Android 5.0) or higher
|
|
54
|
+
- **Node**: 16 or higher
|
|
55
|
+
|
|
56
|
+
---
|
|
17
57
|
|
|
18
58
|
## React Native Setup
|
|
19
59
|
|
|
20
|
-
|
|
60
|
+
NPM:
|
|
21
61
|
```bash
|
|
22
|
-
|
|
62
|
+
npm install --save @turbopush/react-native-code-push
|
|
23
63
|
```
|
|
24
64
|
|
|
25
|
-
|
|
65
|
+
Yarn:
|
|
26
66
|
```bash
|
|
27
|
-
|
|
67
|
+
yarn add @turbopush/react-native-code-push
|
|
28
68
|
```
|
|
29
69
|
|
|
30
|
-
Follow the [Getting Started](https://
|
|
70
|
+
Follow the [Getting Started](https://turbopush.org/docs/?platform=react-native&utm_source=readme) guide to configure your app.
|
|
71
|
+
|
|
72
|
+
---
|
|
31
73
|
|
|
32
74
|
## Expo Setup
|
|
33
75
|
|
|
34
|
-
|
|
76
|
+
NPM:
|
|
35
77
|
```bash
|
|
36
|
-
|
|
78
|
+
npm install --save @turbopush/react-native-code-push @turbopush/turbopush-expo-plugin expo-build-properties
|
|
37
79
|
```
|
|
38
80
|
|
|
39
|
-
|
|
81
|
+
Yarn:
|
|
40
82
|
```bash
|
|
41
|
-
|
|
83
|
+
yarn add @turbopush/react-native-code-push @turbopush/turbopush-expo-plugin expo-build-properties
|
|
42
84
|
```
|
|
43
85
|
|
|
44
86
|
Add the following to your `app.json` or `app.config.ts` file:
|
|
@@ -50,57 +92,94 @@ Add the following to your `app.json` or `app.config.ts` file:
|
|
|
50
92
|
"expo-build-properties",
|
|
51
93
|
{
|
|
52
94
|
"ios": {
|
|
53
|
-
"deploymentTarget": "15.5"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
95
|
+
"deploymentTarget": "15.5"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
56
98
|
],
|
|
57
99
|
[
|
|
58
100
|
"@turbopush/turbopush-expo-plugin",
|
|
59
101
|
{
|
|
60
102
|
"android": {
|
|
61
|
-
"CodePushDeploymentKey": "YOUR_ANDROID_CODE_PUSH_KEY"
|
|
103
|
+
"CodePushDeploymentKey": "YOUR_ANDROID_CODE_PUSH_KEY"
|
|
62
104
|
},
|
|
63
105
|
"ios": {
|
|
64
|
-
"CodePushDeploymentKey": "YOUR_IOS_CODE_PUSH_KEY"
|
|
65
|
-
}
|
|
106
|
+
"CodePushDeploymentKey": "YOUR_IOS_CODE_PUSH_KEY"
|
|
107
|
+
}
|
|
66
108
|
}
|
|
67
109
|
]
|
|
68
110
|
]
|
|
69
111
|
}
|
|
70
112
|
```
|
|
71
113
|
|
|
72
|
-
For more information, see the [Getting Started](https://
|
|
114
|
+
For more information, see the [Getting Started](https://turbopush.org/docs/?platform=expo&utm_source=readme) guide.
|
|
73
115
|
|
|
74
|
-
|
|
116
|
+
---
|
|
75
117
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
## Basic Usage
|
|
119
|
+
|
|
120
|
+
The simplest way to integrate Turbopush is to wrap your root component with the `codePush` HOC. This will automatically check for and apply updates on each app launch.
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import React from 'react';
|
|
124
|
+
import { View, Text } from 'react-native';
|
|
125
|
+
import codePush from '@turbopush/react-native-code-push';
|
|
126
|
+
|
|
127
|
+
function App() {
|
|
128
|
+
return (
|
|
129
|
+
<View>
|
|
130
|
+
<Text>My App</Text>
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export default codePush(App);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
You can also trigger a manual update check at any point:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import codePush from '@turbopush/react-native-code-push';
|
|
142
|
+
|
|
143
|
+
async function checkForUpdate() {
|
|
144
|
+
const update = await codePush.checkForUpdate();
|
|
145
|
+
if (update) {
|
|
146
|
+
await codePush.sync();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
For advanced configuration options (update dialogs, install modes, rollback handling), see the [full documentation](https://turbopush.org/docs?utm_source=readme).
|
|
152
|
+
|
|
153
|
+
---
|
|
81
154
|
|
|
82
155
|
## Store Guideline Compliance
|
|
83
156
|
|
|
84
|
-
|
|
157
|
+
### Google Play
|
|
85
158
|
|
|
86
|
-
|
|
159
|
+
The third paragraph of [Device and Network Abuse](https://support.google.com/googleplay/android-developer/answer/9888379?hl=en) states that updating source code by any method other than Google Play's update mechanism is restricted. However, this restriction does not apply to updating JavaScript bundles:
|
|
87
160
|
|
|
88
|
-
Third paragraph of [Device and Network Abuse](https://support.google.com/googleplay/android-developer/answer/9888379?hl=en) topic describe that updating source code by any method other than Google Play's update mechanism is restricted. But this restriction does not apply to updating javascript bundles.
|
|
89
161
|
> This restriction does not apply to code that runs in a virtual machine and has limited access to Android APIs (such as JavaScript in a webview or browser).
|
|
90
162
|
|
|
91
|
-
|
|
163
|
+
Turbopush only updates JS bundles and cannot update native code, so it is fully compliant.
|
|
92
164
|
|
|
93
165
|
### App Store
|
|
94
166
|
|
|
95
|
-
Paragraph **3.3.2
|
|
167
|
+
Paragraph **3.3.2** of the [Apple Developer Program License Agreement](https://developer.apple.com/terms/) allows over-the-air updates of JavaScript and assets:
|
|
96
168
|
|
|
97
169
|
> Interpreted code may be downloaded to an Application but only so long as such code: (a) does not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store, (b) does not create a store or storefront for other code or applications, and (c) does not bypass signing, sandbox, or other security features of the OS.
|
|
98
170
|
|
|
99
|
-
|
|
171
|
+
Turbopush allows you to follow these rules in full compliance as long as the update you push does not significantly deviate your product from its original App Store approved intent.
|
|
172
|
+
|
|
173
|
+
> **Tip:** For App Store-distributed apps, we suggest not enabling the `updateDialog` option when calling `sync`, as Apple's [App Store Review Guidelines](https://developer.apple.com/app-store/review/guidelines/) discourage prompts that require user action to access app functionality.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Contributing
|
|
100
178
|
|
|
101
|
-
|
|
179
|
+
Bug reports and feature requests are welcome via [GitHub Issues](https://github.com/turbopushdev/react-native-code-push/issues).
|
|
102
180
|
|
|
103
|
-
|
|
181
|
+
---
|
|
104
182
|
|
|
105
|
-
|
|
183
|
+
## License
|
|
106
184
|
|
|
185
|
+
MIT — see [LICENSE.md](LICENSE.md) for details.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
|
|
3
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
4
|
+
|
|
5
|
+
<application>
|
|
6
|
+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
|
7
|
+
</application>
|
|
8
|
+
|
|
9
|
+
</manifest>
|
|
@@ -150,12 +150,20 @@ public class CodePushNativeModule extends BaseJavaModule {
|
|
|
150
150
|
latestJSBundleLoader = JSBundleLoader.createFileLoader(latestJSBundleFile);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
// ExpoReactHostDelegate (Kotlin) exposes jsBundleLoader as a computed property whose
|
|
154
|
+
// backing field is named "_jsBundleLoader". Setting it makes the getter return the new
|
|
155
|
+
// loader on the next reload. Fall back to the non-prefixed name for other delegates.
|
|
156
|
+
Field bundleLoaderField;
|
|
157
|
+
try {
|
|
158
|
+
bundleLoaderField = reactHostDelegate.getClass().getDeclaredField("_jsBundleLoader");
|
|
159
|
+
} catch (NoSuchFieldException ignored) {
|
|
160
|
+
bundleLoaderField = reactHostDelegate.getClass().getDeclaredField("jsBundleLoader");
|
|
161
|
+
}
|
|
154
162
|
bundleLoaderField.setAccessible(true);
|
|
155
163
|
bundleLoaderField.set(reactHostDelegate, latestJSBundleLoader);
|
|
156
164
|
|
|
157
165
|
} catch (NoSuchFieldException nsfe) {
|
|
158
|
-
CodePushUtils.log("
|
|
166
|
+
CodePushUtils.log("Neither '_jsBundleLoader' nor 'jsBundleLoader' field found on " + (reactHostDelegate != null ? reactHostDelegate.getClass().getName() : "null") + ". Unable to update JS bundle for reload.");
|
|
159
167
|
// DO NOT THROW for NoSuchFieldException.
|
|
160
168
|
}catch (Exception e) {
|
|
161
169
|
CodePushUtils.log("Unable to set JSBundle of ReactHostDelegate - CodePush may not support this version of React Native");
|
|
@@ -197,31 +205,26 @@ public class CodePushNativeModule extends BaseJavaModule {
|
|
|
197
205
|
|
|
198
206
|
|
|
199
207
|
try {
|
|
200
|
-
if (reactHost instanceof ReactHostImpl) {
|
|
201
|
-
ReactHostDelegate delegate = getReactHostDelegate((ReactHostImpl) reactHost);
|
|
208
|
+
if (reactHost instanceof ReactHostImpl) {
|
|
209
|
+
ReactHostDelegate delegate = getReactHostDelegate((ReactHostImpl) reactHost);
|
|
202
210
|
if (delegate != null) {
|
|
203
|
-
// #2) Update the
|
|
204
|
-
setJSBundle(delegate, latestJSBundleFile);
|
|
211
|
+
// #2) Update the bundle loader on the delegate so the next reload uses it
|
|
212
|
+
setJSBundle(delegate, latestJSBundleFile);
|
|
205
213
|
} else {
|
|
206
214
|
CodePushUtils.log("Could not get ReactHostDelegate from ReactHostImpl.");
|
|
207
215
|
}
|
|
208
216
|
} else {
|
|
209
|
-
CodePushUtils.log("ReactHost is not
|
|
217
|
+
CodePushUtils.log("ReactHost is not ReactHostImpl (" + reactHost.getClass().getName() + ")");
|
|
210
218
|
}
|
|
211
|
-
} catch (
|
|
212
|
-
CodePushUtils.log(
|
|
213
|
-
}catch (Exception e) {
|
|
214
|
-
// Catch any unexpected errors from the attempt to call setJSBundle, e.g., if getReactHostDelegate itself fails
|
|
215
|
-
CodePushUtils.log("Exception during the reflective setJSBundle block: " + e.getMessage());
|
|
219
|
+
} catch (Exception e) {
|
|
220
|
+
CodePushUtils.log("Exception during setJSBundle: " + e.getMessage());
|
|
216
221
|
}
|
|
217
222
|
|
|
218
|
-
// #3)
|
|
223
|
+
// #3) Trigger reload and initialize update state
|
|
219
224
|
try {
|
|
220
225
|
reactHost.reload("CodePush triggers reload");
|
|
221
226
|
mCodePush.initializeUpdateAfterRestart();
|
|
222
227
|
} catch (Exception e) {
|
|
223
|
-
// The recreation method threw an unknown exception
|
|
224
|
-
// so just simply fallback to restarting the Activity (if it exists)
|
|
225
228
|
loadBundleLegacy();
|
|
226
229
|
}
|
|
227
230
|
|
|
@@ -856,14 +859,23 @@ public class CodePushNativeModule extends BaseJavaModule {
|
|
|
856
859
|
}
|
|
857
860
|
|
|
858
861
|
public ReactHostDelegate getReactHostDelegate(ReactHostImpl reactHostImpl) {
|
|
862
|
+
// RN 0.76+ (used in Expo SDK 55+) names the field "reactHostDelegate" (Kotlin constructor
|
|
863
|
+
// property, no "m" prefix). Older versions used "mReactHostDelegate".
|
|
864
|
+
String[] candidateFields = {"reactHostDelegate", "mReactHostDelegate"};
|
|
859
865
|
try {
|
|
860
866
|
Class<?> clazz = reactHostImpl.getClass();
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
+
for (String fieldName : candidateFields) {
|
|
868
|
+
try {
|
|
869
|
+
Field field = clazz.getDeclaredField(fieldName);
|
|
870
|
+
field.setAccessible(true);
|
|
871
|
+
return (ReactHostDelegate) field.get(reactHostImpl);
|
|
872
|
+
} catch (NoSuchFieldException ignored) {
|
|
873
|
+
// try next candidate
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
CodePushUtils.log("Could not find reactHostDelegate field on " + clazz.getName());
|
|
877
|
+
return null;
|
|
878
|
+
} catch (IllegalAccessException e) {
|
|
867
879
|
e.printStackTrace();
|
|
868
880
|
return null;
|
|
869
881
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turbopush/react-native-code-push",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0-rc.1",
|
|
4
4
|
"description": "React Native plugin for the CodePush service",
|
|
5
5
|
"main": "CodePush.js",
|
|
6
6
|
"typings": "typings/react-native-code-push.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"android/",
|
|
9
|
+
"ios/",
|
|
10
|
+
"scripts/",
|
|
11
|
+
"typings/",
|
|
12
|
+
"AlertAdapter.js",
|
|
13
|
+
"CodePush.js",
|
|
14
|
+
"CodePush.podspec",
|
|
15
|
+
"logging.js",
|
|
16
|
+
"package-mixins.js",
|
|
17
|
+
"react-native.config.js",
|
|
18
|
+
"request-fetch-adapter.js"
|
|
19
|
+
],
|
|
7
20
|
"homepage": "https://turbopush.org",
|
|
8
21
|
"keywords": [
|
|
9
22
|
"react-native",
|
|
@@ -72,17 +85,7 @@
|
|
|
72
85
|
"tslint": "^6.1.3",
|
|
73
86
|
"typescript": "^4.4.3"
|
|
74
87
|
},
|
|
75
|
-
"rnpm": {
|
|
76
|
-
"android": {
|
|
77
|
-
"packageInstance": "new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)"
|
|
78
|
-
},
|
|
79
|
-
"ios": {
|
|
80
|
-
"sharedLibraries": [
|
|
81
|
-
"libz"
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
88
|
"bugs": {
|
|
86
89
|
"url": "https://github.com/turbopushdev/react-native-code-push/issues"
|
|
87
90
|
}
|
|
88
|
-
}
|
|
91
|
+
}
|
package/request-fetch-adapter.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
const packageJson = require("./package.json");
|
|
2
|
+
const { Platform } = require("react-native");
|
|
3
|
+
|
|
4
|
+
const { major, minor, patch } = Platform.constants.reactNativeVersion;
|
|
5
|
+
const rnVersion = `${major}.${minor}.${patch}`;
|
|
6
|
+
|
|
7
|
+
let expoVersion;
|
|
8
|
+
try {
|
|
9
|
+
expoVersion = require("expo/package.json").version;
|
|
10
|
+
} catch (_) { }
|
|
11
|
+
|
|
12
|
+
let turbopushExpoPluginVersion;
|
|
13
|
+
try {
|
|
14
|
+
turbopushExpoPluginVersion = require("@turbopush/turbopush-expo-plugin/package.json").version;
|
|
15
|
+
} catch (_) { }
|
|
2
16
|
|
|
3
17
|
module.exports = {
|
|
4
|
-
|
|
18
|
+
request(verb, url, requestBody, callback) {
|
|
5
19
|
if (typeof requestBody === "function") {
|
|
6
20
|
callback = requestBody;
|
|
7
21
|
requestBody = null;
|
|
@@ -12,26 +26,32 @@ module.exports = {
|
|
|
12
26
|
"Content-Type": "application/json",
|
|
13
27
|
"X-CodePush-Plugin-Name": packageJson.name,
|
|
14
28
|
"X-CodePush-Plugin-Version": packageJson.version,
|
|
15
|
-
"X-CodePush-SDK-Version": packageJson.dependencies["code-push"]
|
|
29
|
+
"X-CodePush-SDK-Version": packageJson.dependencies["code-push"],
|
|
30
|
+
"X-React-Native-Version": rnVersion,
|
|
31
|
+
...(expoVersion && { "X-Expo-Version": expoVersion }),
|
|
32
|
+
...(turbopushExpoPluginVersion && { "X-Turbopush-Expo-Plugin-Version": turbopushExpoPluginVersion }),
|
|
16
33
|
};
|
|
17
34
|
|
|
18
35
|
if (requestBody && typeof requestBody === "object") {
|
|
19
36
|
requestBody = JSON.stringify(requestBody);
|
|
20
37
|
}
|
|
21
38
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
const xhr = new XMLHttpRequest();
|
|
40
|
+
xhr.open(getHttpMethodName(verb), url, true);
|
|
41
|
+
|
|
42
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
43
|
+
xhr.setRequestHeader(key, value);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
xhr.onload = () => {
|
|
47
|
+
callback(null, { statusCode: xhr.status, body: xhr.responseText });
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
xhr.onerror = () => {
|
|
51
|
+
callback(new Error(`Network request failed for url ${url}`));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
xhr.send(requestBody || null);
|
|
35
55
|
}
|
|
36
56
|
};
|
|
37
57
|
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
trigger:
|
|
2
|
-
- master
|
|
3
|
-
|
|
4
|
-
pr:
|
|
5
|
-
- master
|
|
6
|
-
|
|
7
|
-
resources:
|
|
8
|
-
repositories:
|
|
9
|
-
- repository: 1ESPipelineTemplates
|
|
10
|
-
type: git
|
|
11
|
-
name: 1ESPipelineTemplates/1ESPipelineTemplates
|
|
12
|
-
ref: refs/tags/release
|
|
13
|
-
name: $(Build.SourceBranchName)_$(date:yyyyMMdd)$(rev:.r)
|
|
14
|
-
|
|
15
|
-
extends:
|
|
16
|
-
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
|
|
17
|
-
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
|
|
18
|
-
${{ else }}:
|
|
19
|
-
template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplates
|
|
20
|
-
parameters:
|
|
21
|
-
pool:
|
|
22
|
-
name: 1ES-PT-CBL-Mariner-2.0-Gen2
|
|
23
|
-
os: linux
|
|
24
|
-
customBuildTags:
|
|
25
|
-
- ES365AIMigrationTooling-BulkMigrated
|
|
26
|
-
sdl:
|
|
27
|
-
sourceAnalysisPool: 1ES-PT-Windows-2022
|
|
28
|
-
credscan:
|
|
29
|
-
suppressionsFile: $(Build.SourcesDirectory)/.config/CredScanSuppressions.json
|
|
30
|
-
stages:
|
|
31
|
-
- stage: Stage
|
|
32
|
-
jobs:
|
|
33
|
-
- job: HostJob
|
|
34
|
-
templateContext:
|
|
35
|
-
outputs:
|
|
36
|
-
- output: pipelineArtifact
|
|
37
|
-
displayName: "Publish Artifact: artifacts"
|
|
38
|
-
path: '$(Build.ArtifactStagingDirectory)/npm'
|
|
39
|
-
artifactName: npm
|
|
40
|
-
|
|
41
|
-
steps:
|
|
42
|
-
- task: NodeTool@0
|
|
43
|
-
inputs:
|
|
44
|
-
versionSpec: '14.x'
|
|
45
|
-
displayName: 'Install Node.js'
|
|
46
|
-
|
|
47
|
-
- script: |
|
|
48
|
-
npm pack
|
|
49
|
-
npm install -g react-native-code-push*.tgz
|
|
50
|
-
displayName: 'Package react-native-code-push'
|
|
51
|
-
workingDirectory: $(Build.SourcesDirectory)
|
|
52
|
-
|
|
53
|
-
- task: DeleteFiles@1
|
|
54
|
-
inputs:
|
|
55
|
-
contents: node_modules
|
|
56
|
-
displayName: 'Delete node_modules'
|
|
57
|
-
|
|
58
|
-
- task: ArchiveFiles@2
|
|
59
|
-
inputs:
|
|
60
|
-
rootFolderOrFile: '$(Build.SourcesDirectory)'
|
|
61
|
-
includeRootFolder: false
|
|
62
|
-
archiveType: 'tar'
|
|
63
|
-
archiveFile: '$(Build.ArtifactStagingDirectory)/npm/$(Build.BuildId).tgz'
|
|
64
|
-
replaceExistingArchive: true
|
|
65
|
-
verbose: true
|
|
66
|
-
displayName: 'Prepare npm artifact'
|
|
67
|
-
|
|
68
|
-
- stage: APIScan
|
|
69
|
-
dependsOn: Stage
|
|
70
|
-
pool:
|
|
71
|
-
name: 1ES-PT-Windows-2022
|
|
72
|
-
os: windows
|
|
73
|
-
variables:
|
|
74
|
-
"agent.source.skip": true
|
|
75
|
-
jobs:
|
|
76
|
-
- job: APIScan
|
|
77
|
-
steps:
|
|
78
|
-
- task: DownloadPipelineArtifact@2
|
|
79
|
-
displayName: Download Build Artifacts for APIScan
|
|
80
|
-
inputs:
|
|
81
|
-
artifactName: npm
|
|
82
|
-
targetPath: '$(Agent.BuildDirectory)/npm'
|
|
83
|
-
- task: ExtractFiles@1
|
|
84
|
-
inputs:
|
|
85
|
-
archiveFilePatterns: '$(Agent.BuildDirectory)/npm/*.tgz'
|
|
86
|
-
destinationFolder: '$(Agent.BuildDirectory)/npm_extracted'
|
|
87
|
-
- task: AzureKeyVault@2
|
|
88
|
-
inputs:
|
|
89
|
-
azureSubscription: 'AC - Dev Infra & Build Pool'
|
|
90
|
-
KeyVaultName: 'mobile-center-sdk'
|
|
91
|
-
SecretsFilter: 'appcenter-sdk-managed-identity-clientid'
|
|
92
|
-
RunAsPreJob: false
|
|
93
|
-
- task: APIScan@2
|
|
94
|
-
displayName: 'Run APIScan'
|
|
95
|
-
inputs:
|
|
96
|
-
softwareFolder: '$(Agent.BuildDirectory)\npm_extracted'
|
|
97
|
-
softwareName: 'react-native-code-push'
|
|
98
|
-
softwareVersionNum: '$(Build.BuildId)'
|
|
99
|
-
isLargeApp: false
|
|
100
|
-
toolVersion: 'Latest'
|
|
101
|
-
verbosityLevel: verbose
|
|
102
|
-
condition: and(succeeded(), ne(variables['DisableAPIScan'], 'true'))
|
|
103
|
-
env:
|
|
104
|
-
AzureServicesAuthConnectionString: 'runAs=App;AppId=$(appcenter-sdk-managed-identity-clientid)'
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
trigger:
|
|
2
|
-
- master
|
|
3
|
-
|
|
4
|
-
pr:
|
|
5
|
-
- master
|
|
6
|
-
|
|
7
|
-
variables:
|
|
8
|
-
- name: api-level
|
|
9
|
-
value: '27'
|
|
10
|
-
|
|
11
|
-
pool:
|
|
12
|
-
vmImage: 'macOS-12'
|
|
13
|
-
|
|
14
|
-
stages:
|
|
15
|
-
- stage: RunTests
|
|
16
|
-
displayName: 'Run Android & IOS tests'
|
|
17
|
-
jobs:
|
|
18
|
-
- job: TestAndroid
|
|
19
|
-
timeoutInMinutes: 120
|
|
20
|
-
displayName: 'Test android'
|
|
21
|
-
steps:
|
|
22
|
-
|
|
23
|
-
- script: |
|
|
24
|
-
adb devices
|
|
25
|
-
displayName: 'Start adb server'
|
|
26
|
-
|
|
27
|
-
- script: |
|
|
28
|
-
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-$(api-level);google_apis;x86"
|
|
29
|
-
displayName: 'Download system image'
|
|
30
|
-
|
|
31
|
-
- script: |
|
|
32
|
-
$ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestEmulator --abi google_apis/x86 --package 'system-images;android-$(api-level);google_apis;x86' --device "Nexus 6P"
|
|
33
|
-
displayName: 'Creating Android emulator'
|
|
34
|
-
|
|
35
|
-
- script: |
|
|
36
|
-
$ANDROID_HOME/emulator/emulator -avd TestEmulator -noaudio -no-window -no-snapshot-save -no-boot-anim -memory 6144 &
|
|
37
|
-
displayName: 'Start Android emulator'
|
|
38
|
-
|
|
39
|
-
- script: |
|
|
40
|
-
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
|
|
41
|
-
displayName: 'Wait for emulator to boot'
|
|
42
|
-
|
|
43
|
-
- script: |
|
|
44
|
-
adb shell settings put global window_animation_scale 0.0
|
|
45
|
-
displayName: 'Disable animations and transitions'
|
|
46
|
-
|
|
47
|
-
- script: |
|
|
48
|
-
adb shell settings put global transition_animation_scale 0.0
|
|
49
|
-
displayName: 'Disable animations and transitions'
|
|
50
|
-
|
|
51
|
-
- script: |
|
|
52
|
-
adb shell settings put global animator_duration_scale 0.0
|
|
53
|
-
displayName: 'Disable animations and transitions'
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- task: JavaToolInstaller@0
|
|
57
|
-
inputs:
|
|
58
|
-
versionSpec: '11'
|
|
59
|
-
jdkArchitectureOption: 'x64'
|
|
60
|
-
jdkSourceOption: 'PreInstalled'
|
|
61
|
-
displayName: 'Change Java version'
|
|
62
|
-
|
|
63
|
-
- script: |
|
|
64
|
-
npm install
|
|
65
|
-
displayName: 'Package Installation'
|
|
66
|
-
|
|
67
|
-
- script: |
|
|
68
|
-
npm run build:tests && npm run test:setup:android
|
|
69
|
-
displayName: 'Setup Android tests'
|
|
70
|
-
|
|
71
|
-
- script: |
|
|
72
|
-
npm run test:fast:android
|
|
73
|
-
displayName: 'Run Android test'
|
|
74
|
-
|
|
75
|
-
- job: TestIOS
|
|
76
|
-
timeoutInMinutes: 120
|
|
77
|
-
displayName: 'Test IOS'
|
|
78
|
-
steps:
|
|
79
|
-
|
|
80
|
-
- script: |
|
|
81
|
-
npm install
|
|
82
|
-
displayName: 'Install dependencies'
|
|
83
|
-
|
|
84
|
-
- script: |
|
|
85
|
-
npm run build:tests && npm run test:setup:ios
|
|
86
|
-
displayName: 'Setup iOS tests'
|
|
87
|
-
|
|
88
|
-
- script: |
|
|
89
|
-
npm run test:fast:ios
|
|
90
|
-
displayName: 'Run tests'
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tool": "Credential Scanner",
|
|
3
|
-
"suppressions": [
|
|
4
|
-
{
|
|
5
|
-
"file": "/Examples/CodePushDemoApp/android/app/debug.keystore",
|
|
6
|
-
"_justification": "Used only in DemoApp"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"file": "/Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp/CodePushDemoAppCpp_TemporaryKey.pfx",
|
|
10
|
-
"_justification": "Used only in DemoApp"
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
|