react-native-update-cli 2.8.4 → 2.9.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.
Files changed (112) hide show
  1. package/lib/api.d.ts +18 -0
  2. package/lib/app.d.ts +38 -0
  3. package/lib/app.js +5 -4
  4. package/lib/bundle-pack.d.ts +1 -0
  5. package/lib/bundle-pack.js +104 -0
  6. package/lib/bundle-runner.d.ts +20 -0
  7. package/lib/bundle-runner.js +404 -0
  8. package/lib/bundle.d.ts +6 -0
  9. package/lib/bundle.js +73 -471
  10. package/lib/diff.d.ts +13 -0
  11. package/lib/diff.js +144 -123
  12. package/lib/exports.d.ts +12 -0
  13. package/lib/index.d.ts +5 -0
  14. package/lib/index.js +5 -13
  15. package/lib/install.d.ts +4 -0
  16. package/lib/locales/en.d.ts +137 -0
  17. package/lib/locales/en.js +11 -0
  18. package/lib/locales/zh.d.ts +136 -0
  19. package/lib/locales/zh.js +11 -0
  20. package/lib/module-manager.d.ts +20 -0
  21. package/lib/module-manager.js +3 -9
  22. package/lib/modules/app-module.d.ts +2 -0
  23. package/lib/modules/app-module.js +84 -44
  24. package/lib/modules/bundle-module.d.ts +2 -0
  25. package/lib/modules/bundle-module.js +7 -8
  26. package/lib/modules/index.d.ts +6 -0
  27. package/lib/modules/package-module.d.ts +2 -0
  28. package/lib/modules/user-module.d.ts +2 -0
  29. package/lib/modules/user-module.js +55 -44
  30. package/lib/modules/version-module.d.ts +2 -0
  31. package/lib/package.d.ts +58 -0
  32. package/lib/package.js +103 -139
  33. package/lib/provider.d.ts +26 -0
  34. package/lib/provider.js +115 -217
  35. package/lib/types.d.ts +120 -0
  36. package/lib/user.d.ts +8 -0
  37. package/lib/utils/add-gitignore.d.ts +1 -0
  38. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  39. package/lib/utils/app-info-parser/aab.js +0 -4
  40. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  41. package/lib/utils/app-info-parser/apk.js +6 -4
  42. package/lib/utils/app-info-parser/app.d.ts +4 -0
  43. package/lib/utils/app-info-parser/app.js +3 -0
  44. package/lib/utils/app-info-parser/index.d.ts +16 -0
  45. package/lib/utils/app-info-parser/index.js +2 -0
  46. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  47. package/lib/utils/app-info-parser/ipa.js +1 -1
  48. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  49. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  50. package/lib/utils/app-info-parser/utils.js +1 -0
  51. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  52. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  53. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  54. package/lib/utils/app-info-parser/zip.js +7 -9
  55. package/lib/utils/check-lockfile.d.ts +1 -0
  56. package/lib/utils/check-plugin.d.ts +7 -0
  57. package/lib/utils/command-result.d.ts +3 -0
  58. package/lib/utils/command-result.js +35 -0
  59. package/lib/utils/constants.d.ts +9 -0
  60. package/lib/utils/dep-versions.d.ts +1 -0
  61. package/lib/utils/git.d.ts +8 -0
  62. package/lib/utils/http-helper.d.ts +4 -0
  63. package/lib/utils/i18n.d.ts +12 -0
  64. package/lib/utils/index.d.ts +22 -0
  65. package/lib/utils/index.js +52 -22
  66. package/lib/utils/latest-version/cli.d.ts +1 -0
  67. package/lib/utils/latest-version/cli.js +24 -60
  68. package/lib/utils/latest-version/index.d.ts +146 -0
  69. package/lib/utils/latest-version/index.js +22 -22
  70. package/lib/utils/options.d.ts +4 -0
  71. package/lib/utils/options.js +63 -0
  72. package/lib/utils/plugin-config.d.ts +9 -0
  73. package/lib/utils/zip-entries.d.ts +3 -0
  74. package/lib/versions.d.ts +43 -0
  75. package/lib/versions.js +186 -2
  76. package/lib/workflow-runner.d.ts +2 -0
  77. package/lib/workflow-runner.js +25 -0
  78. package/package.json +20 -5
  79. package/src/api.ts +1 -1
  80. package/src/app.ts +20 -11
  81. package/src/bundle-pack.ts +51 -0
  82. package/src/bundle-runner.ts +463 -0
  83. package/src/bundle.ts +184 -571
  84. package/src/diff.ts +208 -174
  85. package/src/index.ts +15 -17
  86. package/src/locales/en.ts +15 -0
  87. package/src/locales/zh.ts +13 -0
  88. package/src/module-manager.ts +15 -15
  89. package/src/modules/app-module.ts +120 -48
  90. package/src/modules/bundle-module.ts +21 -11
  91. package/src/modules/package-module.ts +0 -1
  92. package/src/modules/user-module.ts +117 -58
  93. package/src/package.ts +158 -138
  94. package/src/provider.ts +164 -240
  95. package/src/types.ts +15 -8
  96. package/src/utils/app-info-parser/aab.ts +0 -7
  97. package/src/utils/app-info-parser/apk.ts +9 -6
  98. package/src/utils/app-info-parser/app.ts +5 -1
  99. package/src/utils/app-info-parser/index.ts +11 -6
  100. package/src/utils/app-info-parser/ipa.ts +1 -1
  101. package/src/utils/app-info-parser/utils.ts +3 -0
  102. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  103. package/src/utils/app-info-parser/zip.ts +12 -14
  104. package/src/utils/command-result.ts +24 -0
  105. package/src/utils/index.ts +138 -39
  106. package/src/utils/latest-version/cli.ts +22 -20
  107. package/src/utils/latest-version/index.ts +20 -20
  108. package/src/utils/options.ts +56 -0
  109. package/src/utils/zip-entries.ts +1 -1
  110. package/src/versions.ts +265 -2
  111. package/src/workflow-runner.ts +24 -0
  112. package/index.js +0 -1
@@ -0,0 +1,26 @@
1
+ import type { BundleOptions, CLIProvider, CommandContext, CommandResult, CustomWorkflow, Platform, PublishOptions, Session, UploadOptions, Version } from './types';
2
+ export declare class CLIProviderImpl implements CLIProvider {
3
+ private workflows;
4
+ private session?;
5
+ private sessionInitPromise?;
6
+ private createContext;
7
+ private ensureInitialized;
8
+ private runMessageCommand;
9
+ private runDataCommand;
10
+ bundle(options: BundleOptions): Promise<CommandResult>;
11
+ publish(options: PublishOptions): Promise<CommandResult>;
12
+ upload(options: UploadOptions): Promise<CommandResult>;
13
+ getSelectedApp(platform?: Platform): Promise<{
14
+ appId: string;
15
+ platform: Platform;
16
+ }>;
17
+ listApps(platform?: Platform): Promise<CommandResult>;
18
+ createApp(name: string, platform: Platform): Promise<CommandResult>;
19
+ listVersions(appId: string): Promise<CommandResult>;
20
+ updateVersion(appId: string, versionId: string, updates: Partial<Version>): Promise<CommandResult>;
21
+ getPlatform(platform?: Platform): Promise<Platform>;
22
+ loadSession(): Promise<Session>;
23
+ registerWorkflow(workflow: CustomWorkflow): void;
24
+ executeWorkflow(workflowName: string, context: CommandContext): Promise<CommandResult>;
25
+ listPackages(appId?: string): Promise<CommandResult>;
26
+ }
package/lib/provider.js CHANGED
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "CLIProviderImpl", {
10
10
  });
11
11
  const _api = require("./api");
12
12
  const _app = require("./app");
13
+ const _commandresult = require("./utils/command-result");
14
+ const _workflowrunner = require("./workflow-runner");
13
15
  function _getRequireWildcardCache(nodeInterop) {
14
16
  if (typeof WeakMap !== "function") return null;
15
17
  var cacheBabelInterop = new WeakMap();
@@ -52,129 +54,114 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
54
  return newObj;
53
55
  }
54
56
  class CLIProviderImpl {
55
- async init() {
56
- try {
57
- await (0, _api.loadSession)();
58
- this.session = (0, _api.getSession)();
59
- } catch (error) {}
57
+ createContext(options, args = []) {
58
+ return {
59
+ args,
60
+ options
61
+ };
62
+ }
63
+ async ensureInitialized() {
64
+ if (this.session) {
65
+ return;
66
+ }
67
+ if (!this.sessionInitPromise) {
68
+ this.sessionInitPromise = (async ()=>{
69
+ await (0, _api.loadSession)();
70
+ this.session = (0, _api.getSession)();
71
+ })().finally(()=>{
72
+ this.sessionInitPromise = undefined;
73
+ });
74
+ }
75
+ await this.sessionInitPromise;
76
+ }
77
+ runMessageCommand(task, fallbackError, successMessage, requireSession = true) {
78
+ return (0, _commandresult.runAsCommandResult)(async ()=>{
79
+ if (requireSession) {
80
+ await this.ensureInitialized();
81
+ }
82
+ await task();
83
+ }, fallbackError, ()=>({
84
+ message: successMessage
85
+ }));
86
+ }
87
+ runDataCommand(task, fallbackError, requireSession = true) {
88
+ return (0, _commandresult.runAsCommandResult)(async ()=>{
89
+ if (requireSession) {
90
+ await this.ensureInitialized();
91
+ }
92
+ return task();
93
+ }, fallbackError);
60
94
  }
61
95
  async bundle(options) {
62
- try {
63
- const context = {
64
- args: [],
65
- options: {
66
- dev: options.dev || false,
67
- platform: options.platform,
68
- bundleName: options.bundleName || 'index.bundlejs',
69
- entryFile: options.entryFile || 'index.js',
70
- output: options.output || '${tempDir}/output/${platform}.${time}.ppk',
71
- sourcemap: options.sourcemap || false,
72
- taro: options.taro || false,
73
- expo: options.expo || false,
74
- rncli: options.rncli || false,
75
- hermes: options.hermes || false
76
- }
77
- };
96
+ return this.runMessageCommand(async ()=>{
97
+ const context = this.createContext({
98
+ dev: options.dev || false,
99
+ platform: options.platform,
100
+ bundleName: options.bundleName || 'index.bundlejs',
101
+ entryFile: options.entryFile || 'index.js',
102
+ output: options.output || '${tempDir}/output/${platform}.${time}.ppk',
103
+ sourcemap: options.sourcemap || false,
104
+ taro: options.taro || false,
105
+ expo: options.expo || false,
106
+ rncli: options.rncli || false,
107
+ hermes: options.hermes || false
108
+ });
78
109
  const { bundleCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bundle")));
79
110
  await bundleCommands.bundle(context);
80
- return {
81
- success: true,
82
- data: {
83
- message: 'Bundle created successfully'
84
- }
85
- };
86
- } catch (error) {
87
- return {
88
- success: false,
89
- error: error instanceof Error ? error.message : 'Unknown error during bundling'
90
- };
91
- }
111
+ }, 'Unknown error during bundling', 'Bundle created successfully', false);
92
112
  }
93
113
  async publish(options) {
94
- try {
95
- const context = {
96
- args: [],
97
- options: {
98
- name: options.name,
99
- description: options.description,
100
- metaInfo: options.metaInfo,
101
- packageId: options.packageId,
102
- packageVersion: options.packageVersion,
103
- minPackageVersion: options.minPackageVersion,
104
- maxPackageVersion: options.maxPackageVersion,
105
- packageVersionRange: options.packageVersionRange,
106
- rollout: options.rollout,
107
- dryRun: options.dryRun || false
108
- }
109
- };
114
+ return this.runMessageCommand(async ()=>{
115
+ const context = this.createContext({
116
+ name: options.name,
117
+ description: options.description,
118
+ metaInfo: options.metaInfo,
119
+ packageId: options.packageId,
120
+ packageVersion: options.packageVersion,
121
+ minPackageVersion: options.minPackageVersion,
122
+ maxPackageVersion: options.maxPackageVersion,
123
+ packageVersionRange: options.packageVersionRange,
124
+ rollout: options.rollout,
125
+ dryRun: options.dryRun || false
126
+ });
110
127
  const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
111
128
  await versionCommands.publish(context);
112
- return {
113
- success: true,
114
- data: {
115
- message: 'Version published successfully'
116
- }
117
- };
118
- } catch (error) {
119
- return {
120
- success: false,
121
- error: error instanceof Error ? error.message : 'Unknown error during publishing'
122
- };
123
- }
129
+ }, 'Unknown error during publishing', 'Version published successfully');
124
130
  }
125
131
  async upload(options) {
126
- try {
132
+ return this.runMessageCommand(async ()=>{
127
133
  var _filePath_split_pop;
128
134
  const platform = await this.getPlatform(options.platform);
129
135
  const { appId } = await this.getSelectedApp(platform);
130
136
  const filePath = options.filePath;
131
137
  const fileType = (_filePath_split_pop = filePath.split('.').pop()) == null ? void 0 : _filePath_split_pop.toLowerCase();
132
- const context = {
133
- args: [
134
- filePath
135
- ],
136
- options: {
137
- platform,
138
- appId,
139
- version: options.version
140
- }
141
- };
138
+ const context = this.createContext({
139
+ platform,
140
+ appId,
141
+ version: options.version
142
+ }, [
143
+ filePath
144
+ ]);
142
145
  const { packageCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
143
- switch(fileType){
144
- case 'ipa':
145
- await packageCommands.uploadIpa(context);
146
- break;
147
- case 'apk':
148
- await packageCommands.uploadApk(context);
149
- break;
150
- case 'aab':
151
- await packageCommands.uploadAab(context);
152
- break;
153
- case 'app':
154
- await packageCommands.uploadApp(context);
155
- break;
156
- default:
157
- throw new Error(`Unsupported file type: ${fileType}`);
146
+ const uploadHandlerMap = {
147
+ ipa: packageCommands.uploadIpa,
148
+ apk: packageCommands.uploadApk,
149
+ aab: packageCommands.uploadAab,
150
+ app: packageCommands.uploadApp
151
+ };
152
+ const uploadHandler = fileType && fileType in uploadHandlerMap ? uploadHandlerMap[fileType] : undefined;
153
+ if (!uploadHandler) {
154
+ throw new Error(`Unsupported file type: ${fileType}`);
158
155
  }
159
- return {
160
- success: true,
161
- data: {
162
- message: 'File uploaded successfully'
163
- }
164
- };
165
- } catch (error) {
166
- return {
167
- success: false,
168
- error: error instanceof Error ? error.message : 'Unknown error during upload'
169
- };
170
- }
156
+ await uploadHandler(context);
157
+ }, 'Unknown error during upload', 'File uploaded successfully');
171
158
  }
172
159
  async getSelectedApp(platform) {
173
160
  const resolvedPlatform = await this.getPlatform(platform);
174
161
  return (0, _app.getSelectedApp)(resolvedPlatform);
175
162
  }
176
163
  async listApps(platform) {
177
- try {
164
+ return this.runMessageCommand(async ()=>{
178
165
  const resolvedPlatform = await this.getPlatform(platform);
179
166
  const { appCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
180
167
  await appCommands.apps({
@@ -182,21 +169,10 @@ class CLIProviderImpl {
182
169
  platform: resolvedPlatform
183
170
  }
184
171
  });
185
- return {
186
- success: true,
187
- data: {
188
- message: 'Apps listed successfully'
189
- }
190
- };
191
- } catch (error) {
192
- return {
193
- success: false,
194
- error: error instanceof Error ? error.message : 'Unknown error listing apps'
195
- };
196
- }
172
+ }, 'Unknown error listing apps', 'Apps listed successfully');
197
173
  }
198
174
  async createApp(name, platform) {
199
- try {
175
+ return this.runMessageCommand(async ()=>{
200
176
  const { appCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
201
177
  await appCommands.createApp({
202
178
  options: {
@@ -205,74 +181,34 @@ class CLIProviderImpl {
205
181
  downloadUrl: ''
206
182
  }
207
183
  });
208
- return {
209
- success: true,
210
- data: {
211
- message: 'App created successfully'
212
- }
213
- };
214
- } catch (error) {
215
- return {
216
- success: false,
217
- error: error instanceof Error ? error.message : 'Unknown error creating app'
218
- };
219
- }
184
+ }, 'Unknown error creating app', 'App created successfully');
220
185
  }
221
186
  async listVersions(appId) {
222
- try {
223
- const context = {
224
- args: [],
225
- options: {
226
- appId
227
- }
228
- };
187
+ return this.runMessageCommand(async ()=>{
188
+ const context = this.createContext({
189
+ appId
190
+ });
229
191
  const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
230
192
  await versionCommands.versions(context);
231
- return {
232
- success: true,
233
- data: {
234
- message: 'Versions listed successfully'
235
- }
236
- };
237
- } catch (error) {
238
- return {
239
- success: false,
240
- error: error instanceof Error ? error.message : 'Unknown error listing versions'
241
- };
242
- }
193
+ }, 'Unknown error listing versions', 'Versions listed successfully');
243
194
  }
244
195
  async updateVersion(appId, versionId, updates) {
245
- try {
246
- const context = {
247
- args: [
248
- versionId
249
- ],
250
- options: {
251
- appId,
252
- ...updates
253
- }
254
- };
196
+ return this.runMessageCommand(async ()=>{
197
+ const context = this.createContext({
198
+ appId,
199
+ ...updates
200
+ }, [
201
+ versionId
202
+ ]);
255
203
  const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
256
204
  await versionCommands.update(context);
257
- return {
258
- success: true,
259
- data: {
260
- message: 'Version updated successfully'
261
- }
262
- };
263
- } catch (error) {
264
- return {
265
- success: false,
266
- error: error instanceof Error ? error.message : 'Unknown error updating version'
267
- };
268
- }
205
+ }, 'Unknown error updating version', 'Version updated successfully');
269
206
  }
270
207
  async getPlatform(platform) {
271
208
  return (0, _app.getPlatform)(platform);
272
209
  }
273
210
  async loadSession() {
274
- await (0, _api.loadSession)();
275
- this.session = (0, _api.getSession)();
211
+ await this.ensureInitialized();
276
212
  if (!this.session) {
277
213
  throw new Error('Failed to load session');
278
214
  }
@@ -282,63 +218,25 @@ class CLIProviderImpl {
282
218
  this.workflows.set(workflow.name, workflow);
283
219
  }
284
220
  async executeWorkflow(workflowName, context) {
285
- const workflow = this.workflows.get(workflowName);
286
- if (!workflow) {
287
- return {
288
- success: false,
289
- error: `Workflow '${workflowName}' not found`
290
- };
291
- }
292
- try {
293
- let previousResult = null;
294
- for (const step of workflow.steps){
295
- if (step.condition && !step.condition(context)) {
296
- console.log(`Skipping step '${step.name}' due to condition`);
297
- continue;
298
- }
299
- console.log(`Executing step '${step.name}'`);
300
- previousResult = await step.execute(context, previousResult);
221
+ return this.runDataCommand(async ()=>{
222
+ const workflow = this.workflows.get(workflowName);
223
+ if (!workflow) {
224
+ throw new Error(`Workflow '${workflowName}' not found`);
301
225
  }
226
+ const result = await (0, _workflowrunner.runWorkflow)(workflowName, workflow, context);
302
227
  return {
303
- success: true,
304
- data: {
305
- message: `Workflow '${workflowName}' completed successfully`,
306
- result: previousResult
307
- }
228
+ message: `Workflow '${workflowName}' completed successfully`,
229
+ result
308
230
  };
309
- } catch (error) {
310
- return {
311
- success: false,
312
- error: error instanceof Error ? error.message : `Workflow '${workflowName}' failed`
313
- };
314
- }
315
- }
316
- getRegisteredWorkflows() {
317
- return Array.from(this.workflows.keys());
231
+ }, `Workflow '${workflowName}' failed`);
318
232
  }
319
233
  async listPackages(appId) {
320
- try {
321
- const context = {
322
- args: [],
323
- options: appId ? {
324
- appId
325
- } : {}
326
- };
234
+ return this.runDataCommand(async ()=>{
327
235
  const { listPackage } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
328
- const result = await listPackage(appId || '');
329
- return {
330
- success: true,
331
- data: result
332
- };
333
- } catch (error) {
334
- return {
335
- success: false,
336
- error: error instanceof Error ? error.message : 'Unknown error listing packages'
337
- };
338
- }
236
+ return listPackage(appId || '');
237
+ }, 'Unknown error listing packages');
339
238
  }
340
239
  constructor(){
341
240
  this.workflows = new Map();
342
- this.init();
343
241
  }
344
242
  }
package/lib/types.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ declare global {
2
+ var NO_INTERACTIVE: boolean;
3
+ var USE_ACC_OSS: boolean;
4
+ }
5
+ export interface Session {
6
+ token: string;
7
+ }
8
+ export type Platform = 'ios' | 'android' | 'harmony';
9
+ export interface Package {
10
+ id: string;
11
+ name: string;
12
+ version?: string;
13
+ status?: string;
14
+ appId?: string;
15
+ appKey?: string;
16
+ versionName?: string | number | null;
17
+ buildTime?: string | number | null;
18
+ deps?: Record<string, string> | string | null;
19
+ }
20
+ export interface Version {
21
+ id: string;
22
+ hash: string;
23
+ name: string;
24
+ packages?: Package[];
25
+ deps?: Record<string, string> | string | null;
26
+ }
27
+ export interface CommandContext<TOptions extends Record<string, unknown> = Record<string, unknown>> {
28
+ args: string[];
29
+ options: TOptions;
30
+ platform?: Platform;
31
+ appId?: string;
32
+ session?: Session;
33
+ }
34
+ export interface CommandResult {
35
+ success: boolean;
36
+ data?: unknown;
37
+ error?: string;
38
+ }
39
+ export interface CommandDefinition {
40
+ name: string;
41
+ description?: string;
42
+ handler: (context: CommandContext) => Promise<CommandResult>;
43
+ options?: Record<string, {
44
+ hasValue?: boolean;
45
+ default?: unknown;
46
+ description?: string;
47
+ }>;
48
+ }
49
+ export interface BundleOptions {
50
+ dev?: boolean;
51
+ platform?: Platform;
52
+ bundleName?: string;
53
+ entryFile?: string;
54
+ output?: string;
55
+ sourcemap?: boolean;
56
+ taro?: boolean;
57
+ expo?: boolean;
58
+ rncli?: boolean;
59
+ hermes?: boolean;
60
+ }
61
+ export interface PublishOptions {
62
+ name?: string;
63
+ description?: string;
64
+ metaInfo?: string;
65
+ packageId?: string;
66
+ packageVersion?: string;
67
+ minPackageVersion?: string;
68
+ maxPackageVersion?: string;
69
+ packageVersionRange?: string;
70
+ rollout?: number;
71
+ dryRun?: boolean;
72
+ }
73
+ export interface UploadOptions {
74
+ platform?: Platform;
75
+ filePath: string;
76
+ appId?: string;
77
+ version?: string;
78
+ }
79
+ export interface WorkflowStep {
80
+ name: string;
81
+ description?: string;
82
+ execute: (context: CommandContext, previousResult?: unknown) => Promise<unknown>;
83
+ condition?: (context: CommandContext) => boolean;
84
+ }
85
+ export interface CustomWorkflow {
86
+ name: string;
87
+ description?: string;
88
+ steps: WorkflowStep[];
89
+ validate?: (context: CommandContext) => boolean;
90
+ options?: Record<string, {
91
+ hasValue?: boolean;
92
+ default?: unknown;
93
+ description?: string;
94
+ }>;
95
+ }
96
+ export interface CLIProvider {
97
+ bundle: (options: BundleOptions) => Promise<CommandResult>;
98
+ publish: (options: PublishOptions) => Promise<CommandResult>;
99
+ upload: (options: UploadOptions) => Promise<CommandResult>;
100
+ createApp: (name: string, platform: Platform) => Promise<CommandResult>;
101
+ listApps: (platform?: Platform) => Promise<CommandResult>;
102
+ getSelectedApp: (platform?: Platform) => Promise<{
103
+ appId: string;
104
+ platform: Platform;
105
+ }>;
106
+ listVersions: (appId: string) => Promise<CommandResult>;
107
+ updateVersion: (appId: string, versionId: string, updates: Partial<Version>) => Promise<CommandResult>;
108
+ getPlatform: (platform?: Platform) => Promise<Platform>;
109
+ loadSession: () => Promise<Session>;
110
+ registerWorkflow: (workflow: CustomWorkflow) => void;
111
+ executeWorkflow: (workflowName: string, context: CommandContext) => Promise<CommandResult>;
112
+ }
113
+ export interface CLIModule {
114
+ name: string;
115
+ version: string;
116
+ commands?: CommandDefinition[];
117
+ workflows?: CustomWorkflow[];
118
+ init?: (provider: CLIProvider) => void;
119
+ cleanup?: () => void;
120
+ }
package/lib/user.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { CommandContext } from 'types';
2
+ export declare const userCommands: {
3
+ login: ({ args }: {
4
+ args: string[];
5
+ }) => Promise<void>;
6
+ logout: (context: CommandContext) => Promise<void>;
7
+ me: () => Promise<void>;
8
+ };
@@ -0,0 +1 @@
1
+ export declare function addGitIgnore(): void;
@@ -0,0 +1,22 @@
1
+ import { Zip } from './zip';
2
+ export declare class AabParser extends Zip {
3
+ extractApk(outputPath: string, { includeAllSplits, splits, }: {
4
+ includeAllSplits?: boolean;
5
+ splits?: string[] | null;
6
+ }): Promise<void>;
7
+ /**
8
+ * 解析 AAB 文件信息(类似 APK parser 的 parse 方法)
9
+ * 注意:AAB 中的 AndroidManifest.xml 在 base/manifest/AndroidManifest.xml
10
+ */
11
+ parse(): Promise<Record<string, any>>;
12
+ /**
13
+ * Parse manifest
14
+ * @param {Buffer} buffer // manifest file's buffer
15
+ */
16
+ private _parseManifest;
17
+ /**
18
+ * Parse resourceMap
19
+ * @param {Buffer} buffer // resourceMap file's buffer
20
+ */
21
+ private _parseResourceMap;
22
+ }
@@ -222,9 +222,5 @@ class AabParser extends _zip.Zip {
222
222
  }));
223
223
  }
224
224
  }
225
- constructor(file){
226
- super(file);
227
- this.file = file;
228
- }
229
225
  }
230
226
  const escapeRegExp = (value)=>value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
@@ -0,0 +1,14 @@
1
+ import { Zip } from './zip';
2
+ export declare class ApkParser extends Zip {
3
+ parse(): Promise<any>;
4
+ /**
5
+ * Parse manifest
6
+ * @param {Buffer} buffer // manifest file's buffer
7
+ */
8
+ private _parseManifest;
9
+ /**
10
+ * Parse resourceMap
11
+ * @param {Buffer} buffer // resourceMap file's buffer
12
+ */
13
+ private _parseResourceMap;
14
+ }
@@ -16,27 +16,29 @@ const ManifestName = /^androidmanifest\.xml$/;
16
16
  const ResourceName = /^resources\.arsc$/;
17
17
  class ApkParser extends _zip.Zip {
18
18
  parse() {
19
+ const manifestKey = ManifestName.toString();
20
+ const resourceKey = ResourceName.toString();
19
21
  return new Promise((resolve, reject)=>{
20
22
  this.getEntries([
21
23
  ManifestName,
22
24
  ResourceName
23
25
  ]).then((buffers)=>{
24
- const manifestBuffer = buffers[ManifestName];
26
+ const manifestBuffer = buffers[manifestKey];
25
27
  if (!manifestBuffer) {
26
28
  throw new Error("AndroidManifest.xml can't be found.");
27
29
  }
28
30
  let apkInfo;
29
31
  let resourceMap;
30
32
  apkInfo = this._parseManifest(manifestBuffer);
31
- if (!buffers[ResourceName]) {
33
+ if (!buffers[resourceKey]) {
32
34
  resolve(apkInfo);
33
35
  } else {
34
- resourceMap = this._parseResourceMap(buffers[ResourceName]);
36
+ resourceMap = this._parseResourceMap(buffers[resourceKey]);
35
37
  apkInfo = (0, _utils.mapInfoResource)(apkInfo, resourceMap);
36
38
  const iconPath = (0, _utils.findApkIconPath)(apkInfo);
37
39
  if (iconPath) {
38
40
  this.getEntry(iconPath).then((iconBuffer)=>{
39
- apkInfo.icon = iconBuffer ? (0, _utils.getBase64FromBuffer)(iconBuffer) : null;
41
+ apkInfo.icon = Buffer.isBuffer(iconBuffer) ? (0, _utils.getBase64FromBuffer)(iconBuffer) : null;
40
42
  resolve(apkInfo);
41
43
  }).catch((e)=>{
42
44
  apkInfo.icon = null;
@@ -0,0 +1,4 @@
1
+ import { Zip } from './zip';
2
+ export declare class AppParser extends Zip {
3
+ parse(): Promise<Record<string, never>>;
4
+ }
@@ -10,4 +10,7 @@ Object.defineProperty(exports, "AppParser", {
10
10
  });
11
11
  const _zip = require("./zip");
12
12
  class AppParser extends _zip.Zip {
13
+ async parse() {
14
+ return {};
15
+ }
13
16
  }