@bravemobile/react-native-code-push 9.0.0-beta.4 → 9.0.0
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/CodePush.js +28 -40
- package/README.md +265 -369
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +13 -13
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +3 -3
- package/ios/CodePush/CodePush.m +5 -5
- package/ios/CodePush/CodePushConfig.m +1 -1
- package/package.json +5 -2
- package/react-native.config.js +1 -1
- package/tsconfig.json +5 -1
- package/typings/react-native-code-push.d.ts +0 -9
- package/code-push.config.example.supabase.ts +0 -114
- package/docs/setup-android.md +0 -482
- package/docs/setup-ios.md +0 -280
package/CodePush.js
CHANGED
|
@@ -7,7 +7,9 @@ import { SemverVersioning } from './versioning/SemverVersioning'
|
|
|
7
7
|
let NativeCodePush = require("react-native").NativeModules.CodePush;
|
|
8
8
|
const PackageMixins = require("./package-mixins")(NativeCodePush);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const DEPLOYMENT_KEY = 'deprecated_deployment_key';
|
|
11
|
+
|
|
12
|
+
async function checkForUpdate(handleBinaryVersionMismatchCallback = null) {
|
|
11
13
|
/*
|
|
12
14
|
* Before we ask the server if an update exists, we
|
|
13
15
|
* need to retrieve three pieces of information from the
|
|
@@ -18,14 +20,6 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
18
20
|
* different from the CodePush update they have already installed.
|
|
19
21
|
*/
|
|
20
22
|
const nativeConfig = await getConfiguration();
|
|
21
|
-
/*
|
|
22
|
-
* If a deployment key was explicitly provided,
|
|
23
|
-
* then let's override the one we retrieved
|
|
24
|
-
* from the native-side of the app. This allows
|
|
25
|
-
* dynamically "redirecting" end-users at different
|
|
26
|
-
* deployments (e.g. an early access deployment for insiders).
|
|
27
|
-
*/
|
|
28
|
-
const config = deploymentKey ? { ...nativeConfig, ...{ deploymentKey } } : nativeConfig;
|
|
29
23
|
|
|
30
24
|
// Use dynamically overridden getCurrentPackage() during tests.
|
|
31
25
|
const localPackage = await module.exports.getCurrentPackage();
|
|
@@ -42,22 +36,20 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
42
36
|
if (localPackage) {
|
|
43
37
|
queryPackage = localPackage;
|
|
44
38
|
} else {
|
|
45
|
-
queryPackage = { appVersion:
|
|
46
|
-
if (Platform.OS === "ios" &&
|
|
47
|
-
queryPackage.packageHash =
|
|
39
|
+
queryPackage = { appVersion: nativeConfig.appVersion };
|
|
40
|
+
if (Platform.OS === "ios" && nativeConfig.packageHash) {
|
|
41
|
+
queryPackage.packageHash = nativeConfig.packageHash;
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
const update = await (async () => {
|
|
52
46
|
try {
|
|
53
|
-
// refer to `UpdateCheckRequest` type inside code-push SDK
|
|
54
47
|
const updateRequest = {
|
|
55
|
-
deployment_key: config.deploymentKey,
|
|
56
48
|
app_version: queryPackage.appVersion,
|
|
57
49
|
package_hash: queryPackage.packageHash,
|
|
58
|
-
is_companion:
|
|
50
|
+
is_companion: nativeConfig.ignoreAppVersion,
|
|
59
51
|
label: queryPackage.label,
|
|
60
|
-
client_unique_id:
|
|
52
|
+
client_unique_id: nativeConfig.clientUniqueId,
|
|
61
53
|
};
|
|
62
54
|
|
|
63
55
|
/**
|
|
@@ -68,7 +60,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
68
60
|
if (updateChecker) {
|
|
69
61
|
const { update_info } = await updateChecker(updateRequest);
|
|
70
62
|
|
|
71
|
-
return mapToRemotePackageMetadata(update_info
|
|
63
|
+
return mapToRemotePackageMetadata(update_info);
|
|
72
64
|
} else {
|
|
73
65
|
/**
|
|
74
66
|
* `releaseHistory`
|
|
@@ -107,28 +99,31 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
107
99
|
is_available: latestReleaseInfo.enabled,
|
|
108
100
|
package_hash: latestReleaseInfo.packageHash,
|
|
109
101
|
is_mandatory: isMandatory,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
/**
|
|
103
|
+
* The `ReleaseHistoryInterface` data returned by the `releaseHistoryFetcher` function is
|
|
104
|
+
* based on the assumption that it is compatible with the current runtime binary.
|
|
105
|
+
* (because it is querying the update history deployed for the current binary version)
|
|
106
|
+
* Therefore, the current runtime binary version should be passed as it is.
|
|
107
|
+
*/
|
|
113
108
|
target_binary_range: updateRequest.app_version,
|
|
114
109
|
/**
|
|
115
110
|
* Retrieve the update version from the ReleaseHistory and store it in the label.
|
|
116
111
|
* This information can be accessed at runtime through the CodePush bundle metadata.
|
|
117
112
|
*/
|
|
118
113
|
label: latestVersion,
|
|
119
|
-
// false
|
|
114
|
+
// `false` should be passed to work properly
|
|
120
115
|
update_app_version: false,
|
|
121
|
-
//
|
|
122
|
-
description:
|
|
123
|
-
//
|
|
116
|
+
// currently not used.
|
|
117
|
+
description: "",
|
|
118
|
+
// not used at runtime.
|
|
124
119
|
is_disabled: false,
|
|
125
|
-
//
|
|
120
|
+
// not used at runtime.
|
|
126
121
|
package_size: 0,
|
|
127
|
-
//
|
|
122
|
+
// not used at runtime.
|
|
128
123
|
should_run_binary_version: false,
|
|
129
|
-
}
|
|
124
|
+
};
|
|
130
125
|
|
|
131
|
-
return mapToRemotePackageMetadata(updateInfo
|
|
126
|
+
return mapToRemotePackageMetadata(updateInfo);
|
|
132
127
|
}
|
|
133
128
|
} catch (error) {
|
|
134
129
|
log(`An error has occurred at update checker :`);
|
|
@@ -158,7 +153,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
158
153
|
*/
|
|
159
154
|
if (!update || update.updateAppVersion ||
|
|
160
155
|
localPackage && (update.packageHash === localPackage.packageHash) ||
|
|
161
|
-
(!localPackage || localPackage._isDebugOnly) &&
|
|
156
|
+
(!localPackage || localPackage._isDebugOnly) && nativeConfig.packageHash === update.packageHash) {
|
|
162
157
|
if (update && update.updateAppVersion) {
|
|
163
158
|
log("An update is available but it is not targeting the binary version of your app.");
|
|
164
159
|
if (handleBinaryVersionMismatchCallback && typeof handleBinaryVersionMismatchCallback === "function") {
|
|
@@ -170,17 +165,15 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
170
165
|
} else {
|
|
171
166
|
const remotePackage = { ...update, ...PackageMixins.remote() };
|
|
172
167
|
remotePackage.failedInstall = await NativeCodePush.isFailedUpdate(remotePackage.packageHash);
|
|
173
|
-
remotePackage.deploymentKey = deploymentKey || nativeConfig.deploymentKey;
|
|
174
168
|
return remotePackage;
|
|
175
169
|
}
|
|
176
170
|
}
|
|
177
171
|
|
|
178
172
|
/**
|
|
179
173
|
* @param updateInfo {UpdateCheckResponse}
|
|
180
|
-
* @param deploymentKey {string}
|
|
181
174
|
* @return {RemotePackage | null}
|
|
182
175
|
*/
|
|
183
|
-
function mapToRemotePackageMetadata(updateInfo
|
|
176
|
+
function mapToRemotePackageMetadata(updateInfo) {
|
|
184
177
|
if (!updateInfo) {
|
|
185
178
|
return null;
|
|
186
179
|
} else if (!updateInfo.download_url) {
|
|
@@ -192,7 +185,7 @@ function mapToRemotePackageMetadata(updateInfo, deploymentKey) {
|
|
|
192
185
|
|
|
193
186
|
// refer to `RemotePackage` type inside code-push SDK
|
|
194
187
|
return {
|
|
195
|
-
deploymentKey:
|
|
188
|
+
deploymentKey: DEPLOYMENT_KEY,
|
|
196
189
|
description: updateInfo.description ?? '',
|
|
197
190
|
label: updateInfo.label ?? '',
|
|
198
191
|
appVersion: updateInfo.target_binary_range ?? '',
|
|
@@ -253,15 +246,9 @@ async function notifyApplicationReadyInternal() {
|
|
|
253
246
|
}
|
|
254
247
|
|
|
255
248
|
async function tryReportStatus(statusReport, retryOnAppResume) {
|
|
256
|
-
const config = await getConfiguration();
|
|
257
|
-
|
|
258
249
|
try {
|
|
259
250
|
if (statusReport.appVersion) {
|
|
260
251
|
log(`Reporting binary update (${statusReport.appVersion})`);
|
|
261
|
-
|
|
262
|
-
if (!config.deploymentKey) {
|
|
263
|
-
throw new Error("Deployment key is missed");
|
|
264
|
-
}
|
|
265
252
|
} else {
|
|
266
253
|
const label = statusReport.package.label;
|
|
267
254
|
if (statusReport.status === "DeploymentSucceeded") {
|
|
@@ -275,6 +262,7 @@ async function tryReportStatus(statusReport, retryOnAppResume) {
|
|
|
275
262
|
NativeCodePush.recordStatusReported(statusReport);
|
|
276
263
|
retryOnAppResume && retryOnAppResume.remove();
|
|
277
264
|
} catch (e) {
|
|
265
|
+
log(`${e}`)
|
|
278
266
|
log(`Report status failed: ${JSON.stringify(statusReport)}`);
|
|
279
267
|
NativeCodePush.saveStatusReportForRetry(statusReport);
|
|
280
268
|
// Try again when the app resumes
|
|
@@ -480,7 +468,7 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
|
|
|
480
468
|
await CodePush.notifyApplicationReady();
|
|
481
469
|
|
|
482
470
|
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
|
|
483
|
-
const remotePackage = await checkForUpdate(
|
|
471
|
+
const remotePackage = await checkForUpdate(handleBinaryVersionMismatchCallback);
|
|
484
472
|
|
|
485
473
|
const doDownloadAndInstall = async () => {
|
|
486
474
|
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
|