Skip to content

Commit 6e37fe2

Browse files
authored
Merge pull request #47 from Soomgo-Mobile/v9-example-app
Update the example app / Deprecate deployment key
2 parents 827aef6 + 764fb20 commit 6e37fe2

File tree

73 files changed

+12113
-15975
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+12113
-15975
lines changed

CodePush.js

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { SemverVersioning } from './versioning/SemverVersioning'
77
let NativeCodePush = require("react-native").NativeModules.CodePush;
88
const PackageMixins = require("./package-mixins")(NativeCodePush);
99

10-
async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchCallback = null) {
10+
const DEPLOYMENT_KEY = 'deprecated_deployment_key';
11+
12+
async function checkForUpdate(handleBinaryVersionMismatchCallback = null) {
1113
/*
1214
* Before we ask the server if an update exists, we
1315
* need to retrieve three pieces of information from the
@@ -18,14 +20,6 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
1820
* different from the CodePush update they have already installed.
1921
*/
2022
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;
2923

3024
// Use dynamically overridden getCurrentPackage() during tests.
3125
const localPackage = await module.exports.getCurrentPackage();
@@ -42,22 +36,20 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
4236
if (localPackage) {
4337
queryPackage = localPackage;
4438
} else {
45-
queryPackage = { appVersion: config.appVersion };
46-
if (Platform.OS === "ios" && config.packageHash) {
47-
queryPackage.packageHash = config.packageHash;
39+
queryPackage = { appVersion: nativeConfig.appVersion };
40+
if (Platform.OS === "ios" && nativeConfig.packageHash) {
41+
queryPackage.packageHash = nativeConfig.packageHash;
4842
}
4943
}
5044

5145
const update = await (async () => {
5246
try {
53-
// refer to `UpdateCheckRequest` type inside code-push SDK
5447
const updateRequest = {
55-
deployment_key: config.deploymentKey,
5648
app_version: queryPackage.appVersion,
5749
package_hash: queryPackage.packageHash,
58-
is_companion: config.ignoreAppVersion,
50+
is_companion: nativeConfig.ignoreAppVersion,
5951
label: queryPackage.label,
60-
client_unique_id: config.clientUniqueId,
52+
client_unique_id: nativeConfig.clientUniqueId,
6153
};
6254

6355
/**
@@ -68,7 +60,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
6860
if (updateChecker) {
6961
const { update_info } = await updateChecker(updateRequest);
7062

71-
return mapToRemotePackageMetadata(update_info, config.deploymentKey);
63+
return mapToRemotePackageMetadata(update_info);
7264
} else {
7365
/**
7466
* `releaseHistory`
@@ -128,7 +120,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
128120
should_run_binary_version: false,
129121
}
130122

131-
return mapToRemotePackageMetadata(updateInfo, config.deploymentKey);
123+
return mapToRemotePackageMetadata(updateInfo);
132124
}
133125
} catch (error) {
134126
log(`An error has occurred at update checker :`);
@@ -158,7 +150,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
158150
*/
159151
if (!update || update.updateAppVersion ||
160152
localPackage && (update.packageHash === localPackage.packageHash) ||
161-
(!localPackage || localPackage._isDebugOnly) && config.packageHash === update.packageHash) {
153+
(!localPackage || localPackage._isDebugOnly) && nativeConfig.packageHash === update.packageHash) {
162154
if (update && update.updateAppVersion) {
163155
log("An update is available but it is not targeting the binary version of your app.");
164156
if (handleBinaryVersionMismatchCallback && typeof handleBinaryVersionMismatchCallback === "function") {
@@ -170,17 +162,15 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
170162
} else {
171163
const remotePackage = { ...update, ...PackageMixins.remote() };
172164
remotePackage.failedInstall = await NativeCodePush.isFailedUpdate(remotePackage.packageHash);
173-
remotePackage.deploymentKey = deploymentKey || nativeConfig.deploymentKey;
174165
return remotePackage;
175166
}
176167
}
177168

178169
/**
179170
* @param updateInfo {UpdateCheckResponse}
180-
* @param deploymentKey {string}
181171
* @return {RemotePackage | null}
182172
*/
183-
function mapToRemotePackageMetadata(updateInfo, deploymentKey) {
173+
function mapToRemotePackageMetadata(updateInfo) {
184174
if (!updateInfo) {
185175
return null;
186176
} else if (!updateInfo.download_url) {
@@ -192,7 +182,7 @@ function mapToRemotePackageMetadata(updateInfo, deploymentKey) {
192182

193183
// refer to `RemotePackage` type inside code-push SDK
194184
return {
195-
deploymentKey: deploymentKey,
185+
deploymentKey: DEPLOYMENT_KEY,
196186
description: updateInfo.description ?? '',
197187
label: updateInfo.label ?? '',
198188
appVersion: updateInfo.target_binary_range ?? '',
@@ -253,15 +243,9 @@ async function notifyApplicationReadyInternal() {
253243
}
254244

255245
async function tryReportStatus(statusReport, retryOnAppResume) {
256-
const config = await getConfiguration();
257-
258246
try {
259247
if (statusReport.appVersion) {
260248
log(`Reporting binary update (${statusReport.appVersion})`);
261-
262-
if (!config.deploymentKey) {
263-
throw new Error("Deployment key is missed");
264-
}
265249
} else {
266250
const label = statusReport.package.label;
267251
if (statusReport.status === "DeploymentSucceeded") {
@@ -275,6 +259,7 @@ async function tryReportStatus(statusReport, retryOnAppResume) {
275259
NativeCodePush.recordStatusReported(statusReport);
276260
retryOnAppResume && retryOnAppResume.remove();
277261
} catch (e) {
262+
log(`${e}`)
278263
log(`Report status failed: ${JSON.stringify(statusReport)}`);
279264
NativeCodePush.saveStatusReportForRetry(statusReport);
280265
// Try again when the app resumes
@@ -480,7 +465,7 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
480465
await CodePush.notifyApplicationReady();
481466

482467
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
483-
const remotePackage = await checkForUpdate(syncOptions.deploymentKey, handleBinaryVersionMismatchCallback);
468+
const remotePackage = await checkForUpdate(handleBinaryVersionMismatchCallback);
484469

485470
const doDownloadAndInstall = async () => {
486471
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);

Examples/CodePushDemoApp/.buckconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

Examples/CodePushDemoApp/.editorconfig

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
};

Examples/CodePushDemoApp/.flowconfig

Lines changed: 0 additions & 65 deletions
This file was deleted.

Examples/CodePushDemoApp/.gitattributes

Lines changed: 0 additions & 3 deletions
This file was deleted.

Examples/CodePushDemoApp/.gitignore

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23+
**/.xcode.env.local
2324

2425
# Android/IntelliJ
2526
#
@@ -29,32 +30,45 @@ build/
2930
local.properties
3031
*.iml
3132
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
3236

3337
# node.js
3438
#
3539
node_modules/
3640
npm-debug.log
3741
yarn-error.log
3842

39-
# BUCK
40-
buck-out/
41-
\.buckd/
42-
*.keystore
43-
!debug.keystore
44-
4543
# fastlane
4644
#
4745
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4846
# screenshots whenever they are needed.
4947
# For more information about the recommended setup visit:
5048
# https://docs.fastlane.tools/best-practices/source-control/
5149

52-
*/fastlane/report.xml
53-
*/fastlane/Preview.html
54-
*/fastlane/screenshots
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
5554

5655
# Bundle artifact
5756
*.jsbundle
5857

59-
# CocoaPods
60-
/ios/Pods/
58+
# Ruby / CocoaPods
59+
**/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*
64+
65+
# testing
66+
/coverage
67+
68+
# Yarn
69+
.yarn/*
70+
!.yarn/patches
71+
!.yarn/plugins
72+
!.yarn/releases
73+
!.yarn/sdks
74+
!.yarn/versions
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2+
arrowParens: "avoid",
3+
bracketSameLine: true,
24
bracketSpacing: false,
3-
jsxBracketSameLine: true,
4-
singleQuote: true,
5-
trailingComma: 'all',
6-
arrowParens: 'avoid',
5+
singleQuote: false,
6+
trailingComma: "all",
77
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

0 commit comments

Comments
 (0)