@sentry/wizard 3.15.0 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +11 -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/Cordova.js +7 -0
  5. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  6. package/dist/lib/Steps/Integrations/ReactNative.d.ts +7 -32
  7. package/dist/lib/Steps/Integrations/ReactNative.js +17 -485
  8. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  9. package/dist/package.json +1 -1
  10. package/dist/src/android/android-wizard.js +13 -18
  11. package/dist/src/android/android-wizard.js.map +1 -1
  12. package/dist/src/apple/apple-wizard.js +11 -4
  13. package/dist/src/apple/apple-wizard.js.map +1 -1
  14. package/dist/src/apple/cocoapod.d.ts +1 -0
  15. package/dist/src/apple/cocoapod.js +36 -13
  16. package/dist/src/apple/cocoapod.js.map +1 -1
  17. package/dist/src/nextjs/nextjs-wizard.js +1 -1
  18. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  19. package/dist/src/react-native/glob.d.ts +3 -0
  20. package/dist/src/react-native/glob.js +18 -0
  21. package/dist/src/react-native/glob.js.map +1 -0
  22. package/dist/src/react-native/gradle.d.ts +4 -0
  23. package/dist/src/react-native/gradle.js +49 -0
  24. package/dist/src/react-native/gradle.js.map +1 -0
  25. package/dist/src/react-native/javascript.d.ts +8 -0
  26. package/dist/src/react-native/javascript.js +25 -0
  27. package/dist/src/react-native/javascript.js.map +1 -0
  28. package/dist/src/react-native/options.d.ts +4 -0
  29. package/dist/src/react-native/options.js +3 -0
  30. package/dist/src/react-native/options.js.map +1 -0
  31. package/dist/src/react-native/react-native-wizard.d.ts +9 -0
  32. package/dist/src/react-native/react-native-wizard.js +356 -0
  33. package/dist/src/react-native/react-native-wizard.js.map +1 -0
  34. package/dist/src/react-native/uninstall.d.ts +2 -0
  35. package/dist/src/react-native/uninstall.js +130 -0
  36. package/dist/src/react-native/uninstall.js.map +1 -0
  37. package/dist/src/react-native/xcode.d.ts +18 -0
  38. package/dist/src/react-native/xcode.js +170 -0
  39. package/dist/src/react-native/xcode.js.map +1 -0
  40. package/dist/src/remix/remix-wizard.js +1 -1
  41. package/dist/src/remix/remix-wizard.js.map +1 -1
  42. package/dist/src/sourcemaps/tools/nextjs.js +3 -3
  43. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  44. package/dist/src/sourcemaps/tools/sentry-cli.js +1 -1
  45. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  46. package/dist/src/sveltekit/sveltekit-wizard.js +1 -1
  47. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  48. package/dist/src/utils/clack-utils.d.ts +19 -3
  49. package/dist/src/utils/clack-utils.js +141 -39
  50. package/dist/src/utils/clack-utils.js.map +1 -1
  51. package/dist/src/utils/semver.d.ts +5 -0
  52. package/dist/src/utils/semver.js +27 -0
  53. package/dist/src/utils/semver.js.map +1 -0
  54. package/dist/src/utils/sentrycli-utils.js +4 -1
  55. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  56. package/dist/src/utils/types.d.ts +3 -0
  57. package/dist/src/utils/types.js.map +1 -1
  58. package/dist/test/react-native/gradle.test.js +57 -0
  59. package/dist/test/react-native/gradle.test.js.map +1 -0
  60. package/dist/test/react-native/javascript.test.js +47 -0
  61. package/dist/test/react-native/javascript.test.js.map +1 -0
  62. package/dist/test/react-native/xcode.test.d.ts +1 -0
  63. package/dist/test/react-native/xcode.test.js +144 -0
  64. package/dist/test/react-native/xcode.test.js.map +1 -0
  65. package/lib/Steps/ChooseIntegration.ts +1 -1
  66. package/lib/Steps/Integrations/Cordova.ts +7 -0
  67. package/lib/Steps/Integrations/ReactNative.ts +17 -573
  68. package/package.json +1 -1
  69. package/src/android/android-wizard.ts +3 -18
  70. package/src/apple/apple-wizard.ts +12 -3
  71. package/src/apple/cocoapod.ts +20 -9
  72. package/src/nextjs/nextjs-wizard.ts +1 -1
  73. package/src/react-native/glob.ts +13 -0
  74. package/src/react-native/gradle.ts +26 -0
  75. package/src/react-native/javascript.ts +33 -0
  76. package/src/react-native/options.ts +5 -0
  77. package/src/react-native/react-native-wizard.ts +369 -0
  78. package/src/react-native/uninstall.ts +107 -0
  79. package/src/react-native/xcode.ts +228 -0
  80. package/src/remix/remix-wizard.ts +2 -2
  81. package/src/sourcemaps/tools/nextjs.ts +6 -6
  82. package/src/sourcemaps/tools/sentry-cli.ts +1 -1
  83. package/src/sveltekit/sveltekit-wizard.ts +1 -1
  84. package/src/utils/clack-utils.ts +229 -74
  85. package/src/utils/semver.ts +33 -0
  86. package/src/utils/sentrycli-utils.ts +3 -1
  87. package/src/utils/types.ts +3 -0
  88. package/test/react-native/gradle.test.ts +310 -0
  89. package/test/react-native/javascript.test.ts +131 -0
  90. package/test/react-native/xcode.test.ts +238 -0
  91. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +0 -198
  92. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +0 -1
  93. package/dist/lib/__tests__/Setup.js +0 -57
  94. package/dist/lib/__tests__/Setup.js.map +0 -1
  95. package/lib/Steps/Integrations/__tests__/ReactNative.ts +0 -136
  96. package/lib/__tests__/Setup.ts +0 -42
  97. /package/dist/{lib/Steps/Integrations/__tests__/ReactNative.d.ts → test/react-native/gradle.test.d.ts} +0 -0
  98. /package/dist/{lib/__tests__/Setup.d.ts → test/react-native/javascript.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SentryProjectData {\n id: string;\n slug: string;\n name: string;\n platform: string;\n organization: {\n slug: string;\n };\n keys: [{ dsn: { public: string } }];\n}\n\nexport type WizardOptions = {\n /**\n * Controls whether the wizard should send telemetry data to Sentry.\n */\n telemetryEnabled: boolean;\n\n /**\n * The promo code to use while signing up for Sentry.\n * This can be passed via the --promo-code arg.\n */\n promoCode?: string;\n\n /**\n * The url of the Sentry instance to use.\n * This can be passed via the `-u` or `--url` arg.\n */\n url?: string;\n\n /**\n * If this is set, the wizard will skip the login and project selection step.\n * (This can not yet be set externally but for example when redirecting from\n * one wizard to another when the project was already selected)\n */\n preSelectedProject?: {\n project: SentryProjectData;\n authToken: string;\n selfHosted: boolean;\n };\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SentryProjectData {\n id: string;\n slug: string;\n name: string;\n platform: string;\n organization: {\n slug: string;\n links: {\n organizationUrl: string;\n };\n };\n keys: [{ dsn: { public: string } }];\n}\n\nexport type WizardOptions = {\n /**\n * Controls whether the wizard should send telemetry data to Sentry.\n */\n telemetryEnabled: boolean;\n\n /**\n * The promo code to use while signing up for Sentry.\n * This can be passed via the --promo-code arg.\n */\n promoCode?: string;\n\n /**\n * The url of the Sentry instance to use.\n * This can be passed via the `-u` or `--url` arg.\n */\n url?: string;\n\n /**\n * If this is set, the wizard will skip the login and project selection step.\n * (This can not yet be set externally but for example when redirecting from\n * one wizard to another when the project was already selected)\n */\n preSelectedProject?: {\n project: SentryProjectData;\n authToken: string;\n selfHosted: boolean;\n };\n};\n"]}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var gradle_1 = require("../../src/react-native/gradle");
4
+ describe('react-native gradle', function () {
5
+ describe('doesAppBuildGradleIncludeSentry', function () {
6
+ it('returns false for empty file', function () {
7
+ expect((0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)('')).toBe(false);
8
+ });
9
+ it('returns false for minimal app/build.gradle', function () {
10
+ var appBuildGradle = "apply plugin: \"com.android.application\"\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
11
+ expect((0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(appBuildGradle)).toBe(false);
12
+ });
13
+ it('returns false for app/build.gradle with SAGP', function () {
14
+ var appBuildGradle = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
15
+ expect((0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(appBuildGradle)).toBe(false);
16
+ });
17
+ it('returns true for app/build.gradle with RN SAGP', function () {
18
+ var appBuildGradle = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
19
+ expect((0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(appBuildGradle)).toBe(true);
20
+ });
21
+ });
22
+ describe('addRNSentryGradlePlugin', function () {
23
+ it('does not add nothing to empty file', function () {
24
+ expect((0, gradle_1.addRNSentryGradlePlugin)('')).toBe('');
25
+ });
26
+ it('does add RN SAGP', function () {
27
+ var input = "apply plugin: \"com.android.application\"\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
28
+ var expectedOutput = "apply plugin: \"com.android.application\"\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
29
+ expect((0, gradle_1.addRNSentryGradlePlugin)(input)).toBe(expectedOutput);
30
+ });
31
+ it('does add RN SAGP to build gradle with SAGP', function () {
32
+ var input = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
33
+ var expectedOutput = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
34
+ expect((0, gradle_1.addRNSentryGradlePlugin)(input)).toBe(expectedOutput);
35
+ });
36
+ });
37
+ describe('removeRNSentryGradlePlugin', function () {
38
+ it('does not add nothing to empty file', function () {
39
+ expect((0, gradle_1.removeRNSentryGradlePlugin)('')).toBe('');
40
+ });
41
+ it('does not change build gradle without RN SAGP', function () {
42
+ var input = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
43
+ expect((0, gradle_1.removeRNSentryGradlePlugin)(input)).toBe(input);
44
+ });
45
+ it('does remove RN SAGP referenced by node resolved path', function () {
46
+ var input = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
47
+ var output = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
48
+ expect((0, gradle_1.removeRNSentryGradlePlugin)(input)).toBe(output);
49
+ });
50
+ it('does remove RN SAGP reference by relative path', function () {
51
+ var input = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: \"../../node_modules/@sentry/react-native/sentry.gradle\"\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
52
+ var output = "apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n";
53
+ expect((0, gradle_1.removeRNSentryGradlePlugin)(input)).toBe(output);
54
+ });
55
+ });
56
+ });
57
+ //# sourceMappingURL=gradle.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradle.test.js","sourceRoot":"","sources":["../../../test/react-native/gradle.test.ts"],"names":[],"mappings":";;AAAA,wDAIuC;AAEvC,QAAQ,CAAC,qBAAqB,EAAE;IAC9B,QAAQ,CAAC,iCAAiC,EAAE;QAC1C,E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cAAc,GAAG,upBAqB5B,CAAC;YACI,MAAM,CAAC,IAAA,gCAAuB,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,4BAA4B,EAAE;QACrC,EAAE,CAAC,oCAAoC,EAAE;YACvC,MAAM,CAAC,IAAA,mCAA0B,EAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE;YACjD,IAAM,KAAK,GAAG,kgBAoBnB,CAAC;YAEI,MAAM,CAAC,IAAA,mCAA0B,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sDAAsD,EAAE;YACzD,IAAM,KAAK,GAAG,upBAqBnB,CAAC;YACI,IAAM,MAAM,GAAG,ggBAmBpB,CAAC;YAEI,MAAM,CAAC,IAAA,mCAA0B,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;YACnD,IAAM,KAAK,GAAG,ykBAqBnB,CAAC;YACI,IAAM,MAAM,GAAG,ggBAmBpB,CAAC;YAEI,MAAM,CAAC,IAAA,mCAA0B,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n addRNSentryGradlePlugin,\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n removeRNSentryGradlePlugin,\n} from '../../src/react-native/gradle';\n\ndescribe('react-native gradle', () => {\n describe('doesAppBuildGradleIncludeSentry', () => {\n it('returns false for empty file', () => {\n expect(doesAppBuildGradleIncludeRNSentryGradlePlugin('')).toBe(false);\n });\n\n it('returns false for minimal app/build.gradle', () => {\n const appBuildGradle = `apply plugin: \"com.android.application\"\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n expect(\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle),\n ).toBe(false);\n });\n\n it('returns false for app/build.gradle with SAGP', () => {\n const appBuildGradle = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n expect(\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle),\n ).toBe(false);\n });\n\n it('returns true for app/build.gradle with RN SAGP', () => {\n const appBuildGradle = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n expect(\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle),\n ).toBe(true);\n });\n });\n\n describe('addRNSentryGradlePlugin', () => {\n it('does not add nothing to empty file', () => {\n expect(addRNSentryGradlePlugin('')).toBe('');\n });\n\n it('does add RN SAGP', () => {\n const input = `apply plugin: \"com.android.application\"\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n const expectedOutput = `apply plugin: \"com.android.application\"\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n expect(addRNSentryGradlePlugin(input)).toBe(expectedOutput);\n });\n\n it('does add RN SAGP to build gradle with SAGP', () => {\n const input = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n const expectedOutput = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n expect(addRNSentryGradlePlugin(input)).toBe(expectedOutput);\n });\n });\n\n describe('removeRNSentryGradlePlugin', () => {\n it('does not add nothing to empty file', () => {\n expect(removeRNSentryGradlePlugin('')).toBe('');\n });\n\n it('does not change build gradle without RN SAGP', () => {\n const input = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n\n expect(removeRNSentryGradlePlugin(input)).toBe(input);\n });\n\n it('does remove RN SAGP referenced by node resolved path', () => {\n const input = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n const output = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n\n expect(removeRNSentryGradlePlugin(input)).toBe(output);\n });\n\n it('does remove RN SAGP reference by relative path', () => {\n const input = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\n\napply from: \"../../node_modules/@sentry/react-native/sentry.gradle\"\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n const output = `apply plugin: \"com.android.application\"\napply plugin: \"io.sentry.android.gradle\"\n\nsentry {\n}\nandroid {\n ndkVersion rootProject.ext.ndkVersion\n\n compileSdkVersion rootProject.ext.compileSdkVersion\n\n namespace \"com.samplenewarchitecture\"\n defaultConfig {\n applicationId \"com.samplenewarchitecture\"\n minSdkVersion rootProject.ext.minSdkVersion\n targetSdkVersion rootProject.ext.targetSdkVersion\n versionCode 1\n versionName \"1.0\"\n }\n}\n`;\n\n expect(removeRNSentryGradlePlugin(input)).toBe(output);\n });\n });\n});\n"]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var javascript_1 = require("../../src/react-native/javascript");
4
+ describe('react-native javascript', function () {
5
+ describe('addSentryInitWithSdkImport', function () {
6
+ it('adds sdk import and sentry init under last import in the file', function () {
7
+ var input = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
8
+ var expectedOutput = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
9
+ expect((0, javascript_1.addSentryInitWithSdkImport)(input, { dsn: 'dsn' })).toBe(expectedOutput);
10
+ });
11
+ it('does not add sdk import and sentry init in the file without imports', function () {
12
+ var input = "export const test = 'test';";
13
+ expect((0, javascript_1.addSentryInitWithSdkImport)(input, { dsn: 'dsn' })).toBe(input);
14
+ });
15
+ it('does not add sdk import and sentry init in the empty file', function () {
16
+ var input = '';
17
+ expect((0, javascript_1.addSentryInitWithSdkImport)(input, { dsn: 'dsn' })).toBe(input);
18
+ });
19
+ });
20
+ describe('doesJsCodeIncludeSdkSentryImport', function () {
21
+ it('returns true if code has sdk import', function () {
22
+ var input = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
23
+ expect((0, javascript_1.doesJsCodeIncludeSdkSentryImport)(input, {
24
+ sdkPackageName: '@sentry/react-native',
25
+ })).toBe(true);
26
+ });
27
+ it('returns true if code has sdk require', function () {
28
+ var input = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nconst Sentry = require('@sentry/react-native');\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
29
+ expect((0, javascript_1.doesJsCodeIncludeSdkSentryImport)(input, {
30
+ sdkPackageName: '@sentry/react-native',
31
+ })).toBe(true);
32
+ });
33
+ it('returns false if code does not have sdk import', function () {
34
+ var input = "export const test = 'test';";
35
+ expect((0, javascript_1.doesJsCodeIncludeSdkSentryImport)(input, {
36
+ sdkPackageName: '@sentry/react-native',
37
+ })).toBe(false);
38
+ });
39
+ it('returns false for empty file', function () {
40
+ var input = '';
41
+ expect((0, javascript_1.doesJsCodeIncludeSdkSentryImport)(input, {
42
+ sdkPackageName: '@sentry/react-native',
43
+ })).toBe(false);
44
+ });
45
+ });
46
+ });
47
+ //# sourceMappingURL=javascript.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.test.js","sourceRoot":"","sources":["../../../test/react-native/javascript.test.ts"],"names":[],"mappings":";;AAAA,gEAG2C;AAE3C,QAAQ,CAAC,yBAAyB,EAAE;IAClC,QAAQ,CAAC,4BAA4B,EAAE;QACrC,EAAE,CAAC,+DAA+D,EAAE;YAClE,IAAM,KAAK,GAAG,8MAcA,CAAC;YAEf,IAAM,cAAc,GAAG,oSAmBT,CAAC;YAEf,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAC5D,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qEAAqE,EAAE;YACxE,IAAM,KAAK,GAAG,6BAA6B,CAAC;YAC5C,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2DAA2D,EAAE;YAC9D,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kCAAkC,EAAE;QAC3C,EAAE,CAAC,qCAAqC,EAAE;YACxC,IAAM,KAAK,GAAG,+PAeA,CAAC;YAEf,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE;YACzC,IAAM,KAAK,GAAG,+PAeA,CAAC;YAEf,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;YACnD,IAAM,KAAK,GAAG,6BAA6B,CAAC;YAC5C,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAAE;YACjC,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n} from '../../src/react-native/javascript';\n\ndescribe('react-native javascript', () => {\n describe('addSentryInitWithSdkImport', () => {\n it('adds sdk import and sentry init under last import in the file', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n const expectedOutput = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(\n expectedOutput,\n );\n });\n\n it('does not add sdk import and sentry init in the file without imports', () => {\n const input = `export const test = 'test';`;\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n\n it('does not add sdk import and sentry init in the empty file', () => {\n const input = '';\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n });\n\n describe('doesJsCodeIncludeSdkSentryImport', () => {\n it('returns true if code has sdk import', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns true if code has sdk require', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nconst Sentry = require('@sentry/react-native');\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns false if code does not have sdk import', () => {\n const input = `export const test = 'test';`;\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n\n it('returns false for empty file', () => {\n const input = '';\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable no-useless-escape */
4
+ var xcode_1 = require("../../src/react-native/xcode");
5
+ describe('react-native xcode', function () {
6
+ describe('addSentryToBundleShellScript', function () {
7
+ it('adds sentry cli to rn bundle build phase', function () {
8
+ var input = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"";
9
+ // actual shell script looks like this:
10
+ // /bin/sh -c "$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\""
11
+ // but during parsing xcode library removes the quotes
12
+ var expectedOutput = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\"\"\n/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"\n";
13
+ expect((0, xcode_1.addSentryToBundleShellScript)(input)).toBe(expectedOutput);
14
+ });
15
+ });
16
+ describe('removeSentryFromBundleShellScript', function () {
17
+ it('removes sentry cli from rn bundle build phase', function () {
18
+ var input = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\"\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"\n";
19
+ var expectedOutput = "export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\"\"\n\n";
20
+ expect((0, xcode_1.removeSentryFromBundleShellScript)(input)).toBe(expectedOutput);
21
+ });
22
+ });
23
+ describe('findBundlePhase', function () {
24
+ it('returns build phase with react native xcode shell script', function () {
25
+ var inputMap = {
26
+ 1: {
27
+ shellScript: 'foo',
28
+ },
29
+ 2: {
30
+ shellScript: 'bar',
31
+ },
32
+ 3: {
33
+ shellScript: "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\"\"\n\n",
34
+ },
35
+ 4: {
36
+ shellScript: 'qux',
37
+ },
38
+ };
39
+ var expected = {
40
+ shellScript: "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\"\"\n\n",
41
+ };
42
+ expect((0, xcode_1.findBundlePhase)(inputMap)).toEqual(expected);
43
+ });
44
+ it('returns undefined if bundle phase not present', function () {
45
+ var inputMap = {
46
+ 1: {
47
+ shellScript: 'foo',
48
+ },
49
+ 2: {
50
+ shellScript: 'bar',
51
+ },
52
+ 3: {
53
+ // note different path to the script
54
+ shellScript: "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/unknown/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\"\"\n\n",
55
+ },
56
+ 4: {
57
+ shellScript: 'qux',
58
+ },
59
+ };
60
+ expect((0, xcode_1.findBundlePhase)(inputMap)).toBeUndefined();
61
+ });
62
+ });
63
+ describe('doesBundlePhaseIncludeSentry', function () {
64
+ it('returns true for script containing sentry cli calling react native xcode command', function () {
65
+ var input = {
66
+ shellScript: "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_CLI=\"sentry-cli react-native xcode\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"$SENTRY_CLI $REACT_NATIVE_XCODE\"\"\n",
67
+ };
68
+ expect((0, xcode_1.doesBundlePhaseIncludeSentry)(input)).toBeTruthy();
69
+ });
70
+ it('returns false', function () {
71
+ var input = {
72
+ // note sentry-cli can be part of the script but doesn't call react native xcode script
73
+ shellScript: "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\"\"\n\nsentry-cli --version\n",
74
+ };
75
+ expect((0, xcode_1.doesBundlePhaseIncludeSentry)(input)).toBeFalsy();
76
+ });
77
+ });
78
+ describe('findDebugFilesUploadPhase', function () {
79
+ it('returns debug files build phase using debug files command', function () {
80
+ var input = {
81
+ 1: {
82
+ shellScript: 'foo',
83
+ },
84
+ 2: {
85
+ shellScript: "set -e\nsentry-cli debug-files upload path/to/dsym --include-sources\n",
86
+ },
87
+ };
88
+ var expected = [
89
+ '2',
90
+ {
91
+ shellScript: "set -e\nsentry-cli debug-files upload path/to/dsym --include-sources\n",
92
+ },
93
+ ];
94
+ expect((0, xcode_1.findDebugFilesUploadPhase)(input)).toEqual(expected);
95
+ });
96
+ it('returns debug files build phase with sentry-cli absolute path', function () {
97
+ var input = {
98
+ 1: {
99
+ shellScript: 'foo',
100
+ },
101
+ 2: {
102
+ shellScript: "set -e\n/path/to/bin/sentry-cli debug-files upload path/to/dsym --include-sources\n",
103
+ },
104
+ };
105
+ var expected = [
106
+ '2',
107
+ {
108
+ shellScript: "set -e\n/path/to/bin/sentry-cli debug-files upload path/to/dsym --include-sources\n",
109
+ },
110
+ ];
111
+ expect((0, xcode_1.findDebugFilesUploadPhase)(input)).toEqual(expected);
112
+ });
113
+ it('returns debug files build phase using dsym command', function () {
114
+ var input = {
115
+ 1: {
116
+ shellScript: 'foo',
117
+ },
118
+ 2: {
119
+ shellScript: "set -e\nsentry-cli upload-dsym path/to/dsym --include-sources\n",
120
+ },
121
+ };
122
+ var expected = [
123
+ '2',
124
+ {
125
+ shellScript: "set -e\nsentry-cli upload-dsym path/to/dsym --include-sources\n",
126
+ },
127
+ ];
128
+ expect((0, xcode_1.findDebugFilesUploadPhase)(input)).toEqual(expected);
129
+ });
130
+ it('returns undefined if build phase not present', function () {
131
+ var input = {
132
+ 1: {
133
+ shellScript: 'foo',
134
+ },
135
+ 2: {
136
+ // sentry-cli present but with different command
137
+ shellScript: 'sentry-cli sourcempas upload',
138
+ },
139
+ };
140
+ expect((0, xcode_1.findDebugFilesUploadPhase)(input)).toBeUndefined();
141
+ });
142
+ });
143
+ });
144
+ //# sourceMappingURL=xcode.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xcode.test.js","sourceRoot":"","sources":["../../../test/react-native/xcode.test.ts"],"names":[],"mappings":";;AAAA,sCAAsC;AACtC,sDAMsC;AAEtC,QAAQ,CAAC,oBAAoB,EAAE;IAC7B,QAAQ,CAAC,8BAA8B,EAAE;QACvC,EAAE,CAAC,0CAA0C,EAAE;YAC7C,IAAM,KAAK,GAAG,0OAK+B,C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AAM,QAAQ,GAAG;gBACf,GAAG;gBACH;oBACE,WAAW,EAAE,qFAEtB;iBACQ;aACF,CAAC;YACF,MAAM,CAAC,IAAA,iCAAyB,EAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oDAAoD,EAAE;YACvD,IAAM,KAAK,GAAG;gBACZ,CAAC,EAAE;oBACD,WAAW,EAAE,KAAK;iBACnB;gBACD,CAAC,EAAE;oBACD,WAAW,EAAE,iEAEtB;iBACQ;aACF,CAAC;YACF,IAAM,QAAQ,GAAG;gBACf,GAAG;gBACH;oBACE,WAAW,EAAE,iEAEtB;iBACQ;aACF,CAAC;YACF,MAAM,CAAC,IAAA,iCAAyB,EAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE;YACjD,IAAM,KAAK,GAAG;gBACZ,CAAC,EAAE;oBACD,WAAW,EAAE,KAAK;iBACnB;gBACD,CAAC,EAAE;oBACD,gDAAgD;oBAChD,WAAW,EAAE,8BAA8B;iBAC5C;aACF,CAAC;YAEF,MAAM,CAAC,IAAA,iCAAyB,EAAC,KAAK,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable no-useless-escape */\nimport {\n addSentryToBundleShellScript,\n doesBundlePhaseIncludeSentry,\n findBundlePhase,\n findDebugFilesUploadPhase,\n removeSentryFromBundleShellScript,\n} from '../../src/react-native/xcode';\n\ndescribe('react-native xcode', () => {\n describe('addSentryToBundleShellScript', () => {\n it('adds sentry cli to rn bundle build phase', () => {\n const input = `set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"`;\n // actual shell script looks like this:\n // /bin/sh -c \"$WITH_ENVIRONMENT \\\"$REACT_NATIVE_XCODE\\\"\"\n // but during parsing xcode library removes the quotes\n const expectedOutput = `export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\\\"\"\n/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"\n`;\n\n expect(addSentryToBundleShellScript(input)).toBe(expectedOutput);\n });\n });\n\n describe('removeSentryFromBundleShellScript', () => {\n it('removes sentry cli from rn bundle build phase', () => {\n const input = `export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\"\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"\n`;\n const expectedOutput = `export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$REACT_NATIVE_XCODE\\\"\"\n\n`;\n\n expect(removeSentryFromBundleShellScript(input)).toBe(expectedOutput);\n });\n });\n\n describe('findBundlePhase', () => {\n it('returns build phase with react native xcode shell script', () => {\n const inputMap = {\n 1: {\n shellScript: 'foo',\n },\n 2: {\n shellScript: 'bar',\n },\n 3: {\n shellScript: `set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$REACT_NATIVE_XCODE\\\"\"\n\n`,\n },\n 4: {\n shellScript: 'qux',\n },\n };\n\n const expected = {\n shellScript: `set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$REACT_NATIVE_XCODE\\\"\"\n\n`,\n };\n\n expect(findBundlePhase(inputMap)).toEqual(expected);\n });\n\n it('returns undefined if bundle phase not present', () => {\n const inputMap = {\n 1: {\n shellScript: 'foo',\n },\n 2: {\n shellScript: 'bar',\n },\n 3: {\n // note different path to the script\n shellScript: `set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/unknown/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$REACT_NATIVE_XCODE\\\"\"\n\n`,\n },\n 4: {\n shellScript: 'qux',\n },\n };\n\n expect(findBundlePhase(inputMap)).toBeUndefined();\n });\n });\n\n describe('doesBundlePhaseIncludeSentry', () => {\n it('returns true for script containing sentry cli calling react native xcode command', () => {\n const input = {\n shellScript: `set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_CLI=\"sentry-cli react-native xcode\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$SENTRY_CLI $REACT_NATIVE_XCODE\\\"\"\n`,\n };\n expect(doesBundlePhaseIncludeSentry(input)).toBeTruthy();\n });\n\n it('returns false', () => {\n const input = {\n // note sentry-cli can be part of the script but doesn't call react native xcode script\n shellScript: `set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$REACT_NATIVE_XCODE\\\"\"\n\nsentry-cli --version\n`,\n };\n expect(doesBundlePhaseIncludeSentry(input)).toBeFalsy();\n });\n });\n\n describe('findDebugFilesUploadPhase', () => {\n it('returns debug files build phase using debug files command', () => {\n const input = {\n 1: {\n shellScript: 'foo',\n },\n 2: {\n shellScript: `set -e\nsentry-cli debug-files upload path/to/dsym --include-sources\n`,\n },\n };\n const expected = [\n '2',\n {\n shellScript: `set -e\nsentry-cli debug-files upload path/to/dsym --include-sources\n`,\n },\n ];\n expect(findDebugFilesUploadPhase(input)).toEqual(expected);\n });\n\n it('returns debug files build phase with sentry-cli absolute path', () => {\n const input = {\n 1: {\n shellScript: 'foo',\n },\n 2: {\n shellScript: `set -e\n/path/to/bin/sentry-cli debug-files upload path/to/dsym --include-sources\n`,\n },\n };\n const expected = [\n '2',\n {\n shellScript: `set -e\n/path/to/bin/sentry-cli debug-files upload path/to/dsym --include-sources\n`,\n },\n ];\n expect(findDebugFilesUploadPhase(input)).toEqual(expected);\n });\n\n it('returns debug files build phase using dsym command', () => {\n const input = {\n 1: {\n shellScript: 'foo',\n },\n 2: {\n shellScript: `set -e\nsentry-cli upload-dsym path/to/dsym --include-sources\n`,\n },\n };\n const expected = [\n '2',\n {\n shellScript: `set -e\nsentry-cli upload-dsym path/to/dsym --include-sources\n`,\n },\n ];\n expect(findDebugFilesUploadPhase(input)).toEqual(expected);\n });\n\n it('returns undefined if build phase not present', () => {\n const input = {\n 1: {\n shellScript: 'foo',\n },\n 2: {\n // sentry-cli present but with different command\n shellScript: 'sentry-cli sourcempas upload',\n },\n };\n\n expect(findDebugFilesUploadPhase(input)).toBeUndefined();\n });\n });\n});\n"]}
@@ -65,7 +65,7 @@ export class ChooseIntegration extends BaseStep {
65
65
  break;
66
66
  case Integration.reactNative:
67
67
  default:
68
- integration = new ReactNative(sanitizeUrl(this._argv));
68
+ integration = new ReactNative(this._argv);
69
69
  break;
70
70
  }
71
71
 
@@ -252,6 +252,13 @@ export class Cordova extends BaseIntegration {
252
252
  'EXTRACTED_ARCHS=()\\n' +
253
253
  'for ARCH in $ARCHS\\n' +
254
254
  'do\\n' +
255
+ 'echo "Checking if $FRAMEWORK_EXECUTABLE_PATH needs to be stripped."\\n' +
256
+ '# Do not skip if "Architectures in the fat file".\\n' +
257
+ '# Skip if Non-fat file or if file not found. \\n' +
258
+ 'if lipo -info "$FRAMEWORK_EXECUTABLE_PATH" | grep -v " fat "; then\\n' +
259
+ ' echo "Strip not required, skipping the strip script."\\n' +
260
+ ' exit 0\\n' +
261
+ 'fi\\n' +
255
262
  'echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"\\n' +
256
263
  'lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"\\n' +
257
264
  'EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")\\n' +