native-update-capacitor 0.0.0-stage → 4.4.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/AI-INTEGRATION-GUIDE.md +578 -0
- package/LICENSE +25 -0
- package/NativeUpdate.podspec +19 -0
- package/README.md +574 -2
- package/android/build.gradle +125 -0
- package/android/consumer-rules.pro +9 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +17 -0
- package/android/manifest-additions.xml +28 -0
- package/android/proguard-rules.pro +26 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +13 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +159 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +314 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +406 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +48 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +343 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +236 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/JsonOptional.kt +26 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +1249 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +404 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +107 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +240 -0
- package/android/variables.gradle +5 -0
- package/cli/commands/backend-create.js +623 -0
- package/cli/commands/bundle-create.js +145 -0
- package/cli/commands/bundle-sign.js +64 -0
- package/cli/commands/bundle-verify.js +58 -0
- package/cli/commands/flutter-patch.js +107 -0
- package/cli/commands/init.js +146 -0
- package/cli/commands/keys-generate.js +58 -0
- package/cli/commands/monitor.js +89 -0
- package/cli/commands/remote-shared.js +264 -0
- package/cli/commands/remote.js +634 -0
- package/cli/commands/server-start.js +96 -0
- package/cli/index.js +625 -0
- package/cli/package.json +21 -0
- package/dist/esm/app-review/app-review-manager.d.ts +24 -0
- package/dist/esm/app-review/app-review-manager.js +194 -0
- package/dist/esm/app-review/index.d.ts +5 -0
- package/dist/esm/app-review/index.js +5 -0
- package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
- package/dist/esm/app-review/platform-review-handler.js +137 -0
- package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
- package/dist/esm/app-review/review-conditions-checker.js +154 -0
- package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
- package/dist/esm/app-review/review-rate-limiter.js +163 -0
- package/dist/esm/app-review/types.d.ts +41 -0
- package/dist/esm/app-review/types.js +1 -0
- package/dist/esm/app-update/app-update-checker.d.ts +58 -0
- package/dist/esm/app-update/app-update-checker.js +227 -0
- package/dist/esm/app-update/app-update-installer.d.ts +20 -0
- package/dist/esm/app-update/app-update-installer.js +134 -0
- package/dist/esm/app-update/app-update-manager.d.ts +28 -0
- package/dist/esm/app-update/app-update-manager.js +198 -0
- package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
- package/dist/esm/app-update/app-update-notifier.js +99 -0
- package/dist/esm/app-update/index.d.ts +6 -0
- package/dist/esm/app-update/index.js +6 -0
- package/dist/esm/app-update/platform-app-update.d.ts +19 -0
- package/dist/esm/app-update/platform-app-update.js +138 -0
- package/dist/esm/app-update/types.d.ts +58 -0
- package/dist/esm/app-update/types.js +11 -0
- package/dist/esm/background-update/background-scheduler.d.ts +63 -0
- package/dist/esm/background-update/background-scheduler.js +332 -0
- package/dist/esm/background-update/index.d.ts +3 -0
- package/dist/esm/background-update/index.js +2 -0
- package/dist/esm/background-update/notification-manager.d.ts +29 -0
- package/dist/esm/background-update/notification-manager.js +88 -0
- package/dist/esm/config/support.d.ts +9 -0
- package/dist/esm/config/support.js +9 -0
- package/dist/esm/core/analytics.d.ts +83 -0
- package/dist/esm/core/analytics.js +151 -0
- package/dist/esm/core/cache-manager.d.ts +72 -0
- package/dist/esm/core/cache-manager.js +274 -0
- package/dist/esm/core/config.d.ts +69 -0
- package/dist/esm/core/config.js +107 -0
- package/dist/esm/core/errors.d.ts +56 -0
- package/dist/esm/core/errors.js +85 -0
- package/dist/esm/core/event-emitter.d.ts +30 -0
- package/dist/esm/core/event-emitter.js +80 -0
- package/dist/esm/core/logger.d.ts +21 -0
- package/dist/esm/core/logger.js +108 -0
- package/dist/esm/core/performance.d.ts +53 -0
- package/dist/esm/core/performance.js +153 -0
- package/dist/esm/core/plugin-manager.d.ts +88 -0
- package/dist/esm/core/plugin-manager.js +224 -0
- package/dist/esm/core/security.d.ts +123 -0
- package/dist/esm/core/security.js +361 -0
- package/dist/esm/core/update-check.d.ts +121 -0
- package/dist/esm/core/update-check.js +127 -0
- package/dist/esm/definitions.d.ts +872 -0
- package/dist/esm/definitions.js +104 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/live-update/bundle-manager.d.ts +102 -0
- package/dist/esm/live-update/bundle-manager.js +344 -0
- package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
- package/dist/esm/live-update/certificate-pinning.js +77 -0
- package/dist/esm/live-update/delta-processor.d.ts +84 -0
- package/dist/esm/live-update/delta-processor.js +257 -0
- package/dist/esm/live-update/download-manager.d.ts +106 -0
- package/dist/esm/live-update/download-manager.js +412 -0
- package/dist/esm/live-update/rollout-checker.d.ts +86 -0
- package/dist/esm/live-update/rollout-checker.js +304 -0
- package/dist/esm/live-update/update-manager.d.ts +63 -0
- package/dist/esm/live-update/update-manager.js +321 -0
- package/dist/esm/live-update/version-manager.d.ts +93 -0
- package/dist/esm/live-update/version-manager.js +390 -0
- package/dist/esm/plugin.d.ts +3 -0
- package/dist/esm/plugin.js +848 -0
- package/dist/esm/security/crypto.d.ts +88 -0
- package/dist/esm/security/crypto.js +228 -0
- package/dist/esm/security/validator.d.ts +60 -0
- package/dist/esm/security/validator.js +142 -0
- package/dist/esm/types/app-identity.d.ts +36 -0
- package/dist/esm/types/app-identity.js +1 -0
- package/dist/esm/types/rollout.d.ts +91 -0
- package/dist/esm/types/rollout.js +25 -0
- package/dist/esm/web.d.ts +130 -0
- package/dist/esm/web.js +981 -0
- package/dist/plugin.cjs +1 -0
- package/dist/plugin.esm.js +1 -0
- package/dist/plugin.js +2 -0
- package/docs/CHANGELOG.md +1016 -0
- package/docs/KNOWN_LIMITATIONS.md +240 -0
- package/docs/MIGRATION.md +391 -0
- package/docs/protocol/CLIENT-PROTOCOL.md +199 -0
- package/docs/server-requirements.md +211 -0
- package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
- package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +249 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +333 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +464 -0
- package/ios/Plugin/Info.plist +43 -0
- package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +1286 -0
- package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
- package/ios/Plugin/NativeUpdatePlugin.m +53 -0
- package/ios/Plugin/NativeUpdatePlugin.swift +315 -0
- package/ios/Plugin/Security/SecurityManager.swift +289 -0
- package/package.json +133 -4
package/cli/index.js
ADDED
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Native Update CLI
|
|
5
|
+
*
|
|
6
|
+
* Provides command-line tools for managing Capacitor Native Update plugin
|
|
7
|
+
* Can be used with npx, global install, or local install
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Command } from 'commander';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { dirname, join } from 'path';
|
|
14
|
+
import fs from 'fs/promises';
|
|
15
|
+
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename);
|
|
18
|
+
const packagePath = join(__dirname, '..', 'package.json');
|
|
19
|
+
const packageJson = JSON.parse(await fs.readFile(packagePath, 'utf-8'));
|
|
20
|
+
|
|
21
|
+
const program = new Command();
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.name('native-update')
|
|
25
|
+
// Positional options: program-level flags (e.g. the root `-V, --version`)
|
|
26
|
+
// must come BEFORE a subcommand. Anything after `bundle create …` belongs
|
|
27
|
+
// to the leaf command — so `bundle create ./www --version 1.2.0` reaches the
|
|
28
|
+
// leaf's own `--version <version>` option instead of triggering the root
|
|
29
|
+
// version display. Every parent command below enables this too so the flag
|
|
30
|
+
// is passed all the way down the program → bundle → create chain.
|
|
31
|
+
.enablePositionalOptions()
|
|
32
|
+
.description(`CLI tools for Capacitor Native Update plugin
|
|
33
|
+
|
|
34
|
+
${chalk.bold('Quick Start:')}
|
|
35
|
+
${chalk.gray('npx native-update init --example')} # Initialize with examples
|
|
36
|
+
${chalk.gray('npx native-update backend create express')} # Create backend server
|
|
37
|
+
${chalk.gray('npx native-update bundle create ./www')} # Create update bundle
|
|
38
|
+
|
|
39
|
+
${chalk.bold('Documentation:')}
|
|
40
|
+
${chalk.blue('https://nativeupdate.aoneahsan.com/docs')}`)
|
|
41
|
+
.version(packageJson.version)
|
|
42
|
+
.configureHelp({
|
|
43
|
+
sortSubcommands: true,
|
|
44
|
+
subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.aliases().join(', ')
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Bundle Management Commands
|
|
48
|
+
const bundleCmd = program
|
|
49
|
+
.command('bundle')
|
|
50
|
+
.enablePositionalOptions()
|
|
51
|
+
.description('Bundle management commands');
|
|
52
|
+
|
|
53
|
+
bundleCmd
|
|
54
|
+
.command('flutter-patch <apk>')
|
|
55
|
+
.description(`Turn a Flutter release APK into a signed-ready Dart code update (sideloaded apps only)
|
|
56
|
+
|
|
57
|
+
${chalk.bold('Examples:')}
|
|
58
|
+
${chalk.green('npx native-update bundle flutter-patch build/app/outputs/flutter-apk/app-release.apk -o patch.zip')}
|
|
59
|
+
${chalk.green('npx native-update deploy patch.zip --app com.example.app --version 1.0.1 --payload-type dart_aot --wait')}`)
|
|
60
|
+
.option('-o, --output <file>', 'Patch ZIP to write', 'flutter-patch.zip')
|
|
61
|
+
.option('--assets <dir>', 'Also ship the files in this folder, read with NativeUpdate.file()')
|
|
62
|
+
.action(async (apk, options) => {
|
|
63
|
+
const { createFlutterPatch } = await import('./commands/flutter-patch.js');
|
|
64
|
+
try {
|
|
65
|
+
await createFlutterPatch(apk, options);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
bundleCmd
|
|
73
|
+
.command('create <webDir>')
|
|
74
|
+
.alias('create-bundle')
|
|
75
|
+
.description(`Create an update bundle from your web directory
|
|
76
|
+
|
|
77
|
+
${chalk.bold('Examples:')}
|
|
78
|
+
${chalk.gray('# Create bundle from default build directory')}
|
|
79
|
+
${chalk.green('npx native-update bundle create ./www')}
|
|
80
|
+
|
|
81
|
+
${chalk.gray('# Create with specific version and channel')}
|
|
82
|
+
${chalk.green('npx native-update bundle create ./dist --version 1.2.0 --channel staging')}
|
|
83
|
+
|
|
84
|
+
${chalk.gray('# Add metadata like release notes')}
|
|
85
|
+
${chalk.green(`npx native-update bundle create ./www --metadata '{"releaseNotes":"Bug fixes"}'`)}`)
|
|
86
|
+
.option('-o, --output <path>', 'Output directory for the bundle', './update-bundles')
|
|
87
|
+
.option('-v, --version <version>', 'Bundle version (defaults to package.json version)')
|
|
88
|
+
.option('-c, --channel <channel>', 'Release channel', 'production')
|
|
89
|
+
.option('-m, --metadata <json>', 'Additional metadata as JSON string')
|
|
90
|
+
.action(async (webDir, options) => {
|
|
91
|
+
const { createBundle } = await import('./commands/bundle-create.js');
|
|
92
|
+
await createBundle(webDir, options);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
bundleCmd
|
|
96
|
+
.command('sign <bundlePath>')
|
|
97
|
+
.alias('sign-bundle')
|
|
98
|
+
.description(`Sign an update bundle with your private key
|
|
99
|
+
|
|
100
|
+
${chalk.bold('Examples:')}
|
|
101
|
+
${chalk.gray('# Sign a bundle with your private key')}
|
|
102
|
+
${chalk.green('npx native-update bundle sign ./bundle.zip --key ./keys/private.pem')}
|
|
103
|
+
|
|
104
|
+
${chalk.gray('# Specify output path for signed bundle')}
|
|
105
|
+
${chalk.green('npx native-update bundle sign ./bundle.zip --key private.pem --output ./signed-bundle.zip')}`)
|
|
106
|
+
.requiredOption('-k, --key <path>', 'Path to private key file')
|
|
107
|
+
.option('-o, --output <path>', 'Output path for signed bundle')
|
|
108
|
+
.action(async (bundlePath, options) => {
|
|
109
|
+
const { signBundle } = await import('./commands/bundle-sign.js');
|
|
110
|
+
await signBundle(bundlePath, options);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
bundleCmd
|
|
114
|
+
.command('verify <bundlePath>')
|
|
115
|
+
.alias('verify-bundle')
|
|
116
|
+
.description(`Verify a signed bundle with public key
|
|
117
|
+
|
|
118
|
+
${chalk.bold('Example:')}
|
|
119
|
+
${chalk.green('npx native-update bundle verify ./signed-bundle.zip --key ./keys/public.pem')}`)
|
|
120
|
+
.requiredOption('-k, --key <path>', 'Path to public key file')
|
|
121
|
+
.action(async (bundlePath, options) => {
|
|
122
|
+
const { verifyBundle } = await import('./commands/bundle-verify.js');
|
|
123
|
+
await verifyBundle(bundlePath, options);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Key Management Commands
|
|
127
|
+
const keysCmd = program
|
|
128
|
+
.command('keys')
|
|
129
|
+
.enablePositionalOptions()
|
|
130
|
+
.description('Key management commands');
|
|
131
|
+
|
|
132
|
+
keysCmd
|
|
133
|
+
.command('generate')
|
|
134
|
+
.alias('generate-keys')
|
|
135
|
+
.description(`Generate a new key pair for bundle signing
|
|
136
|
+
|
|
137
|
+
${chalk.bold('Examples:')}
|
|
138
|
+
${chalk.gray('# Generate default RSA 2048-bit keys')}
|
|
139
|
+
${chalk.green('npx native-update keys generate')}
|
|
140
|
+
|
|
141
|
+
${chalk.gray('# Generate strong RSA 4096-bit keys for production')}
|
|
142
|
+
${chalk.green('npx native-update keys generate --type rsa --size 4096 --output ./my-keys')}`)
|
|
143
|
+
.option('-o, --output <dir>', 'Output directory for keys', './keys')
|
|
144
|
+
.option('-t, --type <type>', 'Key type (rsa)', 'rsa')
|
|
145
|
+
.option('-s, --size <size>', 'RSA key size (2048 or 4096)', '2048')
|
|
146
|
+
.action(async (options) => {
|
|
147
|
+
const { generateKeys } = await import('./commands/keys-generate.js');
|
|
148
|
+
await generateKeys(options);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Server Commands
|
|
152
|
+
const serverCmd = program
|
|
153
|
+
.command('server')
|
|
154
|
+
.enablePositionalOptions()
|
|
155
|
+
.description('Development server commands');
|
|
156
|
+
|
|
157
|
+
serverCmd
|
|
158
|
+
.command('start')
|
|
159
|
+
.alias('start-server')
|
|
160
|
+
.description('Start a local update server for testing')
|
|
161
|
+
.option('-p, --port <port>', 'Server port', '3000')
|
|
162
|
+
.option('-d, --dir <dir>', 'Directory containing update bundles', './update-bundles')
|
|
163
|
+
.option('--cors', 'Enable CORS for testing', true)
|
|
164
|
+
.action(async (options) => {
|
|
165
|
+
const { startServer } = await import('./commands/server-start.js');
|
|
166
|
+
await startServer(options);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Init Commands
|
|
170
|
+
program
|
|
171
|
+
.command('init')
|
|
172
|
+
.description(`Initialize native-update in your project
|
|
173
|
+
|
|
174
|
+
${chalk.bold('Examples:')}
|
|
175
|
+
${chalk.gray('# Basic initialization')}
|
|
176
|
+
${chalk.green('npx native-update init')}
|
|
177
|
+
|
|
178
|
+
${chalk.gray('# Initialize with example code and configuration')}
|
|
179
|
+
${chalk.green('npx native-update init --example')}
|
|
180
|
+
|
|
181
|
+
${chalk.gray('# Initialize for Firebase backend')}
|
|
182
|
+
${chalk.green('npx native-update init --backend firebase --example')}`)
|
|
183
|
+
.option('--example', 'Include example configuration')
|
|
184
|
+
.option('--backend <type>', 'Backend type (firebase, express, custom)', 'custom')
|
|
185
|
+
.action(async (options) => {
|
|
186
|
+
const { init } = await import('./commands/init.js');
|
|
187
|
+
await init(options);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Backend Commands
|
|
191
|
+
const backendCmd = program
|
|
192
|
+
.command('backend')
|
|
193
|
+
.enablePositionalOptions()
|
|
194
|
+
.description('Backend template commands');
|
|
195
|
+
|
|
196
|
+
backendCmd
|
|
197
|
+
.command('create <type>')
|
|
198
|
+
.alias('create-backend')
|
|
199
|
+
.description(`Create a backend template (express, firebase, vercel)
|
|
200
|
+
|
|
201
|
+
${chalk.bold('Examples:')}
|
|
202
|
+
${chalk.gray('# Create Express.js backend with admin dashboard')}
|
|
203
|
+
${chalk.green('npx native-update backend create express --with-admin')}
|
|
204
|
+
|
|
205
|
+
${chalk.gray('# Create Firebase Functions backend with monitoring')}
|
|
206
|
+
${chalk.green('npx native-update backend create firebase --with-monitoring')}
|
|
207
|
+
|
|
208
|
+
${chalk.gray('# Create Vercel serverless backend')}
|
|
209
|
+
${chalk.green('npx native-update backend create vercel --output my-backend')}`)
|
|
210
|
+
.option('-o, --output <dir>', 'Output directory', './native-update-backend')
|
|
211
|
+
.option('--with-monitoring', 'Include monitoring setup', false)
|
|
212
|
+
.option('--with-admin', 'Include admin dashboard', false)
|
|
213
|
+
.action(async (type, options) => {
|
|
214
|
+
const { createBackend } = await import('./commands/backend-create.js');
|
|
215
|
+
await createBackend(type, options);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
// Public Management API commands (access token → nativeupdatebe.aoneahsan.com)
|
|
220
|
+
//
|
|
221
|
+
// Auth for all of these: NATIVE_UPDATE_TOKEN (preferred — a --token flag lands
|
|
222
|
+
// in shell history and `ps` output) or --token. Server: NATIVE_UPDATE_SERVER or
|
|
223
|
+
// --server, defaulting to the hosted backend.
|
|
224
|
+
//
|
|
225
|
+
// Every parent below calls .enablePositionalOptions() for the same reason
|
|
226
|
+
// `bundle` does: without it the root's `-V, --version` swallows a leaf's own
|
|
227
|
+
// `--version <v>` flag and prints the CLI version instead of deploying.
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
|
|
230
|
+
const remoteAuthOptions = (cmd) =>
|
|
231
|
+
cmd
|
|
232
|
+
.option('-t, --token <token>', 'Access token (or set NATIVE_UPDATE_TOKEN)')
|
|
233
|
+
.option('-s, --server <url>', 'Backend base URL (or set NATIVE_UPDATE_SERVER)');
|
|
234
|
+
|
|
235
|
+
// deploy — upload a bundle and publish it
|
|
236
|
+
remoteAuthOptions(
|
|
237
|
+
program
|
|
238
|
+
.command('deploy <webDirOrZip>')
|
|
239
|
+
.description(`Upload a bundle to your app and publish it
|
|
240
|
+
|
|
241
|
+
${chalk.bold('Examples:')}
|
|
242
|
+
${chalk.gray('# Deploy a built web directory (zipped for you)')}
|
|
243
|
+
${chalk.green('npx native-update deploy ./dist --app com.example.app --version 1.2.0')}
|
|
244
|
+
|
|
245
|
+
${chalk.gray('# Block until the release is actually live (recommended in CI)')}
|
|
246
|
+
${chalk.green('npx native-update deploy ./dist --app com.example.app --wait')}
|
|
247
|
+
|
|
248
|
+
${chalk.gray('# Staged rollout with release notes')}
|
|
249
|
+
${chalk.green('npx native-update deploy ./bundle.zip --app 12 --version 1.2.0 --rollout 10 --notes "Bug fixes"')}`)
|
|
250
|
+
.requiredOption('-a, --app <appIdOrNumericId>', 'App to deploy to (app_id like com.example.app, or numeric id)')
|
|
251
|
+
.option('-v, --version <version>', 'Bundle version (defaults to ./package.json version)')
|
|
252
|
+
.option('-c, --channel <channel>', 'Release channel', 'production')
|
|
253
|
+
.option('-n, --notes <text>', 'Release notes')
|
|
254
|
+
.option('-r, --rollout <percent>', 'Initial rollout percentage (1-100)')
|
|
255
|
+
.option('--min-native <version>', 'Minimum native app version required')
|
|
256
|
+
.option(
|
|
257
|
+
'--payload-type <type>',
|
|
258
|
+
'web_bundle (Capacitor / React Native code), assets (files a native Android or Flutter app reads) or dart_aot (a Flutter code patch from `bundle flutter-patch`)',
|
|
259
|
+
'web_bundle'
|
|
260
|
+
)
|
|
261
|
+
.option('--runtime-keys <keys>', 'dart_aot only: comma-separated engine keys (auto-read from a sibling .runtime-keys)')
|
|
262
|
+
.option('--signature <file>', 'Detached signature from `bundle sign` (auto-detects a sibling .sig)')
|
|
263
|
+
.option('-w, --wait', 'Wait for processing to finish (exit non-zero if it fails)', false)
|
|
264
|
+
).action(async (target, options) => {
|
|
265
|
+
const { deploy } = await import('./commands/remote.js');
|
|
266
|
+
await deploy(target, options);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// apps
|
|
270
|
+
const appsCmd = program
|
|
271
|
+
.command('apps')
|
|
272
|
+
.enablePositionalOptions()
|
|
273
|
+
.description('Manage the apps your access token can reach');
|
|
274
|
+
|
|
275
|
+
remoteAuthOptions(appsCmd.command('list').description('List apps this token can manage')).action(
|
|
276
|
+
async (options) => {
|
|
277
|
+
const { appsList } = await import('./commands/remote.js');
|
|
278
|
+
await appsList(options);
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
remoteAuthOptions(
|
|
283
|
+
appsCmd
|
|
284
|
+
.command('create')
|
|
285
|
+
.description('Create a new app (an explicitly-scoped token gains it automatically)')
|
|
286
|
+
.requiredOption('--name <name>', 'App display name')
|
|
287
|
+
.option('--bundle-id <id>', 'Reverse-DNS package id (e.g. com.example.app)')
|
|
288
|
+
.option('--platform <platform>', 'ios | android | both', 'both')
|
|
289
|
+
.option('--description <text>', 'Optional description')
|
|
290
|
+
).action(async (options) => {
|
|
291
|
+
const { appsCreate } = await import('./commands/remote.js');
|
|
292
|
+
await appsCreate(options);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
remoteAuthOptions(appsCmd.command('show <app>').description('Show one app')).action(
|
|
296
|
+
async (app, options) => {
|
|
297
|
+
const { appsShow } = await import('./commands/remote.js');
|
|
298
|
+
await appsShow(app, options);
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
remoteAuthOptions(
|
|
303
|
+
appsCmd
|
|
304
|
+
.command('update <app>')
|
|
305
|
+
.description('Edit an app (name / platform / description; bundle_id is immutable)')
|
|
306
|
+
.option('--name <name>', 'New display name')
|
|
307
|
+
.option('--platform <platform>', 'ios | android | both')
|
|
308
|
+
.option('--description <text>', 'New description')
|
|
309
|
+
).action(async (app, options) => {
|
|
310
|
+
const { appsUpdate } = await import('./commands/remote.js');
|
|
311
|
+
await appsUpdate(app, options);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
remoteAuthOptions(
|
|
315
|
+
appsCmd
|
|
316
|
+
.command('delete <app>')
|
|
317
|
+
.description('Delete an app + its builds/keys (needs the apps.delete token permission)')
|
|
318
|
+
.option('-y, --yes', 'Confirm the deletion', false)
|
|
319
|
+
).action(async (app, options) => {
|
|
320
|
+
const { appsDelete } = await import('./commands/remote.js');
|
|
321
|
+
await appsDelete(app, options);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// apps keys — per-app DEVICE API keys (nu_app_…). Nested under `apps` so it
|
|
325
|
+
// never collides with the top-level local signing `keys` command above.
|
|
326
|
+
const appsKeysCmd = appsCmd
|
|
327
|
+
.command('keys')
|
|
328
|
+
.enablePositionalOptions()
|
|
329
|
+
.description("Manage an app's device API keys (nu_app_…)");
|
|
330
|
+
|
|
331
|
+
remoteAuthOptions(appsKeysCmd.command('list <app>').description("List an app's API keys")).action(
|
|
332
|
+
async (app, options) => {
|
|
333
|
+
const { keysList } = await import('./commands/remote.js');
|
|
334
|
+
await keysList(app, options);
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
remoteAuthOptions(
|
|
339
|
+
appsKeysCmd.command('create <app>').description('Create an API key').option('--name <name>', 'Key name')
|
|
340
|
+
).action(async (app, options) => {
|
|
341
|
+
const { keysCreate } = await import('./commands/remote.js');
|
|
342
|
+
await keysCreate(app, options);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
remoteAuthOptions(appsKeysCmd.command('show <app> <key>').description('Show one API key')).action(
|
|
346
|
+
async (app, key, options) => {
|
|
347
|
+
const { keysShow } = await import('./commands/remote.js');
|
|
348
|
+
await keysShow(app, key, options);
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
remoteAuthOptions(
|
|
353
|
+
appsKeysCmd.command('rotate <app> <key>').description('Rotate a key (old one stops working)')
|
|
354
|
+
).action(async (app, key, options) => {
|
|
355
|
+
const { keysRotate } = await import('./commands/remote.js');
|
|
356
|
+
await keysRotate(app, key, options);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
remoteAuthOptions(
|
|
360
|
+
appsKeysCmd.command('reveal <app> <key>').description('Re-print a recoverable key')
|
|
361
|
+
).action(async (app, key, options) => {
|
|
362
|
+
const { keysReveal } = await import('./commands/remote.js');
|
|
363
|
+
await keysReveal(app, key, options);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
remoteAuthOptions(appsKeysCmd.command('revoke <app> <key>').description('Revoke a key')).action(
|
|
367
|
+
async (app, key, options) => {
|
|
368
|
+
const { keysRevoke } = await import('./commands/remote.js');
|
|
369
|
+
await keysRevoke(app, key, options);
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
remoteAuthOptions(
|
|
374
|
+
appsKeysCmd.command('deprecate <app> <key>').description('Deprecate a key (still works, usage logged)')
|
|
375
|
+
).action(async (app, key, options) => {
|
|
376
|
+
const { keysDeprecate } = await import('./commands/remote.js');
|
|
377
|
+
await keysDeprecate(app, key, options);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
remoteAuthOptions(
|
|
381
|
+
appsKeysCmd
|
|
382
|
+
.command('restrict <app> <key>')
|
|
383
|
+
.description('Set client restrictions from a JSON payload ({} clears them)')
|
|
384
|
+
.requiredOption('--json <json>', 'Restrictions JSON (origins/android/ios)')
|
|
385
|
+
).action(async (app, key, options) => {
|
|
386
|
+
const { keysRestrict } = await import('./commands/remote.js');
|
|
387
|
+
await keysRestrict(app, key, options);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
remoteAuthOptions(
|
|
391
|
+
appsKeysCmd
|
|
392
|
+
.command('delete <app> <key>')
|
|
393
|
+
.description('Permanently delete a key (needs the keys.delete permission)')
|
|
394
|
+
.option('-y, --yes', 'Confirm the deletion', false)
|
|
395
|
+
).action(async (app, key, options) => {
|
|
396
|
+
const { keysDelete } = await import('./commands/remote.js');
|
|
397
|
+
await keysDelete(app, key, options);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// apps signing — bundle signing keys (public key + fingerprint only)
|
|
401
|
+
const appsSigningCmd = appsCmd
|
|
402
|
+
.command('signing')
|
|
403
|
+
.enablePositionalOptions()
|
|
404
|
+
.description('Manage an app\'s bundle signing key');
|
|
405
|
+
|
|
406
|
+
remoteAuthOptions(appsSigningCmd.command('show <app>').description('Show the active signing key')).action(
|
|
407
|
+
async (app, options) => {
|
|
408
|
+
const { signingShow } = await import('./commands/remote.js');
|
|
409
|
+
await signingShow(app, options);
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
remoteAuthOptions(
|
|
414
|
+
appsSigningCmd.command('create <app>').description('Create the signing key').option('--name <name>', 'Key name')
|
|
415
|
+
).action(async (app, options) => {
|
|
416
|
+
const { signingCreate } = await import('./commands/remote.js');
|
|
417
|
+
await signingCreate(app, options);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
remoteAuthOptions(
|
|
421
|
+
appsSigningCmd.command('rotate <app>').description('Rotate the signing key').option('--name <name>', 'Key name')
|
|
422
|
+
).action(async (app, options) => {
|
|
423
|
+
const { signingRotate } = await import('./commands/remote.js');
|
|
424
|
+
await signingRotate(app, options);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// apps keystore — a private .zip backup of your app-signing keystore
|
|
428
|
+
const appsKeystoreCmd = appsCmd
|
|
429
|
+
.command('keystore')
|
|
430
|
+
.enablePositionalOptions()
|
|
431
|
+
.description('Private .zip backup of your app-signing keystore');
|
|
432
|
+
|
|
433
|
+
remoteAuthOptions(
|
|
434
|
+
appsKeystoreCmd.command('upload <app> <zipPath>').description('Upload/replace the keystore backup (.zip)')
|
|
435
|
+
).action(async (app, zipPath, options) => {
|
|
436
|
+
const { keystoreUpload } = await import('./commands/remote.js');
|
|
437
|
+
await keystoreUpload(app, zipPath, options);
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
remoteAuthOptions(appsKeystoreCmd.command('info <app>').description('Show backup metadata')).action(
|
|
441
|
+
async (app, options) => {
|
|
442
|
+
const { keystoreInfo } = await import('./commands/remote.js');
|
|
443
|
+
await keystoreInfo(app, options);
|
|
444
|
+
}
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
remoteAuthOptions(
|
|
448
|
+
appsKeystoreCmd
|
|
449
|
+
.command('download <app>')
|
|
450
|
+
.description('Download the keystore backup')
|
|
451
|
+
.option('-o, --output <file>', 'Output file (default: keystore-<app>.zip)')
|
|
452
|
+
).action(async (app, options) => {
|
|
453
|
+
const { keystoreDownload } = await import('./commands/remote.js');
|
|
454
|
+
await keystoreDownload(app, options);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
remoteAuthOptions(
|
|
458
|
+
appsKeystoreCmd
|
|
459
|
+
.command('delete <app>')
|
|
460
|
+
.description('Delete the keystore backup')
|
|
461
|
+
.option('-y, --yes', 'Confirm the deletion', false)
|
|
462
|
+
).action(async (app, options) => {
|
|
463
|
+
const { keystoreDelete } = await import('./commands/remote.js');
|
|
464
|
+
await keystoreDelete(app, options);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
// builds
|
|
468
|
+
const buildsCmd = program
|
|
469
|
+
.command('builds')
|
|
470
|
+
.enablePositionalOptions()
|
|
471
|
+
.description('Manage builds over the public API');
|
|
472
|
+
|
|
473
|
+
remoteAuthOptions(
|
|
474
|
+
buildsCmd
|
|
475
|
+
.command('list <app>')
|
|
476
|
+
.description('List builds for an app')
|
|
477
|
+
.option('-c, --channel <channel>', 'Filter by channel (production|staging|development)')
|
|
478
|
+
.option('--status <status>', 'Filter by status (active|processing|paused|archived|failed)')
|
|
479
|
+
.option('-p, --page <page>', 'Page number')
|
|
480
|
+
).action(async (app, options) => {
|
|
481
|
+
const { buildsList } = await import('./commands/remote.js');
|
|
482
|
+
await buildsList(app, options);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
remoteAuthOptions(
|
|
486
|
+
buildsCmd
|
|
487
|
+
.command('promote <app> <build>')
|
|
488
|
+
.description('Promote a build into another channel (zero-copy)')
|
|
489
|
+
.requiredOption('--to <channel>', 'Target channel (production|staging|development)')
|
|
490
|
+
).action(async (app, build, options) => {
|
|
491
|
+
const { buildsPromote } = await import('./commands/remote.js');
|
|
492
|
+
await buildsPromote(app, build, options);
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
remoteAuthOptions(
|
|
496
|
+
buildsCmd
|
|
497
|
+
.command('rollout <app> <build>')
|
|
498
|
+
.description('Set a build\'s rollout percentage')
|
|
499
|
+
.requiredOption('--percent <n>', 'Rollout percentage (0-100)')
|
|
500
|
+
).action(async (app, build, options) => {
|
|
501
|
+
const { buildsRollout } = await import('./commands/remote.js');
|
|
502
|
+
await buildsRollout(app, build, options);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
remoteAuthOptions(
|
|
506
|
+
buildsCmd
|
|
507
|
+
.command('status <app> <build>')
|
|
508
|
+
.description('Pause, resume, or archive a build')
|
|
509
|
+
.requiredOption('--set <status>', 'New status (active|paused|archived)')
|
|
510
|
+
).action(async (app, build, options) => {
|
|
511
|
+
const { buildsStatus } = await import('./commands/remote.js');
|
|
512
|
+
await buildsStatus(app, build, options);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
remoteAuthOptions(
|
|
516
|
+
buildsCmd
|
|
517
|
+
.command('delete <app> <build>')
|
|
518
|
+
.description('Delete a build (needs a token with the builds.delete permission)')
|
|
519
|
+
.option('-y, --yes', 'Confirm the deletion', false)
|
|
520
|
+
).action(async (app, build, options) => {
|
|
521
|
+
const { buildsDelete } = await import('./commands/remote.js');
|
|
522
|
+
await buildsDelete(app, build, options);
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// jobs
|
|
526
|
+
const jobsCmd = program
|
|
527
|
+
.command('jobs')
|
|
528
|
+
.enablePositionalOptions()
|
|
529
|
+
.description('Inspect queued work (bundle processing)');
|
|
530
|
+
|
|
531
|
+
remoteAuthOptions(
|
|
532
|
+
jobsCmd
|
|
533
|
+
.command('status <jobId>')
|
|
534
|
+
.description('Show a job\'s status')
|
|
535
|
+
.option('-w, --wait', 'Poll until the job finishes', false)
|
|
536
|
+
).action(async (jobId, options) => {
|
|
537
|
+
const { jobsStatus } = await import('./commands/remote.js');
|
|
538
|
+
await jobsStatus(jobId, options);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// token
|
|
542
|
+
const tokenCmd = program
|
|
543
|
+
.command('token')
|
|
544
|
+
.enablePositionalOptions()
|
|
545
|
+
.description('Inspect your access token');
|
|
546
|
+
|
|
547
|
+
remoteAuthOptions(
|
|
548
|
+
tokenCmd.command('info').description('Show what this token is and which apps it can manage')
|
|
549
|
+
).action(async (options) => {
|
|
550
|
+
const { tokenInfo } = await import('./commands/remote.js');
|
|
551
|
+
await tokenInfo(options);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
// Monitoring Commands
|
|
555
|
+
program
|
|
556
|
+
.command('monitor')
|
|
557
|
+
.description('Monitor update deployments')
|
|
558
|
+
.option('-s, --server <url>', 'Backend server URL')
|
|
559
|
+
.option('-k, --key <key>', 'API key for authentication')
|
|
560
|
+
.action(async (options) => {
|
|
561
|
+
const { monitor } = await import('./commands/monitor.js');
|
|
562
|
+
await monitor(options);
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
// Add helpful examples
|
|
566
|
+
program.on('--help', () => {
|
|
567
|
+
console.log('');
|
|
568
|
+
console.log('Examples:');
|
|
569
|
+
console.log('');
|
|
570
|
+
console.log(' Quick Start:');
|
|
571
|
+
console.log(' $ npx native-update init --example');
|
|
572
|
+
console.log(' $ npx native-update backend create express --with-admin');
|
|
573
|
+
console.log('');
|
|
574
|
+
console.log(' Bundle Management:');
|
|
575
|
+
console.log(' $ npx native-update bundle create ./www');
|
|
576
|
+
console.log(' $ npx native-update bundle sign ./bundle.zip --key ./keys/private.pem');
|
|
577
|
+
console.log(' $ npx native-update bundle verify ./bundle.zip --key ./keys/public.pem');
|
|
578
|
+
console.log('');
|
|
579
|
+
console.log(' Key Management:');
|
|
580
|
+
console.log(' $ npx native-update keys generate --type rsa --size 4096');
|
|
581
|
+
console.log('');
|
|
582
|
+
console.log(' Development:');
|
|
583
|
+
console.log(' $ npx native-update server start --port 3000');
|
|
584
|
+
console.log(' $ npx native-update monitor --server http://localhost:3000');
|
|
585
|
+
console.log('');
|
|
586
|
+
console.log(' Backend Templates:');
|
|
587
|
+
console.log(' $ npx native-update backend create express');
|
|
588
|
+
console.log(' $ npx native-update backend create firebase --with-monitoring');
|
|
589
|
+
console.log(' $ npx native-update backend create vercel --with-admin');
|
|
590
|
+
console.log('');
|
|
591
|
+
console.log(chalk.bold('Resources:'));
|
|
592
|
+
console.log(' Website: ' + chalk.blue('https://nativeupdate.aoneahsan.com'));
|
|
593
|
+
console.log(' Documentation: ' + chalk.blue('https://nativeupdate.aoneahsan.com/docs'));
|
|
594
|
+
console.log(' NPM Package: ' + chalk.blue('https://www.npmjs.com/package/native-update'));
|
|
595
|
+
console.log('');
|
|
596
|
+
console.log(chalk.bold('Support:'));
|
|
597
|
+
console.log(' Email: ' + chalk.blue('aoneahsan@gmail.com'));
|
|
598
|
+
console.log(' Author: Ahsan Mahmood (' + chalk.blue('https://aoneahsan.com') + ')');
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// Error handling
|
|
602
|
+
program.exitOverride();
|
|
603
|
+
|
|
604
|
+
try {
|
|
605
|
+
await program.parseAsync(process.argv);
|
|
606
|
+
} catch (error) {
|
|
607
|
+
// With exitOverride(), Commander throws for normal help/version output too
|
|
608
|
+
// (exitCode 0). Those are successful displays, not errors — exit quietly.
|
|
609
|
+
if (
|
|
610
|
+
error.code === 'commander.helpDisplayed' ||
|
|
611
|
+
error.code === 'commander.help' ||
|
|
612
|
+
error.code === 'commander.version'
|
|
613
|
+
) {
|
|
614
|
+
process.exit(0);
|
|
615
|
+
}
|
|
616
|
+
if (error.code === 'commander.missingArgument') {
|
|
617
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
618
|
+
} else if (error.code === 'commander.unknownCommand') {
|
|
619
|
+
console.error(chalk.red(`Error: Unknown command`));
|
|
620
|
+
program.outputHelp();
|
|
621
|
+
} else {
|
|
622
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
623
|
+
}
|
|
624
|
+
process.exit(error.exitCode ?? 1);
|
|
625
|
+
}
|
package/cli/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "native-update-cli",
|
|
3
|
+
"private": true,
|
|
4
|
+
"packageManager": "yarn@4.18.1",
|
|
5
|
+
"description": "CLI for Native Update. No version field on purpose: the CLI ships inside the native-update npm package and reads its version from the ROOT package.json (single source of truth) via cli/index.js.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=24.16.0"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"native-update": "./index.js"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"archiver": "^8.0.0",
|
|
15
|
+
"chalk": "^6.0.1",
|
|
16
|
+
"commander": "^15.1.0",
|
|
17
|
+
"express": "^5.3.0",
|
|
18
|
+
"ora": "^10.0.0",
|
|
19
|
+
"prompts": "^2.4.2"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PluginConfig } from '../core/config';
|
|
2
|
+
import { ReviewConditions, ReviewRequestOptions } from './types';
|
|
3
|
+
import { AppReviewPlugin, ReviewResult, CanRequestReviewResult } from '../definitions';
|
|
4
|
+
import { PluginListenerHandle } from '@capacitor/core';
|
|
5
|
+
export declare class AppReviewManager implements AppReviewPlugin {
|
|
6
|
+
private config;
|
|
7
|
+
private logger;
|
|
8
|
+
private conditionsChecker;
|
|
9
|
+
private rateLimiter;
|
|
10
|
+
private platformHandler;
|
|
11
|
+
private listeners;
|
|
12
|
+
constructor(config: PluginConfig);
|
|
13
|
+
requestReview(options?: ReviewRequestOptions): Promise<ReviewResult>;
|
|
14
|
+
canRequestReview(): Promise<CanRequestReviewResult>;
|
|
15
|
+
openStoreReview(): Promise<void>;
|
|
16
|
+
private getStoreReviewUrl;
|
|
17
|
+
resetReviewPrompts(): Promise<void>;
|
|
18
|
+
setReviewConditions(conditions: ReviewConditions): Promise<void>;
|
|
19
|
+
trackSignificantEvent(eventName: string): Promise<void>;
|
|
20
|
+
getReviewMetrics(): Promise<Record<string, unknown>>;
|
|
21
|
+
addListener(eventName: string, listenerFunc: (data: unknown) => void): PluginListenerHandle;
|
|
22
|
+
removeAllListeners(eventName?: string): void;
|
|
23
|
+
private emit;
|
|
24
|
+
}
|