@sentry/wizard 3.22.3 → 3.23.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 (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/apple/xcode-manager.js +5 -3
  4. package/dist/src/apple/xcode-manager.js.map +1 -1
  5. package/dist/src/nextjs/nextjs-wizard.js +3 -3
  6. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  7. package/dist/src/nextjs/templates.d.ts +3 -3
  8. package/dist/src/nextjs/templates.js +3 -3
  9. package/dist/src/nextjs/templates.js.map +1 -1
  10. package/dist/src/react-native/javascript.js +1 -1
  11. package/dist/src/react-native/javascript.js.map +1 -1
  12. package/dist/src/react-native/metro.d.ts +6 -1
  13. package/dist/src/react-native/metro.js +166 -17
  14. package/dist/src/react-native/metro.js.map +1 -1
  15. package/dist/src/react-native/react-native-wizard.d.ts +1 -0
  16. package/dist/src/react-native/react-native-wizard.js +19 -20
  17. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  18. package/dist/src/utils/ast-utils.d.ts +1 -1
  19. package/dist/src/utils/ast-utils.js +2 -2
  20. package/dist/src/utils/ast-utils.js.map +1 -1
  21. package/dist/test/nextjs/templates.test.d.ts +1 -0
  22. package/dist/test/nextjs/templates.test.js +38 -0
  23. package/dist/test/nextjs/templates.test.js.map +1 -0
  24. package/dist/test/react-native/javascript.test.js +1 -1
  25. package/dist/test/react-native/javascript.test.js.map +1 -1
  26. package/dist/test/react-native/metro.test.js +115 -0
  27. package/dist/test/react-native/metro.test.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/apple/xcode-manager.ts +9 -5
  30. package/src/nextjs/nextjs-wizard.ts +3 -3
  31. package/src/nextjs/templates.ts +7 -5
  32. package/src/react-native/javascript.ts +3 -0
  33. package/src/react-native/metro.ts +208 -18
  34. package/src/react-native/react-native-wizard.ts +24 -7
  35. package/src/utils/ast-utils.ts +2 -2
  36. package/test/nextjs/templates.test.ts +147 -0
  37. package/test/react-native/javascript.test.ts +3 -0
  38. package/test/react-native/metro.test.ts +113 -0
@@ -62,7 +62,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
62
62
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
63
  };
64
64
  Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.getMetroConfigObject = exports.addSentrySerializerRequireToMetroConfig = exports.addSentrySerializerToMetroConfig = exports.removeSentryRequire = exports.removeSentrySerializerFromMetroConfig = exports.unPatchMetroConfig = exports.patchMetroConfig = void 0;
65
+ exports.getModuleExportsAssignmentRight = exports.getMetroConfigObject = exports.addSentryMetroRequireToMetroConfig = exports.addSentrySerializerRequireToMetroConfig = exports.addSentrySerializerToMetroConfig = exports.removeSentryRequire = exports.removeSentrySerializerFromMetroConfig = exports.unPatchMetroConfig = exports.patchMetroConfigWithSentrySerializer = exports.patchMetroWithSentryConfigInMemory = exports.patchMetroWithSentryConfig = void 0;
66
66
  // @ts-ignore - clack is ESM and TS complains about that. It works though
67
67
  var clack = __importStar(require("@clack/prompts"));
68
68
  // @ts-ignore - magicast is ESM and TS complains about that. It works though
@@ -75,7 +75,88 @@ var recast = __importStar(require("recast"));
75
75
  var chalk_1 = __importDefault(require("chalk"));
76
76
  var b = recast.types.builders;
77
77
  var metroConfigPath = 'metro.config.js';
78
- function patchMetroConfig() {
78
+ function patchMetroWithSentryConfig() {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var mod, showInstructions, success, saved;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0: return [4 /*yield*/, parseMetroConfig()];
84
+ case 1:
85
+ mod = _a.sent();
86
+ showInstructions = function () {
87
+ return (0, clack_utils_1.showCopyPasteInstructions)(metroConfigPath, getMetroWithSentryConfigSnippet(true));
88
+ };
89
+ return [4 /*yield*/, patchMetroWithSentryConfigInMemory(mod, showInstructions)];
90
+ case 2:
91
+ success = _a.sent();
92
+ if (!success) {
93
+ return [2 /*return*/];
94
+ }
95
+ return [4 /*yield*/, writeMetroConfig(mod)];
96
+ case 3:
97
+ saved = _a.sent();
98
+ if (!saved) return [3 /*break*/, 4];
99
+ clack.log.success(chalk_1.default.green("".concat(chalk_1.default.cyan(metroConfigPath), " changes saved.")));
100
+ return [3 /*break*/, 6];
101
+ case 4:
102
+ clack.log.warn("Could not save changes to ".concat(chalk_1.default.cyan(metroConfigPath), ", please follow the manual steps."));
103
+ return [4 /*yield*/, showInstructions()];
104
+ case 5: return [2 /*return*/, _a.sent()];
105
+ case 6: return [2 /*return*/];
106
+ }
107
+ });
108
+ });
109
+ }
110
+ exports.patchMetroWithSentryConfig = patchMetroWithSentryConfig;
111
+ function patchMetroWithSentryConfigInMemory(mod, showInstructions) {
112
+ return __awaiter(this, void 0, void 0, function () {
113
+ var shouldContinue, configExpression, wrappedConfig, replacedModuleExportsRight, addedSentryMetroImport;
114
+ return __generator(this, function (_a) {
115
+ switch (_a.label) {
116
+ case 0:
117
+ if (!(0, ast_utils_1.hasSentryContent)(mod.$ast)) return [3 /*break*/, 3];
118
+ return [4 /*yield*/, confirmPathMetroConfig()];
119
+ case 1:
120
+ shouldContinue = _a.sent();
121
+ if (!!shouldContinue) return [3 /*break*/, 3];
122
+ return [4 /*yield*/, showInstructions()];
123
+ case 2:
124
+ _a.sent();
125
+ return [2 /*return*/, false];
126
+ case 3:
127
+ configExpression = getModuleExportsAssignmentRight(mod.$ast);
128
+ if (!!configExpression) return [3 /*break*/, 5];
129
+ clack.log.warn('Could not find Metro config, please follow the manual steps.');
130
+ return [4 /*yield*/, showInstructions()];
131
+ case 4:
132
+ _a.sent();
133
+ return [2 /*return*/, false];
134
+ case 5:
135
+ wrappedConfig = wrapWithSentryConfig(configExpression);
136
+ replacedModuleExportsRight = replaceModuleExportsRight(mod.$ast, wrappedConfig);
137
+ if (!!replacedModuleExportsRight) return [3 /*break*/, 7];
138
+ clack.log.warn('Could not automatically wrap the config export, please follow the manual steps.');
139
+ return [4 /*yield*/, showInstructions()];
140
+ case 6:
141
+ _a.sent();
142
+ return [2 /*return*/, false];
143
+ case 7:
144
+ addedSentryMetroImport = addSentryMetroRequireToMetroConfig(mod.$ast);
145
+ if (!!addedSentryMetroImport) return [3 /*break*/, 9];
146
+ clack.log.warn('Could not add `@sentry/react-native/metro` import to Metro config, please follow the manual steps.');
147
+ return [4 /*yield*/, showInstructions()];
148
+ case 8:
149
+ _a.sent();
150
+ return [2 /*return*/, false];
151
+ case 9:
152
+ clack.log.success("Added Sentry Metro plugin to ".concat(chalk_1.default.cyan(metroConfigPath), "."));
153
+ return [2 /*return*/, true];
154
+ }
155
+ });
156
+ });
157
+ }
158
+ exports.patchMetroWithSentryConfigInMemory = patchMetroWithSentryConfigInMemory;
159
+ function patchMetroConfigWithSentrySerializer() {
79
160
  return __awaiter(this, void 0, void 0, function () {
80
161
  var mod, showInstructions, shouldContinue, configObj, addedSentrySerializer, addedSentrySerializerImport, saved;
81
162
  return __generator(this, function (_a) {
@@ -84,7 +165,7 @@ function patchMetroConfig() {
84
165
  case 1:
85
166
  mod = _a.sent();
86
167
  showInstructions = function () {
87
- return (0, clack_utils_1.showCopyPasteInstructions)(metroConfigPath, getMetroConfigSnippet(true));
168
+ return (0, clack_utils_1.showCopyPasteInstructions)(metroConfigPath, getMetroSentrySerializerSnippet(true));
88
169
  };
89
170
  if (!(0, ast_utils_1.hasSentryContent)(mod.$ast)) return [3 /*break*/, 4];
90
171
  return [4 /*yield*/, confirmPathMetroConfig()];
@@ -127,7 +208,7 @@ function patchMetroConfig() {
127
208
  });
128
209
  });
129
210
  }
130
- exports.patchMetroConfig = patchMetroConfig;
211
+ exports.patchMetroConfigWithSentrySerializer = patchMetroConfigWithSentrySerializer;
131
212
  function unPatchMetroConfig() {
132
213
  return __awaiter(this, void 0, void 0, function () {
133
214
  var mod, removedAtLeastOneRequire, removedSerializerConfig, saved;
@@ -295,12 +376,41 @@ function addSentrySerializerRequireToMetroConfig(program) {
295
376
  program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);
296
377
  }
297
378
  else {
298
- // insert at the end
299
- program.body.push(sentrySerializerRequire);
379
+ // insert at the beginning
380
+ program.body.unshift(sentrySerializerRequire);
300
381
  }
301
382
  return true;
302
383
  }
303
384
  exports.addSentrySerializerRequireToMetroConfig = addSentrySerializerRequireToMetroConfig;
385
+ function addSentryMetroRequireToMetroConfig(program) {
386
+ var lastRequireIndex = (0, ast_utils_1.getLastRequireIndex)(program);
387
+ var sentryMetroRequire = createSentryMetroRequire();
388
+ var sentryImportIndex = lastRequireIndex + 1;
389
+ if (sentryImportIndex < program.body.length) {
390
+ // insert after last require
391
+ program.body.splice(lastRequireIndex + 1, 0, sentryMetroRequire);
392
+ }
393
+ else {
394
+ // insert at the beginning
395
+ program.body.unshift(sentryMetroRequire);
396
+ }
397
+ return true;
398
+ }
399
+ exports.addSentryMetroRequireToMetroConfig = addSentryMetroRequireToMetroConfig;
400
+ function wrapWithSentryConfig(configObj) {
401
+ return b.callExpression(b.identifier('withSentryConfig'), [configObj]);
402
+ }
403
+ function replaceModuleExportsRight(program, wrappedConfig) {
404
+ var moduleExports = getModuleExports(program);
405
+ if (!moduleExports) {
406
+ return false;
407
+ }
408
+ if (moduleExports.expression.type === 'AssignmentExpression') {
409
+ moduleExports.expression.right = wrappedConfig;
410
+ return true;
411
+ }
412
+ return false;
413
+ }
304
414
  /**
305
415
  * Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');
306
416
  */
@@ -317,6 +427,22 @@ function createSentrySerializerRequire() {
317
427
  ])),
318
428
  ]);
319
429
  }
430
+ /**
431
+ * Creates const {withSentryConfig} = require('@sentry/react-native/metro');
432
+ */
433
+ function createSentryMetroRequire() {
434
+ return b.variableDeclaration('const', [
435
+ b.variableDeclarator(b.objectPattern([
436
+ b.objectProperty.from({
437
+ key: b.identifier('withSentryConfig'),
438
+ value: b.identifier('withSentryConfig'),
439
+ shorthand: true,
440
+ }),
441
+ ]), b.callExpression(b.identifier('require'), [
442
+ b.literal('@sentry/react-native/metro'),
443
+ ])),
444
+ ]);
445
+ }
320
446
  function confirmPathMetroConfig() {
321
447
  return __awaiter(this, void 0, void 0, function () {
322
448
  var shouldContinue;
@@ -367,8 +493,35 @@ function getMetroConfigObject(program) {
367
493
  Sentry.setTag('metro-config', 'config-variable');
368
494
  return configVariable.declarations[0].init;
369
495
  }
496
+ return getModuleExportsObject(program);
497
+ }
498
+ exports.getMetroConfigObject = getMetroConfigObject;
499
+ function getModuleExportsObject(program) {
500
+ // check module.exports
501
+ var moduleExports = getModuleExportsAssignmentRight(program);
502
+ if ((moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.type) === 'ObjectExpression') {
503
+ return moduleExports;
504
+ }
505
+ Sentry.setTag('metro-config', 'not-found');
506
+ return undefined;
507
+ }
508
+ function getModuleExportsAssignmentRight(program) {
370
509
  // check module.exports
371
- var moduleExports = program.body.find(function (s) {
510
+ var moduleExports = getModuleExports(program);
511
+ if ((moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression.type) === 'AssignmentExpression' &&
512
+ (moduleExports.expression.right.type === 'ObjectExpression' ||
513
+ moduleExports.expression.right.type === 'CallExpression' ||
514
+ moduleExports.expression.right.type === 'Identifier')) {
515
+ Sentry.setTag('metro-config', 'module-exports');
516
+ return moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression.right;
517
+ }
518
+ Sentry.setTag('metro-config', 'not-found');
519
+ return undefined;
520
+ }
521
+ exports.getModuleExportsAssignmentRight = getModuleExportsAssignmentRight;
522
+ function getModuleExports(program) {
523
+ // find module.exports
524
+ return program.body.find(function (s) {
372
525
  if (s.type === 'ExpressionStatement' &&
373
526
  s.expression.type === 'AssignmentExpression' &&
374
527
  s.expression.left.type === 'MemberExpression' &&
@@ -380,19 +533,15 @@ function getMetroConfigObject(program) {
380
533
  }
381
534
  return false;
382
535
  });
383
- if ((moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression).right.type ===
384
- 'ObjectExpression') {
385
- Sentry.setTag('metro-config', 'module-exports');
386
- return (moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression)
387
- .right;
388
- }
389
- Sentry.setTag('metro-config', 'not-found');
390
- return undefined;
391
536
  }
392
- exports.getMetroConfigObject = getMetroConfigObject;
393
- function getMetroConfigSnippet(colors) {
537
+ function getMetroSentrySerializerSnippet(colors) {
394
538
  return (0, clack_utils_1.makeCodeSnippet)(colors, function (unchanged, plus, _) {
395
539
  return unchanged("const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n".concat(plus("const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');"), "\n\nconst config = {\n ").concat(plus("serializer: {\n customSerializer: createSentryMetroSerializer(),\n },"), "\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);\n"));
396
540
  });
397
541
  }
542
+ function getMetroWithSentryConfigSnippet(colors) {
543
+ return (0, clack_utils_1.makeCodeSnippet)(colors, function (unchanged, plus, _) {
544
+ return unchanged("const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n".concat(plus("const {withSentryConfig} = require('@sentry/react-native/metro');"), "\n\nconst config = {};\n\nmodule.exports = ").concat(plus('withSentryConfig('), "mergeConfig(getDefaultConfig(__dirname), config)").concat(plus(')'), ";\n"));
545
+ });
546
+ }
398
547
  //# sourceMappingURL=metro.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metro.js","sourceRoot":"","sources":["../../../src/react-native/metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,4EAA4E;AAC5E,qCAAmE;AACnE,qCAAyB;AACzB,mDAAuC;AAEvC,gDAI4B;AAC5B,oDAI8B;AAE9B,6CAAiC;AAGjC,gDAA0B;AAE1B,IAAM,CAAC,GAAG,MAAM,CAAC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S,CAAC;AACnB,CAAC;AApDD,oDAoDC;AAED,SAAS,qBAAqB,CAAC,MAAe;IAC5C,OAAO,IAAA,6BAAe,EAAC,MAAM,EAAE,UAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAChD,OAAA,SAAS,CAAC,6FACZ,IAAI,CACJ,4GAA4G,CAC7G,qCAGG,IAAI,CAAC,2EAEJ,CAAC,iFAIL,CAAC;IAZE,CAYF,CACC,CAAC;AACJ,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { ProxifiedModule, parseModule, writeFile } from 'magicast';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport {\n getLastRequireIndex,\n hasSentryContent,\n removeRequire,\n} from '../utils/ast-utils';\nimport {\n abortIfCancelled,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\nimport chalk from 'chalk';\n\nconst b = recast.types.builders;\n\nconst metroConfigPath = 'metro.config.js';\n\nexport async function patchMetroConfig() {\n const mod = await parseMetroConfig();\n\n const showInstructions = () =>\n showCopyPasteInstructions(metroConfigPath, getMetroConfigSnippet(true));\n\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await confirmPathMetroConfig();\n if (!shouldContinue) {\n return await showInstructions();\n }\n }\n\n const configObj = getMetroConfigObject(mod.$ast as t.Program);\n if (!configObj) {\n clack.log.warn(\n 'Could not find Metro config object, please follow the manual steps.',\n );\n return showInstructions();\n }\n\n const addedSentrySerializer = addSentrySerializerToMetroConfig(configObj);\n if (!addedSentrySerializer) {\n clack.log.warn(\n 'Could not add Sentry serializer to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n const addedSentrySerializerImport = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n if (!addedSentrySerializerImport) {\n clack.log.warn(\n 'Could not add Sentry serializer import to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n clack.log.success(\n `Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,\n );\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport async function unPatchMetroConfig() {\n const mod = await parseMetroConfig();\n\n const removedAtLeastOneRequire = removeSentryRequire(mod.$ast as t.Program);\n const removedSerializerConfig = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n\n if (removedAtLeastOneRequire || removedSerializerConfig) {\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n `Removed Sentry Metro plugin from ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n } else {\n clack.log.warn(\n `No Sentry Metro plugin found in ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n}\n\nexport function removeSentrySerializerFromMetroConfig(\n program: t.Program,\n): boolean {\n const configObject = getMetroConfigObject(program);\n if (!configObject) {\n return false;\n }\n\n const serializerProp = getSerializerProp(configObject);\n if ('invalid' === serializerProp || 'undefined' === serializerProp) {\n return false;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n if (\n 'invalid' === customSerializerProp ||\n 'undefined' === customSerializerProp\n ) {\n return false;\n }\n\n if (\n serializerProp.value.type === 'ObjectExpression' &&\n customSerializerProp.value.type === 'CallExpression' &&\n customSerializerProp.value.callee.type === 'Identifier' &&\n customSerializerProp.value.callee.name === 'createSentryMetroSerializer'\n ) {\n if (customSerializerProp.value.arguments.length === 0) {\n // FROM serializer: { customSerializer: createSentryMetroSerializer() }\n // TO serializer: {}\n let removed = false;\n serializerProp.value.properties = serializerProp.value.properties.filter(\n (p) => {\n if (\n p.type === 'ObjectProperty' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'customSerializer'\n ) {\n removed = true;\n return false;\n }\n return true;\n },\n );\n\n if (removed) {\n return true;\n }\n } else {\n if (customSerializerProp.value.arguments[0].type !== 'SpreadElement') {\n // FROM serializer: { customSerializer: createSentryMetroSerializer(wrapperSerializer) }\n // TO serializer: { customSerializer: wrapperSerializer }\n customSerializerProp.value = customSerializerProp.value.arguments[0];\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function removeSentryRequire(program: t.Program): boolean {\n return removeRequire(program, '@sentry');\n}\n\nasync function parseMetroConfig(): Promise<ProxifiedModule> {\n const metroConfigContent = (\n await fs.promises.readFile(metroConfigPath)\n ).toString();\n\n return parseModule(metroConfigContent);\n}\n\nasync function writeMetroConfig(mod: ProxifiedModule): Promise<boolean> {\n try {\n await writeFile(mod.$ast, metroConfigPath);\n } catch (e) {\n clack.log.error(\n `Failed to write to ${chalk.cyan(metroConfigPath)}: ${JSON.stringify(e)}`,\n );\n return false;\n }\n return true;\n}\n\nexport function addSentrySerializerToMetroConfig(\n configObj: t.ObjectExpression,\n): boolean {\n const serializerProp = getSerializerProp(configObj);\n if ('invalid' === serializerProp) {\n return false;\n }\n\n // case 1: serializer property doesn't exist yet, so we can just add it\n if ('undefined' === serializerProp) {\n configObj.properties.push(\n b.objectProperty(\n b.identifier('serializer'),\n b.objectExpression([\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n ]),\n ),\n );\n return true;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n // case 2: serializer.customSerializer property doesn't exist yet, so we just add it\n if (\n 'undefined' === customSerializerProp &&\n serializerProp.value.type === 'ObjectExpression'\n ) {\n serializerProp.value.properties.push(\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n );\n return true;\n }\n\n return false;\n}\n\nfunction getCustomSerializerProp(\n prop: t.ObjectProperty,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const customSerializerProp =\n prop.value.type === 'ObjectExpression' &&\n prop.value.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'customSerializer',\n );\n\n if (!customSerializerProp) {\n return 'undefined';\n }\n\n if (customSerializerProp.type === 'ObjectProperty') {\n return customSerializerProp;\n }\n\n return 'invalid';\n}\n\nfunction getSerializerProp(\n obj: t.ObjectExpression,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const serializerProp = obj.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'serializer',\n );\n\n if (!serializerProp) {\n return 'undefined';\n }\n\n if (serializerProp.type === 'ObjectProperty') {\n return serializerProp;\n }\n\n return 'invalid';\n}\n\nexport function addSentrySerializerRequireToMetroConfig(\n program: t.Program,\n): boolean {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentrySerializerRequire = createSentrySerializerRequire();\n const sentryImportIndex = lastRequireIndex + 1;\n if (sentryImportIndex < program.body.length) {\n // insert after last require\n program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);\n } else {\n // insert at the end\n program.body.push(sentrySerializerRequire);\n }\n return true;\n}\n\n/**\n * Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\n */\nfunction createSentrySerializerRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('createSentryMetroSerializer'),\n value: b.identifier('createSentryMetroSerializer'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/dist/js/tools/sentryMetroSerializer'),\n ]),\n ),\n ]);\n}\n\nasync function confirmPathMetroConfig() {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `Metro Config already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Metro plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n }\n\n return shouldContinue;\n}\n\n/**\n * Returns value from `module.exports = value` or `const config = value`\n */\nexport function getMetroConfigObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n // check config variable\n const configVariable = program.body.find((s) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations.length === 1 &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].id.type === 'Identifier' &&\n s.declarations[0].id.name === 'config'\n ) {\n return true;\n }\n return false;\n }) as t.VariableDeclaration | undefined;\n\n if (\n configVariable?.declarations[0].type === 'VariableDeclarator' &&\n configVariable?.declarations[0].init?.type === 'ObjectExpression'\n ) {\n Sentry.setTag('metro-config', 'config-variable');\n return configVariable.declarations[0].init;\n }\n\n // check module.exports\n const moduleExports = program.body.find((s) => {\n if (\n s.type === 'ExpressionStatement' &&\n s.expression.type === 'AssignmentExpression' &&\n s.expression.left.type === 'MemberExpression' &&\n s.expression.left.object.type === 'Identifier' &&\n s.expression.left.object.name === 'module' &&\n s.expression.left.property.type === 'Identifier' &&\n s.expression.left.property.name === 'exports'\n ) {\n return true;\n }\n return false;\n }) as t.ExpressionStatement | undefined;\n\n if (\n (moduleExports?.expression as t.AssignmentExpression).right.type ===\n 'ObjectExpression'\n ) {\n Sentry.setTag('metro-config', 'module-exports');\n return (moduleExports?.expression as t.AssignmentExpression)\n .right as t.ObjectExpression;\n }\n\n Sentry.setTag('metro-config', 'not-found');\n return undefined;\n}\n\nfunction getMetroConfigSnippet(colors: boolean) {\n return makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n${plus(\n \"const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\",\n)}\n\nconst config = {\n ${plus(`serializer: {\n customSerializer: createSentryMetroSerializer(),\n },`)}\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);\n`),\n );\n}\n"]}
1
+ {"version":3,"file":"metro.js","sourceRoot":"","sources":["../../../src/react-native/metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,4EAA4E;AAC5E,qCAAmE;AACnE,qCAAyB;AACzB,mDAAuC;AAEvC,gDAI4B;AAC5B,oDAI8B;AAE9B,6CAAiC;AAGjC,gDAA0B;AAE1B,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC,IAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C,SAAsB,0BAA0B;;;;;wBAClC,qBAAM,gBAAgB,EAAE,EAAA;;oBAA9B,GAAG,GAAG,SAAwB;oBAE9B,gBAAgB,GAAG;wBACvB,OAAA,IAAA,uCAAyB,EACvB,eAAe,EACf,+BAA+B,CAAC,IAAI,CAAC,CACtC;oBAHD,CAGC,CAAC;oBAEY,qBAAM,kCAAkC,CACtD,GAAG,EACH,gBAAgB,CACjB,EAAA;;oBAHK,OAAO,GAAG,SAGf;oBACD,IAAI,CAAC,OAAO,EAAE;wBACZ,sBAAO;qBACR;oBAEa,qBAAM,gBAAgB,CAAC,GAAG,CAAC,EAAA;;oBAAnC,KAAK,GAAG,SAA2B;yBACrC,KAAK,EAAL,wBAAK;oBACP,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,UAAG,eAAK,CAAC,IAAI,CAAC,eAAe,CAAC,oBAAiB,CAAC,CAC7D,CAAC;;;oBAEF,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,oCAA6B,eAAK,CAAC,IAAI,CACrC,eAAe,CAChB,sCAAmC,CACrC,CAAC;oBACK,qBAAM,gBAAgB,EAAE,EAAA;wBAA/B,sBAAO,SAAwB,EAAC;;;;;CAE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IL,CAAC;IAZE,CAYF,CACC,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAe;IACtD,OAAO,IAAA,6BAAe,EAAC,MAAM,EAAE,UAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAChD,OAAA,SAAS,CAAC,6FACZ,IAAI,CAAC,mEAAmE,CAAC,wDAIxD,IAAI,CACjB,mBAAmB,CACpB,6DAAmD,IAAI,CAAC,GAAG,CAAC,QAChE,CAAC;IARE,CAQF,CACC,CAAC;AACJ,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { ProxifiedModule, parseModule, writeFile } from 'magicast';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport {\n getLastRequireIndex,\n hasSentryContent,\n removeRequire,\n} from '../utils/ast-utils';\nimport {\n abortIfCancelled,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\nimport chalk from 'chalk';\n\nconst b = recast.types.builders;\n\nconst metroConfigPath = 'metro.config.js';\n\nexport async function patchMetroWithSentryConfig() {\n const mod = await parseMetroConfig();\n\n const showInstructions = () =>\n showCopyPasteInstructions(\n metroConfigPath,\n getMetroWithSentryConfigSnippet(true),\n );\n\n const success = await patchMetroWithSentryConfigInMemory(\n mod,\n showInstructions,\n );\n if (!success) {\n return;\n }\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport async function patchMetroWithSentryConfigInMemory(\n mod: ProxifiedModule,\n showInstructions: () => Promise<void>,\n): Promise<boolean> {\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await confirmPathMetroConfig();\n if (!shouldContinue) {\n await showInstructions();\n return false;\n }\n }\n\n const configExpression = getModuleExportsAssignmentRight(\n mod.$ast as t.Program,\n );\n if (!configExpression) {\n clack.log.warn(\n 'Could not find Metro config, please follow the manual steps.',\n );\n await showInstructions();\n return false;\n }\n\n const wrappedConfig = wrapWithSentryConfig(configExpression);\n\n const replacedModuleExportsRight = replaceModuleExportsRight(\n mod.$ast as t.Program,\n wrappedConfig,\n );\n if (!replacedModuleExportsRight) {\n clack.log.warn(\n 'Could not automatically wrap the config export, please follow the manual steps.',\n );\n await showInstructions();\n return false;\n }\n\n const addedSentryMetroImport = addSentryMetroRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n if (!addedSentryMetroImport) {\n clack.log.warn(\n 'Could not add `@sentry/react-native/metro` import to Metro config, please follow the manual steps.',\n );\n await showInstructions();\n return false;\n }\n\n clack.log.success(\n `Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,\n );\n return true;\n}\n\nexport async function patchMetroConfigWithSentrySerializer() {\n const mod = await parseMetroConfig();\n\n const showInstructions = () =>\n showCopyPasteInstructions(\n metroConfigPath,\n getMetroSentrySerializerSnippet(true),\n );\n\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await confirmPathMetroConfig();\n if (!shouldContinue) {\n return await showInstructions();\n }\n }\n\n const configObj = getMetroConfigObject(mod.$ast as t.Program);\n if (!configObj) {\n clack.log.warn(\n 'Could not find Metro config object, please follow the manual steps.',\n );\n return showInstructions();\n }\n\n const addedSentrySerializer = addSentrySerializerToMetroConfig(configObj);\n if (!addedSentrySerializer) {\n clack.log.warn(\n 'Could not add Sentry serializer to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n const addedSentrySerializerImport = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n if (!addedSentrySerializerImport) {\n clack.log.warn(\n 'Could not add Sentry serializer import to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n clack.log.success(\n `Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,\n );\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport async function unPatchMetroConfig() {\n const mod = await parseMetroConfig();\n\n const removedAtLeastOneRequire = removeSentryRequire(mod.$ast as t.Program);\n const removedSerializerConfig = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n\n if (removedAtLeastOneRequire || removedSerializerConfig) {\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n `Removed Sentry Metro plugin from ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n } else {\n clack.log.warn(\n `No Sentry Metro plugin found in ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n}\n\nexport function removeSentrySerializerFromMetroConfig(\n program: t.Program,\n): boolean {\n const configObject = getMetroConfigObject(program);\n if (!configObject) {\n return false;\n }\n\n const serializerProp = getSerializerProp(configObject);\n if ('invalid' === serializerProp || 'undefined' === serializerProp) {\n return false;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n if (\n 'invalid' === customSerializerProp ||\n 'undefined' === customSerializerProp\n ) {\n return false;\n }\n\n if (\n serializerProp.value.type === 'ObjectExpression' &&\n customSerializerProp.value.type === 'CallExpression' &&\n customSerializerProp.value.callee.type === 'Identifier' &&\n customSerializerProp.value.callee.name === 'createSentryMetroSerializer'\n ) {\n if (customSerializerProp.value.arguments.length === 0) {\n // FROM serializer: { customSerializer: createSentryMetroSerializer() }\n // TO serializer: {}\n let removed = false;\n serializerProp.value.properties = serializerProp.value.properties.filter(\n (p) => {\n if (\n p.type === 'ObjectProperty' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'customSerializer'\n ) {\n removed = true;\n return false;\n }\n return true;\n },\n );\n\n if (removed) {\n return true;\n }\n } else {\n if (customSerializerProp.value.arguments[0].type !== 'SpreadElement') {\n // FROM serializer: { customSerializer: createSentryMetroSerializer(wrapperSerializer) }\n // TO serializer: { customSerializer: wrapperSerializer }\n customSerializerProp.value = customSerializerProp.value.arguments[0];\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function removeSentryRequire(program: t.Program): boolean {\n return removeRequire(program, '@sentry');\n}\n\nasync function parseMetroConfig(): Promise<ProxifiedModule> {\n const metroConfigContent = (\n await fs.promises.readFile(metroConfigPath)\n ).toString();\n\n return parseModule(metroConfigContent);\n}\n\nasync function writeMetroConfig(mod: ProxifiedModule): Promise<boolean> {\n try {\n await writeFile(mod.$ast, metroConfigPath);\n } catch (e) {\n clack.log.error(\n `Failed to write to ${chalk.cyan(metroConfigPath)}: ${JSON.stringify(e)}`,\n );\n return false;\n }\n return true;\n}\n\nexport function addSentrySerializerToMetroConfig(\n configObj: t.ObjectExpression,\n): boolean {\n const serializerProp = getSerializerProp(configObj);\n if ('invalid' === serializerProp) {\n return false;\n }\n\n // case 1: serializer property doesn't exist yet, so we can just add it\n if ('undefined' === serializerProp) {\n configObj.properties.push(\n b.objectProperty(\n b.identifier('serializer'),\n b.objectExpression([\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n ]),\n ),\n );\n return true;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n // case 2: serializer.customSerializer property doesn't exist yet, so we just add it\n if (\n 'undefined' === customSerializerProp &&\n serializerProp.value.type === 'ObjectExpression'\n ) {\n serializerProp.value.properties.push(\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n );\n return true;\n }\n\n return false;\n}\n\nfunction getCustomSerializerProp(\n prop: t.ObjectProperty,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const customSerializerProp =\n prop.value.type === 'ObjectExpression' &&\n prop.value.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'customSerializer',\n );\n\n if (!customSerializerProp) {\n return 'undefined';\n }\n\n if (customSerializerProp.type === 'ObjectProperty') {\n return customSerializerProp;\n }\n\n return 'invalid';\n}\n\nfunction getSerializerProp(\n obj: t.ObjectExpression,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const serializerProp = obj.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'serializer',\n );\n\n if (!serializerProp) {\n return 'undefined';\n }\n\n if (serializerProp.type === 'ObjectProperty') {\n return serializerProp;\n }\n\n return 'invalid';\n}\n\nexport function addSentrySerializerRequireToMetroConfig(\n program: t.Program,\n): boolean {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentrySerializerRequire = createSentrySerializerRequire();\n const sentryImportIndex = lastRequireIndex + 1;\n if (sentryImportIndex < program.body.length) {\n // insert after last require\n program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);\n } else {\n // insert at the beginning\n program.body.unshift(sentrySerializerRequire);\n }\n return true;\n}\n\nexport function addSentryMetroRequireToMetroConfig(\n program: t.Program,\n): boolean {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentryMetroRequire = createSentryMetroRequire();\n const sentryImportIndex = lastRequireIndex + 1;\n if (sentryImportIndex < program.body.length) {\n // insert after last require\n program.body.splice(lastRequireIndex + 1, 0, sentryMetroRequire);\n } else {\n // insert at the beginning\n program.body.unshift(sentryMetroRequire);\n }\n return true;\n}\n\nfunction wrapWithSentryConfig(\n configObj: t.Identifier | t.CallExpression | t.ObjectExpression,\n): t.CallExpression {\n return b.callExpression(b.identifier('withSentryConfig'), [configObj]);\n}\n\nfunction replaceModuleExportsRight(\n program: t.Program,\n wrappedConfig: t.CallExpression,\n): boolean {\n const moduleExports = getModuleExports(program);\n if (!moduleExports) {\n return false;\n }\n\n if (moduleExports.expression.type === 'AssignmentExpression') {\n moduleExports.expression.right = wrappedConfig;\n return true;\n }\n\n return false;\n}\n\n/**\n * Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\n */\nfunction createSentrySerializerRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('createSentryMetroSerializer'),\n value: b.identifier('createSentryMetroSerializer'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/dist/js/tools/sentryMetroSerializer'),\n ]),\n ),\n ]);\n}\n\n/**\n * Creates const {withSentryConfig} = require('@sentry/react-native/metro');\n */\nfunction createSentryMetroRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('withSentryConfig'),\n value: b.identifier('withSentryConfig'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/metro'),\n ]),\n ),\n ]);\n}\n\nasync function confirmPathMetroConfig() {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `Metro Config already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Metro plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n }\n\n return shouldContinue;\n}\n\n/**\n * Returns value from `module.exports = value` or `const config = value`\n */\nexport function getMetroConfigObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n // check config variable\n const configVariable = program.body.find((s) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations.length === 1 &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].id.type === 'Identifier' &&\n s.declarations[0].id.name === 'config'\n ) {\n return true;\n }\n return false;\n }) as t.VariableDeclaration | undefined;\n\n if (\n configVariable?.declarations[0].type === 'VariableDeclarator' &&\n configVariable?.declarations[0].init?.type === 'ObjectExpression'\n ) {\n Sentry.setTag('metro-config', 'config-variable');\n return configVariable.declarations[0].init;\n }\n\n return getModuleExportsObject(program);\n}\n\nfunction getModuleExportsObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n // check module.exports\n const moduleExports = getModuleExportsAssignmentRight(program);\n\n if (moduleExports?.type === 'ObjectExpression') {\n return moduleExports;\n }\n\n Sentry.setTag('metro-config', 'not-found');\n return undefined;\n}\n\nexport function getModuleExportsAssignmentRight(\n program: t.Program,\n): t.Identifier | t.CallExpression | t.ObjectExpression | undefined {\n // check module.exports\n const moduleExports = getModuleExports(program);\n\n if (\n moduleExports?.expression.type === 'AssignmentExpression' &&\n (moduleExports.expression.right.type === 'ObjectExpression' ||\n moduleExports.expression.right.type === 'CallExpression' ||\n moduleExports.expression.right.type === 'Identifier')\n ) {\n Sentry.setTag('metro-config', 'module-exports');\n return moduleExports?.expression.right;\n }\n\n Sentry.setTag('metro-config', 'not-found');\n return undefined;\n}\n\nfunction getModuleExports(\n program: t.Program,\n): t.ExpressionStatement | undefined {\n // find module.exports\n return program.body.find((s) => {\n if (\n s.type === 'ExpressionStatement' &&\n s.expression.type === 'AssignmentExpression' &&\n s.expression.left.type === 'MemberExpression' &&\n s.expression.left.object.type === 'Identifier' &&\n s.expression.left.object.name === 'module' &&\n s.expression.left.property.type === 'Identifier' &&\n s.expression.left.property.name === 'exports'\n ) {\n return true;\n }\n return false;\n }) as t.ExpressionStatement | undefined;\n}\n\nfunction getMetroSentrySerializerSnippet(colors: boolean) {\n return makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n${plus(\n \"const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\",\n)}\n\nconst config = {\n ${plus(`serializer: {\n customSerializer: createSentryMetroSerializer(),\n },`)}\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);\n`),\n );\n}\n\nfunction getMetroWithSentryConfigSnippet(colors: boolean) {\n return makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n${plus(\"const {withSentryConfig} = require('@sentry/react-native/metro');\")}\n\nconst config = {};\n\nmodule.exports = ${plus(\n 'withSentryConfig(',\n )}mergeConfig(getDefaultConfig(__dirname), config)${plus(')')};\n`),\n );\n}\n"]}
@@ -6,6 +6,7 @@ export declare const RN_HUMAN_NAME = "React Native";
6
6
  export declare const SUPPORTED_RN_RANGE = ">=0.69.0";
7
7
  export declare const SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = ">=5.11.0";
8
8
  export declare const SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = ">=5.11.0";
9
+ export declare const SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = ">=5.17.0";
9
10
  export type RNCliSetupConfigContent = Pick<Required<CliSetupConfigContent>, 'authToken' | 'org' | 'project' | 'url'>;
10
11
  export declare function runReactNativeWizard(params: ReactNativeWizardOptions): Promise<void>;
11
12
  export declare function runReactNativeWizardWithTelemetry(options: ReactNativeWizardOptions): Promise<void>;
@@ -73,7 +73,7 @@ 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_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_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;
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"));
@@ -106,6 +106,8 @@ exports.SUPPORTED_RN_RANGE = '>=0.69.0';
106
106
  exports.SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';
107
107
  // The following SDK version ship with Sentry Metro plugin
108
108
  exports.SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';
109
+ // The following SDK version shipped `withSentryConfig`
110
+ exports.SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = '>=5.17.0';
109
111
  function runReactNativeWizard(params) {
110
112
  return __awaiter(this, void 0, void 0, function () {
111
113
  return __generator(this, function (_a) {
@@ -218,25 +220,22 @@ function runReactNativeWizardWithTelemetry(options) {
218
220
  exports.runReactNativeWizardWithTelemetry = runReactNativeWizardWithTelemetry;
219
221
  function addSentryToMetroConfig(_a) {
220
222
  var sdkVersion = _a.sdkVersion;
221
- return __awaiter(this, void 0, void 0, function () {
222
- return __generator(this, function (_b) {
223
- switch (_b.label) {
224
- case 0:
225
- if (!sdkVersion ||
226
- !(0, semver_1.fulfillsVersionRange)({
227
- version: sdkVersion,
228
- acceptableVersions: exports.SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,
229
- canBeLatest: true,
230
- })) {
231
- return [2 /*return*/];
232
- }
233
- return [4 /*yield*/, (0, metro_1.patchMetroConfig)()];
234
- case 1:
235
- _b.sent();
236
- return [2 /*return*/];
237
- }
238
- });
239
- });
223
+ if (sdkVersion &&
224
+ (0, semver_1.fulfillsVersionRange)({
225
+ version: sdkVersion,
226
+ acceptableVersions: exports.SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE,
227
+ canBeLatest: true,
228
+ })) {
229
+ return (0, metro_1.patchMetroWithSentryConfig)();
230
+ }
231
+ if (sdkVersion &&
232
+ (0, semver_1.fulfillsVersionRange)({
233
+ version: sdkVersion,
234
+ acceptableVersions: exports.SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,
235
+ canBeLatest: true,
236
+ })) {
237
+ return (0, metro_1.patchMetroConfigWithSentrySerializer)();
238
+ }
240
239
  }
241
240
  function addSentryInit(_a) {
242
241
  var dsn = _a.dsn;
@@ -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,iCAA2C;AAE3C,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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C;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 { patchMetroConfig } 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\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\nasync function addSentryToMetroConfig({\n sdkVersion,\n}: {\n sdkVersion: string | undefined;\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;\n }\n\n await patchMetroConfig();\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,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,QAA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B,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';\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"]}
@@ -83,7 +83,7 @@ export declare function printJsonC(ast: t.Program): string;
83
83
  * Walks the program body and returns index of the last variable assignment initialized by require statement.
84
84
  * Only counts top level require statements.
85
85
  *
86
- * @returns index of the last `const foo = require('bar');` statement
86
+ * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.
87
87
  */
88
88
  export declare function getLastRequireIndex(program: t.Program): number;
89
89
  /**
@@ -212,10 +212,10 @@ exports.printJsonC = printJsonC;
212
212
  * Walks the program body and returns index of the last variable assignment initialized by require statement.
213
213
  * Only counts top level require statements.
214
214
  *
215
- * @returns index of the last `const foo = require('bar');` statement
215
+ * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.
216
216
  */
217
217
  function getLastRequireIndex(program) {
218
- var lastRequireIdex = 0;
218
+ var lastRequireIdex = -1;
219
219
  program.body.forEach(function (s, i) {
220
220
  if (s.type === 'VariableDeclaration' &&
221
221
  s.declarations[0].type === 'VariableDeclarator' &&