@sentry/wizard 3.15.0 → 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 (95) hide show
  1. package/CHANGELOG.md +7 -0
  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/remix-wizard.js +1 -1
  39. package/dist/src/remix/remix-wizard.js.map +1 -1
  40. package/dist/src/sourcemaps/tools/nextjs.js +3 -3
  41. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  42. package/dist/src/sourcemaps/tools/sentry-cli.js +1 -1
  43. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  44. package/dist/src/sveltekit/sveltekit-wizard.js +1 -1
  45. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  46. package/dist/src/utils/clack-utils.d.ts +19 -3
  47. package/dist/src/utils/clack-utils.js +141 -39
  48. package/dist/src/utils/clack-utils.js.map +1 -1
  49. package/dist/src/utils/semver.d.ts +5 -0
  50. package/dist/src/utils/semver.js +27 -0
  51. package/dist/src/utils/semver.js.map +1 -0
  52. package/dist/src/utils/sentrycli-utils.js +4 -1
  53. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  54. package/dist/src/utils/types.d.ts +3 -0
  55. package/dist/src/utils/types.js.map +1 -1
  56. package/dist/test/react-native/gradle.test.js +57 -0
  57. package/dist/test/react-native/gradle.test.js.map +1 -0
  58. package/dist/test/react-native/javascript.test.js +47 -0
  59. package/dist/test/react-native/javascript.test.js.map +1 -0
  60. package/dist/test/react-native/xcode.test.d.ts +1 -0
  61. package/dist/test/react-native/xcode.test.js +144 -0
  62. package/dist/test/react-native/xcode.test.js.map +1 -0
  63. package/lib/Steps/ChooseIntegration.ts +1 -1
  64. package/lib/Steps/Integrations/ReactNative.ts +17 -573
  65. package/package.json +1 -1
  66. package/src/android/android-wizard.ts +3 -18
  67. package/src/apple/apple-wizard.ts +12 -3
  68. package/src/apple/cocoapod.ts +20 -9
  69. package/src/nextjs/nextjs-wizard.ts +1 -1
  70. package/src/react-native/glob.ts +13 -0
  71. package/src/react-native/gradle.ts +26 -0
  72. package/src/react-native/javascript.ts +33 -0
  73. package/src/react-native/options.ts +5 -0
  74. package/src/react-native/react-native-wizard.ts +369 -0
  75. package/src/react-native/uninstall.ts +107 -0
  76. package/src/react-native/xcode.ts +228 -0
  77. package/src/remix/remix-wizard.ts +2 -2
  78. package/src/sourcemaps/tools/nextjs.ts +6 -6
  79. package/src/sourcemaps/tools/sentry-cli.ts +1 -1
  80. package/src/sveltekit/sveltekit-wizard.ts +1 -1
  81. package/src/utils/clack-utils.ts +229 -74
  82. package/src/utils/semver.ts +33 -0
  83. package/src/utils/sentrycli-utils.ts +3 -1
  84. package/src/utils/types.ts +3 -0
  85. package/test/react-native/gradle.test.ts +310 -0
  86. package/test/react-native/javascript.test.ts +131 -0
  87. package/test/react-native/xcode.test.ts +238 -0
  88. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +0 -198
  89. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +0 -1
  90. package/dist/lib/__tests__/Setup.js +0 -57
  91. package/dist/lib/__tests__/Setup.js.map +0 -1
  92. package/lib/Steps/Integrations/__tests__/ReactNative.ts +0 -136
  93. package/lib/__tests__/Setup.ts +0 -42
  94. /package/dist/{lib/Steps/Integrations/__tests__/ReactNative.d.ts → test/react-native/gradle.test.d.ts} +0 -0
  95. /package/dist/{lib/__tests__/Setup.d.ts → test/react-native/javascript.test.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.16.0
4
+
5
+ - ref(reactnative): Use clack prompts and share common code (dirty repo, login) (#473)
6
+ - feat(reactnative): Add telemetry (#477)
7
+ - feat(reactnative): Improve `build.gradle` patch so that it's more likely to work without changes in monorepos (#478)
8
+ - fix(reactnative): Save Sentry URL, Organization and Project to `sentry.properties` (#479)
9
+
3
10
  ## 3.15.0
4
11
 
5
12
  - feat(remix): Support sourcemap uploads of Hydrogen apps (#474)
@@ -115,7 +115,7 @@ var ChooseIntegration = /** @class */ (function (_super) {
115
115
  break;
116
116
  case Constants_1.Integration.reactNative:
117
117
  default:
118
- integration = new ReactNative_1.ReactNative(sanitizeUrl(this._argv));
118
+ integration = new ReactNative_1.ReactNative(this._argv);
119
119
  break;
120
120
  }
121
121
  return [2 /*return*/, { integration: integration }];
@@ -1 +1 @@
1
- {"version":3,"file":"ChooseIntegration.js","sourceRoot":"","sources":["../../../lib/Steps/ChooseIntegration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAkC;AAElC,0CAKsB;AACtB,uCAAsC;AACtC,kDAAiD;AACjD,oDAAmD;AACnD,wDAAuD;AACvD,0DAAyD;AACzD,gEAA+D;AAC/D,8CAA6C;AAC7C,8DAA6D;AAC7D,6DAAmE;AACnE,8CAA6C;AAC7C,kDAAiD;AACjD,6CAAwC;AAExC,IAAI,cAAc,GAAQ,EAAE,CAAC;AAE7B,IAAI;IACF,qCAAqC;IACrC,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAChD;AAAC,WAAM;IACN,cAAc,GAAG,OAAO,CAAC,UAAG,OAAO,CAAC,GAAG,EAAE,kBAAe,CAAC,CAAC;CAC3D;AAMD;IAAuC,qCAAQ;IAA/C;;IAqFA,CAAC;IApFc,gCAAI,GAAjB,UAAkB,QAAiB;;;;;4BACP,qBAAM,IAAI,CAAC,8BAA8B,EAAE,EAAA;;wBAA/D,iBAAiB,GAAG,SAA2C;wBAEjE,WAAW,GAAG,IAAI,CAAC;wBACvB,QAAQ,iBAAiB,CAAC,WAAW,EAAE;4BACrC,KAAK,uBAAW,CAAC,OAAO;gCACtB,WAAW,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gCACtC,MAAM;4BACR,KAAK,uBAAW,CAAC,OAAO;gCACtB,WAAW,GAAG,IAAI,iBAAO,CAAC,WAAW,CAAC,IAAI,CAAC,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,CAAE,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC;IAEnB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { Answers } from 'inquirer';\nimport { prompt } from 'inquirer';\n\nimport {\n Args,\n DEFAULT_URL,\n getIntegrationChoices,\n Integration,\n} from '../Constants';\nimport { BaseStep } from './BaseStep';\nimport { Cordova } from './Integrations/Cordova';\nimport { Electron } from './Integrations/Electron';\nimport { NextJsShim } from './Integrations/NextJsShim';\nimport { ReactNative } from './Integrations/ReactNative';\nimport { SourceMapsShim } from './Integrations/SourceMapsShim';\nimport { Apple } from './Integrations/Apple';\nimport { SvelteKitShim } from './Integrations/SvelteKitShim';\nimport { hasPackageInstalled } from '../../src/utils/package-json';\nimport { Remix } from './Integrations/Remix';\nimport { Android } from './Integrations/Android';\nimport { dim } from '../Helper/Logging';\n\nlet projectPackage: any = {};\n\ntry {\n // If we run directly in setup-wizard\n projectPackage = require('../../package.json');\n} catch {\n projectPackage = require(`${process.cwd()}/package.json`);\n}\n\ntype IntegrationPromptAnswer = {\n integration: Integration;\n};\n\nexport class ChooseIntegration extends BaseStep {\n public async emit(_answers: Answers): Promise<Answers> {\n const integrationPrompt = await this._getIntegrationPromptSelection();\n\n let integration = null;\n switch (integrationPrompt.integration) {\n case Integration.android:\n integration = new Android(this._argv);\n break;\n case Integration.cordova:\n integration = new Cordova(sanitizeUrl(this._argv));\n break;\n case Integration.electron:\n integration = new Electron(sanitizeUrl(this._argv));\n break;\n case Integration.nextjs:\n integration = new NextJsShim(this._argv);\n break;\n case Integration.remix:\n integration = new Remix(this._argv);\n break;\n case Integration.sveltekit:\n integration = new SvelteKitShim(this._argv);\n break;\n case Integration.sourcemaps:\n integration = new SourceMapsShim(this._argv);\n break;\n case Integration.ios:\n integration = new Apple(this._argv);\n break;\n case Integration.reactNative:\n default:\n integration = new ReactNative(sanitizeUrl(this._argv));\n break;\n }\n\n return { integration };\n }\n\n public tryDetectingIntegration(): Integration | undefined {\n if (hasPackageInstalled('react-native', projectPackage)) {\n return Integration.reactNative;\n }\n if (hasPackageInstalled('cordova', projectPackage)) {\n return Integration.cordova;\n }\n if (hasPackageInstalled('electron', projectPackage)) {\n return Integration.electron;\n }\n if (hasPackageInstalled('next', projectPackage)) {\n return Integration.nextjs;\n }\n if (hasPackageInstalled('remix-run', projectPackage)) {\n return Integration.remix;\n }\n if (hasPackageInstalled('@sveltejs/kit', projectPackage)) {\n return Integration.sveltekit;\n }\n\n return;\n }\n\n private async _getIntegrationPromptSelection(): Promise<IntegrationPromptAnswer> {\n // If we receive project type as an arg we skip asking\n if (this._argv.integration) {\n return { integration: this._argv.integration };\n } else {\n if (this._argv.quiet) {\n throw new Error('You need to choose a platform');\n }\n\n const detectedDefaultSelection = this.tryDetectingIntegration();\n\n return prompt([\n {\n choices: getIntegrationChoices(),\n default: detectedDefaultSelection,\n message: 'What platform do you want to set up?',\n name: 'integration',\n type: 'list',\n pageSize: 10,\n },\n ]);\n }\n }\n}\n\n/**\n * For the `clack`-based wizard flows, which we only shim here, we don't set\n * a default url value. For backwards-compatibility with the other flows,\n * we fill it here and sanitize a user-enterd url.\n */\nfunction sanitizeUrl(argv: Args): Args {\n if (!argv.url) {\n argv.url = DEFAULT_URL;\n dim(`no URL provided, fallback to ${argv.url}`);\n return argv;\n }\n\n let baseUrl = argv.url;\n baseUrl += baseUrl.endsWith('/') ? '' : '/';\n baseUrl = baseUrl.replace(/:\\/(?!\\/)/g, '://');\n argv.url = baseUrl;\n\n return argv;\n}\n"]}
1
+ {"version":3,"file":"Ch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,EAAE,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC;IAEnB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { Answers } from 'inquirer';\nimport { prompt } from 'inquirer';\n\nimport {\n Args,\n DEFAULT_URL,\n getIntegrationChoices,\n Integration,\n} from '../Constants';\nimport { BaseStep } from './BaseStep';\nimport { Cordova } from './Integrations/Cordova';\nimport { Electron } from './Integrations/Electron';\nimport { NextJsShim } from './Integrations/NextJsShim';\nimport { ReactNative } from './Integrations/ReactNative';\nimport { SourceMapsShim } from './Integrations/SourceMapsShim';\nimport { Apple } from './Integrations/Apple';\nimport { SvelteKitShim } from './Integrations/SvelteKitShim';\nimport { hasPackageInstalled } from '../../src/utils/package-json';\nimport { Remix } from './Integrations/Remix';\nimport { Android } from './Integrations/Android';\nimport { dim } from '../Helper/Logging';\n\nlet projectPackage: any = {};\n\ntry {\n // If we run directly in setup-wizard\n projectPackage = require('../../package.json');\n} catch {\n projectPackage = require(`${process.cwd()}/package.json`);\n}\n\ntype IntegrationPromptAnswer = {\n integration: Integration;\n};\n\nexport class ChooseIntegration extends BaseStep {\n public async emit(_answers: Answers): Promise<Answers> {\n const integrationPrompt = await this._getIntegrationPromptSelection();\n\n let integration = null;\n switch (integrationPrompt.integration) {\n case Integration.android:\n integration = new Android(this._argv);\n break;\n case Integration.cordova:\n integration = new Cordova(sanitizeUrl(this._argv));\n break;\n case Integration.electron:\n integration = new Electron(sanitizeUrl(this._argv));\n break;\n case Integration.nextjs:\n integration = new NextJsShim(this._argv);\n break;\n case Integration.remix:\n integration = new Remix(this._argv);\n break;\n case Integration.sveltekit:\n integration = new SvelteKitShim(this._argv);\n break;\n case Integration.sourcemaps:\n integration = new SourceMapsShim(this._argv);\n break;\n case Integration.ios:\n integration = new Apple(this._argv);\n break;\n case Integration.reactNative:\n default:\n integration = new ReactNative(this._argv);\n break;\n }\n\n return { integration };\n }\n\n public tryDetectingIntegration(): Integration | undefined {\n if (hasPackageInstalled('react-native', projectPackage)) {\n return Integration.reactNative;\n }\n if (hasPackageInstalled('cordova', projectPackage)) {\n return Integration.cordova;\n }\n if (hasPackageInstalled('electron', projectPackage)) {\n return Integration.electron;\n }\n if (hasPackageInstalled('next', projectPackage)) {\n return Integration.nextjs;\n }\n if (hasPackageInstalled('remix-run', projectPackage)) {\n return Integration.remix;\n }\n if (hasPackageInstalled('@sveltejs/kit', projectPackage)) {\n return Integration.sveltekit;\n }\n\n return;\n }\n\n private async _getIntegrationPromptSelection(): Promise<IntegrationPromptAnswer> {\n // If we receive project type as an arg we skip asking\n if (this._argv.integration) {\n return { integration: this._argv.integration };\n } else {\n if (this._argv.quiet) {\n throw new Error('You need to choose a platform');\n }\n\n const detectedDefaultSelection = this.tryDetectingIntegration();\n\n return prompt([\n {\n choices: getIntegrationChoices(),\n default: detectedDefaultSelection,\n message: 'What platform do you want to set up?',\n name: 'integration',\n type: 'list',\n pageSize: 10,\n },\n ]);\n }\n }\n}\n\n/**\n * For the `clack`-based wizard flows, which we only shim here, we don't set\n * a default url value. For backwards-compatibility with the other flows,\n * we fill it here and sanitize a user-enterd url.\n */\nfunction sanitizeUrl(argv: Args): Args {\n if (!argv.url) {\n argv.url = DEFAULT_URL;\n dim(`no URL provided, fallback to ${argv.url}`);\n return argv;\n }\n\n let baseUrl = argv.url;\n baseUrl += baseUrl.endsWith('/') ? '' : '/';\n baseUrl = baseUrl.replace(/:\\/(?!\\/)/g, '://');\n argv.url = baseUrl;\n\n return argv;\n}\n"]}
@@ -1,35 +1,10 @@
1
- import type { Answers } from 'inquirer';
2
- import type { Args } from '../../Constants';
3
- import { SentryCli } from '../../Helper/SentryCli';
4
- import { MobileProject } from './MobileProject';
5
- export declare const COMPATIBLE_REACT_NATIVE_VERSIONS = ">=0.69.0";
6
- export declare const COMPATIBLE_SDK_VERSION = ">= 5.0.0";
7
- export declare const SENTRY_REACT_NATIVE_PACKAGE = "@sentry/react-native";
8
- export declare const REACT_NATIVE_PACKAGE = "react-native";
9
- export declare const DOCS_MANUAL_STEPS = "https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/";
10
- export declare class ReactNative extends MobileProject {
1
+ import { Answers } from 'inquirer';
2
+ import { type Args } from '../../Constants';
3
+ import { BaseIntegration } from './BaseIntegration';
4
+ export declare class ReactNative extends BaseIntegration {
11
5
  protected _argv: Args;
12
- /**
13
- * All React Native versions have app/build.gradle with android section.
14
- */
15
- private static _buildGradleAndroidSectionBeginning;
16
- private url;
17
- protected _answers: Answers;
18
- protected _sentryCli: SentryCli;
6
+ argv: Args;
19
7
  constructor(_argv: Args);
20
- emit(answers: Answers): Promise<Answers>;
21
- uninstall(_answers: Answers): Promise<Answers>;
22
- protected _shouldConfigurePlatform(platform: string): Promise<boolean>;
23
- private _readAppPackage;
24
- private _podInstall;
25
- private _patchJsSentryInit;
26
- private _addSentryProperties;
27
- private _patchJs;
28
- private _patchBuildGradle;
29
- private _unpatchBuildGradle;
30
- private _patchExistingXcodeBuildScripts;
31
- private _addNewXcodeBuildPhaseForSymbols;
32
- private _patchXcodeProj;
33
- private _unpatchXcodeBuildScripts;
34
- private _unpatchXcodeProj;
8
+ emit(_answers: Answers): Promise<Answers>;
9
+ shouldConfigure(_answers: Answers): Promise<Answers>;
35
10
  }
@@ -14,29 +14,6 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
17
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
18
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
19
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -74,488 +51,43 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
74
51
  }
75
52
  };
76
53
  Object.defineProperty(exports, "__esModule", { value: true });
77
- exports.ReactNative = exports.DOCS_MANUAL_STEPS = exports.REACT_NATIVE_PACKAGE = exports.SENTRY_REACT_NATIVE_PACKAGE = exports.COMPATIBLE_SDK_VERSION = exports.COMPATIBLE_REACT_NATIVE_VERSIONS = void 0;
78
- /* eslint-disable max-lines */
79
- var child_process_1 = require("child_process");
80
- var fs = __importStar(require("fs"));
81
- var inquirer_1 = require("inquirer");
82
- var _ = __importStar(require("lodash"));
83
- var path = __importStar(require("path"));
84
- var util_1 = require("util");
85
- var File_1 = require("../../Helper/File");
86
- var Logging_1 = require("../../Helper/Logging");
87
- var Package_1 = require("../../Helper/Package");
88
- var package_manager_1 = require("../../../src/utils/package-manager");
89
- var SentryCli_1 = require("../../Helper/SentryCli");
90
- var MobileProject_1 = require("./MobileProject");
91
- var BottomBar_1 = require("../../Helper/BottomBar");
92
- var url_1 = require("url");
93
- var xcode = require('xcode');
94
- exports.COMPATIBLE_REACT_NATIVE_VERSIONS = '>=0.69.0';
95
- exports.COMPATIBLE_SDK_VERSION = '>= 5.0.0';
96
- exports.SENTRY_REACT_NATIVE_PACKAGE = '@sentry/react-native';
97
- exports.REACT_NATIVE_PACKAGE = 'react-native';
98
- exports.DOCS_MANUAL_STEPS = 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/';
99
- var ReactNative = exports.ReactNative = /** @class */ (function (_super) {
54
+ exports.ReactNative = void 0;
55
+ var BaseIntegration_1 = require("./BaseIntegration");
56
+ var react_native_wizard_1 = require("../../../src/react-native/react-native-wizard");
57
+ var ReactNative = /** @class */ (function (_super) {
100
58
  __extends(ReactNative, _super);
101
59
  function ReactNative(_argv) {
102
60
  var _this = _super.call(this, _argv) || this;
103
61
  _this._argv = _argv;
104
- _this.url = _argv.url;
105
- _this._sentryCli = new SentryCli_1.SentryCli(_this._argv);
62
+ _this.argv = _argv;
106
63
  return _this;
107
64
  }
108
- ReactNative.prototype.emit = function (answers) {
65
+ ReactNative.prototype.emit = function (_answers) {
109
66
  return __awaiter(this, void 0, void 0, function () {
110
- var userAnswers, packageManager, hasCompatibleReactNativeVersion, hasCompatibleSentryReactNativeVersion, sentryCliProperties, promises, host, orgSlug, projectId, projectIssuesUrl;
111
- var _this = this;
112
67
  return __generator(this, function (_a) {
113
68
  switch (_a.label) {
114
- case 0:
115
- if (this._argv.uninstall) {
116
- return [2 /*return*/, this.uninstall(answers)];
117
- }
118
- return [4 /*yield*/, this.shouldEmit(answers)];
69
+ case 0: return [4 /*yield*/, (0, react_native_wizard_1.runReactNativeWizard)({
70
+ promoCode: this._argv.promoCode,
71
+ url: this._argv.url,
72
+ telemetryEnabled: !this._argv.disableTelemetry,
73
+ uninstall: this._argv.uninstall,
74
+ // eslint-disable-next-line no-console
75
+ }).catch(console.error)];
119
76
  case 1:
120
- if (!(_a.sent())) {
121
- return [2 /*return*/, {}];
122
- }
123
- (0, Logging_1.nl)();
124
- userAnswers = { continue: true };
125
- packageManager = (0, package_manager_1.detectPackageManger)();
126
- hasCompatibleReactNativeVersion = (0, Package_1.checkPackageVersion)(this._readAppPackage(), exports.REACT_NATIVE_PACKAGE, exports.COMPATIBLE_REACT_NATIVE_VERSIONS, true);
127
- if (!(!hasCompatibleReactNativeVersion && !this._argv.quiet)) return [3 /*break*/, 3];
128
- return [4 /*yield*/, (0, inquirer_1.prompt)({
129
- message: "Your version of React Native is not compatible with Sentry's React Native SDK. Do you want to continue?",
130
- name: 'continue',
131
- default: false,
132
- type: 'confirm',
133
- })];
134
- case 2:
135
- userAnswers = _a.sent();
136
- (0, Logging_1.nl)();
137
- _a.label = 3;
138
- case 3:
139
- if (!userAnswers.continue) {
140
- throw new Error("Please upgrade to a version that is compatible with ".concat(exports.COMPATIBLE_REACT_NATIVE_VERSIONS, ". Or use ").concat(exports.DOCS_MANUAL_STEPS));
141
- }
142
- if (!packageManager) return [3 /*break*/, 5];
143
- BottomBar_1.BottomBar.show("Adding ".concat(exports.SENTRY_REACT_NATIVE_PACKAGE, "..."));
144
- return [4 /*yield*/, (0, package_manager_1.installPackageWithPackageManager)(packageManager, exports.SENTRY_REACT_NATIVE_PACKAGE)];
145
- case 4:
146
- _a.sent();
147
- BottomBar_1.BottomBar.hide();
148
- (0, Logging_1.green)("\u2713 Added `".concat(exports.SENTRY_REACT_NATIVE_PACKAGE, "`"));
149
- _a.label = 5;
150
- case 5:
151
- hasCompatibleSentryReactNativeVersion = (0, Package_1.checkPackageVersion)(this._readAppPackage(), exports.SENTRY_REACT_NATIVE_PACKAGE, exports.COMPATIBLE_SDK_VERSION, true);
152
- if (!(!hasCompatibleSentryReactNativeVersion && !this._argv.quiet)) return [3 /*break*/, 7];
153
- return [4 /*yield*/, (0, inquirer_1.prompt)({
154
- message: "Your version of ".concat(exports.SENTRY_REACT_NATIVE_PACKAGE, " is not compatible with this wizard. Do you want to continue?"),
155
- name: 'continue',
156
- default: false,
157
- type: 'confirm',
158
- })];
159
- case 6:
160
- userAnswers = _a.sent();
161
- (0, Logging_1.nl)();
162
- _a.label = 7;
163
- case 7:
164
- if (!userAnswers.continue) {
165
- throw new Error("Please upgrade to a version that is compatible with ".concat(exports.COMPATIBLE_SDK_VERSION, "."));
166
- }
167
- sentryCliProperties = this._sentryCli.convertAnswersToProperties(answers);
168
- promises = this.getPlatforms(answers).map(function (platform) { return __awaiter(_this, void 0, void 0, function () {
169
- var e_1;
170
- return __generator(this, function (_a) {
171
- switch (_a.label) {
172
- case 0:
173
- _a.trys.push([0, 8, , 9]);
174
- if (!(platform === 'ios')) return [3 /*break*/, 3];
175
- return [4 /*yield*/, (0, File_1.patchMatchingFile)('ios/*.xcodeproj/project.pbxproj', this._patchXcodeProj.bind(this))];
176
- case 1:
177
- _a.sent();
178
- (0, Logging_1.green)('✓ Patched build script in Xcode project.');
179
- BottomBar_1.BottomBar.show('Adding Sentry pods...');
180
- return [4 /*yield*/, this._podInstall()];
181
- case 2:
182
- _a.sent();
183
- BottomBar_1.BottomBar.hide();
184
- (0, Logging_1.green)('✓ Pods installed.');
185
- return [3 /*break*/, 5];
186
- case 3: return [4 /*yield*/, (0, File_1.patchMatchingFile)('**/app/build.gradle', this._patchBuildGradle.bind(this))];
187
- case 4:
188
- _a.sent();
189
- (0, Logging_1.green)('✓ Patched build.gradle file.');
190
- _a.label = 5;
191
- case 5: return [4 /*yield*/, this._patchJsSentryInit(platform, answers)];
192
- case 6:
193
- _a.sent();
194
- return [4 /*yield*/, this._addSentryProperties(platform, sentryCliProperties)];
195
- case 7:
196
- _a.sent();
197
- (0, Logging_1.green)("\u2713 Added sentry.properties file to ".concat(platform));
198
- return [3 /*break*/, 9];
199
- case 8:
200
- e_1 = _a.sent();
201
- (0, Logging_1.red)(e_1);
202
- return [3 /*break*/, 9];
203
- case 9: return [2 /*return*/];
204
- }
205
- });
206
- }); });
207
- return [4 /*yield*/, Promise.all(promises)];
208
- case 8:
209
- _a.sent();
210
- host = null;
211
- try {
212
- host = new url_1.URL(this.url || '').host;
213
- }
214
- catch (_error) {
215
- // ignore
216
- }
217
- orgSlug = _.get(answers, 'config.organization.slug', null);
218
- projectId = _.get(answers, 'config.project.id', null);
219
- projectIssuesUrl = host && orgSlug && projectId
220
- ? "https://".concat(orgSlug, ".").concat(host, "/issues/?project=").concat(projectId)
221
- : null;
222
- (0, Logging_1.l)("\nTo 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");
223
- if (projectIssuesUrl) {
224
- (0, Logging_1.l)("After that check your project issues:");
225
- (0, Logging_1.l)(projectIssuesUrl);
226
- (0, Logging_1.nl)();
227
- }
228
- (0, Logging_1.l)("<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>");
229
- (0, Logging_1.nl)();
230
- if (!!this._argv.quiet) return [3 /*break*/, 10];
231
- return [4 /*yield*/, (0, inquirer_1.prompt)({
232
- message: 'Have you successfully sent a test event?',
233
- name: 'snippet',
234
- default: true,
235
- type: 'confirm',
236
- })];
237
- case 9:
238
- _a.sent();
239
- _a.label = 10;
240
- case 10: return [2 /*return*/, answers];
241
- }
242
- });
243
- });
244
- };
245
- ReactNative.prototype.uninstall = function (_answers) {
246
- return __awaiter(this, void 0, void 0, function () {
247
- return __generator(this, function (_a) {
248
- switch (_a.label) {
249
- case 0: return [4 /*yield*/, (0, File_1.patchMatchingFile)('**/*.xcodeproj/project.pbxproj', this._unpatchXcodeProj.bind(this))];
250
- case 1:
251
- _a.sent();
252
- return [4 /*yield*/, (0, File_1.patchMatchingFile)('**/app/build.gradle', this._unpatchBuildGradle.bind(this))];
253
- case 2:
254
77
  _a.sent();
255
78
  return [2 /*return*/, {}];
256
79
  }
257
80
  });
258
81
  });
259
82
  };
260
- // eslint-disable-next-line @typescript-eslint/require-await
261
- ReactNative.prototype._shouldConfigurePlatform = function (platform) {
83
+ ReactNative.prototype.shouldConfigure = function (_answers) {
262
84
  return __awaiter(this, void 0, void 0, function () {
263
- var result, regex;
264
85
  return __generator(this, function (_a) {
265
- result = false;
266
- if (!(0, File_1.exists)("".concat(platform, "/sentry.properties"))) {
267
- result = true;
268
- this.debug("".concat(platform, "/sentry.properties not exists"));
269
- }
270
- if (!(0, File_1.matchesContent)('**/*.xcodeproj/project.pbxproj', /sentry-cli/gi)) {
271
- result = true;
272
- this.debug('**/*.xcodeproj/project.pbxproj not matched');
273
- }
274
- if (!(0, File_1.matchesContent)('**/app/build.gradle', /sentry\.gradle/gi)) {
275
- result = true;
276
- this.debug('**/app/build.gradle not matched');
277
- }
278
- regex = /Sentry/gi;
279
- if ((0, File_1.exists)("index.".concat(platform, ".js")) &&
280
- !(0, File_1.matchesContent)("index.".concat(platform, ".js"), regex)) {
281
- result = true;
282
- this.debug("index.".concat(platform, ".js not matched"));
283
- }
284
- if ((0, File_1.exists)('App.js') && !(0, File_1.matchesContent)('App.js', regex)) {
285
- result = true;
286
- this.debug('index.js or App.js not matched');
287
- }
288
- if (this._argv.uninstall) {
289
- // if we uninstall we need to invert the result so we remove already patched
290
- // but leave untouched platforms as they are
291
- return [2 /*return*/, !result];
292
- }
293
- return [2 /*return*/, result];
294
- });
295
- });
296
- };
297
- ReactNative.prototype._readAppPackage = function () {
298
- var appPackage = {};
299
- try {
300
- appPackage = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'));
301
- }
302
- catch (_a) {
303
- // We don't need to have this
304
- }
305
- return appPackage;
306
- };
307
- ReactNative.prototype._podInstall = function () {
308
- return __awaiter(this, void 0, void 0, function () {
309
- return __generator(this, function (_a) {
310
- switch (_a.label) {
311
- case 0: return [4 /*yield*/, (0, util_1.promisify)(child_process_1.exec)('npx --yes pod-install --non-interactive --quiet')];
312
- case 1:
313
- _a.sent();
314
- return [2 /*return*/];
315
- }
316
- });
317
- });
318
- };
319
- ReactNative.prototype._patchJsSentryInit = function (platform, answers) {
320
- return __awaiter(this, void 0, void 0, function () {
321
- var prefixGlob, suffixGlob, platformGlob, universalGlob, jsFileGlob, jsFileToPatch;
322
- return __generator(this, function (_a) {
323
- switch (_a.label) {
324
- case 0:
325
- prefixGlob = '{.,./src}';
326
- suffixGlob = '@(j|t|cj|mj)s?(x)';
327
- platformGlob = "index.".concat(platform, ".").concat(suffixGlob);
328
- universalGlob = "App.".concat(suffixGlob);
329
- jsFileGlob = "".concat(prefixGlob, "/+(").concat(platformGlob, "|").concat(universalGlob, ")");
330
- jsFileToPatch = (0, File_1.matchFiles)(jsFileGlob);
331
- if (!(jsFileToPatch.length !== 0)) return [3 /*break*/, 2];
332
- return [4 /*yield*/, (0, File_1.patchMatchingFile)(jsFileGlob, this._patchJs.bind(this), answers, platform)];
333
- case 1:
334
- _a.sent();
335
- (0, Logging_1.green)("\u2713 Patched ".concat(jsFileToPatch.join(', '), " file(s)."));
336
- return [3 /*break*/, 3];
337
- case 2:
338
- (0, Logging_1.red)("\u2717 Could not find ".concat(platformGlob, " nor ").concat(universalGlob, " files."));
339
- (0, Logging_1.red)('✗ Please, visit https://docs.sentry.io/platforms/react-native');
340
- _a.label = 3;
341
- case 3: return [2 /*return*/];
342
- }
343
- });
344
- });
345
- };
346
- ReactNative.prototype._addSentryProperties = function (platform, properties) {
347
- var _this = this;
348
- var rv = Promise.resolve();
349
- // This will create the ios/android folder before trying to write
350
- // sentry.properties in it which would fail otherwise
351
- if (!fs.existsSync(platform)) {
352
- (0, Logging_1.dim)("".concat(platform, " folder did not exist, creating it."));
353
- fs.mkdirSync(platform);
354
- }
355
- var fn = path.join(platform, 'sentry.properties');
356
- if (platform === 'android' && properties['cli/executable']) {
357
- // We don't need to write the sentry-cli path in the properties file
358
- // since our gradle plugins already pick it up on the correct spot
359
- delete properties['cli/executable'];
360
- }
361
- rv = rv.then(function () {
362
- return fs.writeFileSync(fn, _this._sentryCli.dumpProperties(properties));
363
- });
364
- return rv;
365
- };
366
- ReactNative.prototype._patchJs = function (contents, _filename, answers, platform) {
367
- // since the init call could live in other places too, we really only
368
- // want to do this if we managed to patch any of the other files as well.
369
- if (contents.match(/Sentry.config\(/)) {
370
- return Promise.resolve(null);
371
- }
372
- // if we match @sentry\/react-native somewhere, we already patched the file
373
- // and no longer need to
374
- if (contents.match('@sentry/react-native')) {
375
- return Promise.resolve(contents);
376
- }
377
- var dsn = '__DSN__';
378
- this.getPlatforms(answers).forEach(function (selectedPlatform) {
379
- if (platform && selectedPlatform === platform) {
380
- dsn = _.get(answers, 'config.dsn.public', null);
381
- }
382
- else if (platform === undefined) {
383
- dsn = _.get(answers, 'config.dsn.public', null);
384
- }
385
- });
386
- return Promise.resolve(contents.replace(/^([^]*)(import\s+[^;]*?;$)/m, function (match) {
387
- // eslint-disable-next-line prefer-template
388
- return match +
389
- "\n\nimport * as Sentry from '@sentry/react-native';\n\n" +
390
- 'Sentry.init({ \n' +
391
- " dsn: '".concat(dsn, "', \n") +
392
- '});\n';
393
- }));
394
- };
395
- // ANDROID -----------------------------------------
396
- ReactNative.prototype._patchBuildGradle = function (contents) {
397
- var applyFrom = 'apply from: "../../node_modules/@sentry/react-native/sentry.gradle"';
398
- if (contents.indexOf(applyFrom) >= 0) {
399
- return Promise.resolve(null);
400
- }
401
- return Promise.resolve(contents.replace(ReactNative._buildGradleAndroidSectionBeginning,
402
- // eslint-disable-next-line prefer-template
403
- function (match) { return applyFrom + '\n' + match; }));
404
- };
405
- ReactNative.prototype._unpatchBuildGradle = function (contents) {
406
- return Promise.resolve(contents.replace(/^\s*apply from: ["']..\/..\/node_modules\/@sentry\/react-native\/sentry.gradle["'];?\s*?\r?\n/m, ''));
407
- };
408
- // IOS -----------------------------------------
409
- ReactNative.prototype._patchExistingXcodeBuildScripts = function (buildScripts) {
410
- for (var _i = 0, buildScripts_1 = buildScripts; _i < buildScripts_1.length; _i++) {
411
- var script = buildScripts_1[_i];
412
- if (!script.shellScript.match(/\/scripts\/react-native-xcode\.sh/i) ||
413
- script.shellScript.match(/sentry-cli\s+react-native\s+xcode/i)) {
414
- continue;
415
- }
416
- var code = JSON.parse(script.shellScript);
417
- code =
418
- // eslint-disable-next-line prefer-template, @typescript-eslint/restrict-plus-operands
419
- 'export SENTRY_PROPERTIES=sentry.properties\n' +
420
- 'export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"\n' +
421
- code.replace('$REACT_NATIVE_XCODE', function () {
422
- // eslint-disable-next-line no-useless-escape
423
- return '\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\"';
424
- }) +
425
- '\n/bin/sh -c "$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh"\n';
426
- script.shellScript = JSON.stringify(code);
427
- }
428
- };
429
- ReactNative.prototype._addNewXcodeBuildPhaseForSymbols = function (buildScripts, proj) {
430
- for (var _i = 0, buildScripts_2 = buildScripts; _i < buildScripts_2.length; _i++) {
431
- var script = buildScripts_2[_i];
432
- if (script.shellScript.match(/sentry-cli\s+(upload-dsym|debug-files upload)/)) {
433
- return;
434
- }
435
- }
436
- proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Upload Debug Symbols to Sentry', null, {
437
- shellPath: '/bin/sh',
438
- shellScript: "\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nif [ -f \"$WITH_ENVIRONMENT\" ]; then\n . \"$WITH_ENVIRONMENT\"\nfi \nexport SENTRY_PROPERTIES=sentry.properties\n[ \"$SENTRY_INCLUDE_NATIVE_SOURCES\" = \"true\" ] && INCLUDE_SOURCES_FLAG=\"--include-sources\" || INCLUDE_SOURCES_FLAG=\"\"\n../node_modules/@sentry/cli/bin/sentry-cli debug-files upload \"$INCLUDE_SOURCES_FLAG\" \"$DWARF_DSYM_FOLDER_PATH\"\n",
439
- });
440
- };
441
- ReactNative.prototype._patchXcodeProj = function (contents, filename) {
442
- var _this = this;
443
- var proj = xcode.project(filename);
444
- return new Promise(function (resolve, reject) {
445
- proj.parse(function (err) {
446
- if (err) {
447
- reject(err);
448
- return;
449
- }
450
- var buildScripts = [];
451
- for (var key in proj.hash.project.objects.PBXShellScriptBuildPhase ||
452
- {}) {
453
- if (
454
- // eslint-disable-next-line no-prototype-builtins
455
- proj.hash.project.objects.PBXShellScriptBuildPhase.hasOwnProperty(key)) {
456
- var val = proj.hash.project.objects.PBXShellScriptBuildPhase[key];
457
- if (val.isa) {
458
- buildScripts.push(val);
459
- }
460
- }
461
- }
462
- try {
463
- _this._patchExistingXcodeBuildScripts(buildScripts);
464
- }
465
- catch (e) {
466
- (0, Logging_1.red)(e);
467
- }
468
- try {
469
- _this._addNewXcodeBuildPhaseForSymbols(buildScripts, proj);
470
- }
471
- catch (e) {
472
- (0, Logging_1.red)(e);
473
- }
474
- // we always modify the xcode file in memory but we only want to save it
475
- // in case the user wants configuration for ios. This is why we check
476
- // here first if changes are made before we might prompt the platform
477
- // continue prompt.
478
- var newContents = proj.writeSync();
479
- if (newContents === contents) {
480
- resolve(undefined);
481
- }
482
- else {
483
- resolve(newContents);
484
- }
485
- });
486
- });
487
- };
488
- ReactNative.prototype._unpatchXcodeBuildScripts = function (proj) {
489
- var scripts = proj.hash.project.objects.PBXShellScriptBuildPhase || {};
490
- var firstTarget = proj.getFirstTarget().uuid;
491
- var nativeTargets = proj.hash.project.objects.PBXNativeTarget;
492
- // scripts to patch partially. Run this first so that we don't
493
- // accidentally delete some scripts later entirely that we only want to
494
- // rewrite.
495
- for (var _i = 0, _a = Object.keys(scripts); _i < _a.length; _i++) {
496
- var key = _a[_i];
497
- var script = scripts[key];
498
- // ignore comments
499
- if (typeof script === 'string') {
500
- continue;
501
- }
502
- // ignore scripts that do not invoke the react-native-xcode command.
503
- if (!script.shellScript.match(/sentry-cli\s+react-native\s+xcode/i)) {
504
- continue;
505
- }
506
- script.shellScript = JSON.stringify(JSON.parse(script.shellScript)
507
- // remove sentry properties export
508
- .replace(/^export SENTRY_PROPERTIES=sentry.properties\r?\n/m, '')
509
- .replace(/^\/bin\/sh .*?..\/node_modules\/@sentry\/react-native\/scripts\/collect-modules.sh"?\r?\n/m, '')
510
- // unwrap react-native-xcode.sh command. In case someone replaced it
511
- // entirely with the sentry-cli command we need to put the original
512
- // version back in.
513
- .replace(/\.\.\/node_modules\/@sentry\/cli\/bin\/sentry-cli\s+react-native\s+xcode\s+\$REACT_NATIVE_XCODE/i, '$REACT_NATIVE_XCODE'));
514
- }
515
- // scripts to kill entirely.
516
- for (var _b = 0, _c = Object.keys(scripts); _b < _c.length; _b++) {
517
- var key = _c[_b];
518
- var script = scripts[key];
519
- // ignore comments and keys that got deleted
520
- if (typeof script === 'string' || script === undefined) {
521
- continue;
522
- }
523
- if (script.shellScript.match(/@sentry\/cli\/bin\/sentry-cli\s+(upload-dsym|debug-files upload)\b/)) {
524
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
525
- delete scripts[key];
526
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
527
- delete scripts["".concat(key, "_comment")];
528
- var phases = nativeTargets[firstTarget].buildPhases;
529
- if (phases) {
530
- for (var i = 0; i < phases.length; i++) {
531
- if (phases[i].value === key) {
532
- phases.splice(i, 1);
533
- break;
534
- }
535
- }
536
- }
537
- continue;
538
- }
539
- }
540
- };
541
- ReactNative.prototype._unpatchXcodeProj = function (_contents, filename) {
542
- var _this = this;
543
- var proj = xcode.project(filename);
544
- return new Promise(function (resolve, reject) {
545
- proj.parse(function (err) {
546
- if (err) {
547
- reject(err);
548
- return;
549
- }
550
- _this._unpatchXcodeBuildScripts(proj);
551
- resolve(proj.writeSync());
86
+ return [2 /*return*/, this._shouldConfigure];
552
87
  });
553
88
  });
554
89
  };
555
- /**
556
- * All React Native versions have app/build.gradle with android section.
557
- */
558
- ReactNative._buildGradleAndroidSectionBeginning = /^android {/m;
559
90
  return ReactNative;
560
- }(MobileProject_1.MobileProject));
91
+ }(BaseIntegration_1.BaseIntegration));
92
+ exports.ReactNative = ReactNative;
561
93
  //# sourceMappingURL=ReactNative.js.map