native-update 1.0.3 → 1.0.5
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/docs/APP_REVIEW_GUIDE.md +2 -2
- package/docs/BUNDLE_SIGNING.md +10 -4
- package/docs/LIVE_UPDATES_GUIDE.md +152 -127
- package/docs/MIGRATION.md +2 -2
- package/docs/NATIVE_UPDATES_GUIDE.md +17 -16
- package/docs/QUICK_START.md +64 -75
- package/docs/README.md +4 -5
- package/docs/api/app-review-api.md +1 -21
- package/docs/api/app-update-api.md +18 -110
- package/docs/api/events-api.md +83 -334
- package/docs/api/live-update-api.md +63 -86
- package/docs/examples/advanced-scenarios.md +72 -88
- package/docs/examples/basic-usage.md +41 -38
- package/docs/features/app-reviews.md +1 -1
- package/docs/features/app-updates.md +1 -1
- package/docs/features/live-updates.md +23 -14
- package/docs/getting-started/configuration.md +1 -1
- package/docs/getting-started/installation.md +2 -2
- package/docs/getting-started/quick-start.md +3 -3
- package/docs/guides/migration-from-codepush.md +10 -11
- package/docs/guides/security-best-practices.md +3 -3
- package/docs/guides/testing-guide.md +27 -28
- package/package.json +1 -1
|
@@ -55,12 +55,11 @@ src/__tests__/
|
|
|
55
55
|
3. **Test Update Flow**
|
|
56
56
|
```typescript
|
|
57
57
|
// Check for updates
|
|
58
|
-
const update = await NativeUpdate.
|
|
58
|
+
const update = await NativeUpdate.sync();
|
|
59
59
|
|
|
60
|
-
//
|
|
61
|
-
if (update.
|
|
62
|
-
await NativeUpdate.
|
|
63
|
-
await NativeUpdate.applyUpdate();
|
|
60
|
+
// Update will be downloaded and applied based on sync result
|
|
61
|
+
if (update.status === 'UPDATE_INSTALLED') {
|
|
62
|
+
await NativeUpdate.reload();
|
|
64
63
|
}
|
|
65
64
|
```
|
|
66
65
|
|
|
@@ -124,10 +123,11 @@ try {
|
|
|
124
123
|
node tools/bundle-signer.js sign test-bundle.zip private-key.pem
|
|
125
124
|
|
|
126
125
|
# Verify in app
|
|
127
|
-
const isValid = await NativeUpdate.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
const isValid = await NativeUpdate.LiveUpdate.validateUpdate({
|
|
127
|
+
bundlePath: 'bundle-path',
|
|
128
|
+
checksum: 'bundle-checksum',
|
|
129
|
+
signature: signature
|
|
130
|
+
});
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
### 4. Performance Testing
|
|
@@ -135,7 +135,7 @@ const isValid = await NativeUpdate.verifySignature(
|
|
|
135
135
|
#### Download Performance
|
|
136
136
|
```typescript
|
|
137
137
|
// Monitor download speed
|
|
138
|
-
NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
138
|
+
NativeUpdate.LiveUpdate.addListener('downloadProgress', (progress) => {
|
|
139
139
|
console.log(`Speed: ${progress.speed} MB/s`);
|
|
140
140
|
console.log(`Progress: ${progress.percent}%`);
|
|
141
141
|
});
|
|
@@ -175,18 +175,16 @@ NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
|
175
175
|
publicKey: 'your-public-key',
|
|
176
176
|
});
|
|
177
177
|
|
|
178
|
-
//
|
|
179
|
-
const
|
|
180
|
-
if (!update.available) return;
|
|
181
|
-
|
|
182
|
-
// Download with progress
|
|
183
|
-
await NativeUpdate.downloadUpdate();
|
|
178
|
+
// Sync will check, download and apply update
|
|
179
|
+
const result = await NativeUpdate.sync();
|
|
184
180
|
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
if (result.status === 'UPDATE_INSTALLED') {
|
|
182
|
+
// Reload to apply update
|
|
183
|
+
await NativeUpdate.reload();
|
|
184
|
+
}
|
|
187
185
|
|
|
188
186
|
// Verify
|
|
189
|
-
const current = await NativeUpdate.
|
|
187
|
+
const current = await NativeUpdate.current();
|
|
190
188
|
console.log('Updated to:', current.version);
|
|
191
189
|
}
|
|
192
190
|
```
|
|
@@ -196,7 +194,7 @@ NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
|
196
194
|
#### Network Failures
|
|
197
195
|
```typescript
|
|
198
196
|
// Test offline behavior
|
|
199
|
-
await NativeUpdate.
|
|
197
|
+
await NativeUpdate.sync()
|
|
200
198
|
.catch(error => {
|
|
201
199
|
expect(error.code).toBe('NETWORK_ERROR');
|
|
202
200
|
});
|
|
@@ -205,8 +203,9 @@ await NativeUpdate.checkForUpdate()
|
|
|
205
203
|
#### Corrupted Bundles
|
|
206
204
|
```typescript
|
|
207
205
|
// Test checksum validation
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
await NativeUpdate.download({
|
|
207
|
+
version: 'corrupted-version'
|
|
208
|
+
})
|
|
210
209
|
.catch(error => {
|
|
211
210
|
expect(error.code).toBe('CHECKSUM_ERROR');
|
|
212
211
|
});
|
|
@@ -217,15 +216,15 @@ await NativeUpdate.applyUpdate(corruptedBundle)
|
|
|
217
216
|
```typescript
|
|
218
217
|
// Test rollback mechanism
|
|
219
218
|
async function testRollback() {
|
|
220
|
-
//
|
|
221
|
-
await NativeUpdate.
|
|
219
|
+
// Set bad update
|
|
220
|
+
await NativeUpdate.set(badUpdate);
|
|
222
221
|
|
|
223
222
|
// Simulate app crash
|
|
224
223
|
await simulateCrash();
|
|
225
224
|
|
|
226
225
|
// Verify rollback on restart
|
|
227
|
-
const version = await NativeUpdate.
|
|
228
|
-
expect(version).toBe(previousVersion);
|
|
226
|
+
const version = await NativeUpdate.current();
|
|
227
|
+
expect(version.version).toBe(previousVersion);
|
|
229
228
|
}
|
|
230
229
|
```
|
|
231
230
|
|
|
@@ -269,8 +268,8 @@ jobs:
|
|
|
269
268
|
- [ ] Invalid configs rejected
|
|
270
269
|
- [ ] Channel switching works
|
|
271
270
|
|
|
272
|
-
- [ ] **Update
|
|
273
|
-
- [ ] Returns correct
|
|
271
|
+
- [ ] **Update Sync**
|
|
272
|
+
- [ ] Returns correct sync status
|
|
274
273
|
- [ ] Respects version constraints
|
|
275
274
|
- [ ] Handles network errors
|
|
276
275
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-update",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Foundation package for building a comprehensive update system for Capacitor apps. Provides architecture and interfaces but requires backend implementation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.cjs.js",
|