@sentry/wizard 3.24.0 → 3.25.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 (58) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/nextjs/templates.js +1 -1
  4. package/dist/src/nextjs/templates.js.map +1 -1
  5. package/dist/src/react-native/expo-env-file.d.ts +2 -0
  6. package/dist/src/react-native/expo-env-file.js +127 -0
  7. package/dist/src/react-native/expo-env-file.js.map +1 -0
  8. package/dist/src/react-native/expo-metro.d.ts +7 -0
  9. package/dist/src/react-native/expo-metro.js +236 -0
  10. package/dist/src/react-native/expo-metro.js.map +1 -0
  11. package/dist/src/react-native/expo.d.ts +16 -0
  12. package/dist/src/react-native/expo.js +195 -0
  13. package/dist/src/react-native/expo.js.map +1 -0
  14. package/dist/src/react-native/git.d.ts +1 -0
  15. package/dist/src/react-native/git.js +85 -0
  16. package/dist/src/react-native/git.js.map +1 -0
  17. package/dist/src/react-native/javascript.d.ts +3 -0
  18. package/dist/src/react-native/javascript.js +119 -1
  19. package/dist/src/react-native/javascript.js.map +1 -1
  20. package/dist/src/react-native/metro.d.ts +3 -0
  21. package/dist/src/react-native/metro.js +17 -15
  22. package/dist/src/react-native/metro.js.map +1 -1
  23. package/dist/src/react-native/react-native-wizard.d.ts +12 -0
  24. package/dist/src/react-native/react-native-wizard.js +91 -78
  25. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  26. package/dist/src/react-native/xcode.js +14 -3
  27. package/dist/src/react-native/xcode.js.map +1 -1
  28. package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
  29. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  30. package/dist/src/utils/clack-utils.d.ts +2 -1
  31. package/dist/src/utils/clack-utils.js +2 -2
  32. package/dist/src/utils/clack-utils.js.map +1 -1
  33. package/dist/test/nextjs/templates.test.js +1 -1
  34. package/dist/test/nextjs/templates.test.js.map +1 -1
  35. package/dist/test/react-native/expo-metro.test.d.ts +1 -0
  36. package/dist/test/react-native/expo-metro.test.js +26 -0
  37. package/dist/test/react-native/expo-metro.test.js.map +1 -0
  38. package/dist/test/react-native/expo.test.d.ts +1 -0
  39. package/dist/test/react-native/expo.test.js +57 -0
  40. package/dist/test/react-native/expo.test.js.map +1 -0
  41. package/dist/test/react-native/xcode.test.js +5 -0
  42. package/dist/test/react-native/xcode.test.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/nextjs/templates.ts +1 -1
  45. package/src/react-native/expo-env-file.ts +55 -0
  46. package/src/react-native/expo-metro.ts +212 -0
  47. package/src/react-native/expo.ts +175 -0
  48. package/src/react-native/git.ts +25 -0
  49. package/src/react-native/javascript.ts +68 -1
  50. package/src/react-native/metro.ts +3 -3
  51. package/src/react-native/react-native-wizard.ts +72 -76
  52. package/src/react-native/xcode.ts +21 -5
  53. package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
  54. package/src/utils/clack-utils.ts +4 -4
  55. package/test/nextjs/templates.test.ts +1 -1
  56. package/test/react-native/expo-metro.test.ts +81 -0
  57. package/test/react-native/expo.test.ts +86 -0
  58. package/test/react-native/xcode.test.ts +90 -0
@@ -0,0 +1,86 @@
1
+ import { addWithSentryToAppConfigJson } from '../../src/react-native/expo';
2
+ import { RNCliSetupConfigContent } from '../../src/react-native/react-native-wizard';
3
+
4
+ describe('expo', () => {
5
+ const MOCK_CONFIG: RNCliSetupConfigContent = {
6
+ url: 'https://sentry.mock/',
7
+ org: 'sentry-mock',
8
+ project: 'project-mock',
9
+ authToken: 'authToken-mock',
10
+ };
11
+
12
+ describe('addWithSentryToAppConfigJson', () => {
13
+ test('do not add if sentry-expo present', () => {
14
+ const appConfigJson = `{
15
+ "expo": {
16
+ "plugins": ["sentry-expo"]
17
+ }
18
+ }`;
19
+ expect(
20
+ addWithSentryToAppConfigJson(appConfigJson, MOCK_CONFIG),
21
+ ).toBeNull();
22
+ });
23
+
24
+ test('do not add if sentry-react-native/expo present', () => {
25
+ const appConfigJson = `{
26
+ "expo": {
27
+ "plugins": ["@sentry/react-native/expo"]
28
+ }
29
+ }`;
30
+ expect(
31
+ addWithSentryToAppConfigJson(appConfigJson, MOCK_CONFIG),
32
+ ).toBeNull();
33
+ });
34
+
35
+ test.each([
36
+ [
37
+ `{
38
+ "expo": {
39
+ "plugins": "should be an array, but it is not"
40
+ }
41
+ }`,
42
+ ],
43
+ [
44
+ `{
45
+ "expo": ["should be an object, but it is not"]
46
+ }`,
47
+ ],
48
+ ])('do not add if plugins is not an array', (appConfigJson) => {
49
+ expect(
50
+ addWithSentryToAppConfigJson(appConfigJson, MOCK_CONFIG),
51
+ ).toBeNull();
52
+ });
53
+
54
+ test.each([
55
+ [
56
+ `{
57
+ "expo": {
58
+ "plugins": []
59
+ }
60
+ }`,
61
+ ],
62
+ [`{}`],
63
+ [
64
+ `{
65
+ "expo": {}
66
+ }`,
67
+ ],
68
+ ])('add sentry react native expo plugin configuration', (appConfigJson) => {
69
+ const result = addWithSentryToAppConfigJson(appConfigJson, MOCK_CONFIG);
70
+ expect(JSON.parse(result ?? '{}')).toStrictEqual({
71
+ expo: {
72
+ plugins: [
73
+ [
74
+ '@sentry/react-native/expo',
75
+ {
76
+ url: 'https://sentry.mock/',
77
+ organization: 'sentry-mock',
78
+ project: 'project-mock',
79
+ },
80
+ ],
81
+ ],
82
+ },
83
+ });
84
+ });
85
+ });
86
+ });
@@ -57,6 +57,96 @@ REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
57
57
  expectedOutput,
58
58
  );
59
59
  });
60
+
61
+ it('adds sentry cli to expo bundle build phase', () => {
62
+ const input = `
63
+ if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then
64
+ source "$PODS_ROOT/../.xcode.env"
65
+ fi
66
+ if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
67
+ source "$PODS_ROOT/../.xcode.env.local"
68
+ fi
69
+
70
+ # The project root by default is one level up from the ios directory
71
+ export PROJECT_ROOT="$PROJECT_DIR"/..
72
+
73
+ if [[ "$CONFIGURATION" = *Debug* ]]; then
74
+ export SKIP_BUNDLING=1
75
+ fi
76
+ if [[ -z "$ENTRY_FILE" ]]; then
77
+ # Set the entry JS file using the bundler's entry resolution.
78
+ export ENTRY_FILE="$("$NODE_BINARY" -e "require('expo/scripts/resolveAppEntry')" "$PROJECT_ROOT" ios absolute | tail -n 1)"
79
+ fi
80
+
81
+ if [[ -z "$CLI_PATH" ]]; then
82
+ # Use Expo CLI
83
+ export CLI_PATH="$("$NODE_BINARY" --print "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })")"
84
+ fi
85
+ if [[ -z "$BUNDLE_COMMAND" ]]; then
86
+ # Default Expo CLI command for bundling
87
+ export BUNDLE_COMMAND="export:embed"
88
+ fi
89
+
90
+ # Source .xcode.env.updates if it exists to allow
91
+ # SKIP_BUNDLING to be unset if needed
92
+ if [[ -f "$PODS_ROOT/../.xcode.env.updates" ]]; then
93
+ source "$PODS_ROOT/../.xcode.env.updates"
94
+ fi
95
+ # Source local changes to allow overrides
96
+ # if needed
97
+ if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
98
+ source "$PODS_ROOT/../.xcode.env.local"
99
+ fi
100
+
101
+ \`"$NODE_BINARY" --print "require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'"\`
102
+ `;
103
+
104
+ const expectedOutput = `
105
+ if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then
106
+ source "$PODS_ROOT/../.xcode.env"
107
+ fi
108
+ if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
109
+ source "$PODS_ROOT/../.xcode.env.local"
110
+ fi
111
+
112
+ # The project root by default is one level up from the ios directory
113
+ export PROJECT_ROOT="$PROJECT_DIR"/..
114
+
115
+ if [[ "$CONFIGURATION" = *Debug* ]]; then
116
+ export SKIP_BUNDLING=1
117
+ fi
118
+ if [[ -z "$ENTRY_FILE" ]]; then
119
+ # Set the entry JS file using the bundler's entry resolution.
120
+ export ENTRY_FILE="$("$NODE_BINARY" -e "require('expo/scripts/resolveAppEntry')" "$PROJECT_ROOT" ios absolute | tail -n 1)"
121
+ fi
122
+
123
+ if [[ -z "$CLI_PATH" ]]; then
124
+ # Use Expo CLI
125
+ export CLI_PATH="$("$NODE_BINARY" --print "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })")"
126
+ fi
127
+ if [[ -z "$BUNDLE_COMMAND" ]]; then
128
+ # Default Expo CLI command for bundling
129
+ export BUNDLE_COMMAND="export:embed"
130
+ fi
131
+
132
+ # Source .xcode.env.updates if it exists to allow
133
+ # SKIP_BUNDLING to be unset if needed
134
+ if [[ -f "$PODS_ROOT/../.xcode.env.updates" ]]; then
135
+ source "$PODS_ROOT/../.xcode.env.updates"
136
+ fi
137
+ # Source local changes to allow overrides
138
+ # if needed
139
+ if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
140
+ source "$PODS_ROOT/../.xcode.env.local"
141
+ fi
142
+
143
+ /bin/sh \`"$NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'"\` \`"$NODE_BINARY" --print "require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'"\`
144
+ `;
145
+
146
+ expect(addSentryWithBundledScriptsToBundleShellScript(input)).toBe(
147
+ expectedOutput,
148
+ );
149
+ });
60
150
  });
61
151
 
62
152
  describe('removeSentryFromBundleShellScript', () => {