react-native-update-cli 2.8.5 → 2.9.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.
Files changed (106) 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/zh.d.ts +136 -0
  18. package/lib/module-manager.d.ts +20 -0
  19. package/lib/module-manager.js +3 -9
  20. package/lib/modules/app-module.d.ts +2 -0
  21. package/lib/modules/app-module.js +84 -44
  22. package/lib/modules/bundle-module.d.ts +2 -0
  23. package/lib/modules/bundle-module.js +7 -8
  24. package/lib/modules/index.d.ts +6 -0
  25. package/lib/modules/package-module.d.ts +2 -0
  26. package/lib/modules/user-module.d.ts +2 -0
  27. package/lib/modules/user-module.js +55 -44
  28. package/lib/modules/version-module.d.ts +2 -0
  29. package/lib/package.d.ts +59 -0
  30. package/lib/package.js +110 -139
  31. package/lib/provider.d.ts +26 -0
  32. package/lib/provider.js +115 -217
  33. package/lib/types.d.ts +120 -0
  34. package/lib/user.d.ts +8 -0
  35. package/lib/utils/add-gitignore.d.ts +1 -0
  36. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  37. package/lib/utils/app-info-parser/aab.js +0 -4
  38. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  39. package/lib/utils/app-info-parser/apk.js +6 -4
  40. package/lib/utils/app-info-parser/app.d.ts +4 -0
  41. package/lib/utils/app-info-parser/app.js +3 -0
  42. package/lib/utils/app-info-parser/index.d.ts +16 -0
  43. package/lib/utils/app-info-parser/index.js +2 -0
  44. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  45. package/lib/utils/app-info-parser/ipa.js +1 -1
  46. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  47. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  48. package/lib/utils/app-info-parser/utils.js +1 -0
  49. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  50. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  51. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  52. package/lib/utils/app-info-parser/zip.js +7 -9
  53. package/lib/utils/check-lockfile.d.ts +1 -0
  54. package/lib/utils/check-plugin.d.ts +7 -0
  55. package/lib/utils/command-result.d.ts +3 -0
  56. package/lib/utils/command-result.js +35 -0
  57. package/lib/utils/constants.d.ts +9 -0
  58. package/lib/utils/dep-versions.d.ts +1 -0
  59. package/lib/utils/git.d.ts +8 -0
  60. package/lib/utils/http-helper.d.ts +4 -0
  61. package/lib/utils/i18n.d.ts +12 -0
  62. package/lib/utils/index.d.ts +22 -0
  63. package/lib/utils/index.js +52 -22
  64. package/lib/utils/latest-version/cli.d.ts +1 -0
  65. package/lib/utils/latest-version/cli.js +24 -60
  66. package/lib/utils/latest-version/index.d.ts +146 -0
  67. package/lib/utils/latest-version/index.js +22 -22
  68. package/lib/utils/options.d.ts +4 -0
  69. package/lib/utils/options.js +63 -0
  70. package/lib/utils/plugin-config.d.ts +9 -0
  71. package/lib/utils/zip-entries.d.ts +3 -0
  72. package/lib/versions.d.ts +43 -0
  73. package/lib/workflow-runner.d.ts +2 -0
  74. package/lib/workflow-runner.js +25 -0
  75. package/package.json +20 -5
  76. package/src/api.ts +1 -1
  77. package/src/app.ts +20 -11
  78. package/src/bundle-pack.ts +51 -0
  79. package/src/bundle-runner.ts +463 -0
  80. package/src/bundle.ts +184 -571
  81. package/src/diff.ts +208 -174
  82. package/src/index.ts +15 -17
  83. package/src/module-manager.ts +15 -15
  84. package/src/modules/app-module.ts +120 -48
  85. package/src/modules/bundle-module.ts +21 -11
  86. package/src/modules/package-module.ts +0 -1
  87. package/src/modules/user-module.ts +117 -58
  88. package/src/package.ts +163 -138
  89. package/src/provider.ts +164 -240
  90. package/src/types.ts +13 -8
  91. package/src/utils/app-info-parser/aab.ts +0 -7
  92. package/src/utils/app-info-parser/apk.ts +9 -6
  93. package/src/utils/app-info-parser/app.ts +5 -1
  94. package/src/utils/app-info-parser/index.ts +11 -6
  95. package/src/utils/app-info-parser/ipa.ts +1 -1
  96. package/src/utils/app-info-parser/utils.ts +3 -0
  97. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  98. package/src/utils/app-info-parser/zip.ts +12 -14
  99. package/src/utils/command-result.ts +24 -0
  100. package/src/utils/index.ts +138 -39
  101. package/src/utils/latest-version/cli.ts +22 -20
  102. package/src/utils/latest-version/index.ts +20 -20
  103. package/src/utils/options.ts +56 -0
  104. package/src/utils/zip-entries.ts +1 -1
  105. package/src/workflow-runner.ts +24 -0
  106. package/index.js +0 -1
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "userModule", {
10
10
  });
11
11
  const _api = require("../api");
12
12
  const _user = require("../user");
13
+ const _options = require("../utils/options");
13
14
  function _getRequireWildcardCache(nodeInterop) {
14
15
  if (typeof WeakMap !== "function") return null;
15
16
  var cacheBabelInterop = new WeakMap();
@@ -78,21 +79,20 @@ const userModule = {
78
79
  try {
79
80
  await (0, _api.loadSession)();
80
81
  const session = (0, _api.getSession)();
81
- if (session && session.token) {
82
+ if (session == null ? void 0 : session.token) {
82
83
  console.log('✓ Session found in local storage');
83
84
  return {
84
85
  sessionLoaded: true,
85
86
  hasToken: true,
86
87
  session
87
88
  };
88
- } else {
89
- console.log('✗ No valid session found in local storage');
90
- return {
91
- sessionLoaded: true,
92
- hasToken: false,
93
- session: null
94
- };
95
89
  }
90
+ console.log('✗ No valid session found in local storage');
91
+ return {
92
+ sessionLoaded: true,
93
+ hasToken: false,
94
+ session: null
95
+ };
96
96
  } catch (error) {
97
97
  console.log('✗ Failed to load session:', error instanceof Error ? error.message : 'Unknown error');
98
98
  return {
@@ -108,10 +108,11 @@ const userModule = {
108
108
  name: 'validate-session',
109
109
  description: 'Validate session by calling API',
110
110
  execute: async (context, previousResult)=>{
111
- if (!previousResult.hasToken) {
111
+ const state = (0, _options.toObjectState)(previousResult, {});
112
+ if (!state.hasToken) {
112
113
  console.log('No token available, skipping validation');
113
114
  return {
114
- ...previousResult,
115
+ ...state,
115
116
  validated: false,
116
117
  reason: 'No token available'
117
118
  };
@@ -121,14 +122,14 @@ const userModule = {
121
122
  await _user.userCommands.me();
122
123
  console.log('✓ Session is valid');
123
124
  return {
124
- ...previousResult,
125
+ ...state,
125
126
  validated: true,
126
127
  reason: 'Session validated successfully'
127
128
  };
128
129
  } catch (error) {
129
130
  console.log('✗ Session validation failed:', error instanceof Error ? error.message : 'Unknown error');
130
131
  return {
131
- ...previousResult,
132
+ ...state,
132
133
  validated: false,
133
134
  reason: error instanceof Error ? error.message : 'Unknown error'
134
135
  };
@@ -139,10 +140,11 @@ const userModule = {
139
140
  name: 'get-user-info',
140
141
  description: 'Get current user information',
141
142
  execute: async (context, previousResult)=>{
142
- if (!previousResult.validated) {
143
+ const state = (0, _options.toObjectState)(previousResult, {});
144
+ if (!state.validated) {
143
145
  console.log('Session not valid, cannot get user info');
144
146
  return {
145
- ...previousResult,
147
+ ...state,
146
148
  userInfo: null,
147
149
  reason: 'Session not valid'
148
150
  };
@@ -152,7 +154,8 @@ const userModule = {
152
154
  const { get } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("../api")));
153
155
  const userInfo = await get('/user/me');
154
156
  console.log('✓ User information retrieved successfully');
155
- if (context.options.showDetails !== false) {
157
+ const showDetails = (0, _options.getBooleanOption)(context.options, 'showDetails', true);
158
+ if (showDetails) {
156
159
  console.log('\n=== User Information ===');
157
160
  for (const [key, value] of Object.entries(userInfo)){
158
161
  if (key !== 'ok') {
@@ -162,14 +165,14 @@ const userModule = {
162
165
  console.log('========================\n');
163
166
  }
164
167
  return {
165
- ...previousResult,
168
+ ...state,
166
169
  userInfo,
167
170
  reason: 'User info retrieved successfully'
168
171
  };
169
172
  } catch (error) {
170
173
  console.log('✗ Failed to get user info:', error instanceof Error ? error.message : 'Unknown error');
171
174
  return {
172
- ...previousResult,
175
+ ...state,
173
176
  userInfo: null,
174
177
  reason: error instanceof Error ? error.message : 'Unknown error'
175
178
  };
@@ -180,16 +183,18 @@ const userModule = {
180
183
  name: 'handle-auth-failure',
181
184
  description: 'Handle authentication failure',
182
185
  execute: async (context, previousResult)=>{
183
- if (previousResult.validated) {
186
+ const state = (0, _options.toObjectState)(previousResult, {});
187
+ if (state.validated) {
184
188
  console.log('✓ Authentication check completed successfully');
185
189
  return {
186
- ...previousResult,
190
+ ...state,
187
191
  authCheckComplete: true,
188
192
  status: 'authenticated'
189
193
  };
190
194
  }
191
195
  console.log('✗ Authentication check failed');
192
- if (context.options.autoLogin) {
196
+ const autoLogin = (0, _options.getBooleanOption)(context.options, 'autoLogin', false);
197
+ if (autoLogin) {
193
198
  console.log('Attempting automatic login...');
194
199
  try {
195
200
  await _user.userCommands.login({
@@ -197,7 +202,7 @@ const userModule = {
197
202
  });
198
203
  console.log('✓ Automatic login successful');
199
204
  return {
200
- ...previousResult,
205
+ ...state,
201
206
  authCheckComplete: true,
202
207
  status: 'auto-logged-in',
203
208
  autoLoginSuccess: true
@@ -205,7 +210,7 @@ const userModule = {
205
210
  } catch (error) {
206
211
  console.log('✗ Automatic login failed:', error instanceof Error ? error.message : 'Unknown error');
207
212
  return {
208
- ...previousResult,
213
+ ...state,
209
214
  authCheckComplete: true,
210
215
  status: 'failed',
211
216
  autoLoginSuccess: false,
@@ -215,7 +220,7 @@ const userModule = {
215
220
  } else {
216
221
  console.log('Please run login command to authenticate');
217
222
  return {
218
- ...previousResult,
223
+ ...state,
219
224
  authCheckComplete: true,
220
225
  status: 'unauthenticated',
221
226
  suggestion: 'Run login command to authenticate'
@@ -251,7 +256,7 @@ const userModule = {
251
256
  try {
252
257
  await (0, _api.loadSession)();
253
258
  const session = (0, _api.getSession)();
254
- if (session && session.token) {
259
+ if (session == null ? void 0 : session.token) {
255
260
  try {
256
261
  await _user.userCommands.me();
257
262
  console.log('✓ User is already logged in');
@@ -291,10 +296,11 @@ const userModule = {
291
296
  name: 'perform-login',
292
297
  description: 'Perform user login',
293
298
  execute: async (context, previousResult)=>{
294
- if (previousResult.alreadyLoggedIn) {
299
+ const state = (0, _options.toObjectState)(previousResult, {});
300
+ if (state.alreadyLoggedIn) {
295
301
  console.log('Skipping login - user already authenticated');
296
302
  return {
297
- ...previousResult,
303
+ ...state,
298
304
  loginPerformed: false,
299
305
  loginSuccess: true
300
306
  };
@@ -302,25 +308,27 @@ const userModule = {
302
308
  console.log('Performing login...');
303
309
  try {
304
310
  const loginArgs = [];
305
- if (context.options.email) {
306
- loginArgs.push(context.options.email);
311
+ const email = (0, _options.getOptionalStringOption)(context.options, 'email');
312
+ if (email) {
313
+ loginArgs.push(email);
307
314
  }
308
- if (context.options.password) {
309
- loginArgs.push(context.options.password);
315
+ const password = (0, _options.getOptionalStringOption)(context.options, 'password');
316
+ if (password) {
317
+ loginArgs.push(password);
310
318
  }
311
319
  await _user.userCommands.login({
312
320
  args: loginArgs
313
321
  });
314
322
  console.log('✓ Login successful');
315
323
  return {
316
- ...previousResult,
324
+ ...state,
317
325
  loginPerformed: true,
318
326
  loginSuccess: true
319
327
  };
320
328
  } catch (error) {
321
329
  console.log('✗ Login failed:', error instanceof Error ? error.message : 'Unknown error');
322
330
  return {
323
- ...previousResult,
331
+ ...state,
324
332
  loginPerformed: true,
325
333
  loginSuccess: false,
326
334
  loginError: error instanceof Error ? error.message : 'Unknown error'
@@ -332,18 +340,20 @@ const userModule = {
332
340
  name: 'validate-login',
333
341
  description: 'Validate login by getting user info',
334
342
  execute: async (context, previousResult)=>{
335
- if (!previousResult.loginSuccess && !previousResult.alreadyLoggedIn) {
343
+ const state = (0, _options.toObjectState)(previousResult, {});
344
+ if (!state.loginSuccess && !state.alreadyLoggedIn) {
336
345
  console.log('Login failed, skipping validation');
337
346
  return {
338
- ...previousResult,
347
+ ...state,
339
348
  validationPerformed: false,
340
349
  validationSuccess: false
341
350
  };
342
351
  }
343
- if (context.options.validateAfterLogin === false) {
352
+ const validateAfterLogin = (0, _options.getBooleanOption)(context.options, 'validateAfterLogin', true);
353
+ if (!validateAfterLogin) {
344
354
  console.log('Skipping validation as requested');
345
355
  return {
346
- ...previousResult,
356
+ ...state,
347
357
  validationPerformed: false,
348
358
  validationSuccess: true
349
359
  };
@@ -353,7 +363,7 @@ const userModule = {
353
363
  const userInfo = await _user.userCommands.me();
354
364
  console.log('✓ Login validation successful');
355
365
  return {
356
- ...previousResult,
366
+ ...state,
357
367
  validationPerformed: true,
358
368
  validationSuccess: true,
359
369
  userInfo
@@ -361,7 +371,7 @@ const userModule = {
361
371
  } catch (error) {
362
372
  console.log('✗ Login validation failed:', error instanceof Error ? error.message : 'Unknown error');
363
373
  return {
364
- ...previousResult,
374
+ ...state,
365
375
  validationPerformed: true,
366
376
  validationSuccess: false,
367
377
  validationError: error instanceof Error ? error.message : 'Unknown error'
@@ -373,26 +383,27 @@ const userModule = {
373
383
  name: 'login-summary',
374
384
  description: 'Provide login flow summary',
375
385
  execute: async (context, previousResult)=>{
386
+ const state = (0, _options.toObjectState)(previousResult, {});
376
387
  console.log('\n=== Login Flow Summary ===');
377
- if (previousResult.alreadyLoggedIn) {
388
+ if (state.alreadyLoggedIn) {
378
389
  console.log('Status: Already logged in');
379
390
  console.log('Session: Valid');
380
- } else if (previousResult.loginSuccess) {
391
+ } else if (state.loginSuccess) {
381
392
  console.log('Status: Login successful');
382
- if (previousResult.validationSuccess) {
393
+ if (state.validationSuccess) {
383
394
  console.log('Validation: Passed');
384
395
  } else {
385
396
  console.log('Validation: Failed');
386
397
  }
387
398
  } else {
388
399
  console.log('Status: Login failed');
389
- console.log('Error:', previousResult.loginError || 'Unknown error');
400
+ console.log('Error:', state.loginError || 'Unknown error');
390
401
  }
391
402
  console.log('==========================\n');
392
403
  return {
393
- ...previousResult,
404
+ ...state,
394
405
  flowComplete: true,
395
- finalStatus: previousResult.alreadyLoggedIn || previousResult.loginSuccess ? 'success' : 'failed'
406
+ finalStatus: state.alreadyLoggedIn || state.loginSuccess ? 'success' : 'failed'
396
407
  };
397
408
  }
398
409
  }
@@ -0,0 +1,2 @@
1
+ import type { CLIModule } from '../types';
2
+ export declare const versionModule: CLIModule;
@@ -0,0 +1,59 @@
1
+ import type { Platform } from './types';
2
+ type PackageCommandOptions = Record<string, unknown> & {
3
+ version?: string;
4
+ includeAllSplits?: boolean | string;
5
+ splits?: string;
6
+ output?: string;
7
+ };
8
+ export declare function normalizeUploadBuildTime(value: unknown): string;
9
+ export declare function listPackage(appId: string): Promise<import("./types").Package[]>;
10
+ export declare function choosePackage(appId: string): Promise<import("./types").Package>;
11
+ export declare const packageCommands: {
12
+ uploadIpa: ({ args, options, }: {
13
+ args: string[];
14
+ options: PackageCommandOptions;
15
+ }) => Promise<void>;
16
+ uploadApk: ({ args, options, }: {
17
+ args: string[];
18
+ options: PackageCommandOptions;
19
+ }) => Promise<void>;
20
+ uploadAab: ({ args, options, }: {
21
+ args: string[];
22
+ options: PackageCommandOptions;
23
+ }) => Promise<void>;
24
+ uploadApp: ({ args, options, }: {
25
+ args: string[];
26
+ options: PackageCommandOptions;
27
+ }) => Promise<void>;
28
+ parseApp: ({ args }: {
29
+ args: string[];
30
+ }) => Promise<void>;
31
+ parseIpa: ({ args }: {
32
+ args: string[];
33
+ }) => Promise<void>;
34
+ parseApk: ({ args }: {
35
+ args: string[];
36
+ }) => Promise<void>;
37
+ parseAab: ({ args }: {
38
+ args: string[];
39
+ }) => Promise<void>;
40
+ extractApk: ({ args, options, }: {
41
+ args: string[];
42
+ options: PackageCommandOptions;
43
+ }) => Promise<void>;
44
+ packages: ({ options }: {
45
+ options: {
46
+ platform: Platform;
47
+ };
48
+ }) => Promise<void>;
49
+ deletePackage: ({ args, options, }: {
50
+ args: string[];
51
+ options: {
52
+ appId?: string;
53
+ packageId?: string;
54
+ packageVersion?: string;
55
+ platform?: Platform;
56
+ };
57
+ }) => Promise<void>;
58
+ };
59
+ export {};
package/lib/package.js CHANGED
@@ -15,6 +15,9 @@ _export(exports, {
15
15
  listPackage: function() {
16
16
  return listPackage;
17
17
  },
18
+ normalizeUploadBuildTime: function() {
19
+ return normalizeUploadBuildTime;
20
+ },
18
21
  packageCommands: function() {
19
22
  return packageCommands;
20
23
  }
@@ -35,6 +38,76 @@ function _interop_require_default(obj) {
35
38
  default: obj
36
39
  };
37
40
  }
41
+ function normalizeUploadBuildTime(value) {
42
+ return String(value);
43
+ }
44
+ function ensureFileByExt(filePath, extension, usageKey) {
45
+ if (!filePath || !filePath.endsWith(extension)) {
46
+ throw new Error((0, _i18n.t)(usageKey));
47
+ }
48
+ return filePath;
49
+ }
50
+ function parseBooleanOption(value) {
51
+ return value === true || value === 'true';
52
+ }
53
+ function parseCsvOption(value) {
54
+ if (typeof value !== 'string') {
55
+ return null;
56
+ }
57
+ const parsed = value.split(',').map((item)=>item.trim()).filter(Boolean);
58
+ return parsed.length > 0 ? parsed : null;
59
+ }
60
+ function getVersionBinding(version) {
61
+ if (!version || typeof version !== 'object') {
62
+ return undefined;
63
+ }
64
+ const v = version;
65
+ return {
66
+ id: v.id,
67
+ name: v.name
68
+ };
69
+ }
70
+ async function uploadNativePackage(filePath, options, config) {
71
+ const info = await config.getInfo(filePath);
72
+ const { versionName: extractedVersionName, buildTime } = info;
73
+ const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
74
+ const { appId, appKey } = await (0, _app.getSelectedApp)(config.platform);
75
+ if (appIdInPkg && appIdInPkg != appId) {
76
+ throw new Error((0, _i18n.t)(config.appIdMismatchKey, {
77
+ appIdInPkg,
78
+ appId
79
+ }));
80
+ }
81
+ if (appKeyInPkg && appKeyInPkg !== appKey) {
82
+ throw new Error((0, _i18n.t)(config.appKeyMismatchKey, {
83
+ appKeyInPkg,
84
+ appKey
85
+ }));
86
+ }
87
+ const customVersion = typeof options.version === 'string' && options.version ? options.version : undefined;
88
+ const versionName = customVersion != null ? customVersion : extractedVersionName;
89
+ if (customVersion !== undefined) {
90
+ console.log((0, _i18n.t)('usingCustomVersion', {
91
+ version: versionName
92
+ }));
93
+ }
94
+ const { hash } = await (0, _api.uploadFile)(filePath);
95
+ const normalizedBuildTime = config.normalizeBuildTime ? config.normalizeBuildTime(buildTime) : buildTime;
96
+ const uploadBuildTime = normalizeUploadBuildTime(normalizedBuildTime);
97
+ const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
98
+ name: versionName,
99
+ hash,
100
+ buildTime: uploadBuildTime,
101
+ deps: _depversions.depVersions,
102
+ commit: await (0, _git.getCommitInfo)()
103
+ });
104
+ (0, _utils.saveToLocal)(filePath, `${appId}/package/${id}${config.extension}`);
105
+ console.log((0, _i18n.t)(config.successKey, {
106
+ id,
107
+ version: versionName,
108
+ buildTime: uploadBuildTime
109
+ }));
110
+ }
38
111
  async function listPackage(appId) {
39
112
  const allPkgs = await (0, _api.getAllPackages)(appId) || [];
40
113
  const header = [
@@ -50,10 +123,11 @@ async function listPackage(appId) {
50
123
  const { version } = pkg;
51
124
  let versionInfo = '';
52
125
  if (version) {
53
- const versionObj = version;
126
+ const versionObj = getVersionBinding(version);
127
+ var _versionObj_name, _versionObj_id;
54
128
  versionInfo = (0, _i18n.t)('boundTo', {
55
- name: versionObj.name || version,
56
- id: versionObj.id || version
129
+ name: (_versionObj_name = versionObj == null ? void 0 : versionObj.name) != null ? _versionObj_name : version,
130
+ id: (_versionObj_id = versionObj == null ? void 0 : versionObj.id) != null ? _versionObj_id : version
57
131
  });
58
132
  }
59
133
  let output = pkg.name;
@@ -87,101 +161,32 @@ async function choosePackage(appId) {
87
161
  }
88
162
  const packageCommands = {
89
163
  uploadIpa: async ({ args, options })=>{
90
- const fn = args[0];
91
- if (!fn || !fn.endsWith('.ipa')) {
92
- throw new Error((0, _i18n.t)('usageUploadIpa'));
93
- }
94
- const ipaInfo = await (0, _utils.getIpaInfo)(fn);
95
- const { versionName: extractedVersionName, buildTime } = ipaInfo;
96
- const appIdInPkg = ipaInfo.appId;
97
- const appKeyInPkg = ipaInfo.appKey;
98
- const { appId, appKey } = await (0, _app.getSelectedApp)('ios');
99
- if (appIdInPkg && appIdInPkg != appId) {
100
- throw new Error((0, _i18n.t)('appIdMismatchIpa', {
101
- appIdInPkg,
102
- appId
103
- }));
104
- }
105
- if (appKeyInPkg && appKeyInPkg !== appKey) {
106
- throw new Error((0, _i18n.t)('appKeyMismatchIpa', {
107
- appKeyInPkg,
108
- appKey
109
- }));
110
- }
111
- // Use custom version if provided, otherwise use extracted version
112
- const versionName = options.version || extractedVersionName;
113
- if (options.version) {
114
- console.log((0, _i18n.t)('usingCustomVersion', {
115
- version: versionName
116
- }));
117
- }
118
- const { hash } = await (0, _api.uploadFile)(fn);
119
- const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
120
- name: versionName,
121
- hash,
122
- buildTime,
123
- deps: _depversions.depVersions,
124
- commit: await (0, _git.getCommitInfo)()
164
+ const fn = ensureFileByExt(args[0], '.ipa', 'usageUploadIpa');
165
+ await uploadNativePackage(fn, options, {
166
+ extension: '.ipa',
167
+ platform: 'ios',
168
+ appIdMismatchKey: 'appIdMismatchIpa',
169
+ appKeyMismatchKey: 'appKeyMismatchIpa',
170
+ successKey: 'ipaUploadSuccess',
171
+ getInfo: (filePath)=>(0, _utils.getIpaInfo)(filePath)
125
172
  });
126
- (0, _utils.saveToLocal)(fn, `${appId}/package/${id}.ipa`);
127
- console.log((0, _i18n.t)('ipaUploadSuccess', {
128
- id,
129
- version: versionName,
130
- buildTime
131
- }));
132
173
  },
133
174
  uploadApk: async ({ args, options })=>{
134
- const fn = args[0];
135
- if (!fn || !fn.endsWith('.apk')) {
136
- throw new Error((0, _i18n.t)('usageUploadApk'));
137
- }
138
- const apkInfo = await (0, _utils.getApkInfo)(fn);
139
- const { versionName: extractedVersionName, buildTime } = apkInfo;
140
- const appIdInPkg = apkInfo.appId;
141
- const appKeyInPkg = apkInfo.appKey;
142
- const { appId, appKey } = await (0, _app.getSelectedApp)('android');
143
- if (appIdInPkg && appIdInPkg != appId) {
144
- throw new Error((0, _i18n.t)('appIdMismatchApk', {
145
- appIdInPkg,
146
- appId
147
- }));
148
- }
149
- if (appKeyInPkg && appKeyInPkg !== appKey) {
150
- throw new Error((0, _i18n.t)('appKeyMismatchApk', {
151
- appKeyInPkg,
152
- appKey
153
- }));
154
- }
155
- // Use custom version if provided, otherwise use extracted version
156
- const versionName = options.version || extractedVersionName;
157
- if (options.version) {
158
- console.log((0, _i18n.t)('usingCustomVersion', {
159
- version: versionName
160
- }));
161
- }
162
- const { hash } = await (0, _api.uploadFile)(fn);
163
- const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
164
- name: versionName,
165
- hash,
166
- buildTime,
167
- deps: _depversions.depVersions,
168
- commit: await (0, _git.getCommitInfo)()
175
+ const fn = ensureFileByExt(args[0], '.apk', 'usageUploadApk');
176
+ await uploadNativePackage(fn, options, {
177
+ extension: '.apk',
178
+ platform: 'android',
179
+ appIdMismatchKey: 'appIdMismatchApk',
180
+ appKeyMismatchKey: 'appKeyMismatchApk',
181
+ successKey: 'apkUploadSuccess',
182
+ getInfo: (filePath)=>(0, _utils.getApkInfo)(filePath)
169
183
  });
170
- (0, _utils.saveToLocal)(fn, `${appId}/package/${id}.apk`);
171
- console.log((0, _i18n.t)('apkUploadSuccess', {
172
- id,
173
- version: versionName,
174
- buildTime
175
- }));
176
184
  },
177
185
  uploadAab: async ({ args, options })=>{
178
- const source = args[0];
179
- if (!source || !source.endsWith('.aab')) {
180
- throw new Error((0, _i18n.t)('usageUploadAab'));
181
- }
186
+ const source = ensureFileByExt(args[0], '.aab', 'usageUploadAab');
182
187
  const output = _path.default.join(_os.default.tmpdir(), `${_path.default.basename(source, _path.default.extname(source))}-${Date.now()}.apk`);
183
- const includeAllSplits = options.includeAllSplits === true || options.includeAllSplits === 'true';
184
- const splits = options.splits ? String(options.splits).split(',').map((item)=>item.trim()).filter(Boolean) : null;
188
+ const includeAllSplits = parseBooleanOption(options.includeAllSplits);
189
+ const splits = parseCsvOption(options.splits);
185
190
  const parser = new _aab.AabParser(source);
186
191
  try {
187
192
  await parser.extractApk(output, {
@@ -201,48 +206,16 @@ const packageCommands = {
201
206
  }
202
207
  },
203
208
  uploadApp: async ({ args, options })=>{
204
- const fn = args[0];
205
- if (!fn || !fn.endsWith('.app')) {
206
- throw new Error((0, _i18n.t)('usageUploadApp'));
207
- }
208
- const appInfo = await (0, _utils.getAppInfo)(fn);
209
- const { versionName: extractedVersionName, buildTime } = appInfo;
210
- const appIdInPkg = appInfo.appId;
211
- const appKeyInPkg = appInfo.appKey;
212
- const { appId, appKey } = await (0, _app.getSelectedApp)('harmony');
213
- if (appIdInPkg && appIdInPkg != appId) {
214
- throw new Error((0, _i18n.t)('appIdMismatchApp', {
215
- appIdInPkg,
216
- appId
217
- }));
218
- }
219
- if (appKeyInPkg && appKeyInPkg !== appKey) {
220
- throw new Error((0, _i18n.t)('appKeyMismatchApp', {
221
- appKeyInPkg,
222
- appKey
223
- }));
224
- }
225
- // Use custom version if provided, otherwise use extracted version
226
- const versionName = options.version || extractedVersionName;
227
- if (options.version) {
228
- console.log((0, _i18n.t)('usingCustomVersion', {
229
- version: versionName
230
- }));
231
- }
232
- const { hash } = await (0, _api.uploadFile)(fn);
233
- const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
234
- name: versionName,
235
- hash,
236
- buildTime: String(buildTime),
237
- deps: _depversions.depVersions,
238
- commit: await (0, _git.getCommitInfo)()
209
+ const fn = ensureFileByExt(args[0], '.app', 'usageUploadApp');
210
+ await uploadNativePackage(fn, options, {
211
+ extension: '.app',
212
+ platform: 'harmony',
213
+ appIdMismatchKey: 'appIdMismatchApp',
214
+ appKeyMismatchKey: 'appKeyMismatchApp',
215
+ successKey: 'appUploadSuccess',
216
+ getInfo: (filePath)=>(0, _utils.getAppInfo)(filePath),
217
+ normalizeBuildTime: (buildTime)=>String(buildTime)
239
218
  });
240
- (0, _utils.saveToLocal)(fn, `${appId}/package/${id}.app`);
241
- console.log((0, _i18n.t)('appUploadSuccess', {
242
- id,
243
- version: versionName,
244
- buildTime
245
- }));
246
219
  },
247
220
  parseApp: async ({ args })=>{
248
221
  const fn = args[0];
@@ -273,13 +246,10 @@ const packageCommands = {
273
246
  console.log(await (0, _utils.getAabInfo)(fn));
274
247
  },
275
248
  extractApk: async ({ args, options })=>{
276
- const source = args[0];
277
- if (!source || !source.endsWith('.aab')) {
278
- throw new Error((0, _i18n.t)('usageExtractApk'));
279
- }
249
+ const source = ensureFileByExt(args[0], '.aab', 'usageExtractApk');
280
250
  const output = options.output || _path.default.join(_path.default.dirname(source), `${_path.default.basename(source, _path.default.extname(source))}.apk`);
281
- const includeAllSplits = options.includeAllSplits === true || options.includeAllSplits === 'true';
282
- const splits = options.splits ? String(options.splits).split(',').map((item)=>item.trim()).filter(Boolean) : null;
251
+ const includeAllSplits = parseBooleanOption(options.includeAllSplits);
252
+ const splits = parseCsvOption(options.splits);
283
253
  const parser = new _aab.AabParser(source);
284
254
  await parser.extractApk(output, {
285
255
  includeAllSplits,
@@ -333,9 +303,10 @@ const packageCommands = {
333
303
  packageId
334
304
  }));
335
305
  } catch (error) {
306
+ const message = error instanceof Error ? error.message : String(error);
336
307
  throw new Error((0, _i18n.t)('deletePackageError', {
337
308
  packageId,
338
- error: error.message
309
+ error: message
339
310
  }));
340
311
  }
341
312
  }