@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
@@ -0,0 +1,33 @@
1
+ import { satisfies, subset, valid, validRange } from 'semver';
2
+
3
+ export function fulfillsVersionRange({
4
+ version,
5
+ acceptableVersions,
6
+ canBeLatest,
7
+ }: {
8
+ version: string;
9
+ acceptableVersions: string;
10
+ canBeLatest: boolean;
11
+ }): boolean {
12
+ if (version === 'latest') {
13
+ return canBeLatest;
14
+ }
15
+
16
+ let cleanedUserVersion, isRange;
17
+
18
+ if (valid(version)) {
19
+ cleanedUserVersion = valid(version);
20
+ isRange = false;
21
+ } else if (validRange(version)) {
22
+ cleanedUserVersion = validRange(version);
23
+ isRange = true;
24
+ }
25
+
26
+ return (
27
+ // If the given version is a bogus format, this will still be undefined and we'll automatically reject it
28
+ !!cleanedUserVersion &&
29
+ (isRange
30
+ ? subset(cleanedUserVersion, acceptableVersions)
31
+ : satisfies(cleanedUserVersion, acceptableVersions))
32
+ );
33
+ }
@@ -13,7 +13,9 @@ export function createSentryCLIRC(
13
13
  const rcPath = path.join(directory, '.sentryclirc');
14
14
  fs.writeFileSync(rcPath, '[auth]\ntoken=' + params.auth_token);
15
15
 
16
- if (fs.existsSync('.gitignore')) {
16
+ if (!fs.existsSync('.gitignore')) {
17
+ fs.writeFileSync('.gitignore', '.sentryclirc');
18
+ } else {
17
19
  const gitIgnore = fs.readFileSync('.gitignore').toString();
18
20
  if (!gitIgnore.includes('.sentryclirc')) {
19
21
  fs.appendFileSync('.gitignore', '\n.sentryclirc');
@@ -5,6 +5,9 @@ export interface SentryProjectData {
5
5
  platform: string;
6
6
  organization: {
7
7
  slug: string;
8
+ links: {
9
+ organizationUrl: string;
10
+ };
8
11
  };
9
12
  keys: [{ dsn: { public: string } }];
10
13
  }
@@ -0,0 +1,310 @@
1
+ import {
2
+ addRNSentryGradlePlugin,
3
+ doesAppBuildGradleIncludeRNSentryGradlePlugin,
4
+ removeRNSentryGradlePlugin,
5
+ } from '../../src/react-native/gradle';
6
+
7
+ describe('react-native gradle', () => {
8
+ describe('doesAppBuildGradleIncludeSentry', () => {
9
+ it('returns false for empty file', () => {
10
+ expect(doesAppBuildGradleIncludeRNSentryGradlePlugin('')).toBe(false);
11
+ });
12
+
13
+ it('returns false for minimal app/build.gradle', () => {
14
+ const appBuildGradle = `apply plugin: "com.android.application"
15
+
16
+ android {
17
+ ndkVersion rootProject.ext.ndkVersion
18
+
19
+ compileSdkVersion rootProject.ext.compileSdkVersion
20
+
21
+ namespace "com.samplenewarchitecture"
22
+ defaultConfig {
23
+ applicationId "com.samplenewarchitecture"
24
+ minSdkVersion rootProject.ext.minSdkVersion
25
+ targetSdkVersion rootProject.ext.targetSdkVersion
26
+ versionCode 1
27
+ versionName "1.0"
28
+ }
29
+ }
30
+ `;
31
+ expect(
32
+ doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle),
33
+ ).toBe(false);
34
+ });
35
+
36
+ it('returns false for app/build.gradle with SAGP', () => {
37
+ const appBuildGradle = `apply plugin: "com.android.application"
38
+ apply plugin: "io.sentry.android.gradle"
39
+
40
+ sentry {
41
+ }
42
+
43
+ android {
44
+ ndkVersion rootProject.ext.ndkVersion
45
+
46
+ compileSdkVersion rootProject.ext.compileSdkVersion
47
+
48
+ namespace "com.samplenewarchitecture"
49
+ defaultConfig {
50
+ applicationId "com.samplenewarchitecture"
51
+ minSdkVersion rootProject.ext.minSdkVersion
52
+ targetSdkVersion rootProject.ext.targetSdkVersion
53
+ versionCode 1
54
+ versionName "1.0"
55
+ }
56
+ }
57
+ `;
58
+ expect(
59
+ doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle),
60
+ ).toBe(false);
61
+ });
62
+
63
+ it('returns true for app/build.gradle with RN SAGP', () => {
64
+ const appBuildGradle = `apply plugin: "com.android.application"
65
+ apply plugin: "io.sentry.android.gradle"
66
+
67
+ sentry {
68
+ }
69
+
70
+ apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
71
+
72
+ android {
73
+ ndkVersion rootProject.ext.ndkVersion
74
+
75
+ compileSdkVersion rootProject.ext.compileSdkVersion
76
+
77
+ namespace "com.samplenewarchitecture"
78
+ defaultConfig {
79
+ applicationId "com.samplenewarchitecture"
80
+ minSdkVersion rootProject.ext.minSdkVersion
81
+ targetSdkVersion rootProject.ext.targetSdkVersion
82
+ versionCode 1
83
+ versionName "1.0"
84
+ }
85
+ }
86
+ `;
87
+ expect(
88
+ doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle),
89
+ ).toBe(true);
90
+ });
91
+ });
92
+
93
+ describe('addRNSentryGradlePlugin', () => {
94
+ it('does not add nothing to empty file', () => {
95
+ expect(addRNSentryGradlePlugin('')).toBe('');
96
+ });
97
+
98
+ it('does add RN SAGP', () => {
99
+ const input = `apply plugin: "com.android.application"
100
+
101
+ android {
102
+ ndkVersion rootProject.ext.ndkVersion
103
+
104
+ compileSdkVersion rootProject.ext.compileSdkVersion
105
+
106
+ namespace "com.samplenewarchitecture"
107
+ defaultConfig {
108
+ applicationId "com.samplenewarchitecture"
109
+ minSdkVersion rootProject.ext.minSdkVersion
110
+ targetSdkVersion rootProject.ext.targetSdkVersion
111
+ versionCode 1
112
+ versionName "1.0"
113
+ }
114
+ }
115
+ `;
116
+ const expectedOutput = `apply plugin: "com.android.application"
117
+
118
+ apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
119
+ android {
120
+ ndkVersion rootProject.ext.ndkVersion
121
+
122
+ compileSdkVersion rootProject.ext.compileSdkVersion
123
+
124
+ namespace "com.samplenewarchitecture"
125
+ defaultConfig {
126
+ applicationId "com.samplenewarchitecture"
127
+ minSdkVersion rootProject.ext.minSdkVersion
128
+ targetSdkVersion rootProject.ext.targetSdkVersion
129
+ versionCode 1
130
+ versionName "1.0"
131
+ }
132
+ }
133
+ `;
134
+ expect(addRNSentryGradlePlugin(input)).toBe(expectedOutput);
135
+ });
136
+
137
+ it('does add RN SAGP to build gradle with SAGP', () => {
138
+ const input = `apply plugin: "com.android.application"
139
+ apply plugin: "io.sentry.android.gradle"
140
+
141
+ sentry {
142
+ }
143
+
144
+ android {
145
+ ndkVersion rootProject.ext.ndkVersion
146
+
147
+ compileSdkVersion rootProject.ext.compileSdkVersion
148
+
149
+ namespace "com.samplenewarchitecture"
150
+ defaultConfig {
151
+ applicationId "com.samplenewarchitecture"
152
+ minSdkVersion rootProject.ext.minSdkVersion
153
+ targetSdkVersion rootProject.ext.targetSdkVersion
154
+ versionCode 1
155
+ versionName "1.0"
156
+ }
157
+ }
158
+ `;
159
+ const expectedOutput = `apply plugin: "com.android.application"
160
+ apply plugin: "io.sentry.android.gradle"
161
+
162
+ sentry {
163
+ }
164
+
165
+ apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
166
+ android {
167
+ ndkVersion rootProject.ext.ndkVersion
168
+
169
+ compileSdkVersion rootProject.ext.compileSdkVersion
170
+
171
+ namespace "com.samplenewarchitecture"
172
+ defaultConfig {
173
+ applicationId "com.samplenewarchitecture"
174
+ minSdkVersion rootProject.ext.minSdkVersion
175
+ targetSdkVersion rootProject.ext.targetSdkVersion
176
+ versionCode 1
177
+ versionName "1.0"
178
+ }
179
+ }
180
+ `;
181
+ expect(addRNSentryGradlePlugin(input)).toBe(expectedOutput);
182
+ });
183
+ });
184
+
185
+ describe('removeRNSentryGradlePlugin', () => {
186
+ it('does not add nothing to empty file', () => {
187
+ expect(removeRNSentryGradlePlugin('')).toBe('');
188
+ });
189
+
190
+ it('does not change build gradle without RN SAGP', () => {
191
+ const input = `apply plugin: "com.android.application"
192
+ apply plugin: "io.sentry.android.gradle"
193
+
194
+ sentry {
195
+ }
196
+
197
+ android {
198
+ ndkVersion rootProject.ext.ndkVersion
199
+
200
+ compileSdkVersion rootProject.ext.compileSdkVersion
201
+
202
+ namespace "com.samplenewarchitecture"
203
+ defaultConfig {
204
+ applicationId "com.samplenewarchitecture"
205
+ minSdkVersion rootProject.ext.minSdkVersion
206
+ targetSdkVersion rootProject.ext.targetSdkVersion
207
+ versionCode 1
208
+ versionName "1.0"
209
+ }
210
+ }
211
+ `;
212
+
213
+ expect(removeRNSentryGradlePlugin(input)).toBe(input);
214
+ });
215
+
216
+ it('does remove RN SAGP referenced by node resolved path', () => {
217
+ const input = `apply plugin: "com.android.application"
218
+ apply plugin: "io.sentry.android.gradle"
219
+
220
+ sentry {
221
+ }
222
+
223
+ apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
224
+ android {
225
+ ndkVersion rootProject.ext.ndkVersion
226
+
227
+ compileSdkVersion rootProject.ext.compileSdkVersion
228
+
229
+ namespace "com.samplenewarchitecture"
230
+ defaultConfig {
231
+ applicationId "com.samplenewarchitecture"
232
+ minSdkVersion rootProject.ext.minSdkVersion
233
+ targetSdkVersion rootProject.ext.targetSdkVersion
234
+ versionCode 1
235
+ versionName "1.0"
236
+ }
237
+ }
238
+ `;
239
+ const output = `apply plugin: "com.android.application"
240
+ apply plugin: "io.sentry.android.gradle"
241
+
242
+ sentry {
243
+ }
244
+ android {
245
+ ndkVersion rootProject.ext.ndkVersion
246
+
247
+ compileSdkVersion rootProject.ext.compileSdkVersion
248
+
249
+ namespace "com.samplenewarchitecture"
250
+ defaultConfig {
251
+ applicationId "com.samplenewarchitecture"
252
+ minSdkVersion rootProject.ext.minSdkVersion
253
+ targetSdkVersion rootProject.ext.targetSdkVersion
254
+ versionCode 1
255
+ versionName "1.0"
256
+ }
257
+ }
258
+ `;
259
+
260
+ expect(removeRNSentryGradlePlugin(input)).toBe(output);
261
+ });
262
+
263
+ it('does remove RN SAGP reference by relative path', () => {
264
+ const input = `apply plugin: "com.android.application"
265
+ apply plugin: "io.sentry.android.gradle"
266
+
267
+ sentry {
268
+ }
269
+
270
+ apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
271
+ android {
272
+ ndkVersion rootProject.ext.ndkVersion
273
+
274
+ compileSdkVersion rootProject.ext.compileSdkVersion
275
+
276
+ namespace "com.samplenewarchitecture"
277
+ defaultConfig {
278
+ applicationId "com.samplenewarchitecture"
279
+ minSdkVersion rootProject.ext.minSdkVersion
280
+ targetSdkVersion rootProject.ext.targetSdkVersion
281
+ versionCode 1
282
+ versionName "1.0"
283
+ }
284
+ }
285
+ `;
286
+ const output = `apply plugin: "com.android.application"
287
+ apply plugin: "io.sentry.android.gradle"
288
+
289
+ sentry {
290
+ }
291
+ android {
292
+ ndkVersion rootProject.ext.ndkVersion
293
+
294
+ compileSdkVersion rootProject.ext.compileSdkVersion
295
+
296
+ namespace "com.samplenewarchitecture"
297
+ defaultConfig {
298
+ applicationId "com.samplenewarchitecture"
299
+ minSdkVersion rootProject.ext.minSdkVersion
300
+ targetSdkVersion rootProject.ext.targetSdkVersion
301
+ versionCode 1
302
+ versionName "1.0"
303
+ }
304
+ }
305
+ `;
306
+
307
+ expect(removeRNSentryGradlePlugin(input)).toBe(output);
308
+ });
309
+ });
310
+ });
@@ -0,0 +1,131 @@
1
+ import {
2
+ addSentryInitWithSdkImport,
3
+ doesJsCodeIncludeSdkSentryImport,
4
+ } from '../../src/react-native/javascript';
5
+
6
+ describe('react-native javascript', () => {
7
+ describe('addSentryInitWithSdkImport', () => {
8
+ it('adds sdk import and sentry init under last import in the file', () => {
9
+ const input = `import * as React from 'react';
10
+
11
+ const test = 'test';
12
+
13
+ import { View } from 'react-native';
14
+
15
+ const App = () => {
16
+ return (
17
+ <View>
18
+ Test App
19
+ </View>
20
+ );
21
+ };
22
+
23
+ export default App;`;
24
+
25
+ const expectedOutput = `import * as React from 'react';
26
+
27
+ const test = 'test';
28
+
29
+ import { View } from 'react-native';
30
+ import * as Sentry from '@sentry/react-native';
31
+
32
+ Sentry.init({
33
+ dsn: 'dsn',
34
+ });
35
+
36
+ const App = () => {
37
+ return (
38
+ <View>
39
+ Test App
40
+ </View>
41
+ );
42
+ };
43
+
44
+ export default App;`;
45
+
46
+ expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(
47
+ expectedOutput,
48
+ );
49
+ });
50
+
51
+ it('does not add sdk import and sentry init in the file without imports', () => {
52
+ const input = `export const test = 'test';`;
53
+ expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);
54
+ });
55
+
56
+ it('does not add sdk import and sentry init in the empty file', () => {
57
+ const input = '';
58
+ expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);
59
+ });
60
+ });
61
+
62
+ describe('doesJsCodeIncludeSdkSentryImport', () => {
63
+ it('returns true if code has sdk import', () => {
64
+ const input = `import * as React from 'react';
65
+
66
+ const test = 'test';
67
+
68
+ import { View } from 'react-native';
69
+ import * as Sentry from '@sentry/react-native';
70
+
71
+ const App = () => {
72
+ return (
73
+ <View>
74
+ Test App
75
+ </View>
76
+ );
77
+ };
78
+
79
+ export default App;`;
80
+
81
+ expect(
82
+ doesJsCodeIncludeSdkSentryImport(input, {
83
+ sdkPackageName: '@sentry/react-native',
84
+ }),
85
+ ).toBe(true);
86
+ });
87
+
88
+ it('returns true if code has sdk require', () => {
89
+ const input = `import * as React from 'react';
90
+
91
+ const test = 'test';
92
+
93
+ import { View } from 'react-native';
94
+ const Sentry = require('@sentry/react-native');
95
+
96
+ const App = () => {
97
+ return (
98
+ <View>
99
+ Test App
100
+ </View>
101
+ );
102
+ };
103
+
104
+ export default App;`;
105
+
106
+ expect(
107
+ doesJsCodeIncludeSdkSentryImport(input, {
108
+ sdkPackageName: '@sentry/react-native',
109
+ }),
110
+ ).toBe(true);
111
+ });
112
+
113
+ it('returns false if code does not have sdk import', () => {
114
+ const input = `export const test = 'test';`;
115
+ expect(
116
+ doesJsCodeIncludeSdkSentryImport(input, {
117
+ sdkPackageName: '@sentry/react-native',
118
+ }),
119
+ ).toBe(false);
120
+ });
121
+
122
+ it('returns false for empty file', () => {
123
+ const input = '';
124
+ expect(
125
+ doesJsCodeIncludeSdkSentryImport(input, {
126
+ sdkPackageName: '@sentry/react-native',
127
+ }),
128
+ ).toBe(false);
129
+ });
130
+ });
131
+ });