@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
|
@@ -50,20 +50,20 @@ public class CodePush implements ReactPackage {
|
|
|
50
50
|
private static ReactInstanceHolder mReactInstanceHolder;
|
|
51
51
|
private static CodePush mCurrentInstance;
|
|
52
52
|
|
|
53
|
-
public CodePush(
|
|
54
|
-
this(
|
|
53
|
+
public CodePush(Context context) {
|
|
54
|
+
this(context, false);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
public static String getServiceUrl() {
|
|
58
58
|
return mServerUrl;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
public CodePush(
|
|
61
|
+
public CodePush(Context context, boolean isDebugMode) {
|
|
62
62
|
mContext = context.getApplicationContext();
|
|
63
63
|
|
|
64
64
|
mUpdateManager = new CodePushUpdateManager(context.getFilesDir().getAbsolutePath());
|
|
65
65
|
mTelemetryManager = new CodePushTelemetryManager(mContext);
|
|
66
|
-
mDeploymentKey =
|
|
66
|
+
mDeploymentKey = "deprecated_deployment_key";
|
|
67
67
|
mIsDebugMode = isDebugMode;
|
|
68
68
|
mSettingsManager = new SettingsManager(mContext);
|
|
69
69
|
|
|
@@ -88,19 +88,19 @@ public class CodePush implements ReactPackage {
|
|
|
88
88
|
initializeUpdateAfterRestart();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
public CodePush(
|
|
92
|
-
this(
|
|
91
|
+
public CodePush(Context context, boolean isDebugMode, String serverUrl) {
|
|
92
|
+
this(context, isDebugMode);
|
|
93
93
|
mServerUrl = serverUrl;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
public CodePush(
|
|
97
|
-
this(
|
|
96
|
+
public CodePush(Context context, boolean isDebugMode, int publicKeyResourceDescriptor) {
|
|
97
|
+
this(context, isDebugMode);
|
|
98
98
|
|
|
99
99
|
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
public CodePush(
|
|
103
|
-
this(
|
|
102
|
+
public CodePush(Context context, boolean isDebugMode, String serverUrl, Integer publicKeyResourceDescriptor) {
|
|
103
|
+
this(context, isDebugMode);
|
|
104
104
|
|
|
105
105
|
if (publicKeyResourceDescriptor != null) {
|
|
106
106
|
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
|
|
@@ -129,10 +129,10 @@ public class CodePush implements ReactPackage {
|
|
|
129
129
|
|
|
130
130
|
private String getCustomPropertyFromStringsIfExist(String propertyName) {
|
|
131
131
|
String property;
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
String packageName = mContext.getPackageName();
|
|
134
134
|
int resId = mContext.getResources().getIdentifier("CodePush" + propertyName, "string", packageName);
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
if (resId != 0) {
|
|
137
137
|
property = mContext.getString(resId);
|
|
138
138
|
|
|
@@ -140,7 +140,7 @@ public class CodePush implements ReactPackage {
|
|
|
140
140
|
return property;
|
|
141
141
|
} else {
|
|
142
142
|
CodePushUtils.log("Specified " + propertyName + " is empty");
|
|
143
|
-
}
|
|
143
|
+
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
return null;
|
|
@@ -10,8 +10,8 @@ public class CodePushBuilder {
|
|
|
10
10
|
private String mServerUrl;
|
|
11
11
|
private Integer mPublicKeyResourceDescriptor;
|
|
12
12
|
|
|
13
|
-
public CodePushBuilder(
|
|
14
|
-
this.mDeploymentKey =
|
|
13
|
+
public CodePushBuilder(Context context) {
|
|
14
|
+
this.mDeploymentKey = "deprecated_deployment_key";
|
|
15
15
|
this.mContext = context;
|
|
16
16
|
this.mServerUrl = CodePush.getServiceUrl();
|
|
17
17
|
}
|
|
@@ -32,6 +32,6 @@ public class CodePushBuilder {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
public CodePush build() {
|
|
35
|
-
return new CodePush(this.
|
|
35
|
+
return new CodePush(this.mContext, this.mIsDebugMode, this.mServerUrl, this.mPublicKeyResourceDescriptor);
|
|
36
36
|
}
|
|
37
37
|
}
|
package/ios/CodePush/CodePush.m
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
long long _latestExpectedContentLength;
|
|
32
32
|
long long _latestReceivedConentLength;
|
|
33
33
|
BOOL _didUpdateProgress;
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
BOOL _allowed;
|
|
36
36
|
BOOL _restartInProgress;
|
|
37
37
|
NSMutableArray *_restartQueue;
|
|
@@ -216,7 +216,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
216
216
|
|
|
217
217
|
+ (void)setDeploymentKey:(NSString *)deploymentKey
|
|
218
218
|
{
|
|
219
|
-
[CodePushConfig current].deploymentKey =
|
|
219
|
+
[CodePushConfig current].deploymentKey = @"deprecated_deployment_key";
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
/*
|
|
@@ -376,7 +376,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
376
376
|
_allowed = YES;
|
|
377
377
|
_restartInProgress = NO;
|
|
378
378
|
_restartQueue = [NSMutableArray arrayWithCapacity:1];
|
|
379
|
-
|
|
379
|
+
|
|
380
380
|
self = [super init];
|
|
381
381
|
if (self) {
|
|
382
382
|
[self initializeUpdateAfterRestart];
|
|
@@ -582,7 +582,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
582
582
|
if ([[self class] isFailedHash:[failedPackage objectForKey:PackageHashKey]]) {
|
|
583
583
|
return;
|
|
584
584
|
}
|
|
585
|
-
|
|
585
|
+
|
|
586
586
|
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
|
587
587
|
NSMutableArray *failedUpdates = [preferences objectForKey:FailedUpdatesKey];
|
|
588
588
|
if (failedUpdates == nil) {
|
|
@@ -913,7 +913,7 @@ RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage
|
|
|
913
913
|
selector:@selector(applicationDidBecomeActive)
|
|
914
914
|
name:UIApplicationDidBecomeActiveNotification
|
|
915
915
|
object:RCTSharedApplication()];
|
|
916
|
-
|
|
916
|
+
|
|
917
917
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
918
918
|
selector:@selector(applicationWillEnterForeground)
|
|
919
919
|
name:UIApplicationWillEnterForegroundNotification
|
|
@@ -36,7 +36,7 @@ static NSString * const PublicKeyKey = @"publicKey";
|
|
|
36
36
|
NSString *deploymentKey = [infoDictionary objectForKey:@"CodePushDeploymentKey"];
|
|
37
37
|
NSString *serverURL = [infoDictionary objectForKey:@"CodePushServerURL"];
|
|
38
38
|
NSString *publicKey = [infoDictionary objectForKey:@"CodePushPublicKey"];
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
|
41
41
|
NSString *clientUniqueId = [userDefaults stringForKey:ClientUniqueIDConfigKey];
|
|
42
42
|
if (clientUniqueId == nil) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bravemobile/react-native-code-push",
|
|
3
|
-
"version": "9.0.0
|
|
3
|
+
"version": "9.0.0",
|
|
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",
|
|
@@ -47,6 +47,9 @@
|
|
|
47
47
|
"shelljs": "^0.8.5",
|
|
48
48
|
"yazl": "^3.3.1"
|
|
49
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"react-native": "*"
|
|
52
|
+
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@babel/core": "^7.26.0",
|
|
52
55
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -75,7 +78,7 @@
|
|
|
75
78
|
"slash": "^3.0.0",
|
|
76
79
|
"ts-node": "^10.9.2",
|
|
77
80
|
"tslint": "^6.1.3",
|
|
78
|
-
"typescript": "
|
|
81
|
+
"typescript": "5.0.4",
|
|
79
82
|
"typescript-eslint": "^8.11.0"
|
|
80
83
|
},
|
|
81
84
|
"engines": {
|
package/react-native.config.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = {
|
|
|
4
4
|
android: {
|
|
5
5
|
packageImportPath: "import com.microsoft.codepush.react.CodePush;",
|
|
6
6
|
packageInstance:
|
|
7
|
-
"new CodePush(
|
|
7
|
+
"new CodePush(getApplicationContext(), BuildConfig.DEBUG)",
|
|
8
8
|
sourceDir: './android/app'
|
|
9
9
|
}
|
|
10
10
|
}
|
package/tsconfig.json
CHANGED
|
@@ -2,12 +2,10 @@ export type DownloadProgressCallback = (progress: DownloadProgress) => void;
|
|
|
2
2
|
export type SyncStatusChangedCallback = (status: CodePush.SyncStatus) => void;
|
|
3
3
|
export type HandleBinaryVersionMismatchCallback = (update: RemotePackage) => void;
|
|
4
4
|
|
|
5
|
-
// from code-push SDK
|
|
6
5
|
export interface UpdateCheckRequest {
|
|
7
6
|
/** The native version, not in package.json. */
|
|
8
7
|
app_version: string;
|
|
9
8
|
client_unique_id?: string;
|
|
10
|
-
deployment_key: string;
|
|
11
9
|
is_companion?: boolean;
|
|
12
10
|
label?: string;
|
|
13
11
|
package_hash?: string;
|
|
@@ -314,13 +312,6 @@ export interface StatusReport {
|
|
|
314
312
|
*/
|
|
315
313
|
declare function CodePush(options?: CodePushOptions): (x: any) => any;
|
|
316
314
|
|
|
317
|
-
/**
|
|
318
|
-
* Decorates a React Component configuring it to sync for updates with the CodePush server.
|
|
319
|
-
*
|
|
320
|
-
* @param x the React Component that will decorated
|
|
321
|
-
*/
|
|
322
|
-
declare function CodePush(x: any): any;
|
|
323
|
-
|
|
324
315
|
declare namespace CodePush {
|
|
325
316
|
/**
|
|
326
317
|
* Represents the default settings that will be used by the sync method if
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
CliConfigInterface,
|
|
6
|
-
ReleaseHistoryInterface,
|
|
7
|
-
} from "@bravemobile/react-native-code-push";
|
|
8
|
-
import * as fs from "fs";
|
|
9
|
-
import axios from "axios"; // install as devDependency
|
|
10
|
-
import * as SupabaseSDK from "@supabase/supabase-js"; // install as devDependency
|
|
11
|
-
|
|
12
|
-
const SUPABASE_URL = process.env.SUPABASE_URL;
|
|
13
|
-
const SUPABASE_KEY = process.env.SUPABASE_KEY;
|
|
14
|
-
const supabase = SupabaseSDK.createClient(SUPABASE_URL!, SUPABASE_KEY!);
|
|
15
|
-
const BUCKET_NAME = "codePush";
|
|
16
|
-
const STORAGE_HOST = `${SUPABASE_URL}/storage/v1/object/public`;
|
|
17
|
-
|
|
18
|
-
function historyJsonFileRemotePath(
|
|
19
|
-
platform: "ios" | "android",
|
|
20
|
-
identifier: string,
|
|
21
|
-
binaryVersion: string,
|
|
22
|
-
) {
|
|
23
|
-
return `histories/${platform}/${identifier}/${binaryVersion}.json`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function bundleFileRemotePath(
|
|
27
|
-
platform: "ios" | "android",
|
|
28
|
-
identifier: string,
|
|
29
|
-
fileName: string,
|
|
30
|
-
) {
|
|
31
|
-
return `bundles/${platform}/${identifier}/${fileName}`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Config: CliConfigInterface = {
|
|
35
|
-
bundleUploader: async (
|
|
36
|
-
source: string,
|
|
37
|
-
platform: "ios" | "android",
|
|
38
|
-
identifier = "staging",
|
|
39
|
-
): Promise<{downloadUrl: string}> => {
|
|
40
|
-
const fileName = source.split("/").pop();
|
|
41
|
-
const fileStream = fs.createReadStream(source);
|
|
42
|
-
const remotePath = bundleFileRemotePath(platform, identifier, fileName!);
|
|
43
|
-
|
|
44
|
-
const {data, error} = await supabase.storage
|
|
45
|
-
.from(BUCKET_NAME)
|
|
46
|
-
.upload(remotePath, fileStream, {
|
|
47
|
-
contentType: "application/zip",
|
|
48
|
-
duplex: "half",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (error) {
|
|
52
|
-
console.error("Error uploading file:", error.message);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
console.log("Bundle File uploaded:", `${STORAGE_HOST}/${data.fullPath}`);
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
downloadUrl: `${STORAGE_HOST}/${data.fullPath}`,
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
getReleaseHistory: async (
|
|
64
|
-
targetBinaryVersion: string,
|
|
65
|
-
platform: "ios" | "android",
|
|
66
|
-
identifier = "staging",
|
|
67
|
-
): Promise<ReleaseHistoryInterface> => {
|
|
68
|
-
const remoteJsonPath = historyJsonFileRemotePath(
|
|
69
|
-
platform,
|
|
70
|
-
identifier,
|
|
71
|
-
targetBinaryVersion,
|
|
72
|
-
);
|
|
73
|
-
const {data} = await axios.get(
|
|
74
|
-
`${STORAGE_HOST}/${BUCKET_NAME}/${remoteJsonPath}`,
|
|
75
|
-
);
|
|
76
|
-
return data as ReleaseHistoryInterface;
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
setReleaseHistory: async (
|
|
80
|
-
targetBinaryVersion: string,
|
|
81
|
-
jsonFilePath: string,
|
|
82
|
-
releaseInfo: ReleaseHistoryInterface,
|
|
83
|
-
platform: "ios" | "android",
|
|
84
|
-
identifier = "staging",
|
|
85
|
-
): Promise<void> => {
|
|
86
|
-
// upload JSON file or call API using `releaseInfo` metadata.
|
|
87
|
-
|
|
88
|
-
const fileContent = fs.readFileSync(jsonFilePath, "utf8");
|
|
89
|
-
const remoteJsonPath = historyJsonFileRemotePath(
|
|
90
|
-
platform,
|
|
91
|
-
identifier,
|
|
92
|
-
targetBinaryVersion,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const {data, error} = await supabase.storage
|
|
96
|
-
.from(BUCKET_NAME)
|
|
97
|
-
.upload(remoteJsonPath, Buffer.from(fileContent), {
|
|
98
|
-
contentType: "application/json",
|
|
99
|
-
cacheControl: "5",
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
if (error) {
|
|
103
|
-
console.error("Error uploading file:", error.message);
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
console.log(
|
|
108
|
-
"Release history File uploaded:",
|
|
109
|
-
`${STORAGE_HOST}/${data.fullPath}`,
|
|
110
|
-
);
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
module.exports = Config;
|