react-native-update-cli 2.29.0 → 2.29.2

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 (85) hide show
  1. package/lib/account.js +2 -4
  2. package/lib/api.d.ts +1 -1
  3. package/lib/api.js +35 -73
  4. package/lib/app.js +13 -27
  5. package/lib/auto-update.d.ts +1 -1
  6. package/lib/auto-update.js +6 -16
  7. package/lib/bin.js +4 -6
  8. package/lib/bundle-pack.js +26 -60
  9. package/lib/bundle-runner.js +89 -119
  10. package/lib/bundle.js +18 -26
  11. package/lib/diff.js +43 -133
  12. package/lib/locales/en.d.ts +0 -10
  13. package/lib/locales/en.js +0 -10
  14. package/lib/locales/zh.d.ts +0 -10
  15. package/lib/locales/zh.js +0 -10
  16. package/lib/native-package.js +27 -99
  17. package/lib/package.d.ts +6 -1
  18. package/lib/package.js +56 -108
  19. package/lib/provider.js +3 -5
  20. package/lib/symbolicate.js +1 -16
  21. package/lib/utils/add-gitignore.js +0 -1
  22. package/lib/utils/app-info-parser/aab.d.ts +5 -22
  23. package/lib/utils/app-info-parser/aab.js +89 -226
  24. package/lib/utils/app-info-parser/apk.d.ts +12 -13
  25. package/lib/utils/app-info-parser/apk.js +28 -78
  26. package/lib/utils/app-info-parser/ipa.d.ts +2 -14
  27. package/lib/utils/app-info-parser/ipa.js +9 -70
  28. package/lib/utils/app-info-parser/resource-finder.d.ts +1 -34
  29. package/lib/utils/app-info-parser/resource-finder.js +95 -234
  30. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
  31. package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
  32. package/lib/utils/app-info-parser/zip.d.ts +6 -24
  33. package/lib/utils/app-info-parser/zip.js +19 -86
  34. package/lib/utils/check-plugin.d.ts +7 -5
  35. package/lib/utils/check-plugin.js +15 -25
  36. package/lib/utils/dep-versions.d.ts +0 -6
  37. package/lib/utils/dep-versions.js +2 -27
  38. package/lib/utils/failure-fingerprint.js +3 -4
  39. package/lib/utils/fs-helpers.d.ts +18 -0
  40. package/lib/utils/fs-helpers.js +84 -0
  41. package/lib/utils/git.d.ts +0 -1
  42. package/lib/utils/git.js +0 -8
  43. package/lib/utils/hash.d.ts +3 -0
  44. package/lib/utils/hash.js +19 -0
  45. package/lib/utils/hbcTransform.d.ts +9 -2
  46. package/lib/utils/hbcTransform.js +41 -70
  47. package/lib/utils/hermes-base.d.ts +1 -5
  48. package/lib/utils/hermes-base.js +136 -196
  49. package/lib/utils/hermes-literals.d.ts +5 -3
  50. package/lib/utils/hermes-literals.js +30 -53
  51. package/lib/utils/hermes-raw.d.ts +7 -0
  52. package/lib/utils/hermes-raw.js +26 -9
  53. package/lib/utils/http-helper.d.ts +0 -1
  54. package/lib/utils/http-helper.js +0 -20
  55. package/lib/utils/i18n.js +0 -2
  56. package/lib/utils/index.d.ts +5 -19
  57. package/lib/utils/index.js +95 -189
  58. package/lib/utils/latest-version.d.ts +19 -0
  59. package/lib/utils/latest-version.js +137 -0
  60. package/lib/utils/options.d.ts +2 -1
  61. package/lib/utils/options.js +5 -7
  62. package/lib/utils/runtime.d.ts +1 -1
  63. package/lib/utils/runtime.js +2 -10
  64. package/lib/utils/upload-request.d.ts +33 -0
  65. package/lib/utils/upload-request.js +120 -0
  66. package/lib/utils/zip-entries.d.ts +23 -0
  67. package/lib/utils/zip-entries.js +130 -139
  68. package/lib/utils/zip-options.js +29 -56
  69. package/lib/utils/zip-range.js +29 -69
  70. package/lib/utils/zip-raw-writer.js +6 -5
  71. package/lib/versions.d.ts +5 -0
  72. package/lib/versions.js +86 -153
  73. package/package.json +1 -9
  74. package/lib/utils/app-info-parser/app.d.ts +0 -4
  75. package/lib/utils/app-info-parser/app.js +0 -10
  76. package/lib/utils/app-info-parser/index.d.ts +0 -16
  77. package/lib/utils/app-info-parser/index.js +0 -46
  78. package/lib/utils/app-info-parser/utils.d.ts +0 -31
  79. package/lib/utils/app-info-parser/utils.js +0 -135
  80. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
  81. package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
  82. package/lib/utils/latest-version/index.d.ts +0 -149
  83. package/lib/utils/latest-version/index.js +0 -326
  84. package/lib/utils/plugin-config.d.ts +0 -9
  85. package/lib/utils/plugin-config.js +0 -61
@@ -23,7 +23,7 @@ exports.readRemoteZipEntry = readRemoteZipEntry;
23
23
  // `openRemoteZip` read just the bundle of a remote archive through HTTP Range
24
24
  // requests instead of downloading the whole ppk / apk / ipa. Every helper
25
25
  // throws on anything unexpected; callers fall back to a full download.
26
- const fs_extra_1 = __importDefault(require("fs-extra"));
26
+ const fs_1 = __importDefault(require("fs"));
27
27
  const stream_1 = require("stream");
28
28
  const yauzl_1 = require("yauzl");
29
29
  const zlib_1 = require("zlib");
@@ -49,7 +49,7 @@ const HINT_SLACK_BYTES = 4 * 1024;
49
49
  const HEAD_PROBE_BYTES = 4 * 1024;
50
50
  /** Data location of the first entry matching `matches` in a local zip. */
51
51
  async function locateZipEntry(zipPath, matches) {
52
- const found = await openFirstEntry(zipPath, matches);
52
+ const found = await (0, zip_entries_1.openFirstEntry)(zipPath, matches);
53
53
  if (!found)
54
54
  return null;
55
55
  found.zipFile.close();
@@ -61,7 +61,7 @@ async function locateZipEntry(zipPath, matches) {
61
61
  * report to the server).
62
62
  */
63
63
  async function readZipEntryWithLocation(zipPath, matches) {
64
- const found = await openFirstEntry(zipPath, matches);
64
+ const found = await (0, zip_entries_1.openFirstEntry)(zipPath, matches);
65
65
  if (!found)
66
66
  return null;
67
67
  let data;
@@ -73,68 +73,45 @@ async function readZipEntryWithLocation(zipPath, matches) {
73
73
  }
74
74
  return { data, location: await locationOfEntry(zipPath, found.entry) };
75
75
  }
76
+ /** Where an entry's data starts, from its local file header at `headerOffset`. */
77
+ function dataOffsetFromLocalHeader(header, headerOffset) {
78
+ if (header.readUInt32LE(0) !== LOCAL_HEADER_SIGNATURE) {
79
+ throw new Error('invalid local file header signature');
80
+ }
81
+ // fixed header, then the file name and extra field lengths it declares
82
+ return (headerOffset +
83
+ LOCAL_HEADER_SIZE +
84
+ header.readUInt16LE(26) +
85
+ header.readUInt16LE(28));
86
+ }
87
+ function assertValidLocation({ dataOffset, compressedSize, }) {
88
+ if (!Number.isInteger(dataOffset) ||
89
+ !Number.isInteger(compressedSize) ||
90
+ dataOffset < 0 ||
91
+ compressedSize <= 0) {
92
+ throw new Error('invalid bundle location');
93
+ }
94
+ }
76
95
  async function locationOfEntry(zipPath, entry) {
77
96
  const header = Buffer.alloc(LOCAL_HEADER_SIZE);
78
- const fd = await fs_extra_1.default.open(zipPath, 'r');
97
+ const handle = await fs_1.default.promises.open(zipPath, 'r');
79
98
  try {
80
- const { bytesRead } = await fs_extra_1.default.read(fd, header, 0, LOCAL_HEADER_SIZE, entry.relativeOffsetOfLocalHeader);
99
+ const { bytesRead } = await handle.read(header, 0, LOCAL_HEADER_SIZE, entry.relativeOffsetOfLocalHeader);
81
100
  if (bytesRead !== LOCAL_HEADER_SIZE) {
82
101
  throw new Error('truncated local file header');
83
102
  }
84
103
  }
85
104
  finally {
86
- await fs_extra_1.default.close(fd);
87
- }
88
- if (header.readUInt32LE(0) !== LOCAL_HEADER_SIGNATURE) {
89
- throw new Error('invalid local file header signature');
105
+ await handle.close();
90
106
  }
91
- const fileNameLength = header.readUInt16LE(26);
92
- const extraFieldLength = header.readUInt16LE(28);
93
107
  return {
94
108
  fileName: entry.fileName,
95
- dataOffset: entry.relativeOffsetOfLocalHeader +
96
- LOCAL_HEADER_SIZE +
97
- fileNameLength +
98
- extraFieldLength,
109
+ dataOffset: dataOffsetFromLocalHeader(header, entry.relativeOffsetOfLocalHeader),
99
110
  compressedSize: entry.compressedSize,
100
111
  uncompressedSize: entry.uncompressedSize,
101
112
  compressionMethod: entry.compressionMethod,
102
113
  };
103
114
  }
104
- /** Open a local zip and stop at the first matching entry (caller closes). */
105
- function openFirstEntry(zipPath, matches) {
106
- return new Promise((resolve, reject) => {
107
- (0, yauzl_1.open)(zipPath, { lazyEntries: true, autoClose: false }, (err, zipFile) => {
108
- if (err)
109
- return reject(err);
110
- let settled = false;
111
- zipFile.on('error', (error) => {
112
- if (!settled) {
113
- settled = true;
114
- reject(error);
115
- }
116
- });
117
- zipFile.on('end', () => {
118
- if (!settled) {
119
- settled = true;
120
- zipFile.close();
121
- resolve(null);
122
- }
123
- });
124
- zipFile.on('entry', (entry) => {
125
- if (settled)
126
- return;
127
- if (matches(entry.fileName)) {
128
- settled = true;
129
- resolve({ zipFile, entry });
130
- return;
131
- }
132
- zipFile.readEntry();
133
- });
134
- zipFile.readEntry();
135
- });
136
- });
137
- }
138
115
  /**
139
116
  * The `bundleOffset` / `bundleCompressedSize` / `bundleCompression` fields for
140
117
  * version/create and package/create, or nothing when the entry cannot be
@@ -265,12 +242,7 @@ async function fetchZipEntryData(url, location, options = {}) {
265
242
  if (compressionMethod !== exports.ZIP_STORED && compressionMethod !== exports.ZIP_DEFLATED) {
266
243
  throw new Error(`unsupported compression method ${compressionMethod}`);
267
244
  }
268
- if (!Number.isInteger(dataOffset) ||
269
- !Number.isInteger(compressedSize) ||
270
- dataOffset < 0 ||
271
- compressedSize <= 0) {
272
- throw new Error('invalid bundle location');
273
- }
245
+ assertValidLocation(location);
274
246
  const { data, total } = await fetchRangeBuffer(url, dataOffset, dataOffset + compressedSize, { timeoutMs: timeoutFor(compressedSize, options) });
275
247
  return {
276
248
  data: compressionMethod === exports.ZIP_DEFLATED ? (0, zlib_1.inflateRawSync)(data) : data,
@@ -302,12 +274,7 @@ function headProbeSize(compressedSize, compressionMethod, bytes) {
302
274
  */
303
275
  async function fetchZipEntryHead(url, location, bytes, options = {}) {
304
276
  const { dataOffset, compressedSize, compressionMethod } = location;
305
- if (!Number.isInteger(dataOffset) ||
306
- !Number.isInteger(compressedSize) ||
307
- dataOffset < 0 ||
308
- compressedSize <= 0) {
309
- throw new Error('invalid bundle location');
310
- }
277
+ assertValidLocation(location);
311
278
  const size = headProbeSize(compressedSize, compressionMethod, bytes);
312
279
  const { data } = await fetchRangeBuffer(url, dataOffset, dataOffset + size, {
313
280
  timeoutMs: timeoutFor(size, options),
@@ -599,14 +566,7 @@ function readAt(reader, position, length) {
599
566
  /** The first `bytes` of `entry`, read through `reader` without its body. */
600
567
  async function remoteEntryHead(reader, entry, bytes) {
601
568
  const start = entry.relativeOffsetOfLocalHeader;
602
- const header = await readAt(reader, start, LOCAL_HEADER_SIZE);
603
- if (header.readUInt32LE(0) !== LOCAL_HEADER_SIGNATURE) {
604
- throw new Error('invalid local file header signature');
605
- }
606
- const dataOffset = start +
607
- LOCAL_HEADER_SIZE +
608
- header.readUInt16LE(26) +
609
- header.readUInt16LE(28);
569
+ const dataOffset = dataOffsetFromLocalHeader(await readAt(reader, start, LOCAL_HEADER_SIZE), start);
610
570
  const size = headProbeSize(entry.compressedSize, entry.compressionMethod, bytes);
611
571
  if (size <= 0)
612
572
  return Buffer.alloc(0);
@@ -12,7 +12,8 @@ exports.crc32Update = crc32Update;
12
12
  // a second deflate of every asset (yazl can only add uncompressed data and
13
13
  // re-deflates it). Plain zip only: no zip64, no data descriptors, no extra
14
14
  // fields; callers must check `fitsRawZip` before choosing this writer.
15
- const fs_extra_1 = __importDefault(require("fs-extra"));
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const fs_helpers_1 = require("./fs-helpers");
16
17
  const LOCAL_HEADER_SIGNATURE = 0x04034b50;
17
18
  const CENTRAL_HEADER_SIGNATURE = 0x02014b50;
18
19
  const EOCD_SIGNATURE = 0x06054b50;
@@ -67,7 +68,7 @@ class RawZipWriter {
67
68
  closed;
68
69
  constructor(output) {
69
70
  this.output = output;
70
- this.out = fs_extra_1.default.createWriteStream(output);
71
+ this.out = fs_1.default.createWriteStream(output);
71
72
  this.closed = new Promise((resolve, reject) => {
72
73
  this.out.once('close', resolve);
73
74
  this.out.once('error', (error) => {
@@ -148,7 +149,7 @@ class RawZipWriter {
148
149
  async addStoredFile(filePath, fileName, like) {
149
150
  let crc = 0;
150
151
  let size = 0;
151
- for await (const chunk of fs_extra_1.default.createReadStream(filePath)) {
152
+ for await (const chunk of fs_1.default.createReadStream(filePath)) {
152
153
  crc = crc32Update(crc, chunk);
153
154
  size += chunk.length;
154
155
  }
@@ -162,7 +163,7 @@ class RawZipWriter {
162
163
  lastModFileDate: like?.lastModFileDate ?? 0x21, // 1980-01-01
163
164
  externalFileAttributes: like?.externalFileAttributes,
164
165
  versionMadeBy: like?.versionMadeBy,
165
- }, fs_extra_1.default.createReadStream(filePath));
166
+ }, fs_1.default.createReadStream(filePath));
166
167
  }
167
168
  /** Write the central directory and close the file. */
168
169
  async end() {
@@ -190,7 +191,7 @@ class RawZipWriter {
190
191
  async abort() {
191
192
  this.out.destroy();
192
193
  await this.closed.catch(() => { });
193
- await fs_extra_1.default.remove(this.output).catch(() => { });
194
+ await (0, fs_helpers_1.remove)(this.output).catch(() => { });
194
195
  }
195
196
  write(chunk) {
196
197
  if (this.failure)
package/lib/versions.d.ts CHANGED
@@ -27,6 +27,11 @@ interface VersionCommandOptions {
27
27
  type Deps = Record<string, string>;
28
28
  export declare function normalizeDeps(input: unknown): Deps | undefined;
29
29
  export declare function fetchVersions(appId: string, offset?: number, limit?: number): Promise<Version[]>;
30
+ /**
31
+ * The first version matching `predicate`, paging through the list newest
32
+ * first (crashes and binds are usually about recent versions).
33
+ */
34
+ export declare function findVersion(appId: string, predicate: (version: Version) => boolean): Promise<Version | undefined>;
30
35
  export declare const bindVersionToPackages: ({ appId, versionId, pkgs, rollout, dryRun, }: {
31
36
  appId: string;
32
37
  versionId: string | null;
package/lib/versions.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.versionCommands = exports.describePpkBundleForTests = exports.bindVersionToPackages = void 0;
7
7
  exports.normalizeDeps = normalizeDeps;
8
8
  exports.fetchVersions = fetchVersions;
9
+ exports.findVersion = findVersion;
9
10
  const chalk_1 = __importDefault(require("chalk"));
10
11
  const compare_versions_1 = require("compare-versions");
11
12
  const fs_1 = __importDefault(require("fs"));
@@ -17,6 +18,7 @@ const package_1 = require("./package");
17
18
  const utils_1 = require("./utils");
18
19
  const dep_versions_1 = require("./utils/dep-versions");
19
20
  const git_1 = require("./utils/git");
21
+ const hash_1 = require("./utils/hash");
20
22
  const hermes_base_1 = require("./utils/hermes-base");
21
23
  const i18n_1 = require("./utils/i18n");
22
24
  const options_1 = require("./utils/options");
@@ -55,59 +57,28 @@ function getDepsChanges(oldDeps, newDeps) {
55
57
  for (const key of keys) {
56
58
  const oldVersion = oldDeps[key];
57
59
  const newVersion = newDeps[key];
58
- if (oldVersion === undefined && newVersion !== undefined) {
59
- rows.push({
60
- dependency: key,
61
- oldVersion: '-',
62
- newVersion,
63
- type: 'added',
64
- });
65
- continue;
66
- }
67
- if (oldVersion !== undefined && newVersion === undefined) {
68
- rows.push({
69
- dependency: key,
70
- oldVersion,
71
- newVersion: '-',
72
- type: 'removed',
73
- });
60
+ if (oldVersion === newVersion) {
74
61
  continue;
75
62
  }
76
- if (oldVersion !== undefined &&
77
- newVersion !== undefined &&
78
- oldVersion !== newVersion) {
79
- rows.push({
80
- dependency: key,
81
- oldVersion,
82
- newVersion,
83
- type: 'changed',
84
- });
85
- }
63
+ rows.push({
64
+ dependency: key,
65
+ oldVersion: oldVersion ?? '-',
66
+ newVersion: newVersion ?? '-',
67
+ type: oldVersion === undefined
68
+ ? 'added'
69
+ : newVersion === undefined
70
+ ? 'removed'
71
+ : 'changed',
72
+ });
86
73
  }
87
74
  return rows;
88
75
  }
89
- function toNumericIds(ids) {
90
- return ids.map((id) => {
91
- const numericId = Number(id);
92
- if (!Number.isInteger(numericId) || numericId <= 0) {
93
- throw new Error((0, i18n_1.t)('invalidId', { id }));
94
- }
95
- return numericId;
96
- });
97
- }
98
76
  function getDepsChangeSummary(changes) {
99
- return changes.reduce((acc, item) => {
100
- if (item.type === 'added') {
101
- acc.added += 1;
102
- }
103
- else if (item.type === 'removed') {
104
- acc.removed += 1;
105
- }
106
- else {
107
- acc.changed += 1;
108
- }
109
- return acc;
110
- }, { added: 0, removed: 0, changed: 0 });
77
+ const summary = { added: 0, removed: 0, changed: 0 };
78
+ for (const { type } of changes) {
79
+ summary[type] += 1;
80
+ }
81
+ return summary;
111
82
  }
112
83
  function renderVersionChange(change) {
113
84
  const arrow = chalk_1.default.gray(` ${(0, i18n_1.t)('depsChangeArrow')} `);
@@ -155,24 +126,6 @@ function printDepsChangesForPackage({ pkg, versionDeps, }) {
155
126
  console.log(chalk_1.default.yellow((0, i18n_1.t)('depsChangeRiskWarning')));
156
127
  return true;
157
128
  }
158
- async function findVersionDeps(appId, versionId) {
159
- const targetId = String(versionId);
160
- const limit = 100;
161
- let offset = 0;
162
- while (true) {
163
- const { data, count } = await (0, api_1.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
164
- const versions = Array.isArray(data) ? data : [];
165
- const version = versions.find((item) => String(item.id) === targetId);
166
- if (version) {
167
- return normalizeDeps(version.deps);
168
- }
169
- offset += versions.length;
170
- if (versions.length === 0 || offset >= Number(count || 0)) {
171
- break;
172
- }
173
- }
174
- return undefined;
175
- }
176
129
  async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVersionDeps, }) {
177
130
  if (!versionId || pkgs.length !== 1) {
178
131
  return;
@@ -180,7 +133,8 @@ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVers
180
133
  let versionDeps = normalizeDeps(providedVersionDeps);
181
134
  if (!versionDeps) {
182
135
  try {
183
- versionDeps = await findVersionDeps(appId, versionId);
136
+ const version = await findVersion(appId, (item) => String(item.id) === String(versionId));
137
+ versionDeps = normalizeDeps(version?.deps);
184
138
  }
185
139
  catch (error) {
186
140
  console.warn(chalk_1.default.yellow((0, i18n_1.t)('depsChangeFetchFailed', {
@@ -206,6 +160,33 @@ async function fetchVersions(appId, offset = 0, limit = versionPageLimit) {
206
160
  const { data } = await (0, api_1.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
207
161
  return Array.isArray(data) ? data : [];
208
162
  }
163
+ /**
164
+ * The first version matching `predicate`, paging through the list newest
165
+ * first (crashes and binds are usually about recent versions).
166
+ */
167
+ async function findVersion(appId, predicate) {
168
+ const limit = 100;
169
+ for (let offset = 0; offset < 100 * limit; offset += limit) {
170
+ const page = await fetchVersions(appId, offset, limit);
171
+ const found = page.find(predicate);
172
+ if (found || page.length < limit) {
173
+ return found;
174
+ }
175
+ }
176
+ return undefined;
177
+ }
178
+ /** The offset after a U(p) / D(own) / B(egin) paging command, else undefined. */
179
+ function pageOffset(cmd, offset) {
180
+ switch (cmd.toLowerCase()) {
181
+ case 'u':
182
+ return Math.max(0, offset - versionPageLimit);
183
+ case 'd':
184
+ return offset + versionPageLimit;
185
+ case 'b':
186
+ return 0;
187
+ }
188
+ return undefined;
189
+ }
209
190
  async function showVersion(appId, offset) {
210
191
  const data = await fetchVersions(appId, offset, versionPageLimit);
211
192
  console.log((0, i18n_1.t)('offset', { offset }));
@@ -239,21 +220,10 @@ async function listVersions(appId, interactive = true) {
239
220
  return data;
240
221
  }
241
222
  const cmd = await (0, utils_1.question)('page Up/page Down/Begin/Quit(U/D/B/Q)');
242
- switch (cmd.toLowerCase()) {
243
- case 'u':
244
- offset = Math.max(0, offset - 10);
245
- break;
246
- case 'd':
247
- offset += 10;
248
- break;
249
- case 'b':
250
- offset = 0;
251
- break;
252
- case 'q':
253
- return data;
254
- case '':
255
- return data;
223
+ if (cmd === '' || cmd.toLowerCase() === 'q') {
224
+ return data;
256
225
  }
226
+ offset = pageOffset(cmd, offset) ?? offset;
257
227
  }
258
228
  }
259
229
  async function chooseVersion(appId) {
@@ -264,25 +234,30 @@ async function chooseVersion(appId) {
264
234
  throw new Error((0, i18n_1.t)('versionIdRequired'));
265
235
  }
266
236
  const cmd = await (0, utils_1.question)('Enter versionId or page Up/page Down/Begin(U/D/B)');
267
- switch (cmd.toUpperCase()) {
268
- case 'U':
269
- offset = Math.max(0, offset - 10);
270
- break;
271
- case 'D':
272
- offset += 10;
273
- break;
274
- case 'B':
275
- offset = 0;
276
- break;
277
- default: {
278
- const versionId = Number.parseInt(cmd, 10);
279
- const v = data.find((version) => String(version.id) === String(versionId));
280
- if (v) {
281
- return v;
282
- }
283
- }
237
+ const nextOffset = pageOffset(cmd, offset);
238
+ if (nextOffset !== undefined) {
239
+ offset = nextOffset;
240
+ continue;
284
241
  }
242
+ const versionId = Number.parseInt(cmd, 10);
243
+ const v = data.find((version) => String(version.id) === String(versionId));
244
+ if (v) {
245
+ return v;
246
+ }
247
+ }
248
+ }
249
+ function isNonInteractiveFor(options) {
250
+ return ((0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)());
251
+ }
252
+ /** `versionId` when given, else one picked from the list (interactive only). */
253
+ async function versionIdOrChoose(appId, versionId, options) {
254
+ if (versionId) {
255
+ return versionId;
256
+ }
257
+ if (isNonInteractiveFor(options)) {
258
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
285
259
  }
260
+ return String((await chooseVersion(appId)).id);
286
261
  }
287
262
  const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun, }) => {
288
263
  if (dryRun) {
@@ -307,7 +282,7 @@ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun,
307
282
  await (0, api_1.post)(`/app/${appId}/binding`, {
308
283
  versionId,
309
284
  rollout,
310
- packageIds: toNumericIds(pkgs.map((pkg) => String(pkg.id))),
285
+ packageIds: (0, package_1.toNumericIds)(pkgs.map((pkg) => String(pkg.id))),
311
286
  });
312
287
  }
313
288
  }
@@ -341,7 +316,7 @@ async function describePpkBundle(ppkPath, base) {
341
316
  : null;
342
317
  const bundle = found?.data ?? (await (0, hermes_base_1.extractBundleFromArchive)(ppkPath));
343
318
  if (bundle) {
344
- const bundleHash = (0, hermes_base_1.sha256Hex)(bundle);
319
+ const bundleHash = (0, hash_1.sha256Hex)(bundle);
345
320
  meta.bundleHash = bundleHash;
346
321
  // 0 for plain JS: the server then never offers it as a Hermes base
347
322
  meta.bytecodeVersion = (0, hermes_base_1.reportedBytecodeVersion)(bundle);
@@ -376,7 +351,7 @@ exports.versionCommands = {
376
351
  }
377
352
  const platform = await (0, app_1.getPlatform)(options.platform);
378
353
  const appId = await (0, app_1.resolveAppId)({ ...options, platform });
379
- const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
354
+ const nonInteractive = isNonInteractiveFor(options);
380
355
  // The source map is archived with the version so `pushy symbolicate` can
381
356
  // map crashes back to source. An explicit path that does not exist is a
382
357
  // publish error; no path at all is a loud warning (custom pipelines that
@@ -411,11 +386,11 @@ exports.versionCommands = {
411
386
  // fail the publish, only lose the archive.
412
387
  let sourceMapUploadError;
413
388
  const [{ hash }, bundleMeta, commit, sourceMapUpload] = await Promise.all([
414
- (0, api_1.uploadFile)(fn, undefined, appId),
389
+ (0, api_1.uploadFile)(fn, appId),
415
390
  describePpkBundle(fn, options.hermesBase),
416
391
  (0, git_1.getCommitInfo)(),
417
392
  uploadSourcemapPath
418
- ? (0, api_1.uploadFile)(uploadSourcemapPath, undefined, appId).catch((error) => {
393
+ ? (0, api_1.uploadFile)(uploadSourcemapPath, appId).catch((error) => {
419
394
  sourceMapUploadError = error;
420
395
  return undefined;
421
396
  })
@@ -498,19 +473,11 @@ exports.versionCommands = {
498
473
  },
499
474
  versions: async ({ options }) => {
500
475
  const appId = await (0, app_1.resolveAppId)(options);
501
- const interactive = !((0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)());
502
- await listVersions(appId, interactive);
476
+ await listVersions(appId, !isNonInteractiveFor(options));
503
477
  },
504
478
  update: async ({ options }) => {
505
- const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
506
479
  const appId = await (0, app_1.resolveAppId)(options);
507
- let versionId = options.versionId;
508
- if (!versionId) {
509
- if (nonInteractive) {
510
- throw new Error((0, i18n_1.t)('versionIdRequired'));
511
- }
512
- versionId = String((await chooseVersion(appId)).id);
513
- }
480
+ let versionId = await versionIdOrChoose(appId, options.versionId, options);
514
481
  if (versionId === 'null') {
515
482
  versionId = null;
516
483
  }
@@ -581,7 +548,7 @@ exports.versionCommands = {
581
548
  }
582
549
  else {
583
550
  if (!pkgId) {
584
- if (nonInteractive) {
551
+ if (isNonInteractiveFor(options)) {
585
552
  throw new Error((0, i18n_1.t)('packageIdRequired'));
586
553
  }
587
554
  // the package list was already fetched above: no second round trip
@@ -616,15 +583,8 @@ exports.versionCommands = {
616
583
  });
617
584
  },
618
585
  updateVersionInfo: async ({ options, }) => {
619
- const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
620
586
  const appId = await (0, app_1.resolveAppId)(options);
621
- let versionId = options.versionId;
622
- if (!versionId) {
623
- if (nonInteractive) {
624
- throw new Error((0, i18n_1.t)('versionIdRequired'));
625
- }
626
- versionId = String((await chooseVersion(appId)).id);
627
- }
587
+ const versionId = await versionIdOrChoose(appId, options.versionId, options);
628
588
  const updateParams = {};
629
589
  if (options.name)
630
590
  updateParams.name = options.name;
@@ -636,38 +596,11 @@ exports.versionCommands = {
636
596
  console.log((0, i18n_1.t)('operationSuccess'));
637
597
  },
638
598
  deleteVersion: async ({ options }) => {
639
- const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
640
599
  const appId = await (0, app_1.resolveAppId)(options);
641
- const parsedVersionIds = (0, options_1.getStringListOption)(options, 'versionIds') ??
642
- (0, options_1.getStringListOption)(options, 'versionId');
643
- let versionIds = parsedVersionIds;
644
- if (!versionIds) {
645
- if (nonInteractive) {
646
- throw new Error((0, i18n_1.t)('versionIdRequired'));
647
- }
648
- versionIds = [String((await chooseVersion(appId)).id)];
649
- }
650
- try {
651
- if (versionIds.length === 1) {
652
- const [versionId] = versionIds;
653
- await (0, api_1.doDelete)(`/app/${appId}/version/${versionId}`);
654
- console.log((0, i18n_1.t)('deleteVersionSuccess', { versionId }));
655
- }
656
- else {
657
- await (0, api_1.doDelete)(`/app/${appId}/version`, {
658
- versionIds: toNumericIds(versionIds),
659
- });
660
- console.log((0, i18n_1.t)('deleteVersionsSuccess', {
661
- count: versionIds.length,
662
- versionIds: versionIds.join(', '),
663
- }));
664
- }
665
- }
666
- catch (error) {
667
- throw new Error((0, i18n_1.t)('deleteVersionError', {
668
- versionId: versionIds.join(', '),
669
- error: error.message,
670
- }));
671
- }
600
+ const versionIds = (0, options_1.getStringListOption)(options, 'versionIds') ??
601
+ (0, options_1.getStringListOption)(options, 'versionId') ?? [
602
+ await versionIdOrChoose(appId, undefined, options),
603
+ ];
604
+ await (0, package_1.deleteByIds)(appId, 'version', versionIds);
672
605
  },
673
606
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.29.0",
3
+ "version": "2.29.2",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "lib/exports.js",
6
6
  "types": "lib/exports.d.ts",
@@ -62,22 +62,16 @@
62
62
  "homepage": "https://github.com/reactnativecn/react-native-update-cli",
63
63
  "dependencies": {
64
64
  "bplist-parser": "^0.3.2",
65
- "bytebuffer": "^5.0.1",
66
- "cgbi-to-png": "^1.0.7",
67
65
  "chalk": "4",
68
66
  "cli-arguments": "^0.2.1",
69
67
  "compare-versions": "^6.1.1",
70
68
  "filesize-parser": "^1.5.2",
71
- "form-data": "^4.0.6",
72
- "fs-extra": "^11.4.0",
73
69
  "global-dirs": "^4.0.0",
74
70
  "gradle-to-js": "^2.0.1",
75
71
  "https-proxy-agent": "^7.0.6",
76
72
  "i18next": "^26.4.0",
77
- "node-fetch": "^2.6.1",
78
73
  "plist": "^5.0.0",
79
74
  "progress": "^2.0.3",
80
- "properties": "^1.2.1",
81
75
  "protobufjs": "^8.7.2",
82
76
  "read": "^4.1.0",
83
77
  "registry-auth-token": "^5.1.1",
@@ -98,9 +92,7 @@
98
92
  "@biomejs/biome": "^2.5.10",
99
93
  "@types/bun": "^1.4.0",
100
94
  "@types/filesize-parser": "^1.5.3",
101
- "@types/fs-extra": "^11.0.4",
102
95
  "@types/node": "^26.3.0",
103
- "@types/node-fetch": "^2.6.13",
104
96
  "@types/progress": "^2.0.7",
105
97
  "@types/yauzl": "^3.4.0",
106
98
  "@types/yazl": "^3.3.1",
@@ -1,4 +0,0 @@
1
- import { Zip } from './zip';
2
- export declare class AppParser extends Zip {
3
- parse(): Promise<Record<string, never>>;
4
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppParser = void 0;
4
- const zip_1 = require("./zip");
5
- class AppParser extends zip_1.Zip {
6
- async parse() {
7
- return {};
8
- }
9
- }
10
- exports.AppParser = AppParser;
@@ -1,16 +0,0 @@
1
- import { AabParser } from './aab';
2
- import { ApkParser } from './apk';
3
- import { AppParser } from './app';
4
- import { IpaParser } from './ipa';
5
- type AppInfoInnerParser = AabParser | ApkParser | AppParser | IpaParser;
6
- declare class AppInfoParser {
7
- file: string | File;
8
- parser: AppInfoInnerParser;
9
- /**
10
- * parser for parsing .ipa or .apk file
11
- * @param {String | File} file // file's path in Node, instance of File in Browser
12
- */
13
- constructor(file: string | File);
14
- parse<T = unknown>(): Promise<T>;
15
- }
16
- export default AppInfoParser;