react-native-update-cli 2.15.1 → 2.15.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.
package/README.md CHANGED
@@ -134,6 +134,24 @@ export PUSHY_REGISTRY=https://your-api-endpoint.com
134
134
  export NO_INTERACTIVE=true
135
135
  ```
136
136
 
137
+ ## Sentry Sourcemaps
138
+
139
+ When `ios/sentry.properties` or `android/sentry.properties` exists, `bundle` uploads sourcemaps for OTA packages. The default matching path is Sentry Debug IDs; the CLI no longer infers release/dist from the native package.
140
+
141
+ React Native projects should use `@sentry/react-native/metro` in `metro.config.js` so the generated bundle and sourcemap share the same Debug ID. For Hermes, the CLI copies the packager sourcemap Debug ID to the composed Hermes sourcemap and uploads with:
142
+
143
+ ```bash
144
+ sentry-cli sourcemaps upload --debug-id-reference
145
+ ```
146
+
147
+ For older self-hosted Sentry versions or older `@sentry/cli` versions without Debug ID support, pass explicit legacy release/dist values:
148
+
149
+ ```bash
150
+ npx pushy bundle --platform android --name "4.1" --sentry-release "com.example@1.0.0+10+pushy:4.1" --sentry-dist "pushy:4.1"
151
+ ```
152
+
153
+ In legacy mode, the app runtime must report exactly the same Sentry `release` and `dist` values.
154
+
137
155
  ## Configuration
138
156
 
139
157
  Create `update.json` in your React Native project:
package/README.zh-CN.md CHANGED
@@ -134,6 +134,24 @@ export PUSHY_REGISTRY=https://your-api-endpoint.com
134
134
  export NO_INTERACTIVE=true
135
135
  ```
136
136
 
137
+ ## Sentry Sourcemap
138
+
139
+ 当项目存在 `ios/sentry.properties` 或 `android/sentry.properties` 时,`bundle` 会为 OTA 包上传 sourcemap。默认使用 Sentry Debug ID 匹配,不再根据原生包推导 release/dist。
140
+
141
+ React Native 项目需要在 `metro.config.js` 中接入 `@sentry/react-native/metro`,确保生成的 bundle 和 sourcemap 带有相同 Debug ID。Hermes 场景下 CLI 会把 packager sourcemap 的 Debug ID 复制到合成后的 Hermes sourcemap,并使用:
142
+
143
+ ```bash
144
+ sentry-cli sourcemaps upload --debug-id-reference
145
+ ```
146
+
147
+ 旧版 self-hosted Sentry 或旧版 `@sentry/cli` 不支持 Debug ID 时,可以显式指定 legacy release/dist:
148
+
149
+ ```bash
150
+ npx pushy bundle --platform android --name "4.1" --sentry-release "com.example@1.0.0+10+pushy:4.1" --sentry-dist "pushy:4.1"
151
+ ```
152
+
153
+ 这种 legacy 模式要求 App 运行时上报到 Sentry 的 `release` 和 `dist` 与上传参数完全一致。
154
+
137
155
  ## 配置文件
138
156
 
139
157
  在 React Native 项目中创建 `update.json`:
package/cli.json CHANGED
@@ -313,14 +313,6 @@
313
313
  "sentryDist": {
314
314
  "hasValue": true,
315
315
  "description": "Sentry dist for source map upload"
316
- },
317
- "sentry-flavor": {
318
- "hasValue": true,
319
- "description": "Android product flavor or variant for native Sentry release/dist"
320
- },
321
- "sentryFlavor": {
322
- "hasValue": true,
323
- "description": "Android product flavor or variant for native Sentry release/dist"
324
316
  }
325
317
  }
326
318
  },
@@ -1,4 +1,3 @@
1
- import { type SentryReleaseOptions } from './utils/sentry-release';
2
1
  export interface BundleCliOptions {
3
2
  taro?: boolean;
4
3
  expo?: boolean;
@@ -28,17 +27,32 @@ type BuildSentrySourcemapsUploadArgsOptions = {
28
27
  sentryCliPath: string;
29
28
  bundlePath: string;
30
29
  sourcemapPath: string;
31
- release: string;
30
+ release?: string;
32
31
  dist?: string;
33
32
  stripPrefix?: string;
33
+ debugIdReference?: boolean;
34
34
  useStandaloneSourcemapsCommand?: boolean;
35
35
  };
36
+ export interface SentryUploadOptions {
37
+ sentryRelease?: string;
38
+ sentryDist?: string;
39
+ }
40
+ type SentryUploadMode = {
41
+ type: 'debug-id';
42
+ debugId: string;
43
+ } | {
44
+ type: 'release';
45
+ release: string;
46
+ dist?: string;
47
+ };
36
48
  export declare function hasProjectDependency(dependencyName: string, projectRoot?: string): boolean;
37
49
  export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
38
50
  export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }: RunBundleCommandOptions): Promise<void>;
39
51
  export declare function resolveHermesCommand(projectRoot?: string): string;
40
52
  export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
41
53
  export declare function prepareSentryUploadArtifacts(bundleName: string, outputFolder: string, platform: string): SentryUploadArtifacts;
42
- export declare function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix, useStandaloneSourcemapsCommand, }: BuildSentrySourcemapsUploadArgsOptions): string[];
43
- export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, version: string, platform?: string, sentryOptions?: SentryReleaseOptions): Promise<void>;
54
+ export declare function readSourcemapDebugId(sourcemapPath: string): string | undefined;
55
+ export declare function resolveSentryUploadMode(sourcemapPath: string, options?: SentryUploadOptions): SentryUploadMode;
56
+ export declare function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix, debugIdReference, useStandaloneSourcemapsCommand, }: BuildSentrySourcemapsUploadArgsOptions): string[];
57
+ export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, platform?: string, sentryOptions?: SentryUploadOptions): Promise<void>;
44
58
  export {};
@@ -21,12 +21,18 @@ _export(exports, {
21
21
  get prepareSentryUploadArtifacts () {
22
22
  return prepareSentryUploadArtifacts;
23
23
  },
24
+ get readSourcemapDebugId () {
25
+ return readSourcemapDebugId;
26
+ },
24
27
  get resolveExpoCli () {
25
28
  return resolveExpoCli;
26
29
  },
27
30
  get resolveHermesCommand () {
28
31
  return resolveHermesCommand;
29
32
  },
33
+ get resolveSentryUploadMode () {
34
+ return resolveSentryUploadMode;
35
+ },
30
36
  get runReactNativeBundleCommand () {
31
37
  return runReactNativeBundleCommand;
32
38
  },
@@ -41,7 +47,6 @@ const _os = /*#__PURE__*/ _interop_require_default(require("os"));
41
47
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
42
48
  const _i18n = require("./utils/i18n");
43
49
  const _runtime = require("./utils/runtime");
44
- const _sentryrelease = require("./utils/sentry-release");
45
50
  function _interop_require_default(obj) {
46
51
  return obj && obj.__esModule ? obj : {
47
52
  default: obj
@@ -332,6 +337,10 @@ function assertSuccessfulSyncProcess(result, command) {
332
337
  throw new Error(`${command} failed with ${result.status === null ? `signal ${result.signal}` : `exit code ${result.status}`}`);
333
338
  }
334
339
  }
340
+ function normalizeString(value) {
341
+ const normalized = value == null ? void 0 : value.trim();
342
+ return normalized ? normalized : undefined;
343
+ }
335
344
  function resolveHermesCommand(projectRoot = process.cwd()) {
336
345
  const osBin = getHermesOSBin();
337
346
  if (!osBin) {
@@ -475,13 +484,72 @@ function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
475
484
  sourcemapPath: androidSourcemapPath
476
485
  };
477
486
  }
478
- function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix = process.cwd(), useStandaloneSourcemapsCommand = true }) {
487
+ function readSourcemapDebugId(sourcemapPath) {
488
+ try {
489
+ var _sourcemap_debugId;
490
+ const sourcemap = JSON.parse(_fsextra.readFileSync(sourcemapPath, 'utf8'));
491
+ const debugId = (_sourcemap_debugId = sourcemap.debugId) != null ? _sourcemap_debugId : sourcemap.debug_id;
492
+ return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
493
+ } catch (unused) {
494
+ return undefined;
495
+ }
496
+ }
497
+ function resolveSentryReleaseFromValues(releaseValue, distValue) {
498
+ const release = normalizeString(releaseValue);
499
+ if (!release) {
500
+ return undefined;
501
+ }
502
+ return {
503
+ release,
504
+ dist: normalizeString(distValue)
505
+ };
506
+ }
507
+ function resolveSentryUploadMode(sourcemapPath, options = {}) {
508
+ const optionRelease = resolveSentryReleaseFromValues(options.sentryRelease, options.sentryDist);
509
+ if (optionRelease) {
510
+ return {
511
+ type: 'release',
512
+ ...optionRelease
513
+ };
514
+ }
515
+ const debugId = readSourcemapDebugId(sourcemapPath);
516
+ if (debugId) {
517
+ return {
518
+ type: 'debug-id',
519
+ debugId
520
+ };
521
+ }
522
+ const environmentRelease = resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
523
+ if (environmentRelease) {
524
+ return {
525
+ type: 'release',
526
+ ...environmentRelease
527
+ };
528
+ }
529
+ throw new Error('[pushy/sentry] Generated source map does not contain a Debug ID. ' + 'Add @sentry/react-native/metro to metro.config.js so the OTA bundle can be matched by Debug ID, ' + 'or set --sentry-release/--sentry-dist (or SENTRY_RELEASE/SENTRY_DIST) for legacy release matching.');
530
+ }
531
+ function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix = process.cwd(), debugIdReference = false, useStandaloneSourcemapsCommand = true }) {
479
532
  const uploadArgs = [
480
533
  '--strip-prefix',
481
534
  stripPrefix,
482
535
  bundlePath,
483
536
  sourcemapPath
484
537
  ];
538
+ if (debugIdReference) {
539
+ if (!useStandaloneSourcemapsCommand) {
540
+ throw new Error('[pushy/sentry] Debug ID upload requires sentry-cli sourcemaps upload.');
541
+ }
542
+ return [
543
+ sentryCliPath,
544
+ 'sourcemaps',
545
+ 'upload',
546
+ '--debug-id-reference',
547
+ ...uploadArgs
548
+ ];
549
+ }
550
+ if (!release) {
551
+ throw new Error('[pushy/sentry] Legacy Sentry sourcemap upload requires a release.');
552
+ }
485
553
  if (!useStandaloneSourcemapsCommand) {
486
554
  return [
487
555
  sentryCliPath,
@@ -520,7 +588,45 @@ function supportsStandaloneSentrySourcemapsUpload(sentryCliPath) {
520
588
  });
521
589
  return !result.error && result.status === 0;
522
590
  }
523
- async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutput, version, platform = '', sentryOptions = {}) {
591
+ function supportsSentryDebugIdReference(sentryCliPath) {
592
+ const result = (0, _runtime.spawnJavaScriptSync)([
593
+ sentryCliPath,
594
+ 'sourcemaps',
595
+ 'upload',
596
+ '--help'
597
+ ], {
598
+ encoding: 'utf8'
599
+ });
600
+ return !result.error && result.status === 0 && typeof result.stdout === 'string' && result.stdout.includes('--debug-id-reference');
601
+ }
602
+ function runSentryCli(args) {
603
+ return (0, _runtime.spawnJavaScriptSync)(args, {
604
+ stdio: 'inherit'
605
+ });
606
+ }
607
+ function uploadSourcemapsWithRelease({ sentryCliPath, bundlePath, sourcemapPath, release, dist, useStandaloneSourcemapsCommand }) {
608
+ assertSuccessfulSyncProcess(runSentryCli([
609
+ sentryCliPath,
610
+ 'releases',
611
+ 'set-commits',
612
+ release,
613
+ '--auto'
614
+ ]), sentryCliPath);
615
+ console.log((0, _i18n.t)('sentryReleaseCreated', {
616
+ version: release
617
+ }));
618
+ console.log((0, _i18n.t)('uploadingSourcemap'));
619
+ assertSuccessfulSyncProcess(runSentryCli(buildSentrySourcemapsUploadArgs({
620
+ sentryCliPath,
621
+ bundlePath,
622
+ sourcemapPath,
623
+ release,
624
+ dist,
625
+ useStandaloneSourcemapsCommand
626
+ })), sentryCliPath);
627
+ }
628
+ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutput, platform = '', sentryOptions = {}) {
629
+ var _resolveSentryReleaseFromValues;
524
630
  if (!sourcemapOutput) {
525
631
  return;
526
632
  }
@@ -538,29 +644,60 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
538
644
  if (!_fsextra.existsSync(sentryCliPath)) {
539
645
  return;
540
646
  }
541
- const { release, dist } = await (0, _sentryrelease.resolveSentryReleaseAndDist)(platform, version, sentryOptions);
542
647
  const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
543
- assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
648
+ const uploadMode = resolveSentryUploadMode(sourcemapPath, sentryOptions);
649
+ const useStandaloneSourcemapsCommand = supportsStandaloneSentrySourcemapsUpload(sentryCliPath);
650
+ if (uploadMode.type === 'release') {
651
+ uploadSourcemapsWithRelease({
652
+ sentryCliPath,
653
+ bundlePath,
654
+ sourcemapPath,
655
+ release: uploadMode.release,
656
+ dist: uploadMode.dist,
657
+ useStandaloneSourcemapsCommand
658
+ });
659
+ return;
660
+ }
661
+ console.log((0, _i18n.t)('uploadingSourcemap'));
662
+ if (!useStandaloneSourcemapsCommand || !supportsSentryDebugIdReference(sentryCliPath)) {
663
+ var _resolveSentryReleaseFromValues1;
664
+ const explicitRelease = (_resolveSentryReleaseFromValues1 = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist)) != null ? _resolveSentryReleaseFromValues1 : resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
665
+ if (!explicitRelease) {
666
+ throw new Error('[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' + 'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.');
667
+ }
668
+ uploadSourcemapsWithRelease({
669
+ sentryCliPath,
670
+ bundlePath,
671
+ sourcemapPath,
672
+ release: explicitRelease.release,
673
+ dist: explicitRelease.dist,
674
+ useStandaloneSourcemapsCommand
675
+ });
676
+ return;
677
+ }
678
+ console.log(`[pushy/sentry] Using source map Debug ID: ${uploadMode.debugId}`);
679
+ const debugIdResult = runSentryCli(buildSentrySourcemapsUploadArgs({
544
680
  sentryCliPath,
545
- 'releases',
546
- 'set-commits',
547
- release,
548
- '--auto'
549
- ], {
550
- stdio: 'inherit'
551
- }), sentryCliPath);
552
- console.log((0, _i18n.t)('sentryReleaseCreated', {
553
- version: release
681
+ bundlePath,
682
+ sourcemapPath,
683
+ debugIdReference: true,
684
+ useStandaloneSourcemapsCommand
554
685
  }));
555
- console.log((0, _i18n.t)('uploadingSourcemap'));
556
- assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)(buildSentrySourcemapsUploadArgs({
686
+ if (debugIdResult.status === 0 && !debugIdResult.error) {
687
+ return;
688
+ }
689
+ const explicitRelease = (_resolveSentryReleaseFromValues = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist)) != null ? _resolveSentryReleaseFromValues : resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
690
+ if (!explicitRelease) {
691
+ assertSuccessfulSyncProcess(debugIdResult, sentryCliPath);
692
+ return;
693
+ }
694
+ console.warn('[pushy/sentry] Debug ID source map upload failed; falling back to explicit release/dist upload.');
695
+ uploadSourcemapsWithRelease({
557
696
  sentryCliPath,
558
697
  bundlePath,
559
698
  sourcemapPath,
560
- release,
561
- dist,
562
- useStandaloneSourcemapsCommand: supportsStandaloneSentrySourcemapsUpload(sentryCliPath)
563
- }), {
564
- stdio: 'inherit'
565
- }), sentryCliPath);
699
+ release: explicitRelease.release,
700
+ dist: explicitRelease.dist,
701
+ useStandaloneSourcemapsCommand
702
+ });
566
703
  }
package/lib/bundle.js CHANGED
@@ -52,16 +52,15 @@ function normalizeBundleOptions(translatedOptions, platform) {
52
52
  rollout: (0, _options.getOptionalStringOption)(translatedOptions, 'rollout'),
53
53
  dryRun: (0, _options.getBooleanOption)(translatedOptions, 'dryRun', false),
54
54
  sentryRelease: getAliasedOptionalStringOption(translatedOptions, 'sentry-release', 'sentryRelease'),
55
- sentryDist: getAliasedOptionalStringOption(translatedOptions, 'sentry-dist', 'sentryDist'),
56
- sentryFlavor: getAliasedOptionalStringOption(translatedOptions, 'sentry-flavor', 'sentryFlavor')
55
+ sentryDist: getAliasedOptionalStringOption(translatedOptions, 'sentry-dist', 'sentryDist')
57
56
  };
58
57
  }
59
- async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, versionName, platform, sentryOptions) {
58
+ async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions) {
60
59
  if (!shouldUpload) {
61
60
  return;
62
61
  }
63
62
  await (0, _bundlerunner.copyDebugidForSentry)(bundleName, intermediaDir, sourcemapOutput);
64
- await (0, _bundlerunner.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, versionName, platform, sentryOptions);
63
+ await (0, _bundlerunner.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions);
65
64
  }
66
65
  async function publishBundleVersion(outputPath, platform, payload) {
67
66
  return _versions.versionCommands.publish({
@@ -109,7 +108,7 @@ const bundleCommands = {
109
108
  });
110
109
  await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput);
111
110
  if (normalized.name) {
112
- const versionName = await publishBundleVersion(realOutput, platform, {
111
+ await publishBundleVersion(realOutput, platform, {
113
112
  name: normalized.name,
114
113
  description: normalized.description,
115
114
  metaInfo: normalized.metaInfo,
@@ -121,21 +120,19 @@ const bundleCommands = {
121
120
  rollout: normalized.rollout,
122
121
  dryRun: normalized.dryRun
123
122
  });
124
- await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, versionName, platform, {
123
+ await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
125
124
  sentryRelease: normalized.sentryRelease,
126
- sentryDist: normalized.sentryDist,
127
- sentryFlavor: normalized.sentryFlavor
125
+ sentryDist: normalized.sentryDist
128
126
  });
129
127
  return;
130
128
  }
131
129
  if (!(0, _options.getBooleanOption)(options, 'no-interactive', false)) {
132
130
  const v = await (0, _utils.question)((0, _i18n.t)('uploadBundlePrompt'));
133
131
  if (v.toLowerCase() === 'y') {
134
- const versionName = await publishBundleVersion(realOutput, platform, {});
135
- await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, versionName, platform, {
132
+ await publishBundleVersion(realOutput, platform, {});
133
+ await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
136
134
  sentryRelease: normalized.sentryRelease,
137
- sentryDist: normalized.sentryDist,
138
- sentryFlavor: normalized.sentryFlavor
135
+ sentryDist: normalized.sentryDist
139
136
  });
140
137
  }
141
138
  }
package/lib/provider.js CHANGED
@@ -107,8 +107,7 @@ class CLIProviderImpl {
107
107
  rncli: options.rncli || false,
108
108
  hermes: options.hermes || false,
109
109
  sentryRelease: options.sentryRelease,
110
- sentryDist: options.sentryDist,
111
- sentryFlavor: options.sentryFlavor
110
+ sentryDist: options.sentryDist
112
111
  });
113
112
  const { bundleCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bundle")));
114
113
  await bundleCommands.bundle(context);
package/lib/types.d.ts CHANGED
@@ -49,7 +49,6 @@ export interface BundleOptions {
49
49
  hermes?: boolean;
50
50
  sentryRelease?: string;
51
51
  sentryDist?: string;
52
- sentryFlavor?: string;
53
52
  }
54
53
  export interface PublishOptions {
55
54
  filePath?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.15.1",
3
+ "version": "2.15.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",