@sentry/wizard 4.9.0 → 5.0.0

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 (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/lib/Steps/Integrations/Cordova.js +13 -30
  3. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  4. package/dist/src/react-native/gradle.d.ts +0 -1
  5. package/dist/src/react-native/gradle.js +1 -5
  6. package/dist/src/react-native/gradle.js.map +1 -1
  7. package/dist/src/react-native/metro.d.ts +0 -4
  8. package/dist/src/react-native/metro.js +1 -129
  9. package/dist/src/react-native/metro.js.map +1 -1
  10. package/dist/src/react-native/options.d.ts +1 -3
  11. package/dist/src/react-native/options.js.map +1 -1
  12. package/dist/src/react-native/react-native-wizard.d.ts +1 -23
  13. package/dist/src/react-native/react-native-wizard.js +25 -127
  14. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  15. package/dist/src/react-native/xcode.d.ts +0 -7
  16. package/dist/src/react-native/xcode.js +1 -109
  17. package/dist/src/react-native/xcode.js.map +1 -1
  18. package/dist/src/run.js +1 -4
  19. package/dist/src/run.js.map +1 -1
  20. package/dist/src/sourcemaps/utils/sdk-version.js +3 -0
  21. package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
  22. package/dist/src/utils/ast-utils.d.ts +0 -7
  23. package/dist/src/utils/ast-utils.js +1 -27
  24. package/dist/src/utils/ast-utils.js.map +1 -1
  25. package/dist/src/version.d.ts +1 -1
  26. package/dist/src/version.js +1 -1
  27. package/dist/src/version.js.map +1 -1
  28. package/dist/test/react-native/gradle.test.js +0 -119
  29. package/dist/test/react-native/gradle.test.js.map +1 -1
  30. package/dist/test/react-native/metro.test.js +0 -90
  31. package/dist/test/react-native/metro.test.js.map +1 -1
  32. package/dist/test/react-native/xcode.test.js +0 -81
  33. package/dist/test/react-native/xcode.test.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/src/react-native/uninstall.d.ts +0 -2
  36. package/dist/src/react-native/uninstall.js +0 -94
  37. package/dist/src/react-native/uninstall.js.map +0 -1
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.runReactNativeWizardWithTelemetry = exports.runReactNativeWizard = exports.METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = exports.EXPO_SUPPORTED_SDK_RANGE = exports.FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE = exports.SESSION_REPLAY_SUPPORTED_SDK_RANGE = exports.SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = exports.XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = exports.SUPPORTED_EXPO_RANGE = exports.SUPPORTED_RN_RANGE = exports.RN_HUMAN_NAME = exports.RN_PACKAGE = exports.RN_SDK_SUPPORTED_RANGE = exports.RN_SDK_PACKAGE = void 0;
29
+ exports.runReactNativeWizardWithTelemetry = exports.runReactNativeWizard = exports.SUPPORTED_EXPO_RANGE = exports.SUPPORTED_RN_RANGE = exports.RN_HUMAN_NAME = exports.RN_PACKAGE = exports.RN_SDK_SUPPORTED_RANGE = exports.RN_SDK_PACKAGE = void 0;
30
30
  /* eslint-disable max-lines */
31
31
  // @ts-expect-error - clack is ESM and TS complains about that. It works though
32
32
  const prompts_1 = __importDefault(require("@clack/prompts"));
@@ -38,7 +38,6 @@ const cocoapod_1 = require("../apple/cocoapod");
38
38
  const telemetry_1 = require("../telemetry");
39
39
  const clack_1 = require("../utils/clack");
40
40
  const package_json_1 = require("../utils/package-json");
41
- const semver_1 = require("../utils/semver");
42
41
  const url_1 = require("../utils/url");
43
42
  const expo_1 = require("./expo");
44
43
  const expo_env_file_1 = require("./expo-env-file");
@@ -47,38 +46,14 @@ const glob_1 = require("./glob");
47
46
  const gradle_1 = require("./gradle");
48
47
  const javascript_1 = require("./javascript");
49
48
  const metro_1 = require("./metro");
50
- const uninstall_1 = require("./uninstall");
51
49
  const xcode_1 = require("./xcode");
52
50
  const xcode_2 = __importDefault(require("xcode"));
53
51
  exports.RN_SDK_PACKAGE = '@sentry/react-native';
54
- exports.RN_SDK_SUPPORTED_RANGE = '>=5.0.0';
52
+ exports.RN_SDK_SUPPORTED_RANGE = '>=6.12.0';
55
53
  exports.RN_PACKAGE = 'react-native';
56
54
  exports.RN_HUMAN_NAME = 'React Native';
57
55
  exports.SUPPORTED_RN_RANGE = '>=0.69.0';
58
56
  exports.SUPPORTED_EXPO_RANGE = '>=50.0.0';
59
- /**
60
- * The following SDK version ship with bundled Xcode scripts
61
- * which simplifies the Xcode Build Phases setup.
62
- */
63
- exports.XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';
64
- /**
65
- * The following SDK version ship with Sentry Metro plugin
66
- */
67
- exports.SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';
68
- /**
69
- * The following SDK version supports mobile Session Replay
70
- */
71
- exports.SESSION_REPLAY_SUPPORTED_SDK_RANGE = '>=6.5.0';
72
- /**
73
- * The following SDK version supports the Feedback Widget
74
- */
75
- exports.FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE = '>=6.9.0';
76
- /**
77
- * The following SDK version ship with bundled Expo plugin
78
- */
79
- exports.EXPO_SUPPORTED_SDK_RANGE = `>=5.16.0`;
80
- // The following SDK version shipped `withSentryConfig`
81
- exports.METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = '>=5.17.0';
82
57
  async function runReactNativeWizard(params) {
83
58
  return (0, telemetry_1.withTelemetry)({
84
59
  enabled: params.telemetryEnabled,
@@ -88,10 +63,6 @@ async function runReactNativeWizard(params) {
88
63
  }
89
64
  exports.runReactNativeWizard = runReactNativeWizard;
90
65
  async function runReactNativeWizardWithTelemetry(options) {
91
- if (options.uninstall) {
92
- Sentry.setTag('uninstall', true);
93
- return (0, uninstall_1.runReactNativeUninstall)(options);
94
- }
95
66
  const { promoCode, telemetryEnabled, forceInstall } = options;
96
67
  (0, clack_1.printWelcome)({
97
68
  wizardName: 'Sentry React Native Wizard',
@@ -147,14 +118,7 @@ Or setup using ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-na
147
118
  Sentry.setTag(`detected-sentry-react-native-sdk-version`, sdkVersion);
148
119
  const expoVersion = (0, package_json_1.getPackageVersion)('expo', packageJson);
149
120
  const isExpo = !!expoVersion;
150
- if (expoVersion && sdkVersion) {
151
- await (0, clack_1.confirmContinueIfPackageVersionNotSupported)({
152
- packageName: 'Sentry React Native SDK',
153
- packageVersion: sdkVersion,
154
- packageId: exports.RN_SDK_PACKAGE,
155
- acceptableVersions: exports.EXPO_SUPPORTED_SDK_RANGE,
156
- note: `Please upgrade to ${exports.EXPO_SUPPORTED_SDK_RANGE} to continue with the wizard in this Expo project.`,
157
- });
121
+ if (expoVersion) {
158
122
  await (0, clack_1.confirmContinueIfPackageVersionNotSupported)({
159
123
  packageName: 'Expo SDK',
160
124
  packageVersion: expoVersion,
@@ -173,48 +137,22 @@ Or setup using ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-na
173
137
  project: projectSlug,
174
138
  url: sentryUrl,
175
139
  };
176
- // Check if SDK version supports Session Replay
177
- let enableSessionReplay = false;
178
- if (sdkVersion &&
179
- (0, semver_1.fulfillsVersionRange)({
180
- version: sdkVersion,
181
- acceptableVersions: exports.SESSION_REPLAY_SUPPORTED_SDK_RANGE,
182
- canBeLatest: true,
183
- })) {
184
- // Ask if user wants to enable Session Replay
185
- enableSessionReplay = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
186
- message: 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',
187
- }));
188
- Sentry.setTag('enable-session-replay', enableSessionReplay);
189
- if (enableSessionReplay) {
190
- prompts_1.default.log.info(`Session Replay will be enabled with default settings (replaysSessionSampleRate: ${javascript_1.sessionReplaySampleRate}, replaysOnErrorSampleRate: ${javascript_1.sessionReplayOnErrorSampleRate}).`);
191
- prompts_1.default.log.message('By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.');
192
- }
193
- }
194
- else if (sdkVersion) {
195
- prompts_1.default.log.info(`Session Replay is supported from Sentry React Native SDK version ${exports.SESSION_REPLAY_SUPPORTED_SDK_RANGE}. Your version (${sdkVersion}) doesn't support it yet.`);
196
- prompts_1.default.log.message(`To use Session Replay, please upgrade your Sentry SDK: npm install ${exports.RN_SDK_PACKAGE}@latest --save`);
197
- }
198
- // Check if SDK version supports the Feedback Widget
199
- let enableFeedbackWidget = false;
200
- if (sdkVersion &&
201
- (0, semver_1.fulfillsVersionRange)({
202
- version: sdkVersion,
203
- acceptableVersions: exports.FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE,
204
- canBeLatest: true,
205
- })) {
206
- // Ask if user wants to enable the Feedback Widget
207
- enableFeedbackWidget = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
208
- message: 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',
209
- }));
210
- Sentry.setTag('enable-feedback-widget', enableFeedbackWidget);
211
- if (enableFeedbackWidget) {
212
- prompts_1.default.log.info(`The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`);
213
- }
140
+ // Ask if user wants to enable Session Replay
141
+ const enableSessionReplay = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
142
+ message: 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',
143
+ }));
144
+ Sentry.setTag('enable-session-replay', enableSessionReplay);
145
+ if (enableSessionReplay) {
146
+ prompts_1.default.log.info(`Session Replay will be enabled with default settings (replaysSessionSampleRate: ${javascript_1.sessionReplaySampleRate}, replaysOnErrorSampleRate: ${javascript_1.sessionReplayOnErrorSampleRate}).`);
147
+ prompts_1.default.log.message('By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.');
214
148
  }
215
- else if (sdkVersion) {
216
- prompts_1.default.log.info(`The Feedback Widget is supported from Sentry React Native SDK version ${exports.FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE}. Your version (${sdkVersion}) doesn't support it yet.`);
217
- prompts_1.default.log.message(`To use the Feedback Widget, please upgrade your Sentry SDK: npm install ${exports.RN_SDK_PACKAGE}@latest --save`);
149
+ // Ask if user wants to enable the Feedback Widget
150
+ const enableFeedbackWidget = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
151
+ message: 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',
152
+ }));
153
+ Sentry.setTag('enable-feedback-widget', enableFeedbackWidget);
154
+ if (enableFeedbackWidget) {
155
+ prompts_1.default.log.info(`The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`);
218
156
  }
219
157
  await (0, telemetry_1.traceStep)('patch-app-js', () => (0, javascript_1.addSentryInit)({
220
158
  dsn: selectedProject.keys[0].dsn.public,
@@ -230,11 +168,11 @@ Or setup using ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-na
230
168
  await (0, telemetry_1.traceStep)('patch-metro-config', expo_metro_1.addSentryToExpoMetroConfig);
231
169
  }
232
170
  else {
233
- await (0, telemetry_1.traceStep)('patch-metro-config', () => addSentryToMetroConfig({ sdkVersion }));
171
+ await (0, telemetry_1.traceStep)('patch-metro-config', metro_1.patchMetroWithSentryConfig);
234
172
  }
235
173
  if (fs.existsSync('ios')) {
236
174
  Sentry.setTag('patch-ios', true);
237
- await (0, telemetry_1.traceStep)('patch-xcode-files', () => patchXcodeFiles(cliConfig, { sdkVersion }));
175
+ await (0, telemetry_1.traceStep)('patch-xcode-files', () => patchXcodeFiles(cliConfig));
238
176
  }
239
177
  if (fs.existsSync('android')) {
240
178
  Sentry.setTag('patch-android', true);
@@ -253,24 +191,6 @@ Or setup using ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-na
253
191
  }
254
192
  }
255
193
  exports.runReactNativeWizardWithTelemetry = runReactNativeWizardWithTelemetry;
256
- function addSentryToMetroConfig({ sdkVersion, }) {
257
- if (sdkVersion &&
258
- (0, semver_1.fulfillsVersionRange)({
259
- version: sdkVersion,
260
- acceptableVersions: exports.METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE,
261
- canBeLatest: true,
262
- })) {
263
- return (0, metro_1.patchMetroWithSentryConfig)();
264
- }
265
- if (sdkVersion &&
266
- (0, semver_1.fulfillsVersionRange)({
267
- version: sdkVersion,
268
- acceptableVersions: exports.SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,
269
- canBeLatest: true,
270
- })) {
271
- return (0, metro_1.patchMetroConfigWithSentrySerializer)();
272
- }
273
- }
274
194
  async function confirmFirstSentryException(url, orgSlug, projectId) {
275
195
  const issuesStreamUrl = (0, url_1.getIssueStreamUrl)({ url, orgSlug, projectId });
276
196
  prompts_1.default.log
@@ -290,7 +210,7 @@ ${chalk_1.default.cyan(issuesStreamUrl)}`);
290
210
  });
291
211
  return firstErrorConfirmed;
292
212
  }
293
- async function patchXcodeFiles(config, context) {
213
+ async function patchXcodeFiles(config) {
294
214
  await (0, clack_1.addSentryCliConfig)(config, {
295
215
  ...clack_1.propertiesCliSetupConfig,
296
216
  name: 'source maps and iOS debug files',
@@ -319,37 +239,15 @@ async function patchXcodeFiles(config, context) {
319
239
  await (0, telemetry_1.traceStep)('patch-bundle-phase', async () => {
320
240
  const bundlePhase = (0, xcode_1.findBundlePhase)(buildPhasesMap);
321
241
  Sentry.setTag('xcode-bundle-phase-status', bundlePhase ? 'found' : 'not-found');
322
- if (context.sdkVersion &&
323
- (0, semver_1.fulfillsVersionRange)({
324
- version: context.sdkVersion,
325
- acceptableVersions: exports.XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,
326
- canBeLatest: true,
327
- })) {
328
- await (0, xcode_1.patchBundlePhase)(bundlePhase, xcode_1.addSentryWithBundledScriptsToBundleShellScript);
329
- }
330
- else {
331
- await (0, xcode_1.patchBundlePhase)(bundlePhase, xcode_1.addSentryWithCliToBundleShellScript);
332
- }
242
+ await (0, xcode_1.patchBundlePhase)(bundlePhase, xcode_1.addSentryWithBundledScriptsToBundleShellScript);
333
243
  Sentry.setTag('xcode-bundle-phase-status', 'patched');
334
244
  });
335
245
  (0, telemetry_1.traceStep)('add-debug-files-upload-phase', () => {
336
246
  const debugFilesUploadPhaseExists = !!(0, xcode_1.findDebugFilesUploadPhase)(buildPhasesMap);
337
247
  Sentry.setTag('xcode-debug-files-upload-phase-status', debugFilesUploadPhaseExists ? 'already-exists' : undefined);
338
- if (context.sdkVersion &&
339
- (0, semver_1.fulfillsVersionRange)({
340
- version: context.sdkVersion,
341
- acceptableVersions: exports.XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,
342
- canBeLatest: true,
343
- })) {
344
- (0, xcode_1.addDebugFilesUploadPhaseWithBundledScripts)(xcodeProject, {
345
- debugFilesUploadPhaseExists,
346
- });
347
- }
348
- else {
349
- (0, xcode_1.addDebugFilesUploadPhaseWithCli)(xcodeProject, {
350
- debugFilesUploadPhaseExists,
351
- });
352
- }
248
+ (0, xcode_1.addDebugFilesUploadPhaseWithBundledScripts)(xcodeProject, {
249
+ debugFilesUploadPhaseExists,
250
+ });
353
251
  Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');
354
252
  });
355
253
  (0, telemetry_1.traceStep)('write-xcode-project', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uCAAyB;AAEzB,qDAAuC;AACvC,2BAA8B;AAC9B,gDAA+C;AAC/C,4CAAwD;AACxD,0CAcwB;AACxB,wDAA+E;AAC/E,4CAAuD;AACvD,s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,CAAC,GAAG,CAAC,OAAO,CACf,oCAAoC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CACtE,CAAC;IAEF,IAAA,qBAAS,EAAC,wBAAwB,EAAE,GAAG,EAAE,CACvC,IAAA,4BAAmB,EAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAC/D,CAAC;IACF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,WAAW,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAChE,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,iBAAiB;IAC9B,OAAO,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,sBAAsB,GAAG,MAAM,IAAA,wBAAgB,EACnD,iBAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,uCAAuC;YAChD,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,mEAAmE;iBAC1E;gBACD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;aAChD;YACD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;QACnE,OAAO,sBAAsB,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n\nimport * as Sentry from '@sentry/node';\nimport { platform } from 'os';\nimport { podInstall } from '../apple/cocoapod';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n CliSetupConfigContent,\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { fulfillsVersionRange } from '../utils/semver';\nimport { getIssueStreamUrl } from '../utils/url';\nimport { patchExpoAppConfig, printSentryExpoMigrationOutro } from './expo';\nimport { addExpoEnvLocal } from './expo-env-file';\nimport { addSentryToExpoMetroConfig } from './expo-metro';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport {\n addRNSentryGradlePlugin,\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport {\n addSentryInit,\n sessionReplayOnErrorSampleRate,\n sessionReplaySampleRate,\n wrapRootComponent,\n} from './javascript';\nimport {\n patchMetroConfigWithSentrySerializer,\n patchMetroWithSentryConfig,\n} from './metro';\nimport { ReactNativeWizardOptions } from './options';\nimport { runReactNativeUninstall } from './uninstall';\nimport {\n addDebugFilesUploadPhaseWithBundledScripts,\n addDebugFilesUploadPhaseWithCli,\n addSentryWithBundledScriptsToBundleShellScript,\n addSentryWithCliToBundleShellScript,\n findBundlePhase,\n findDebugFilesUploadPhase,\n getValidExistingBuildPhases,\n patchBundlePhase,\n writeXcodeProject,\n} from './xcode';\n\nimport xcode from 'xcode';\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\nexport const RN_SDK_SUPPORTED_RANGE = '>=5.0.0';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\nexport const SUPPORTED_EXPO_RANGE = '>=50.0.0';\n\n/**\n * The following SDK version ship with bundled Xcode scripts\n * which simplifies the Xcode Build Phases setup.\n */\nexport const XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n/**\n * The following SDK version ship with Sentry Metro plugin\n */\nexport const SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n/**\n * The following SDK version supports mobile Session Replay\n */\nexport const SESSION_REPLAY_SUPPORTED_SDK_RANGE = '>=6.5.0';\n\n/**\n * The following SDK version supports the Feedback Widget\n */\nexport const FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE = '>=6.9.0';\n\n/**\n * The following SDK version ship with bundled Expo plugin\n */\nexport const EXPO_SUPPORTED_SDK_RANGE = `>=5.16.0`;\n\n// The following SDK version shipped `withSentryConfig`\nexport const METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = '>=5.17.0';\n\nexport type RNCliSetupConfigContent = Pick<\n Required<CliSetupConfigContent>,\n 'authToken' | 'org' | 'project' | 'url'\n>;\n\nexport async function runReactNativeWizard(\n params: ReactNativeWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: params.telemetryEnabled,\n integration: 'react-native',\n wizardOptions: params,\n },\n () => runReactNativeWizardWithTelemetry(params),\n );\n}\n\nexport async function runReactNativeWizardWithTelemetry(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n if (options.uninstall) {\n Sentry.setTag('uninstall', true);\n return runReactNativeUninstall(options);\n }\n\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n const hasInstalled = (dep: string) => hasPackageInstalled(dep, packageJson);\n\n if (hasInstalled('sentry-expo')) {\n Sentry.setTag('has-sentry-expo-installed', true);\n printSentryExpoMigrationOutro();\n return;\n }\n\n await ensurePackageIsInstalled(packageJson, RN_PACKAGE, RN_HUMAN_NAME);\n\n const rnVersion = getPackageVersion(RN_PACKAGE, packageJson);\n if (rnVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: RN_HUMAN_NAME,\n packageVersion: rnVersion,\n packageId: RN_PACKAGE,\n acceptableVersions: SUPPORTED_RN_RANGE,\n note: `Please upgrade to ${SUPPORTED_RN_RANGE} if you wish to use the Sentry Wizard.\nOr setup using ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/',\n )}`,\n });\n }\n\n await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n forceInstall,\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n if (sdkVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Sentry React Native SDK',\n packageVersion: sdkVersion,\n packageId: RN_SDK_PACKAGE,\n acceptableVersions: RN_SDK_SUPPORTED_RANGE,\n note: `Please upgrade to ${RN_SDK_SUPPORTED_RANGE} to continue with the wizard in this project.`,\n });\n } else {\n const continueWithoutSdk = await abortIfCancelled(\n clack.confirm({\n message:\n 'Could not detect Sentry React Native SDK version. Do you want to continue anyway?',\n }),\n );\n if (!continueWithoutSdk) {\n await abort(undefined, 0);\n }\n }\n Sentry.setTag(`detected-sentry-react-native-sdk-version`, sdkVersion);\n\n const expoVersion = getPackageVersion('expo', packageJson);\n const isExpo = !!expoVersion;\n if (expoVersion && sdkVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Sentry React Native SDK',\n packageVersion: sdkVersion,\n packageId: RN_SDK_PACKAGE,\n acceptableVersions: EXPO_SUPPORTED_SDK_RANGE,\n note: `Please upgrade to ${EXPO_SUPPORTED_SDK_RANGE} to continue with the wizard in this Expo project.`,\n });\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Expo SDK',\n packageVersion: expoVersion,\n packageId: 'expo',\n acceptableVersions: SUPPORTED_EXPO_RANGE,\n note: `Please upgrade to ${SUPPORTED_EXPO_RANGE} to continue with the wizard in this Expo project.`,\n });\n }\n\n const { selectedProject, authToken, sentryUrl } =\n await getOrAskForProjectData(options, 'react-native');\n const orgSlug = selectedProject.organization.slug;\n const projectSlug = selectedProject.slug;\n const projectId = selectedProject.id;\n const cliConfig: RNCliSetupConfigContent = {\n authToken,\n org: orgSlug,\n project: projectSlug,\n url: sentryUrl,\n };\n\n // Check if SDK version supports Session Replay\n let enableSessionReplay = false;\n if (\n sdkVersion &&\n fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions: SESSION_REPLAY_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n // Ask if user wants to enable Session Replay\n enableSessionReplay = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n }),\n );\n\n Sentry.setTag('enable-session-replay', enableSessionReplay);\n\n if (enableSessionReplay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n } else if (sdkVersion) {\n clack.log.info(\n `Session Replay is supported from Sentry React Native SDK version ${SESSION_REPLAY_SUPPORTED_SDK_RANGE}. Your version (${sdkVersion}) doesn't support it yet.`,\n );\n clack.log.message(\n `To use Session Replay, please upgrade your Sentry SDK: npm install ${RN_SDK_PACKAGE}@latest --save`,\n );\n }\n\n // Check if SDK version supports the Feedback Widget\n let enableFeedbackWidget = false;\n if (\n sdkVersion &&\n fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions: FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n // Ask if user wants to enable the Feedback Widget\n enableFeedbackWidget = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n }),\n );\n\n Sentry.setTag('enable-feedback-widget', enableFeedbackWidget);\n\n if (enableFeedbackWidget) {\n clack.log.info(\n `The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`,\n );\n }\n } else if (sdkVersion) {\n clack.log.info(\n `The Feedback Widget is supported from Sentry React Native SDK version ${FEEDBACK_WIDGET_SUPPORTED_SDK_RANGE}. Your version (${sdkVersion}) doesn't support it yet.`,\n );\n clack.log.message(\n `To use the Feedback Widget, please upgrade your Sentry SDK: npm install ${RN_SDK_PACKAGE}@latest --save`,\n );\n }\n\n await traceStep('patch-app-js', () =>\n addSentryInit({\n dsn: selectedProject.keys[0].dsn.public,\n enableSessionReplay,\n enableFeedbackWidget,\n }),\n );\n\n await traceStep('patch-app-js-wrap', () => wrapRootComponent());\n\n if (isExpo) {\n await traceStep('patch-expo-app-config', () =>\n patchExpoAppConfig(cliConfig),\n );\n await traceStep('add-expo-env-local', () => addExpoEnvLocal(cliConfig));\n }\n\n if (isExpo) {\n await traceStep('patch-metro-config', addSentryToExpoMetroConfig);\n } else {\n await traceStep('patch-metro-config', () =>\n addSentryToMetroConfig({ sdkVersion }),\n );\n }\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () =>\n patchXcodeFiles(cliConfig, { sdkVersion }),\n );\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\n );\n\n Sentry.setTag('user-confirmed-first-error', confirmedFirstException);\n\n if (confirmedFirstException) {\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n } else {\n clack.outro(\n `${chalk.dim(\n 'Let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n }\n}\n\nfunction addSentryToMetroConfig({\n sdkVersion,\n}: {\n sdkVersion: string | undefined;\n}) {\n if (\n sdkVersion &&\n fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions: METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n return patchMetroWithSentryConfig();\n }\n\n if (\n sdkVersion &&\n fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions: SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n return patchMetroConfigWithSentrySerializer();\n }\n}\n\nasync function confirmFirstSentryException(\n url: string,\n orgSlug: string,\n projectId: string,\n) {\n const issuesStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n clack.log\n .step(`To make sure everything is set up correctly, put the following code snippet into your application.\nThe snippet will create a button that, when tapped, sends a test event to Sentry.\n\nAfter that check your project issues:\n\n${chalk.cyan(issuesStreamUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(\n config: RNCliSetupConfigContent,\n context: {\n sdkVersion: string | undefined;\n },\n) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin' && (await confirmPodInstall())) {\n await traceStep('pod-install', () => podInstall('ios'));\n }\n\n const xcodeProjectPath = traceStep('find-xcode-project', () =>\n getFirstMatchedPath(XCODE_PROJECT),\n );\n Sentry.setTag(\n 'xcode-project-status',\n xcodeProjectPath ? 'found' : 'not-found',\n );\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.cyan(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [xcodeProject, buildPhasesMap] = traceStep(\n 'parse-xcode-project',\n () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const project = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n project.parseSync();\n\n const map = getValidExistingBuildPhases(project);\n return [project, map];\n },\n );\n Sentry.setTag('xcode-project-status', 'parsed');\n\n await traceStep('patch-bundle-phase', async () => {\n const bundlePhase = findBundlePhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-bundle-phase-status',\n bundlePhase ? 'found' : 'not-found',\n );\n if (\n context.sdkVersion &&\n fulfillsVersionRange({\n version: context.sdkVersion,\n acceptableVersions: XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n await patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n } else {\n await patchBundlePhase(bundlePhase, addSentryWithCliToBundleShellScript);\n }\n Sentry.setTag('xcode-bundle-phase-status', 'patched');\n });\n\n traceStep('add-debug-files-upload-phase', () => {\n const debugFilesUploadPhaseExists =\n !!findDebugFilesUploadPhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-debug-files-upload-phase-status',\n debugFilesUploadPhaseExists ? 'already-exists' : undefined,\n );\n if (\n context.sdkVersion &&\n fulfillsVersionRange({\n version: context.sdkVersion,\n acceptableVersions: XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n addDebugFilesUploadPhaseWithBundledScripts(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n } else {\n addDebugFilesUploadPhaseWithCli(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n }\n Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');\n });\n\n traceStep('write-xcode-project', () => {\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n });\n Sentry.setTag('xcode-project-status', 'patched');\n}\n\nasync function patchAndroidFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'android/sentry.properties',\n gitignore: false,\n });\n\n const appBuildGradlePath = traceStep('find-app-build-gradle', () =>\n getFirstMatchedPath(APP_BUILD_GRADLE),\n );\n Sentry.setTag(\n 'app-build-gradle-status',\n appBuildGradlePath ? 'found' : 'not-found',\n );\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android ${chalk.cyan(\n 'app/build.gradle',\n )} file using ${chalk.cyan(APP_BUILD_GRADLE)}.`,\n );\n return;\n }\n\n const appBuildGradle = traceStep('read-app-build-gradle', () =>\n fs.readFileSync(appBuildGradlePath, 'utf-8'),\n );\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (includesSentry) {\n Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');\n clack.log.warn(\n `Android ${chalk.cyan('app/build.gradle')} file already includes Sentry.`,\n );\n return;\n }\n\n const patchedAppBuildGradle = traceStep('add-rn-sentry-gradle-plugin', () =>\n addRNSentryGradlePlugin(appBuildGradle),\n );\n if (!doesAppBuildGradleIncludeRNSentryGradlePlugin(patchedAppBuildGradle)) {\n Sentry.setTag(\n 'app-build-gradle-status',\n 'failed-to-add-rn-sentry-gradle-plugin',\n );\n clack.log.warn(\n `Could not add Sentry RN Gradle Plugin to ${chalk.cyan(\n 'app/build.gradle',\n )}.`,\n );\n return;\n }\n\n Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');\n clack.log.success(\n `Added Sentry RN Gradle Plugin to ${chalk.bold('app/build.gradle')}.`,\n );\n\n traceStep('write-app-build-gradle', () =>\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle),\n );\n clack.log.success(\n chalk.green(`Android ${chalk.cyan('app/build.gradle')} saved.`),\n );\n}\n\nasync function confirmPodInstall(): Promise<boolean> {\n return traceStep('confirm-pod-install', async () => {\n const continueWithPodInstall = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run `pod install` now?',\n options: [\n {\n value: true,\n label: 'Yes',\n hint: 'Recommended for smaller projects, this might take several minutes',\n },\n { value: false, label: `No, I'll do it later` },\n ],\n initialValue: true,\n }),\n );\n Sentry.setTag('continue-with-pod-install', continueWithPodInstall);\n return continueWithPodInstall;\n });\n}\n"]}
1
+ {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uCAAyB;AAEzB,qDAAuC;AACvC,2BAA8B;AAC9B,gDAA+C;AAC/C,4CAAwD;AACxD,0CAcwB;AACxB,wDAA+E;AAC/E,sCAAiD;AACjD,iCAA2E;AAC3E,mDAAkD;AAClD,6CAA0D;AAC1D,iCAA8E;AAC9E,qCAIkB;AAClB,6CAKsB;AACtB,mCAAqD;AAErD,mCAQiB;AAEjB,kDAA0B;AAEb,QAAA,cAAc,GAAG,sBAAsB,CAAC;AACxC,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAEpC,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAChC,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAOxC,KAAK,UAAU,oBAAoB,CACxC,MAAgC;IAEhC,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,MAAM,CAAC,gBAAgB;QAChC,WAAW,EAAE,cAAc;QAC3B,aAAa,EAAE,MAAM;KACtB,EACD,GAAG,EAAE,CAAC,iCAAiC,CAAC,MAAM,CAAC,CAChD,CAAC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KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,mEAAmE;iBAC1E;gBACD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;aAChD;YACD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;QACnE,OAAO,sBAAsB,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n\nimport * as Sentry from '@sentry/node';\nimport { platform } from 'os';\nimport { podInstall } from '../apple/cocoapod';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n CliSetupConfigContent,\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { getIssueStreamUrl } from '../utils/url';\nimport { patchExpoAppConfig, printSentryExpoMigrationOutro } from './expo';\nimport { addExpoEnvLocal } from './expo-env-file';\nimport { addSentryToExpoMetroConfig } from './expo-metro';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport {\n addRNSentryGradlePlugin,\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport {\n addSentryInit,\n sessionReplayOnErrorSampleRate,\n sessionReplaySampleRate,\n wrapRootComponent,\n} from './javascript';\nimport { patchMetroWithSentryConfig } from './metro';\nimport { ReactNativeWizardOptions } from './options';\nimport {\n addDebugFilesUploadPhaseWithBundledScripts,\n addSentryWithBundledScriptsToBundleShellScript,\n findBundlePhase,\n findDebugFilesUploadPhase,\n getValidExistingBuildPhases,\n patchBundlePhase,\n writeXcodeProject,\n} from './xcode';\n\nimport xcode from 'xcode';\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\nexport const RN_SDK_SUPPORTED_RANGE = '>=6.12.0';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\nexport const SUPPORTED_EXPO_RANGE = '>=50.0.0';\n\nexport type RNCliSetupConfigContent = Pick<\n Required<CliSetupConfigContent>,\n 'authToken' | 'org' | 'project' | 'url'\n>;\n\nexport async function runReactNativeWizard(\n params: ReactNativeWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: params.telemetryEnabled,\n integration: 'react-native',\n wizardOptions: params,\n },\n () => runReactNativeWizardWithTelemetry(params),\n );\n}\n\nexport async function runReactNativeWizardWithTelemetry(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n const hasInstalled = (dep: string) => hasPackageInstalled(dep, packageJson);\n\n if (hasInstalled('sentry-expo')) {\n Sentry.setTag('has-sentry-expo-installed', true);\n printSentryExpoMigrationOutro();\n return;\n }\n\n await ensurePackageIsInstalled(packageJson, RN_PACKAGE, RN_HUMAN_NAME);\n\n const rnVersion = getPackageVersion(RN_PACKAGE, packageJson);\n if (rnVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: RN_HUMAN_NAME,\n packageVersion: rnVersion,\n packageId: RN_PACKAGE,\n acceptableVersions: SUPPORTED_RN_RANGE,\n note: `Please upgrade to ${SUPPORTED_RN_RANGE} if you wish to use the Sentry Wizard.\nOr setup using ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/',\n )}`,\n });\n }\n\n await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n forceInstall,\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n if (sdkVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Sentry React Native SDK',\n packageVersion: sdkVersion,\n packageId: RN_SDK_PACKAGE,\n acceptableVersions: RN_SDK_SUPPORTED_RANGE,\n note: `Please upgrade to ${RN_SDK_SUPPORTED_RANGE} to continue with the wizard in this project.`,\n });\n } else {\n const continueWithoutSdk = await abortIfCancelled(\n clack.confirm({\n message:\n 'Could not detect Sentry React Native SDK version. Do you want to continue anyway?',\n }),\n );\n if (!continueWithoutSdk) {\n await abort(undefined, 0);\n }\n }\n Sentry.setTag(`detected-sentry-react-native-sdk-version`, sdkVersion);\n\n const expoVersion = getPackageVersion('expo', packageJson);\n const isExpo = !!expoVersion;\n if (expoVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Expo SDK',\n packageVersion: expoVersion,\n packageId: 'expo',\n acceptableVersions: SUPPORTED_EXPO_RANGE,\n note: `Please upgrade to ${SUPPORTED_EXPO_RANGE} to continue with the wizard in this Expo project.`,\n });\n }\n\n const { selectedProject, authToken, sentryUrl } =\n await getOrAskForProjectData(options, 'react-native');\n const orgSlug = selectedProject.organization.slug;\n const projectSlug = selectedProject.slug;\n const projectId = selectedProject.id;\n const cliConfig: RNCliSetupConfigContent = {\n authToken,\n org: orgSlug,\n project: projectSlug,\n url: sentryUrl,\n };\n\n // Ask if user wants to enable Session Replay\n const enableSessionReplay = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n }),\n );\n Sentry.setTag('enable-session-replay', enableSessionReplay);\n\n if (enableSessionReplay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n\n // Ask if user wants to enable the Feedback Widget\n const enableFeedbackWidget = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n }),\n );\n Sentry.setTag('enable-feedback-widget', enableFeedbackWidget);\n\n if (enableFeedbackWidget) {\n clack.log.info(\n `The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`,\n );\n }\n\n await traceStep('patch-app-js', () =>\n addSentryInit({\n dsn: selectedProject.keys[0].dsn.public,\n enableSessionReplay,\n enableFeedbackWidget,\n }),\n );\n\n await traceStep('patch-app-js-wrap', () => wrapRootComponent());\n\n if (isExpo) {\n await traceStep('patch-expo-app-config', () =>\n patchExpoAppConfig(cliConfig),\n );\n await traceStep('add-expo-env-local', () => addExpoEnvLocal(cliConfig));\n }\n\n if (isExpo) {\n await traceStep('patch-metro-config', addSentryToExpoMetroConfig);\n } else {\n await traceStep('patch-metro-config', patchMetroWithSentryConfig);\n }\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () => patchXcodeFiles(cliConfig));\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\n );\n\n Sentry.setTag('user-confirmed-first-error', confirmedFirstException);\n\n if (confirmedFirstException) {\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n } else {\n clack.outro(\n `${chalk.dim(\n 'Let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n }\n}\n\nasync function confirmFirstSentryException(\n url: string,\n orgSlug: string,\n projectId: string,\n) {\n const issuesStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n clack.log\n .step(`To make sure everything is set up correctly, put the following code snippet into your application.\nThe snippet will create a button that, when tapped, sends a test event to Sentry.\n\nAfter that check your project issues:\n\n${chalk.cyan(issuesStreamUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin' && (await confirmPodInstall())) {\n await traceStep('pod-install', () => podInstall('ios'));\n }\n\n const xcodeProjectPath = traceStep('find-xcode-project', () =>\n getFirstMatchedPath(XCODE_PROJECT),\n );\n Sentry.setTag(\n 'xcode-project-status',\n xcodeProjectPath ? 'found' : 'not-found',\n );\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.cyan(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [xcodeProject, buildPhasesMap] = traceStep(\n 'parse-xcode-project',\n () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const project = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n project.parseSync();\n\n const map = getValidExistingBuildPhases(project);\n return [project, map];\n },\n );\n Sentry.setTag('xcode-project-status', 'parsed');\n\n await traceStep('patch-bundle-phase', async () => {\n const bundlePhase = findBundlePhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-bundle-phase-status',\n bundlePhase ? 'found' : 'not-found',\n );\n\n await patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n\n Sentry.setTag('xcode-bundle-phase-status', 'patched');\n });\n\n traceStep('add-debug-files-upload-phase', () => {\n const debugFilesUploadPhaseExists =\n !!findDebugFilesUploadPhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-debug-files-upload-phase-status',\n debugFilesUploadPhaseExists ? 'already-exists' : undefined,\n );\n\n addDebugFilesUploadPhaseWithBundledScripts(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n\n Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');\n });\n\n traceStep('write-xcode-project', () => {\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n });\n Sentry.setTag('xcode-project-status', 'patched');\n}\n\nasync function patchAndroidFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'android/sentry.properties',\n gitignore: false,\n });\n\n const appBuildGradlePath = traceStep('find-app-build-gradle', () =>\n getFirstMatchedPath(APP_BUILD_GRADLE),\n );\n Sentry.setTag(\n 'app-build-gradle-status',\n appBuildGradlePath ? 'found' : 'not-found',\n );\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android ${chalk.cyan(\n 'app/build.gradle',\n )} file using ${chalk.cyan(APP_BUILD_GRADLE)}.`,\n );\n return;\n }\n\n const appBuildGradle = traceStep('read-app-build-gradle', () =>\n fs.readFileSync(appBuildGradlePath, 'utf-8'),\n );\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (includesSentry) {\n Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');\n clack.log.warn(\n `Android ${chalk.cyan('app/build.gradle')} file already includes Sentry.`,\n );\n return;\n }\n\n const patchedAppBuildGradle = traceStep('add-rn-sentry-gradle-plugin', () =>\n addRNSentryGradlePlugin(appBuildGradle),\n );\n if (!doesAppBuildGradleIncludeRNSentryGradlePlugin(patchedAppBuildGradle)) {\n Sentry.setTag(\n 'app-build-gradle-status',\n 'failed-to-add-rn-sentry-gradle-plugin',\n );\n clack.log.warn(\n `Could not add Sentry RN Gradle Plugin to ${chalk.cyan(\n 'app/build.gradle',\n )}.`,\n );\n return;\n }\n\n Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');\n clack.log.success(\n `Added Sentry RN Gradle Plugin to ${chalk.bold('app/build.gradle')}.`,\n );\n\n traceStep('write-app-build-gradle', () =>\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle),\n );\n clack.log.success(\n chalk.green(`Android ${chalk.cyan('app/build.gradle')} saved.`),\n );\n}\n\nasync function confirmPodInstall(): Promise<boolean> {\n return traceStep('confirm-pod-install', async () => {\n const continueWithPodInstall = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run `pod install` now?',\n options: [\n {\n value: true,\n label: 'Yes',\n hint: 'Recommended for smaller projects, this might take several minutes',\n },\n { value: false, label: `No, I'll do it later` },\n ],\n initialValue: true,\n }),\n );\n Sentry.setTag('continue-with-pod-install', continueWithPodInstall);\n return continueWithPodInstall;\n });\n}\n"]}
@@ -9,19 +9,12 @@ export declare class ErrorPatchSnippet {
9
9
  constructor(snippet: string);
10
10
  }
11
11
  export declare function patchBundlePhase(bundlePhase: BuildPhase | undefined, patch: (script: string) => string | ErrorPatchSnippet): Promise<void>;
12
- export declare function unPatchBundlePhase(bundlePhase: BuildPhase | undefined): void;
13
- export declare function removeSentryFromBundleShellScript(script: string): string;
14
12
  export declare function findBundlePhase(buildPhases: BuildPhaseMap): BuildPhase | undefined;
15
13
  export declare function doesBundlePhaseIncludeSentry(buildPhase: BuildPhase): boolean;
16
14
  export declare function addSentryWithBundledScriptsToBundleShellScript(script: string): string | ErrorPatchSnippet;
17
- export declare function addSentryWithCliToBundleShellScript(script: string): string | ErrorPatchSnippet;
18
15
  export declare function addDebugFilesUploadPhaseWithBundledScripts(xcodeProject: any, { debugFilesUploadPhaseExists }: {
19
16
  debugFilesUploadPhaseExists: boolean;
20
17
  }): void;
21
- export declare function addDebugFilesUploadPhaseWithCli(xcodeProject: any, { debugFilesUploadPhaseExists }: {
22
- debugFilesUploadPhaseExists: boolean;
23
- }): void;
24
- export declare function unPatchDebugFilesUploadPhase(xcodeProject: any): void;
25
18
  export declare function findDebugFilesUploadPhase(buildPhasesMap: Record<string, BuildPhase>): [key: string, buildPhase: BuildPhase] | undefined;
26
19
  export declare function writeXcodeProject(xcodeProjectPath: string, xcodeProject: Project): void;
27
20
  export {};
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.writeXcodeProject = exports.findDebugFilesUploadPhase = exports.unPatchDebugFilesUploadPhase = exports.addDebugFilesUploadPhaseWithCli = exports.addDebugFilesUploadPhaseWithBundledScripts = exports.addSentryWithCliToBundleShellScript = exports.addSentryWithBundledScriptsToBundleShellScript = exports.doesBundlePhaseIncludeSentry = exports.findBundlePhase = exports.removeSentryFromBundleShellScript = exports.unPatchBundlePhase = exports.patchBundlePhase = exports.ErrorPatchSnippet = exports.getValidExistingBuildPhases = void 0;
29
+ exports.writeXcodeProject = exports.findDebugFilesUploadPhase = exports.addDebugFilesUploadPhaseWithBundledScripts = exports.addSentryWithBundledScriptsToBundleShellScript = exports.doesBundlePhaseIncludeSentry = exports.findBundlePhase = exports.patchBundlePhase = exports.ErrorPatchSnippet = exports.getValidExistingBuildPhases = void 0;
30
30
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
31
31
  /* eslint-disable @typescript-eslint/no-unsafe-call */
32
32
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
@@ -78,42 +78,6 @@ async function patchBundlePhase(bundlePhase, patch) {
78
78
  clack.log.success(`Patched Build phase ${chalk_1.default.cyan('Bundle React Native code and images')}.`);
79
79
  }
80
80
  exports.patchBundlePhase = patchBundlePhase;
81
- function unPatchBundlePhase(bundlePhase) {
82
- if (!bundlePhase) {
83
- clack.log.warn(`Could not find ${chalk_1.default.cyan('Bundle React Native code and images')} build phase.`);
84
- return;
85
- }
86
- if (!bundlePhase.shellScript.match(/sentry-cli\s+react-native\s+xcode/i) &&
87
- !bundlePhase.shellScript.includes('sentry-xcode.sh')) {
88
- clack.log.success(`Build phase ${chalk_1.default.cyan('Bundle React Native code and images')} does not include Sentry.`);
89
- return;
90
- }
91
- try {
92
- bundlePhase.shellScript = JSON.stringify(removeSentryFromBundleShellScript(JSON.parse(bundlePhase.shellScript)));
93
- clack.log.success(`Build phase ${chalk_1.default.cyan('Bundle React Native code and images')} unpatched successfully.`);
94
- }
95
- catch (error) {
96
- clack.log.error(`Failed to unpatch ${chalk_1.default.cyan('Bundle React Native code and images')} due to a json error.`);
97
- Sentry.captureException('Error while unpatching bundle phase');
98
- }
99
- }
100
- exports.unPatchBundlePhase = unPatchBundlePhase;
101
- function removeSentryFromBundleShellScript(script) {
102
- return (script
103
- // remove sentry properties export
104
- .replace(/^export SENTRY_PROPERTIES=sentry.properties\r?\n/m, '')
105
- .replace(/^\/bin\/sh .*?..\/node_modules\/@sentry\/react-native\/scripts\/collect-modules.sh"?\r?\n/m, '')
106
- // unwrap react-native-xcode.sh command. In case someone replaced it
107
- // entirely with the sentry-cli command we need to put the original
108
- // version back in.
109
- .replace(/\.\.\/node_modules\/@sentry\/cli\/bin\/sentry-cli\s+react-native\s+xcode\s+\$REACT_NATIVE_XCODE/i, '$REACT_NATIVE_XCODE')
110
- .replace(
111
- // eslint-disable-next-line no-useless-escape
112
- /\"\/bin\/sh.*?sentry-xcode.sh\s+\$REACT_NATIVE_XCODE/i,
113
- // eslint-disable-next-line no-useless-escape
114
- '"$REACT_NATIVE_XCODE'));
115
- }
116
- exports.removeSentryFromBundleShellScript = removeSentryFromBundleShellScript;
117
81
  function findBundlePhase(buildPhases) {
118
82
  return Object.values(buildPhases).find((buildPhase) => buildPhase.shellScript.match(/\/scripts\/react-native-xcode\.sh/i));
119
83
  }
@@ -162,27 +126,6 @@ REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"
162
126
  return patchedScript;
163
127
  }
164
128
  exports.addSentryWithBundledScriptsToBundleShellScript = addSentryWithBundledScriptsToBundleShellScript;
165
- function addSentryWithCliToBundleShellScript(script) {
166
- if (!script.includes('$REACT_NATIVE_XCODE')) {
167
- clack.log.error(`Could not find $REACT_NATIVE_XCODE in ${chalk_1.default.cyan('Bundle React Native code and images')} build phase. Skipping patching.`);
168
- Sentry.captureException(`Could not find $REACT_NATIVE_XCODE in 'Bundle React Native code and images' build phase.`);
169
- return new ErrorPatchSnippet((0, clack_1.makeCodeSnippet)(true, (unchanged, plus, _minus) => {
170
- return unchanged(`${plus(`export SENTRY_PROPERTIES=sentry.properties
171
- export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
172
- `)}
173
- /bin/sh -c "$WITH_ENVIRONMENT ${plus(`\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode`)} $REACT_NATIVE_XCODE${plus(`\\"`)}"
174
- ${plus(`/bin/sh -c "$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh"`)}
175
- `);
176
- }));
177
- }
178
- return ('export SENTRY_PROPERTIES=sentry.properties\n' +
179
- 'export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"\n' +
180
- script.replace('$REACT_NATIVE_XCODE', () =>
181
- // eslint-disable-next-line no-useless-escape
182
- '\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\"') +
183
- '\n/bin/sh -c "$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh"\n');
184
- }
185
- exports.addSentryWithCliToBundleShellScript = addSentryWithCliToBundleShellScript;
186
129
  function addDebugFilesUploadPhaseWithBundledScripts(
187
130
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
188
131
  xcodeProject, { debugFilesUploadPhaseExists }) {
@@ -197,57 +140,6 @@ xcodeProject, { debugFilesUploadPhaseExists }) {
197
140
  clack.log.success(`Added Build phase ${chalk_1.default.cyan('Upload Debug Symbols to Sentry')}.`);
198
141
  }
199
142
  exports.addDebugFilesUploadPhaseWithBundledScripts = addDebugFilesUploadPhaseWithBundledScripts;
200
- function addDebugFilesUploadPhaseWithCli(
201
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
- xcodeProject, { debugFilesUploadPhaseExists }) {
203
- if (debugFilesUploadPhaseExists) {
204
- clack.log.warn(`Build phase ${chalk_1.default.cyan('Upload Debug Symbols to Sentry')} already exists.`);
205
- return;
206
- }
207
- xcodeProject.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Upload Debug Symbols to Sentry', null, {
208
- shellPath: '/bin/sh',
209
- shellScript: `
210
- WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
211
- if [ -f "$WITH_ENVIRONMENT" ]; then
212
- . "$WITH_ENVIRONMENT"
213
- fi
214
- export SENTRY_PROPERTIES=sentry.properties
215
- [ "$SENTRY_INCLUDE_NATIVE_SOURCES" = "true" ] && INCLUDE_SOURCES_FLAG="--include-sources" || INCLUDE_SOURCES_FLAG=""
216
- ../node_modules/@sentry/cli/bin/sentry-cli debug-files upload "$INCLUDE_SOURCES_FLAG" "$DWARF_DSYM_FOLDER_PATH"
217
- `,
218
- });
219
- clack.log.success(`Added Build phase ${chalk_1.default.cyan('Upload Debug Symbols to Sentry')}.`);
220
- }
221
- exports.addDebugFilesUploadPhaseWithCli = addDebugFilesUploadPhaseWithCli;
222
- function unPatchDebugFilesUploadPhase(
223
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
224
- xcodeProject) {
225
- const buildPhasesMap = xcodeProject.hash.project.objects.PBXShellScriptBuildPhase || {};
226
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
227
- const debugFilesUploadPhaseResult = findDebugFilesUploadPhase(buildPhasesMap);
228
- if (!debugFilesUploadPhaseResult) {
229
- clack.log.warn(`Build phase ${chalk_1.default.cyan('Upload Debug Symbols to Sentry')} not found.`);
230
- return;
231
- }
232
- const [debugFilesUploadPhaseKey] = debugFilesUploadPhaseResult;
233
- const firstTarget = xcodeProject.getFirstTarget().uuid;
234
- const nativeTargets = xcodeProject.hash.project.objects.PBXNativeTarget;
235
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
236
- delete buildPhasesMap[debugFilesUploadPhaseKey];
237
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
238
- delete buildPhasesMap[`${debugFilesUploadPhaseKey}_comment`];
239
- const phases = nativeTargets[firstTarget].buildPhases;
240
- if (phases) {
241
- for (let i = 0; i < phases.length; i++) {
242
- if (phases[i].value === debugFilesUploadPhaseKey) {
243
- phases.splice(i, 1);
244
- break;
245
- }
246
- }
247
- }
248
- clack.log.success(`Build phase ${chalk_1.default.cyan('Upload Debug Symbols to Sentry')} removed successfully.`);
249
- }
250
- exports.unPatchDebugFilesUploadPhase = unPatchDebugFilesUploadPhase;
251
143
  function findDebugFilesUploadPhase(buildPhasesMap) {
252
144
  return Object.entries(buildPhasesMap).find(([_, buildPhase]) => {
253
145
  const containsCliDebugUpload = typeof buildPhase !== 'string' &&
@@ -1 +1 @@
1
- {"version":3,"file":"xcode.js","sourceRoot":"","sources":["../../../src/react-native/xcode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,sDAAsD;AACtD,+DAA+D;AAC/D,4CAA8B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C,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,qCAAqC,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CACpE,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,mCAAmC,CAAC,CAAC;KAC9D;AACH,CAAC;AAvBD,8CAuBC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport * as fs from 'node:fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { Project } from 'xcode';\nimport * as Sentry from '@sentry/node';\n\ntype BuildPhase = { shellScript: string };\ntype BuildPhaseMap = Record<string, BuildPhase>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getValidExistingBuildPhases(xcodeProject: any): BuildPhaseMap {\n const map: BuildPhaseMap = {};\n const raw = xcodeProject.hash.project.objects.PBXShellScriptBuildPhase || {};\n for (const key in raw) {\n const val = raw[key];\n val.isa && (map[key] = val);\n }\n\n return map;\n}\n\nexport class ErrorPatchSnippet {\n constructor(public snippet: string) {}\n}\n\nexport async function patchBundlePhase(\n bundlePhase: BuildPhase | undefined,\n patch: (script: string) => string | ErrorPatchSnippet,\n) {\n if (!bundlePhase) {\n clack.log.warn(\n `Could not find ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n return;\n }\n\n const bundlePhaseIncludesSentry = doesBundlePhaseIncludeSentry(bundlePhase);\n if (bundlePhaseIncludesSentry) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Bundle React Native code and images',\n )} already includes Sentry.`,\n );\n return;\n }\n\n const script: string = JSON.parse(bundlePhase.shellScript);\n const patchedScript = patch(script);\n if (patchedScript instanceof ErrorPatchSnippet) {\n await showCopyPasteInstructions({\n filename: 'Xcode project',\n codeSnippet: patchedScript.snippet,\n hint: `Apply in the 'Bundle React Native code and images' build phase`,\n });\n return;\n }\n bundlePhase.shellScript = JSON.stringify(patchedScript);\n clack.log.success(\n `Patched Build phase ${chalk.cyan('Bundle React Native code and images')}.`,\n );\n}\n\nexport function unPatchBundlePhase(bundlePhase: BuildPhase | undefined) {\n if (!bundlePhase) {\n clack.log.warn(\n `Could not find ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n return;\n }\n\n if (\n !bundlePhase.shellScript.match(/sentry-cli\\s+react-native\\s+xcode/i) &&\n !bundlePhase.shellScript.includes('sentry-xcode.sh')\n ) {\n clack.log.success(\n `Build phase ${chalk.cyan(\n 'Bundle React Native code and images',\n )} does not include Sentry.`,\n );\n return;\n }\n\n try {\n bundlePhase.shellScript = JSON.stringify(\n removeSentryFromBundleShellScript(\n <string>JSON.parse(bundlePhase.shellScript),\n ),\n );\n clack.log.success(\n `Build phase ${chalk.cyan(\n 'Bundle React Native code and images',\n )} unpatched successfully.`,\n );\n } catch (error) {\n clack.log.error(\n `Failed to unpatch ${chalk.cyan(\n 'Bundle React Native code and images',\n )} due to a json error.`,\n );\n Sentry.captureException('Error while unpatching bundle phase');\n }\n}\n\nexport function removeSentryFromBundleShellScript(script: string): string {\n return (\n script\n // remove sentry properties export\n .replace(/^export SENTRY_PROPERTIES=sentry.properties\\r?\\n/m, '')\n .replace(\n /^\\/bin\\/sh .*?..\\/node_modules\\/@sentry\\/react-native\\/scripts\\/collect-modules.sh\"?\\r?\\n/m,\n '',\n )\n // unwrap react-native-xcode.sh command. In case someone replaced it\n // entirely with the sentry-cli command we need to put the original\n // version back in.\n .replace(\n /\\.\\.\\/node_modules\\/@sentry\\/cli\\/bin\\/sentry-cli\\s+react-native\\s+xcode\\s+\\$REACT_NATIVE_XCODE/i,\n '$REACT_NATIVE_XCODE',\n )\n .replace(\n // eslint-disable-next-line no-useless-escape\n /\\\"\\/bin\\/sh.*?sentry-xcode.sh\\s+\\$REACT_NATIVE_XCODE/i,\n // eslint-disable-next-line no-useless-escape\n '\"$REACT_NATIVE_XCODE',\n )\n );\n}\n\nexport function findBundlePhase(buildPhases: BuildPhaseMap) {\n return Object.values(buildPhases).find((buildPhase) =>\n buildPhase.shellScript.match(/\\/scripts\\/react-native-xcode\\.sh/i),\n );\n}\n\nexport function doesBundlePhaseIncludeSentry(buildPhase: BuildPhase) {\n const containsSentryCliRNCommand = !!buildPhase.shellScript.match(\n /sentry-cli\\s+react-native\\s+xcode/i,\n );\n const containsBundledScript =\n buildPhase.shellScript.includes('sentry-xcode.sh');\n return containsSentryCliRNCommand || containsBundledScript;\n}\n\nexport function addSentryWithBundledScriptsToBundleShellScript(\n script: string,\n): string | ErrorPatchSnippet {\n let patchedScript = script;\n const isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');\n if (isLikelyPlainReactNativeScript) {\n patchedScript = script.replace(\n '$REACT_NATIVE_XCODE',\n // eslint-disable-next-line no-useless-escape\n '\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\\\\"',\n );\n }\n\n const isLikelyExpoScript = script.includes('expo');\n if (isLikelyExpoScript) {\n const SENTRY_REACT_NATIVE_XCODE_PATH =\n \"`\\\"$NODE_BINARY\\\" --print \\\"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\\\"`\";\n patchedScript = script.replace(\n /^.*?(packager|scripts)\\/react-native-xcode\\.sh\\s*(\\\\'\\\\\\\\\")?/m,\n // eslint-disable-next-line no-useless-escape\n (match: string) => `/bin/sh ${SENTRY_REACT_NATIVE_XCODE_PATH} ${match}`,\n );\n }\n\n if (patchedScript === script) {\n // No changes were made\n clack.log.error(\n `Failed to patch ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n Sentry.captureException(\n `Failed to patch 'Bundle React Native code and images' build phase.`,\n );\n if (isLikelyExpoScript) {\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(\n `${plus(\n `/bin/sh \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"\\``,\n )} \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"\\``,\n );\n }),\n );\n } else {\n // plain react-native\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT ${plus(\n `\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh `,\n )}$REACT_NATIVE_XCODE${plus(`\\\\\"`)}\"\n`);\n }),\n );\n }\n }\n\n return patchedScript;\n}\n\nexport function addSentryWithCliToBundleShellScript(\n script: string,\n): string | ErrorPatchSnippet {\n if (!script.includes('$REACT_NATIVE_XCODE')) {\n clack.log.error(\n `Could not find $REACT_NATIVE_XCODE in ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase. Skipping patching.`,\n );\n Sentry.captureException(\n `Could not find $REACT_NATIVE_XCODE in 'Bundle React Native code and images' build phase.`,\n );\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`${plus(`export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\n`)}\n/bin/sh -c \"$WITH_ENVIRONMENT ${plus(\n `\\\\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode`,\n )} $REACT_NATIVE_XCODE${plus(`\\\\\"`)}\"\n${plus(\n `/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"`,\n)}\n`);\n }),\n );\n }\n return (\n 'export SENTRY_PROPERTIES=sentry.properties\\n' +\n 'export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\\n' +\n script.replace(\n '$REACT_NATIVE_XCODE',\n () =>\n // eslint-disable-next-line no-useless-escape\n '\\\\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\\\"',\n ) +\n '\\n/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"\\n'\n );\n}\n\nexport function addDebugFilesUploadPhaseWithBundledScripts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xcodeProject: any,\n { debugFilesUploadPhaseExists }: { debugFilesUploadPhaseExists: boolean },\n) {\n if (debugFilesUploadPhaseExists) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Upload Debug Symbols to Sentry',\n )} already exists.`,\n );\n return;\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh`,\n },\n );\n clack.log.success(\n `Added Build phase ${chalk.cyan('Upload Debug Symbols to Sentry')}.`,\n );\n}\n\nexport function addDebugFilesUploadPhaseWithCli(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xcodeProject: any,\n { debugFilesUploadPhaseExists }: { debugFilesUploadPhaseExists: boolean },\n) {\n if (debugFilesUploadPhaseExists) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Upload Debug Symbols to Sentry',\n )} already exists.`,\n );\n return;\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nif [ -f \"$WITH_ENVIRONMENT\" ]; then\n . \"$WITH_ENVIRONMENT\"\nfi\nexport SENTRY_PROPERTIES=sentry.properties\n[ \"$SENTRY_INCLUDE_NATIVE_SOURCES\" = \"true\" ] && INCLUDE_SOURCES_FLAG=\"--include-sources\" || INCLUDE_SOURCES_FLAG=\"\"\n../node_modules/@sentry/cli/bin/sentry-cli debug-files upload \"$INCLUDE_SOURCES_FLAG\" \"$DWARF_DSYM_FOLDER_PATH\"\n`,\n },\n );\n clack.log.success(\n `Added Build phase ${chalk.cyan('Upload Debug Symbols to Sentry')}.`,\n );\n}\n\nexport function unPatchDebugFilesUploadPhase(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xcodeProject: any,\n) {\n const buildPhasesMap =\n xcodeProject.hash.project.objects.PBXShellScriptBuildPhase || {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const debugFilesUploadPhaseResult = findDebugFilesUploadPhase(buildPhasesMap);\n if (!debugFilesUploadPhaseResult) {\n clack.log.warn(\n `Build phase ${chalk.cyan('Upload Debug Symbols to Sentry')} not found.`,\n );\n return;\n }\n\n const [debugFilesUploadPhaseKey] = debugFilesUploadPhaseResult;\n const firstTarget: string = xcodeProject.getFirstTarget().uuid;\n const nativeTargets = xcodeProject.hash.project.objects.PBXNativeTarget;\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete buildPhasesMap[debugFilesUploadPhaseKey];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete buildPhasesMap[`${debugFilesUploadPhaseKey}_comment`];\n const phases = nativeTargets[firstTarget].buildPhases;\n if (phases) {\n for (let i = 0; i < phases.length; i++) {\n if (phases[i].value === debugFilesUploadPhaseKey) {\n phases.splice(i, 1);\n break;\n }\n }\n }\n clack.log.success(\n `Build phase ${chalk.cyan(\n 'Upload Debug Symbols to Sentry',\n )} removed successfully.`,\n );\n}\n\nexport function findDebugFilesUploadPhase(\n buildPhasesMap: Record<string, BuildPhase>,\n): [key: string, buildPhase: BuildPhase] | undefined {\n return Object.entries(buildPhasesMap).find(([_, buildPhase]) => {\n const containsCliDebugUpload =\n typeof buildPhase !== 'string' &&\n !!buildPhase.shellScript.match(\n /sentry-cli\\s+(upload-dsym|debug-files upload)\\b/,\n );\n const containsBundledDebugUpload =\n typeof buildPhase !== 'string' &&\n buildPhase.shellScript.includes('sentry-xcode-debug-files.sh');\n return containsCliDebugUpload || containsBundledDebugUpload;\n });\n}\n\nexport function writeXcodeProject(\n xcodeProjectPath: string,\n xcodeProject: Project,\n) {\n try {\n const newContent = xcodeProject.writeSync();\n const currentContent = fs.readFileSync(xcodeProjectPath, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(xcodeProjectPath, newContent, 'utf-8');\n clack.log.success(\n chalk.green(\n `Xcode project ${chalk.cyan(xcodeProjectPath)} changes saved.`,\n ),\n );\n } catch (error) {\n clack.log.error(\n `Error while writing Xcode project ${chalk.cyan(xcodeProjectPath)}`,\n );\n Sentry.captureException('Error while writing Xcode project');\n }\n}\n"]}
1
+ {"version":3,"file":"xcode.js","sourceRoot":"","sources":["../../../src/react-native/xcode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,sDAAsD;AACtD,+DAA+D;AAC/D,4CAA8B;AAC9B,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,0CAA4E;AAE5E,qDAAuC;AAKvC,8DAA8D;AAC9D,SAAgB,2BAA2B,CAAC,YAAiB;IAC3D,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,IAAI,EAAE,CAAC;IAC7E,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,C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AAE,EAAE;QAC7D,MAAM,sBAAsB,GAC1B,OAAO,UAAU,KAAK,QAAQ;YAC9B,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAC5B,iDAAiD,CAClD,CAAC;QACJ,MAAM,0BAA0B,GAC9B,OAAO,UAAU,KAAK,QAAQ;YAC9B,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;QACjE,OAAO,sBAAsB,IAAI,0BAA0B,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,8DAcC;AAED,SAAgB,iBAAiB,CAC/B,gBAAwB,EACxB,YAAqB;IAErB,IAAI;QACF,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;QAC5C,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAClE,IAAI,UAAU,KAAK,cAAc,EAAE;YACjC,OAAO;SACR;QAED,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CACT,iBAAiB,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAC/D,CACF,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,qCAAqC,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CACpE,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,mCAAmC,CAAC,CAAC;KAC9D;AACH,CAAC;AAvBD,8CAuBC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport * as fs from 'node:fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { Project } from 'xcode';\nimport * as Sentry from '@sentry/node';\n\ntype BuildPhase = { shellScript: string };\ntype BuildPhaseMap = Record<string, BuildPhase>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getValidExistingBuildPhases(xcodeProject: any): BuildPhaseMap {\n const map: BuildPhaseMap = {};\n const raw = xcodeProject.hash.project.objects.PBXShellScriptBuildPhase || {};\n for (const key in raw) {\n const val = raw[key];\n val.isa && (map[key] = val);\n }\n\n return map;\n}\n\nexport class ErrorPatchSnippet {\n constructor(public snippet: string) {}\n}\n\nexport async function patchBundlePhase(\n bundlePhase: BuildPhase | undefined,\n patch: (script: string) => string | ErrorPatchSnippet,\n) {\n if (!bundlePhase) {\n clack.log.warn(\n `Could not find ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n return;\n }\n\n const bundlePhaseIncludesSentry = doesBundlePhaseIncludeSentry(bundlePhase);\n if (bundlePhaseIncludesSentry) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Bundle React Native code and images',\n )} already includes Sentry.`,\n );\n return;\n }\n\n const script: string = JSON.parse(bundlePhase.shellScript);\n const patchedScript = patch(script);\n if (patchedScript instanceof ErrorPatchSnippet) {\n await showCopyPasteInstructions({\n filename: 'Xcode project',\n codeSnippet: patchedScript.snippet,\n hint: `Apply in the 'Bundle React Native code and images' build phase`,\n });\n return;\n }\n bundlePhase.shellScript = JSON.stringify(patchedScript);\n clack.log.success(\n `Patched Build phase ${chalk.cyan('Bundle React Native code and images')}.`,\n );\n}\n\nexport function findBundlePhase(buildPhases: BuildPhaseMap) {\n return Object.values(buildPhases).find((buildPhase) =>\n buildPhase.shellScript.match(/\\/scripts\\/react-native-xcode\\.sh/i),\n );\n}\n\nexport function doesBundlePhaseIncludeSentry(buildPhase: BuildPhase) {\n const containsSentryCliRNCommand = !!buildPhase.shellScript.match(\n /sentry-cli\\s+react-native\\s+xcode/i,\n );\n const containsBundledScript =\n buildPhase.shellScript.includes('sentry-xcode.sh');\n return containsSentryCliRNCommand || containsBundledScript;\n}\n\nexport function addSentryWithBundledScriptsToBundleShellScript(\n script: string,\n): string | ErrorPatchSnippet {\n let patchedScript = script;\n const isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');\n if (isLikelyPlainReactNativeScript) {\n patchedScript = script.replace(\n '$REACT_NATIVE_XCODE',\n // eslint-disable-next-line no-useless-escape\n '\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\\\\"',\n );\n }\n\n const isLikelyExpoScript = script.includes('expo');\n if (isLikelyExpoScript) {\n const SENTRY_REACT_NATIVE_XCODE_PATH =\n \"`\\\"$NODE_BINARY\\\" --print \\\"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\\\"`\";\n patchedScript = script.replace(\n /^.*?(packager|scripts)\\/react-native-xcode\\.sh\\s*(\\\\'\\\\\\\\\")?/m,\n // eslint-disable-next-line no-useless-escape\n (match: string) => `/bin/sh ${SENTRY_REACT_NATIVE_XCODE_PATH} ${match}`,\n );\n }\n\n if (patchedScript === script) {\n // No changes were made\n clack.log.error(\n `Failed to patch ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n Sentry.captureException(\n `Failed to patch 'Bundle React Native code and images' build phase.`,\n );\n if (isLikelyExpoScript) {\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(\n `${plus(\n `/bin/sh \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"\\``,\n )} \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"\\``,\n );\n }),\n );\n } else {\n // plain react-native\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT ${plus(\n `\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh `,\n )}$REACT_NATIVE_XCODE${plus(`\\\\\"`)}\"\n`);\n }),\n );\n }\n }\n\n return patchedScript;\n}\n\nexport function addDebugFilesUploadPhaseWithBundledScripts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xcodeProject: any,\n { debugFilesUploadPhaseExists }: { debugFilesUploadPhaseExists: boolean },\n) {\n if (debugFilesUploadPhaseExists) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Upload Debug Symbols to Sentry',\n )} already exists.`,\n );\n return;\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh`,\n },\n );\n clack.log.success(\n `Added Build phase ${chalk.cyan('Upload Debug Symbols to Sentry')}.`,\n );\n}\n\nexport function findDebugFilesUploadPhase(\n buildPhasesMap: Record<string, BuildPhase>,\n): [key: string, buildPhase: BuildPhase] | undefined {\n return Object.entries(buildPhasesMap).find(([_, buildPhase]) => {\n const containsCliDebugUpload =\n typeof buildPhase !== 'string' &&\n !!buildPhase.shellScript.match(\n /sentry-cli\\s+(upload-dsym|debug-files upload)\\b/,\n );\n const containsBundledDebugUpload =\n typeof buildPhase !== 'string' &&\n buildPhase.shellScript.includes('sentry-xcode-debug-files.sh');\n return containsCliDebugUpload || containsBundledDebugUpload;\n });\n}\n\nexport function writeXcodeProject(\n xcodeProjectPath: string,\n xcodeProject: Project,\n) {\n try {\n const newContent = xcodeProject.writeSync();\n const currentContent = fs.readFileSync(xcodeProjectPath, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(xcodeProjectPath, newContent, 'utf-8');\n clack.log.success(\n chalk.green(\n `Xcode project ${chalk.cyan(xcodeProjectPath)} changes saved.`,\n ),\n );\n } catch (error) {\n clack.log.error(\n `Error while writing Xcode project ${chalk.cyan(xcodeProjectPath)}`,\n );\n Sentry.captureException('Error while writing Xcode project');\n }\n}\n"]}