@bravemobile/react-native-code-push 9.0.0-beta.3 → 9.0.0-beta.6
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 +15 -30
- 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/android/codepush.gradle +2 -2
- 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/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`
|
|
@@ -128,7 +120,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
128
120
|
should_run_binary_version: false,
|
|
129
121
|
}
|
|
130
122
|
|
|
131
|
-
return mapToRemotePackageMetadata(updateInfo
|
|
123
|
+
return mapToRemotePackageMetadata(updateInfo);
|
|
132
124
|
}
|
|
133
125
|
} catch (error) {
|
|
134
126
|
log(`An error has occurred at update checker :`);
|
|
@@ -158,7 +150,7 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
158
150
|
*/
|
|
159
151
|
if (!update || update.updateAppVersion ||
|
|
160
152
|
localPackage && (update.packageHash === localPackage.packageHash) ||
|
|
161
|
-
(!localPackage || localPackage._isDebugOnly) &&
|
|
153
|
+
(!localPackage || localPackage._isDebugOnly) && nativeConfig.packageHash === update.packageHash) {
|
|
162
154
|
if (update && update.updateAppVersion) {
|
|
163
155
|
log("An update is available but it is not targeting the binary version of your app.");
|
|
164
156
|
if (handleBinaryVersionMismatchCallback && typeof handleBinaryVersionMismatchCallback === "function") {
|
|
@@ -170,17 +162,15 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
|
|
|
170
162
|
} else {
|
|
171
163
|
const remotePackage = { ...update, ...PackageMixins.remote() };
|
|
172
164
|
remotePackage.failedInstall = await NativeCodePush.isFailedUpdate(remotePackage.packageHash);
|
|
173
|
-
remotePackage.deploymentKey = deploymentKey || nativeConfig.deploymentKey;
|
|
174
165
|
return remotePackage;
|
|
175
166
|
}
|
|
176
167
|
}
|
|
177
168
|
|
|
178
169
|
/**
|
|
179
170
|
* @param updateInfo {UpdateCheckResponse}
|
|
180
|
-
* @param deploymentKey {string}
|
|
181
171
|
* @return {RemotePackage | null}
|
|
182
172
|
*/
|
|
183
|
-
function mapToRemotePackageMetadata(updateInfo
|
|
173
|
+
function mapToRemotePackageMetadata(updateInfo) {
|
|
184
174
|
if (!updateInfo) {
|
|
185
175
|
return null;
|
|
186
176
|
} else if (!updateInfo.download_url) {
|
|
@@ -192,7 +182,7 @@ function mapToRemotePackageMetadata(updateInfo, deploymentKey) {
|
|
|
192
182
|
|
|
193
183
|
// refer to `RemotePackage` type inside code-push SDK
|
|
194
184
|
return {
|
|
195
|
-
deploymentKey:
|
|
185
|
+
deploymentKey: DEPLOYMENT_KEY,
|
|
196
186
|
description: updateInfo.description ?? '',
|
|
197
187
|
label: updateInfo.label ?? '',
|
|
198
188
|
appVersion: updateInfo.target_binary_range ?? '',
|
|
@@ -253,15 +243,9 @@ async function notifyApplicationReadyInternal() {
|
|
|
253
243
|
}
|
|
254
244
|
|
|
255
245
|
async function tryReportStatus(statusReport, retryOnAppResume) {
|
|
256
|
-
const config = await getConfiguration();
|
|
257
|
-
|
|
258
246
|
try {
|
|
259
247
|
if (statusReport.appVersion) {
|
|
260
248
|
log(`Reporting binary update (${statusReport.appVersion})`);
|
|
261
|
-
|
|
262
|
-
if (!config.deploymentKey) {
|
|
263
|
-
throw new Error("Deployment key is missed");
|
|
264
|
-
}
|
|
265
249
|
} else {
|
|
266
250
|
const label = statusReport.package.label;
|
|
267
251
|
if (statusReport.status === "DeploymentSucceeded") {
|
|
@@ -275,6 +259,7 @@ async function tryReportStatus(statusReport, retryOnAppResume) {
|
|
|
275
259
|
NativeCodePush.recordStatusReported(statusReport);
|
|
276
260
|
retryOnAppResume && retryOnAppResume.remove();
|
|
277
261
|
} catch (e) {
|
|
262
|
+
log(`${e}`)
|
|
278
263
|
log(`Report status failed: ${JSON.stringify(statusReport)}`);
|
|
279
264
|
NativeCodePush.saveStatusReportForRetry(statusReport);
|
|
280
265
|
// Try again when the app resumes
|
|
@@ -480,7 +465,7 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
|
|
|
480
465
|
await CodePush.notifyApplicationReady();
|
|
481
466
|
|
|
482
467
|
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
|
|
483
|
-
const remotePackage = await checkForUpdate(
|
|
468
|
+
const remotePackage = await checkForUpdate(handleBinaryVersionMismatchCallback);
|
|
484
469
|
|
|
485
470
|
const doDownloadAndInstall = async () => {
|
|
486
471
|
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
|
|
@@ -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/android/codepush.gradle
CHANGED
|
@@ -69,9 +69,9 @@ gradle.projectsEvaluated {
|
|
|
69
69
|
|
|
70
70
|
def nodeModulesPath;
|
|
71
71
|
if (project.hasProperty('nodeModulesPath')) {
|
|
72
|
-
nodeModulesPath = "${project.nodeModulesPath}/react-native-code-push"
|
|
72
|
+
nodeModulesPath = "${project.nodeModulesPath}/@bravemobile/react-native-code-push"
|
|
73
73
|
} else {
|
|
74
|
-
nodeModulesPath = findNodeModulePath(projectDir, "react-native-code-push")
|
|
74
|
+
nodeModulesPath = findNodeModulePath(projectDir, "@bravemobile/react-native-code-push")
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
def targetName = variant.name.capitalize()
|
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-beta.
|
|
3
|
+
"version": "9.0.0-beta.6",
|
|
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;
|