@sentry/wizard 3.24.1 → 3.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/react-native/expo-env-file.d.ts +2 -0
  4. package/dist/src/react-native/expo-env-file.js +127 -0
  5. package/dist/src/react-native/expo-env-file.js.map +1 -0
  6. package/dist/src/react-native/expo-metro.d.ts +7 -0
  7. package/dist/src/react-native/expo-metro.js +236 -0
  8. package/dist/src/react-native/expo-metro.js.map +1 -0
  9. package/dist/src/react-native/expo.d.ts +16 -0
  10. package/dist/src/react-native/expo.js +195 -0
  11. package/dist/src/react-native/expo.js.map +1 -0
  12. package/dist/src/react-native/git.d.ts +1 -0
  13. package/dist/src/react-native/git.js +85 -0
  14. package/dist/src/react-native/git.js.map +1 -0
  15. package/dist/src/react-native/javascript.d.ts +3 -0
  16. package/dist/src/react-native/javascript.js +119 -1
  17. package/dist/src/react-native/javascript.js.map +1 -1
  18. package/dist/src/react-native/metro.d.ts +3 -0
  19. package/dist/src/react-native/metro.js +17 -15
  20. package/dist/src/react-native/metro.js.map +1 -1
  21. package/dist/src/react-native/react-native-wizard.d.ts +12 -0
  22. package/dist/src/react-native/react-native-wizard.js +91 -78
  23. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  24. package/dist/src/react-native/xcode.js +14 -3
  25. package/dist/src/react-native/xcode.js.map +1 -1
  26. package/dist/src/remix/codemods/handle-error.js +35 -33
  27. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  28. package/dist/src/remix/templates.d.ts +1 -1
  29. package/dist/src/remix/templates.js +1 -1
  30. package/dist/src/remix/templates.js.map +1 -1
  31. package/dist/src/utils/clack-utils.d.ts +2 -1
  32. package/dist/src/utils/clack-utils.js +2 -2
  33. package/dist/src/utils/clack-utils.js.map +1 -1
  34. package/dist/test/react-native/expo-metro.test.d.ts +1 -0
  35. package/dist/test/react-native/expo-metro.test.js +26 -0
  36. package/dist/test/react-native/expo-metro.test.js.map +1 -0
  37. package/dist/test/react-native/expo.test.d.ts +1 -0
  38. package/dist/test/react-native/expo.test.js +57 -0
  39. package/dist/test/react-native/expo.test.js.map +1 -0
  40. package/dist/test/react-native/xcode.test.js +5 -0
  41. package/dist/test/react-native/xcode.test.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/react-native/expo-env-file.ts +55 -0
  44. package/src/react-native/expo-metro.ts +212 -0
  45. package/src/react-native/expo.ts +175 -0
  46. package/src/react-native/git.ts +25 -0
  47. package/src/react-native/javascript.ts +68 -1
  48. package/src/react-native/metro.ts +3 -3
  49. package/src/react-native/react-native-wizard.ts +72 -76
  50. package/src/react-native/xcode.ts +21 -5
  51. package/src/remix/codemods/handle-error.ts +57 -37
  52. package/src/remix/templates.ts +3 -3
  53. package/src/utils/clack-utils.ts +4 -4
  54. package/test/react-native/expo-metro.test.ts +81 -0
  55. package/test/react-native/expo.test.ts +86 -0
  56. package/test/react-native/xcode.test.ts +90 -0
@@ -73,14 +73,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
73
73
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
74
  };
75
75
  Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.runReactNativeWizardWithTelemetry = exports.runReactNativeWizard = exports.SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = exports.SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = exports.SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = exports.SUPPORTED_RN_RANGE = exports.RN_HUMAN_NAME = exports.RN_PACKAGE = exports.RN_SDK_PACKAGE = void 0;
76
+ exports.runReactNativeWizardWithTelemetry = exports.runReactNativeWizard = exports.SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = exports.SDK_EXPO_SUPPORTED_SDK_RANGE = exports.SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = exports.SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = exports.SUPPORTED_EXPO_RANGE = exports.SUPPORTED_RN_RANGE = exports.RN_HUMAN_NAME = exports.RN_PACKAGE = exports.RN_SDK_PACKAGE = void 0;
77
77
  /* eslint-disable max-lines */
78
78
  // @ts-ignore - clack is ESM and TS complains about that. It works though
79
79
  var prompts_1 = __importDefault(require("@clack/prompts"));
80
80
  var chalk_1 = __importDefault(require("chalk"));
81
81
  var fs = __importStar(require("fs"));
82
- var path = __importStar(require("path"));
83
- var process = __importStar(require("process"));
84
82
  var clack_utils_1 = require("../utils/clack-utils");
85
83
  var package_json_1 = require("../utils/package-json");
86
84
  var cocoapod_1 = require("../apple/cocoapod");
@@ -95,17 +93,29 @@ var Sentry = __importStar(require("@sentry/node"));
95
93
  var semver_1 = require("../utils/semver");
96
94
  var url_1 = require("../utils/url");
97
95
  var metro_1 = require("./metro");
96
+ var expo_1 = require("./expo");
97
+ var expo_metro_1 = require("./expo-metro");
98
+ var expo_env_file_1 = require("./expo-env-file");
98
99
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
99
100
  var xcode = require('xcode');
100
101
  exports.RN_SDK_PACKAGE = '@sentry/react-native';
101
102
  exports.RN_PACKAGE = 'react-native';
102
103
  exports.RN_HUMAN_NAME = 'React Native';
103
104
  exports.SUPPORTED_RN_RANGE = '>=0.69.0';
104
- // The following SDK version ship with bundled Xcode scripts
105
- // which simplifies the Xcode Build Phases setup.
105
+ exports.SUPPORTED_EXPO_RANGE = '>=50.0.0';
106
+ /**
107
+ * The following SDK version ship with bundled Xcode scripts
108
+ * which simplifies the Xcode Build Phases setup.
109
+ */
106
110
  exports.SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';
107
- // The following SDK version ship with Sentry Metro plugin
111
+ /**
112
+ * The following SDK version ship with Sentry Metro plugin
113
+ */
108
114
  exports.SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';
115
+ /**
116
+ * The following SDK version ship with bundled Expo plugin
117
+ */
118
+ exports.SDK_EXPO_SUPPORTED_SDK_RANGE = ">=5.16.0";
109
119
  // The following SDK version shipped `withSentryConfig`
110
120
  exports.SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = '>=5.17.0';
111
121
  function runReactNativeWizard(params) {
@@ -121,7 +131,7 @@ function runReactNativeWizard(params) {
121
131
  exports.runReactNativeWizard = runReactNativeWizard;
122
132
  function runReactNativeWizardWithTelemetry(options) {
123
133
  return __awaiter(this, void 0, void 0, function () {
124
- var packageJson, rnVersion, _a, selectedProject, authToken, sentryUrl, orgSlug, projectSlug, projectId, cliConfig, sdkVersion, _b, _c, confirmedFirstException;
134
+ var packageJson, hasInstalled, rnVersion, sdkVersion, _a, _b, expoVersion, isExpo, _c, selectedProject, authToken, sentryUrl, orgSlug, projectSlug, projectId, cliConfig, confirmedFirstException;
125
135
  return __generator(this, function (_d) {
126
136
  switch (_d.label) {
127
137
  case 0:
@@ -140,6 +150,12 @@ function runReactNativeWizardWithTelemetry(options) {
140
150
  return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
141
151
  case 2:
142
152
  packageJson = _d.sent();
153
+ hasInstalled = function (dep) { return (0, package_json_1.hasPackageInstalled)(dep, packageJson); };
154
+ if (hasInstalled('sentry-expo')) {
155
+ Sentry.setTag('has-sentry-expo-installed', true);
156
+ (0, expo_1.printSentryExpoMigrationOutro)();
157
+ return [2 /*return*/];
158
+ }
143
159
  return [4 /*yield*/, (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, exports.RN_PACKAGE, exports.RN_HUMAN_NAME)];
144
160
  case 3:
145
161
  _d.sent();
@@ -150,13 +166,47 @@ function runReactNativeWizardWithTelemetry(options) {
150
166
  packageVersion: rnVersion,
151
167
  packageId: exports.RN_PACKAGE,
152
168
  acceptableVersions: exports.SUPPORTED_RN_RANGE,
169
+ note: "Please upgrade to ".concat(exports.SUPPORTED_RN_RANGE, " if you wish to use the Sentry Wizard.\nOr setup using ").concat(chalk_1.default.cyan('https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/')),
153
170
  })];
154
171
  case 4:
155
172
  _d.sent();
156
173
  _d.label = 5;
157
- case 5: return [4 /*yield*/, (0, clack_utils_1.getOrAskForProjectData)(options, 'react-native')];
174
+ case 5: return [4 /*yield*/, (0, clack_utils_1.installPackage)({
175
+ packageName: exports.RN_SDK_PACKAGE,
176
+ alreadyInstalled: (0, package_json_1.hasPackageInstalled)(exports.RN_SDK_PACKAGE, packageJson),
177
+ })];
158
178
  case 6:
159
- _a = _d.sent(), selectedProject = _a.selectedProject, authToken = _a.authToken, sentryUrl = _a.sentryUrl;
179
+ _d.sent();
180
+ _a = package_json_1.getPackageVersion;
181
+ _b = [exports.RN_SDK_PACKAGE];
182
+ return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
183
+ case 7:
184
+ sdkVersion = _a.apply(void 0, _b.concat([_d.sent()]));
185
+ expoVersion = (0, package_json_1.getPackageVersion)('expo', packageJson);
186
+ isExpo = !!expoVersion;
187
+ if (!(expoVersion && sdkVersion)) return [3 /*break*/, 10];
188
+ return [4 /*yield*/, (0, clack_utils_1.confirmContinueIfPackageVersionNotSupported)({
189
+ packageName: 'Sentry React Native SDK',
190
+ packageVersion: sdkVersion,
191
+ packageId: exports.RN_SDK_PACKAGE,
192
+ acceptableVersions: exports.SDK_EXPO_SUPPORTED_SDK_RANGE,
193
+ note: "Please upgrade to ".concat(exports.SDK_EXPO_SUPPORTED_SDK_RANGE, " to continue with the wizard in this Expo project."),
194
+ })];
195
+ case 8:
196
+ _d.sent();
197
+ return [4 /*yield*/, (0, clack_utils_1.confirmContinueIfPackageVersionNotSupported)({
198
+ packageName: 'Expo SDK',
199
+ packageVersion: expoVersion,
200
+ packageId: 'expo',
201
+ acceptableVersions: exports.SUPPORTED_EXPO_RANGE,
202
+ note: "Please upgrade to ".concat(exports.SUPPORTED_EXPO_RANGE, " to continue with the wizard in this Expo project."),
203
+ })];
204
+ case 9:
205
+ _d.sent();
206
+ _d.label = 10;
207
+ case 10: return [4 /*yield*/, (0, clack_utils_1.getOrAskForProjectData)(options, 'react-native')];
208
+ case 11:
209
+ _c = _d.sent(), selectedProject = _c.selectedProject, authToken = _c.authToken, sentryUrl = _c.sentryUrl;
160
210
  orgSlug = selectedProject.organization.slug;
161
211
  projectSlug = selectedProject.slug;
162
212
  projectId = selectedProject.id;
@@ -166,44 +216,51 @@ function runReactNativeWizardWithTelemetry(options) {
166
216
  project: projectSlug,
167
217
  url: sentryUrl,
168
218
  };
169
- return [4 /*yield*/, (0, clack_utils_1.installPackage)({
170
- packageName: exports.RN_SDK_PACKAGE,
171
- alreadyInstalled: (0, package_json_1.hasPackageInstalled)(exports.RN_SDK_PACKAGE, packageJson),
219
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-app-js', function () {
220
+ return (0, javascript_1.addSentryInit)({ dsn: selectedProject.keys[0].dsn.public });
172
221
  })];
173
- case 7:
222
+ case 12:
174
223
  _d.sent();
175
- _b = package_json_1.getPackageVersion;
176
- _c = [exports.RN_SDK_PACKAGE];
177
- return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
178
- case 8:
179
- sdkVersion = _b.apply(void 0, _c.concat([_d.sent()]));
180
- return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-js', function () {
181
- return addSentryInit({ dsn: selectedProject.keys[0].dsn.public });
224
+ if (!isExpo) return [3 /*break*/, 15];
225
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-expo-app-config', function () {
226
+ return (0, expo_1.patchExpoAppConfig)(cliConfig);
182
227
  })];
183
- case 9:
228
+ case 13:
184
229
  _d.sent();
185
- return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-metro-config', function () {
186
- return addSentryToMetroConfig({ sdkVersion: sdkVersion });
187
- })];
188
- case 10:
230
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('add-expo-env-local', function () { return (0, expo_env_file_1.addExpoEnvLocal)(cliConfig); })];
231
+ case 14:
232
+ _d.sent();
233
+ _d.label = 15;
234
+ case 15:
235
+ if (!isExpo) return [3 /*break*/, 17];
236
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-metro-config', expo_metro_1.addSentryToExpoMetroConfig)];
237
+ case 16:
238
+ _d.sent();
239
+ return [3 /*break*/, 19];
240
+ case 17: return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-metro-config', function () {
241
+ return addSentryToMetroConfig({ sdkVersion: sdkVersion });
242
+ })];
243
+ case 18:
189
244
  _d.sent();
190
- if (!fs.existsSync('ios')) return [3 /*break*/, 12];
245
+ _d.label = 19;
246
+ case 19:
247
+ if (!fs.existsSync('ios')) return [3 /*break*/, 21];
191
248
  Sentry.setTag('patch-ios', true);
192
249
  return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-xcode-files', function () {
193
250
  return patchXcodeFiles(cliConfig, { sdkVersion: sdkVersion });
194
251
  })];
195
- case 11:
252
+ case 20:
196
253
  _d.sent();
197
- _d.label = 12;
198
- case 12:
199
- if (!fs.existsSync('android')) return [3 /*break*/, 14];
254
+ _d.label = 21;
255
+ case 21:
256
+ if (!fs.existsSync('android')) return [3 /*break*/, 23];
200
257
  Sentry.setTag('patch-android', true);
201
258
  return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-android-files', function () { return patchAndroidFiles(cliConfig); })];
202
- case 13:
259
+ case 22:
203
260
  _d.sent();
204
- _d.label = 14;
205
- case 14: return [4 /*yield*/, confirmFirstSentryException(sentryUrl, orgSlug, projectId)];
206
- case 15:
261
+ _d.label = 23;
262
+ case 23: return [4 /*yield*/, confirmFirstSentryException(sentryUrl, orgSlug, projectId)];
263
+ case 24:
207
264
  confirmedFirstException = _d.sent();
208
265
  Sentry.setTag('user-confirmed-first-error', confirmedFirstException);
209
266
  if (confirmedFirstException) {
@@ -237,50 +294,6 @@ function addSentryToMetroConfig(_a) {
237
294
  return (0, metro_1.patchMetroConfigWithSentrySerializer)();
238
295
  }
239
296
  }
240
- function addSentryInit(_a) {
241
- var dsn = _a.dsn;
242
- return __awaiter(this, void 0, void 0, function () {
243
- var prefixGlob, suffixGlob, universalGlob, jsFileGlob, jsPath, jsRelativePath, js, includesSentry;
244
- return __generator(this, function (_b) {
245
- switch (_b.label) {
246
- case 0:
247
- prefixGlob = '{.,./src}';
248
- suffixGlob = '@(j|t|cj|mj)s?(x)';
249
- universalGlob = "App.".concat(suffixGlob);
250
- jsFileGlob = "".concat(prefixGlob, "/+(").concat(universalGlob, ")");
251
- jsPath = (0, telemetry_1.traceStep)('find-app-js-file', function () {
252
- return (0, glob_1.getFirstMatchedPath)(jsFileGlob);
253
- });
254
- Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
255
- if (!!jsPath) return [3 /*break*/, 2];
256
- prompts_1.default.log.warn("Could not find main App file using ".concat(chalk_1.default.cyan(jsFileGlob), "."));
257
- return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)('App.js', (0, javascript_1.getSentryInitColoredCodeSnippet)(dsn), 'This ensures the Sentry SDK is ready to capture errors.')];
258
- case 1:
259
- _b.sent();
260
- return [2 /*return*/];
261
- case 2:
262
- jsRelativePath = path.relative(process.cwd(), jsPath);
263
- js = fs.readFileSync(jsPath, 'utf-8');
264
- includesSentry = (0, javascript_1.doesJsCodeIncludeSdkSentryImport)(js, {
265
- sdkPackageName: exports.RN_SDK_PACKAGE,
266
- });
267
- if (includesSentry) {
268
- Sentry.setTag('app-js-file-status', 'already-includes-sentry');
269
- prompts_1.default.log.warn("".concat(chalk_1.default.cyan(jsRelativePath), " already includes Sentry. We wont't add it again."));
270
- return [2 /*return*/];
271
- }
272
- (0, telemetry_1.traceStep)('add-sentry-init', function () {
273
- var newContent = (0, javascript_1.addSentryInitWithSdkImport)(js, { dsn: dsn });
274
- prompts_1.default.log.success("Added ".concat(chalk_1.default.cyan('Sentry.init'), " to ").concat(chalk_1.default.cyan(jsRelativePath), "."));
275
- fs.writeFileSync(jsPath, newContent, 'utf-8');
276
- });
277
- Sentry.setTag('app-js-file-status', 'added-sentry-init');
278
- prompts_1.default.log.success(chalk_1.default.green("".concat(chalk_1.default.cyan(jsRelativePath), " changes saved.")));
279
- return [2 /*return*/];
280
- }
281
- });
282
- });
283
- }
284
297
  function confirmFirstSentryException(url, orgSlug, projectId) {
285
298
  return __awaiter(this, void 0, void 0, function () {
286
299
  var issuesStreamUrl, firstErrorConfirmed;
@@ -1 +1 @@
1
- {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,qCAAyB;AACzB,yCAA6B;AAC7B,+CAAmC;AACnC,oDAa8B;AAC9B,sDAA+E;AAC/E,8CAA+C;AAC/C,yBAA8B;AAC9B,iCAUiB;AACjB,mCAIkB;AAClB,yCAAsD;AACtD,+BAA8E;AAE9E,2CAIsB;AACtB,0CAAwD;AACxD,mDAAuC;AACvC,0CAAuD;AACvD,oCAAiD;AACjD,iCAGiB;AAEjB,mEAAmE;AACnE,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAElB,QAAA,cAAc,GAAG,sBAAsB,CAAC;AAExC,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAE7C,4DAA4D;AAC5D,iDAAiD;AACpC,QAAA,qCAAqC,GAAG,UAAU,CAAC;AAEhE,0DAA0D;AAC7C,QAAA,2CAA2C,GAAG,UAAU,CAAC;AAEtE,uDAAuD;AAC1C,QAAA,uDAAuD,GAClE,UAAU,CAAC;AAOb,SAAsB,oBAAoB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AAG,SAa9B;gCACD,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;gCACnE,sBAAO,sBAAsB,EAAC;;;qBAC/B,CAAC,EAAC;;;CACJ","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - 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';\nimport * as path from 'path';\nimport * as process from 'process';\nimport {\n CliSetupConfigContent,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { podInstall } from '../apple/cocoapod';\nimport { platform } from 'os';\nimport {\n getValidExistingBuildPhases,\n findBundlePhase,\n patchBundlePhase,\n findDebugFilesUploadPhase,\n addDebugFilesUploadPhaseWithCli,\n writeXcodeProject,\n addSentryWithCliToBundleShellScript,\n addSentryWithBundledScriptsToBundleShellScript,\n addDebugFilesUploadPhaseWithBundledScripts,\n} from './xcode';\nimport {\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n addRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport { runReactNativeUninstall } from './uninstall';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport { ReactNativeWizardOptions } from './options';\nimport {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n getSentryInitColoredCodeSnippet,\n} from './javascript';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as Sentry from '@sentry/node';\nimport { fulfillsVersionRange } from '../utils/semver';\nimport { getIssueStreamUrl } from '../utils/url';\nimport {\n patchMetroConfigWithSentrySerializer,\n patchMetroWithSentryConfig,\n} from './metro';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst xcode = require('xcode');\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\n\n// The following SDK version ship with bundled Xcode scripts\n// which simplifies the Xcode Build Phases setup.\nexport const SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n// The following SDK version ship with Sentry Metro plugin\nexport const SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n// The following SDK version shipped `withSentryConfig`\nexport const SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE =\n '>=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 },\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 printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\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 });\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 await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n\n await traceStep('patch-js', () =>\n addSentryInit({ dsn: selectedProject.keys[0].dsn.public }),\n );\n\n await traceStep('patch-metro-config', () =>\n addSentryToMetroConfig({ sdkVersion }),\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 const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\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:\n SDK_SENTRY_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: SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n return patchMetroConfigWithSentrySerializer();\n }\n}\n\nasync function addSentryInit({ dsn }: { dsn: string }) {\n const prefixGlob = '{.,./src}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `App.${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file using ${chalk.cyan(jsFileGlob)}.`,\n );\n await showCopyPasteInstructions(\n 'App.js',\n getSentryInitColoredCodeSnippet(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, { dsn });\n\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\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 traceStep('patch-bundle-phase', () => {\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: SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n } else {\n 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: SDK_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,8BAA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H;AAED,SAAe,iBAAiB;;;;YAC9B,sBAAO,IAAA,qBAAS,EAAC,qBAAqB,EAAE;;;;oCACP,qBAAM,IAAA,8BAAgB,EACnD,iBAAK,CAAC,MAAM,CAAC;oCACX,OAAO,EAAE,uCAAuC;oCAChD,OAAO,EAAE;wCACP;4CACE,KAAK,EAAE,IAAI;4CACX,KAAK,EAAE,KAAK;4CACZ,IAAI,EAAE,mEAAmE;yCAC1E;wCACD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;qCAChD;oCACD,YAAY,EAAE,IAAI;iCACnB,CAAC,CACH,EAAA;;gCAbK,sBAAsB,GAAG,SAa9B;gCACD,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;gCACnE,sBAAO,sBAAsB,EAAC;;;qBAC/B,CAAC,EAAC;;;CACJ","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - 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 {\n CliSetupConfigContent,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { podInstall } from '../apple/cocoapod';\nimport { platform } from 'os';\nimport {\n getValidExistingBuildPhases,\n findBundlePhase,\n patchBundlePhase,\n findDebugFilesUploadPhase,\n addDebugFilesUploadPhaseWithCli,\n writeXcodeProject,\n addSentryWithCliToBundleShellScript,\n addSentryWithBundledScriptsToBundleShellScript,\n addDebugFilesUploadPhaseWithBundledScripts,\n} from './xcode';\nimport {\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n addRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport { runReactNativeUninstall } from './uninstall';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport { ReactNativeWizardOptions } from './options';\nimport { addSentryInit } from './javascript';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as Sentry from '@sentry/node';\nimport { fulfillsVersionRange } from '../utils/semver';\nimport { getIssueStreamUrl } from '../utils/url';\nimport {\n patchMetroConfigWithSentrySerializer,\n patchMetroWithSentryConfig,\n} from './metro';\nimport { patchExpoAppConfig, printSentryExpoMigrationOutro } from './expo';\nimport { addSentryToExpoMetroConfig } from './expo-metro';\nimport { addExpoEnvLocal } from './expo-env-file';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst xcode = require('xcode');\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\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 SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n/**\n * The following SDK version ship with Sentry Metro plugin\n */\nexport const SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n/**\n * The following SDK version ship with bundled Expo plugin\n */\nexport const SDK_EXPO_SUPPORTED_SDK_RANGE = `>=5.16.0`;\n\n// The following SDK version shipped `withSentryConfig`\nexport const SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE =\n '>=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 },\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 printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\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 });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\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: SDK_EXPO_SUPPORTED_SDK_RANGE,\n note: `Please upgrade to ${SDK_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 await traceStep('patch-app-js', () =>\n addSentryInit({ dsn: selectedProject.keys[0].dsn.public }),\n );\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 const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\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:\n SDK_SENTRY_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: SDK_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 traceStep('patch-bundle-phase', () => {\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: SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n } else {\n 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: SDK_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"]}
@@ -103,9 +103,20 @@ function doesBundlePhaseIncludeSentry(buildPhase) {
103
103
  }
104
104
  exports.doesBundlePhaseIncludeSentry = doesBundlePhaseIncludeSentry;
105
105
  function addSentryWithBundledScriptsToBundleShellScript(script) {
106
- return script.replace('$REACT_NATIVE_XCODE',
107
- // eslint-disable-next-line no-useless-escape
108
- '\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\"');
106
+ var isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');
107
+ if (isLikelyPlainReactNativeScript) {
108
+ return script.replace('$REACT_NATIVE_XCODE',
109
+ // eslint-disable-next-line no-useless-escape
110
+ '\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\"');
111
+ }
112
+ var isLikelyExpoScript = script.includes('expo');
113
+ if (isLikelyExpoScript) {
114
+ var SENTRY_REACT_NATIVE_XCODE_PATH_1 = "`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"`";
115
+ return script.replace(/^.*?(packager|scripts)\/react-native-xcode\.sh\s*(\\'\\\\")?/m,
116
+ // eslint-disable-next-line no-useless-escape
117
+ function (match) { return "/bin/sh ".concat(SENTRY_REACT_NATIVE_XCODE_PATH_1, " ").concat(match); });
118
+ }
119
+ return script;
109
120
  }
110
121
  exports.addSentryWithBundledScriptsToBundleShellScript = addSentryWithBundledScriptsToBundleShellScript;
111
122
  function addSentryWithCliToBundleShellScript(script) {
@@ -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,qCAAyB;AACzB,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAK1B,8DAA8D;AAC9D,SAAgB,2BAA2B,CAAC,YAAiB;IAC3D,IAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,IAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,IAAI,EAAE,CAAC;IAC7E,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;KAC7B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AATD,kEASC;AAED,SAAgB,gBAAgB,CAC9B,WAAmC,EACnC,KAAiC;IAEjC,IAAI,CAAC,WAAW,EAAE;QAChB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yBAAkB,eAAK,CAAC,IAAI,CAC1B,qCAAqC,CACtC,kBAAe,CACjB,CAAC;QACF,OAAO;KACR;IAED,IAAM,yBAAyB,GAAG,4BAA4B,CAAC,WAAW,CAAC,CAAC;IAC5E,IAAI,yBAAyB,EAAE;QAC7B,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,sBAAe,eAAK,CAAC,IAAI,CACvB,qCAAqC,CACtC,8BAA2B,CAC7B,CAAC;QACF,OAAO;KACR;IAED,IAAM,MAAM,GAAW,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC3D,WAAW,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,KA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U,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;IAC5C,IAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAClE,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACxD,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,wBAAiB,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAiB,CAAC,CAC5E,CAAC;AACJ,CAAC;AAXD,8CAWC","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 'fs';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\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 function patchBundlePhase(\n bundlePhase: BuildPhase | undefined,\n patch: (script: string) => string,\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 bundlePhase.shellScript = JSON.stringify(patch(script));\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 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}\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 {\n return 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\nexport function addSentryWithCliToBundleShellScript(script: string): string {\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.success(\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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function writeXcodeProject(xcodeProjectPath: string, xcodeProject: any) {\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(`Xcode project ${chalk.cyan(xcodeProjectPath)} changes saved.`),\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,qCAAyB;AACzB,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAK1B,8DAA8D;AAC9D,SAAgB,2BAA2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C;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,8DAcC;AAED,8DAA8D;AAC9D,SAAgB,iBAAiB,CAAC,gBAAwB,EAAE,YAAiB;IAC3E,IAAM,UAAU,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;IAC5C,IAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAClE,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACxD,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,wBAAiB,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAiB,CAAC,CAC5E,CAAC;AACJ,CAAC;AAXD,8CAWC","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 'fs';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\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 function patchBundlePhase(\n bundlePhase: BuildPhase | undefined,\n patch: (script: string) => string,\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 bundlePhase.shellScript = JSON.stringify(patch(script));\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 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}\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 {\n const isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');\n if (isLikelyPlainReactNativeScript) {\n return 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 return 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 return script;\n}\n\nexport function addSentryWithCliToBundleShellScript(script: string): string {\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.success(\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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function writeXcodeProject(xcodeProjectPath: string, xcodeProject: any) {\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(`Xcode project ${chalk.cyan(xcodeProjectPath)} changes saved.`),\n );\n}\n"]}
@@ -39,13 +39,21 @@ var magicast_1 = require("magicast");
39
39
  function instrumentHandleError(originalEntryServerMod, serverEntryFilename) {
40
40
  var _a, _b;
41
41
  var originalEntryServerModAST = originalEntryServerMod.$ast;
42
- var handleErrorFunction = originalEntryServerModAST.body.find(function (node) {
42
+ var handleErrorFunctionExport = originalEntryServerModAST.body.find(function (node) {
43
43
  var _a, _b;
44
- return node.type === 'ExportNamedDeclaration' &&
44
+ return (node.type === 'ExportNamedDeclaration' &&
45
45
  ((_a = node.declaration) === null || _a === void 0 ? void 0 : _a.type) === 'FunctionDeclaration' &&
46
- ((_b = node.declaration.id) === null || _b === void 0 ? void 0 : _b.name) === 'handleError';
46
+ ((_b = node.declaration.id) === null || _b === void 0 ? void 0 : _b.name) === 'handleError');
47
+ });
48
+ var handleErrorFunctionVariableDeclarationExport = originalEntryServerModAST.body.find(function (node) {
49
+ var _a;
50
+ return node.type === 'ExportNamedDeclaration' &&
51
+ ((_a = node.declaration) === null || _a === void 0 ? void 0 : _a.type) === 'VariableDeclaration' &&
52
+ // @ts-expect-error - id should always have a name in this case
53
+ node.declaration.declarations[0].id.name === 'handleError';
47
54
  });
48
- if (!handleErrorFunction) {
55
+ if (!handleErrorFunctionExport &&
56
+ !handleErrorFunctionVariableDeclarationExport) {
49
57
  prompts_1.default.log.warn("Could not find function ".concat(chalk_1.default.cyan('handleError'), " in ").concat(chalk_1.default.cyan(serverEntryFilename), ". Creating one for you."));
50
58
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
51
59
  var implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
@@ -55,42 +63,36 @@ function instrumentHandleError(originalEntryServerMod, serverEntryFilename) {
55
63
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
56
64
  recast.types.builders.exportNamedDeclaration(implementation));
57
65
  }
58
- else if ((0, utils_1.hasSentryContent)((0, magicast_1.generateCode)(handleErrorFunction).code, originalEntryServerMod.$code, 'captureRemixServerException')) {
66
+ else if ((handleErrorFunctionExport &&
67
+ ['wrapHandleErrorWithSentry', 'sentryHandleError'].some(function (util) {
68
+ return (0, utils_1.hasSentryContent)((0, magicast_1.generateCode)(handleErrorFunctionExport).code, originalEntryServerMod.$code, util);
69
+ })) ||
70
+ (handleErrorFunctionVariableDeclarationExport &&
71
+ ['wrapHandleErrorWithSentry', 'sentryHandleError'].some(function (util) {
72
+ return (0, utils_1.hasSentryContent)((0, magicast_1.generateCode)(handleErrorFunctionVariableDeclarationExport).code, originalEntryServerMod.$code, util);
73
+ }))) {
59
74
  return false;
60
75
  }
61
- else {
76
+ else if (handleErrorFunctionExport) {
62
77
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
63
78
  var implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
64
79
  .body[0];
65
- // @ts-expect-error - string works here because the AST is proxified by magicast
80
+ // If the current handleError function has a body, we need to merge the new implementation with the existing one
66
81
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
67
- handleErrorFunction.declaration.body.body.unshift(
68
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
69
- recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program.body[0].body.body[0]);
70
- // First parameter is the error
71
- //
72
- // @ts-expect-error - string works here because the AST is proxified by magicast
73
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
74
- handleErrorFunction.declaration.params[0] = implementation.params[0];
75
- // Second parameter is the request inside an object
76
- // Merging the object properties to make sure it includes request
77
- //
78
- // @ts-expect-error - string works here because the AST is proxified by magicast
82
+ (_a = implementation.declarations[0].init.arguments[0].body.body).unshift.apply(_a, handleErrorFunctionExport.declaration.body.body);
83
+ // @ts-expect-error - declaration works here because the AST is proxified by magicast
84
+ handleErrorFunctionExport.declaration = implementation;
85
+ }
86
+ else if (handleErrorFunctionVariableDeclarationExport) {
79
87
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
80
- if ((_b = (_a = handleErrorFunction.declaration.params) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.properties) {
81
- // @ts-expect-error - string works here because the AST is proxified by magicast
82
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
83
- handleErrorFunction.declaration.params[1].properties.push(
84
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
85
- implementation.params[1].properties[0]);
86
- }
87
- else {
88
- // Create second parameter if it doesn't exist
89
- //
90
- // @ts-expect-error - string works here because the AST is proxified by magicast
91
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
92
- handleErrorFunction.declaration.params[1] = implementation.params[1];
93
- }
88
+ var implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
89
+ .body[0];
90
+ // If the current handleError function has a body, we need to merge the new implementation with the existing one
91
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
92
+ (_b = implementation.declarations[0].init.arguments[0].body.body).unshift.apply(_b, handleErrorFunctionVariableDeclarationExport.declaration
93
+ .declarations[0].init.body.body);
94
+ // @ts-expect-error - declaration works here because the AST is proxified by magicast
95
+ handleErrorFunctionVariableDeclarationExport.declaration = implementation;
94
96
  }
95
97
  return true;
96
98
  }