@algocare/react-native-code-push 11.0.0 → 11.0.2
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.
|
@@ -8,6 +8,7 @@ program
|
|
|
8
8
|
.description('Creates a new pull request history.')
|
|
9
9
|
.option('-a, --app <string>', 'target app (user/device)')
|
|
10
10
|
.option('-p, --platform <string>', 'target platform (ios/android)')
|
|
11
|
+
.option('-b, --binary-version <string>', 'target binary version (x.y.z)')
|
|
11
12
|
.option(
|
|
12
13
|
'-c, --config <path>',
|
|
13
14
|
'set config file name (JS/TS)',
|
package/package.json
CHANGED
|
@@ -1,533 +1,555 @@
|
|
|
1
|
-
export type DownloadProgressCallback = (progress: DownloadProgress) => void
|
|
2
|
-
export type SyncStatusChangedCallback = (status: CodePush.SyncStatus) => void
|
|
3
|
-
export type HandleBinaryVersionMismatchCallback = (
|
|
1
|
+
export type DownloadProgressCallback = (progress: DownloadProgress) => void
|
|
2
|
+
export type SyncStatusChangedCallback = (status: CodePush.SyncStatus) => void
|
|
3
|
+
export type HandleBinaryVersionMismatchCallback = (
|
|
4
|
+
update: RemotePackage
|
|
5
|
+
) => void
|
|
4
6
|
|
|
5
7
|
// from code-push SDK
|
|
6
8
|
export interface UpdateCheckRequest {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/** The native version, not in package.json. */
|
|
10
|
+
app_version: string
|
|
11
|
+
client_unique_id?: string
|
|
12
|
+
deployment_key: string
|
|
13
|
+
is_companion?: boolean
|
|
14
|
+
label?: string
|
|
15
|
+
package_hash?: string
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Alias for a string representing a released CodePush update version.
|
|
18
20
|
*/
|
|
19
|
-
export type ReleaseVersion = string
|
|
21
|
+
export type ReleaseVersion = string
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* The interface representing the release information that the `releaseHistoryFetcher` function must return.
|
|
23
25
|
*/
|
|
24
|
-
export type ReleaseHistoryInterface = Record<ReleaseVersion, ReleaseInfo
|
|
26
|
+
export type ReleaseHistoryInterface = Record<ReleaseVersion, ReleaseInfo>
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* The interface that represents a single deployment history entry, which the `releaseHistoryFetcher` function should return.
|
|
28
30
|
*/
|
|
29
31
|
export interface ReleaseInfo {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
enabled: boolean
|
|
33
|
+
mandatory: boolean
|
|
34
|
+
downloadUrl: string
|
|
35
|
+
packageHash: string
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
// from code-push SDK
|
|
37
39
|
export interface UpdateCheckResponse {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
download_url?: string
|
|
41
|
+
description?: string
|
|
42
|
+
is_available: boolean
|
|
43
|
+
is_disabled?: boolean
|
|
44
|
+
target_binary_range: string
|
|
45
|
+
/*generated*/ label?: string
|
|
46
|
+
/*generated*/ package_hash?: string
|
|
47
|
+
package_size?: number
|
|
48
|
+
should_run_binary_version?: boolean
|
|
49
|
+
update_app_version?: boolean
|
|
50
|
+
is_mandatory?: boolean
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export interface CodePushOptions extends SyncOptions {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Specifies when you would like to synchronize updates with the CodePush server.
|
|
56
|
+
* Defaults to codePush.CheckFrequency.ON_APP_START.
|
|
57
|
+
*/
|
|
58
|
+
checkFrequency: CodePush.CheckFrequency
|
|
59
|
+
/**
|
|
60
|
+
* Specifies a function to get the release history.
|
|
61
|
+
*
|
|
62
|
+
* If you want to use `updateChecker`, pass no-op function like below.
|
|
63
|
+
* But it is deprecated and will be removed in the next major version.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* const codePushOptions: {
|
|
67
|
+
* releaseHistoryFetcher: async () => ({}), // This will not be called
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
releaseHistoryFetcher: (
|
|
72
|
+
updateRequest: UpdateCheckRequest
|
|
73
|
+
) => Promise<ReleaseHistoryInterface>
|
|
74
|
+
/**
|
|
75
|
+
* Specify a function to perform the update check.
|
|
76
|
+
* It can be used for self-hosting.
|
|
77
|
+
* Defaults to AppCenter update_check REST API request.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated It will be removed in the next major version. Please migrate to `releaseHistoryFetcher`.
|
|
80
|
+
*/
|
|
81
|
+
updateChecker?: (
|
|
82
|
+
updateRequest: UpdateCheckRequest
|
|
83
|
+
) => Promise<{ update_info: UpdateCheckResponse }>
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
export interface DownloadProgress {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The total number of bytes expected to be received for this update.
|
|
89
|
+
*/
|
|
90
|
+
totalBytes: number
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The number of bytes downloaded thus far.
|
|
94
|
+
*/
|
|
95
|
+
receivedBytes: number
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
export interface LocalPackage extends Package {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Installs the update by saving it to the location on disk where the runtime expects to find the latest version of the app.
|
|
101
|
+
*
|
|
102
|
+
* @param installMode Indicates when you would like the update changes to take affect for the end-user.
|
|
103
|
+
* @param minimumBackgroundDuration For resume-based installs, this specifies the number of seconds the app needs to be in the background before forcing a restart. Defaults to 0 if unspecified.
|
|
104
|
+
*/
|
|
105
|
+
install(
|
|
106
|
+
installMode: CodePush.InstallMode,
|
|
107
|
+
minimumBackgroundDuration?: number
|
|
108
|
+
): Promise<void>
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
export interface Package {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
112
|
+
/**
|
|
113
|
+
* The app binary version that this update is dependent on. This is the value that was
|
|
114
|
+
* specified via the appStoreVersion parameter when calling the CLI's release command.
|
|
115
|
+
*/
|
|
116
|
+
appVersion: string
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The deployment key that was used to originally download this update.
|
|
120
|
+
*/
|
|
121
|
+
deploymentKey: string
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The description of the update. This is the same value that you specified in the CLI when you released the update.
|
|
125
|
+
*/
|
|
126
|
+
description: string
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Indicates whether this update has been previously installed but was rolled back.
|
|
130
|
+
*/
|
|
131
|
+
failedInstall: boolean
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Indicates whether this is the first time the update has been run after being installed.
|
|
135
|
+
*/
|
|
136
|
+
isFirstRun: boolean
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Indicates whether the update is considered mandatory. This is the value that was specified in the CLI when the update was released.
|
|
140
|
+
*/
|
|
141
|
+
isMandatory: boolean
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Indicates whether this update is in a "pending" state. When true, that means the update has been downloaded and installed, but the app restart
|
|
145
|
+
* needed to apply it hasn't occurred yet, and therefore, its changes aren't currently visible to the end-user.
|
|
146
|
+
*/
|
|
147
|
+
isPending: boolean
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The internal label automatically given to the update by the CodePush server. This value uniquely identifies the update within its deployment.
|
|
151
|
+
*/
|
|
152
|
+
label: string
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The SHA hash value of the update.
|
|
156
|
+
*/
|
|
157
|
+
packageHash: string
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The size of the code contained within the update, in bytes.
|
|
161
|
+
*/
|
|
162
|
+
packageSize: number
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
export interface RemotePackage extends Package {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Downloads the available update from the CodePush service.
|
|
168
|
+
*
|
|
169
|
+
* @param downloadProgressCallback An optional callback that allows tracking the progress of the update while it is being downloaded.
|
|
170
|
+
*/
|
|
171
|
+
download(
|
|
172
|
+
downloadProgressCallback?: DownloadProgressCallback
|
|
173
|
+
): Promise<LocalPackage>
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The URL at which the package is available for download.
|
|
177
|
+
*/
|
|
178
|
+
downloadUrl: string
|
|
168
179
|
}
|
|
169
180
|
|
|
170
181
|
export interface SyncOptions {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Specifies the deployment key you want to query for an update against. By default, this value is derived from the Info.plist
|
|
184
|
+
* file (iOS) and MainActivity.java file (Android), but this option allows you to override it from the script-side if you need to
|
|
185
|
+
* dynamically use a different deployment for a specific call to sync.
|
|
186
|
+
*/
|
|
187
|
+
deploymentKey?: string
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Specifies when you would like to install optional updates (i.e. those that aren't marked as mandatory).
|
|
191
|
+
* Defaults to codePush.InstallMode.ON_NEXT_RESTART.
|
|
192
|
+
*/
|
|
193
|
+
installMode?: CodePush.InstallMode
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Specifies when you would like to install updates which are marked as mandatory.
|
|
197
|
+
* Defaults to codePush.InstallMode.IMMEDIATE.
|
|
198
|
+
*/
|
|
199
|
+
mandatoryInstallMode?: CodePush.InstallMode
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Specifies the minimum number of seconds that the app needs to have been in the background before restarting the app. This property
|
|
203
|
+
* only applies to updates which are installed using `InstallMode.ON_NEXT_RESUME` or `InstallMode.ON_NEXT_SUSPEND`, and can be useful
|
|
204
|
+
* for getting your update in front of end users sooner, without being too obtrusive. Defaults to `0`, which has the effect of applying
|
|
205
|
+
* the update immediately after a resume or unless the app suspension is long enough to not matter, regardless how long it was in the background.
|
|
206
|
+
*/
|
|
207
|
+
minimumBackgroundDuration?: number
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available,
|
|
211
|
+
* and if so, what strings to use. Defaults to null, which has the effect of disabling the dialog completely. Setting this to any truthy
|
|
212
|
+
* value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as
|
|
213
|
+
* overriding one or more of the default strings.
|
|
214
|
+
*/
|
|
215
|
+
updateDialog?: UpdateDialog | true
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The rollback retry mechanism allows the application to attempt to reinstall an update that was previously rolled back (with the restrictions
|
|
219
|
+
* specified in the options). It is an "options" object used to determine whether a rollback retry should occur, and if so, what settings to use
|
|
220
|
+
* for the rollback retry. This defaults to null, which has the effect of disabling the retry mechanism. Setting this to any truthy value will enable
|
|
221
|
+
* the retry mechanism with the default settings, and passing an object to this parameter allows enabling the rollback retry as well as overriding
|
|
222
|
+
* one or more of the default values.
|
|
223
|
+
*/
|
|
224
|
+
rollbackRetryOptions?: RollbackRetryOptions
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Specifies whether to ignore the update if the installation fails.
|
|
228
|
+
* If set to false, the update will be retried when the sync method is called, even if the previous installation attempt failed.
|
|
229
|
+
* However, depending on the deployment strategy, if an update that cannot be successfully installed is deployed, this option could result in an infinite update retry loop.
|
|
230
|
+
* Defaults to true.
|
|
231
|
+
*/
|
|
232
|
+
ignoreFailedUpdates?: boolean
|
|
233
|
+
}
|
|
197
234
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
235
|
+
export interface UpdateDialog {
|
|
236
|
+
/**
|
|
237
|
+
* Indicates whether you would like to append the description of an available release to the
|
|
238
|
+
* notification message which is displayed to the end user. Defaults to false.
|
|
239
|
+
*/
|
|
240
|
+
appendReleaseDescription?: boolean
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Indicates the string you would like to prefix the release description with, if any, when
|
|
244
|
+
* displaying the update notification to the end user. Defaults to " Description: "
|
|
245
|
+
*/
|
|
246
|
+
descriptionPrefix?: string
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The text to use for the button the end user must press in order to install a mandatory update. Defaults to "Continue".
|
|
250
|
+
*/
|
|
251
|
+
mandatoryContinueButtonLabel?: string
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The text used as the body of an update notification, when the update is specified as mandatory.
|
|
255
|
+
* Defaults to "An update is available that must be installed.".
|
|
256
|
+
*/
|
|
257
|
+
mandatoryUpdateMessage?: string
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The text to use for the button the end user can press in order to ignore an optional update that is available. Defaults to "Ignore".
|
|
261
|
+
*/
|
|
262
|
+
optionalIgnoreButtonLabel?: string
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The text to use for the button the end user can press in order to install an optional update. Defaults to "Install".
|
|
266
|
+
*/
|
|
267
|
+
optionalInstallButtonLabel?: string
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The text used as the body of an update notification, when the update is optional. Defaults to "An update is available. Would you like to install it?".
|
|
271
|
+
*/
|
|
272
|
+
optionalUpdateMessage?: string
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The text used as the header of an update notification that is displayed to the end user. Defaults to "Update available".
|
|
276
|
+
*/
|
|
277
|
+
title?: string
|
|
278
|
+
}
|
|
205
279
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
280
|
+
export interface RollbackRetryOptions {
|
|
281
|
+
/**
|
|
282
|
+
* Specifies the minimum time in hours that the app will wait after the latest rollback
|
|
283
|
+
* before attempting to reinstall same rolled-back package. Defaults to `24`.
|
|
284
|
+
*/
|
|
285
|
+
delayInHours?: number
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Specifies the maximum number of retry attempts that the app can make before it stops trying.
|
|
289
|
+
* Cannot be less than `1`. Defaults to `1`.
|
|
290
|
+
*/
|
|
291
|
+
maxRetryAttempts?: number
|
|
292
|
+
}
|
|
214
293
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
294
|
+
export interface StatusReport {
|
|
295
|
+
/**
|
|
296
|
+
* Whether the deployment succeeded or failed.
|
|
297
|
+
*/
|
|
298
|
+
status: CodePush.DeploymentStatus
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The version of the app that was deployed (for a native app upgrade).
|
|
302
|
+
*/
|
|
303
|
+
appVersion?: string
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Details of the package that was deployed (or attempted to).
|
|
307
|
+
*/
|
|
308
|
+
package?: Package
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Deployment key used when deploying the previous package.
|
|
312
|
+
*/
|
|
313
|
+
previousDeploymentKey?: string
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The label (v#) of the package that was upgraded from.
|
|
317
|
+
*/
|
|
318
|
+
previousLabelOrAppVersion?: string
|
|
222
319
|
}
|
|
223
320
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Decorates a React Component configuring it to sync for updates with the CodePush server.
|
|
323
|
+
*
|
|
324
|
+
* @param options Options used to configure the end-user sync and update experience (e.g. when to check for updates?, show an prompt?, install the update immediately?).
|
|
325
|
+
*/
|
|
326
|
+
declare function CodePush(options?: CodePushOptions): (x: any) => any
|
|
230
327
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
328
|
+
/**
|
|
329
|
+
* Decorates a React Component configuring it to sync for updates with the CodePush server.
|
|
330
|
+
*
|
|
331
|
+
* @param x the React Component that will decorated
|
|
332
|
+
*/
|
|
333
|
+
declare function CodePush(x: any): any
|
|
236
334
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
335
|
+
declare namespace CodePush {
|
|
336
|
+
/**
|
|
337
|
+
* Represents the default settings that will be used by the sync method if
|
|
338
|
+
* an update dialog is configured to be displayed.
|
|
339
|
+
*/
|
|
340
|
+
var DEFAULT_UPDATE_DIALOG: UpdateDialog
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Asks the CodePush service whether the configured app deployment has an update available.
|
|
344
|
+
*
|
|
345
|
+
* @param prNumber The pull request number to use to query the CodePush server for an update.
|
|
346
|
+
* @param packageHash The package hash to use to query the CodePush server for an update.
|
|
347
|
+
* @param handleBinaryVersionMismatchCallback An optional callback for handling target binary version mismatch
|
|
348
|
+
*/
|
|
349
|
+
function checkForUpdate(
|
|
350
|
+
prNumber?: string,
|
|
351
|
+
packageHash?: string,
|
|
352
|
+
handleBinaryVersionMismatchCallback?: HandleBinaryVersionMismatchCallback
|
|
353
|
+
): Promise<RemotePackage | null>
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Retrieves the metadata for an installed update (e.g. description, mandatory).
|
|
357
|
+
*
|
|
358
|
+
* @param updateState The state of the update you want to retrieve the metadata for. Defaults to UpdateState.RUNNING.
|
|
359
|
+
*/
|
|
360
|
+
function getUpdateMetadata(
|
|
361
|
+
updateState?: UpdateState
|
|
362
|
+
): Promise<LocalPackage | null>
|
|
241
363
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
mandatoryUpdateMessage?: string;
|
|
364
|
+
/**
|
|
365
|
+
* Notifies the CodePush runtime that an installed update is considered successful.
|
|
366
|
+
*/
|
|
367
|
+
function notifyAppReady(): Promise<StatusReport | void>
|
|
247
368
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Allow CodePush to restart the app.
|
|
371
|
+
*/
|
|
372
|
+
function allowRestart(): void
|
|
252
373
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Forbid CodePush to restart the app.
|
|
376
|
+
*/
|
|
377
|
+
function disallowRestart(): void
|
|
257
378
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
379
|
+
/**
|
|
380
|
+
* Clear all downloaded CodePush updates.
|
|
381
|
+
* This is useful when switching to a different deployment which may have an older release than the current package.
|
|
382
|
+
* Note: we don’t recommend to use this method in scenarios other than that (CodePush will call
|
|
383
|
+
* this method automatically when needed in other cases) as it could lead to unpredictable behavior.
|
|
384
|
+
*/
|
|
385
|
+
function clearUpdates(): void
|
|
262
386
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
387
|
+
/**
|
|
388
|
+
* Immediately restarts the app.
|
|
389
|
+
*
|
|
390
|
+
* @param onlyIfUpdateIsPending Indicates whether you want the restart to no-op if there isn't currently a pending update.
|
|
391
|
+
*/
|
|
392
|
+
function restartApp(onlyIfUpdateIsPending?: boolean): void
|
|
268
393
|
|
|
269
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Allows checking for an update, downloading it and installing it, all with a single call.
|
|
396
|
+
*
|
|
397
|
+
* @param options Options used to configure the end-user update experience (e.g. show an prompt?, install the update immediately?).
|
|
398
|
+
* @param syncStatusChangedCallback An optional callback that allows tracking the status of the sync operation, as opposed to simply checking the resolved state via the returned Promise.
|
|
399
|
+
* @param downloadProgressCallback An optional callback that allows tracking the progress of an update while it is being downloaded.
|
|
400
|
+
* @param handleBinaryVersionMismatchCallback An optional callback for handling target binary version mismatch
|
|
401
|
+
*/
|
|
402
|
+
function sync(
|
|
403
|
+
options?: SyncOptions,
|
|
404
|
+
syncStatusChangedCallback?: SyncStatusChangedCallback,
|
|
405
|
+
downloadProgressCallback?: DownloadProgressCallback,
|
|
406
|
+
handleBinaryVersionMismatchCallback?: HandleBinaryVersionMismatchCallback
|
|
407
|
+
): Promise<SyncStatus>
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Indicates when you would like an installed update to actually be applied.
|
|
411
|
+
*/
|
|
412
|
+
enum InstallMode {
|
|
270
413
|
/**
|
|
271
|
-
*
|
|
272
|
-
* before attempting to reinstall same rolled-back package. Defaults to `24`.
|
|
414
|
+
* Indicates that you want to install the update and restart the app immediately.
|
|
273
415
|
*/
|
|
274
|
-
|
|
416
|
+
IMMEDIATE,
|
|
275
417
|
|
|
276
418
|
/**
|
|
277
|
-
*
|
|
278
|
-
* Cannot be less than `1`. Defaults to `1`.
|
|
419
|
+
* Indicates that you want to install the update, but not forcibly restart the app.
|
|
279
420
|
*/
|
|
280
|
-
|
|
281
|
-
}
|
|
421
|
+
ON_NEXT_RESTART,
|
|
282
422
|
|
|
283
|
-
export interface StatusReport {
|
|
284
423
|
/**
|
|
285
|
-
*
|
|
424
|
+
* Indicates that you want to install the update, but don't want to restart the app until the next time
|
|
425
|
+
* the end user resumes it from the background. This way, you don't disrupt their current session,
|
|
426
|
+
* but you can get the update in front of them sooner then having to wait for the next natural restart.
|
|
427
|
+
* This value is appropriate for silent installs that can be applied on resume in a non-invasive way.
|
|
286
428
|
*/
|
|
287
|
-
|
|
429
|
+
ON_NEXT_RESUME,
|
|
288
430
|
|
|
289
431
|
/**
|
|
290
|
-
*
|
|
432
|
+
* Indicates that you want to install the update when the app is in the background,
|
|
433
|
+
* but only after it has been in the background for "minimumBackgroundDuration" seconds (0 by default),
|
|
434
|
+
* so that user context isn't lost unless the app suspension is long enough to not matter.
|
|
291
435
|
*/
|
|
292
|
-
|
|
436
|
+
ON_NEXT_SUSPEND,
|
|
437
|
+
}
|
|
293
438
|
|
|
439
|
+
/**
|
|
440
|
+
* Indicates the current status of a sync operation.
|
|
441
|
+
*/
|
|
442
|
+
enum SyncStatus {
|
|
294
443
|
/**
|
|
295
|
-
*
|
|
444
|
+
* The app is up-to-date with the CodePush server.
|
|
296
445
|
*/
|
|
297
|
-
|
|
446
|
+
UP_TO_DATE,
|
|
298
447
|
|
|
299
448
|
/**
|
|
300
|
-
*
|
|
449
|
+
* An available update has been installed and will be run either immediately after the
|
|
450
|
+
* syncStatusChangedCallback function returns or the next time the app resumes/restarts,
|
|
451
|
+
* depending on the InstallMode specified in SyncOptions
|
|
301
452
|
*/
|
|
302
|
-
|
|
453
|
+
UPDATE_INSTALLED,
|
|
303
454
|
|
|
304
455
|
/**
|
|
305
|
-
* The
|
|
456
|
+
* The app had an optional update which the end user chose to ignore.
|
|
457
|
+
* (This is only applicable when the updateDialog is used)
|
|
306
458
|
*/
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Decorates a React Component configuring it to sync for updates with the CodePush server.
|
|
312
|
-
*
|
|
313
|
-
* @param options Options used to configure the end-user sync and update experience (e.g. when to check for updates?, show an prompt?, install the update immediately?).
|
|
314
|
-
*/
|
|
315
|
-
declare function CodePush(options?: CodePushOptions): (x: any) => any;
|
|
459
|
+
UPDATE_IGNORED,
|
|
316
460
|
|
|
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
|
-
declare namespace CodePush {
|
|
325
461
|
/**
|
|
326
|
-
*
|
|
327
|
-
* an update dialog is configured to be displayed.
|
|
462
|
+
* The sync operation encountered an unknown error.
|
|
328
463
|
*/
|
|
329
|
-
|
|
464
|
+
UNKNOWN_ERROR,
|
|
330
465
|
|
|
331
466
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* @param deploymentKey The deployment key to use to query the CodePush server for an update.
|
|
335
|
-
*
|
|
336
|
-
* @param handleBinaryVersionMismatchCallback An optional callback for handling target binary version mismatch
|
|
467
|
+
* There is an ongoing sync operation running which prevents the current call from being executed.
|
|
337
468
|
*/
|
|
338
|
-
|
|
469
|
+
SYNC_IN_PROGRESS,
|
|
339
470
|
|
|
340
471
|
/**
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* @param updateState The state of the update you want to retrieve the metadata for. Defaults to UpdateState.RUNNING.
|
|
472
|
+
* The CodePush server is being queried for an update.
|
|
344
473
|
*/
|
|
345
|
-
|
|
474
|
+
CHECKING_FOR_UPDATE,
|
|
346
475
|
|
|
347
476
|
/**
|
|
348
|
-
*
|
|
477
|
+
* An update is available, and a confirmation dialog was shown
|
|
478
|
+
* to the end user. (This is only applicable when the updateDialog is used)
|
|
349
479
|
*/
|
|
350
|
-
|
|
480
|
+
AWAITING_USER_ACTION,
|
|
351
481
|
|
|
352
482
|
/**
|
|
353
|
-
*
|
|
483
|
+
* An available update is being downloaded from the CodePush server.
|
|
354
484
|
*/
|
|
355
|
-
|
|
485
|
+
DOWNLOADING_PACKAGE,
|
|
356
486
|
|
|
357
487
|
/**
|
|
358
|
-
*
|
|
488
|
+
* An available update was downloaded and is about to be installed.
|
|
359
489
|
*/
|
|
360
|
-
|
|
490
|
+
INSTALLING_UPDATE,
|
|
491
|
+
}
|
|
361
492
|
|
|
493
|
+
/**
|
|
494
|
+
* Indicates the state that an update is currently in.
|
|
495
|
+
*/
|
|
496
|
+
enum UpdateState {
|
|
362
497
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* Note: we don’t recommend to use this method in scenarios other than that (CodePush will call
|
|
366
|
-
* this method automatically when needed in other cases) as it could lead to unpredictable behavior.
|
|
498
|
+
* Indicates that an update represents the
|
|
499
|
+
* version of the app that is currently running.
|
|
367
500
|
*/
|
|
368
|
-
|
|
501
|
+
RUNNING,
|
|
369
502
|
|
|
370
503
|
/**
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* @param onlyIfUpdateIsPending Indicates whether you want the restart to no-op if there isn't currently a pending update.
|
|
504
|
+
* Indicates than an update has been installed, but the
|
|
505
|
+
* app hasn't been restarted yet in order to apply it.
|
|
374
506
|
*/
|
|
375
|
-
|
|
507
|
+
PENDING,
|
|
376
508
|
|
|
377
509
|
/**
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* @param options Options used to configure the end-user update experience (e.g. show an prompt?, install the update immediately?).
|
|
381
|
-
* @param syncStatusChangedCallback An optional callback that allows tracking the status of the sync operation, as opposed to simply checking the resolved state via the returned Promise.
|
|
382
|
-
* @param downloadProgressCallback An optional callback that allows tracking the progress of an update while it is being downloaded.
|
|
383
|
-
* @param handleBinaryVersionMismatchCallback An optional callback for handling target binary version mismatch
|
|
510
|
+
* Indicates than an update represents the latest available
|
|
511
|
+
* release, and can be either currently running or pending.
|
|
384
512
|
*/
|
|
385
|
-
|
|
513
|
+
LATEST,
|
|
514
|
+
}
|
|
386
515
|
|
|
516
|
+
/**
|
|
517
|
+
* Indicates the status of a deployment (after installing and restarting).
|
|
518
|
+
*/
|
|
519
|
+
enum DeploymentStatus {
|
|
387
520
|
/**
|
|
388
|
-
*
|
|
521
|
+
* The deployment failed (and was rolled back).
|
|
389
522
|
*/
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Indicates that you want to install the update and restart the app immediately.
|
|
393
|
-
*/
|
|
394
|
-
IMMEDIATE,
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Indicates that you want to install the update, but not forcibly restart the app.
|
|
398
|
-
*/
|
|
399
|
-
ON_NEXT_RESTART,
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Indicates that you want to install the update, but don't want to restart the app until the next time
|
|
403
|
-
* the end user resumes it from the background. This way, you don't disrupt their current session,
|
|
404
|
-
* but you can get the update in front of them sooner then having to wait for the next natural restart.
|
|
405
|
-
* This value is appropriate for silent installs that can be applied on resume in a non-invasive way.
|
|
406
|
-
*/
|
|
407
|
-
ON_NEXT_RESUME,
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Indicates that you want to install the update when the app is in the background,
|
|
411
|
-
* but only after it has been in the background for "minimumBackgroundDuration" seconds (0 by default),
|
|
412
|
-
* so that user context isn't lost unless the app suspension is long enough to not matter.
|
|
413
|
-
*/
|
|
414
|
-
ON_NEXT_SUSPEND
|
|
415
|
-
}
|
|
523
|
+
FAILED,
|
|
416
524
|
|
|
417
525
|
/**
|
|
418
|
-
*
|
|
526
|
+
* The deployment succeeded.
|
|
419
527
|
*/
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* The app is up-to-date with the CodePush server.
|
|
423
|
-
*/
|
|
424
|
-
UP_TO_DATE,
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* An available update has been installed and will be run either immediately after the
|
|
428
|
-
* syncStatusChangedCallback function returns or the next time the app resumes/restarts,
|
|
429
|
-
* depending on the InstallMode specified in SyncOptions
|
|
430
|
-
*/
|
|
431
|
-
UPDATE_INSTALLED,
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* The app had an optional update which the end user chose to ignore.
|
|
435
|
-
* (This is only applicable when the updateDialog is used)
|
|
436
|
-
*/
|
|
437
|
-
UPDATE_IGNORED,
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* The sync operation encountered an unknown error.
|
|
441
|
-
*/
|
|
442
|
-
UNKNOWN_ERROR,
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* There is an ongoing sync operation running which prevents the current call from being executed.
|
|
446
|
-
*/
|
|
447
|
-
SYNC_IN_PROGRESS,
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* The CodePush server is being queried for an update.
|
|
451
|
-
*/
|
|
452
|
-
CHECKING_FOR_UPDATE,
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* An update is available, and a confirmation dialog was shown
|
|
456
|
-
* to the end user. (This is only applicable when the updateDialog is used)
|
|
457
|
-
*/
|
|
458
|
-
AWAITING_USER_ACTION,
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* An available update is being downloaded from the CodePush server.
|
|
462
|
-
*/
|
|
463
|
-
DOWNLOADING_PACKAGE,
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* An available update was downloaded and is about to be installed.
|
|
467
|
-
*/
|
|
468
|
-
INSTALLING_UPDATE
|
|
469
|
-
}
|
|
528
|
+
SUCCEEDED,
|
|
529
|
+
}
|
|
470
530
|
|
|
531
|
+
/**
|
|
532
|
+
* Indicates when you would like to check for (and install) updates from the CodePush server.
|
|
533
|
+
*/
|
|
534
|
+
enum CheckFrequency {
|
|
471
535
|
/**
|
|
472
|
-
*
|
|
536
|
+
* When the app is fully initialized (or more specifically, when the root component is mounted).
|
|
473
537
|
*/
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Indicates that an update represents the
|
|
477
|
-
* version of the app that is currently running.
|
|
478
|
-
*/
|
|
479
|
-
RUNNING,
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Indicates than an update has been installed, but the
|
|
483
|
-
* app hasn't been restarted yet in order to apply it.
|
|
484
|
-
*/
|
|
485
|
-
PENDING,
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Indicates than an update represents the latest available
|
|
489
|
-
* release, and can be either currently running or pending.
|
|
490
|
-
*/
|
|
491
|
-
LATEST
|
|
492
|
-
}
|
|
538
|
+
ON_APP_START,
|
|
493
539
|
|
|
494
540
|
/**
|
|
495
|
-
*
|
|
541
|
+
* When the app re-enters the foreground.
|
|
496
542
|
*/
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* The deployment failed (and was rolled back).
|
|
500
|
-
*/
|
|
501
|
-
FAILED,
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* The deployment succeeded.
|
|
505
|
-
*/
|
|
506
|
-
SUCCEEDED
|
|
507
|
-
}
|
|
543
|
+
ON_APP_RESUME,
|
|
508
544
|
|
|
509
545
|
/**
|
|
510
|
-
*
|
|
546
|
+
* Don't automatically check for updates, but only do it when codePush.sync() is manully called inside app code.
|
|
511
547
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
* When the app is fully initialized (or more specifically, when the root component is mounted).
|
|
515
|
-
*/
|
|
516
|
-
ON_APP_START,
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* When the app re-enters the foreground.
|
|
520
|
-
*/
|
|
521
|
-
ON_APP_RESUME,
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Don't automatically check for updates, but only do it when codePush.sync() is manully called inside app code.
|
|
525
|
-
*/
|
|
526
|
-
MANUAL
|
|
527
|
-
}
|
|
548
|
+
MANUAL,
|
|
549
|
+
}
|
|
528
550
|
}
|
|
529
551
|
|
|
530
|
-
export default CodePush
|
|
552
|
+
export default CodePush
|
|
531
553
|
|
|
532
554
|
/**
|
|
533
555
|
* Interface for the config file required for `npx code-push` CLI operation.
|
|
@@ -535,55 +557,55 @@ export default CodePush;
|
|
|
535
557
|
* Please refer to the example code for implementation guidance.
|
|
536
558
|
*/
|
|
537
559
|
export interface CliConfigInterface {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
560
|
+
/**
|
|
561
|
+
* Interface that must be implemented to upload CodePush bundle files to an arbitrary infrastructure.
|
|
562
|
+
*
|
|
563
|
+
* Used in the `release` command, and must return a URL that allows downloading the file after the upload is completed.
|
|
564
|
+
* The URL is recorded in the ReleaseHistory, and the CodePush runtime library downloads the bundle file from this address.
|
|
565
|
+
*
|
|
566
|
+
* @param source The relative path of the generated bundle file. (e.g. build/bundleOutput/1087bc338fc45a961c...)
|
|
567
|
+
* @param platform The target platform of the bundle file. This is the string passed when executing the CLI command. ('ios'/'android')
|
|
568
|
+
* @param identifier An additional identifier string. This can be used to distinguish execution environments by incorporating it into the upload path or file name. This string is passed when executing the CLI command.
|
|
569
|
+
*/
|
|
570
|
+
bundleUploader: (
|
|
571
|
+
source: string,
|
|
572
|
+
platform: 'ios' | 'android',
|
|
573
|
+
identifier?: string
|
|
574
|
+
) => Promise<{ downloadUrl: string }>
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Interface that must be implemented to retrieve ReleaseHistory information.
|
|
578
|
+
*
|
|
579
|
+
* Use `fetch`, `axios`, or similar methods to fetch the data and return it.
|
|
580
|
+
*
|
|
581
|
+
* @param targetBinaryVersion The target binary app version for which ReleaseHistory information is retrieved. This string is passed when executing the CLI command. (e.g., '1.0.0')
|
|
582
|
+
* @param platform The target platform for which the information is retrieved. This string is passed when executing the CLI command. ('ios'/'android')
|
|
583
|
+
* @param identifier An additional identifier string. This string is passed when executing the CLI command.
|
|
584
|
+
*/
|
|
585
|
+
getReleaseHistory: (
|
|
586
|
+
targetBinaryVersion: string,
|
|
587
|
+
platform: 'ios' | 'android',
|
|
588
|
+
identifier?: string
|
|
589
|
+
) => Promise<ReleaseHistoryInterface>
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Interface that must be implemented to create or update ReleaseHistory information.
|
|
593
|
+
*
|
|
594
|
+
* Used in the `create-history`, `release`, and `update-history` commands.
|
|
595
|
+
* The created or modified object and the JSON file path containing the result of the command execution are provided.
|
|
596
|
+
* Implement this function to upload the file or call a REST API to update the release history.
|
|
597
|
+
*
|
|
598
|
+
* @param targetBinaryVersion The target binary app version for the ReleaseHistory. This string is passed when executing the CLI command. (e.g., '1.0.0')
|
|
599
|
+
* @param jsonFilePath The absolute path to a JSON file following the `ReleaseHistoryInterface` structure. The file is created in the project's root directory and deleted when the command execution completes.
|
|
600
|
+
* @param releaseInfo A plain object following the `ReleaseHistoryInterface` structure.
|
|
601
|
+
* @param platform The target platform. This string is passed when executing the CLI command. ('ios'/'android')
|
|
602
|
+
* @param identifier An additional identifier string. This string is passed when executing the CLI command.
|
|
603
|
+
*/
|
|
604
|
+
setReleaseHistory: (
|
|
605
|
+
targetBinaryVersion: string,
|
|
606
|
+
jsonFilePath: string,
|
|
607
|
+
releaseInfo: ReleaseHistoryInterface,
|
|
608
|
+
platform: 'ios' | 'android',
|
|
609
|
+
identifier?: string
|
|
610
|
+
) => Promise<void>
|
|
589
611
|
}
|