@sentry/wizard 3.14.1 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +19 -4
  2. package/dist/lib/Steps/ChooseIntegration.js +1 -1
  3. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  4. package/dist/lib/Steps/Integrations/ReactNative.d.ts +7 -32
  5. package/dist/lib/Steps/Integrations/ReactNative.js +17 -485
  6. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  7. package/dist/package.json +1 -1
  8. package/dist/src/android/android-wizard.js +13 -18
  9. package/dist/src/android/android-wizard.js.map +1 -1
  10. package/dist/src/apple/apple-wizard.js +11 -4
  11. package/dist/src/apple/apple-wizard.js.map +1 -1
  12. package/dist/src/apple/cocoapod.d.ts +1 -0
  13. package/dist/src/apple/cocoapod.js +36 -13
  14. package/dist/src/apple/cocoapod.js.map +1 -1
  15. package/dist/src/nextjs/nextjs-wizard.js +1 -1
  16. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  17. package/dist/src/react-native/glob.d.ts +3 -0
  18. package/dist/src/react-native/glob.js +18 -0
  19. package/dist/src/react-native/glob.js.map +1 -0
  20. package/dist/src/react-native/gradle.d.ts +4 -0
  21. package/dist/src/react-native/gradle.js +49 -0
  22. package/dist/src/react-native/gradle.js.map +1 -0
  23. package/dist/src/react-native/javascript.d.ts +8 -0
  24. package/dist/src/react-native/javascript.js +25 -0
  25. package/dist/src/react-native/javascript.js.map +1 -0
  26. package/dist/src/react-native/options.d.ts +4 -0
  27. package/dist/src/react-native/options.js +3 -0
  28. package/dist/src/react-native/options.js.map +1 -0
  29. package/dist/src/react-native/react-native-wizard.d.ts +9 -0
  30. package/dist/src/react-native/react-native-wizard.js +356 -0
  31. package/dist/src/react-native/react-native-wizard.js.map +1 -0
  32. package/dist/src/react-native/uninstall.d.ts +2 -0
  33. package/dist/src/react-native/uninstall.js +130 -0
  34. package/dist/src/react-native/uninstall.js.map +1 -0
  35. package/dist/src/react-native/xcode.d.ts +18 -0
  36. package/dist/src/react-native/xcode.js +170 -0
  37. package/dist/src/react-native/xcode.js.map +1 -0
  38. package/dist/src/remix/codemods/handle-error.js +28 -0
  39. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  40. package/dist/src/remix/codemods/root-common.d.ts +2 -0
  41. package/dist/src/remix/codemods/root-common.js +70 -0
  42. package/dist/src/remix/codemods/root-common.js.map +1 -0
  43. package/dist/src/remix/codemods/root-v1.js +5 -36
  44. package/dist/src/remix/codemods/root-v1.js.map +1 -1
  45. package/dist/src/remix/codemods/root-v2.js +53 -4
  46. package/dist/src/remix/codemods/root-v2.js.map +1 -1
  47. package/dist/src/remix/remix-wizard.js +8 -5
  48. package/dist/src/remix/remix-wizard.js.map +1 -1
  49. package/dist/src/remix/sdk-setup.d.ts +1 -0
  50. package/dist/src/remix/sdk-setup.js +10 -6
  51. package/dist/src/remix/sdk-setup.js.map +1 -1
  52. package/dist/src/remix/templates.d.ts +1 -1
  53. package/dist/src/remix/templates.js +1 -1
  54. package/dist/src/remix/templates.js.map +1 -1
  55. package/dist/src/remix/utils.d.ts +2 -0
  56. package/dist/src/remix/utils.js +6 -1
  57. package/dist/src/remix/utils.js.map +1 -1
  58. package/dist/src/sourcemaps/tools/nextjs.js +3 -3
  59. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  60. package/dist/src/sourcemaps/tools/sentry-cli.js +1 -1
  61. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  62. package/dist/src/sveltekit/sveltekit-wizard.js +1 -1
  63. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  64. package/dist/src/utils/clack-utils.d.ts +19 -3
  65. package/dist/src/utils/clack-utils.js +141 -39
  66. package/dist/src/utils/clack-utils.js.map +1 -1
  67. package/dist/src/utils/semver.d.ts +5 -0
  68. package/dist/src/utils/semver.js +27 -0
  69. package/dist/src/utils/semver.js.map +1 -0
  70. package/dist/src/utils/sentrycli-utils.js +4 -1
  71. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  72. package/dist/src/utils/types.d.ts +3 -0
  73. package/dist/src/utils/types.js.map +1 -1
  74. package/dist/test/react-native/gradle.test.js +57 -0
  75. package/dist/test/react-native/gradle.test.js.map +1 -0
  76. package/dist/test/react-native/javascript.test.js +47 -0
  77. package/dist/test/react-native/javascript.test.js.map +1 -0
  78. package/dist/test/react-native/xcode.test.d.ts +1 -0
  79. package/dist/test/react-native/xcode.test.js +144 -0
  80. package/dist/test/react-native/xcode.test.js.map +1 -0
  81. package/lib/Steps/ChooseIntegration.ts +1 -1
  82. package/lib/Steps/Integrations/ReactNative.ts +17 -573
  83. package/package.json +1 -1
  84. package/src/android/android-wizard.ts +3 -18
  85. package/src/apple/apple-wizard.ts +12 -3
  86. package/src/apple/cocoapod.ts +20 -9
  87. package/src/nextjs/nextjs-wizard.ts +1 -1
  88. package/src/react-native/glob.ts +13 -0
  89. package/src/react-native/gradle.ts +26 -0
  90. package/src/react-native/javascript.ts +33 -0
  91. package/src/react-native/options.ts +5 -0
  92. package/src/react-native/react-native-wizard.ts +369 -0
  93. package/src/react-native/uninstall.ts +107 -0
  94. package/src/react-native/xcode.ts +228 -0
  95. package/src/remix/codemods/handle-error.ts +30 -0
  96. package/src/remix/codemods/root-common.ts +63 -0
  97. package/src/remix/codemods/root-v1.ts +3 -53
  98. package/src/remix/codemods/root-v2.ts +71 -2
  99. package/src/remix/remix-wizard.ts +9 -6
  100. package/src/remix/sdk-setup.ts +14 -6
  101. package/src/remix/templates.ts +2 -6
  102. package/src/remix/utils.ts +5 -0
  103. package/src/sourcemaps/tools/nextjs.ts +6 -6
  104. package/src/sourcemaps/tools/sentry-cli.ts +1 -1
  105. package/src/sveltekit/sveltekit-wizard.ts +1 -1
  106. package/src/utils/clack-utils.ts +229 -74
  107. package/src/utils/semver.ts +33 -0
  108. package/src/utils/sentrycli-utils.ts +3 -1
  109. package/src/utils/types.ts +3 -0
  110. package/test/react-native/gradle.test.ts +310 -0
  111. package/test/react-native/javascript.test.ts +131 -0
  112. package/test/react-native/xcode.test.ts +238 -0
  113. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +0 -198
  114. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +0 -1
  115. package/dist/lib/__tests__/Setup.js +0 -57
  116. package/dist/lib/__tests__/Setup.js.map +0 -1
  117. package/lib/Steps/Integrations/__tests__/ReactNative.ts +0 -136
  118. package/lib/__tests__/Setup.ts +0 -42
  119. /package/dist/{lib/Steps/Integrations/__tests__/ReactNative.d.ts → test/react-native/gradle.test.d.ts} +0 -0
  120. /package/dist/{lib/__tests__/Setup.d.ts → test/react-native/javascript.test.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,IAAM,SAAS,GAAG,qJAA6I,CAAC;AAEhK,SAAgB,6CAA6C,CAC3D,OAAe;IAEf,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAJD,sGAIC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,UAAC,KAAK,IAAK,OAAA,UAAG,SAAS,eAAK,KAAK,CAAE,EAAxB,CAAwB,CAAC,CAAC;AAC7E,CAAC;AAFD,0DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,gEAEC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,UAAkB;IAClE,IAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAPD,kDAOC","sourcesContent":["import * as fs from 'fs';\n\nconst applyFrom = `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`;\n\nexport function doesAppBuildGradleIncludeRNSentryGradlePlugin(\n content: string,\n): boolean {\n return content.includes('sentry.gradle');\n}\n\nexport function addRNSentryGradlePlugin(content: string): string {\n return content.replace(/^android {/m, (match) => `${applyFrom}\\n${match}`);\n}\n\nexport function removeRNSentryGradlePlugin(content: string): string {\n return content.replace(/^\\s*apply from:.*sentry\\.gradle.*;?\\s*?\\r?\\n/m, '');\n}\n\nexport function writeAppBuildGradle(path: string, newContent: string): void {\n const currentContent = fs.readFileSync(path, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(path, newContent, 'utf-8');\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare function addSentryInitWithSdkImport(js: string, { dsn }: {
2
+ dsn: string;
3
+ }): string;
4
+ export declare function doesJsCodeIncludeSdkSentryImport(js: string, { sdkPackageName }: {
5
+ sdkPackageName: string;
6
+ }): boolean;
7
+ export declare function getSentryInitColoredCodeSnippet(dsn: string): string;
8
+ export declare function getSentryInitPlainTextSnippet(dsn: string): string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSentryInitPlainTextSnippet = exports.getSentryInitColoredCodeSnippet = exports.doesJsCodeIncludeSdkSentryImport = exports.addSentryInitWithSdkImport = void 0;
4
+ var clack_utils_1 = require("../utils/clack-utils");
5
+ function addSentryInitWithSdkImport(js, _a) {
6
+ var dsn = _a.dsn;
7
+ return js.replace(/^([^]*)(import\s+[^;]*?;$)/m, function (match) { return "".concat(match, "\n").concat(getSentryInitPlainTextSnippet(dsn)); });
8
+ }
9
+ exports.addSentryInitWithSdkImport = addSentryInitWithSdkImport;
10
+ function doesJsCodeIncludeSdkSentryImport(js, _a) {
11
+ var sdkPackageName = _a.sdkPackageName;
12
+ return !!js.match(sdkPackageName);
13
+ }
14
+ exports.doesJsCodeIncludeSdkSentryImport = doesJsCodeIncludeSdkSentryImport;
15
+ function getSentryInitColoredCodeSnippet(dsn) {
16
+ return (0, clack_utils_1.makeCodeSnippet)(true, function (_unchanged, plus, _minus) {
17
+ return plus(getSentryInitPlainTextSnippet(dsn));
18
+ });
19
+ }
20
+ exports.getSentryInitColoredCodeSnippet = getSentryInitColoredCodeSnippet;
21
+ function getSentryInitPlainTextSnippet(dsn) {
22
+ return "import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n});");
23
+ }
24
+ exports.getSentryInitPlainTextSnippet = getSentryInitPlainTextSnippet;
25
+ //# sourceMappingURL=javascript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AAEvD,SAAgB,0BAA0B,CACxC,EAAU,EACV,EAAwB;QAAtB,GAAG,SAAA;IAEL,OAAO,EAAE,CAAC,OAAO,CACf,6BAA6B,EAC7B,UAAC,KAAa,IAAK,OAAA,UAAG,KAAK,eAC7B,6BAA6B,CAAC,GAAG,CAAC,CAAE,EADf,CACe,CACnC,CAAC;AACJ,CAAC;AATD,gEASC;AAED,SAAgB,gCAAgC,CAC9C,EAAU,EACV,EAA8C;QAA5C,cAAc,oBAAA;IAEhB,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC;AALD,4EAKC;AAED,SAAgB,+BAA+B,CAAC,GAAW;IACzD,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,UAAC,UAAU,EAAE,IAAI,EAAE,MAAM;QACpD,OAAO,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,0EAIC;AAED,SAAgB,6BAA6B,CAAC,GAAW;IACvD,OAAO,oFAGC,GAAG,YACT,CAAC;AACL,CAAC;AAND,sEAMC","sourcesContent":["import { makeCodeSnippet } from '../utils/clack-utils';\n\nexport function addSentryInitWithSdkImport(\n js: string,\n { dsn }: { dsn: string },\n): string {\n return js.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match: string) => `${match}\n${getSentryInitPlainTextSnippet(dsn)}`,\n );\n}\n\nexport function doesJsCodeIncludeSdkSentryImport(\n js: string,\n { sdkPackageName }: { sdkPackageName: string },\n): boolean {\n return !!js.match(sdkPackageName);\n}\n\nexport function getSentryInitColoredCodeSnippet(dsn: string) {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(getSentryInitPlainTextSnippet(dsn));\n });\n}\n\nexport function getSentryInitPlainTextSnippet(dsn: string) {\n return `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '${dsn}',\n});`;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { WizardOptions } from '../utils/types';
2
+ export interface ReactNativeWizardOptions extends WizardOptions {
3
+ uninstall: boolean;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/react-native/options.ts"],"names":[],"mappings":"","sourcesContent":["import { WizardOptions } from '../utils/types';\n\nexport interface ReactNativeWizardOptions extends WizardOptions {\n uninstall: boolean;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { CliSetupConfigContent } from '../utils/clack-utils';
2
+ import { ReactNativeWizardOptions } from './options';
3
+ export declare const RN_SDK_PACKAGE = "@sentry/react-native";
4
+ export declare const RN_PACKAGE = "react-native";
5
+ export declare const RN_HUMAN_NAME = "React Native";
6
+ export declare const SUPPORTED_RN_RANGE = ">=0.69.0";
7
+ export type RNCliSetupConfigContent = Pick<Required<CliSetupConfigContent>, 'authToken' | 'org' | 'project' | 'url'>;
8
+ export declare function runReactNativeWizard(params: ReactNativeWizardOptions): Promise<void>;
9
+ export declare function runReactNativeWizardWithTelemetry(options: ReactNativeWizardOptions): Promise<void>;
@@ -0,0 +1,356 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __importDefault = (this && this.__importDefault) || function (mod) {
73
+ return (mod && mod.__esModule) ? mod : { "default": mod };
74
+ };
75
+ Object.defineProperty(exports, "__esModule", { value: true });
76
+ exports.runReactNativeWizardWithTelemetry = exports.runReactNativeWizard = exports.SUPPORTED_RN_RANGE = exports.RN_HUMAN_NAME = exports.RN_PACKAGE = exports.RN_SDK_PACKAGE = void 0;
77
+ /* eslint-disable max-lines */
78
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
79
+ var prompts_1 = __importDefault(require("@clack/prompts"));
80
+ var chalk_1 = __importDefault(require("chalk"));
81
+ var fs = __importStar(require("fs"));
82
+ var path = __importStar(require("path"));
83
+ var process = __importStar(require("process"));
84
+ var clack_utils_1 = require("../utils/clack-utils");
85
+ var package_json_1 = require("../utils/package-json");
86
+ var cocoapod_1 = require("../apple/cocoapod");
87
+ var os_1 = require("os");
88
+ var xcode_1 = require("./xcode");
89
+ var gradle_1 = require("./gradle");
90
+ var uninstall_1 = require("./uninstall");
91
+ var glob_1 = require("./glob");
92
+ var javascript_1 = require("./javascript");
93
+ var telemetry_1 = require("../telemetry");
94
+ var Sentry = __importStar(require("@sentry/node"));
95
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
96
+ var xcode = require('xcode');
97
+ exports.RN_SDK_PACKAGE = '@sentry/react-native';
98
+ exports.RN_PACKAGE = 'react-native';
99
+ exports.RN_HUMAN_NAME = 'React Native';
100
+ exports.SUPPORTED_RN_RANGE = '>=0.69.0';
101
+ function runReactNativeWizard(params) {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ return __generator(this, function (_a) {
104
+ return [2 /*return*/, (0, telemetry_1.withTelemetry)({
105
+ enabled: params.telemetryEnabled,
106
+ integration: 'react-native',
107
+ }, function () { return runReactNativeWizardWithTelemetry(params); })];
108
+ });
109
+ });
110
+ }
111
+ exports.runReactNativeWizard = runReactNativeWizard;
112
+ function runReactNativeWizardWithTelemetry(options) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var packageJson, rnVersion, _a, selectedProject, authToken, sentryUrl, orgSlug, projectSlug, cliConfig, confirmedFirstException;
115
+ return __generator(this, function (_b) {
116
+ switch (_b.label) {
117
+ case 0:
118
+ if (options.uninstall) {
119
+ Sentry.setTag('uninstall', true);
120
+ return [2 /*return*/, (0, uninstall_1.runReactNativeUninstall)(options)];
121
+ }
122
+ (0, clack_utils_1.printWelcome)({
123
+ wizardName: 'Sentry React Native Wizard',
124
+ promoCode: options.promoCode,
125
+ telemetryEnabled: options.telemetryEnabled,
126
+ });
127
+ return [4 /*yield*/, (0, clack_utils_1.confirmContinueIfNoOrDirtyGitRepo)()];
128
+ case 1:
129
+ _b.sent();
130
+ return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
131
+ case 2:
132
+ packageJson = _b.sent();
133
+ return [4 /*yield*/, (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, exports.RN_PACKAGE, exports.RN_HUMAN_NAME)];
134
+ case 3:
135
+ _b.sent();
136
+ rnVersion = (0, package_json_1.getPackageVersion)(exports.RN_PACKAGE, packageJson);
137
+ if (!rnVersion) return [3 /*break*/, 5];
138
+ return [4 /*yield*/, (0, clack_utils_1.confirmContinueIfPackageVersionNotSupported)({
139
+ packageName: exports.RN_HUMAN_NAME,
140
+ packageVersion: rnVersion,
141
+ packageId: exports.RN_PACKAGE,
142
+ acceptableVersions: exports.SUPPORTED_RN_RANGE,
143
+ })];
144
+ case 4:
145
+ _b.sent();
146
+ _b.label = 5;
147
+ case 5: return [4 /*yield*/, (0, clack_utils_1.getOrAskForProjectData)(options, 'react-native')];
148
+ case 6:
149
+ _a = _b.sent(), selectedProject = _a.selectedProject, authToken = _a.authToken, sentryUrl = _a.sentryUrl;
150
+ orgSlug = selectedProject.organization.slug;
151
+ projectSlug = selectedProject.slug;
152
+ cliConfig = {
153
+ authToken: authToken,
154
+ org: orgSlug,
155
+ project: projectSlug,
156
+ url: sentryUrl,
157
+ };
158
+ return [4 /*yield*/, (0, clack_utils_1.installPackage)({
159
+ packageName: exports.RN_SDK_PACKAGE,
160
+ alreadyInstalled: (0, package_json_1.hasPackageInstalled)(exports.RN_SDK_PACKAGE, packageJson),
161
+ })];
162
+ case 7:
163
+ _b.sent();
164
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-js', function () {
165
+ return addSentryInit({ dsn: selectedProject.keys[0].dsn.public });
166
+ })];
167
+ case 8:
168
+ _b.sent();
169
+ if (!fs.existsSync('ios')) return [3 /*break*/, 10];
170
+ Sentry.setTag('patch-ios', true);
171
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-xcode-files', function () { return patchXcodeFiles(cliConfig); })];
172
+ case 9:
173
+ _b.sent();
174
+ _b.label = 10;
175
+ case 10:
176
+ if (!fs.existsSync('android')) return [3 /*break*/, 12];
177
+ Sentry.setTag('patch-android', true);
178
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('patch-android-files', function () { return patchAndroidFiles(cliConfig); })];
179
+ case 11:
180
+ _b.sent();
181
+ _b.label = 12;
182
+ case 12: return [4 /*yield*/, confirmFirstSentryException(selectedProject)];
183
+ case 13:
184
+ confirmedFirstException = _b.sent();
185
+ Sentry.setTag('user-confirmed-first-error', confirmedFirstException);
186
+ if (confirmedFirstException) {
187
+ prompts_1.default.outro("".concat(chalk_1.default.green('Everything is set up!'), "\n\n ").concat(chalk_1.default.dim('If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues')));
188
+ }
189
+ else {
190
+ prompts_1.default.outro("".concat(chalk_1.default.dim('Let us know here: https://github.com/getsentry/sentry-react-native/issues')));
191
+ }
192
+ return [2 /*return*/];
193
+ }
194
+ });
195
+ });
196
+ }
197
+ exports.runReactNativeWizardWithTelemetry = runReactNativeWizardWithTelemetry;
198
+ function addSentryInit(_a) {
199
+ var dsn = _a.dsn;
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var prefixGlob, suffixGlob, universalGlob, jsFileGlob, jsPath, jsRelativePath, js, includesSentry;
202
+ return __generator(this, function (_b) {
203
+ switch (_b.label) {
204
+ case 0:
205
+ prefixGlob = '{.,./src}';
206
+ suffixGlob = '@(j|t|cj|mj)s?(x)';
207
+ universalGlob = "App.".concat(suffixGlob);
208
+ jsFileGlob = "".concat(prefixGlob, "/+(").concat(universalGlob, ")");
209
+ jsPath = (0, telemetry_1.traceStep)('find-app-js-file', function () {
210
+ return (0, glob_1.getFirstMatchedPath)(jsFileGlob);
211
+ });
212
+ Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
213
+ if (!!jsPath) return [3 /*break*/, 2];
214
+ prompts_1.default.log.warn("Could not find main App file using ".concat(chalk_1.default.cyan(jsFileGlob), "."));
215
+ 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.')];
216
+ case 1:
217
+ _b.sent();
218
+ return [2 /*return*/];
219
+ case 2:
220
+ jsRelativePath = path.relative(process.cwd(), jsPath);
221
+ js = fs.readFileSync(jsPath, 'utf-8');
222
+ includesSentry = (0, javascript_1.doesJsCodeIncludeSdkSentryImport)(js, {
223
+ sdkPackageName: exports.RN_SDK_PACKAGE,
224
+ });
225
+ if (includesSentry) {
226
+ Sentry.setTag('app-js-file-status', 'already-includes-sentry');
227
+ prompts_1.default.log.warn("".concat(chalk_1.default.cyan(jsRelativePath), " already includes Sentry. We wont't add it again."));
228
+ return [2 /*return*/];
229
+ }
230
+ (0, telemetry_1.traceStep)('add-sentry-init', function () {
231
+ var newContent = (0, javascript_1.addSentryInitWithSdkImport)(js, { dsn: dsn });
232
+ prompts_1.default.log.success("Added ".concat(chalk_1.default.cyan('Sentry.init'), " to ").concat(chalk_1.default.cyan(jsRelativePath), "."));
233
+ fs.writeFileSync(jsPath, newContent, 'utf-8');
234
+ });
235
+ Sentry.setTag('app-js-file-status', 'added-sentry-init');
236
+ prompts_1.default.log.success(chalk_1.default.green("".concat(chalk_1.default.cyan(jsRelativePath), " changes saved.")));
237
+ return [2 /*return*/];
238
+ }
239
+ });
240
+ });
241
+ }
242
+ function confirmFirstSentryException(project) {
243
+ return __awaiter(this, void 0, void 0, function () {
244
+ var projectsIssuesUrl, firstErrorConfirmed;
245
+ return __generator(this, function (_a) {
246
+ projectsIssuesUrl = "".concat(project.organization.links.organizationUrl, "/issues/?project=").concat(project.id);
247
+ prompts_1.default.log
248
+ .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".concat(chalk_1.default.cyan(projectsIssuesUrl)));
249
+ // We want the code snippet to be easily copy-pasteable, without any clack artifacts
250
+ // eslint-disable-next-line no-console
251
+ console.log(chalk_1.default.greenBright("\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n"));
252
+ firstErrorConfirmed = prompts_1.default.confirm({
253
+ message: "Have you successfully sent a test event?",
254
+ });
255
+ return [2 /*return*/, firstErrorConfirmed];
256
+ });
257
+ });
258
+ }
259
+ function patchXcodeFiles(config) {
260
+ return __awaiter(this, void 0, void 0, function () {
261
+ var xcodeProjectPath, _a, xcodeProject, buildPhasesMap;
262
+ return __generator(this, function (_b) {
263
+ switch (_b.label) {
264
+ case 0: return [4 /*yield*/, (0, clack_utils_1.addSentryCliConfig)(config, __assign(__assign({}, clack_utils_1.propertiesCliSetupConfig), { name: 'source maps and iOS debug files', filename: 'ios/sentry.properties', gitignore: false }))];
265
+ case 1:
266
+ _b.sent();
267
+ if (!((0, os_1.platform)() === 'darwin')) return [3 /*break*/, 3];
268
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('pod-install', function () { return (0, cocoapod_1.podInstall)('ios'); })];
269
+ case 2:
270
+ _b.sent();
271
+ Sentry.setTag('pods-installed', true);
272
+ _b.label = 3;
273
+ case 3:
274
+ xcodeProjectPath = (0, telemetry_1.traceStep)('find-xcode-project', function () {
275
+ return (0, glob_1.getFirstMatchedPath)(glob_1.XCODE_PROJECT);
276
+ });
277
+ Sentry.setTag('xcode-project-status', xcodeProjectPath ? 'found' : 'not-found');
278
+ if (!xcodeProjectPath) {
279
+ prompts_1.default.log.warn("Could not find Xcode project file using ".concat(chalk_1.default.cyan(glob_1.XCODE_PROJECT), "."));
280
+ return [2 /*return*/];
281
+ }
282
+ _a = (0, telemetry_1.traceStep)('parse-xcode-project', function () {
283
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
284
+ var project = xcode.project(xcodeProjectPath);
285
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
286
+ project.parseSync();
287
+ var map = (0, xcode_1.getValidExistingBuildPhases)(project);
288
+ return [project, map];
289
+ }), xcodeProject = _a[0], buildPhasesMap = _a[1];
290
+ Sentry.setTag('xcode-project-status', 'parsed');
291
+ (0, telemetry_1.traceStep)('patch-bundle-phase', function () {
292
+ var bundlePhase = (0, xcode_1.findBundlePhase)(buildPhasesMap);
293
+ Sentry.setTag('xcode-bundle-phase-status', bundlePhase ? 'found' : 'not-found');
294
+ (0, xcode_1.patchBundlePhase)(bundlePhase);
295
+ Sentry.setTag('xcode-bundle-phase-status', 'patched');
296
+ });
297
+ (0, telemetry_1.traceStep)('add-debug-files-upload-phase', function () {
298
+ var debugFilesUploadPhaseExists = !!(0, xcode_1.findDebugFilesUploadPhase)(buildPhasesMap);
299
+ Sentry.setTag('xcode-debug-files-upload-phase-status', debugFilesUploadPhaseExists ? 'already-exists' : undefined);
300
+ (0, xcode_1.addDebugFilesUploadPhase)(xcodeProject, { debugFilesUploadPhaseExists: debugFilesUploadPhaseExists });
301
+ Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');
302
+ });
303
+ (0, telemetry_1.traceStep)('write-xcode-project', function () {
304
+ (0, xcode_1.writeXcodeProject)(xcodeProjectPath, xcodeProject);
305
+ });
306
+ Sentry.setTag('xcode-project-status', 'patched');
307
+ return [2 /*return*/];
308
+ }
309
+ });
310
+ });
311
+ }
312
+ function patchAndroidFiles(config) {
313
+ return __awaiter(this, void 0, void 0, function () {
314
+ var appBuildGradlePath, appBuildGradle, includesSentry, patchedAppBuildGradle;
315
+ return __generator(this, function (_a) {
316
+ switch (_a.label) {
317
+ case 0: return [4 /*yield*/, (0, clack_utils_1.addSentryCliConfig)(config, __assign(__assign({}, clack_utils_1.propertiesCliSetupConfig), { name: 'source maps and iOS debug files', filename: 'android/sentry.properties', gitignore: false }))];
318
+ case 1:
319
+ _a.sent();
320
+ appBuildGradlePath = (0, telemetry_1.traceStep)('find-app-build-gradle', function () {
321
+ return (0, glob_1.getFirstMatchedPath)(glob_1.APP_BUILD_GRADLE);
322
+ });
323
+ Sentry.setTag('app-build-gradle-status', appBuildGradlePath ? 'found' : 'not-found');
324
+ if (!appBuildGradlePath) {
325
+ prompts_1.default.log.warn("Could not find Android ".concat(chalk_1.default.cyan('app/build.gradle'), " file using ").concat(chalk_1.default.cyan(glob_1.APP_BUILD_GRADLE), "."));
326
+ return [2 /*return*/];
327
+ }
328
+ appBuildGradle = (0, telemetry_1.traceStep)('read-app-build-gradle', function () {
329
+ return fs.readFileSync(appBuildGradlePath, 'utf-8');
330
+ });
331
+ includesSentry = (0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(appBuildGradle);
332
+ if (includesSentry) {
333
+ Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');
334
+ prompts_1.default.log.warn("Android ".concat(chalk_1.default.cyan('app/build.gradle'), " file already includes Sentry."));
335
+ return [2 /*return*/];
336
+ }
337
+ patchedAppBuildGradle = (0, telemetry_1.traceStep)('add-rn-sentry-gradle-plugin', function () {
338
+ return (0, gradle_1.addRNSentryGradlePlugin)(appBuildGradle);
339
+ });
340
+ if (!(0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(patchedAppBuildGradle)) {
341
+ Sentry.setTag('app-build-gradle-status', 'failed-to-add-rn-sentry-gradle-plugin');
342
+ prompts_1.default.log.warn("Could not add Sentry RN Gradle Plugin to ".concat(chalk_1.default.cyan('app/build.gradle'), "."));
343
+ return [2 /*return*/];
344
+ }
345
+ Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');
346
+ prompts_1.default.log.success("Added Sentry RN Gradle Plugin to ".concat(chalk_1.default.bold('app/build.gradle'), "."));
347
+ (0, telemetry_1.traceStep)('write-app-build-gradle', function () {
348
+ return (0, gradle_1.writeAppBuildGradle)(appBuildGradlePath, patchedAppBuildGradle);
349
+ });
350
+ prompts_1.default.log.success(chalk_1.default.green("Android ".concat(chalk_1.default.cyan('app/build.gradle'), " saved.")));
351
+ return [2 /*return*/];
352
+ }
353
+ });
354
+ });
355
+ }
356
+ //# sourceMappingURL=react-native-wizard.js.map
@@ -0,0 +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,oDAY8B;AAC9B,sDAA+E;AAC/E,8CAA+C;AAC/C,yBAA8B;AAC9B,iCAOiB;AACjB,mCAIkB;AAClB,yCAAsD;AACtD,+BAA8E;AAG9E,2CAIsB;AACtB,0CAAwD;AACxD,mDAAuC;AAEvC,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;AAO7C,SAAsB,oBAAoB,CACxC,M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C,EAAE;wBACzE,MAAM,CAAC,MAAM,CACX,yBAAyB,EACzB,uCAAuC,CACxC,CAAC;wBACF,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,mDAA4C,eAAK,CAAC,IAAI,CACpD,kBAAkB,CACnB,MAAG,CACL,CAAC;wBACF,sBAAO;qBACR;oBAED,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,+BAA+B,CAAC,CAAC;oBAC1E,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,2CAAoC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAG,CACtE,CAAC;oBAEF,IAAA,qBAAS,EAAC,wBAAwB,EAAE;wBAClC,OAAA,IAAA,4BAAmB,EAAC,kBAAkB,EAAE,qBAAqB,CAAC;oBAA9D,CAA8D,CAC/D,CAAC;oBACF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,kBAAW,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,YAAS,CAAC,CAChE,CAAC;;;;;CACH","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 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 addDebugFilesUploadPhase,\n writeXcodeProject,\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 { SentryProjectData } from '../utils/types';\nimport {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n getSentryInitColoredCodeSnippet,\n} from './javascript';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as Sentry from '@sentry/node';\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\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 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\n await traceStep('patch-js', () =>\n addSentryInit({ dsn: selectedProject.keys[0].dsn.public }),\n );\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () => patchXcodeFiles(cliConfig));\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n const confirmedFirstException = await confirmFirstSentryException(\n selectedProject,\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 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(project: SentryProjectData) {\n const projectsIssuesUrl = `${project.organization.links.organizationUrl}/issues/?project=${project.id}`;\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(projectsIssuesUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin') {\n await traceStep('pod-install', () => podInstall('ios'));\n Sentry.setTag('pods-installed', true);\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 patchBundlePhase(bundlePhase);\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 addDebugFilesUploadPhase(xcodeProject, { debugFilesUploadPhaseExists });\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"]}
@@ -0,0 +1,2 @@
1
+ import { ReactNativeWizardOptions } from './options';
2
+ export declare function runReactNativeUninstall(options: ReactNativeWizardOptions): Promise<void>;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.runReactNativeUninstall = void 0;
66
+ var fs = __importStar(require("fs"));
67
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
68
+ var prompts_1 = __importDefault(require("@clack/prompts"));
69
+ var chalk_1 = __importDefault(require("chalk"));
70
+ var clack_utils_1 = require("../utils/clack-utils");
71
+ var xcode_1 = require("./xcode");
72
+ var glob_1 = require("./glob");
73
+ var gradle_1 = require("./gradle");
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ var xcode = require('xcode');
76
+ function runReactNativeUninstall(options) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0:
81
+ (0, clack_utils_1.printWelcome)({
82
+ wizardName: 'Sentry React Native Uninstall Wizard',
83
+ message: 'This wizard will remove Sentry from your React Native project.',
84
+ telemetryEnabled: options.telemetryEnabled,
85
+ });
86
+ return [4 /*yield*/, (0, clack_utils_1.confirmContinueIfNoOrDirtyGitRepo)()];
87
+ case 1:
88
+ _a.sent();
89
+ unPatchXcodeFiles();
90
+ unPatchAndroidFiles();
91
+ prompts_1.default.note("To make sure your project builds after removing Sentry please run:\n\n1. ".concat(chalk_1.default.bold('yarn remove @sentry/react-native'), "\n2. ").concat(chalk_1.default.bold('cd ios && pod install'), "\n3. Remove all occurrences of ").concat(chalk_1.default.bold('@sentry/react-native'), " from your application code."));
92
+ prompts_1.default.outro("".concat(chalk_1.default.green('Uninstall is done!'), "\n\n ").concat(chalk_1.default.dim('If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues')));
93
+ return [2 /*return*/];
94
+ }
95
+ });
96
+ });
97
+ }
98
+ exports.runReactNativeUninstall = runReactNativeUninstall;
99
+ function unPatchXcodeFiles() {
100
+ var xcodeProjectPath = (0, glob_1.getFirstMatchedPath)(glob_1.XCODE_PROJECT);
101
+ if (!xcodeProjectPath) {
102
+ prompts_1.default.log.warn("Could not find Xcode project file using ".concat(chalk_1.default.bold(glob_1.XCODE_PROJECT), "."));
103
+ return;
104
+ }
105
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
106
+ var xcodeProject = xcode.project(xcodeProjectPath);
107
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
108
+ xcodeProject.parseSync();
109
+ var buildPhases = (0, xcode_1.getValidExistingBuildPhases)(xcodeProject);
110
+ var bundlePhase = (0, xcode_1.findBundlePhase)(buildPhases);
111
+ (0, xcode_1.unPatchBundlePhase)(bundlePhase);
112
+ (0, xcode_1.unPatchDebugFilesUploadPhase)(xcodeProject);
113
+ (0, xcode_1.writeXcodeProject)(xcodeProjectPath, xcodeProject);
114
+ }
115
+ function unPatchAndroidFiles() {
116
+ var appBuildGradlePath = (0, glob_1.getFirstMatchedPath)(glob_1.APP_BUILD_GRADLE);
117
+ if (!appBuildGradlePath) {
118
+ prompts_1.default.log.warn("Could not find Android app/build.gradle file using ".concat(chalk_1.default.bold(glob_1.APP_BUILD_GRADLE), "."));
119
+ return;
120
+ }
121
+ var appBuildGradle = fs.readFileSync(appBuildGradlePath, 'utf-8');
122
+ var includesSentry = (0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(appBuildGradle);
123
+ if (!includesSentry) {
124
+ prompts_1.default.log.warn("Sentry not found in Android app/build.gradle.");
125
+ return;
126
+ }
127
+ var patchedAppBuildGradle = (0, gradle_1.removeRNSentryGradlePlugin)(appBuildGradle);
128
+ (0, gradle_1.writeAppBuildGradle)(appBuildGradlePath, patchedAppBuildGradle);
129
+ }
130
+ //# sourceMappingURL=uninstall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/react-native/uninstall.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAE1B,oDAG8B;AAC9B,iCAMiB;AACjB,+BAA8E;AAC9E,mCAIkB;AAGlB,mEAAmE;AACnE,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,SAAsB,uBAAuB,CAC3C,OAAiC;;;;;oBAEjC,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,sCAAsC;wBAClD,OAAO,EAAE,gEAAgE;wBACzE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;qBAC3C,CAAC,CAAC;oBAEH,qBAAM,IAAA,+CAAiC,GAAE,EAAA;;oBAAzC,SAAyC,CAAC;oBAE1C,iBAAiB,EAAE,CAAC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IAAI,CAC9D,uBAAgB,CACjB,MAAG,CACL,CAAC;QACF,OAAO;KACR;IAED,IAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACpE,IAAM,cAAc,GAClB,IAAA,sDAA6C,EAAC,cAAc,CAAC,CAAC;IAChE,IAAI,CAAC,cAAc,EAAE;QACnB,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QAChE,OAAO;KACR;IAED,IAAM,qBAAqB,GAAG,IAAA,mCAA0B,EAAC,cAAc,CAAC,CAAC;IAEzE,IAAA,4BAAmB,EAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import * 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\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n printWelcome,\n} from '../utils/clack-utils';\nimport {\n findBundlePhase,\n getValidExistingBuildPhases,\n unPatchBundlePhase,\n unPatchDebugFilesUploadPhase,\n writeXcodeProject,\n} from './xcode';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport {\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n removeRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport { ReactNativeWizardOptions } from './options';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst xcode = require('xcode');\n\nexport async function runReactNativeUninstall(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry React Native Uninstall Wizard',\n message: 'This wizard will remove Sentry from your React Native project.',\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n unPatchXcodeFiles();\n\n unPatchAndroidFiles();\n\n clack.note(\n `To make sure your project builds after removing Sentry please run:\n\n1. ${chalk.bold('yarn remove @sentry/react-native')}\n2. ${chalk.bold('cd ios && pod install')}\n3. Remove all occurrences of ${chalk.bold(\n '@sentry/react-native',\n )} from your application code.`,\n );\n\n clack.outro(\n `${chalk.green('Uninstall is done!')}\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}\n\nfunction unPatchXcodeFiles() {\n const xcodeProjectPath = getFirstMatchedPath(XCODE_PROJECT);\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.bold(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const xcodeProject = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n xcodeProject.parseSync();\n const buildPhases = getValidExistingBuildPhases(xcodeProject);\n\n const bundlePhase = findBundlePhase(buildPhases);\n unPatchBundlePhase(bundlePhase);\n\n unPatchDebugFilesUploadPhase(xcodeProject);\n\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n}\n\nfunction unPatchAndroidFiles() {\n const appBuildGradlePath = getFirstMatchedPath(APP_BUILD_GRADLE);\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android app/build.gradle file using ${chalk.bold(\n APP_BUILD_GRADLE,\n )}.`,\n );\n return;\n }\n\n const appBuildGradle = fs.readFileSync(appBuildGradlePath, 'utf-8');\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (!includesSentry) {\n clack.log.warn(`Sentry not found in Android app/build.gradle.`);\n return;\n }\n\n const patchedAppBuildGradle = removeRNSentryGradlePlugin(appBuildGradle);\n\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle);\n}\n"]}