native-update 1.0.9 → 1.1.1
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/Readme.md +35 -17
- package/android/build.gradle +5 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +1 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +12 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +1 -2
- package/cli/cap-update.js +45 -0
- package/cli/commands/backend-create.js +582 -0
- package/cli/commands/bundle-create.js +113 -0
- package/cli/commands/bundle-sign.js +58 -0
- package/cli/commands/bundle-verify.js +55 -0
- package/cli/commands/init.js +146 -0
- package/cli/commands/keys-generate.js +92 -0
- package/cli/commands/monitor.js +68 -0
- package/cli/commands/server-start.js +96 -0
- package/cli/index.js +269 -0
- package/cli/package.json +12 -0
- package/docs/BUNDLE_SIGNING.md +16 -9
- package/docs/LIVE_UPDATES_GUIDE.md +1 -1
- package/docs/README.md +1 -0
- package/docs/cli-reference.md +321 -0
- package/docs/getting-started/configuration.md +3 -2
- package/docs/getting-started/quick-start.md +53 -1
- package/docs/guides/deployment-guide.md +9 -7
- package/docs/guides/key-management.md +284 -0
- package/docs/guides/migration-from-codepush.md +9 -5
- package/docs/guides/testing-guide.md +4 -4
- package/package.json +15 -2
package/Readme.md
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
- **[App Update API](./docs/api/app-update-api.md)** - Native app update methods
|
|
42
42
|
- **[App Review API](./docs/api/app-review-api.md)** - Review request methods
|
|
43
43
|
- **[Events API](./docs/api/events-api.md)** - Event listeners and handlers
|
|
44
|
+
- **[CLI Reference](./docs/cli-reference.md)** - Command-line tools documentation
|
|
44
45
|
|
|
45
46
|
### Examples
|
|
46
47
|
|
|
@@ -316,28 +317,45 @@ The **[example-app](./example-app)** directory contains a complete, production-r
|
|
|
316
317
|
|
|
317
318
|
We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
318
319
|
|
|
319
|
-
## 🛠️
|
|
320
|
+
## 🛠️ CLI Tools & Utilities
|
|
320
321
|
|
|
321
|
-
###
|
|
322
|
+
### Zero-Install CLI Access
|
|
322
323
|
|
|
323
|
-
|
|
324
|
-
- Vitest test setup with example tests
|
|
325
|
-
- Run tests: `npm test`
|
|
326
|
-
- Coverage: `npm run test:coverage`
|
|
324
|
+
All tools are available via `npx` without cloning the repo:
|
|
327
325
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
-
|
|
326
|
+
```bash
|
|
327
|
+
# Quick start
|
|
328
|
+
npx native-update init --example
|
|
329
|
+
npx native-update backend create express --with-admin
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Available Commands
|
|
333
|
+
|
|
334
|
+
✅ **Bundle Management**
|
|
335
|
+
- Create bundles: `npx native-update bundle create ./www`
|
|
336
|
+
- Sign bundles: `npx native-update bundle sign bundle.zip --key private.pem`
|
|
337
|
+
- Verify signatures: `npx native-update bundle verify bundle.zip --key public.pem`
|
|
338
|
+
|
|
339
|
+
✅ **Key Management**
|
|
340
|
+
- Generate keys: `npx native-update keys generate --type rsa --size 4096`
|
|
341
|
+
- Supports RSA (2048/4096) and EC (256/384) keys
|
|
342
|
+
- Creates timestamped key pairs with proper permissions
|
|
343
|
+
- See [Key Management Guide](./docs/guides/key-management.md) for detailed instructions
|
|
344
|
+
|
|
345
|
+
✅ **Backend Templates**
|
|
346
|
+
- Express.js: `npx native-update backend create express --with-admin`
|
|
347
|
+
- Firebase: `npx native-update backend create firebase --with-monitoring`
|
|
348
|
+
- Vercel: `npx native-update backend create vercel`
|
|
349
|
+
|
|
350
|
+
✅ **Development Tools**
|
|
351
|
+
- Start dev server: `npx native-update server start --port 3000`
|
|
352
|
+
- Monitor updates: `npx native-update monitor --server https://your-server.com`
|
|
353
|
+
- Validate config: `npx native-update config check`
|
|
331
354
|
|
|
332
|
-
✅ **
|
|
333
|
-
-
|
|
334
|
-
- Sign bundles: `node tools/bundle-signer.js sign bundle.zip private-key.pem`
|
|
335
|
-
- Verify: `node tools/bundle-signer.js verify bundle.zip bundle.zip.sig public-key.pem`
|
|
355
|
+
✅ **Migration Tools**
|
|
356
|
+
- From CodePush: `npx native-update migrate --from codepush`
|
|
336
357
|
|
|
337
|
-
|
|
338
|
-
- Development server in `backend-template/`
|
|
339
|
-
- Start: `cd backend-template && npm install && npm start`
|
|
340
|
-
- Provides basic update API endpoints
|
|
358
|
+
See [CLI Reference](./docs/cli-reference.md) for complete documentation.
|
|
341
359
|
|
|
342
360
|
## 🏗️ Development Status
|
|
343
361
|
|
package/android/build.gradle
CHANGED
|
@@ -71,6 +71,8 @@ dependencies {
|
|
|
71
71
|
|
|
72
72
|
// Kotlin
|
|
73
73
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.22'
|
|
74
|
+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
|
|
75
|
+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.7.3'
|
|
74
76
|
|
|
75
77
|
// AndroidX
|
|
76
78
|
implementation "androidx.appcompat:appcompat:${androidxAppCompatVersion}"
|
|
@@ -90,6 +92,9 @@ dependencies {
|
|
|
90
92
|
// Security
|
|
91
93
|
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
|
|
92
94
|
|
|
95
|
+
// JSON parsing
|
|
96
|
+
implementation 'com.google.code.gson:gson:2.10.1'
|
|
97
|
+
|
|
93
98
|
// Testing
|
|
94
99
|
testImplementation 'junit:junit:4.13.2'
|
|
95
100
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
|
@@ -17,6 +17,7 @@ import com.google.android.play.core.install.model.InstallStatus
|
|
|
17
17
|
import com.google.android.play.core.install.model.UpdateAvailability
|
|
18
18
|
import com.google.android.play.core.ktx.isFlexibleUpdateAllowed
|
|
19
19
|
import com.google.android.play.core.ktx.isImmediateUpdateAllowed
|
|
20
|
+
import com.google.android.gms.tasks.Tasks
|
|
20
21
|
import kotlinx.coroutines.tasks.await
|
|
21
22
|
|
|
22
23
|
class AppUpdatePlugin(
|
|
@@ -25,6 +25,14 @@ class BackgroundNotificationManager(
|
|
|
25
25
|
private const val ACTION_UPDATE_NOW = "com.aoneahsan.nativeupdate.UPDATE_NOW"
|
|
26
26
|
private const val ACTION_UPDATE_LATER = "com.aoneahsan.nativeupdate.UPDATE_LATER"
|
|
27
27
|
private const val ACTION_DISMISS = "com.aoneahsan.nativeupdate.DISMISS"
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Static method to cancel notification from BroadcastReceiver
|
|
31
|
+
*/
|
|
32
|
+
fun cancelNotificationStatic(context: Context) {
|
|
33
|
+
val notificationManager = NotificationManagerCompat.from(context)
|
|
34
|
+
notificationManager.cancel(NOTIFICATION_ID)
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
private var preferences: NotificationPreferences = NotificationPreferences.default()
|
|
@@ -133,6 +141,10 @@ class BackgroundNotificationManager(
|
|
|
133
141
|
notificationManager.cancel(NOTIFICATION_ID)
|
|
134
142
|
}
|
|
135
143
|
|
|
144
|
+
fun cancelUpdateNotification() {
|
|
145
|
+
cancelNotification()
|
|
146
|
+
}
|
|
147
|
+
|
|
136
148
|
private fun createNotificationBuilder(
|
|
137
149
|
appUpdate: AppUpdateInfo?,
|
|
138
150
|
liveUpdate: LatestVersion?
|
|
@@ -38,8 +38,7 @@ class NotificationActionReceiver : BroadcastReceiver() {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Cancel the notification
|
|
41
|
-
|
|
42
|
-
notificationManager.cancelUpdateNotification()
|
|
41
|
+
BackgroundNotificationManager.cancelNotificationStatic(context)
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
private fun handleInstallNow(context: Context, intent: Intent) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
|
|
7
|
+
const program = new Command();
|
|
8
|
+
const packageJson = JSON.parse(
|
|
9
|
+
readFileSync(resolve(process.cwd(), 'package.json'), 'utf8')
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.name('cap-update')
|
|
14
|
+
.description('CLI for Capacitor Native Update')
|
|
15
|
+
.version('1.0.0');
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.command('init')
|
|
19
|
+
.description('Initialize update configuration')
|
|
20
|
+
.option('-s, --server <url>', 'Update server URL')
|
|
21
|
+
.action((options) => {
|
|
22
|
+
console.log('Initializing Capacitor Native Update...');
|
|
23
|
+
console.log('Server:', options.server || 'Not specified');
|
|
24
|
+
// TODO: Create config file
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
program
|
|
28
|
+
.command('bundle')
|
|
29
|
+
.description('Create update bundle')
|
|
30
|
+
.argument('<path>', 'Path to dist directory')
|
|
31
|
+
.action((path) => {
|
|
32
|
+
console.log(`Creating bundle from: ${path}`);
|
|
33
|
+
// TODO: Call bundle creator
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
program
|
|
37
|
+
.command('sign')
|
|
38
|
+
.description('Sign update bundle')
|
|
39
|
+
.argument('<bundle>', 'Bundle file path')
|
|
40
|
+
.action((bundle) => {
|
|
41
|
+
console.log(`Signing bundle: ${bundle}`);
|
|
42
|
+
// TODO: Call bundle signer
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
program.parse();
|