react-native-update-cli 2.22.1 → 2.22.3

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.
@@ -6,9 +6,9 @@ export interface HermesBaseSelection {
6
6
  bundleHash: string;
7
7
  /** server version id when the base came from the server */
8
8
  versionId?: number;
9
- /** server object key of the base ppk when known */
9
+ /** server object key of the base artifact when known */
10
10
  hash?: string;
11
- source: 'cache' | 'download' | 'local' | 'latest-version';
11
+ source: 'cache' | 'download' | 'local' | 'latest-version' | 'native-package';
12
12
  }
13
13
  /** Metadata attached to version/create so the server can track the chain. */
14
14
  export interface HermesBaseMeta {
@@ -65,8 +65,9 @@ export declare function cacheStats(): Promise<{
65
65
  export declare function cleanStaleTmp(maxAgeMs?: number): Promise<void>;
66
66
  export declare function downloadToFile(url: string, destination: string): Promise<void>;
67
67
  export interface HermesBaseServerRecord {
68
- versionId: number;
68
+ versionId?: number | null;
69
69
  hash: string;
70
+ artifactType?: 'ppk' | 'apk' | 'ipa' | 'app';
70
71
  bundleHash?: string | null;
71
72
  bytecodeVersion?: number | null;
72
73
  url: string;
@@ -79,8 +80,8 @@ export interface ResolveHermesBaseParams {
79
80
  cacheMaxMb?: number;
80
81
  /**
81
82
  * server lookup; returns null when the app has no usable base. The server
82
- * itself falls back to the newest version when the epoch is still unknown
83
- * (its bytecodeVersion is then null and verified here after download).
83
+ * itself falls back to the newest legacy version, then the newest native
84
+ * package (bytecodeVersion is null and verified here after download).
84
85
  */
85
86
  fetchBase: (appId: string, bytecodeVersion: number) => Promise<HermesBaseServerRecord | null>;
86
87
  log?: (message: string) => void;
@@ -424,7 +424,11 @@ async function resolveHermesBase(params) {
424
424
  }));
425
425
  return null;
426
426
  }
427
- const source = record?.bytecodeVersion == null ? 'latest-version' : 'download';
427
+ const source = record?.artifactType && record.artifactType !== 'ppk'
428
+ ? 'native-package'
429
+ : record?.bytecodeVersion == null
430
+ ? 'latest-version'
431
+ : 'download';
428
432
  if (!record) {
429
433
  log((0, i18n_1.t)('hermesBaseNone', { reason: 'no published version yet' }));
430
434
  return null;
@@ -441,14 +445,14 @@ async function resolveHermesBase(params) {
441
445
  const hit = await cacheLookup(record.bundleHash);
442
446
  if (hit) {
443
447
  log((0, i18n_1.t)('hermesBaseUsing', {
444
- source: `cache ${record.bundleHash.slice(0, 12)} (version ${record.versionId})`,
448
+ source: `cache ${record.bundleHash.slice(0, 12)}${record.versionId == null ? '' : ` (version ${record.versionId})`}`,
445
449
  version: bytecodeVersion,
446
450
  }));
447
451
  return {
448
452
  path: hit,
449
453
  bytecodeVersion,
450
454
  bundleHash: record.bundleHash,
451
- versionId: record.versionId,
455
+ versionId: record.versionId ?? undefined,
452
456
  hash: record.hash,
453
457
  source: 'cache',
454
458
  };
@@ -458,7 +462,10 @@ async function resolveHermesBase(params) {
458
462
  for (let attempt = 1; attempt <= 2; attempt++) {
459
463
  const dir = tmpDir();
460
464
  await fs_extra_1.default.ensureDir(dir);
461
- const archive = path_1.default.join(dir, `base-${process.pid}-${Date.now()}-${attempt}.ppk`);
465
+ const artifactType = ['ppk', 'apk', 'ipa', 'app'].includes(record.artifactType ?? '')
466
+ ? record.artifactType
467
+ : 'ppk';
468
+ const archive = path_1.default.join(dir, `base-${process.pid}-${Date.now()}-${attempt}.${artifactType}`);
462
469
  try {
463
470
  log((0, i18n_1.t)('hermesBaseDownloading', { url: record.url }));
464
471
  await downloadToFile(record.url, archive);
@@ -478,14 +485,16 @@ async function resolveHermesBase(params) {
478
485
  }
479
486
  const cached = await cachePut(bundle, params.cacheMaxMb);
480
487
  log((0, i18n_1.t)('hermesBaseUsing', {
481
- source: `version ${record.versionId} ${record.hash.slice(0, 8)}`,
488
+ source: record.versionId == null
489
+ ? `native package ${record.hash.slice(0, 8)}`
490
+ : `version ${record.versionId} ${record.hash.slice(0, 8)}`,
482
491
  version: bytecodeVersion,
483
492
  }));
484
493
  return {
485
494
  path: cached.path,
486
495
  bytecodeVersion,
487
496
  bundleHash: cached.bundleHash,
488
- versionId: record.versionId,
497
+ versionId: record.versionId ?? undefined,
489
498
  hash: record.hash,
490
499
  source,
491
500
  };
package/lib/versions.d.ts CHANGED
@@ -34,6 +34,14 @@ export declare const bindVersionToPackages: ({ appId, versionId, pkgs, rollout,
34
34
  rollout?: number;
35
35
  dryRun?: boolean;
36
36
  }) => Promise<void>;
37
+ /**
38
+ * Content identity of the ppk's bundle for the server (bundleHash, HBC version)
39
+ * plus the base used to compile it, and a copy of the bundle in the local
40
+ * cache so it can serve as a future base without a download.
41
+ */
42
+ declare function describePpkBundle(ppkPath: string, base?: HermesBaseMeta): Promise<Record<string, unknown>>;
43
+ /** Exported for tests: the version/create fields derived from a ppk + base. */
44
+ export declare const describePpkBundleForTests: typeof describePpkBundle;
37
45
  export declare const versionCommands: {
38
46
  publish: ({ args, options, }: {
39
47
  args: string[];
package/lib/versions.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.versionCommands = exports.bindVersionToPackages = void 0;
6
+ exports.versionCommands = exports.describePpkBundleForTests = exports.bindVersionToPackages = void 0;
7
7
  exports.normalizeDeps = normalizeDeps;
8
8
  exports.fetchVersions = fetchVersions;
9
9
  const chalk_1 = __importDefault(require("chalk"));
@@ -322,23 +322,32 @@ exports.bindVersionToPackages = bindVersionToPackages;
322
322
  * cache so it can serve as a future base without a download.
323
323
  */
324
324
  async function describePpkBundle(ppkPath, base) {
325
+ // Only known values are sent: the server's optional-field parsers treat an
326
+ // explicit JSON null as invalid (that contract broke 2.22.0/2.22.1 publishes
327
+ // with "Expected baseHash string"), and omitting a field is what every
328
+ // server version — strict, tolerant or too old to know the field — accepts.
325
329
  const meta = {};
326
330
  try {
327
331
  const bundle = await (0, hermes_base_1.extractBundleFromArchive)(ppkPath);
328
332
  if (bundle) {
329
333
  meta.bundleHash = (0, hermes_base_1.sha256Hex)(bundle);
330
- const hbcVersion = (0, hbcTransform_1.getHbcVersion)(bundle);
331
- meta.bytecodeVersion = hbcVersion ?? base?.bytecodeVersion ?? null;
334
+ const hbcVersion = (0, hbcTransform_1.getHbcVersion)(bundle) ?? base?.bytecodeVersion;
335
+ if (hbcVersion != null)
336
+ meta.bytecodeVersion = hbcVersion;
332
337
  await (0, hermes_base_1.cachePut)(bundle).catch(() => { });
333
338
  }
334
339
  }
335
340
  catch {
336
341
  // best effort: metadata never blocks a publish
337
342
  }
338
- meta.baseVersionId = base?.baseVersionId ?? null;
339
- meta.baseHash = base?.baseHash ?? null;
343
+ if (base?.baseVersionId != null)
344
+ meta.baseVersionId = base.baseVersionId;
345
+ if (base?.baseHash)
346
+ meta.baseHash = base.baseHash;
340
347
  return meta;
341
348
  }
349
+ /** Exported for tests: the version/create fields derived from a ppk + base. */
350
+ exports.describePpkBundleForTests = describePpkBundle;
342
351
  exports.versionCommands = {
343
352
  publish: async ({ args, options, }) => {
344
353
  const fn = args[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.22.1",
3
+ "version": "2.22.3",
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",
@@ -28,9 +28,9 @@ export interface HermesBaseSelection {
28
28
  bundleHash: string;
29
29
  /** server version id when the base came from the server */
30
30
  versionId?: number;
31
- /** server object key of the base ppk when known */
31
+ /** server object key of the base artifact when known */
32
32
  hash?: string;
33
- source: 'cache' | 'download' | 'local' | 'latest-version';
33
+ source: 'cache' | 'download' | 'local' | 'latest-version' | 'native-package';
34
34
  }
35
35
 
36
36
  /** Metadata attached to version/create so the server can track the chain. */
@@ -397,8 +397,9 @@ export async function downloadToFile(
397
397
  // ---------------------------------------------------------------------------
398
398
 
399
399
  export interface HermesBaseServerRecord {
400
- versionId: number;
400
+ versionId?: number | null;
401
401
  hash: string;
402
+ artifactType?: 'ppk' | 'apk' | 'ipa' | 'app';
402
403
  bundleHash?: string | null;
403
404
  bytecodeVersion?: number | null;
404
405
  url: string;
@@ -412,8 +413,8 @@ export interface ResolveHermesBaseParams {
412
413
  cacheMaxMb?: number;
413
414
  /**
414
415
  * server lookup; returns null when the app has no usable base. The server
415
- * itself falls back to the newest version when the epoch is still unknown
416
- * (its bytecodeVersion is then null and verified here after download).
416
+ * itself falls back to the newest legacy version, then the newest native
417
+ * package (bytecodeVersion is null and verified here after download).
417
418
  */
418
419
  fetchBase: (
419
420
  appId: string,
@@ -480,7 +481,11 @@ export async function resolveHermesBase(
480
481
  return null;
481
482
  }
482
483
  const source: HermesBaseSelection['source'] =
483
- record?.bytecodeVersion == null ? 'latest-version' : 'download';
484
+ record?.artifactType && record.artifactType !== 'ppk'
485
+ ? 'native-package'
486
+ : record?.bytecodeVersion == null
487
+ ? 'latest-version'
488
+ : 'download';
484
489
  if (!record) {
485
490
  log(t('hermesBaseNone', { reason: 'no published version yet' }));
486
491
  return null;
@@ -502,7 +507,7 @@ export async function resolveHermesBase(
502
507
  if (hit) {
503
508
  log(
504
509
  t('hermesBaseUsing', {
505
- source: `cache ${record.bundleHash.slice(0, 12)} (version ${record.versionId})`,
510
+ source: `cache ${record.bundleHash.slice(0, 12)}${record.versionId == null ? '' : ` (version ${record.versionId})`}`,
506
511
  version: bytecodeVersion,
507
512
  }),
508
513
  );
@@ -510,7 +515,7 @@ export async function resolveHermesBase(
510
515
  path: hit,
511
516
  bytecodeVersion,
512
517
  bundleHash: record.bundleHash,
513
- versionId: record.versionId,
518
+ versionId: record.versionId ?? undefined,
514
519
  hash: record.hash,
515
520
  source: 'cache',
516
521
  };
@@ -520,9 +525,14 @@ export async function resolveHermesBase(
520
525
  for (let attempt = 1; attempt <= 2; attempt++) {
521
526
  const dir = tmpDir();
522
527
  await fs.ensureDir(dir);
528
+ const artifactType = ['ppk', 'apk', 'ipa', 'app'].includes(
529
+ record.artifactType ?? '',
530
+ )
531
+ ? record.artifactType
532
+ : 'ppk';
523
533
  const archive = path.join(
524
534
  dir,
525
- `base-${process.pid}-${Date.now()}-${attempt}.ppk`,
535
+ `base-${process.pid}-${Date.now()}-${attempt}.${artifactType}`,
526
536
  );
527
537
  try {
528
538
  log(t('hermesBaseDownloading', { url: record.url }));
@@ -548,7 +558,10 @@ export async function resolveHermesBase(
548
558
  const cached = await cachePut(bundle, params.cacheMaxMb);
549
559
  log(
550
560
  t('hermesBaseUsing', {
551
- source: `version ${record.versionId} ${record.hash.slice(0, 8)}`,
561
+ source:
562
+ record.versionId == null
563
+ ? `native package ${record.hash.slice(0, 8)}`
564
+ : `version ${record.versionId} ${record.hash.slice(0, 8)}`,
552
565
  version: bytecodeVersion,
553
566
  }),
554
567
  );
@@ -556,7 +569,7 @@ export async function resolveHermesBase(
556
569
  path: cached.path,
557
570
  bytecodeVersion,
558
571
  bundleHash: cached.bundleHash,
559
- versionId: record.versionId,
572
+ versionId: record.versionId ?? undefined,
560
573
  hash: record.hash,
561
574
  source,
562
575
  };
package/src/versions.ts CHANGED
@@ -468,23 +468,30 @@ async function describePpkBundle(
468
468
  ppkPath: string,
469
469
  base?: HermesBaseMeta,
470
470
  ): Promise<Record<string, unknown>> {
471
+ // Only known values are sent: the server's optional-field parsers treat an
472
+ // explicit JSON null as invalid (that contract broke 2.22.0/2.22.1 publishes
473
+ // with "Expected baseHash string"), and omitting a field is what every
474
+ // server version — strict, tolerant or too old to know the field — accepts.
471
475
  const meta: Record<string, unknown> = {};
472
476
  try {
473
477
  const bundle = await extractBundleFromArchive(ppkPath);
474
478
  if (bundle) {
475
479
  meta.bundleHash = sha256Hex(bundle);
476
- const hbcVersion = getHbcVersion(bundle);
477
- meta.bytecodeVersion = hbcVersion ?? base?.bytecodeVersion ?? null;
480
+ const hbcVersion = getHbcVersion(bundle) ?? base?.bytecodeVersion;
481
+ if (hbcVersion != null) meta.bytecodeVersion = hbcVersion;
478
482
  await cachePut(bundle).catch(() => {});
479
483
  }
480
484
  } catch {
481
485
  // best effort: metadata never blocks a publish
482
486
  }
483
- meta.baseVersionId = base?.baseVersionId ?? null;
484
- meta.baseHash = base?.baseHash ?? null;
487
+ if (base?.baseVersionId != null) meta.baseVersionId = base.baseVersionId;
488
+ if (base?.baseHash) meta.baseHash = base.baseHash;
485
489
  return meta;
486
490
  }
487
491
 
492
+ /** Exported for tests: the version/create fields derived from a ppk + base. */
493
+ export const describePpkBundleForTests = describePpkBundle;
494
+
488
495
  export const versionCommands = {
489
496
  publish: async ({
490
497
  args,