react-native-update-cli 2.10.1 → 2.11.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/README.md +47 -497
- package/README.zh-CN.md +52 -500
- package/cli.json +2 -16
- package/lib/api.js +1 -1
- package/lib/app.d.ts +1 -1
- package/lib/app.js +42 -45
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +70 -0
- package/lib/bundle-runner.d.ts +1 -0
- package/lib/bundle-runner.js +46 -10
- package/lib/exports.d.ts +2 -9
- package/lib/exports.js +0 -31
- package/lib/index.d.ts +1 -5
- package/lib/index.js +12 -128
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/package.d.ts +1 -2
- package/lib/package.js +50 -10
- package/lib/provider.d.ts +1 -4
- package/lib/provider.js +6 -25
- package/lib/types.d.ts +0 -37
- package/lib/user.d.ts +1 -1
- package/lib/user.js +1 -1
- package/lib/utils/app-info-parser/aab.js +46 -5
- package/lib/utils/app-info-parser/resource-finder.js +5 -5
- package/lib/utils/app-info-parser/utils.js +3 -2
- package/lib/utils/check-lockfile.js +1 -1
- package/lib/utils/dep-versions.js +2 -2
- package/lib/utils/http-helper.js +2 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -13
- package/lib/utils/plugin-config.js +42 -6
- package/lib/versions.d.ts +1 -0
- package/lib/versions.js +19 -16
- package/package.json +8 -10
- package/src/api.ts +1 -1
- package/src/app.ts +40 -40
- package/src/bin.ts +86 -0
- package/src/bundle-runner.ts +70 -12
- package/src/exports.ts +1 -12
- package/src/index.ts +1 -159
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/package.ts +6 -10
- package/src/provider.ts +10 -29
- package/src/types.ts +0 -54
- package/src/user.ts +1 -1
- package/src/utils/app-info-parser/aab.ts +2 -2
- package/src/utils/app-info-parser/resource-finder.ts +5 -5
- package/src/utils/app-info-parser/utils.ts +2 -2
- package/src/utils/check-lockfile.ts +1 -1
- package/src/utils/dep-versions.ts +2 -2
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +1 -12
- package/src/utils/plugin-config.ts +1 -1
- package/src/versions.ts +25 -17
- package/lib/module-manager.d.ts +0 -20
- package/lib/module-manager.js +0 -118
- package/lib/modules/app-module.d.ts +0 -2
- package/lib/modules/app-module.js +0 -263
- package/lib/modules/bundle-module.d.ts +0 -2
- package/lib/modules/bundle-module.js +0 -187
- package/lib/modules/index.d.ts +0 -6
- package/lib/modules/index.js +0 -42
- package/lib/modules/package-module.d.ts +0 -2
- package/lib/modules/package-module.js +0 -16
- package/lib/modules/user-module.d.ts +0 -2
- package/lib/modules/user-module.js +0 -413
- package/lib/modules/version-module.d.ts +0 -2
- package/lib/modules/version-module.js +0 -16
- package/lib/workflow-runner.d.ts +0 -2
- package/lib/workflow-runner.js +0 -25
- package/src/module-manager.ts +0 -145
- package/src/modules/app-module.ts +0 -277
- package/src/modules/bundle-module.ts +0 -212
- package/src/modules/index.ts +0 -19
- package/src/modules/package-module.ts +0 -10
- package/src/modules/user-module.ts +0 -465
- package/src/modules/version-module.ts +0 -8
- package/src/workflow-runner.ts +0 -24
package/README.md
CHANGED
|
@@ -1,58 +1,50 @@
|
|
|
1
1
|
# React Native Update CLI
|
|
2
2
|
|
|
3
|
-
[中文文档](./README.zh-CN.md)
|
|
3
|
+
[中文文档](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
A
|
|
5
|
+
A React Native Update command line tool for bundling, uploading native packages, publishing OTA versions, and managing apps/packages.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- **Extensibility**: Users can import and register custom modules
|
|
14
|
-
- **Type Safety**: Complete TypeScript type support
|
|
9
|
+
- Single `pushy` / `cresc` CLI entrypoint
|
|
10
|
+
- Backward-compatible command set
|
|
11
|
+
- Programmatic provider API for build scripts and CI/CD
|
|
12
|
+
- TypeScript type definitions
|
|
15
13
|
|
|
16
|
-
##
|
|
14
|
+
## Installation
|
|
17
15
|
|
|
18
16
|
```bash
|
|
19
17
|
npm install react-native-update-cli
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
### Basic Usage
|
|
20
|
+
## Basic Usage
|
|
25
21
|
|
|
26
22
|
```bash
|
|
27
|
-
# Use unified CLI
|
|
28
23
|
npx pushy help
|
|
29
|
-
|
|
30
|
-
# List all available commands and workflows
|
|
31
24
|
npx pushy list
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
npx pushy
|
|
35
|
-
|
|
36
|
-
# Execute custom workflow
|
|
37
|
-
npx pushy workflow custom-publish
|
|
26
|
+
npx pushy bundle --platform ios
|
|
27
|
+
npx pushy publish --platform ios --name 1.0.0
|
|
28
|
+
npx pushy uploadIpa ./app.ipa
|
|
38
29
|
```
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
## Programmatic Usage
|
|
41
32
|
|
|
42
33
|
```typescript
|
|
43
|
-
import {
|
|
34
|
+
import { CLIProviderImpl } from 'react-native-update-cli';
|
|
44
35
|
|
|
45
|
-
|
|
46
|
-
const provider = moduleManager.getProvider();
|
|
36
|
+
const provider = new CLIProviderImpl();
|
|
47
37
|
|
|
48
|
-
// Execute bundling
|
|
49
38
|
const bundleResult = await provider.bundle({
|
|
50
39
|
platform: 'ios',
|
|
51
40
|
dev: false,
|
|
52
41
|
sourcemap: true,
|
|
53
42
|
});
|
|
54
43
|
|
|
55
|
-
|
|
44
|
+
if (!bundleResult.success) {
|
|
45
|
+
throw new Error(bundleResult.error);
|
|
46
|
+
}
|
|
47
|
+
|
|
56
48
|
const publishResult = await provider.publish({
|
|
57
49
|
name: 'v1.2.3',
|
|
58
50
|
description: 'Bug fixes and improvements',
|
|
@@ -60,141 +52,9 @@ const publishResult = await provider.publish({
|
|
|
60
52
|
});
|
|
61
53
|
```
|
|
62
54
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
### 1. Define Module
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import type {
|
|
69
|
-
CLIModule,
|
|
70
|
-
CommandDefinition,
|
|
71
|
-
CustomWorkflow,
|
|
72
|
-
} from 'react-native-update-cli';
|
|
73
|
-
|
|
74
|
-
export const myCustomModule: CLIModule = {
|
|
75
|
-
name: 'my-custom',
|
|
76
|
-
version: '1.0.0',
|
|
77
|
-
|
|
78
|
-
commands: [
|
|
79
|
-
{
|
|
80
|
-
name: 'custom-command',
|
|
81
|
-
description: 'My custom command',
|
|
82
|
-
handler: async (context) => {
|
|
83
|
-
console.log('Executing custom command...');
|
|
84
|
-
return {
|
|
85
|
-
success: true,
|
|
86
|
-
data: { message: 'Custom command executed' },
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
options: {
|
|
90
|
-
param: { hasValue: true, description: 'Custom parameter' },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
|
|
95
|
-
workflows: [
|
|
96
|
-
{
|
|
97
|
-
name: 'my-workflow',
|
|
98
|
-
description: 'My custom workflow',
|
|
99
|
-
steps: [
|
|
100
|
-
{
|
|
101
|
-
name: 'step1',
|
|
102
|
-
description: 'First step',
|
|
103
|
-
execute: async (context, previousResult) => {
|
|
104
|
-
console.log('Executing step 1...');
|
|
105
|
-
return { step1Completed: true };
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: 'step2',
|
|
110
|
-
description: 'Second step',
|
|
111
|
-
execute: async (context, previousResult) => {
|
|
112
|
-
console.log('Executing step 2...');
|
|
113
|
-
return { ...previousResult, step2Completed: true };
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
|
|
120
|
-
init: (provider) => {
|
|
121
|
-
console.log('Custom module initialized');
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
cleanup: () => {
|
|
125
|
-
console.log('Custom module cleanup');
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### 2. Register Module
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
import { moduleManager } from 'react-native-update-cli';
|
|
134
|
-
import { myCustomModule } from './my-custom-module';
|
|
135
|
-
|
|
136
|
-
// Register custom module
|
|
137
|
-
moduleManager.registerModule(myCustomModule);
|
|
138
|
-
|
|
139
|
-
// Execute custom command
|
|
140
|
-
const result = await moduleManager.executeCommand('custom-command', {
|
|
141
|
-
args: [],
|
|
142
|
-
options: { param: 'value' },
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// Execute custom workflow
|
|
146
|
-
const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
|
|
147
|
-
args: [],
|
|
148
|
-
options: {},
|
|
149
|
-
});
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## 🔄 Workflow System
|
|
153
|
-
|
|
154
|
-
### Workflow Steps
|
|
155
|
-
|
|
156
|
-
Each workflow step contains:
|
|
157
|
-
|
|
158
|
-
- `name`: Step name
|
|
159
|
-
- `description`: Step description
|
|
160
|
-
- `execute`: Execution function
|
|
161
|
-
- `condition`: Optional condition function
|
|
162
|
-
|
|
163
|
-
### Conditional Execution
|
|
164
|
-
|
|
165
|
-
```typescript
|
|
166
|
-
{
|
|
167
|
-
name: 'conditional-step',
|
|
168
|
-
description: 'Only execute in production',
|
|
169
|
-
execute: async (context, previousResult) => {
|
|
170
|
-
// Execution logic
|
|
171
|
-
},
|
|
172
|
-
condition: (context) => {
|
|
173
|
-
return context.options.environment === 'production';
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Workflow Validation
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
{
|
|
182
|
-
name: 'validated-workflow',
|
|
183
|
-
description: 'Workflow with validation',
|
|
184
|
-
steps: [...],
|
|
185
|
-
validate: (context) => {
|
|
186
|
-
if (!context.options.requiredParam) {
|
|
187
|
-
console.error('Required parameter missing');
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
return true;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## 📋 Built-in Modules
|
|
55
|
+
## Built-in Commands
|
|
196
56
|
|
|
197
|
-
### Bundle
|
|
57
|
+
### Bundle
|
|
198
58
|
|
|
199
59
|
- `bundle`: Bundle JavaScript code and optionally publish
|
|
200
60
|
- `hdiff`: Generate hdiff between two PPK files
|
|
@@ -202,137 +62,77 @@ Each workflow step contains:
|
|
|
202
62
|
- `hdiffFromApp`: Generate hdiff from APP files
|
|
203
63
|
- `hdiffFromIpa`: Generate hdiff from IPA files
|
|
204
64
|
|
|
205
|
-
### Version
|
|
65
|
+
### Version
|
|
206
66
|
|
|
207
|
-
- `publish`: Publish new version
|
|
208
|
-
- `versions`: List
|
|
209
|
-
- `update`: Update version
|
|
67
|
+
- `publish`: Publish a new version
|
|
68
|
+
- `versions`: List versions
|
|
69
|
+
- `update`: Update version package rules
|
|
210
70
|
- `updateVersionInfo`: Update version metadata
|
|
71
|
+
- `deleteVersion`: Delete a version
|
|
211
72
|
|
|
212
|
-
### App
|
|
73
|
+
### App
|
|
213
74
|
|
|
214
|
-
- `createApp`: Create
|
|
215
|
-
- `apps`: List
|
|
216
|
-
- `selectApp`: Select
|
|
217
|
-
- `deleteApp`: Delete
|
|
75
|
+
- `createApp`: Create an app
|
|
76
|
+
- `apps`: List apps
|
|
77
|
+
- `selectApp`: Select an app
|
|
78
|
+
- `deleteApp`: Delete an app
|
|
218
79
|
|
|
219
|
-
### Package
|
|
80
|
+
### Package
|
|
220
81
|
|
|
221
|
-
- `uploadIpa`: Upload IPA files
|
|
222
|
-
- `uploadApk`: Upload APK files
|
|
223
|
-
- `uploadAab`: Upload AAB files
|
|
224
|
-
- `uploadApp`: Upload APP files
|
|
82
|
+
- `uploadIpa`: Upload IPA files
|
|
83
|
+
- `uploadApk`: Upload APK files
|
|
84
|
+
- `uploadAab`: Upload AAB files
|
|
85
|
+
- `uploadApp`: Upload APP files
|
|
225
86
|
- `parseApp`: Parse APP file information
|
|
226
87
|
- `parseIpa`: Parse IPA file information
|
|
227
88
|
- `parseApk`: Parse APK file information
|
|
228
|
-
- `
|
|
89
|
+
- `parseAab`: Parse AAB file information
|
|
90
|
+
- `extractApk`: Extract a universal APK from an AAB
|
|
229
91
|
- `packages`: List packages
|
|
92
|
+
- `deletePackage`: Delete a package
|
|
230
93
|
|
|
231
|
-
### User
|
|
94
|
+
### User
|
|
232
95
|
|
|
233
96
|
- `login`: Login
|
|
234
97
|
- `logout`: Logout
|
|
235
|
-
- `me`: Show user information
|
|
98
|
+
- `me`: Show current user information
|
|
236
99
|
|
|
237
|
-
##
|
|
238
|
-
|
|
239
|
-
### Core Functionality
|
|
100
|
+
## Provider API
|
|
240
101
|
|
|
241
102
|
```typescript
|
|
242
103
|
interface CLIProvider {
|
|
243
|
-
// Bundle
|
|
244
104
|
bundle(options: BundleOptions): Promise<CommandResult>;
|
|
245
|
-
|
|
246
|
-
// Publish
|
|
247
105
|
publish(options: PublishOptions): Promise<CommandResult>;
|
|
248
|
-
|
|
249
|
-
// Upload
|
|
250
106
|
upload(options: UploadOptions): Promise<CommandResult>;
|
|
251
107
|
|
|
252
|
-
// Application management
|
|
253
108
|
getSelectedApp(
|
|
254
109
|
platform?: Platform,
|
|
255
110
|
): Promise<{ appId: string; platform: Platform }>;
|
|
256
111
|
listApps(platform?: Platform): Promise<CommandResult>;
|
|
257
112
|
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
|
258
113
|
|
|
259
|
-
// Version management
|
|
260
114
|
listVersions(appId: string): Promise<CommandResult>;
|
|
261
|
-
getVersion(appId: string, versionId: string): Promise<CommandResult>;
|
|
262
115
|
updateVersion(
|
|
263
116
|
appId: string,
|
|
264
117
|
versionId: string,
|
|
265
118
|
updates: Partial<Version>,
|
|
266
119
|
): Promise<CommandResult>;
|
|
267
120
|
|
|
268
|
-
// Package management
|
|
269
|
-
listPackages(appId: string, platform?: Platform): Promise<CommandResult>;
|
|
270
|
-
getPackage(appId: string, packageId: string): Promise<CommandResult>;
|
|
271
|
-
|
|
272
|
-
// Utility functions
|
|
273
121
|
getPlatform(platform?: Platform): Promise<Platform>;
|
|
274
122
|
loadSession(): Promise<Session>;
|
|
275
|
-
saveToLocal(key: string, value: string): void;
|
|
276
|
-
question(prompt: string): Promise<string>;
|
|
277
|
-
|
|
278
|
-
// Workflows
|
|
279
|
-
registerWorkflow(workflow: CustomWorkflow): void;
|
|
280
|
-
executeWorkflow(
|
|
281
|
-
workflowName: string,
|
|
282
|
-
context: CommandContext,
|
|
283
|
-
): Promise<CommandResult>;
|
|
284
123
|
}
|
|
285
124
|
```
|
|
286
125
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
```typescript
|
|
290
|
-
// Execute custom bundle command
|
|
291
|
-
const bundleResult = await moduleManager.executeCommand('custom-bundle', {
|
|
292
|
-
args: [],
|
|
293
|
-
options: {
|
|
294
|
-
platform: 'android',
|
|
295
|
-
validate: true,
|
|
296
|
-
optimize: true,
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
// Generate hdiff file
|
|
301
|
-
const diffResult = await moduleManager.executeCommand('hdiff', {
|
|
302
|
-
args: [],
|
|
303
|
-
options: {
|
|
304
|
-
origin: './build/v1.0.0.ppk',
|
|
305
|
-
next: './build/v1.1.0.ppk',
|
|
306
|
-
output: './build/hdiff.patch',
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
// Generate hdiff from APK files
|
|
311
|
-
const apkDiffResult = await moduleManager.executeCommand('hdiffFromApk', {
|
|
312
|
-
args: [],
|
|
313
|
-
options: {
|
|
314
|
-
origin: './build/app-v1.0.0.apk',
|
|
315
|
-
next: './build/app-v1.1.0.apk',
|
|
316
|
-
output: './build/apk-hdiff.patch',
|
|
317
|
-
},
|
|
318
|
-
});
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
## 🔧 Configuration
|
|
322
|
-
|
|
323
|
-
### Environment Variables
|
|
126
|
+
## Environment Variables
|
|
324
127
|
|
|
325
128
|
```bash
|
|
326
|
-
# Set API endpoint
|
|
327
129
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
328
|
-
|
|
329
|
-
# Set non-interactive mode
|
|
330
130
|
export NO_INTERACTIVE=true
|
|
331
131
|
```
|
|
332
132
|
|
|
333
|
-
|
|
133
|
+
## Configuration
|
|
334
134
|
|
|
335
|
-
Create `update.json`
|
|
135
|
+
Create `update.json` in your React Native project:
|
|
336
136
|
|
|
337
137
|
```json
|
|
338
138
|
{
|
|
@@ -347,256 +147,6 @@ Create `update.json` file:
|
|
|
347
147
|
}
|
|
348
148
|
```
|
|
349
149
|
|
|
350
|
-
##
|
|
351
|
-
|
|
352
|
-
1. **Backward Compatibility**: The new modular CLI maintains compatibility with existing CLI
|
|
353
|
-
2. **Type Safety**: All APIs have complete TypeScript type definitions
|
|
354
|
-
3. **Error Handling**: All operations return standardized result formats
|
|
355
|
-
4. **Resource Cleanup**: Modules support cleanup functions to release resources
|
|
356
|
-
5. **Module Separation**: Functionality is logically separated into different modules for easy maintenance and extension
|
|
357
|
-
|
|
358
|
-
## 🤝 Contributing
|
|
359
|
-
|
|
360
|
-
Welcome to submit Issues and Pull Requests to improve this project!
|
|
361
|
-
|
|
362
|
-
## 🚀 Provider API Usage Guide
|
|
363
|
-
|
|
364
|
-
Provider provides a concise programming interface suitable for integrating React Native Update CLI functionality in applications.
|
|
365
|
-
|
|
366
|
-
### 📋 Core API Methods
|
|
367
|
-
|
|
368
|
-
#### Core Business Functions
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
// Bundle application
|
|
372
|
-
await provider.bundle({
|
|
373
|
-
platform: 'ios',
|
|
374
|
-
dev: false,
|
|
375
|
-
sourcemap: true,
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
// Publish version
|
|
379
|
-
await provider.publish({
|
|
380
|
-
name: 'v1.0.0',
|
|
381
|
-
description: 'Bug fixes',
|
|
382
|
-
rollout: 100,
|
|
383
|
-
});
|
|
150
|
+
## Notes
|
|
384
151
|
|
|
385
|
-
|
|
386
|
-
await provider.upload({
|
|
387
|
-
filePath: 'app.ipa',
|
|
388
|
-
platform: 'ios',
|
|
389
|
-
});
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
#### Application Management
|
|
393
|
-
|
|
394
|
-
```typescript
|
|
395
|
-
// Create application
|
|
396
|
-
await provider.createApp('MyApp', 'ios');
|
|
397
|
-
|
|
398
|
-
// List applications
|
|
399
|
-
await provider.listApps('ios');
|
|
400
|
-
|
|
401
|
-
// Get current application
|
|
402
|
-
const { appId, platform } = await provider.getSelectedApp('ios');
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
#### Version Management
|
|
406
|
-
|
|
407
|
-
```typescript
|
|
408
|
-
// List versions
|
|
409
|
-
await provider.listVersions('app123');
|
|
410
|
-
|
|
411
|
-
// Update version
|
|
412
|
-
await provider.updateVersion('app123', 'version456', {
|
|
413
|
-
name: 'v1.1.0',
|
|
414
|
-
description: 'New features',
|
|
415
|
-
});
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
#### Utility Functions
|
|
419
|
-
|
|
420
|
-
```typescript
|
|
421
|
-
// Get platform
|
|
422
|
-
const platform = await provider.getPlatform('ios');
|
|
423
|
-
|
|
424
|
-
// Load session
|
|
425
|
-
const session = await provider.loadSession();
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
### 🎯 Use Cases
|
|
429
|
-
|
|
430
|
-
#### 1. Automated Build Scripts
|
|
431
|
-
|
|
432
|
-
```typescript
|
|
433
|
-
import { moduleManager } from 'react-native-update-cli';
|
|
434
|
-
|
|
435
|
-
async function buildAndPublish() {
|
|
436
|
-
const provider = moduleManager.getProvider();
|
|
437
|
-
|
|
438
|
-
// 1. Bundle
|
|
439
|
-
const bundleResult = await provider.bundle({
|
|
440
|
-
platform: 'ios',
|
|
441
|
-
dev: false,
|
|
442
|
-
sourcemap: true,
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
if (!bundleResult.success) {
|
|
446
|
-
throw new Error(`Bundle failed: ${bundleResult.error}`);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// 2. Publish
|
|
450
|
-
const publishResult = await provider.publish({
|
|
451
|
-
name: 'v1.2.3',
|
|
452
|
-
description: 'Bug fixes and performance improvements',
|
|
453
|
-
rollout: 100,
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
if (!publishResult.success) {
|
|
457
|
-
throw new Error(`Publish failed: ${publishResult.error}`);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
console.log('Build and publish completed!');
|
|
461
|
-
}
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
#### 2. CI/CD Integration
|
|
465
|
-
|
|
466
|
-
```typescript
|
|
467
|
-
async function ciBuild() {
|
|
468
|
-
const provider = moduleManager.getProvider();
|
|
469
|
-
|
|
470
|
-
const result = await provider.bundle({
|
|
471
|
-
platform: process.env.PLATFORM as 'ios' | 'android',
|
|
472
|
-
dev: process.env.NODE_ENV !== 'production',
|
|
473
|
-
sourcemap: process.env.NODE_ENV === 'production',
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
return result;
|
|
477
|
-
}
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
#### 3. Application Management Service
|
|
481
|
-
|
|
482
|
-
```typescript
|
|
483
|
-
class AppManagementService {
|
|
484
|
-
private provider = moduleManager.getProvider();
|
|
485
|
-
|
|
486
|
-
async setupNewApp(name: string, platform: Platform) {
|
|
487
|
-
// Create application
|
|
488
|
-
const createResult = await this.provider.createApp(name, platform);
|
|
489
|
-
|
|
490
|
-
if (createResult.success) {
|
|
491
|
-
// Get application information
|
|
492
|
-
const { appId } = await this.provider.getSelectedApp(platform);
|
|
493
|
-
|
|
494
|
-
// List versions
|
|
495
|
-
await this.provider.listVersions(appId);
|
|
496
|
-
|
|
497
|
-
return { appId, success: true };
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
return { success: false, error: createResult.error };
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
### ⚠️ Important Notes
|
|
506
|
-
|
|
507
|
-
1. **Error Handling**: All Provider methods return `CommandResult`, need to check the `success` field
|
|
508
|
-
2. **Type Safety**: Provider provides complete TypeScript type support
|
|
509
|
-
3. **Session Management**: Ensure login before use, can check via `loadSession()`
|
|
510
|
-
4. **Platform Support**: Supports `'ios' | 'android' | 'harmony'` three platforms
|
|
511
|
-
|
|
512
|
-
### 🔧 Advanced Features
|
|
513
|
-
|
|
514
|
-
#### Custom Workflows
|
|
515
|
-
|
|
516
|
-
```typescript
|
|
517
|
-
// Register custom workflow
|
|
518
|
-
provider.registerWorkflow({
|
|
519
|
-
name: 'quick-release',
|
|
520
|
-
description: 'Quick release process',
|
|
521
|
-
steps: [
|
|
522
|
-
{
|
|
523
|
-
name: 'bundle',
|
|
524
|
-
execute: async () => {
|
|
525
|
-
return await provider.bundle({ platform: 'ios', dev: false });
|
|
526
|
-
},
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
name: 'publish',
|
|
530
|
-
execute: async (context, bundleResult) => {
|
|
531
|
-
if (!bundleResult.success) {
|
|
532
|
-
throw new Error('Bundle failed, cannot publish');
|
|
533
|
-
}
|
|
534
|
-
return await provider.publish({ name: 'auto-release', rollout: 50 });
|
|
535
|
-
},
|
|
536
|
-
},
|
|
537
|
-
],
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
// Execute workflow
|
|
541
|
-
await provider.executeWorkflow('quick-release', { args: [], options: {} });
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
### 📚 Complete Example
|
|
545
|
-
|
|
546
|
-
```typescript
|
|
547
|
-
import { moduleManager } from 'react-native-update-cli';
|
|
548
|
-
|
|
549
|
-
class ReactNativeUpdateService {
|
|
550
|
-
private provider = moduleManager.getProvider();
|
|
551
|
-
|
|
552
|
-
async initialize() {
|
|
553
|
-
// Load session
|
|
554
|
-
await this.provider.loadSession();
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
async buildAndDeploy(platform: Platform, version: string) {
|
|
558
|
-
try {
|
|
559
|
-
// 1. Bundle
|
|
560
|
-
const bundleResult = await this.provider.bundle({
|
|
561
|
-
platform,
|
|
562
|
-
dev: false,
|
|
563
|
-
sourcemap: true,
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
if (!bundleResult.success) {
|
|
567
|
-
throw new Error(`Bundle failed: ${bundleResult.error}`);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// 2. Publish
|
|
571
|
-
const publishResult = await this.provider.publish({
|
|
572
|
-
name: version,
|
|
573
|
-
description: `Release ${version}`,
|
|
574
|
-
rollout: 100,
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
if (!publishResult.success) {
|
|
578
|
-
throw new Error(`Publish failed: ${publishResult.error}`);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return { success: true, data: publishResult.data };
|
|
582
|
-
} catch (error) {
|
|
583
|
-
return {
|
|
584
|
-
success: false,
|
|
585
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
async getAppInfo(platform: Platform) {
|
|
591
|
-
const { appId } = await this.provider.getSelectedApp(platform);
|
|
592
|
-
const versions = await this.provider.listVersions(appId);
|
|
593
|
-
|
|
594
|
-
return { appId, versions };
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// Usage example
|
|
599
|
-
const service = new ReactNativeUpdateService();
|
|
600
|
-
await service.initialize();
|
|
601
|
-
await service.buildAndDeploy('ios', 'v1.0.0');
|
|
602
|
-
```
|
|
152
|
+
All provider methods return `CommandResult`; check `success` before consuming `data`. The CLI supports `ios`, `android`, and `harmony` platforms.
|