react-native-update-cli 2.18.0 → 2.20.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 (56) hide show
  1. package/lib/api.d.ts +1 -1
  2. package/lib/api.js +143 -134
  3. package/lib/app.d.ts +2 -2
  4. package/lib/app.js +60 -107
  5. package/lib/bin.js +38 -35
  6. package/lib/bundle-pack.js +57 -77
  7. package/lib/bundle-runner.js +249 -312
  8. package/lib/bundle.js +71 -89
  9. package/lib/diff.js +190 -240
  10. package/lib/exports.js +14 -37
  11. package/lib/index.js +16 -17
  12. package/lib/install.js +24 -37
  13. package/lib/locales/en.js +3 -11
  14. package/lib/locales/zh.js +3 -11
  15. package/lib/native-package.d.ts +17 -0
  16. package/lib/native-package.js +232 -0
  17. package/lib/package.js +180 -225
  18. package/lib/provider.js +85 -107
  19. package/lib/types.js +1 -3
  20. package/lib/user.d.ts +1 -1
  21. package/lib/user.js +26 -39
  22. package/lib/utils/add-gitignore.js +16 -29
  23. package/lib/utils/app-info-parser/aab.js +133 -157
  24. package/lib/utils/app-info-parser/apk.js +42 -39
  25. package/lib/utils/app-info-parser/app.js +5 -11
  26. package/lib/utils/app-info-parser/index.js +21 -31
  27. package/lib/utils/app-info-parser/ipa.js +35 -35
  28. package/lib/utils/app-info-parser/resource-finder.js +84 -71
  29. package/lib/utils/app-info-parser/utils.js +52 -77
  30. package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
  31. package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
  32. package/lib/utils/app-info-parser/zip.js +43 -51
  33. package/lib/utils/check-lockfile.js +28 -37
  34. package/lib/utils/check-plugin.js +16 -32
  35. package/lib/utils/command-result.js +7 -20
  36. package/lib/utils/constants.js +23 -63
  37. package/lib/utils/dep-versions.js +21 -27
  38. package/lib/utils/git.js +20 -64
  39. package/lib/utils/hbcTransform.js +133 -246
  40. package/lib/utils/http-helper.js +33 -44
  41. package/lib/utils/i18n.js +17 -26
  42. package/lib/utils/index.js +137 -179
  43. package/lib/utils/latest-version/index.js +128 -137
  44. package/lib/utils/options.js +13 -34
  45. package/lib/utils/plugin-config.js +43 -56
  46. package/lib/utils/runtime.js +50 -108
  47. package/lib/utils/zip-entries.js +70 -97
  48. package/lib/utils/zip-options.js +80 -181
  49. package/lib/versions.js +231 -265
  50. package/package.json +19 -21
  51. package/src/api.ts +47 -3
  52. package/src/diff.ts +12 -20
  53. package/src/native-package.ts +248 -0
  54. package/src/package.ts +29 -19
  55. package/src/user.ts +1 -1
  56. package/src/versions.ts +1 -1
package/lib/package.js CHANGED
@@ -1,91 +1,64 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get choosePackage () {
13
- return choosePackage;
14
- },
15
- get listPackage () {
16
- return listPackage;
17
- },
18
- get normalizeUploadBuildTime () {
19
- return normalizeUploadBuildTime;
20
- },
21
- get packageCommands () {
22
- return packageCommands;
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
7
  }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
24
17
  });
25
- const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
26
- const _os = /*#__PURE__*/ _interop_require_default(require("os"));
27
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
28
- const _ttytable = /*#__PURE__*/ _interop_require_default(require("tty-table"));
29
- const _api = require("./api");
30
- const _app = require("./app");
31
- const _utils = require("./utils");
32
- const _aab = require("./utils/app-info-parser/aab");
33
- const _depversions = require("./utils/dep-versions");
34
- const _git = require("./utils/git");
35
- const _i18n = require("./utils/i18n");
36
- const _options = require("./utils/options");
37
- function _interop_require_default(obj) {
38
- return obj && obj.__esModule ? obj : {
39
- default: obj
40
- };
41
- }
42
- function _getRequireWildcardCache(nodeInterop) {
43
- if (typeof WeakMap !== "function") return null;
44
- var cacheBabelInterop = new WeakMap();
45
- var cacheNodeInterop = new WeakMap();
46
- return (_getRequireWildcardCache = function(nodeInterop) {
47
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
48
- })(nodeInterop);
49
- }
50
- function _interop_require_wildcard(obj, nodeInterop) {
51
- if (!nodeInterop && obj && obj.__esModule) {
52
- return obj;
53
- }
54
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
55
- return {
56
- default: obj
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
57
24
  };
58
- }
59
- var cache = _getRequireWildcardCache(nodeInterop);
60
- if (cache && cache.has(obj)) {
61
- return cache.get(obj);
62
- }
63
- var newObj = {
64
- __proto__: null
25
+ return ownKeys(o);
65
26
  };
66
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
67
- for(var key in obj){
68
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
69
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
70
- if (desc && (desc.get || desc.set)) {
71
- Object.defineProperty(newObj, key, desc);
72
- } else {
73
- newObj[key] = obj[key];
74
- }
75
- }
76
- }
77
- newObj.default = obj;
78
- if (cache) {
79
- cache.set(obj, newObj);
80
- }
81
- return newObj;
82
- }
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.packageCommands = void 0;
40
+ exports.normalizeUploadBuildTime = normalizeUploadBuildTime;
41
+ exports.listPackage = listPackage;
42
+ exports.choosePackage = choosePackage;
43
+ const fs = __importStar(require("fs-extra"));
44
+ const os_1 = __importDefault(require("os"));
45
+ const path_1 = __importDefault(require("path"));
46
+ const tty_table_1 = __importDefault(require("tty-table"));
47
+ const api_1 = require("./api");
48
+ const app_1 = require("./app");
49
+ const native_package_1 = require("./native-package");
50
+ const utils_1 = require("./utils");
51
+ const aab_1 = require("./utils/app-info-parser/aab");
52
+ const dep_versions_1 = require("./utils/dep-versions");
53
+ const git_1 = require("./utils/git");
54
+ const i18n_1 = require("./utils/i18n");
55
+ const options_1 = require("./utils/options");
83
56
  function normalizeUploadBuildTime(value) {
84
57
  return String(value);
85
58
  }
86
59
  function ensureFileByExt(filePath, extension, usageKey) {
87
- if (!(filePath == null ? void 0 : filePath.endsWith(extension))) {
88
- throw new Error((0, _i18n.t)(usageKey));
60
+ if (!filePath?.endsWith(extension)) {
61
+ throw new Error((0, i18n_1.t)(usageKey));
89
62
  }
90
63
  return filePath;
91
64
  }
@@ -96,16 +69,17 @@ function parseCsvOption(value) {
96
69
  if (typeof value !== 'string') {
97
70
  return null;
98
71
  }
99
- const parsed = value.split(',').map((item)=>item.trim()).filter(Boolean);
72
+ const parsed = value
73
+ .split(',')
74
+ .map((item) => item.trim())
75
+ .filter(Boolean);
100
76
  return parsed.length > 0 ? parsed : null;
101
77
  }
102
78
  function toNumericIds(ids) {
103
- return ids.map((id)=>{
79
+ return ids.map((id) => {
104
80
  const numericId = Number(id);
105
81
  if (!Number.isInteger(numericId) || numericId <= 0) {
106
- throw new Error((0, _i18n.t)('invalidId', {
107
- id
108
- }));
82
+ throw new Error((0, i18n_1.t)('invalidId', { id }));
109
83
  }
110
84
  return numericId;
111
85
  });
@@ -115,112 +89,102 @@ function getVersionBinding(version) {
115
89
  return undefined;
116
90
  }
117
91
  const v = version;
118
- return {
119
- id: v.id,
120
- name: v.name
121
- };
92
+ return { id: v.id, name: v.name };
122
93
  }
123
94
  async function uploadNativePackage(filePath, options, config) {
124
95
  const info = await config.getInfo(filePath);
125
96
  const { versionName: extractedVersionName, buildTime } = info;
126
97
  const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
127
- const selectedApp = options.appId ? {
128
- appId: String(options.appId),
129
- appKey: typeof options.appKey === 'string' ? options.appKey : undefined
130
- } : await (0, _app.getSelectedApp)(config.platform, options.config);
98
+ const selectedApp = options.appId
99
+ ? {
100
+ appId: String(options.appId),
101
+ appKey: typeof options.appKey === 'string' ? options.appKey : undefined,
102
+ }
103
+ : await (0, app_1.getSelectedApp)(config.platform, options.config);
131
104
  const { appId, appKey } = selectedApp;
132
105
  if (appIdInPkg && String(appIdInPkg) !== appId) {
133
- throw new Error((0, _i18n.t)(config.appIdMismatchKey, {
134
- appIdInPkg,
135
- appId
136
- }));
106
+ throw new Error((0, i18n_1.t)(config.appIdMismatchKey, { appIdInPkg, appId }));
137
107
  }
138
108
  if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
139
- throw new Error((0, _i18n.t)(config.appKeyMismatchKey, {
140
- appKeyInPkg,
141
- appKey
142
- }));
109
+ throw new Error((0, i18n_1.t)(config.appKeyMismatchKey, { appKeyInPkg, appKey }));
143
110
  }
144
- const customVersion = typeof options.version === 'string' && options.version ? options.version : undefined;
145
- const versionName = customVersion != null ? customVersion : extractedVersionName;
111
+ const customVersion = typeof options.version === 'string' && options.version
112
+ ? options.version
113
+ : undefined;
114
+ const versionName = customVersion ?? extractedVersionName;
146
115
  if (customVersion !== undefined) {
147
- console.log((0, _i18n.t)('usingCustomVersion', {
148
- version: versionName
116
+ console.log((0, i18n_1.t)('usingCustomVersion', { version: versionName }));
117
+ }
118
+ const tempRoot = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-native-package-upload-'));
119
+ const slimPackagePath = path_1.default.join(tempRoot, `package${config.extension}`);
120
+ try {
121
+ await (0, native_package_1.createSlimNativePackage)(filePath, slimPackagePath, config.platform);
122
+ const { hash } = await (0, api_1.uploadFile)(slimPackagePath, undefined, appId);
123
+ const normalizedBuildTime = config.normalizeBuildTime
124
+ ? config.normalizeBuildTime(buildTime)
125
+ : buildTime;
126
+ const uploadBuildTime = normalizeUploadBuildTime(normalizedBuildTime);
127
+ const { id } = await (0, api_1.post)(`/app/${appId}/package/create`, {
128
+ name: versionName,
129
+ hash,
130
+ buildTime: uploadBuildTime,
131
+ deps: dep_versions_1.depVersions,
132
+ commit: await (0, git_1.getCommitInfo)(),
133
+ });
134
+ console.log((0, i18n_1.t)(config.successKey, {
135
+ id,
136
+ version: versionName,
137
+ buildTime: uploadBuildTime,
149
138
  }));
150
139
  }
151
- const { hash } = await (0, _api.uploadFile)(filePath);
152
- const normalizedBuildTime = config.normalizeBuildTime ? config.normalizeBuildTime(buildTime) : buildTime;
153
- const uploadBuildTime = normalizeUploadBuildTime(normalizedBuildTime);
154
- const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
155
- name: versionName,
156
- hash,
157
- buildTime: uploadBuildTime,
158
- deps: _depversions.depVersions,
159
- commit: await (0, _git.getCommitInfo)()
160
- });
161
- console.log((0, _i18n.t)(config.successKey, {
162
- id,
163
- version: versionName,
164
- buildTime: uploadBuildTime
165
- }));
140
+ finally {
141
+ await fs.remove(tempRoot);
142
+ }
166
143
  }
167
144
  async function listPackage(appId) {
168
- const allPkgs = await (0, _api.getAllPackages)(appId) || [];
145
+ const allPkgs = (await (0, api_1.getAllPackages)(appId)) || [];
169
146
  const header = [
170
- {
171
- value: (0, _i18n.t)('nativePackageId')
172
- },
173
- {
174
- value: (0, _i18n.t)('nativeVersion')
175
- }
147
+ { value: (0, i18n_1.t)('nativePackageId') },
148
+ { value: (0, i18n_1.t)('nativeVersion') },
176
149
  ];
177
150
  const rows = [];
178
- for (const pkg of allPkgs){
151
+ for (const pkg of allPkgs) {
179
152
  const { version } = pkg;
180
153
  let versionInfo = '';
181
154
  if (version) {
182
- var _ref, _ref1;
183
155
  const versionObj = getVersionBinding(version);
184
- versionInfo = (0, _i18n.t)('boundTo', {
185
- name: (_ref = versionObj == null ? void 0 : versionObj.name) != null ? _ref : version,
186
- id: (_ref1 = versionObj == null ? void 0 : versionObj.id) != null ? _ref1 : version
156
+ versionInfo = (0, i18n_1.t)('boundTo', {
157
+ name: versionObj?.name ?? version,
158
+ id: versionObj?.id ?? version,
187
159
  });
188
160
  }
189
161
  let output = pkg.name;
190
162
  if (pkg.status === 'paused') {
191
- output += (0, _i18n.t)('pausedStatus');
163
+ output += (0, i18n_1.t)('pausedStatus');
192
164
  }
193
165
  if (pkg.status === 'expired') {
194
- output += (0, _i18n.t)('expiredStatus');
166
+ output += (0, i18n_1.t)('expiredStatus');
195
167
  }
196
168
  output += versionInfo;
197
- rows.push([
198
- pkg.id,
199
- output
200
- ]);
169
+ rows.push([pkg.id, output]);
201
170
  }
202
- console.log((0, _ttytable.default)(header, rows).render());
203
- console.log((0, _i18n.t)('totalPackages', {
204
- count: allPkgs.length
205
- }));
171
+ console.log((0, tty_table_1.default)(header, rows).render());
172
+ console.log((0, i18n_1.t)('totalPackages', { count: allPkgs.length }));
206
173
  return allPkgs;
207
174
  }
208
175
  async function choosePackage(appId) {
209
176
  const list = await listPackage(appId);
210
- const packageMap = new Map(list == null ? void 0 : list.map((v)=>[
211
- v.id.toString(),
212
- v
213
- ]));
214
- while(true){
215
- const id = await (0, _utils.question)((0, _i18n.t)('enterNativePackageId'));
177
+ const packageMap = new Map(list?.map((v) => [v.id.toString(), v]));
178
+ while (true) {
179
+ const id = await (0, utils_1.question)((0, i18n_1.t)('enterNativePackageId'));
216
180
  const app = packageMap.get(id);
217
181
  if (app) {
218
182
  return app;
219
183
  }
220
184
  }
221
185
  }
222
- const packageCommands = {
223
- uploadIpa: async ({ args, options })=>{
186
+ exports.packageCommands = {
187
+ uploadIpa: async ({ args, options, }) => {
224
188
  const fn = ensureFileByExt(args[0], '.ipa', 'usageUploadIpa');
225
189
  await uploadNativePackage(fn, options, {
226
190
  extension: '.ipa',
@@ -228,10 +192,10 @@ const packageCommands = {
228
192
  appIdMismatchKey: 'appIdMismatchIpa',
229
193
  appKeyMismatchKey: 'appKeyMismatchIpa',
230
194
  successKey: 'ipaUploadSuccess',
231
- getInfo: (filePath)=>(0, _utils.getIpaInfo)(filePath)
195
+ getInfo: (filePath) => (0, utils_1.getIpaInfo)(filePath),
232
196
  });
233
197
  },
234
- uploadApk: async ({ args, options })=>{
198
+ uploadApk: async ({ args, options, }) => {
235
199
  const fn = ensureFileByExt(args[0], '.apk', 'usageUploadApk');
236
200
  await uploadNativePackage(fn, options, {
237
201
  extension: '.apk',
@@ -239,33 +203,32 @@ const packageCommands = {
239
203
  appIdMismatchKey: 'appIdMismatchApk',
240
204
  appKeyMismatchKey: 'appKeyMismatchApk',
241
205
  successKey: 'apkUploadSuccess',
242
- getInfo: (filePath)=>(0, _utils.getApkInfo)(filePath)
206
+ getInfo: (filePath) => (0, utils_1.getApkInfo)(filePath),
243
207
  });
244
208
  },
245
- uploadAab: async ({ args, options })=>{
209
+ uploadAab: async ({ args, options, }) => {
246
210
  const source = ensureFileByExt(args[0], '.aab', 'usageUploadAab');
247
- const output = _path.default.join(_os.default.tmpdir(), `${_path.default.basename(source, _path.default.extname(source))}-${Date.now()}.apk`);
211
+ const output = path_1.default.join(os_1.default.tmpdir(), `${path_1.default.basename(source, path_1.default.extname(source))}-${Date.now()}.apk`);
248
212
  const includeAllSplits = parseBooleanOption(options.includeAllSplits);
249
213
  const splits = parseCsvOption(options.splits);
250
- const parser = new _aab.AabParser(source);
214
+ const parser = new aab_1.AabParser(source);
251
215
  try {
252
216
  await parser.extractApk(output, {
253
217
  includeAllSplits,
254
- splits
218
+ splits,
255
219
  });
256
- await packageCommands.uploadApk({
257
- args: [
258
- output
259
- ],
260
- options
220
+ await exports.packageCommands.uploadApk({
221
+ args: [output],
222
+ options,
261
223
  });
262
- } finally{
263
- if (await _fsextra.pathExists(output)) {
264
- await _fsextra.remove(output);
224
+ }
225
+ finally {
226
+ if (await fs.pathExists(output)) {
227
+ await fs.remove(output);
265
228
  }
266
229
  }
267
230
  },
268
- uploadApp: async ({ args, options })=>{
231
+ uploadApp: async ({ args, options, }) => {
269
232
  const fn = ensureFileByExt(args[0], '.app', 'usageUploadApp');
270
233
  await uploadNativePackage(fn, options, {
271
234
  extension: '.app',
@@ -273,89 +236,81 @@ const packageCommands = {
273
236
  appIdMismatchKey: 'appIdMismatchApp',
274
237
  appKeyMismatchKey: 'appKeyMismatchApp',
275
238
  successKey: 'appUploadSuccess',
276
- getInfo: (filePath)=>(0, _utils.getAppInfo)(filePath),
277
- normalizeBuildTime: (buildTime)=>String(buildTime)
239
+ getInfo: (filePath) => (0, utils_1.getAppInfo)(filePath),
240
+ normalizeBuildTime: (buildTime) => String(buildTime),
278
241
  });
279
242
  },
280
- parseApp: async ({ args })=>{
243
+ parseApp: async ({ args }) => {
281
244
  const fn = args[0];
282
- if (!(fn == null ? void 0 : fn.endsWith('.app'))) {
283
- throw new Error((0, _i18n.t)('usageParseApp'));
245
+ if (!fn?.endsWith('.app')) {
246
+ throw new Error((0, i18n_1.t)('usageParseApp'));
284
247
  }
285
- console.log(await (0, _utils.getAppInfo)(fn));
248
+ console.log(await (0, utils_1.getAppInfo)(fn));
286
249
  },
287
- parseIpa: async ({ args })=>{
250
+ parseIpa: async ({ args }) => {
288
251
  const fn = args[0];
289
- if (!(fn == null ? void 0 : fn.endsWith('.ipa'))) {
290
- throw new Error((0, _i18n.t)('usageParseIpa'));
252
+ if (!fn?.endsWith('.ipa')) {
253
+ throw new Error((0, i18n_1.t)('usageParseIpa'));
291
254
  }
292
- console.log(await (0, _utils.getIpaInfo)(fn));
255
+ console.log(await (0, utils_1.getIpaInfo)(fn));
293
256
  },
294
- parseApk: async ({ args })=>{
257
+ parseApk: async ({ args }) => {
295
258
  const fn = args[0];
296
- if (!(fn == null ? void 0 : fn.endsWith('.apk'))) {
297
- throw new Error((0, _i18n.t)('usageParseApk'));
259
+ if (!fn?.endsWith('.apk')) {
260
+ throw new Error((0, i18n_1.t)('usageParseApk'));
298
261
  }
299
- console.log(await (0, _utils.getApkInfo)(fn));
262
+ console.log(await (0, utils_1.getApkInfo)(fn));
300
263
  },
301
- parseAab: async ({ args })=>{
264
+ parseAab: async ({ args }) => {
302
265
  const fn = args[0];
303
- if (!(fn == null ? void 0 : fn.endsWith('.aab'))) {
304
- throw new Error((0, _i18n.t)('usageParseAab'));
266
+ if (!fn?.endsWith('.aab')) {
267
+ throw new Error((0, i18n_1.t)('usageParseAab'));
305
268
  }
306
- console.log(await (0, _utils.getAabInfo)(fn));
269
+ console.log(await (0, utils_1.getAabInfo)(fn));
307
270
  },
308
- extractApk: async ({ args, options })=>{
271
+ extractApk: async ({ args, options, }) => {
309
272
  const source = ensureFileByExt(args[0], '.aab', 'usageExtractApk');
310
- const output = options.output || _path.default.join(_path.default.dirname(source), `${_path.default.basename(source, _path.default.extname(source))}.apk`);
273
+ const output = options.output ||
274
+ path_1.default.join(path_1.default.dirname(source), `${path_1.default.basename(source, path_1.default.extname(source))}.apk`);
311
275
  const includeAllSplits = parseBooleanOption(options.includeAllSplits);
312
276
  const splits = parseCsvOption(options.splits);
313
- const parser = new _aab.AabParser(source);
277
+ const parser = new aab_1.AabParser(source);
314
278
  await parser.extractApk(output, {
315
279
  includeAllSplits,
316
- splits
280
+ splits,
317
281
  });
318
- console.log((0, _i18n.t)('apkExtracted', {
319
- output
320
- }));
282
+ console.log((0, i18n_1.t)('apkExtracted', { output }));
321
283
  },
322
- packages: async ({ options })=>{
284
+ packages: async ({ options, }) => {
323
285
  let appId = options.appId;
324
286
  if (!appId) {
325
- const platform = await (0, _app.getPlatform)(options.platform);
326
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
287
+ const platform = await (0, app_1.getPlatform)(options.platform);
288
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
327
289
  }
328
290
  await listPackage(String(appId));
329
291
  },
330
- deletePackage: async ({ options })=>{
331
- var _getStringListOption;
292
+ deletePackage: async ({ options }) => {
332
293
  let { appId } = options;
333
- let packageIds = (_getStringListOption = (0, _options.getStringListOption)(options, 'packageIds')) != null ? _getStringListOption : (0, _options.getStringListOption)(options, 'packageId');
294
+ let packageIds = (0, options_1.getStringListOption)(options, 'packageIds') ??
295
+ (0, options_1.getStringListOption)(options, 'packageId');
334
296
  if (!appId) {
335
- const platform = await (0, _app.getPlatform)(options.platform);
336
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
297
+ const platform = await (0, app_1.getPlatform)(options.platform);
298
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
337
299
  }
338
300
  if (!packageIds) {
339
- const packageVersions = (0, _options.getStringListOption)(options, 'packageVersion');
301
+ const packageVersions = (0, options_1.getStringListOption)(options, 'packageVersion');
340
302
  if (!packageVersions) {
341
- throw new Error((0, _i18n.t)('usageDeletePackage'));
303
+ throw new Error((0, i18n_1.t)('usageDeletePackage'));
342
304
  }
343
- const allPkgs = await (0, _api.getAllPackages)(appId);
305
+ const allPkgs = await (0, api_1.getAllPackages)(appId);
344
306
  if (!allPkgs) {
345
- throw new Error((0, _i18n.t)('noPackagesFound', {
346
- appId
347
- }));
307
+ throw new Error((0, i18n_1.t)('noPackagesFound', { appId }));
348
308
  }
349
- const allPkgsMap = new Map(allPkgs.map((pkg)=>[
350
- pkg.name,
351
- pkg
352
- ]));
353
- packageIds = packageVersions.map((packageVersion)=>{
309
+ const allPkgsMap = new Map(allPkgs.map((pkg) => [pkg.name, pkg]));
310
+ packageIds = packageVersions.map((packageVersion) => {
354
311
  const selectedPackage = allPkgsMap.get(packageVersion);
355
312
  if (!selectedPackage) {
356
- throw new Error((0, _i18n.t)('packageNotFound', {
357
- packageVersion
358
- }));
313
+ throw new Error((0, i18n_1.t)('packageNotFound', { packageVersion }));
359
314
  }
360
315
  return String(selectedPackage.id);
361
316
  });
@@ -374,25 +329,25 @@ const packageCommands = {
374
329
  try {
375
330
  if (packageIds.length === 1) {
376
331
  const [packageId] = packageIds;
377
- await (0, _api.doDelete)(`/app/${appId}/package/${packageId}`);
378
- console.log((0, _i18n.t)('deletePackageSuccess', {
379
- packageId
380
- }));
381
- } else {
382
- await (0, _api.doDelete)(`/app/${appId}/package`, {
383
- packageIds: toNumericIds(packageIds)
332
+ await (0, api_1.doDelete)(`/app/${appId}/package/${packageId}`);
333
+ console.log((0, i18n_1.t)('deletePackageSuccess', { packageId }));
334
+ }
335
+ else {
336
+ await (0, api_1.doDelete)(`/app/${appId}/package`, {
337
+ packageIds: toNumericIds(packageIds),
384
338
  });
385
- console.log((0, _i18n.t)('deletePackagesSuccess', {
339
+ console.log((0, i18n_1.t)('deletePackagesSuccess', {
386
340
  count: packageIds.length,
387
- packageIds: packageIds.join(', ')
341
+ packageIds: packageIds.join(', '),
388
342
  }));
389
343
  }
390
- } catch (error) {
344
+ }
345
+ catch (error) {
391
346
  const message = error instanceof Error ? error.message : String(error);
392
- throw new Error((0, _i18n.t)('deletePackageError', {
347
+ throw new Error((0, i18n_1.t)('deletePackageError', {
393
348
  packageId: packageIds.join(', '),
394
- error: message
349
+ error: message,
395
350
  }));
396
351
  }
397
- }
352
+ },
398
353
  };