@algocare/react-native-code-push 11.2.0 → 12.1.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 +56 -19
- package/package.json +1 -1
package/CodePush.js
CHANGED
|
@@ -8,8 +8,9 @@ let NativeCodePush = require('react-native').NativeModules.CodePush
|
|
|
8
8
|
const PackageMixins = require('./package-mixins')(NativeCodePush)
|
|
9
9
|
|
|
10
10
|
async function checkForUpdate(
|
|
11
|
-
prNumber,
|
|
12
|
-
packageHash,
|
|
11
|
+
prNumber = null,
|
|
12
|
+
packageHash = null,
|
|
13
|
+
deploymentKey = null,
|
|
13
14
|
handleBinaryVersionMismatchCallback = null
|
|
14
15
|
) {
|
|
15
16
|
/*
|
|
@@ -29,7 +30,9 @@ async function checkForUpdate(
|
|
|
29
30
|
* dynamically "redirecting" end-users at different
|
|
30
31
|
* deployments (e.g. an early access deployment for insiders).
|
|
31
32
|
*/
|
|
32
|
-
const config =
|
|
33
|
+
const config = deploymentKey
|
|
34
|
+
? { ...nativeConfig, ...{ deploymentKey } }
|
|
35
|
+
: nativeConfig
|
|
33
36
|
|
|
34
37
|
// Use dynamically overridden getCurrentPackage() during tests.
|
|
35
38
|
const localPackage = await module.exports.getCurrentPackage()
|
|
@@ -64,6 +67,9 @@ async function checkForUpdate(
|
|
|
64
67
|
client_unique_id: config.clientUniqueId,
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
console.log('updateRequest')
|
|
71
|
+
console.log(updateRequest)
|
|
72
|
+
|
|
67
73
|
/**
|
|
68
74
|
* @type {updateChecker|undefined}
|
|
69
75
|
* @deprecated
|
|
@@ -81,28 +87,52 @@ async function checkForUpdate(
|
|
|
81
87
|
const releaseHistory =
|
|
82
88
|
await sharedCodePushOptions.releaseHistoryFetcher(updateRequest)
|
|
83
89
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
acc[version] = value
|
|
89
|
-
return acc
|
|
90
|
-
}, {})
|
|
90
|
+
const releaseHistoryVersions = Object.keys(releaseHistory)
|
|
91
|
+
|
|
92
|
+
console.log('releaseHistory')
|
|
93
|
+
console.log(releaseHistory)
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
console.log('prNumber')
|
|
96
|
+
console.log(prNumber)
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
!prNumber &&
|
|
100
|
+
updateRequest.label.includes('-') &&
|
|
101
|
+
releaseHistoryVersions.includes(updateRequest.label)
|
|
102
|
+
) {
|
|
103
|
+
// Pull Request 업데이트 체크 후 재시작 시 다시 시작 방지
|
|
104
|
+
console.log('after updating pull request, skip update check')
|
|
105
|
+
return
|
|
106
|
+
}
|
|
95
107
|
|
|
108
|
+
const filteredReleaseHistory = prNumber
|
|
109
|
+
? Object.entries(releaseHistory)
|
|
110
|
+
.filter(([key]) => key.includes(prNumber))
|
|
111
|
+
.reduce((acc, [key, value]) => {
|
|
112
|
+
const version = key.split('-')[1]
|
|
113
|
+
acc[version] = value
|
|
114
|
+
return acc
|
|
115
|
+
}, {})
|
|
116
|
+
: Object.entries(releaseHistory)
|
|
117
|
+
.filter(([key]) => !key.includes('-'))
|
|
118
|
+
.reduce((acc, [key, value]) => {
|
|
119
|
+
acc[key] = value
|
|
120
|
+
return acc
|
|
121
|
+
}, {})
|
|
122
|
+
|
|
123
|
+
console.log('filteredReleaseHistory')
|
|
124
|
+
console.log(filteredReleaseHistory)
|
|
96
125
|
/**
|
|
97
126
|
* `runtimeVersion`
|
|
98
127
|
* The version of currently running CodePush update. (It can be undefined if the app is running without CodePush update.)
|
|
99
128
|
* @type {string|undefined}
|
|
100
129
|
*/
|
|
101
|
-
const runtimeVersion =
|
|
102
|
-
|
|
103
|
-
|
|
130
|
+
const runtimeVersion =
|
|
131
|
+
updateRequest.label && updateRequest.label.includes('-')
|
|
132
|
+
? updateRequest.label.split('-')[1]
|
|
133
|
+
: updateRequest.label
|
|
104
134
|
|
|
105
|
-
const versioning = new SemverVersioning(
|
|
135
|
+
const versioning = new SemverVersioning(filteredReleaseHistory)
|
|
106
136
|
|
|
107
137
|
const shouldRollbackToBinary =
|
|
108
138
|
versioning.shouldRollbackToBinary(runtimeVersion)
|
|
@@ -117,6 +147,9 @@ async function checkForUpdate(
|
|
|
117
147
|
versioning.findLatestRelease()
|
|
118
148
|
const isMandatory = versioning.checkIsMandatory(runtimeVersion)
|
|
119
149
|
|
|
150
|
+
console.log('latestVersion')
|
|
151
|
+
console.log(latestVersion)
|
|
152
|
+
|
|
120
153
|
/**
|
|
121
154
|
* Convert the update information decided from `ReleaseHistoryInterface` to be passed to the library core (original CodePush library).
|
|
122
155
|
*
|
|
@@ -136,7 +169,7 @@ async function checkForUpdate(
|
|
|
136
169
|
* Retrieve the update version from the ReleaseHistory and store it in the label.
|
|
137
170
|
* This information can be accessed at runtime through the CodePush bundle metadata.
|
|
138
171
|
*/
|
|
139
|
-
label: latestVersion,
|
|
172
|
+
label: prNumber ? `${prNumber}-${latestVersion}` : latestVersion,
|
|
140
173
|
// false 전달해야 정상 동작함
|
|
141
174
|
update_app_version: false,
|
|
142
175
|
// 그닥 쓸모 없음
|
|
@@ -202,7 +235,7 @@ async function checkForUpdate(
|
|
|
202
235
|
remotePackage.failedInstall = await NativeCodePush.isFailedUpdate(
|
|
203
236
|
remotePackage.packageHash
|
|
204
237
|
)
|
|
205
|
-
remotePackage.deploymentKey = nativeConfig.deploymentKey
|
|
238
|
+
remotePackage.deploymentKey = deploymentKey || nativeConfig.deploymentKey
|
|
206
239
|
return remotePackage
|
|
207
240
|
}
|
|
208
241
|
}
|
|
@@ -257,6 +290,7 @@ async function getUpdateMetadata(updateState) {
|
|
|
257
290
|
let updateMetadata = await NativeCodePush.getUpdateMetadata(
|
|
258
291
|
updateState || CodePush.UpdateState.RUNNING
|
|
259
292
|
)
|
|
293
|
+
|
|
260
294
|
if (updateMetadata) {
|
|
261
295
|
updateMetadata = { ...PackageMixins.local, ...updateMetadata }
|
|
262
296
|
updateMetadata.failedInstall = await NativeCodePush.isFailedUpdate(
|
|
@@ -561,9 +595,12 @@ async function syncInternal(
|
|
|
561
595
|
await CodePush.notifyApplicationReady()
|
|
562
596
|
|
|
563
597
|
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE)
|
|
598
|
+
console.log('syncOptions')
|
|
599
|
+
console.log(syncOptions)
|
|
564
600
|
const remotePackage = await checkForUpdate(
|
|
565
601
|
syncOptions.prNumber,
|
|
566
602
|
syncOptions.packageHash,
|
|
603
|
+
syncOptions.deploymentKey,
|
|
567
604
|
handleBinaryVersionMismatchCallback
|
|
568
605
|
)
|
|
569
606
|
|