@sentry/wizard 3.42.0 → 4.0.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 (339) hide show
  1. package/.node-cache/node-v22.14.0-darwin-arm64 +0 -0
  2. package/.node-cache/node-v22.14.0-darwin-x64 +0 -0
  3. package/.node-cache/node-v22.14.0-linux-arm64 +0 -0
  4. package/.node-cache/node-v22.14.0-linux-x64 +0 -0
  5. package/.node-cache/node-v22.14.0-win-x64.exe +0 -0
  6. package/CHANGELOG.md +30 -0
  7. package/COPYING +3575 -0
  8. package/bin.ts +85 -80
  9. package/dist/bin.js +44 -35
  10. package/dist/bin.js.map +1 -1
  11. package/dist/e2e-tests/jest.config.js +1 -1
  12. package/dist/e2e-tests/jest.config.js.map +1 -1
  13. package/dist/e2e-tests/tests/flutter.test.js +62 -147
  14. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  15. package/dist/e2e-tests/tests/nextjs.test.js +77 -175
  16. package/dist/e2e-tests/tests/nextjs.test.js.map +1 -1
  17. package/dist/e2e-tests/tests/nuxt-3.test.js +61 -162
  18. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  19. package/dist/e2e-tests/tests/nuxt-4.test.js +62 -163
  20. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  21. package/dist/e2e-tests/tests/remix.test.js +147 -189
  22. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  23. package/dist/e2e-tests/tests/sveltekit.test.js +133 -187
  24. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  25. package/dist/e2e-tests/utils/index.d.ts +1 -1
  26. package/dist/e2e-tests/utils/index.js +113 -195
  27. package/dist/e2e-tests/utils/index.js.map +1 -1
  28. package/dist/lib/Constants.js +5 -5
  29. package/dist/lib/Constants.js.map +1 -1
  30. package/dist/lib/Helper/BottomBar.d.ts +1 -1
  31. package/dist/lib/Helper/BottomBar.js +14 -15
  32. package/dist/lib/Helper/BottomBar.js.map +1 -1
  33. package/dist/lib/Helper/Env.js +5 -2
  34. package/dist/lib/Helper/Env.js.map +1 -1
  35. package/dist/lib/Helper/File.js +14 -27
  36. package/dist/lib/Helper/File.js.map +1 -1
  37. package/dist/lib/Helper/Git.js +24 -59
  38. package/dist/lib/Helper/Git.js.map +1 -1
  39. package/dist/lib/Helper/Logging.js +2 -2
  40. package/dist/lib/Helper/Logging.js.map +1 -1
  41. package/dist/lib/Helper/MergeConfig.js +4 -4
  42. package/dist/lib/Helper/MergeConfig.js.map +1 -1
  43. package/dist/lib/Helper/Package.d.ts +4 -1
  44. package/dist/lib/Helper/Package.js +12 -38
  45. package/dist/lib/Helper/Package.js.map +1 -1
  46. package/dist/lib/Helper/SentryCli.js +77 -149
  47. package/dist/lib/Helper/SentryCli.js.map +1 -1
  48. package/dist/lib/Helper/Wizard.js +29 -124
  49. package/dist/lib/Helper/Wizard.js.map +1 -1
  50. package/dist/lib/Helper/__tests__/File.js +4 -4
  51. package/dist/lib/Helper/__tests__/File.js.map +1 -1
  52. package/dist/lib/Helper/__tests__/MergeConfig.js +24 -24
  53. package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
  54. package/dist/lib/Helper/__tests__/SentryCli.js +33 -23
  55. package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
  56. package/dist/lib/Setup.js +23 -85
  57. package/dist/lib/Setup.js.map +1 -1
  58. package/dist/lib/Steps/BaseStep.js +8 -8
  59. package/dist/lib/Steps/BaseStep.js.map +1 -1
  60. package/dist/lib/Steps/ChooseIntegration.js +80 -125
  61. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  62. package/dist/lib/Steps/ConfigureProject.js +6 -66
  63. package/dist/lib/Steps/ConfigureProject.js.map +1 -1
  64. package/dist/lib/Steps/Initial.js +16 -104
  65. package/dist/lib/Steps/Initial.js.map +1 -1
  66. package/dist/lib/Steps/Integrations/BaseIntegration.js +24 -118
  67. package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
  68. package/dist/lib/Steps/Integrations/Cordova.js +95 -183
  69. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  70. package/dist/lib/Steps/Integrations/Electron.js +87 -145
  71. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  72. package/dist/lib/Steps/Integrations/MobileProject.js +40 -148
  73. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  74. package/dist/lib/Steps/OpenSentry.js +63 -126
  75. package/dist/lib/Steps/OpenSentry.js.map +1 -1
  76. package/dist/lib/Steps/PromptForParameters.js +110 -206
  77. package/dist/lib/Steps/PromptForParameters.js.map +1 -1
  78. package/dist/lib/Steps/Result.js +19 -79
  79. package/dist/lib/Steps/Result.js.map +1 -1
  80. package/dist/lib/Steps/SentryProjectSelector.js +57 -148
  81. package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
  82. package/dist/lib/Steps/ShouldConfigure.js +6 -66
  83. package/dist/lib/Steps/ShouldConfigure.js.map +1 -1
  84. package/dist/lib/Steps/WaitForSentry.js +43 -120
  85. package/dist/lib/Steps/WaitForSentry.js.map +1 -1
  86. package/dist/lib/Steps/Welcome.js +17 -76
  87. package/dist/lib/Steps/Welcome.js.map +1 -1
  88. package/dist/lib/__tests__/Env.js +3 -3
  89. package/dist/lib/__tests__/Env.js.map +1 -1
  90. package/dist/src/android/android-wizard.js +100 -176
  91. package/dist/src/android/android-wizard.js.map +1 -1
  92. package/dist/src/android/code-tools.js +24 -33
  93. package/dist/src/android/code-tools.js.map +1 -1
  94. package/dist/src/android/gradle.js +106 -165
  95. package/dist/src/android/gradle.js.map +1 -1
  96. package/dist/src/android/manifest.js +26 -27
  97. package/dist/src/android/manifest.js.map +1 -1
  98. package/dist/src/android/templates.js +76 -23
  99. package/dist/src/android/templates.js.map +1 -1
  100. package/dist/src/apple/apple-wizard.js +129 -225
  101. package/dist/src/apple/apple-wizard.js.map +1 -1
  102. package/dist/src/apple/cocoapod.js +47 -109
  103. package/dist/src/apple/cocoapod.js.map +1 -1
  104. package/dist/src/apple/code-tools.js +32 -35
  105. package/dist/src/apple/code-tools.js.map +1 -1
  106. package/dist/src/apple/fastlane.js +51 -97
  107. package/dist/src/apple/fastlane.js.map +1 -1
  108. package/dist/src/apple/templates.js +41 -5
  109. package/dist/src/apple/templates.js.map +1 -1
  110. package/dist/src/apple/xcode-manager.d.ts +2 -2
  111. package/dist/src/apple/xcode-manager.js +93 -108
  112. package/dist/src/apple/xcode-manager.js.map +1 -1
  113. package/dist/src/flutter/code-tools.js +79 -127
  114. package/dist/src/flutter/code-tools.js.map +1 -1
  115. package/dist/src/flutter/flutter-wizard.js +75 -136
  116. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  117. package/dist/src/flutter/templates.js +48 -12
  118. package/dist/src/flutter/templates.js.map +1 -1
  119. package/dist/src/nextjs/nextjs-wizard.js +527 -805
  120. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  121. package/dist/src/nextjs/templates.js +380 -40
  122. package/dist/src/nextjs/templates.js.map +1 -1
  123. package/dist/src/nextjs/utils.js +5 -5
  124. package/dist/src/nextjs/utils.js.map +1 -1
  125. package/dist/src/nuxt/nuxt-wizard.js +91 -188
  126. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  127. package/dist/src/nuxt/sdk-example.js +68 -137
  128. package/dist/src/nuxt/sdk-example.js.map +1 -1
  129. package/dist/src/nuxt/sdk-setup.d.ts +4 -4
  130. package/dist/src/nuxt/sdk-setup.js +180 -336
  131. package/dist/src/nuxt/sdk-setup.js.map +1 -1
  132. package/dist/src/nuxt/templates.js +195 -18
  133. package/dist/src/nuxt/templates.js.map +1 -1
  134. package/dist/src/nuxt/utils.js +29 -76
  135. package/dist/src/nuxt/utils.js.map +1 -1
  136. package/dist/src/react-native/expo-env-file.js +41 -94
  137. package/dist/src/react-native/expo-env-file.js.map +1 -1
  138. package/dist/src/react-native/expo-metro.d.ts +1 -1
  139. package/dist/src/react-native/expo-metro.js +75 -130
  140. package/dist/src/react-native/expo-metro.js.map +1 -1
  141. package/dist/src/react-native/expo.js +61 -114
  142. package/dist/src/react-native/expo.js.map +1 -1
  143. package/dist/src/react-native/git.js +23 -56
  144. package/dist/src/react-native/git.js.map +1 -1
  145. package/dist/src/react-native/glob.js +3 -3
  146. package/dist/src/react-native/glob.js.map +1 -1
  147. package/dist/src/react-native/gradle.js +4 -4
  148. package/dist/src/react-native/gradle.js.map +1 -1
  149. package/dist/src/react-native/javascript.js +51 -95
  150. package/dist/src/react-native/javascript.js.map +1 -1
  151. package/dist/src/react-native/metro.js +176 -296
  152. package/dist/src/react-native/metro.js.map +1 -1
  153. package/dist/src/react-native/react-native-wizard.js +267 -418
  154. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  155. package/dist/src/react-native/uninstall.js +37 -80
  156. package/dist/src/react-native/uninstall.js.map +1 -1
  157. package/dist/src/react-native/xcode.js +57 -55
  158. package/dist/src/react-native/xcode.js.map +1 -1
  159. package/dist/src/remix/codemods/express-server.js +27 -82
  160. package/dist/src/remix/codemods/express-server.js.map +1 -1
  161. package/dist/src/remix/codemods/handle-error.js +28 -31
  162. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  163. package/dist/src/remix/codemods/root-common.js +11 -11
  164. package/dist/src/remix/codemods/root-common.js.map +1 -1
  165. package/dist/src/remix/codemods/root-v1.js +17 -67
  166. package/dist/src/remix/codemods/root-v1.js.map +1 -1
  167. package/dist/src/remix/codemods/root-v2.js +89 -140
  168. package/dist/src/remix/codemods/root-v2.js.map +1 -1
  169. package/dist/src/remix/remix-wizard.js +181 -343
  170. package/dist/src/remix/remix-wizard.js.map +1 -1
  171. package/dist/src/remix/sdk-example.js +84 -66
  172. package/dist/src/remix/sdk-example.js.map +1 -1
  173. package/dist/src/remix/sdk-setup.js +161 -293
  174. package/dist/src/remix/sdk-setup.js.map +1 -1
  175. package/dist/src/remix/templates.js +10 -2
  176. package/dist/src/remix/templates.js.map +1 -1
  177. package/dist/src/remix/utils.js +13 -14
  178. package/dist/src/remix/utils.js.map +1 -1
  179. package/dist/src/run.js +106 -178
  180. package/dist/src/run.js.map +1 -1
  181. package/dist/src/sourcemaps/sourcemaps-wizard.js +248 -372
  182. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  183. package/dist/src/sourcemaps/tools/angular.js +32 -66
  184. package/dist/src/sourcemaps/tools/angular.js.map +1 -1
  185. package/dist/src/sourcemaps/tools/create-react-app.js +14 -59
  186. package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
  187. package/dist/src/sourcemaps/tools/esbuild.js +34 -77
  188. package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
  189. package/dist/src/sourcemaps/tools/nextjs.d.ts +2 -2
  190. package/dist/src/sourcemaps/tools/nextjs.js +75 -102
  191. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  192. package/dist/src/sourcemaps/tools/remix.js +53 -93
  193. package/dist/src/sourcemaps/tools/remix.js.map +1 -1
  194. package/dist/src/sourcemaps/tools/rollup.js +35 -76
  195. package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
  196. package/dist/src/sourcemaps/tools/sentry-cli.js +157 -289
  197. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  198. package/dist/src/sourcemaps/tools/tsc.js +68 -134
  199. package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
  200. package/dist/src/sourcemaps/tools/vite.js +111 -196
  201. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  202. package/dist/src/sourcemaps/tools/webpack.d.ts +1 -1
  203. package/dist/src/sourcemaps/tools/webpack.js +158 -260
  204. package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
  205. package/dist/src/sourcemaps/utils/detect-tool.js +9 -54
  206. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  207. package/dist/src/sourcemaps/utils/other-wizards.js +77 -144
  208. package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
  209. package/dist/src/sourcemaps/utils/sdk-version.js +112 -191
  210. package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
  211. package/dist/src/sveltekit/sdk-example.js +20 -70
  212. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  213. package/dist/src/sveltekit/sdk-setup.js +250 -411
  214. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  215. package/dist/src/sveltekit/sveltekit-wizard.js +107 -191
  216. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  217. package/dist/src/sveltekit/templates.js +147 -13
  218. package/dist/src/sveltekit/templates.js.map +1 -1
  219. package/dist/src/sveltekit/utils.js +3 -3
  220. package/dist/src/sveltekit/utils.js.map +1 -1
  221. package/dist/src/telemetry.d.ts +2 -2
  222. package/dist/src/telemetry.js +58 -108
  223. package/dist/src/telemetry.js.map +1 -1
  224. package/dist/src/utils/ast-utils.js +39 -54
  225. package/dist/src/utils/ast-utils.js.map +1 -1
  226. package/dist/src/utils/bash.js +28 -75
  227. package/dist/src/utils/bash.js.map +1 -1
  228. package/dist/src/utils/clack-utils.d.ts +3 -7
  229. package/dist/src/utils/clack-utils.js +688 -1083
  230. package/dist/src/utils/clack-utils.js.map +1 -1
  231. package/dist/src/utils/debug.js +6 -10
  232. package/dist/src/utils/debug.js.map +1 -1
  233. package/dist/src/utils/package-json.js +5 -6
  234. package/dist/src/utils/package-json.js.map +1 -1
  235. package/dist/src/utils/package-manager.js +65 -139
  236. package/dist/src/utils/package-manager.js.map +1 -1
  237. package/dist/src/utils/release-registry.js +12 -59
  238. package/dist/src/utils/release-registry.js.map +1 -1
  239. package/dist/src/utils/semver.js +3 -4
  240. package/dist/src/utils/semver.js.map +1 -1
  241. package/dist/src/utils/sentrycli-utils.js +4 -4
  242. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  243. package/dist/src/utils/url.js +5 -6
  244. package/dist/src/utils/url.js.map +1 -1
  245. package/dist/test/android/code-tools.test.js +18 -18
  246. package/dist/test/android/code-tools.test.js.map +1 -1
  247. package/dist/test/apple/cocoapod.test.js +154 -299
  248. package/dist/test/apple/cocoapod.test.js.map +1 -1
  249. package/dist/test/apple/code-tools.test.js +375 -263
  250. package/dist/test/apple/code-tools.test.js.map +1 -1
  251. package/dist/test/apple/fastfile.test.js +319 -271
  252. package/dist/test/apple/fastfile.test.js.map +1 -1
  253. package/dist/test/apple/templates.test.js +114 -30
  254. package/dist/test/apple/templates.test.js.map +1 -1
  255. package/dist/test/apple/xcode-manager.test.js +230 -234
  256. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  257. package/dist/test/flutter/code-tools.test.js +119 -48
  258. package/dist/test/flutter/code-tools.test.js.map +1 -1
  259. package/dist/test/flutter/templates.test.js +63 -20
  260. package/dist/test/flutter/templates.test.js.map +1 -1
  261. package/dist/test/nextjs/templates.test.js +332 -43
  262. package/dist/test/nextjs/templates.test.js.map +1 -1
  263. package/dist/test/nuxt/templates.test.js +161 -33
  264. package/dist/test/nuxt/templates.test.js.map +1 -1
  265. package/dist/test/react-native/expo-metro.test.js +61 -15
  266. package/dist/test/react-native/expo-metro.test.js.map +1 -1
  267. package/dist/test/react-native/expo.test.js +37 -17
  268. package/dist/test/react-native/expo.test.js.map +1 -1
  269. package/dist/test/react-native/gradle.test.js +260 -28
  270. package/dist/test/react-native/gradle.test.js.map +1 -1
  271. package/dist/test/react-native/javascript.test.js +85 -19
  272. package/dist/test/react-native/javascript.test.js.map +1 -1
  273. package/dist/test/react-native/metro.test.js +261 -187
  274. package/dist/test/react-native/metro.test.js.map +1 -1
  275. package/dist/test/react-native/xcode.test.js +243 -62
  276. package/dist/test/react-native/xcode.test.js.map +1 -1
  277. package/dist/test/remix/client-entry.test.js +81 -21
  278. package/dist/test/remix/client-entry.test.js.map +1 -1
  279. package/dist/test/remix/server-instrumentation.test.js +21 -8
  280. package/dist/test/remix/server-instrumentation.test.js.map +1 -1
  281. package/dist/test/sourcemaps/tools/sentry-cli.test.js +20 -72
  282. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  283. package/dist/test/sourcemaps/tools/tsc.test.js +142 -68
  284. package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
  285. package/dist/test/sourcemaps/tools/vite.test.js +106 -75
  286. package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
  287. package/dist/test/sourcemaps/tools/webpack.test.js +226 -102
  288. package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
  289. package/dist/test/sveltekit/templates.test.js +117 -18
  290. package/dist/test/sveltekit/templates.test.js.map +1 -1
  291. package/dist/test/utils/ast-utils.test.js +99 -58
  292. package/dist/test/utils/ast-utils.test.js.map +1 -1
  293. package/dist/test/utils/clack-utils.test.js +142 -247
  294. package/dist/test/utils/clack-utils.test.js.map +1 -1
  295. package/e2e-tests/package.json +1 -1
  296. package/e2e-tests/tests/flutter.test.ts +20 -20
  297. package/e2e-tests/tests/nextjs.test.ts +2 -2
  298. package/e2e-tests/tests/nuxt-3.test.ts +4 -4
  299. package/e2e-tests/tests/nuxt-4.test.ts +3 -3
  300. package/e2e-tests/tests/remix.test.ts +3 -3
  301. package/e2e-tests/tests/sveltekit.test.ts +3 -3
  302. package/e2e-tests/utils/index.ts +33 -15
  303. package/lib/Helper/BottomBar.ts +1 -1
  304. package/lib/Helper/Env.ts +1 -1
  305. package/lib/Helper/Package.ts +12 -10
  306. package/lib/Helper/SentryCli.ts +18 -27
  307. package/lib/Helper/Wizard.ts +1 -2
  308. package/lib/Setup.ts +4 -5
  309. package/lib/Steps/ChooseIntegration.ts +40 -8
  310. package/lib/Steps/Initial.ts +17 -26
  311. package/lib/Steps/Integrations/BaseIntegration.ts +2 -8
  312. package/lib/Steps/Integrations/Cordova.ts +9 -15
  313. package/lib/Steps/Integrations/Electron.ts +23 -20
  314. package/lib/Steps/Integrations/MobileProject.ts +18 -15
  315. package/lib/Steps/OpenSentry.ts +12 -7
  316. package/lib/Steps/PromptForParameters.ts +12 -19
  317. package/lib/Steps/SentryProjectSelector.ts +30 -29
  318. package/lib/Steps/WaitForSentry.ts +29 -23
  319. package/package.json +12 -8
  320. package/src/apple/xcode-manager.ts +10 -10
  321. package/src/nextjs/templates.ts +2 -6
  322. package/src/nuxt/sdk-setup.ts +21 -18
  323. package/src/react-native/expo-metro.ts +2 -2
  324. package/src/react-native/react-native-wizard.ts +1 -2
  325. package/src/react-native/uninstall.ts +1 -2
  326. package/src/react-native/xcode.ts +1 -1
  327. package/src/run.ts +12 -5
  328. package/src/sourcemaps/tools/nextjs.ts +2 -5
  329. package/src/sourcemaps/tools/webpack.ts +3 -3
  330. package/src/telemetry.ts +27 -7
  331. package/src/utils/clack-utils.ts +50 -47
  332. package/test/apple/cocoapod.test.ts +4 -0
  333. package/test/apple/fastfile.test.ts +12 -7
  334. package/test/apple/xcode-manager.test.ts +13 -11
  335. package/test/nextjs/templates.test.ts +0 -12
  336. package/test/utils/clack-utils.test.ts +40 -50
  337. package/types/read-env.d.ts +3 -0
  338. package/types/xcode.d.ts +1 -0
  339. package/dist/package.json +0 -128
@@ -22,137 +22,73 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
27
  };
64
28
  Object.defineProperty(exports, "__esModule", { value: true });
65
29
  exports.getSentryAppConfigJsonCodeSnippet = exports.addWithSentryToAppConfigJson = exports.patchExpoAppConfig = exports.printSentryExpoMigrationOutro = exports.SENTRY_PLUGIN_FUNCTION_NAME = exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = exports.SENTRY_EXPO_PLUGIN_NAME = void 0;
66
30
  // @ts-ignore - clack is ESM and TS complains about that. It works though
67
- var clack = __importStar(require("@clack/prompts"));
68
- var chalk_1 = __importDefault(require("chalk"));
69
- var fs = __importStar(require("fs"));
70
- var os_1 = require("os");
71
- var utils_1 = require("@sentry/utils");
72
- var Sentry = __importStar(require("@sentry/node"));
73
- var clack_utils_1 = require("../utils/clack-utils");
74
- var telemetry_1 = require("../telemetry");
31
+ const clack = __importStar(require("@clack/prompts"));
32
+ const chalk_1 = __importDefault(require("chalk"));
33
+ const fs = __importStar(require("fs"));
34
+ const os_1 = require("os");
35
+ const utils_1 = require("@sentry/utils");
36
+ const Sentry = __importStar(require("@sentry/node"));
37
+ const clack_utils_1 = require("../utils/clack-utils");
38
+ const telemetry_1 = require("../telemetry");
75
39
  exports.SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';
76
40
  exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';
77
41
  exports.SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';
78
- var APP_CONFIG_JSON = "app.json";
42
+ const APP_CONFIG_JSON = `app.json`;
79
43
  function printSentryExpoMigrationOutro() {
80
- clack.outro("Deprecated ".concat(chalk_1.default.cyan('sentry-expo'), " package installed in your dependencies. Please follow the migration guide at ").concat(chalk_1.default.cyan('https://docs.sentry.io/platforms/react-native/migration/sentry-expo/')));
44
+ clack.outro(`Deprecated ${chalk_1.default.cyan('sentry-expo')} package installed in your dependencies. Please follow the migration guide at ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-native/migration/sentry-expo/')}`);
81
45
  }
82
46
  exports.printSentryExpoMigrationOutro = printSentryExpoMigrationOutro;
83
47
  /**
84
48
  * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.
85
49
  */
86
- function patchExpoAppConfig(options) {
87
- return __awaiter(this, void 0, void 0, function () {
88
- function showInstructions() {
89
- return (0, clack_utils_1.showCopyPasteInstructions)(APP_CONFIG_JSON, getSentryAppConfigJsonCodeSnippet(options), 'This ensures auto upload of source maps during native app build.');
90
- }
91
- var appConfigJsonExists, patched;
92
- return __generator(this, function (_a) {
93
- switch (_a.label) {
94
- case 0:
95
- appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);
96
- Sentry.setTag('app-config-file-status', appConfigJsonExists ? 'found' : 'not-found');
97
- if (!!appConfigJsonExists) return [3 /*break*/, 2];
98
- return [4 /*yield*/, showInstructions()];
99
- case 1: return [2 /*return*/, _a.sent()];
100
- case 2: return [4 /*yield*/, patchAppConfigJson(APP_CONFIG_JSON, options)];
101
- case 3:
102
- patched = _a.sent();
103
- if (!!patched) return [3 /*break*/, 5];
104
- return [4 /*yield*/, showInstructions()];
105
- case 4: return [2 /*return*/, _a.sent()];
106
- case 5: return [2 /*return*/];
107
- }
108
- });
109
- });
50
+ async function patchExpoAppConfig(options) {
51
+ function showInstructions() {
52
+ return (0, clack_utils_1.showCopyPasteInstructions)(APP_CONFIG_JSON, getSentryAppConfigJsonCodeSnippet(options), 'This ensures auto upload of source maps during native app build.');
53
+ }
54
+ const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);
55
+ Sentry.setTag('app-config-file-status', appConfigJsonExists ? 'found' : 'not-found');
56
+ if (!appConfigJsonExists) {
57
+ return await showInstructions();
58
+ }
59
+ const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);
60
+ if (!patched) {
61
+ return await showInstructions();
62
+ }
110
63
  }
111
64
  exports.patchExpoAppConfig = patchExpoAppConfig;
112
- function patchAppConfigJson(path, options) {
113
- return __awaiter(this, void 0, void 0, function () {
114
- var appConfigContent, patchedContent, error_1;
115
- return __generator(this, function (_a) {
116
- switch (_a.label) {
117
- case 0: return [4 /*yield*/, fs.promises.readFile(path, { encoding: 'utf-8' })];
118
- case 1:
119
- appConfigContent = (_a.sent()).toString();
120
- patchedContent = (0, telemetry_1.traceStep)('app-config-json-patch', function () {
121
- return addWithSentryToAppConfigJson(appConfigContent, options);
122
- });
123
- if (patchedContent === null) {
124
- return [2 /*return*/, false];
125
- }
126
- _a.label = 2;
127
- case 2:
128
- _a.trys.push([2, 4, , 5]);
129
- return [4 /*yield*/, fs.promises.writeFile(path, patchedContent)];
130
- case 3:
131
- _a.sent();
132
- return [3 /*break*/, 5];
133
- case 4:
134
- error_1 = _a.sent();
135
- Sentry.setTag('app-config-file-status', 'json-write-error');
136
- clack.log.error("Unable to write ".concat(chalk_1.default.cyan('app.config.json'), "."));
137
- return [2 /*return*/, false];
138
- case 5:
139
- Sentry.setTag('app-config-file-status', 'json-write-success');
140
- clack.log.success("Added Sentry Expo plugin to ".concat(chalk_1.default.cyan('app.config.json'), "."));
141
- return [2 /*return*/, true];
142
- }
143
- });
144
- });
65
+ async function patchAppConfigJson(path, options) {
66
+ const appConfigContent = (await fs.promises.readFile(path, { encoding: 'utf-8' })).toString();
67
+ const patchedContent = (0, telemetry_1.traceStep)('app-config-json-patch', () => addWithSentryToAppConfigJson(appConfigContent, options));
68
+ if (patchedContent === null) {
69
+ return false;
70
+ }
71
+ try {
72
+ await fs.promises.writeFile(path, patchedContent);
73
+ }
74
+ catch (error) {
75
+ Sentry.setTag('app-config-file-status', 'json-write-error');
76
+ clack.log.error(`Unable to write ${chalk_1.default.cyan('app.config.json')}.`);
77
+ return false;
78
+ }
79
+ Sentry.setTag('app-config-file-status', 'json-write-success');
80
+ clack.log.success(`Added Sentry Expo plugin to ${chalk_1.default.cyan('app.config.json')}.`);
81
+ return true;
145
82
  }
146
83
  function addWithSentryToAppConfigJson(appConfigContent, options) {
147
- var _a, _b;
148
84
  try {
149
85
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
150
- var parsedAppConfig = JSON.parse(appConfigContent);
151
- var includesWithSentry = appConfigContent.includes(exports.SENTRY_EXPO_PLUGIN_NAME) ||
86
+ const parsedAppConfig = JSON.parse(appConfigContent);
87
+ const includesWithSentry = appConfigContent.includes(exports.SENTRY_EXPO_PLUGIN_NAME) ||
152
88
  appConfigContent.includes(exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);
153
89
  if (includesWithSentry) {
154
90
  Sentry.setTag('app-config-file-status', 'already-patched');
155
- clack.log.warn("Your ".concat(chalk_1.default.cyan('app.config.json'), " already includes the Sentry Expo plugin."));
91
+ clack.log.warn(`Your ${chalk_1.default.cyan('app.config.json')} already includes the Sentry Expo plugin.`);
156
92
  return null;
157
93
  }
158
94
  if (parsedAppConfig.expo !== undefined &&
@@ -166,8 +102,8 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
166
102
  Sentry.setTag('app-config-file-status', 'invalid-json');
167
103
  return null;
168
104
  }
169
- parsedAppConfig.expo = (_a = parsedAppConfig.expo) !== null && _a !== void 0 ? _a : {};
170
- parsedAppConfig.expo.plugins = (_b = parsedAppConfig.expo.plugins) !== null && _b !== void 0 ? _b : [];
105
+ parsedAppConfig.expo = parsedAppConfig.expo ?? {};
106
+ parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];
171
107
  parsedAppConfig.expo.plugins.push([
172
108
  exports.SENTRY_EXPO_PLUGIN_NAME,
173
109
  {
@@ -180,15 +116,26 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
180
116
  }
181
117
  catch (error) {
182
118
  Sentry.setTag('app-config-file-status', 'invalid-json');
183
- clack.log.error("Unable to parse your ".concat(chalk_1.default.cyan('app.config.json'), ". Make sure it has a valid format!"));
119
+ clack.log.error(`Unable to parse your ${chalk_1.default.cyan('app.config.json')}. Make sure it has a valid format!`);
184
120
  return null;
185
121
  }
186
122
  }
187
123
  exports.addWithSentryToAppConfigJson = addWithSentryToAppConfigJson;
188
- function getSentryAppConfigJsonCodeSnippet(_a) {
189
- var url = _a.url, project = _a.project, org = _a.org;
190
- return (0, clack_utils_1.makeCodeSnippet)(true, function (unchanged, plus, _minus) {
191
- return unchanged("{\n \"name\": \"my app\",\n \"plugins\": [\n ".concat(plus("[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"".concat(url, "\",\n \"project\": \"").concat(project, "\",\n \"organization\": \"").concat(org, "\"\n }\n ]")), "\n ],\n}"));
124
+ function getSentryAppConfigJsonCodeSnippet({ url, project, org, }) {
125
+ return (0, clack_utils_1.makeCodeSnippet)(true, (unchanged, plus, _minus) => {
126
+ return unchanged(`{
127
+ "name": "my app",
128
+ "plugins": [
129
+ ${plus(`[
130
+ "@sentry/react-native/expo",
131
+ {
132
+ "url": "${url}",
133
+ "project": "${project}",
134
+ "organization": "${org}"
135
+ }
136
+ ]`)}
137
+ ],
138
+ }`);
192
139
  });
193
140
  }
194
141
  exports.getSentryAppConfigJsonCodeSnippet = getSentryAppConfigJsonCodeSnippet;
@@ -1 +1 @@
1
- {"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAC1B,qCAAyB;AACzB,yBAAyB;AAEzB,uCAA8C;AAC9C,mDAAuC;AACvC,oDAG8B;AAE9B,0CAAyC;AAE5B,QAAA,uBAAuB,GAAG,2BAA2B,CAAC;AACtD,QAAA,kCAAkC,GAAG,aAAa,CAAC;AAEnD,QAAA,2BAA2B,GAAG,YAAY,CAAC;AAExD,IAAM,eAAe,GAAG,UAAU,CAAC;AAQnC,SAAgB,6BAA6B;IAC3C,KAAK,CAAC,KAAK,CACT,qBAAc,eAAK,CAAC,IAAI,CACtB,aAAa,CACd,2FAAiF,eAAK,CAAC,IAAI,CAC1F,sEAAsE,CACvE,CAAE,CACJ,CAAC;AACJ,CAAC;AARD,sEAQC;AAED;;GAEG;AACH,SAAsB,kBAAkB,CAAC,OAAgC;;QACvE,SAAS,gBAAgB;YACvB,OAAO,IAAA,uCAAyB,EAC9B,eAAe,EACf,iCAAiC,CAAC,OAAO,CAAC,EAC1C,kEAAkE,CACnE,CAAC;QACJ,CAAC;;;;;oBAEK,mBAAmB,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;oBAE3D,MAAM,CAAC,MAAM,CACX,wBAAwB,EACxB,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CA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;gBACE,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,YAAY,EAAE,OAAO,CAAC,GAAG;aAC1B;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,QAAG,CAAC;KACvD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,MAAM,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;QACxD,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,+BAAwB,eAAK,CAAC,IAAI,CAChC,iBAAiB,CAClB,uCAAoC,CACtC,CAAC;QACF,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AA1DD,oEA0DC;AAED,SAAgB,iCAAiC,CAAC,EAIL;QAH3C,GAAG,SAAA,EACH,OAAO,aAAA,EACP,GAAG,SAAA;IAEH,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,UAAC,SAAS,EAAE,IAAI,EAAE,MAAM;QACnD,OAAO,SAAS,CAAC,4DAGf,IAAI,CAAC,+EAGO,GAAG,yCACC,OAAO,8CACF,GAAG,uBAExB,CAAC,cAEL,CAAC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,8EAoBC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport { EOL } from 'os';\n\nimport { isPlainObject } from '@sentry/utils';\nimport * as Sentry from '@sentry/node';\nimport {\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { traceStep } from '../telemetry';\n\nexport const SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';\nexport const DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';\n\nexport const SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';\n\nconst APP_CONFIG_JSON = `app.json`;\n\nexport interface AppConfigJson {\n expo?: {\n plugins?: Array<[string, undefined | Record<string, unknown>]>;\n };\n}\n\nexport function printSentryExpoMigrationOutro(): void {\n clack.outro(\n `Deprecated ${chalk.cyan(\n 'sentry-expo',\n )} package installed in your dependencies. Please follow the migration guide at ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/migration/sentry-expo/',\n )}`,\n );\n}\n\n/**\n * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.\n */\nexport async function patchExpoAppConfig(options: RNCliSetupConfigContent) {\n function showInstructions() {\n return showCopyPasteInstructions(\n APP_CONFIG_JSON,\n getSentryAppConfigJsonCodeSnippet(options),\n 'This ensures auto upload of source maps during native app build.',\n );\n }\n\n const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);\n\n Sentry.setTag(\n 'app-config-file-status',\n appConfigJsonExists ? 'found' : 'not-found',\n );\n if (!appConfigJsonExists) {\n return await showInstructions();\n }\n\n const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);\n if (!patched) {\n return await showInstructions();\n }\n}\n\nasync function patchAppConfigJson(\n path: string,\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const appConfigContent = (\n await fs.promises.readFile(path, { encoding: 'utf-8' })\n ).toString();\n const patchedContent = traceStep('app-config-json-patch', () =>\n addWithSentryToAppConfigJson(appConfigContent, options),\n );\n if (patchedContent === null) {\n return false;\n }\n\n try {\n await fs.promises.writeFile(path, patchedContent);\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'json-write-error');\n clack.log.error(`Unable to write ${chalk.cyan('app.config.json')}.`);\n return false;\n }\n Sentry.setTag('app-config-file-status', 'json-write-success');\n clack.log.success(\n `Added Sentry Expo plugin to ${chalk.cyan('app.config.json')}.`,\n );\n return true;\n}\n\nexport function addWithSentryToAppConfigJson(\n appConfigContent: string,\n options: RNCliSetupConfigContent,\n): string | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedAppConfig: AppConfigJson = JSON.parse(appConfigContent);\n const includesWithSentry =\n appConfigContent.includes(SENTRY_EXPO_PLUGIN_NAME) ||\n appConfigContent.includes(DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);\n\n if (includesWithSentry) {\n Sentry.setTag('app-config-file-status', 'already-patched');\n clack.log.warn(\n `Your ${chalk.cyan(\n 'app.config.json',\n )} already includes the Sentry Expo plugin.`,\n );\n return null;\n }\n\n if (\n parsedAppConfig.expo !== undefined &&\n !isPlainObject(parsedAppConfig.expo)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n if (\n parsedAppConfig.expo &&\n parsedAppConfig.expo.plugins !== undefined &&\n !Array.isArray(parsedAppConfig.expo.plugins)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n\n parsedAppConfig.expo = parsedAppConfig.expo ?? {};\n parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];\n parsedAppConfig.expo.plugins.push([\n SENTRY_EXPO_PLUGIN_NAME,\n {\n url: options.url,\n project: options.project,\n organization: options.org,\n },\n ]);\n\n return JSON.stringify(parsedAppConfig, null, 2) + EOL;\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n}\n\nexport function getSentryAppConfigJsonCodeSnippet({\n url,\n project,\n org,\n}: Omit<RNCliSetupConfigContent, 'authToken'>) {\n return makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`{\n \"name\": \"my app\",\n \"plugins\": [\n ${plus(`[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"${url}\",\n \"project\": \"${project}\",\n \"organization\": \"${org}\"\n }\n ]`)}\n ],\n}`);\n });\n}\n"]}
1
+ {"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;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iC,CAAC,EAChD,GAAG,EACH,OAAO,EACP,GAAG,GACwC;IAC3C,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACvD,OAAO,SAAS,CAAC;;;MAGf,IAAI,CAAC;;;kBAGO,GAAG;sBACC,OAAO;2BACF,GAAG;;MAExB,CAAC;;EAEL,CAAC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,8EAoBC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport { EOL } from 'os';\n\nimport { isPlainObject } from '@sentry/utils';\nimport * as Sentry from '@sentry/node';\nimport {\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { traceStep } from '../telemetry';\n\nexport const SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';\nexport const DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';\n\nexport const SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';\n\nconst APP_CONFIG_JSON = `app.json`;\n\nexport interface AppConfigJson {\n expo?: {\n plugins?: Array<[string, undefined | Record<string, unknown>]>;\n };\n}\n\nexport function printSentryExpoMigrationOutro(): void {\n clack.outro(\n `Deprecated ${chalk.cyan(\n 'sentry-expo',\n )} package installed in your dependencies. Please follow the migration guide at ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/migration/sentry-expo/',\n )}`,\n );\n}\n\n/**\n * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.\n */\nexport async function patchExpoAppConfig(options: RNCliSetupConfigContent) {\n function showInstructions() {\n return showCopyPasteInstructions(\n APP_CONFIG_JSON,\n getSentryAppConfigJsonCodeSnippet(options),\n 'This ensures auto upload of source maps during native app build.',\n );\n }\n\n const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);\n\n Sentry.setTag(\n 'app-config-file-status',\n appConfigJsonExists ? 'found' : 'not-found',\n );\n if (!appConfigJsonExists) {\n return await showInstructions();\n }\n\n const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);\n if (!patched) {\n return await showInstructions();\n }\n}\n\nasync function patchAppConfigJson(\n path: string,\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const appConfigContent = (\n await fs.promises.readFile(path, { encoding: 'utf-8' })\n ).toString();\n const patchedContent = traceStep('app-config-json-patch', () =>\n addWithSentryToAppConfigJson(appConfigContent, options),\n );\n if (patchedContent === null) {\n return false;\n }\n\n try {\n await fs.promises.writeFile(path, patchedContent);\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'json-write-error');\n clack.log.error(`Unable to write ${chalk.cyan('app.config.json')}.`);\n return false;\n }\n Sentry.setTag('app-config-file-status', 'json-write-success');\n clack.log.success(\n `Added Sentry Expo plugin to ${chalk.cyan('app.config.json')}.`,\n );\n return true;\n}\n\nexport function addWithSentryToAppConfigJson(\n appConfigContent: string,\n options: RNCliSetupConfigContent,\n): string | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedAppConfig: AppConfigJson = JSON.parse(appConfigContent);\n const includesWithSentry =\n appConfigContent.includes(SENTRY_EXPO_PLUGIN_NAME) ||\n appConfigContent.includes(DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);\n\n if (includesWithSentry) {\n Sentry.setTag('app-config-file-status', 'already-patched');\n clack.log.warn(\n `Your ${chalk.cyan(\n 'app.config.json',\n )} already includes the Sentry Expo plugin.`,\n );\n return null;\n }\n\n if (\n parsedAppConfig.expo !== undefined &&\n !isPlainObject(parsedAppConfig.expo)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n if (\n parsedAppConfig.expo &&\n parsedAppConfig.expo.plugins !== undefined &&\n !Array.isArray(parsedAppConfig.expo.plugins)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n\n parsedAppConfig.expo = parsedAppConfig.expo ?? {};\n parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];\n parsedAppConfig.expo.plugins.push([\n SENTRY_EXPO_PLUGIN_NAME,\n {\n url: options.url,\n project: options.project,\n organization: options.org,\n },\n ]);\n\n return JSON.stringify(parsedAppConfig, null, 2) + EOL;\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n}\n\nexport function getSentryAppConfigJsonCodeSnippet({\n url,\n project,\n org,\n}: Omit<RNCliSetupConfigContent, 'authToken'>) {\n return makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`{\n \"name\": \"my app\",\n \"plugins\": [\n ${plus(`[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"${url}\",\n \"project\": \"${project}\",\n \"organization\": \"${org}\"\n }\n ]`)}\n ],\n}`);\n });\n}\n"]}
@@ -22,64 +22,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
25
  Object.defineProperty(exports, "__esModule", { value: true });
62
26
  exports.addToGitignore = void 0;
63
- var fs = __importStar(require("fs"));
64
- var GITIGNORE_FILENAME = '.gitignore';
65
- function addToGitignore(filepath) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var _a;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
70
- case 0:
71
- _b.trys.push([0, 2, , 3]);
72
- return [4 /*yield*/, fs.promises.appendFile(GITIGNORE_FILENAME, "\n".concat(filepath, "\n"))];
73
- case 1:
74
- _b.sent();
75
- return [2 /*return*/, true];
76
- case 2:
77
- _a = _b.sent();
78
- return [2 /*return*/, false];
79
- case 3: return [2 /*return*/];
80
- }
81
- });
82
- });
27
+ const fs = __importStar(require("fs"));
28
+ const GITIGNORE_FILENAME = '.gitignore';
29
+ async function addToGitignore(filepath) {
30
+ /**
31
+ * Don't check whether the given file is ignored because:
32
+ * 1. It's tricky to check it without git.
33
+ * 2. Git might not be installed or accessible.
34
+ * 3. It's convenient to use a module to interact with git, but it would
35
+ * increase the size x2 approximately. Docs say to run the Wizard without
36
+ * installing it, and duplicating the size would slow the set-up down.
37
+ * 4. The Wizard is meant to be run once.
38
+ * 5. A message is logged informing users it's been added to the gitignore.
39
+ * 6. It will be added to the gitignore as many times as it runs - not a big
40
+ * deal.
41
+ * 7. It's straightforward to remove it from the gitignore.
42
+ */
43
+ try {
44
+ await fs.promises.appendFile(GITIGNORE_FILENAME, `\n${filepath}\n`);
45
+ return true;
46
+ }
47
+ catch {
48
+ return false;
49
+ }
83
50
  }
84
51
  exports.addToGitignore = addToGitignore;
85
52
  //# sourceMappingURL=git.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/react-native/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,IAAM,kBAAkB,GAAG,YAAY,CAAC;AAExC,SAAsB,cAAc,CAAC,QAAgB;;;;;;;oBAejD,qBAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE,YAAK,QAAQ,OAAI,CAAC,EAAA;;oBAAnE,SAAmE,CAAC;oBACpE,sBAAO,IAAI,EAAC;;;oBAEZ,sBAAO,KAAK,EAAC;;;;;CAEhB;AApBD,wCAoBC","sourcesContent":["import * as fs from 'fs';\n\nconst GITIGNORE_FILENAME = '.gitignore';\n\nexport async function addToGitignore(filepath: string): Promise<boolean> {\n /**\n * Don't check whether the given file is ignored because:\n * 1. It's tricky to check it without git.\n * 2. Git might not be installed or accessible.\n * 3. It's convenient to use a module to interact with git, but it would\n * increase the size x2 approximately. Docs say to run the Wizard without\n * installing it, and duplicating the size would slow the set-up down.\n * 4. The Wizard is meant to be run once.\n * 5. A message is logged informing users it's been added to the gitignore.\n * 6. It will be added to the gitignore as many times as it runs - not a big\n * deal.\n * 7. It's straightforward to remove it from the gitignore.\n */\n try {\n await fs.promises.appendFile(GITIGNORE_FILENAME, `\\n${filepath}\\n`);\n return true;\n } catch {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/react-native/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAEjC,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD;;;;;;;;;;;;OAYG;IACH,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE,KAAK,QAAQ,IAAI,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AApBD,wCAoBC","sourcesContent":["import * as fs from 'fs';\n\nconst GITIGNORE_FILENAME = '.gitignore';\n\nexport async function addToGitignore(filepath: string): Promise<boolean> {\n /**\n * Don't check whether the given file is ignored because:\n * 1. It's tricky to check it without git.\n * 2. Git might not be installed or accessible.\n * 3. It's convenient to use a module to interact with git, but it would\n * increase the size x2 approximately. Docs say to run the Wizard without\n * installing it, and duplicating the size would slow the set-up down.\n * 4. The Wizard is meant to be run once.\n * 5. A message is logged informing users it's been added to the gitignore.\n * 6. It will be added to the gitignore as many times as it runs - not a big\n * deal.\n * 7. It's straightforward to remove it from the gitignore.\n */\n try {\n await fs.promises.appendFile(GITIGNORE_FILENAME, `\\n${filepath}\\n`);\n return true;\n } catch {\n return false;\n }\n}\n"]}
@@ -24,12 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getFirstMatchedPath = exports.APP_BUILD_GRADLE = exports.XCODE_PROJECT = void 0;
27
- var glob = __importStar(require("glob"));
27
+ const glob = __importStar(require("glob"));
28
28
  exports.XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';
29
29
  exports.APP_BUILD_GRADLE = '**/app/build.gradle';
30
- var IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];
30
+ const IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];
31
31
  function getFirstMatchedPath(pattern) {
32
- var matches = glob.sync(pattern, {
32
+ const matches = glob.sync(pattern, {
33
33
  ignore: IGNORE_PATTERNS,
34
34
  });
35
35
  return matches[0];
@@ -1 +1 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/react-native/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAEhB,QAAA,aAAa,GAAG,iCAAiC,CAAC;AAClD,QAAA,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,IAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACzE,SAAgB,mBAAmB,CAAC,OAAe;IACjD,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,eAAe;KACxB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAND,kDAMC","sourcesContent":["import * as glob from 'glob';\n\nexport const XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';\nexport const APP_BUILD_GRADLE = '**/app/build.gradle';\n\nconst IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];\nexport function getFirstMatchedPath(pattern: string): string | undefined {\n const matches = glob.sync(pattern, {\n ignore: IGNORE_PATTERNS,\n });\n\n return matches[0];\n}\n"]}
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/react-native/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAEhB,QAAA,aAAa,GAAG,iCAAiC,CAAC;AAClD,QAAA,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACzE,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,eAAe;KACxB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAND,kDAMC","sourcesContent":["import * as glob from 'glob';\n\nexport const XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';\nexport const APP_BUILD_GRADLE = '**/app/build.gradle';\n\nconst IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];\nexport function getFirstMatchedPath(pattern: string): string | undefined {\n const matches = glob.sync(pattern, {\n ignore: IGNORE_PATTERNS,\n });\n\n return matches[0];\n}\n"]}
@@ -24,14 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.writeAppBuildGradle = exports.removeRNSentryGradlePlugin = exports.addRNSentryGradlePlugin = exports.doesAppBuildGradleIncludeRNSentryGradlePlugin = void 0;
27
- var fs = __importStar(require("fs"));
28
- var applyFrom = "apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")";
27
+ const fs = __importStar(require("fs"));
28
+ const applyFrom = `apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")`;
29
29
  function doesAppBuildGradleIncludeRNSentryGradlePlugin(content) {
30
30
  return content.includes('sentry.gradle');
31
31
  }
32
32
  exports.doesAppBuildGradleIncludeRNSentryGradlePlugin = doesAppBuildGradleIncludeRNSentryGradlePlugin;
33
33
  function addRNSentryGradlePlugin(content) {
34
- return content.replace(/^android {/m, function (match) { return "".concat(applyFrom, "\n").concat(match); });
34
+ return content.replace(/^android {/m, (match) => `${applyFrom}\n${match}`);
35
35
  }
36
36
  exports.addRNSentryGradlePlugin = addRNSentryGradlePlugin;
37
37
  function removeRNSentryGradlePlugin(content) {
@@ -39,7 +39,7 @@ function removeRNSentryGradlePlugin(content) {
39
39
  }
40
40
  exports.removeRNSentryGradlePlugin = removeRNSentryGradlePlugin;
41
41
  function writeAppBuildGradle(path, newContent) {
42
- var currentContent = fs.readFileSync(path, 'utf-8');
42
+ const currentContent = fs.readFileSync(path, 'utf-8');
43
43
  if (newContent === currentContent) {
44
44
  return;
45
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,IAAM,SAAS,GAAG,qJAA6I,CAAC;AAEhK,SAAgB,6CAA6C,CAC3D,OAAe;IAEf,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAJD,sGAIC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,UAAC,KAAK,IAAK,OAAA,UAAG,SAAS,eAAK,KAAK,CAAE,EAAxB,CAAwB,CAAC,CAAC;AAC7E,CAAC;AAFD,0DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,gEAEC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,UAAkB;IAClE,IAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAPD,kDAOC","sourcesContent":["import * as fs from 'fs';\n\nconst applyFrom = `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`;\n\nexport function doesAppBuildGradleIncludeRNSentryGradlePlugin(\n content: string,\n): boolean {\n return content.includes('sentry.gradle');\n}\n\nexport function addRNSentryGradlePlugin(content: string): string {\n return content.replace(/^android {/m, (match) => `${applyFrom}\\n${match}`);\n}\n\nexport function removeRNSentryGradlePlugin(content: string): string {\n return content.replace(/^\\s*apply from:.*sentry\\.gradle.*;?\\s*?\\r?\\n/m, '');\n}\n\nexport function writeAppBuildGradle(path: string, newContent: string): void {\n const currentContent = fs.readFileSync(path, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(path, newContent, 'utf-8');\n}\n"]}
1
+ {"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,MAAM,SAAS,GAAG,6IAA6I,CAAC;AAEhK,SAAgB,6CAA6C,CAC3D,OAAe;IAEf,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAJD,sGAIC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,0DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,gEAEC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,UAAkB;IAClE,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAPD,kDAOC","sourcesContent":["import * as fs from 'fs';\n\nconst applyFrom = `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`;\n\nexport function doesAppBuildGradleIncludeRNSentryGradlePlugin(\n content: string,\n): boolean {\n return content.includes('sentry.gradle');\n}\n\nexport function addRNSentryGradlePlugin(content: string): string {\n return content.replace(/^android {/m, (match) => `${applyFrom}\\n${match}`);\n}\n\nexport function removeRNSentryGradlePlugin(content: string): string {\n return content.replace(/^\\s*apply from:.*sentry\\.gradle.*;?\\s*?\\r?\\n/m, '');\n}\n\nexport function writeAppBuildGradle(path: string, newContent: string): void {\n const currentContent = fs.readFileSync(path, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(path, newContent, 'utf-8');\n}\n"]}
@@ -22,42 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
27
  };
@@ -65,79 +29,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
65
29
  exports.getSentryInitPlainTextSnippet = exports.getSentryInitColoredCodeSnippet = exports.doesJsCodeIncludeSdkSentryImport = exports.addSentryInitWithSdkImport = exports.addSentryInit = void 0;
66
30
  /* eslint-disable max-lines */
67
31
  // @ts-ignore - clack is ESM and TS complains about that. It works though
68
- var prompts_1 = __importDefault(require("@clack/prompts"));
69
- var chalk_1 = __importDefault(require("chalk"));
70
- var path = __importStar(require("path"));
71
- var process = __importStar(require("process"));
72
- var fs = __importStar(require("fs"));
73
- var Sentry = __importStar(require("@sentry/node"));
74
- var telemetry_1 = require("../telemetry");
75
- var clack_utils_1 = require("../utils/clack-utils");
76
- var glob_1 = require("./glob");
77
- var react_native_wizard_1 = require("./react-native-wizard");
78
- function addSentryInit(_a) {
79
- var dsn = _a.dsn;
80
- return __awaiter(this, void 0, void 0, function () {
81
- var prefixGlob, suffixGlob, universalGlob, jsFileGlob, jsPath, jsRelativePath, js, includesSentry;
82
- return __generator(this, function (_b) {
83
- switch (_b.label) {
84
- case 0:
85
- prefixGlob = '{.,./src,./app}';
86
- suffixGlob = '@(j|t|cj|mj)s?(x)';
87
- universalGlob = "@(App|_layout).".concat(suffixGlob);
88
- jsFileGlob = "".concat(prefixGlob, "/+(").concat(universalGlob, ")");
89
- jsPath = (0, telemetry_1.traceStep)('find-app-js-file', function () {
90
- return (0, glob_1.getFirstMatchedPath)(jsFileGlob);
91
- });
92
- Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
93
- if (!!jsPath) return [3 /*break*/, 2];
94
- prompts_1.default.log.warn("Could not find main App file. Place the following code snippet close to the Apps Root component.");
95
- return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryInitColoredCodeSnippet(dsn), 'This ensures the Sentry SDK is ready to capture errors.')];
96
- case 1:
97
- _b.sent();
98
- return [2 /*return*/];
99
- case 2:
100
- jsRelativePath = path.relative(process.cwd(), jsPath);
101
- js = fs.readFileSync(jsPath, 'utf-8');
102
- includesSentry = doesJsCodeIncludeSdkSentryImport(js, {
103
- sdkPackageName: react_native_wizard_1.RN_SDK_PACKAGE,
104
- });
105
- if (includesSentry) {
106
- Sentry.setTag('app-js-file-status', 'already-includes-sentry');
107
- prompts_1.default.log.warn("".concat(chalk_1.default.cyan(jsRelativePath), " already includes Sentry. We wont't add it again."));
108
- return [2 /*return*/];
109
- }
110
- (0, telemetry_1.traceStep)('add-sentry-init', function () {
111
- var newContent = addSentryInitWithSdkImport(js, { dsn: dsn });
112
- prompts_1.default.log.success("Added ".concat(chalk_1.default.cyan('Sentry.init'), " to ").concat(chalk_1.default.cyan(jsRelativePath), "."));
113
- fs.writeFileSync(jsPath, newContent, 'utf-8');
114
- });
115
- Sentry.setTag('app-js-file-status', 'added-sentry-init');
116
- prompts_1.default.log.success(chalk_1.default.green("".concat(chalk_1.default.cyan(jsRelativePath), " changes saved.")));
117
- return [2 /*return*/];
118
- }
119
- });
32
+ const prompts_1 = __importDefault(require("@clack/prompts"));
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ const path = __importStar(require("path"));
35
+ const process = __importStar(require("process"));
36
+ const fs = __importStar(require("fs"));
37
+ const Sentry = __importStar(require("@sentry/node"));
38
+ const telemetry_1 = require("../telemetry");
39
+ const clack_utils_1 = require("../utils/clack-utils");
40
+ const glob_1 = require("./glob");
41
+ const react_native_wizard_1 = require("./react-native-wizard");
42
+ async function addSentryInit({ dsn }) {
43
+ const prefixGlob = '{.,./src,./app}';
44
+ const suffixGlob = '@(j|t|cj|mj)s?(x)';
45
+ const universalGlob = `@(App|_layout).${suffixGlob}`;
46
+ const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;
47
+ const jsPath = (0, telemetry_1.traceStep)('find-app-js-file', () => (0, glob_1.getFirstMatchedPath)(jsFileGlob));
48
+ Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
49
+ if (!jsPath) {
50
+ prompts_1.default.log.warn(`Could not find main App file. Place the following code snippet close to the Apps Root component.`);
51
+ await (0, clack_utils_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryInitColoredCodeSnippet(dsn), 'This ensures the Sentry SDK is ready to capture errors.');
52
+ return;
53
+ }
54
+ const jsRelativePath = path.relative(process.cwd(), jsPath);
55
+ const js = fs.readFileSync(jsPath, 'utf-8');
56
+ const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {
57
+ sdkPackageName: react_native_wizard_1.RN_SDK_PACKAGE,
58
+ });
59
+ if (includesSentry) {
60
+ Sentry.setTag('app-js-file-status', 'already-includes-sentry');
61
+ prompts_1.default.log.warn(`${chalk_1.default.cyan(jsRelativePath)} already includes Sentry. We wont't add it again.`);
62
+ return;
63
+ }
64
+ (0, telemetry_1.traceStep)('add-sentry-init', () => {
65
+ const newContent = addSentryInitWithSdkImport(js, { dsn });
66
+ prompts_1.default.log.success(`Added ${chalk_1.default.cyan('Sentry.init')} to ${chalk_1.default.cyan(jsRelativePath)}.`);
67
+ fs.writeFileSync(jsPath, newContent, 'utf-8');
120
68
  });
69
+ Sentry.setTag('app-js-file-status', 'added-sentry-init');
70
+ prompts_1.default.log.success(chalk_1.default.green(`${chalk_1.default.cyan(jsRelativePath)} changes saved.`));
121
71
  }
122
72
  exports.addSentryInit = addSentryInit;
123
- function addSentryInitWithSdkImport(js, _a) {
124
- var dsn = _a.dsn;
125
- return js.replace(/^([^]*)(import\s+[^;]*?;$)/m, function (match) { return "".concat(match, "\n").concat(getSentryInitPlainTextSnippet(dsn)); });
73
+ function addSentryInitWithSdkImport(js, { dsn }) {
74
+ return js.replace(/^([^]*)(import\s+[^;]*?;$)/m, (match) => `${match}
75
+ ${getSentryInitPlainTextSnippet(dsn)}`);
126
76
  }
127
77
  exports.addSentryInitWithSdkImport = addSentryInitWithSdkImport;
128
- function doesJsCodeIncludeSdkSentryImport(js, _a) {
129
- var sdkPackageName = _a.sdkPackageName;
78
+ function doesJsCodeIncludeSdkSentryImport(js, { sdkPackageName }) {
130
79
  return !!js.match(sdkPackageName);
131
80
  }
132
81
  exports.doesJsCodeIncludeSdkSentryImport = doesJsCodeIncludeSdkSentryImport;
133
82
  function getSentryInitColoredCodeSnippet(dsn) {
134
- return (0, clack_utils_1.makeCodeSnippet)(true, function (_unchanged, plus, _minus) {
83
+ return (0, clack_utils_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
135
84
  return plus(getSentryInitPlainTextSnippet(dsn));
136
85
  });
137
86
  }
138
87
  exports.getSentryInitColoredCodeSnippet = getSentryInitColoredCodeSnippet;
139
88
  function getSentryInitPlainTextSnippet(dsn) {
140
- return "import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});");
89
+ return `import * as Sentry from '@sentry/react-native';
90
+
91
+ Sentry.init({
92
+ dsn: '${dsn}',
93
+
94
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
95
+ // spotlight: __DEV__,
96
+ });`;
141
97
  }
142
98
  exports.getSentryInitPlainTextSnippet = getSentryInitPlainTextSnippet;
143
99
  //# sourceMappingURL=javascript.js.map