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.
@@ -9,10 +9,6 @@ import {
9
9
  spawnJavaScript,
10
10
  spawnJavaScriptSync,
11
11
  } from './utils/runtime';
12
- import {
13
- resolveSentryReleaseAndDist,
14
- type SentryReleaseOptions,
15
- } from './utils/sentry-release';
16
12
 
17
13
  const g2js = require('gradle-to-js/lib/parser');
18
14
  const properties = require('properties');
@@ -68,14 +64,31 @@ type BuildSentrySourcemapsUploadArgsOptions = {
68
64
  sentryCliPath: string;
69
65
  bundlePath: string;
70
66
  sourcemapPath: string;
71
- release: string;
67
+ release?: string;
72
68
  dist?: string;
73
69
  stripPrefix?: string;
70
+ debugIdReference?: boolean;
74
71
  useStandaloneSourcemapsCommand?: boolean;
75
72
  };
76
73
 
77
74
  const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
78
75
 
76
+ export interface SentryUploadOptions {
77
+ sentryRelease?: string;
78
+ sentryDist?: string;
79
+ }
80
+
81
+ type SentryUploadMode =
82
+ | {
83
+ type: 'debug-id';
84
+ debugId: string;
85
+ }
86
+ | {
87
+ type: 'release';
88
+ release: string;
89
+ dist?: string;
90
+ };
91
+
79
92
  export function hasProjectDependency(
80
93
  dependencyName: string,
81
94
  projectRoot = process.cwd(),
@@ -397,6 +410,11 @@ function assertSuccessfulSyncProcess(
397
410
  }
398
411
  }
399
412
 
413
+ function normalizeString(value: string | undefined): string | undefined {
414
+ const normalized = value?.trim();
415
+ return normalized ? normalized : undefined;
416
+ }
417
+
400
418
  export function resolveHermesCommand(projectRoot = process.cwd()): string {
401
419
  const osBin = getHermesOSBin();
402
420
  if (!osBin) {
@@ -612,6 +630,75 @@ export function prepareSentryUploadArtifacts(
612
630
  };
613
631
  }
614
632
 
633
+ export function readSourcemapDebugId(
634
+ sourcemapPath: string,
635
+ ): string | undefined {
636
+ try {
637
+ const sourcemap = JSON.parse(
638
+ fs.readFileSync(sourcemapPath, 'utf8'),
639
+ ) as Record<string, unknown>;
640
+ const debugId = sourcemap.debugId ?? sourcemap.debug_id;
641
+ return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
642
+ } catch {
643
+ return undefined;
644
+ }
645
+ }
646
+
647
+ function resolveSentryReleaseFromValues(
648
+ releaseValue: string | undefined,
649
+ distValue: string | undefined,
650
+ ): { release: string; dist?: string } | undefined {
651
+ const release = normalizeString(releaseValue);
652
+ if (!release) {
653
+ return undefined;
654
+ }
655
+ return {
656
+ release,
657
+ dist: normalizeString(distValue),
658
+ };
659
+ }
660
+
661
+ export function resolveSentryUploadMode(
662
+ sourcemapPath: string,
663
+ options: SentryUploadOptions = {},
664
+ ): SentryUploadMode {
665
+ const optionRelease = resolveSentryReleaseFromValues(
666
+ options.sentryRelease,
667
+ options.sentryDist,
668
+ );
669
+ if (optionRelease) {
670
+ return {
671
+ type: 'release',
672
+ ...optionRelease,
673
+ };
674
+ }
675
+
676
+ const debugId = readSourcemapDebugId(sourcemapPath);
677
+ if (debugId) {
678
+ return {
679
+ type: 'debug-id',
680
+ debugId,
681
+ };
682
+ }
683
+
684
+ const environmentRelease = resolveSentryReleaseFromValues(
685
+ process.env.SENTRY_RELEASE,
686
+ process.env.SENTRY_DIST,
687
+ );
688
+ if (environmentRelease) {
689
+ return {
690
+ type: 'release',
691
+ ...environmentRelease,
692
+ };
693
+ }
694
+
695
+ throw new Error(
696
+ '[pushy/sentry] Generated source map does not contain a Debug ID. ' +
697
+ 'Add @sentry/react-native/metro to metro.config.js so the OTA bundle can be matched by Debug ID, ' +
698
+ 'or set --sentry-release/--sentry-dist (or SENTRY_RELEASE/SENTRY_DIST) for legacy release matching.',
699
+ );
700
+ }
701
+
615
702
  export function buildSentrySourcemapsUploadArgs({
616
703
  sentryCliPath,
617
704
  bundlePath,
@@ -619,10 +706,32 @@ export function buildSentrySourcemapsUploadArgs({
619
706
  release,
620
707
  dist,
621
708
  stripPrefix = process.cwd(),
709
+ debugIdReference = false,
622
710
  useStandaloneSourcemapsCommand = true,
623
711
  }: BuildSentrySourcemapsUploadArgsOptions): string[] {
624
712
  const uploadArgs = ['--strip-prefix', stripPrefix, bundlePath, sourcemapPath];
625
713
 
714
+ if (debugIdReference) {
715
+ if (!useStandaloneSourcemapsCommand) {
716
+ throw new Error(
717
+ '[pushy/sentry] Debug ID upload requires sentry-cli sourcemaps upload.',
718
+ );
719
+ }
720
+ return [
721
+ sentryCliPath,
722
+ 'sourcemaps',
723
+ 'upload',
724
+ '--debug-id-reference',
725
+ ...uploadArgs,
726
+ ];
727
+ }
728
+
729
+ if (!release) {
730
+ throw new Error(
731
+ '[pushy/sentry] Legacy Sentry sourcemap upload requires a release.',
732
+ );
733
+ }
734
+
626
735
  if (!useStandaloneSourcemapsCommand) {
627
736
  return [
628
737
  sentryCliPath,
@@ -656,13 +765,70 @@ function supportsStandaloneSentrySourcemapsUpload(sentryCliPath: string) {
656
765
  return !result.error && result.status === 0;
657
766
  }
658
767
 
768
+ function supportsSentryDebugIdReference(sentryCliPath: string) {
769
+ const result = spawnJavaScriptSync(
770
+ [sentryCliPath, 'sourcemaps', 'upload', '--help'],
771
+ {
772
+ encoding: 'utf8',
773
+ },
774
+ );
775
+ return (
776
+ !result.error &&
777
+ result.status === 0 &&
778
+ typeof result.stdout === 'string' &&
779
+ result.stdout.includes('--debug-id-reference')
780
+ );
781
+ }
782
+
783
+ function runSentryCli(args: string[]): SyncProcessResult {
784
+ return spawnJavaScriptSync(args, {
785
+ stdio: 'inherit',
786
+ });
787
+ }
788
+
789
+ function uploadSourcemapsWithRelease({
790
+ sentryCliPath,
791
+ bundlePath,
792
+ sourcemapPath,
793
+ release,
794
+ dist,
795
+ useStandaloneSourcemapsCommand,
796
+ }: {
797
+ sentryCliPath: string;
798
+ bundlePath: string;
799
+ sourcemapPath: string;
800
+ release: string;
801
+ dist?: string;
802
+ useStandaloneSourcemapsCommand: boolean;
803
+ }): void {
804
+ assertSuccessfulSyncProcess(
805
+ runSentryCli([sentryCliPath, 'releases', 'set-commits', release, '--auto']),
806
+ sentryCliPath,
807
+ );
808
+ console.log(t('sentryReleaseCreated', { version: release }));
809
+
810
+ console.log(t('uploadingSourcemap'));
811
+ assertSuccessfulSyncProcess(
812
+ runSentryCli(
813
+ buildSentrySourcemapsUploadArgs({
814
+ sentryCliPath,
815
+ bundlePath,
816
+ sourcemapPath,
817
+ release,
818
+ dist,
819
+ useStandaloneSourcemapsCommand,
820
+ }),
821
+ ),
822
+ sentryCliPath,
823
+ );
824
+ }
825
+
659
826
  export async function uploadSourcemapForSentry(
660
827
  bundleName: string,
661
828
  outputFolder: string,
662
829
  sourcemapOutput: string,
663
- version: string,
664
830
  platform = '',
665
- sentryOptions: SentryReleaseOptions = {},
831
+ sentryOptions: SentryUploadOptions = {},
666
832
  ): Promise<void> {
667
833
  if (!sourcemapOutput) {
668
834
  return;
@@ -682,44 +848,98 @@ export async function uploadSourcemapForSentry(
682
848
  return;
683
849
  }
684
850
 
685
- const { release, dist } = await resolveSentryReleaseAndDist(
686
- platform,
687
- version,
688
- sentryOptions,
689
- );
690
851
  const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(
691
852
  bundleName,
692
853
  outputFolder,
693
854
  platform,
694
855
  );
856
+ const uploadMode = resolveSentryUploadMode(sourcemapPath, sentryOptions);
857
+ const useStandaloneSourcemapsCommand =
858
+ supportsStandaloneSentrySourcemapsUpload(sentryCliPath);
695
859
 
696
- assertSuccessfulSyncProcess(
697
- spawnJavaScriptSync(
698
- [sentryCliPath, 'releases', 'set-commits', release, '--auto'],
699
- {
700
- stdio: 'inherit',
701
- },
702
- ),
703
- sentryCliPath,
704
- );
705
- console.log(t('sentryReleaseCreated', { version: release }));
860
+ if (uploadMode.type === 'release') {
861
+ uploadSourcemapsWithRelease({
862
+ sentryCliPath,
863
+ bundlePath,
864
+ sourcemapPath,
865
+ release: uploadMode.release,
866
+ dist: uploadMode.dist,
867
+ useStandaloneSourcemapsCommand,
868
+ });
869
+ return;
870
+ }
706
871
 
707
872
  console.log(t('uploadingSourcemap'));
708
- assertSuccessfulSyncProcess(
709
- spawnJavaScriptSync(
710
- buildSentrySourcemapsUploadArgs({
711
- sentryCliPath,
712
- bundlePath,
713
- sourcemapPath,
714
- release,
715
- dist,
716
- useStandaloneSourcemapsCommand:
717
- supportsStandaloneSentrySourcemapsUpload(sentryCliPath),
718
- }),
719
- {
720
- stdio: 'inherit',
721
- },
722
- ),
723
- sentryCliPath,
873
+ if (
874
+ !useStandaloneSourcemapsCommand ||
875
+ !supportsSentryDebugIdReference(sentryCliPath)
876
+ ) {
877
+ const explicitRelease =
878
+ resolveSentryReleaseFromValues(
879
+ sentryOptions.sentryRelease,
880
+ sentryOptions.sentryDist,
881
+ ) ??
882
+ resolveSentryReleaseFromValues(
883
+ process.env.SENTRY_RELEASE,
884
+ process.env.SENTRY_DIST,
885
+ );
886
+ if (!explicitRelease) {
887
+ throw new Error(
888
+ '[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' +
889
+ 'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.',
890
+ );
891
+ }
892
+ uploadSourcemapsWithRelease({
893
+ sentryCliPath,
894
+ bundlePath,
895
+ sourcemapPath,
896
+ release: explicitRelease.release,
897
+ dist: explicitRelease.dist,
898
+ useStandaloneSourcemapsCommand,
899
+ });
900
+ return;
901
+ }
902
+
903
+ console.log(
904
+ `[pushy/sentry] Using source map Debug ID: ${uploadMode.debugId}`,
724
905
  );
906
+ const debugIdResult = runSentryCli(
907
+ buildSentrySourcemapsUploadArgs({
908
+ sentryCliPath,
909
+ bundlePath,
910
+ sourcemapPath,
911
+ debugIdReference: true,
912
+ useStandaloneSourcemapsCommand,
913
+ }),
914
+ );
915
+
916
+ if (debugIdResult.status === 0 && !debugIdResult.error) {
917
+ return;
918
+ }
919
+
920
+ const explicitRelease =
921
+ resolveSentryReleaseFromValues(
922
+ sentryOptions.sentryRelease,
923
+ sentryOptions.sentryDist,
924
+ ) ??
925
+ resolveSentryReleaseFromValues(
926
+ process.env.SENTRY_RELEASE,
927
+ process.env.SENTRY_DIST,
928
+ );
929
+ if (!explicitRelease) {
930
+ assertSuccessfulSyncProcess(debugIdResult, sentryCliPath);
931
+ return;
932
+ }
933
+
934
+ console.warn(
935
+ '[pushy/sentry] Debug ID source map upload failed; falling back to explicit release/dist upload.',
936
+ );
937
+ uploadSourcemapsWithRelease({
938
+ sentryCliPath,
939
+ bundlePath,
940
+ sourcemapPath,
941
+ release: explicitRelease.release,
942
+ dist: explicitRelease.dist,
943
+ useStandaloneSourcemapsCommand,
944
+ });
725
945
  }
package/src/bundle.ts CHANGED
@@ -4,6 +4,7 @@ import { packBundle } from './bundle-pack';
4
4
  import {
5
5
  copyDebugidForSentry,
6
6
  runReactNativeBundleCommand,
7
+ type SentryUploadOptions,
7
8
  uploadSourcemapForSentry,
8
9
  } from './bundle-runner';
9
10
  import type { Platform } from './types';
@@ -18,7 +19,6 @@ import {
18
19
  getOptionalStringOption,
19
20
  getStringOption,
20
21
  } from './utils/options';
21
- import type { SentryReleaseOptions } from './utils/sentry-release';
22
22
  import { versionCommands } from './versions';
23
23
 
24
24
  type NormalizedBundleOptions = {
@@ -44,7 +44,6 @@ type NormalizedBundleOptions = {
44
44
  dryRun: boolean;
45
45
  sentryRelease?: string;
46
46
  sentryDist?: string;
47
- sentryFlavor?: string;
48
47
  };
49
48
 
50
49
  type PublishBundlePayload = {
@@ -130,11 +129,6 @@ function normalizeBundleOptions(
130
129
  'sentry-dist',
131
130
  'sentryDist',
132
131
  ),
133
- sentryFlavor: getAliasedOptionalStringOption(
134
- translatedOptions,
135
- 'sentry-flavor',
136
- 'sentryFlavor',
137
- ),
138
132
  };
139
133
  }
140
134
 
@@ -143,9 +137,8 @@ async function uploadSentryArtifactsIfNeeded(
143
137
  bundleName: string,
144
138
  intermediaDir: string,
145
139
  sourcemapOutput: string,
146
- versionName: string,
147
140
  platform: Platform,
148
- sentryOptions: SentryReleaseOptions,
141
+ sentryOptions: SentryUploadOptions,
149
142
  ): Promise<void> {
150
143
  if (!shouldUpload) {
151
144
  return;
@@ -156,7 +149,6 @@ async function uploadSentryArtifactsIfNeeded(
156
149
  bundleName,
157
150
  intermediaDir,
158
151
  sourcemapOutput,
159
- versionName,
160
152
  platform,
161
153
  sentryOptions,
162
154
  );
@@ -233,7 +225,7 @@ export const bundleCommands = {
233
225
  await packBundle(path.resolve(normalized.intermediaDir), realOutput);
234
226
 
235
227
  if (normalized.name) {
236
- const versionName = await publishBundleVersion(realOutput, platform, {
228
+ await publishBundleVersion(realOutput, platform, {
237
229
  name: normalized.name,
238
230
  description: normalized.description,
239
231
  metaInfo: normalized.metaInfo,
@@ -250,12 +242,10 @@ export const bundleCommands = {
250
242
  normalized.bundleName,
251
243
  normalized.intermediaDir,
252
244
  sourcemapOutput,
253
- versionName,
254
245
  platform,
255
246
  {
256
247
  sentryRelease: normalized.sentryRelease,
257
248
  sentryDist: normalized.sentryDist,
258
- sentryFlavor: normalized.sentryFlavor,
259
249
  },
260
250
  );
261
251
  return;
@@ -264,22 +254,16 @@ export const bundleCommands = {
264
254
  if (!getBooleanOption(options, 'no-interactive', false)) {
265
255
  const v = await question(t('uploadBundlePrompt'));
266
256
  if (v.toLowerCase() === 'y') {
267
- const versionName = await publishBundleVersion(
268
- realOutput,
269
- platform,
270
- {},
271
- );
257
+ await publishBundleVersion(realOutput, platform, {});
272
258
  await uploadSentryArtifactsIfNeeded(
273
259
  bundleParams.sentry,
274
260
  normalized.bundleName,
275
261
  normalized.intermediaDir,
276
262
  sourcemapOutput,
277
- versionName,
278
263
  platform,
279
264
  {
280
265
  sentryRelease: normalized.sentryRelease,
281
266
  sentryDist: normalized.sentryDist,
282
- sentryFlavor: normalized.sentryFlavor,
283
267
  },
284
268
  );
285
269
  }
package/src/provider.ts CHANGED
@@ -92,7 +92,6 @@ export class CLIProviderImpl implements CLIProvider {
92
92
  hermes: options.hermes || false,
93
93
  sentryRelease: options.sentryRelease,
94
94
  sentryDist: options.sentryDist,
95
- sentryFlavor: options.sentryFlavor,
96
95
  });
97
96
 
98
97
  const { bundleCommands } = await import('./bundle');
package/src/types.ts CHANGED
@@ -58,7 +58,6 @@ export interface BundleOptions {
58
58
  hermes?: boolean;
59
59
  sentryRelease?: string;
60
60
  sentryDist?: string;
61
- sentryFlavor?: string;
62
61
  }
63
62
 
64
63
  export interface PublishOptions {
@@ -1,15 +0,0 @@
1
- export interface SentryReleaseOptions {
2
- sentryRelease?: string;
3
- sentryDist?: string;
4
- sentryFlavor?: string;
5
- }
6
- export interface ResolvedSentryRelease {
7
- release: string;
8
- dist?: string;
9
- }
10
- export declare function resolveAndroidSentryReleaseAndDist({ projectRoot, flavor, dist, }?: {
11
- projectRoot?: string;
12
- flavor?: string;
13
- dist?: string;
14
- }): Promise<ResolvedSentryRelease | undefined>;
15
- export declare function resolveSentryReleaseAndDist(platform: string, fallbackVersion: string, options?: SentryReleaseOptions, projectRoot?: string): Promise<ResolvedSentryRelease>;