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