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/versions.js CHANGED
@@ -1,43 +1,22 @@
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 bindVersionToPackages () {
13
- return bindVersionToPackages;
14
- },
15
- get fetchVersions () {
16
- return fetchVersions;
17
- },
18
- get normalizeDeps () {
19
- return normalizeDeps;
20
- },
21
- get versionCommands () {
22
- return versionCommands;
23
- }
24
- });
25
- const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
26
- const _compareversions = require("compare-versions");
27
- const _ttytable = /*#__PURE__*/ _interop_require_default(require("tty-table"));
28
- const _api = require("./api");
29
- const _app = require("./app");
30
- const _package = require("./package");
31
- const _utils = require("./utils");
32
- const _depversions = require("./utils/dep-versions");
33
- const _git = require("./utils/git");
34
- const _i18n = require("./utils/i18n");
35
- const _options = require("./utils/options");
36
- function _interop_require_default(obj) {
37
- return obj && obj.__esModule ? obj : {
38
- default: obj
39
- };
40
- }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.versionCommands = exports.bindVersionToPackages = void 0;
7
+ exports.normalizeDeps = normalizeDeps;
8
+ exports.fetchVersions = fetchVersions;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const compare_versions_1 = require("compare-versions");
11
+ const tty_table_1 = __importDefault(require("tty-table"));
12
+ const api_1 = require("./api");
13
+ const app_1 = require("./app");
14
+ const package_1 = require("./package");
15
+ const utils_1 = require("./utils");
16
+ const dep_versions_1 = require("./utils/dep-versions");
17
+ const git_1 = require("./utils/git");
18
+ const i18n_1 = require("./utils/i18n");
19
+ const options_1 = require("./utils/options");
41
20
  function normalizeDeps(input) {
42
21
  if (!input) {
43
22
  return undefined;
@@ -46,7 +25,8 @@ function normalizeDeps(input) {
46
25
  if (typeof input === 'string') {
47
26
  try {
48
27
  raw = JSON.parse(input);
49
- } catch (_e) {
28
+ }
29
+ catch (_e) {
50
30
  return undefined;
51
31
  }
52
32
  }
@@ -54,7 +34,7 @@ function normalizeDeps(input) {
54
34
  return undefined;
55
35
  }
56
36
  const deps = {};
57
- for (const [name, version] of Object.entries(raw)){
37
+ for (const [name, version] of Object.entries(raw)) {
58
38
  if (typeof version === 'string' && version) {
59
39
  deps[name] = version;
60
40
  }
@@ -66,11 +46,8 @@ function getDepsChanges(oldDeps, newDeps) {
66
46
  return [];
67
47
  }
68
48
  const rows = [];
69
- const keys = Object.keys({
70
- ...oldDeps,
71
- ...newDeps
72
- }).sort((a, b)=>a.localeCompare(b));
73
- for (const key of keys){
49
+ const keys = Object.keys({ ...oldDeps, ...newDeps }).sort((a, b) => a.localeCompare(b));
50
+ for (const key of keys) {
74
51
  const oldVersion = oldDeps[key];
75
52
  const newVersion = newDeps[key];
76
53
  if (oldVersion === undefined && newVersion !== undefined) {
@@ -78,7 +55,7 @@ function getDepsChanges(oldDeps, newDeps) {
78
55
  dependency: key,
79
56
  oldVersion: '-',
80
57
  newVersion,
81
- type: 'added'
58
+ type: 'added',
82
59
  });
83
60
  continue;
84
61
  }
@@ -87,59 +64,57 @@ function getDepsChanges(oldDeps, newDeps) {
87
64
  dependency: key,
88
65
  oldVersion,
89
66
  newVersion: '-',
90
- type: 'removed'
67
+ type: 'removed',
91
68
  });
92
69
  continue;
93
70
  }
94
- if (oldVersion !== undefined && newVersion !== undefined && oldVersion !== newVersion) {
71
+ if (oldVersion !== undefined &&
72
+ newVersion !== undefined &&
73
+ oldVersion !== newVersion) {
95
74
  rows.push({
96
75
  dependency: key,
97
76
  oldVersion,
98
77
  newVersion,
99
- type: 'changed'
78
+ type: 'changed',
100
79
  });
101
80
  }
102
81
  }
103
82
  return rows;
104
83
  }
105
84
  function toNumericIds(ids) {
106
- return ids.map((id)=>{
85
+ return ids.map((id) => {
107
86
  const numericId = Number(id);
108
87
  if (!Number.isInteger(numericId) || numericId <= 0) {
109
- throw new Error((0, _i18n.t)('invalidId', {
110
- id
111
- }));
88
+ throw new Error((0, i18n_1.t)('invalidId', { id }));
112
89
  }
113
90
  return numericId;
114
91
  });
115
92
  }
116
93
  function getDepsChangeSummary(changes) {
117
- return changes.reduce((acc, item)=>{
94
+ return changes.reduce((acc, item) => {
118
95
  if (item.type === 'added') {
119
96
  acc.added += 1;
120
- } else if (item.type === 'removed') {
97
+ }
98
+ else if (item.type === 'removed') {
121
99
  acc.removed += 1;
122
- } else {
100
+ }
101
+ else {
123
102
  acc.changed += 1;
124
103
  }
125
104
  return acc;
126
- }, {
127
- added: 0,
128
- removed: 0,
129
- changed: 0
130
- });
105
+ }, { added: 0, removed: 0, changed: 0 });
131
106
  }
132
107
  function renderVersionChange(change) {
133
- const arrow = _chalk.default.gray(` ${(0, _i18n.t)('depsChangeArrow')} `);
108
+ const arrow = chalk_1.default.gray(` ${(0, i18n_1.t)('depsChangeArrow')} `);
134
109
  if (change.type === 'added') {
135
- return `${_chalk.default.red((0, _i18n.t)('depsChangeAddedLabel'))} | ${_chalk.default.gray(change.oldVersion)}${arrow}${_chalk.default.red(change.newVersion)}`;
110
+ return `${chalk_1.default.red((0, i18n_1.t)('depsChangeAddedLabel'))} | ${chalk_1.default.gray(change.oldVersion)}${arrow}${chalk_1.default.red(change.newVersion)}`;
136
111
  }
137
112
  if (change.type === 'removed') {
138
- return `${_chalk.default.green((0, _i18n.t)('depsChangeRemovedLabel'))} | ${_chalk.default.green(change.oldVersion)}${arrow}${_chalk.default.gray(change.newVersion)}`;
113
+ return `${chalk_1.default.green((0, i18n_1.t)('depsChangeRemovedLabel'))} | ${chalk_1.default.green(change.oldVersion)}${arrow}${chalk_1.default.gray(change.newVersion)}`;
139
114
  }
140
- return `${_chalk.default.yellow((0, _i18n.t)('depsChangeChangedLabel'))} | ${_chalk.default.yellow(change.oldVersion)}${arrow}${_chalk.default.yellow(change.newVersion)}`;
115
+ return `${chalk_1.default.yellow((0, i18n_1.t)('depsChangeChangedLabel'))} | ${chalk_1.default.yellow(change.oldVersion)}${arrow}${chalk_1.default.yellow(change.newVersion)}`;
141
116
  }
142
- function printDepsChangesForPackage({ pkg, versionDeps }) {
117
+ function printDepsChangesForPackage({ pkg, versionDeps, }) {
143
118
  const pkgDeps = normalizeDeps(pkg.deps);
144
119
  if (!pkgDeps) {
145
120
  return false;
@@ -149,42 +124,38 @@ function printDepsChangesForPackage({ pkg, versionDeps }) {
149
124
  return false;
150
125
  }
151
126
  const summary = getDepsChangeSummary(changes);
152
- const summaryText = (0, _i18n.t)('depsChangeSummary', {
153
- added: _chalk.default.red(String(summary.added)),
154
- removed: _chalk.default.green(String(summary.removed)),
155
- changed: _chalk.default.yellow(String(summary.changed))
127
+ const summaryText = (0, i18n_1.t)('depsChangeSummary', {
128
+ added: chalk_1.default.red(String(summary.added)),
129
+ removed: chalk_1.default.green(String(summary.removed)),
130
+ changed: chalk_1.default.yellow(String(summary.changed)),
156
131
  });
157
132
  const header = [
158
- {
159
- value: (0, _i18n.t)('depsChangeDependencyHeader')
160
- },
161
- {
162
- value: (0, _i18n.t)('depsChangeVersionHeader')
163
- }
133
+ { value: (0, i18n_1.t)('depsChangeDependencyHeader') },
134
+ { value: (0, i18n_1.t)('depsChangeVersionHeader') },
164
135
  ];
165
- const rows = changes.map((change)=>[
166
- change.dependency,
167
- renderVersionChange(change)
168
- ]);
136
+ const rows = changes.map((change) => [
137
+ change.dependency,
138
+ renderVersionChange(change),
139
+ ]);
169
140
  console.log('');
170
- console.log(_chalk.default.bgYellow.black.bold(` ${(0, _i18n.t)('depsChangeWarningTitle')} `));
171
- console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeTargetPackage', {
141
+ console.log(chalk_1.default.bgYellow.black.bold(` ${(0, i18n_1.t)('depsChangeWarningTitle')} `));
142
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('depsChangeTargetPackage', {
172
143
  packageName: pkg.name,
173
- packageId: pkg.id
144
+ packageId: pkg.id,
174
145
  })));
175
146
  console.log(summaryText);
176
- console.log((0, _ttytable.default)(header, rows).render());
177
- console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeRiskWarning')));
147
+ console.log((0, tty_table_1.default)(header, rows).render());
148
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('depsChangeRiskWarning')));
178
149
  return true;
179
150
  }
180
151
  async function findVersionDeps(appId, versionId) {
181
152
  const targetId = String(versionId);
182
153
  const limit = 100;
183
154
  let offset = 0;
184
- while(true){
185
- const { data, count } = await (0, _api.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
155
+ while (true) {
156
+ const { data, count } = await (0, api_1.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
186
157
  const versions = Array.isArray(data) ? data : [];
187
- const version = versions.find((item)=>String(item.id) === targetId);
158
+ const version = versions.find((item) => String(item.id) === targetId);
188
159
  if (version) {
189
160
  return normalizeDeps(version.deps);
190
161
  }
@@ -195,7 +166,7 @@ async function findVersionDeps(appId, versionId) {
195
166
  }
196
167
  return undefined;
197
168
  }
198
- async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVersionDeps }) {
169
+ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVersionDeps, }) {
199
170
  if (!versionId || pkgs.length !== 1) {
200
171
  return;
201
172
  }
@@ -203,9 +174,10 @@ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVers
203
174
  if (!versionDeps) {
204
175
  try {
205
176
  versionDeps = await findVersionDeps(appId, versionId);
206
- } catch (error) {
207
- console.warn(_chalk.default.yellow((0, _i18n.t)('depsChangeFetchFailed', {
208
- error: (error == null ? void 0 : error.message) || String(error)
177
+ }
178
+ catch (error) {
179
+ console.warn(chalk_1.default.yellow((0, i18n_1.t)('depsChangeFetchFailed', {
180
+ error: error?.message || String(error),
209
181
  })));
210
182
  return;
211
183
  }
@@ -214,39 +186,37 @@ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVers
214
186
  return;
215
187
  }
216
188
  let hasChanges = false;
217
- for (const pkg of pkgs){
218
- const printed = printDepsChangesForPackage({
219
- pkg,
220
- versionDeps
221
- });
189
+ for (const pkg of pkgs) {
190
+ const printed = printDepsChangesForPackage({ pkg, versionDeps });
222
191
  hasChanges = hasChanges || printed;
223
192
  }
224
193
  if (hasChanges) {
225
- console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeNonBlockingHint')));
194
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('depsChangeNonBlockingHint')));
226
195
  }
227
196
  }
228
197
  const versionPageLimit = 10;
229
198
  async function fetchVersions(appId, offset = 0, limit = versionPageLimit) {
230
- const { data } = await (0, _api.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
199
+ const { data } = await (0, api_1.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
231
200
  return Array.isArray(data) ? data : [];
232
201
  }
233
202
  async function showVersion(appId, offset) {
234
203
  const data = await fetchVersions(appId, offset, versionPageLimit);
235
- console.log((0, _i18n.t)('offset', {
236
- offset
237
- }));
238
- for (const version of data){
239
- var _version_packages;
240
- const pkgCount = ((_version_packages = version.packages) == null ? void 0 : _version_packages.length) || 0;
204
+ console.log((0, i18n_1.t)('offset', { offset }));
205
+ for (const version of data) {
206
+ const pkgCount = version.packages?.length || 0;
241
207
  let packageInfo = '';
242
208
  if (pkgCount === 0) {
243
209
  packageInfo = 'no package';
244
- } else {
245
- var _version_packages1;
246
- packageInfo = ((_version_packages1 = version.packages) != null ? _version_packages1 : []).slice(0, 3).map((pkg)=>pkg.name).join(', ');
210
+ }
211
+ else {
212
+ packageInfo = (version.packages ?? [])
213
+ .slice(0, 3)
214
+ .map((pkg) => pkg.name)
215
+ .join(', ');
247
216
  if (pkgCount > 3) {
248
217
  packageInfo += `...and ${pkgCount - 3} more`;
249
- } else {
218
+ }
219
+ else {
250
220
  packageInfo = `[${packageInfo}]`;
251
221
  }
252
222
  }
@@ -256,13 +226,13 @@ async function showVersion(appId, offset) {
256
226
  }
257
227
  async function listVersions(appId, interactive = true) {
258
228
  let offset = 0;
259
- while(true){
229
+ while (true) {
260
230
  const data = await showVersion(appId, offset);
261
231
  if (!interactive) {
262
232
  return data;
263
233
  }
264
- const cmd = await (0, _utils.question)('page Up/page Down/Begin/Quit(U/D/B/Q)');
265
- switch(cmd.toLowerCase()){
234
+ const cmd = await (0, utils_1.question)('page Up/page Down/Begin/Quit(U/D/B/Q)');
235
+ switch (cmd.toLowerCase()) {
266
236
  case 'u':
267
237
  offset = Math.max(0, offset - 10);
268
238
  break;
@@ -281,13 +251,13 @@ async function listVersions(appId, interactive = true) {
281
251
  }
282
252
  async function chooseVersion(appId) {
283
253
  let offset = 0;
284
- while(true){
254
+ while (true) {
285
255
  const data = await showVersion(appId, offset);
286
- if ((0, _utils.isNonInteractive)()) {
287
- throw new Error((0, _i18n.t)('versionIdRequired'));
256
+ if ((0, utils_1.isNonInteractive)()) {
257
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
288
258
  }
289
- const cmd = await (0, _utils.question)('Enter versionId or page Up/page Down/Begin(U/D/B)');
290
- switch(cmd.toUpperCase()){
259
+ const cmd = await (0, utils_1.question)('Enter versionId or page Up/page Down/Begin(U/D/B)');
260
+ switch (cmd.toUpperCase()) {
291
261
  case 'U':
292
262
  offset = Math.max(0, offset - 10);
293
263
  break;
@@ -297,83 +267,88 @@ async function chooseVersion(appId) {
297
267
  case 'B':
298
268
  offset = 0;
299
269
  break;
300
- default:
301
- {
302
- const versionId = Number.parseInt(cmd, 10);
303
- const v = data.find((version)=>String(version.id) === String(versionId));
304
- if (v) {
305
- return v;
306
- }
270
+ default: {
271
+ const versionId = Number.parseInt(cmd, 10);
272
+ const v = data.find((version) => String(version.id) === String(versionId));
273
+ if (v) {
274
+ return v;
307
275
  }
276
+ }
308
277
  }
309
278
  }
310
279
  }
311
- const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun })=>{
280
+ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun, }) => {
312
281
  if (dryRun) {
313
- console.log(_chalk.default.yellow((0, _i18n.t)('dryRun')));
282
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('dryRun')));
314
283
  }
315
284
  if (rollout !== undefined) {
316
- console.log(`${(0, _i18n.t)('rolloutConfigSet', {
285
+ console.log(`${(0, i18n_1.t)('rolloutConfigSet', {
317
286
  version: versionId,
318
- versions: pkgs.map((pkg)=>pkg.name).join(', '),
319
- rollout: rollout
287
+ versions: pkgs.map((pkg) => pkg.name).join(', '),
288
+ rollout: rollout,
320
289
  })}`);
321
290
  }
322
291
  if (!dryRun) {
323
292
  if (pkgs.length === 1) {
324
- await (0, _api.post)(`/app/${appId}/binding`, {
293
+ await (0, api_1.post)(`/app/${appId}/binding`, {
325
294
  versionId,
326
295
  rollout,
327
- packageId: pkgs[0].id
296
+ packageId: pkgs[0].id,
328
297
  });
329
- } else {
330
- await (0, _api.post)(`/app/${appId}/binding`, {
298
+ }
299
+ else {
300
+ await (0, api_1.post)(`/app/${appId}/binding`, {
331
301
  versionId,
332
302
  rollout,
333
- packageIds: toNumericIds(pkgs.map((pkg)=>String(pkg.id)))
303
+ packageIds: toNumericIds(pkgs.map((pkg) => String(pkg.id))),
334
304
  });
335
305
  }
336
306
  }
337
- for (const pkg of pkgs){
338
- console.log(`${(0, _i18n.t)('versionBind', {
307
+ for (const pkg of pkgs) {
308
+ console.log(`${(0, i18n_1.t)('versionBind', {
339
309
  version: versionId,
340
310
  nativeVersion: pkg.name,
341
- id: pkg.id
311
+ id: pkg.id,
342
312
  })}`);
343
313
  }
344
- console.log((0, _i18n.t)('operationComplete', {
345
- count: pkgs.length
346
- }));
314
+ console.log((0, i18n_1.t)('operationComplete', { count: pkgs.length }));
347
315
  };
348
- const versionCommands = {
349
- publish: async ({ args, options })=>{
316
+ exports.bindVersionToPackages = bindVersionToPackages;
317
+ exports.versionCommands = {
318
+ publish: async ({ args, options, }) => {
350
319
  const fn = args[0];
351
320
  const { name, description, metaInfo } = options;
352
- if (!(fn == null ? void 0 : fn.endsWith('.ppk'))) {
353
- throw new Error((0, _i18n.t)('publishUsage'));
321
+ if (!fn?.endsWith('.ppk')) {
322
+ throw new Error((0, i18n_1.t)('publishUsage'));
354
323
  }
355
- const platform = await (0, _app.getPlatform)(options.platform);
324
+ const platform = await (0, app_1.getPlatform)(options.platform);
356
325
  let appId = options.appId;
357
326
  if (!appId) {
358
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
359
- }
360
- const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
361
- const { hash } = await (0, _api.uploadFile)(fn);
362
- const versionName = name || (nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionNameQuestion'))) || (0, _i18n.t)('unnamed');
363
- const { id } = await (0, _api.post)(`/app/${appId}/version/create`, {
327
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
328
+ }
329
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
330
+ const { hash } = await (0, api_1.uploadFile)(fn, undefined, appId);
331
+ const versionName = name ||
332
+ (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionNameQuestion'))) ||
333
+ (0, i18n_1.t)('unnamed');
334
+ const { id } = await (0, api_1.post)(`/app/${appId}/version/create`, {
364
335
  name: versionName,
365
336
  hash,
366
- description: description != null ? description : nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionDescriptionQuestion')),
367
- metaInfo: metaInfo != null ? metaInfo : nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionMetaInfoQuestion')),
368
- deps: _depversions.depVersions,
369
- commit: await (0, _git.getCommitInfo)()
337
+ description: description ??
338
+ (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionDescriptionQuestion'))),
339
+ metaInfo: metaInfo ??
340
+ (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionMetaInfoQuestion'))),
341
+ deps: dep_versions_1.depVersions,
342
+ commit: await (0, git_1.getCommitInfo)(),
370
343
  });
371
- console.log((0, _i18n.t)('packageUploadSuccess', {
372
- id
373
- }));
374
- const { packageId, packageVersion, packageVersionRange, minPackageVersion, maxPackageVersion, rollout, dryRun } = options;
375
- if (packageId || packageVersion || packageVersionRange || minPackageVersion || maxPackageVersion) {
376
- await versionCommands.update({
344
+ console.log((0, i18n_1.t)('packageUploadSuccess', { id }));
345
+ const { packageId, packageVersion, packageVersionRange, minPackageVersion, maxPackageVersion, rollout, dryRun, } = options;
346
+ if (packageId ||
347
+ packageVersion ||
348
+ packageVersionRange ||
349
+ minPackageVersion ||
350
+ maxPackageVersion) {
351
+ await exports.versionCommands.update({
377
352
  options: {
378
353
  versionId: id,
379
354
  platform,
@@ -384,48 +359,50 @@ const versionCommands = {
384
359
  maxPackageVersion,
385
360
  rollout,
386
361
  dryRun,
387
- versionDeps: _depversions.depVersions,
388
- warnDepsChanges: true
389
- }
362
+ versionDeps: dep_versions_1.depVersions,
363
+ warnDepsChanges: true,
364
+ },
390
365
  });
391
- } else if (!nonInteractive) {
392
- const q = await (0, _utils.question)((0, _i18n.t)('updateNativePackageQuestion'));
366
+ }
367
+ else if (!nonInteractive) {
368
+ const q = await (0, utils_1.question)((0, i18n_1.t)('updateNativePackageQuestion'));
393
369
  if (q.toLowerCase() === 'y') {
394
- await versionCommands.update({
370
+ await exports.versionCommands.update({
395
371
  options: {
396
372
  versionId: id,
397
373
  platform,
398
- versionDeps: _depversions.depVersions,
399
- warnDepsChanges: true
400
- }
374
+ versionDeps: dep_versions_1.depVersions,
375
+ warnDepsChanges: true,
376
+ },
401
377
  });
402
378
  }
403
379
  }
404
380
  return versionName;
405
381
  },
406
- versions: async ({ options })=>{
382
+ versions: async ({ options }) => {
407
383
  let appId = options.appId;
408
384
  if (!appId) {
409
- const platform = await (0, _app.getPlatform)(options.platform);
410
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
385
+ const platform = await (0, app_1.getPlatform)(options.platform);
386
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
411
387
  }
412
- const interactive = !((0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)());
388
+ const interactive = !((0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)());
413
389
  await listVersions(String(appId), interactive);
414
390
  },
415
- update: async ({ options })=>{
416
- const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
391
+ update: async ({ options }) => {
392
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
417
393
  let appId = options.appId;
418
394
  let platform = options.platform;
419
395
  if (!appId) {
420
- platform = await (0, _app.getPlatform)(platform);
421
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
422
- } else if (platform) {
423
- platform = await (0, _app.getPlatform)(platform);
396
+ platform = await (0, app_1.getPlatform)(platform);
397
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
398
+ }
399
+ else if (platform) {
400
+ platform = await (0, app_1.getPlatform)(platform);
424
401
  }
425
402
  let versionId = options.versionId;
426
403
  if (!versionId) {
427
404
  if (nonInteractive) {
428
- throw new Error((0, _i18n.t)('versionIdRequired'));
405
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
429
406
  }
430
407
  versionId = String((await chooseVersion(String(appId))).id);
431
408
  }
@@ -441,77 +418,64 @@ const versionCommands = {
441
418
  if (options.rollout !== undefined) {
442
419
  rollout = Number.parseInt(String(options.rollout), 10);
443
420
  if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
444
- throw new Error((0, _i18n.t)('rolloutRangeError'));
421
+ throw new Error((0, i18n_1.t)('rolloutRangeError'));
445
422
  }
446
423
  }
447
- const allPkgs = await (0, _api.getAllPackages)(String(appId));
424
+ const allPkgs = await (0, api_1.getAllPackages)(String(appId));
448
425
  if (!allPkgs) {
449
- throw new Error((0, _i18n.t)('noPackagesFound', {
450
- appId
451
- }));
426
+ throw new Error((0, i18n_1.t)('noPackagesFound', { appId }));
452
427
  }
453
- const pkgMap = new Map(allPkgs.map((pkg)=>[
454
- String(pkg.id),
455
- pkg
456
- ]));
428
+ const pkgMap = new Map(allPkgs.map((pkg) => [String(pkg.id), pkg]));
457
429
  let pkgsToBind = [];
458
430
  if (minPkgVersion) {
459
431
  minPkgVersion = String(minPkgVersion).trim();
460
- pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.compare)(pkg.name, minPkgVersion, '>='));
432
+ pkgsToBind = allPkgs.filter((pkg) => (0, compare_versions_1.compare)(pkg.name, minPkgVersion, '>='));
461
433
  if (pkgsToBind.length === 0) {
462
- throw new Error((0, _i18n.t)('nativeVersionNotFoundGte', {
463
- version: minPkgVersion
464
- }));
434
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundGte', { version: minPkgVersion }));
465
435
  }
466
- } else if (maxPkgVersion) {
436
+ }
437
+ else if (maxPkgVersion) {
467
438
  maxPkgVersion = String(maxPkgVersion).trim();
468
- pkgsToBind = allPkgs.filter((pkg)=>{
469
- return (0, _compareversions.compare)(pkg.name, maxPkgVersion, '<=');
439
+ pkgsToBind = allPkgs.filter((pkg) => {
440
+ return (0, compare_versions_1.compare)(pkg.name, maxPkgVersion, '<=');
470
441
  });
471
442
  if (pkgsToBind.length === 0) {
472
- throw new Error((0, _i18n.t)('nativeVersionNotFoundLte', {
473
- version: maxPkgVersion
474
- }));
443
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundLte', { version: maxPkgVersion }));
475
444
  }
476
- } else if (pkgVersion) {
445
+ }
446
+ else if (pkgVersion) {
477
447
  pkgVersion = pkgVersion.trim();
478
- const pkg = allPkgs.find((pkg)=>pkg.name === pkgVersion);
448
+ const pkg = allPkgs.find((pkg) => pkg.name === pkgVersion);
479
449
  if (pkg) {
480
- pkgsToBind = [
481
- pkg
482
- ];
483
- } else {
484
- throw new Error((0, _i18n.t)('nativeVersionNotFoundMatch', {
485
- version: pkgVersion
486
- }));
450
+ pkgsToBind = [pkg];
487
451
  }
488
- } else if (packageVersionRange) {
452
+ else {
453
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundMatch', { version: pkgVersion }));
454
+ }
455
+ }
456
+ else if (packageVersionRange) {
489
457
  packageVersionRange = packageVersionRange.trim();
490
- pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.satisfies)(pkg.name, packageVersionRange));
458
+ pkgsToBind = allPkgs.filter((pkg) => (0, compare_versions_1.satisfies)(pkg.name, packageVersionRange));
491
459
  if (pkgsToBind.length === 0) {
492
- throw new Error((0, _i18n.t)('nativeVersionNotFoundMatch', {
493
- version: packageVersionRange
494
- }));
460
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundMatch', { version: packageVersionRange }));
495
461
  }
496
- } else {
462
+ }
463
+ else {
497
464
  if (!pkgId) {
498
465
  if (nonInteractive) {
499
- throw new Error((0, _i18n.t)('packageIdRequired'));
466
+ throw new Error((0, i18n_1.t)('packageIdRequired'));
500
467
  }
501
- pkgId = String((await (0, _package.choosePackage)(String(appId))).id);
468
+ pkgId = String((await (0, package_1.choosePackage)(String(appId))).id);
502
469
  }
503
470
  if (!pkgId) {
504
- throw new Error((0, _i18n.t)('packageIdRequired'));
471
+ throw new Error((0, i18n_1.t)('packageIdRequired'));
505
472
  }
506
473
  const pkg = pkgMap.get(String(pkgId));
507
474
  if (pkg) {
508
- pkgsToBind = [
509
- pkg
510
- ];
511
- } else {
512
- throw new Error((0, _i18n.t)('nativePackageIdNotFound', {
513
- id: pkgId
514
- }));
475
+ pkgsToBind = [pkg];
476
+ }
477
+ else {
478
+ throw new Error((0, i18n_1.t)('nativePackageIdNotFound', { id: pkgId }));
515
479
  }
516
480
  }
517
481
  if (options.warnDepsChanges && versionId) {
@@ -519,81 +483,83 @@ const versionCommands = {
519
483
  appId: String(appId),
520
484
  versionId: String(versionId),
521
485
  pkgs: pkgsToBind,
522
- providedVersionDeps: options.versionDeps
486
+ providedVersionDeps: options.versionDeps,
523
487
  });
524
488
  }
525
- await bindVersionToPackages({
489
+ await (0, exports.bindVersionToPackages)({
526
490
  appId: String(appId),
527
491
  // keep null as-is: `--versionId null` means unbinding the version
528
- versionId: versionId != null ? versionId : null,
492
+ versionId: versionId ?? null,
529
493
  pkgs: pkgsToBind,
530
494
  rollout,
531
- dryRun: options.dryRun
495
+ dryRun: options.dryRun,
532
496
  });
533
497
  },
534
- updateVersionInfo: async ({ options })=>{
535
- const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
498
+ updateVersionInfo: async ({ options, }) => {
499
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
536
500
  let appId = options.appId;
537
501
  let platform = options.platform;
538
502
  if (!appId) {
539
- platform = await (0, _app.getPlatform)(platform);
540
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
541
- } else if (platform) {
542
- await (0, _app.getPlatform)(platform);
503
+ platform = await (0, app_1.getPlatform)(platform);
504
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
505
+ }
506
+ else if (platform) {
507
+ await (0, app_1.getPlatform)(platform);
543
508
  }
544
509
  let versionId = options.versionId;
545
510
  if (!versionId) {
546
511
  if (nonInteractive) {
547
- throw new Error((0, _i18n.t)('versionIdRequired'));
512
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
548
513
  }
549
514
  versionId = String((await chooseVersion(String(appId))).id);
550
515
  }
551
516
  const updateParams = {};
552
- if (options.name) updateParams.name = options.name;
553
- if (options.description) updateParams.description = options.description;
554
- if (options.metaInfo) updateParams.metaInfo = options.metaInfo;
555
- await (0, _api.put)(`/app/${String(appId)}/version/${versionId}`, updateParams);
556
- console.log((0, _i18n.t)('operationSuccess'));
517
+ if (options.name)
518
+ updateParams.name = options.name;
519
+ if (options.description)
520
+ updateParams.description = options.description;
521
+ if (options.metaInfo)
522
+ updateParams.metaInfo = options.metaInfo;
523
+ await (0, api_1.put)(`/app/${String(appId)}/version/${versionId}`, updateParams);
524
+ console.log((0, i18n_1.t)('operationSuccess'));
557
525
  },
558
- deleteVersion: async ({ options })=>{
559
- var _getStringListOption;
560
- const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
526
+ deleteVersion: async ({ options }) => {
527
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
561
528
  let appId = options.appId;
562
529
  if (!appId) {
563
- const platform = await (0, _app.getPlatform)(options.platform);
564
- appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
530
+ const platform = await (0, app_1.getPlatform)(options.platform);
531
+ appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
565
532
  }
566
- const parsedVersionIds = (_getStringListOption = (0, _options.getStringListOption)(options, 'versionIds')) != null ? _getStringListOption : (0, _options.getStringListOption)(options, 'versionId');
533
+ const parsedVersionIds = (0, options_1.getStringListOption)(options, 'versionIds') ??
534
+ (0, options_1.getStringListOption)(options, 'versionId');
567
535
  let versionIds = parsedVersionIds;
568
536
  if (!versionIds) {
569
537
  if (nonInteractive) {
570
- throw new Error((0, _i18n.t)('versionIdRequired'));
538
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
571
539
  }
572
- versionIds = [
573
- String((await chooseVersion(String(appId))).id)
574
- ];
540
+ versionIds = [String((await chooseVersion(String(appId))).id)];
575
541
  }
576
542
  try {
577
543
  if (versionIds.length === 1) {
578
544
  const [versionId] = versionIds;
579
- await (0, _api.doDelete)(`/app/${String(appId)}/version/${versionId}`);
580
- console.log((0, _i18n.t)('deleteVersionSuccess', {
581
- versionId
582
- }));
583
- } else {
584
- await (0, _api.doDelete)(`/app/${String(appId)}/version`, {
585
- versionIds: toNumericIds(versionIds)
545
+ await (0, api_1.doDelete)(`/app/${String(appId)}/version/${versionId}`);
546
+ console.log((0, i18n_1.t)('deleteVersionSuccess', { versionId }));
547
+ }
548
+ else {
549
+ await (0, api_1.doDelete)(`/app/${String(appId)}/version`, {
550
+ versionIds: toNumericIds(versionIds),
586
551
  });
587
- console.log((0, _i18n.t)('deleteVersionsSuccess', {
552
+ console.log((0, i18n_1.t)('deleteVersionsSuccess', {
588
553
  count: versionIds.length,
589
- versionIds: versionIds.join(', ')
554
+ versionIds: versionIds.join(', '),
590
555
  }));
591
556
  }
592
- } catch (error) {
593
- throw new Error((0, _i18n.t)('deleteVersionError', {
557
+ }
558
+ catch (error) {
559
+ throw new Error((0, i18n_1.t)('deleteVersionError', {
594
560
  versionId: versionIds.join(', '),
595
- error: error.message
561
+ error: error.message,
596
562
  }));
597
563
  }
598
- }
564
+ },
599
565
  };