react-native-update-cli 2.22.7 → 2.22.8

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 (59) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/cli.json +5 -0
  4. package/lib/api.d.ts +7 -0
  5. package/lib/api.js +106 -38
  6. package/lib/app.js +3 -2
  7. package/lib/bin.js +16 -2
  8. package/lib/bundle-runner.d.ts +11 -4
  9. package/lib/bundle-runner.js +176 -90
  10. package/lib/bundle.d.ts +1 -0
  11. package/lib/bundle.js +2 -0
  12. package/lib/diff.d.ts +9 -0
  13. package/lib/diff.js +162 -120
  14. package/lib/locales/en.d.ts +1 -0
  15. package/lib/locales/en.js +1 -0
  16. package/lib/locales/zh.d.ts +1 -0
  17. package/lib/locales/zh.js +1 -0
  18. package/lib/package.d.ts +7 -3
  19. package/lib/package.js +22 -12
  20. package/lib/types.d.ts +2 -0
  21. package/lib/utils/dep-versions.d.ts +7 -0
  22. package/lib/utils/dep-versions.js +66 -31
  23. package/lib/utils/hbcTransform.d.ts +21 -0
  24. package/lib/utils/hbcTransform.js +146 -5
  25. package/lib/utils/hermes-base.d.ts +21 -4
  26. package/lib/utils/hermes-base.js +146 -37
  27. package/lib/utils/http-helper.d.ts +6 -1
  28. package/lib/utils/http-helper.js +23 -11
  29. package/lib/utils/index.d.ts +30 -1
  30. package/lib/utils/index.js +98 -24
  31. package/lib/utils/latest-version/index.d.ts +11 -8
  32. package/lib/utils/latest-version/index.js +63 -18
  33. package/lib/utils/zip-entries.js +20 -15
  34. package/lib/utils/zip-options.d.ts +2 -0
  35. package/lib/utils/zip-options.js +9 -4
  36. package/lib/utils/zip-range.d.ts +47 -15
  37. package/lib/utils/zip-range.js +192 -83
  38. package/lib/versions.js +19 -9
  39. package/package.json +11 -11
  40. package/src/api.ts +126 -46
  41. package/src/app.ts +3 -2
  42. package/src/bin.ts +17 -2
  43. package/src/bundle-runner.ts +225 -113
  44. package/src/bundle.ts +3 -0
  45. package/src/diff.ts +210 -153
  46. package/src/locales/en.ts +2 -0
  47. package/src/locales/zh.ts +2 -0
  48. package/src/package.ts +26 -13
  49. package/src/types.ts +2 -0
  50. package/src/utils/dep-versions.ts +76 -33
  51. package/src/utils/hbcTransform.ts +194 -5
  52. package/src/utils/hermes-base.ts +156 -45
  53. package/src/utils/http-helper.ts +24 -13
  54. package/src/utils/index.ts +136 -26
  55. package/src/utils/latest-version/index.ts +82 -29
  56. package/src/utils/zip-entries.ts +18 -16
  57. package/src/utils/zip-options.ts +8 -3
  58. package/src/utils/zip-range.ts +244 -88
  59. package/src/versions.ts +17 -7
@@ -8,6 +8,7 @@ exports.locateZipEntry = locateZipEntry;
8
8
  exports.readZipEntryWithLocation = readZipEntryWithLocation;
9
9
  exports.bundleLocationFields = bundleLocationFields;
10
10
  exports.parseContentRange = parseContentRange;
11
+ exports.rangeValidator = rangeValidator;
11
12
  exports.fetchZipEntryData = fetchZipEntryData;
12
13
  exports.parseEndOfCentralDirectory = parseEndOfCentralDirectory;
13
14
  exports.openRemoteZip = openRemoteZip;
@@ -144,9 +145,18 @@ function bundleLocationFields(location) {
144
145
  bundleCompression: location.compressionMethod,
145
146
  };
146
147
  }
147
- // ---------------------------------------------------------------------------
148
- // HTTP Range
149
- // ---------------------------------------------------------------------------
148
+ const DEFAULT_HEADER_TIMEOUT_MS = 20_000;
149
+ const DEFAULT_DATA_TIMEOUT_MS = 30_000;
150
+ const DEFAULT_DATA_TIMEOUT_PER_MB_MS = 1_000;
151
+ /** deadline for a request of `bytes`: flat for header-sized reads, scaled otherwise */
152
+ function timeoutFor(bytes, options) {
153
+ if (bytes <= CHUNK_BYTES) {
154
+ return options.headerTimeoutMs ?? DEFAULT_HEADER_TIMEOUT_MS;
155
+ }
156
+ return ((options.dataTimeoutMs ?? DEFAULT_DATA_TIMEOUT_MS) +
157
+ ((options.dataTimeoutPerMbMs ?? DEFAULT_DATA_TIMEOUT_PER_MB_MS) * bytes) /
158
+ (1024 * 1024));
159
+ }
150
160
  /** The server answered a Range request with the whole body (HTTP 200). */
151
161
  class RangeUnsupportedError extends Error {
152
162
  response;
@@ -166,30 +176,72 @@ function parseContentRange(header) {
166
176
  return null;
167
177
  return { start, end, total };
168
178
  }
179
+ /**
180
+ * The validator to send as `If-Range` on later requests for the same object,
181
+ * so a replaced archive answers 200 (handled like a server without Range)
182
+ * instead of mixing bytes of two versions. Weak ETags are not allowed there.
183
+ */
184
+ function rangeValidator(headers) {
185
+ const etag = headers.get('etag')?.trim();
186
+ if (etag && !/^W\//i.test(etag))
187
+ return etag;
188
+ return headers.get('last-modified')?.trim() || undefined;
189
+ }
190
+ /** An aborted fetch as a plain Error (never mistaken for a 200 answer). */
191
+ function describeAbort(error, what, timeoutMs) {
192
+ const name = error?.name;
193
+ if (name === 'TimeoutError' || name === 'AbortError') {
194
+ return new Error(`timed out after ${timeoutMs} ms fetching ${what}`);
195
+ }
196
+ return error instanceof Error ? error : new Error(String(error));
197
+ }
169
198
  /** One Range request; `end` is exclusive. Resolves with a 206 response. */
170
- async function fetchRange(url, start, end) {
171
- const response = await fetch(url, {
172
- headers: {
173
- Range: `bytes=${start}-${end - 1}`,
174
- 'Accept-Encoding': 'identity',
175
- },
176
- });
199
+ async function fetchRange(url, start, end, options) {
200
+ const what = `bytes=${start}-${end - 1}`;
201
+ const headers = {
202
+ Range: what,
203
+ 'Accept-Encoding': 'identity',
204
+ };
205
+ if (options.ifRange)
206
+ headers['If-Range'] = options.ifRange;
207
+ let response;
208
+ try {
209
+ response = await fetch(url, {
210
+ headers,
211
+ signal: AbortSignal.timeout(options.timeoutMs),
212
+ });
213
+ }
214
+ catch (error) {
215
+ throw describeAbort(error, what, options.timeoutMs);
216
+ }
177
217
  if (response.status === 200)
178
218
  throw new RangeUnsupportedError(response);
179
219
  if (response.status !== 206 || !response.body) {
180
220
  await response.body?.cancel().catch(() => { });
181
- throw new Error(`HTTP ${response.status} for bytes=${start}-${end - 1}`);
221
+ throw new Error(`HTTP ${response.status} for ${what}`);
182
222
  }
183
223
  const range = parseContentRange(response.headers.get('content-range'));
184
224
  if (!range || range.start !== start || range.end !== end - 1) {
185
225
  await response.body.cancel().catch(() => { });
186
226
  throw new Error(`unexpected Content-Range ${response.headers.get('content-range')}`);
187
227
  }
228
+ if (options.expectTotal !== undefined &&
229
+ range.total !== options.expectTotal) {
230
+ await response.body.cancel().catch(() => { });
231
+ throw new Error(`archive size changed: ${range.total} bytes, expected ${options.expectTotal}`);
232
+ }
188
233
  return Object.assign(response, { range });
189
234
  }
190
- async function fetchRangeBuffer(url, start, end) {
191
- const response = await fetchRange(url, start, end);
192
- const data = Buffer.from(await response.arrayBuffer());
235
+ async function fetchRangeBuffer(url, start, end, options) {
236
+ const response = await fetchRange(url, start, end, options);
237
+ let data;
238
+ try {
239
+ // Buffer.from(ArrayBuffer) is a view: the body is held exactly once
240
+ data = Buffer.from(await response.arrayBuffer());
241
+ }
242
+ catch (error) {
243
+ throw describeAbort(error, `bytes=${start}-${end - 1}`, options.timeoutMs);
244
+ }
193
245
  if (data.length !== end - start) {
194
246
  throw new Error(`range returned ${data.length} bytes, expected ${end - start}`);
195
247
  }
@@ -199,7 +251,7 @@ async function fetchRangeBuffer(url, start, end) {
199
251
  * Fetch one entry whose compressed bytes are already located (the ppk's own
200
252
  * publish-time report) and decompress it. Returns the raw entry content.
201
253
  */
202
- async function fetchZipEntryData(url, location) {
254
+ async function fetchZipEntryData(url, location, options = {}) {
203
255
  const { dataOffset, compressedSize, compressionMethod } = location;
204
256
  if (compressionMethod !== exports.ZIP_STORED && compressionMethod !== exports.ZIP_DEFLATED) {
205
257
  throw new Error(`unsupported compression method ${compressionMethod}`);
@@ -210,7 +262,7 @@ async function fetchZipEntryData(url, location) {
210
262
  compressedSize <= 0) {
211
263
  throw new Error('invalid bundle location');
212
264
  }
213
- const { data, total } = await fetchRangeBuffer(url, dataOffset, dataOffset + compressedSize);
265
+ const { data, total } = await fetchRangeBuffer(url, dataOffset, dataOffset + compressedSize, { timeoutMs: timeoutFor(compressedSize, options) });
214
266
  return {
215
267
  data: compressionMethod === exports.ZIP_DEFLATED ? (0, zlib_1.inflateRawSync)(data) : data,
216
268
  fetchedBytes: compressedSize,
@@ -219,23 +271,28 @@ async function fetchZipEntryData(url, location) {
219
271
  }
220
272
  /**
221
273
  * yauzl reader over HTTP Range. Header reads (EOCD, central directory, local
222
- * file headers) are widened to CHUNK_BYTES and cached — adjacent or
223
- * overlapping chunks are merged so a read never re-fetches bytes it already
224
- * has — and entry data reuses whatever prefix the cache holds (typically the
225
- * bytes following the local file header) before requesting the rest.
274
+ * file headers) are widened to CHUNK_BYTES and cached. Chunks are kept as
275
+ * fetched — only overlapping ones are merged, touching ones are read across —
276
+ * so an entry's bytes are held once, and a read reuses whatever prefix the
277
+ * cache holds (typically the bytes following the local file header) before
278
+ * requesting the rest. Every request after the first carries If-Range and
279
+ * must report the same archive size.
226
280
  */
227
281
  class HttpRangeReader extends yauzl_1.RandomAccessReader {
228
282
  url;
229
283
  totalSize;
284
+ options;
285
+ /** sorted by `start`, never overlapping */
230
286
  chunks = [];
231
287
  /** span a header read inside it should widen to (see `hintEntry`) */
232
288
  hint = null;
233
289
  requests = 0;
234
290
  fetchedBytes = 0;
235
- constructor(url, totalSize, tail) {
291
+ constructor(url, totalSize, tail, options = {}) {
236
292
  super();
237
293
  this.url = url;
238
294
  this.totalSize = totalSize;
295
+ this.options = options;
239
296
  if (tail)
240
297
  this.addChunk(tail.start, tail.data);
241
298
  }
@@ -255,7 +312,7 @@ class HttpRangeReader extends yauzl_1.RandomAccessReader {
255
312
  HINT_SLACK_BYTES;
256
313
  this.hint = { start, end: Math.min(end, this.totalSize) };
257
314
  }
258
- /** Cache `data` at `start`, merging with any chunk it touches. */
315
+ /** Cache `data` at `start`, merging with any chunk it overlaps. */
259
316
  addChunk(start, data) {
260
317
  if (data.length === 0)
261
318
  return;
@@ -265,7 +322,7 @@ class HttpRangeReader extends yauzl_1.RandomAccessReader {
265
322
  const rest = [];
266
323
  for (const chunk of this.chunks) {
267
324
  const chunkEnd = chunk.start + chunk.data.length;
268
- if (chunk.start <= hi && chunkEnd >= lo) {
325
+ if (chunk.start < hi && chunkEnd > lo) {
269
326
  pieces.push(chunk);
270
327
  lo = Math.min(lo, chunk.start);
271
328
  hi = Math.max(hi, chunkEnd);
@@ -288,83 +345,126 @@ class HttpRangeReader extends yauzl_1.RandomAccessReader {
288
345
  rest.sort((a, b) => a.start - b.start);
289
346
  this.chunks = rest;
290
347
  }
291
- /** cached bytes starting exactly at `start`, up to `end` (may be shorter) */
292
- cachedPrefix(start, end) {
348
+ /** Fetch `[start, end)` into the cache in one request. */
349
+ async prefetch(start, end) {
350
+ this.addChunk(start, await this.fetchBuffer(start, end));
351
+ }
352
+ requestOptions(bytes) {
353
+ return {
354
+ timeoutMs: timeoutFor(bytes, this.options),
355
+ ifRange: this.options.ifRange,
356
+ expectTotal: this.totalSize,
357
+ };
358
+ }
359
+ async fetchBuffer(start, end) {
360
+ this.requests++;
361
+ const { data } = await fetchRangeBuffer(this.url, start, end, this.requestOptions(end - start));
362
+ this.fetchedBytes += data.length;
363
+ return data;
364
+ }
365
+ /**
366
+ * Contiguous cached pieces starting exactly at `start`, up to `end`: views
367
+ * into one chunk or into a run of touching chunks, possibly ending short.
368
+ */
369
+ cachedPieces(start, end) {
370
+ const pieces = [];
371
+ let at = start;
293
372
  for (const chunk of this.chunks) {
294
373
  const chunkEnd = chunk.start + chunk.data.length;
295
- if (start >= chunk.start && start < chunkEnd) {
296
- return chunk.data.subarray(start - chunk.start, Math.min(end, chunkEnd) - chunk.start);
297
- }
374
+ if (chunkEnd <= at)
375
+ continue;
376
+ if (chunk.start > at)
377
+ break;
378
+ const stop = Math.min(end, chunkEnd);
379
+ pieces.push(chunk.data.subarray(at - chunk.start, stop - chunk.start));
380
+ at = stop;
381
+ if (at >= end)
382
+ break;
298
383
  }
299
- return null;
300
- }
301
- cached(start, end) {
302
- const prefix = this.cachedPrefix(start, end);
303
- return prefix && prefix.length === end - start ? prefix : null;
384
+ return pieces;
304
385
  }
305
- /** start of the cached chunk holding byte `end - 1`, when there is one */
386
+ /** start of the cached run (touching chunks) holding byte `end - 1` */
306
387
  cachedSuffixStart(end) {
307
- for (const chunk of this.chunks) {
308
- if (end - 1 >= chunk.start && end - 1 < chunk.start + chunk.data.length) {
309
- return chunk.start;
310
- }
388
+ let i = this.chunks.findIndex((c) => end - 1 >= c.start && end - 1 < c.start + c.data.length);
389
+ if (i < 0)
390
+ return null;
391
+ while (i > 0 &&
392
+ this.chunks[i - 1].start + this.chunks[i - 1].data.length ===
393
+ this.chunks[i].start) {
394
+ i--;
311
395
  }
312
- return null;
396
+ return this.chunks[i].start;
397
+ }
398
+ /** start of the first cached chunk at or after `position` */
399
+ nextCachedStart(position) {
400
+ const chunk = this.chunks.find((c) => c.start >= position);
401
+ return chunk ? chunk.start : null;
313
402
  }
314
403
  _readStreamForRange(start, end) {
315
- const prefix = this.cachedPrefix(start, end);
316
- if (prefix && prefix.length === end - start)
317
- return stream_1.Readable.from([prefix]);
404
+ const pieces = this.cachedPieces(start, end);
405
+ const have = pieces.reduce((sum, piece) => sum + piece.length, 0);
406
+ if (have === end - start)
407
+ return stream_1.Readable.from(pieces);
318
408
  const out = new stream_1.PassThrough();
319
- if (prefix)
320
- out.write(prefix);
321
- const from = start + (prefix?.length ?? 0);
409
+ for (const piece of pieces)
410
+ out.write(piece);
411
+ const from = start + have;
412
+ const options = this.requestOptions(end - from);
322
413
  this.requests++;
323
- fetchRange(this.url, from, end)
414
+ fetchRange(this.url, from, end, options)
324
415
  .then((response) => {
325
416
  this.fetchedBytes += end - from;
326
417
  const body = stream_1.Readable.fromWeb(response.body);
327
- body.on('error', (error) => out.destroy(error));
418
+ body.on('error', (error) => out.destroy(describeAbort(error, `bytes=${from}-${end - 1}`, options.timeoutMs)));
328
419
  body.pipe(out);
329
420
  })
330
421
  .catch((error) => out.destroy(error));
331
422
  return out;
332
423
  }
333
424
  read(buffer, offset, length, position, callback) {
334
- const hit = this.cached(position, position + length);
335
- if (hit) {
336
- hit.copy(buffer, offset);
425
+ const requestEnd = position + length;
426
+ const copyOut = (pieces) => {
427
+ let at = offset;
428
+ for (const piece of pieces) {
429
+ piece.copy(buffer, at);
430
+ at += piece.length;
431
+ }
432
+ return at - offset === length;
433
+ };
434
+ const cached = this.cachedPieces(position, requestEnd);
435
+ if (copyOut(cached)) {
337
436
  setImmediate(() => callback(null, length));
338
437
  return;
339
438
  }
340
- // fetch only what the cache lacks: skip a cached prefix, stop at a cached
341
- // suffix (yauzl's EOCD read may just exceed the tail), and otherwise widen
342
- // so the next header read is free
343
- const requestEnd = position + length;
344
- const from = position + (this.cachedPrefix(position, requestEnd)?.length ?? 0);
439
+ // fetch only what the cache lacks: skip the cached prefix, stop at a
440
+ // cached suffix (yauzl's EOCD read may just exceed the tail), and
441
+ // otherwise widen so the next header read is free — to exactly the hinted
442
+ // entry when the hint covers this read, else by CHUNK_BYTES — but never
443
+ // into bytes already cached beyond the request
444
+ const from = position + cached.reduce((sum, piece) => sum + piece.length, 0);
345
445
  const suffixStart = this.cachedSuffixStart(requestEnd);
346
446
  let end;
347
447
  if (suffixStart !== null && suffixStart > from) {
348
448
  end = suffixStart;
349
449
  }
350
450
  else {
351
- end = Math.min(this.totalSize, Math.max(requestEnd, from + CHUNK_BYTES));
352
- if (this.hint &&
451
+ const hinted = this.hint !== null &&
353
452
  position >= this.hint.start &&
354
- position < this.hint.end) {
355
- end = Math.max(end, this.hint.end);
356
- }
453
+ requestEnd <= this.hint.end;
454
+ end = hinted
455
+ ? this.hint.end
456
+ : Math.max(requestEnd, from + CHUNK_BYTES);
457
+ end = Math.min(end, this.totalSize);
458
+ const next = this.nextCachedStart(requestEnd);
459
+ if (next !== null && next < end)
460
+ end = next;
357
461
  }
358
- this.requests++;
359
- fetchRangeBuffer(this.url, from, end).then(({ data }) => {
360
- this.fetchedBytes += data.length;
462
+ this.fetchBuffer(from, end).then((data) => {
361
463
  this.addChunk(from, data);
362
- const full = this.cached(position, position + length);
363
- if (!full) {
464
+ if (!copyOut(this.cachedPieces(position, requestEnd))) {
364
465
  callback(new Error('range read did not cover the requested bytes'));
365
466
  return;
366
467
  }
367
- full.copy(buffer, offset);
368
468
  callback(null, length);
369
469
  }, (error) => callback(error));
370
470
  }
@@ -373,8 +473,6 @@ exports.HttpRangeReader = HttpRangeReader;
373
473
  /** End-of-central-directory record: where the central directory lives. */
374
474
  const EOCD_SIGNATURE = 0x06054b50;
375
475
  const EOCD_SIZE = 22;
376
- /** central directories larger than this are left to yauzl's paged reads */
377
- const MAX_PREFETCH_BYTES = 8 * 1024 * 1024;
378
476
  function parseEndOfCentralDirectory(tail) {
379
477
  for (let i = tail.length - EOCD_SIZE; i >= 0; i--) {
380
478
  if (tail.readUInt32LE(i) !== EOCD_SIGNATURE)
@@ -395,10 +493,18 @@ function parseEndOfCentralDirectory(tail) {
395
493
  * Open a remote zip by fetching its tail (EOCD + central directory for
396
494
  * typical archives) and letting yauzl read the rest on demand.
397
495
  */
398
- async function openRemoteZip(url) {
399
- const response = await fetch(url, {
400
- headers: { Range: `bytes=-${TAIL_BYTES}`, 'Accept-Encoding': 'identity' },
401
- });
496
+ async function openRemoteZip(url, options = {}) {
497
+ const timeoutMs = timeoutFor(TAIL_BYTES, options);
498
+ let response;
499
+ try {
500
+ response = await fetch(url, {
501
+ headers: { Range: `bytes=-${TAIL_BYTES}`, 'Accept-Encoding': 'identity' },
502
+ signal: AbortSignal.timeout(timeoutMs),
503
+ });
504
+ }
505
+ catch (error) {
506
+ throw describeAbort(error, `bytes=-${TAIL_BYTES}`, timeoutMs);
507
+ }
402
508
  if (!response.ok || !response.body) {
403
509
  await response.body?.cancel().catch(() => { });
404
510
  throw new Error(`HTTP ${response.status}`);
@@ -410,27 +516,30 @@ async function openRemoteZip(url) {
410
516
  await response.body.cancel().catch(() => { });
411
517
  throw new Error(`unexpected Content-Range ${response.headers.get('content-range')}`);
412
518
  }
413
- const data = Buffer.from(await response.arrayBuffer());
519
+ let data;
520
+ try {
521
+ data = Buffer.from(await response.arrayBuffer());
522
+ }
523
+ catch (error) {
524
+ throw describeAbort(error, `bytes=-${TAIL_BYTES}`, timeoutMs);
525
+ }
414
526
  if (data.length !== range.end - range.start + 1) {
415
527
  throw new Error(`tail returned ${data.length} bytes, expected ${range.end - range.start + 1}`);
416
528
  }
417
- const reader = new HttpRangeReader(url, range.total, {
418
- start: range.start,
419
- data,
420
- });
529
+ const reader = new HttpRangeReader(url, range.total, { start: range.start, data }, { ...options, ifRange: rangeValidator(response.headers) });
421
530
  reader.requests = 1;
422
531
  reader.fetchedBytes = data.length;
423
532
  // Large archives (apk / ipa with thousands of files) keep their central
424
533
  // directory well before the tail; yauzl would otherwise page it in with one
425
- // sequential request per CHUNK_BYTES. Fetch the missing part at once.
534
+ // sequential request per CHUNK_BYTES. Fetch the missing part at once — one
535
+ // buffer of exactly its size — as long as the EOCD describes a directory
536
+ // that ends inside the tail (a corrupt record could claim the whole file).
426
537
  const eocd = parseEndOfCentralDirectory(data);
427
538
  if (eocd &&
428
539
  eocd.cdOffset < range.start &&
429
- range.start - eocd.cdOffset <= MAX_PREFETCH_BYTES) {
430
- const { data: directory } = await fetchRangeBuffer(url, eocd.cdOffset, range.start);
431
- reader.requests++;
432
- reader.fetchedBytes += directory.length;
433
- reader.addChunk(eocd.cdOffset, directory);
540
+ eocd.cdOffset + eocd.cdSize >= range.start &&
541
+ eocd.cdOffset + eocd.cdSize <= range.total - EOCD_SIZE) {
542
+ await reader.prefetch(eocd.cdOffset, range.start);
434
543
  }
435
544
  const zipFile = await new Promise((resolve, reject) => {
436
545
  (0, yauzl_1.fromRandomAccessReader)(reader, range.total, { lazyEntries: true, autoClose: false }, (err, file) => (err ? reject(err) : resolve(file)));
package/lib/versions.js CHANGED
@@ -8,7 +8,6 @@ exports.normalizeDeps = normalizeDeps;
8
8
  exports.fetchVersions = fetchVersions;
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  const compare_versions_1 = require("compare-versions");
11
- const tty_table_1 = __importDefault(require("tty-table"));
12
11
  const api_1 = require("./api");
13
12
  const app_1 = require("./app");
14
13
  const package_1 = require("./package");
@@ -147,7 +146,9 @@ function printDepsChangesForPackage({ pkg, versionDeps, }) {
147
146
  packageId: pkg.id,
148
147
  })));
149
148
  console.log(summaryText);
150
- console.log((0, tty_table_1.default)(header, rows).render());
149
+ // tty-table is ~25 ms to load; only pay for it when a table is rendered
150
+ const Table = (0, utils_1.loadTtyTable)();
151
+ console.log(Table(header, rows).render());
151
152
  console.log(chalk_1.default.yellow((0, i18n_1.t)('depsChangeRiskWarning')));
152
153
  return true;
153
154
  }
@@ -370,8 +371,16 @@ exports.versionCommands = {
370
371
  appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
371
372
  }
372
373
  const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
373
- const { hash } = await (0, api_1.uploadFile)(fn, undefined, appId);
374
- const bundleMeta = await describePpkBundle(fn, options.hermesBase);
374
+ // Hashing/caching the bundle and asking git for the commit are independent
375
+ // of the upload, so they overlap with it instead of running afterwards.
376
+ // describePpkBundle never rejects (best effort); a failed upload still
377
+ // fails the publish exactly as before.
378
+ const [{ hash }, bundleMeta, commit] = await Promise.all([
379
+ (0, api_1.uploadFile)(fn, undefined, appId),
380
+ describePpkBundle(fn, options.hermesBase),
381
+ (0, git_1.getCommitInfo)(),
382
+ ]);
383
+ const depVersions = (0, dep_versions_1.getDepVersions)();
375
384
  const versionName = name ||
376
385
  (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionNameQuestion'))) ||
377
386
  (0, i18n_1.t)('unnamed');
@@ -382,8 +391,8 @@ exports.versionCommands = {
382
391
  (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionDescriptionQuestion'))),
383
392
  metaInfo: metaInfo ??
384
393
  (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionMetaInfoQuestion'))),
385
- deps: dep_versions_1.depVersions,
386
- commit: await (0, git_1.getCommitInfo)(),
394
+ deps: depVersions,
395
+ commit,
387
396
  // Hermes delta-mode chain metadata (old servers drop unknown fields)
388
397
  ...bundleMeta,
389
398
  });
@@ -405,7 +414,7 @@ exports.versionCommands = {
405
414
  maxPackageVersion,
406
415
  rollout,
407
416
  dryRun,
408
- versionDeps: dep_versions_1.depVersions,
417
+ versionDeps: depVersions,
409
418
  warnDepsChanges: true,
410
419
  },
411
420
  });
@@ -417,7 +426,7 @@ exports.versionCommands = {
417
426
  options: {
418
427
  versionId: id,
419
428
  platform,
420
- versionDeps: dep_versions_1.depVersions,
429
+ versionDeps: depVersions,
421
430
  warnDepsChanges: true,
422
431
  },
423
432
  });
@@ -525,7 +534,8 @@ exports.versionCommands = {
525
534
  if (nonInteractive) {
526
535
  throw new Error((0, i18n_1.t)('packageIdRequired'));
527
536
  }
528
- pkgId = String((await (0, package_1.choosePackage)(String(appId))).id);
537
+ // the package list was already fetched above: no second round trip
538
+ pkgId = String((await (0, package_1.choosePackage)(String(appId), allPkgs)).id);
529
539
  }
530
540
  if (!pkgId) {
531
541
  throw new Error((0, i18n_1.t)('packageIdRequired'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.22.7",
3
+ "version": "2.22.8",
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",
@@ -66,17 +66,17 @@
66
66
  "chalk": "4",
67
67
  "cli-arguments": "^0.2.1",
68
68
  "compare-versions": "^6.1.1",
69
- "filesize-parser": "^1.5.1",
69
+ "filesize-parser": "^1.5.2",
70
70
  "form-data": "^4.0.6",
71
- "fs-extra": "^11.3.6",
71
+ "fs-extra": "^11.4.0",
72
72
  "global-dirs": "^4.0.0",
73
73
  "gradle-to-js": "^2.0.1",
74
- "i18next": "^26.3.5",
74
+ "i18next": "^26.4.0",
75
75
  "node-fetch": "^2.6.1",
76
76
  "plist": "^5.0.0",
77
77
  "progress": "^2.0.3",
78
78
  "properties": "^1.2.1",
79
- "protobufjs": "^8.7.0",
79
+ "protobufjs": "^8.7.2",
80
80
  "read": "^4.1.0",
81
81
  "registry-auth-token": "^5.1.1",
82
82
  "semver": "^7.8.5",
@@ -91,18 +91,18 @@
91
91
  "node": ">= 18.17.0"
92
92
  },
93
93
  "devDependencies": {
94
- "@babel/parser": "^8.0.0",
95
- "@biomejs/biome": "^2.5.3",
96
- "@types/bun": "^1.3.14",
94
+ "@babel/parser": "^8.0.4",
95
+ "@biomejs/biome": "^2.5.10",
96
+ "@types/bun": "^1.4.0",
97
97
  "@types/filesize-parser": "^1.5.3",
98
98
  "@types/fs-extra": "^11.0.4",
99
- "@types/node": "^26.1.1",
99
+ "@types/node": "^26.3.0",
100
100
  "@types/node-fetch": "^2.6.13",
101
101
  "@types/progress": "^2.0.7",
102
- "@types/semver": "^7.7.1",
102
+ "@types/semver": "^7.8.0",
103
103
  "@types/yauzl": "^3.4.0",
104
104
  "@types/yazl": "^3.3.1",
105
- "node-hdiffpatch": "^2.2.1",
105
+ "node-hdiffpatch": "^2.4.0",
106
106
  "typescript": "^7.0.2"
107
107
  },
108
108
  "trustedDependencies": [