@revopush/react-native-code-push 2.5.0-rc.7 → 2.5.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/.claude/settings.local.json +9 -0
- package/CodePush.js +4 -2
- package/android/src/main/java/com/microsoft/codepush/react/CodePush.java +10 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +1 -0
- package/ios/CodePush/CodePush.h +8 -0
- package/ios/CodePush/CodePush.m +5 -0
- package/ios/CodePush/CodePushConfig.m +13 -0
- package/ios/CodePush/CodePushUpdateUtils.m +14 -9
- package/package.json +2 -2
- package/typings/react-native-code-push.d.ts +5 -0
package/CodePush.js
CHANGED
|
@@ -42,9 +42,11 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
42
42
|
*/
|
|
43
43
|
let queryPackage;
|
|
44
44
|
if (localPackage) {
|
|
45
|
-
|
|
45
|
+
// buildNumber reflects the native binary and never changes across OTA updates,
|
|
46
|
+
// so always use the value from config rather than whatever the local package stored.
|
|
47
|
+
queryPackage = { ...localPackage, buildNumber: config.buildNumber };
|
|
46
48
|
} else {
|
|
47
|
-
queryPackage = { appVersion: config.appVersion };
|
|
49
|
+
queryPackage = { appVersion: config.appVersion, buildNumber: config.buildNumber };
|
|
48
50
|
if (config.packageHash) {
|
|
49
51
|
queryPackage.packageHash = config.packageHash;
|
|
50
52
|
}
|
|
@@ -40,6 +40,7 @@ public class CodePush implements ReactPackage {
|
|
|
40
40
|
private static boolean sNeedToReportRollback = false;
|
|
41
41
|
private static boolean sTestConfigurationFlag = false;
|
|
42
42
|
private static String sAppVersion = null;
|
|
43
|
+
private static String sBuildNumber = null;
|
|
43
44
|
|
|
44
45
|
private boolean mDidUpdate = false;
|
|
45
46
|
|
|
@@ -86,6 +87,7 @@ public class CodePush implements ReactPackage {
|
|
|
86
87
|
try {
|
|
87
88
|
PackageInfo pInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
|
88
89
|
sAppVersion = pInfo.versionName;
|
|
90
|
+
sBuildNumber = String.valueOf(pInfo.versionCode);
|
|
89
91
|
} catch (PackageManager.NameNotFoundException e) {
|
|
90
92
|
throw new CodePushUnknownException("Unable to get package info for " + mContext.getPackageName(), e);
|
|
91
93
|
}
|
|
@@ -182,6 +184,10 @@ public class CodePush implements ReactPackage {
|
|
|
182
184
|
return sAppVersion;
|
|
183
185
|
}
|
|
184
186
|
|
|
187
|
+
public String getBuildNumber() {
|
|
188
|
+
return sBuildNumber;
|
|
189
|
+
}
|
|
190
|
+
|
|
185
191
|
public String getAssetsBundleFileName() {
|
|
186
192
|
return mAssetsBundleFileName;
|
|
187
193
|
}
|
|
@@ -372,6 +378,10 @@ public class CodePush implements ReactPackage {
|
|
|
372
378
|
sAppVersion = appVersionOverride;
|
|
373
379
|
}
|
|
374
380
|
|
|
381
|
+
public static void overrideBuildNumber(String buildNumberOverride) {
|
|
382
|
+
sBuildNumber = buildNumberOverride;
|
|
383
|
+
}
|
|
384
|
+
|
|
375
385
|
private void rollbackPackage() {
|
|
376
386
|
JSONObject failedPackage = mUpdateManager.getCurrentPackage();
|
|
377
387
|
mSettingsManager.saveFailedUpdate(failedPackage);
|
|
@@ -499,6 +499,7 @@ public class CodePushNativeModule extends BaseJavaModule {
|
|
|
499
499
|
try {
|
|
500
500
|
WritableMap configMap = Arguments.createMap();
|
|
501
501
|
configMap.putString("appVersion", mCodePush.getAppVersion());
|
|
502
|
+
configMap.putString("buildNumber", mCodePush.getBuildNumber());
|
|
502
503
|
configMap.putString("clientUniqueId", mClientUniqueId);
|
|
503
504
|
configMap.putString("deploymentKey", mCodePush.getDeploymentKey());
|
|
504
505
|
configMap.putString("serverUrl", mCodePush.getServerUrl());
|
package/ios/CodePush/CodePush.h
CHANGED
|
@@ -49,6 +49,13 @@
|
|
|
49
49
|
*/
|
|
50
50
|
+ (void)overrideAppVersion:(NSString *)appVersion;
|
|
51
51
|
|
|
52
|
+
/*
|
|
53
|
+
* This method allows the build number of the app's binary interface
|
|
54
|
+
* to be specified, which would otherwise default to the
|
|
55
|
+
* binary build number of the app.
|
|
56
|
+
*/
|
|
57
|
+
+ (void)overrideBuildNumber:(NSString *)buildNumber;
|
|
58
|
+
|
|
52
59
|
/*
|
|
53
60
|
* This method allows dynamically setting the app's
|
|
54
61
|
* deployment key, in addition to setting it via
|
|
@@ -98,6 +105,7 @@
|
|
|
98
105
|
@interface CodePushConfig : NSObject
|
|
99
106
|
|
|
100
107
|
@property (copy) NSString *appVersion;
|
|
108
|
+
@property (copy) NSString *buildNumber;
|
|
101
109
|
@property (readonly) NSString *buildVersion;
|
|
102
110
|
@property (readonly) NSDictionary *configuration;
|
|
103
111
|
@property (copy) NSString *deploymentKey;
|
package/ios/CodePush/CodePush.m
CHANGED
|
@@ -218,6 +218,11 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
218
218
|
[CodePushConfig current].appVersion = appVersion;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
+ (void)overrideBuildNumber:(NSString *)buildNumber
|
|
222
|
+
{
|
|
223
|
+
[CodePushConfig current].buildNumber = buildNumber;
|
|
224
|
+
}
|
|
225
|
+
|
|
221
226
|
+ (void)setDeploymentKey:(NSString *)deploymentKey
|
|
222
227
|
{
|
|
223
228
|
[CodePushConfig current].deploymentKey = deploymentKey;
|
|
@@ -9,6 +9,7 @@ static CodePushConfig *_currentConfig;
|
|
|
9
9
|
|
|
10
10
|
static NSString * const AppVersionConfigKey = @"appVersion";
|
|
11
11
|
static NSString * const BuildVersionConfigKey = @"buildVersion";
|
|
12
|
+
static NSString * const BuildNumberConfigKey = @"buildNumber";
|
|
12
13
|
static NSString * const ClientUniqueIDConfigKey = @"clientUniqueId";
|
|
13
14
|
static NSString * const DeploymentKeyConfigKey = @"deploymentKey";
|
|
14
15
|
static NSString * const ServerURLConfigKey = @"serverUrl";
|
|
@@ -33,6 +34,7 @@ static NSString * const PublicKeyKey = @"publicKey";
|
|
|
33
34
|
|
|
34
35
|
NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
|
|
35
36
|
NSString *buildVersion = [infoDictionary objectForKey:(NSString *)kCFBundleVersionKey];
|
|
37
|
+
NSString *buildNumber = buildVersion;
|
|
36
38
|
NSString *deploymentKey = [infoDictionary objectForKey:@"CodePushDeploymentKey"];
|
|
37
39
|
NSString *serverURL = [infoDictionary objectForKey:@"CodePushServerURL"];
|
|
38
40
|
NSString *publicKey = [infoDictionary objectForKey:@"CodePushPublicKey"];
|
|
@@ -53,6 +55,7 @@ static NSString * const PublicKeyKey = @"publicKey";
|
|
|
53
55
|
|
|
54
56
|
if (appVersion) [_configDictionary setObject:appVersion forKey:AppVersionConfigKey];
|
|
55
57
|
if (buildVersion) [_configDictionary setObject:buildVersion forKey:BuildVersionConfigKey];
|
|
58
|
+
if (buildNumber) [_configDictionary setObject:buildNumber forKey:BuildNumberConfigKey];
|
|
56
59
|
if (serverURL) [_configDictionary setObject:serverURL forKey:ServerURLConfigKey];
|
|
57
60
|
if (clientUniqueId) [_configDictionary setObject:clientUniqueId forKey:ClientUniqueIDConfigKey];
|
|
58
61
|
if (deploymentKey) [_configDictionary setObject:deploymentKey forKey:DeploymentKeyConfigKey];
|
|
@@ -66,11 +69,21 @@ static NSString * const PublicKeyKey = @"publicKey";
|
|
|
66
69
|
return [_configDictionary objectForKey:AppVersionConfigKey];
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
- (NSString *)buildNumber
|
|
73
|
+
{
|
|
74
|
+
return [_configDictionary objectForKey:BuildNumberConfigKey];
|
|
75
|
+
}
|
|
76
|
+
|
|
69
77
|
- (NSString *)buildVersion
|
|
70
78
|
{
|
|
71
79
|
return [_configDictionary objectForKey:BuildVersionConfigKey];
|
|
72
80
|
}
|
|
73
81
|
|
|
82
|
+
- (void)setBuildNumber:(NSString *)buildNumber
|
|
83
|
+
{
|
|
84
|
+
[_configDictionary setValue:buildNumber forKey:BuildNumberConfigKey];
|
|
85
|
+
}
|
|
86
|
+
|
|
74
87
|
- (NSDictionary *)configuration
|
|
75
88
|
{
|
|
76
89
|
return _configDictionary;
|
|
@@ -197,16 +197,24 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
|
|
|
197
197
|
return AssetsFolderName;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
+ (NSString *)cacheKeyForBinaryAtURL:(NSURL *)binaryBundleUrl
|
|
201
|
+
{
|
|
202
|
+
NSString *bundleModifiedDate = [self modifiedDateStringOfFileAtURL:binaryBundleUrl];
|
|
203
|
+
return [NSString stringWithFormat:@"%@:%@",
|
|
204
|
+
[[NSBundle mainBundle] bundlePath],
|
|
205
|
+
bundleModifiedDate ?: @"unknown"];
|
|
206
|
+
}
|
|
207
|
+
|
|
200
208
|
+ (NSString *)getHashForBinaryContents:(NSURL *)binaryBundleUrl
|
|
201
209
|
error:(NSError **)error
|
|
202
210
|
{
|
|
203
211
|
// Get the cached hash from user preferences if it exists.
|
|
204
|
-
NSString *
|
|
212
|
+
NSString *binaryCacheKey = [self cacheKeyForBinaryAtURL:binaryBundleUrl];
|
|
205
213
|
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
|
206
214
|
NSMutableDictionary *binaryHashDictionary = [preferences objectForKey:BinaryHashKey];
|
|
207
215
|
NSString *binaryHash = nil;
|
|
208
216
|
if (binaryHashDictionary != nil) {
|
|
209
|
-
binaryHash = [binaryHashDictionary objectForKey:
|
|
217
|
+
binaryHash = [binaryHashDictionary objectForKey:binaryCacheKey];
|
|
210
218
|
if (binaryHash == nil) {
|
|
211
219
|
[preferences removeObjectForKey:BinaryHashKey];
|
|
212
220
|
[preferences synchronize];
|
|
@@ -237,9 +245,7 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
|
|
|
237
245
|
|
|
238
246
|
binaryHash = [self computeFinalHashFromManifest:manifest error:error];
|
|
239
247
|
|
|
240
|
-
|
|
241
|
-
// JS bundle changes every time a new bundle is generated by the packager.
|
|
242
|
-
[binaryHashDictionary setObject:binaryHash forKey:binaryModifiedDate];
|
|
248
|
+
[binaryHashDictionary setObject:binaryHash forKey:binaryCacheKey];
|
|
243
249
|
[preferences setObject:binaryHashDictionary forKey:BinaryHashKey];
|
|
244
250
|
[preferences synchronize];
|
|
245
251
|
return binaryHash;
|
|
@@ -255,11 +261,10 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
|
|
|
255
261
|
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
|
256
262
|
NSMutableDictionary *assetsHashDictionary = [preferences objectForKey:BinaryAssetsHashKey];
|
|
257
263
|
|
|
258
|
-
NSString *
|
|
259
|
-
[NSURL fileURLWithPath:assetsPath isDirectory:YES]];
|
|
264
|
+
NSString *assetsCacheKey = [self cacheKeyForBinaryAtURL:[CodePush binaryBundleURL]];
|
|
260
265
|
|
|
261
266
|
if (assetsHashDictionary != nil) {
|
|
262
|
-
NSString *cached = [assetsHashDictionary objectForKey:
|
|
267
|
+
NSString *cached = [assetsHashDictionary objectForKey:assetsCacheKey];
|
|
263
268
|
if (cached != nil) {
|
|
264
269
|
return cached;
|
|
265
270
|
} else {
|
|
@@ -285,7 +290,7 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
|
|
|
285
290
|
return nil;
|
|
286
291
|
}
|
|
287
292
|
|
|
288
|
-
[assetsHashDictionary setObject:assetsHash forKey:
|
|
293
|
+
[assetsHashDictionary setObject:assetsHash forKey:assetsCacheKey];
|
|
289
294
|
[preferences setObject:assetsHashDictionary forKey:BinaryAssetsHashKey];
|
|
290
295
|
[preferences synchronize];
|
|
291
296
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revopush/react-native-code-push",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"url": "https://github.com/revopush/react-native-code-push"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@revopush/code-push": "4.
|
|
40
|
+
"@revopush/code-push": "4.4.0",
|
|
41
41
|
"glob": "^7.1.7",
|
|
42
42
|
"hoist-non-react-statics": "^3.3.2",
|
|
43
43
|
"inquirer": "^8.1.5",
|
|
@@ -39,6 +39,11 @@ export interface Package {
|
|
|
39
39
|
*/
|
|
40
40
|
appVersion: string;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The build number of the app binary (iOS: CFBundleVersion, Android: versionCode).
|
|
44
|
+
*/
|
|
45
|
+
buildNumber?: string;
|
|
46
|
+
|
|
42
47
|
/**
|
|
43
48
|
* The deployment key that was used to originally download this update.
|
|
44
49
|
*/
|