react-native-update-cli 2.14.1 → 2.15.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.14.1",
3
+ "version": "2.15.1",
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",
@@ -91,8 +91,8 @@
91
91
  },
92
92
  "devDependencies": {
93
93
  "@biomejs/biome": "^2.4.12",
94
- "@swc/cli": "0.8.1",
95
- "@swc/core": "^1.15.26",
94
+ "@swc/cli": "^0.8.1",
95
+ "@swc/core": "^1.15.41",
96
96
  "@types/bun": "^1.3.12",
97
97
  "@types/filesize-parser": "^1.5.3",
98
98
  "@types/fs-extra": "^11.0.4",
package/src/api.ts CHANGED
@@ -262,8 +262,7 @@ export async function uploadFile(fn: string, key?: string) {
262
262
  });
263
263
  } catch (error) {
264
264
  if (isProxyRelatedError(error)) {
265
- const rawMessage =
266
- error instanceof Error ? error.message : String(error);
265
+ const rawMessage = error instanceof Error ? error.message : String(error);
267
266
  throw new Error(
268
267
  `${rawMessage}\n\n${t('proxyNetworkError')}\n${t('proxyNetworkErrorTips')}`,
269
268
  );
@@ -9,6 +9,10 @@ import {
9
9
  spawnJavaScript,
10
10
  spawnJavaScriptSync,
11
11
  } from './utils/runtime';
12
+ import {
13
+ resolveSentryReleaseAndDist,
14
+ type SentryReleaseOptions,
15
+ } from './utils/sentry-release';
12
16
 
13
17
  const g2js = require('gradle-to-js/lib/parser');
14
18
  const properties = require('properties');
@@ -55,6 +59,23 @@ type ResolvedExpoCli = {
55
59
  usingExpo: boolean;
56
60
  };
57
61
 
62
+ type SentryUploadArtifacts = {
63
+ bundlePath: string;
64
+ sourcemapPath: string;
65
+ };
66
+
67
+ type BuildSentrySourcemapsUploadArgsOptions = {
68
+ sentryCliPath: string;
69
+ bundlePath: string;
70
+ sourcemapPath: string;
71
+ release: string;
72
+ dist?: string;
73
+ stripPrefix?: string;
74
+ useStandaloneSourcemapsCommand?: boolean;
75
+ };
76
+
77
+ const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
78
+
58
79
  export function hasProjectDependency(
59
80
  dependencyName: string,
60
81
  projectRoot = process.cwd(),
@@ -557,27 +578,59 @@ export async function copyDebugidForSentry(
557
578
  fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
558
579
  }
559
580
 
560
- export function buildSentrySourcemapsUploadArgs(
561
- sentryCliPath: string,
581
+ export function prepareSentryUploadArtifacts(
562
582
  bundleName: string,
563
583
  outputFolder: string,
564
- version: string,
584
+ platform: string,
585
+ ): SentryUploadArtifacts {
586
+ const bundlePath = path.join(outputFolder, bundleName);
587
+ const sourcemapPath = path.join(outputFolder, `${bundleName}.map`);
588
+
589
+ if (platform !== 'android' || bundleName === ANDROID_SENTRY_BUNDLE_NAME) {
590
+ return {
591
+ bundlePath,
592
+ sourcemapPath,
593
+ };
594
+ }
595
+
596
+ const androidBundlePath = path.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
597
+ const androidSourcemapPath = path.join(
598
+ outputFolder,
599
+ `${ANDROID_SENTRY_BUNDLE_NAME}.map`,
600
+ );
601
+ fs.copyFileSync(bundlePath, androidBundlePath);
602
+
603
+ const sourcemap = JSON.parse(
604
+ fs.readFileSync(sourcemapPath, 'utf8'),
605
+ ) as Record<string, unknown>;
606
+ sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
607
+ fs.writeFileSync(androidSourcemapPath, JSON.stringify(sourcemap));
608
+
609
+ return {
610
+ bundlePath: androidBundlePath,
611
+ sourcemapPath: androidSourcemapPath,
612
+ };
613
+ }
614
+
615
+ export function buildSentrySourcemapsUploadArgs({
616
+ sentryCliPath,
617
+ bundlePath,
618
+ sourcemapPath,
619
+ release,
620
+ dist,
621
+ stripPrefix = process.cwd(),
565
622
  useStandaloneSourcemapsCommand = true,
566
- ): string[] {
567
- const uploadArgs = [
568
- '--strip-prefix',
569
- path.join(process.cwd(), outputFolder),
570
- path.join(outputFolder, bundleName),
571
- path.join(outputFolder, `${bundleName}.map`),
572
- ];
623
+ }: BuildSentrySourcemapsUploadArgsOptions): string[] {
624
+ const uploadArgs = ['--strip-prefix', stripPrefix, bundlePath, sourcemapPath];
573
625
 
574
626
  if (!useStandaloneSourcemapsCommand) {
575
627
  return [
576
628
  sentryCliPath,
577
629
  'releases',
578
630
  'files',
579
- version,
631
+ release,
580
632
  'upload-sourcemaps',
633
+ ...(dist ? ['--dist', dist] : []),
581
634
  ...uploadArgs,
582
635
  ];
583
636
  }
@@ -587,7 +640,8 @@ export function buildSentrySourcemapsUploadArgs(
587
640
  'sourcemaps',
588
641
  'upload',
589
642
  '--release',
590
- version,
643
+ release,
644
+ ...(dist ? ['--dist', dist] : []),
591
645
  ...uploadArgs,
592
646
  ];
593
647
  }
@@ -607,6 +661,8 @@ export async function uploadSourcemapForSentry(
607
661
  outputFolder: string,
608
662
  sourcemapOutput: string,
609
663
  version: string,
664
+ platform = '',
665
+ sentryOptions: SentryReleaseOptions = {},
610
666
  ): Promise<void> {
611
667
  if (!sourcemapOutput) {
612
668
  return;
@@ -626,27 +682,40 @@ export async function uploadSourcemapForSentry(
626
682
  return;
627
683
  }
628
684
 
685
+ const { release, dist } = await resolveSentryReleaseAndDist(
686
+ platform,
687
+ version,
688
+ sentryOptions,
689
+ );
690
+ const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(
691
+ bundleName,
692
+ outputFolder,
693
+ platform,
694
+ );
695
+
629
696
  assertSuccessfulSyncProcess(
630
697
  spawnJavaScriptSync(
631
- [sentryCliPath, 'releases', 'set-commits', version, '--auto'],
698
+ [sentryCliPath, 'releases', 'set-commits', release, '--auto'],
632
699
  {
633
700
  stdio: 'inherit',
634
701
  },
635
702
  ),
636
703
  sentryCliPath,
637
704
  );
638
- console.log(t('sentryReleaseCreated', { version }));
705
+ console.log(t('sentryReleaseCreated', { version: release }));
639
706
 
640
707
  console.log(t('uploadingSourcemap'));
641
708
  assertSuccessfulSyncProcess(
642
709
  spawnJavaScriptSync(
643
- buildSentrySourcemapsUploadArgs(
710
+ buildSentrySourcemapsUploadArgs({
644
711
  sentryCliPath,
645
- bundleName,
646
- outputFolder,
647
- version,
648
- supportsStandaloneSentrySourcemapsUpload(sentryCliPath),
649
- ),
712
+ bundlePath,
713
+ sourcemapPath,
714
+ release,
715
+ dist,
716
+ useStandaloneSourcemapsCommand:
717
+ supportsStandaloneSentrySourcemapsUpload(sentryCliPath),
718
+ }),
650
719
  {
651
720
  stdio: 'inherit',
652
721
  },
package/src/bundle.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  getOptionalStringOption,
19
19
  getStringOption,
20
20
  } from './utils/options';
21
+ import type { SentryReleaseOptions } from './utils/sentry-release';
21
22
  import { versionCommands } from './versions';
22
23
 
23
24
  type NormalizedBundleOptions = {
@@ -41,6 +42,9 @@ type NormalizedBundleOptions = {
41
42
  packageVersionRange?: string;
42
43
  rollout?: string;
43
44
  dryRun: boolean;
45
+ sentryRelease?: string;
46
+ sentryDist?: string;
47
+ sentryFlavor?: string;
44
48
  };
45
49
 
46
50
  type PublishBundlePayload = {
@@ -56,6 +60,17 @@ type PublishBundlePayload = {
56
60
  dryRun?: boolean;
57
61
  };
58
62
 
63
+ function getAliasedOptionalStringOption(
64
+ options: Record<string, unknown>,
65
+ key: string,
66
+ alias: string,
67
+ ): string | undefined {
68
+ return (
69
+ getOptionalStringOption(options, key) ??
70
+ getOptionalStringOption(options, alias)
71
+ );
72
+ }
73
+
59
74
  function normalizeBundleOptions(
60
75
  translatedOptions: Record<string, unknown>,
61
76
  platform: string,
@@ -105,6 +120,21 @@ function normalizeBundleOptions(
105
120
  ),
106
121
  rollout: getOptionalStringOption(translatedOptions, 'rollout'),
107
122
  dryRun: getBooleanOption(translatedOptions, 'dryRun', false),
123
+ sentryRelease: getAliasedOptionalStringOption(
124
+ translatedOptions,
125
+ 'sentry-release',
126
+ 'sentryRelease',
127
+ ),
128
+ sentryDist: getAliasedOptionalStringOption(
129
+ translatedOptions,
130
+ 'sentry-dist',
131
+ 'sentryDist',
132
+ ),
133
+ sentryFlavor: getAliasedOptionalStringOption(
134
+ translatedOptions,
135
+ 'sentry-flavor',
136
+ 'sentryFlavor',
137
+ ),
108
138
  };
109
139
  }
110
140
 
@@ -114,6 +144,8 @@ async function uploadSentryArtifactsIfNeeded(
114
144
  intermediaDir: string,
115
145
  sourcemapOutput: string,
116
146
  versionName: string,
147
+ platform: Platform,
148
+ sentryOptions: SentryReleaseOptions,
117
149
  ): Promise<void> {
118
150
  if (!shouldUpload) {
119
151
  return;
@@ -125,6 +157,8 @@ async function uploadSentryArtifactsIfNeeded(
125
157
  intermediaDir,
126
158
  sourcemapOutput,
127
159
  versionName,
160
+ platform,
161
+ sentryOptions,
128
162
  );
129
163
  }
130
164
 
@@ -217,6 +251,12 @@ export const bundleCommands = {
217
251
  normalized.intermediaDir,
218
252
  sourcemapOutput,
219
253
  versionName,
254
+ platform,
255
+ {
256
+ sentryRelease: normalized.sentryRelease,
257
+ sentryDist: normalized.sentryDist,
258
+ sentryFlavor: normalized.sentryFlavor,
259
+ },
220
260
  );
221
261
  return;
222
262
  }
@@ -235,6 +275,12 @@ export const bundleCommands = {
235
275
  normalized.intermediaDir,
236
276
  sourcemapOutput,
237
277
  versionName,
278
+ platform,
279
+ {
280
+ sentryRelease: normalized.sentryRelease,
281
+ sentryDist: normalized.sentryDist,
282
+ sentryFlavor: normalized.sentryFlavor,
283
+ },
238
284
  );
239
285
  }
240
286
  }
package/src/diff.ts CHANGED
@@ -223,6 +223,13 @@ async function diffFromPackage(
223
223
 
224
224
  let originSource: Buffer | undefined;
225
225
 
226
+ // Content checksum (CRC32) for entries that are copied from a *different*
227
+ // path in the origin package ("moved" entries). On Android these are the
228
+ // res/ drawables (images), whose on-device path differs between an APK
229
+ // baseline and an AAB(split-apk) install due to resource path shortening,
230
+ // so the client cannot locate them by path and must fall back to content.
231
+ const copiesCrc: Record<string, number> = {};
232
+
226
233
  await enumZipEntries(origin, async (entry, zipFile) => {
227
234
  if (!/\/$/.test(entry.fileName)) {
228
235
  const fn = transformPackagePath(entry.fileName);
@@ -281,6 +288,10 @@ async function diffFromPackage(
281
288
  const movedFrom = originMap[entry.crc32];
282
289
  if (movedFrom) {
283
290
  copies[entry.fileName] = movedFrom;
291
+ // Record the content checksum so the client can locate this file by
292
+ // content when the origin path does not exist verbatim on device
293
+ // (APK baseline -> AAB install path shortening).
294
+ copiesCrc[entry.fileName] = entry.crc32;
284
295
  return;
285
296
  }
286
297
 
@@ -313,7 +324,7 @@ async function diffFromPackage(
313
324
  }
314
325
  });
315
326
 
316
- const diffManifest = Buffer.from(JSON.stringify({ copies }));
327
+ const diffManifest = Buffer.from(JSON.stringify({ copies, copiesCrc }));
317
328
  zipfile.addBuffer(
318
329
  diffManifest,
319
330
  '__diff.json',
@@ -356,7 +367,7 @@ function diffArgsCheck(
356
367
  const { output } = translateOptions({
357
368
  ...options,
358
369
  tempDir,
359
- });
370
+ } as DiffCommandOptions & { tempDir: string });
360
371
  if (typeof output !== 'string') {
361
372
  throw new Error('Output path is required.');
362
373
  }
package/src/locales/en.ts CHANGED
@@ -184,5 +184,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
184
184
  apkExtracted: 'APK extracted to {{output}}',
185
185
  proxyNetworkError:
186
186
  'Network error — likely caused by a proxy/VPN. Please try disabling your proxy and retry.',
187
- proxyNetworkErrorTips: 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc',
187
+ proxyNetworkErrorTips:
188
+ 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc',
188
189
  };
package/src/locales/zh.ts CHANGED
@@ -170,5 +170,6 @@ export default {
170
170
  apkExtracted: 'APK 已提取到 {{output}}',
171
171
  proxyNetworkError:
172
172
  '网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。',
173
- proxyNetworkErrorTips: '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置',
173
+ proxyNetworkErrorTips:
174
+ '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置',
174
175
  };
package/src/provider.ts CHANGED
@@ -90,6 +90,9 @@ export class CLIProviderImpl implements CLIProvider {
90
90
  expo: options.expo || false,
91
91
  rncli: options.rncli || false,
92
92
  hermes: options.hermes || false,
93
+ sentryRelease: options.sentryRelease,
94
+ sentryDist: options.sentryDist,
95
+ sentryFlavor: options.sentryFlavor,
93
96
  });
94
97
 
95
98
  const { bundleCommands } = await import('./bundle');
package/src/types.ts CHANGED
@@ -56,6 +56,9 @@ export interface BundleOptions {
56
56
  expo?: boolean;
57
57
  rncli?: boolean;
58
58
  hermes?: boolean;
59
+ sentryRelease?: string;
60
+ sentryDist?: string;
61
+ sentryFlavor?: string;
59
62
  }
60
63
 
61
64
  export interface PublishOptions {
@@ -103,27 +103,40 @@ export async function question(query: string, password?: boolean) {
103
103
 
104
104
  export function translateOptions<T extends Record<string, unknown>>(
105
105
  options: T,
106
+ map?: Record<string, string>,
106
107
  ): T & Record<string, unknown> {
107
- const ret: Record<string, unknown> = {};
108
- for (const key in options) {
109
- const value = options[key];
110
- if (typeof value === 'string') {
111
- ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name) => {
112
- const replacement = options[name] ?? process.env[name];
113
- if (
114
- typeof replacement === 'string' ||
115
- typeof replacement === 'number' ||
116
- typeof replacement === 'boolean'
117
- ) {
118
- return String(replacement);
119
- }
120
- return placeholder;
121
- });
122
- } else {
123
- ret[key] = value;
108
+ if (!map) {
109
+ // Existing logic for template replacement if no map is provided
110
+ const ret: Record<string, unknown> = {};
111
+ for (const key in options) {
112
+ const value = options[key];
113
+ if (typeof value === 'string') {
114
+ ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name) => {
115
+ const replacement = options[name] ?? process.env[name];
116
+ if (
117
+ typeof replacement === 'string' ||
118
+ typeof replacement === 'number' ||
119
+ typeof replacement === 'boolean'
120
+ ) {
121
+ return String(replacement);
122
+ }
123
+ return placeholder;
124
+ });
125
+ } else {
126
+ ret[key] = value;
127
+ }
128
+ }
129
+ return ret as T & Record<string, unknown>;
130
+ }
131
+
132
+ const result: Record<string, unknown> = { ...options };
133
+ for (const [key, value] of Object.entries(map)) {
134
+ if (result[key] !== undefined) {
135
+ result[value] = result[key];
136
+ delete result[key];
124
137
  }
125
138
  }
126
- return ret as T & Record<string, unknown>;
139
+ return result as T;
127
140
  }
128
141
 
129
142
  export async function getApkInfo(fn: string) {