@sentry/wizard 3.42.1 → 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 (338) 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 +26 -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 -3
  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 -2
  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/utils/clack-utils.test.ts +40 -50
  336. package/types/read-env.d.ts +3 -0
  337. package/types/xcode.d.ts +1 -0
  338. package/dist/package.json +0 -128
@@ -22,231 +22,126 @@ 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.addSentryCommandToBuildCommand = exports.setupNpmScriptInCI = exports.configureSentryCLI = 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 Sentry = __importStar(require("@sentry/node"));
70
- var path = __importStar(require("path"));
71
- var fs = __importStar(require("fs"));
72
- var clack_utils_1 = require("../../utils/clack-utils");
73
- var package_json_1 = require("../../utils/package-json");
74
- var telemetry_1 = require("../../telemetry");
75
- var package_manager_1 = require("../../utils/package-manager");
76
- var SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';
77
- var addedToBuildCommand = false;
78
- function configureSentryCLI(options, configureSourcemapGenerationFlow) {
79
- if (configureSourcemapGenerationFlow === void 0) { configureSourcemapGenerationFlow = defaultConfigureSourcemapGenerationFlow; }
80
- return __awaiter(this, void 0, void 0, function () {
81
- var packageDotJson, validPath, relativeArtifactPath, rawArtifactPath, _a, relativePosixArtifactPath;
82
- return __generator(this, function (_b) {
83
- switch (_b.label) {
84
- case 0: return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
85
- case 1:
86
- packageDotJson = _b.sent();
87
- return [4 /*yield*/, (0, clack_utils_1.installPackage)({
88
- packageName: '@sentry/cli',
89
- alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/cli', packageDotJson),
90
- })];
91
- case 2:
92
- _b.sent();
93
- validPath = false;
94
- _b.label = 3;
95
- case 3: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.text({
96
- message: 'Where are your build artifacts located?',
97
- placeholder: ".".concat(path.sep, "out"),
98
- validate: function (value) {
99
- if (!value) {
100
- return 'Please enter a path.';
101
- }
102
- },
103
- }))];
104
- case 4:
105
- rawArtifactPath = _b.sent();
106
- if (path.isAbsolute(rawArtifactPath)) {
107
- relativeArtifactPath = path.relative(process.cwd(), rawArtifactPath);
108
- }
109
- else {
110
- relativeArtifactPath = rawArtifactPath;
111
- }
112
- _b.label = 5;
113
- case 5:
114
- _b.trys.push([5, 7, , 9]);
115
- return [4 /*yield*/, fs.promises.access(path.join(process.cwd(), relativeArtifactPath))];
116
- case 6:
117
- _b.sent();
118
- validPath = true;
119
- return [3 /*break*/, 9];
120
- case 7:
121
- _a = _b.sent();
122
- return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
123
- message: "We couldn't find artifacts at ".concat(relativeArtifactPath, ". Are you sure that this is the location that contains your build artifacts?"),
124
- options: [
125
- {
126
- label: 'No, let me verify.',
127
- value: false,
128
- },
129
- { label: 'Yes, I am sure!', value: true },
130
- ],
131
- initialValue: false,
132
- }))];
133
- case 8:
134
- validPath = _b.sent();
135
- return [3 /*break*/, 9];
136
- case 9:
137
- if (!validPath) return [3 /*break*/, 3];
138
- _b.label = 10;
139
- case 10:
140
- relativePosixArtifactPath = relativeArtifactPath
141
- .split(path.sep)
142
- .join(path.posix.sep);
143
- return [4 /*yield*/, configureSourcemapGenerationFlow()];
144
- case 11:
145
- _b.sent();
146
- return [4 /*yield*/, createAndAddNpmScript(options, relativePosixArtifactPath)];
147
- case 12:
148
- _b.sent();
149
- return [4 /*yield*/, askShouldAddToBuildCommand()];
150
- case 13:
151
- if (!_b.sent()) return [3 /*break*/, 15];
152
- return [4 /*yield*/, (0, telemetry_1.traceStep)('sentry-cli-add-to-build-cmd', function () {
153
- return addSentryCommandToBuildCommand();
154
- })];
155
- case 14:
156
- _b.sent();
157
- return [3 /*break*/, 16];
158
- case 15:
159
- clack.log.info("No problem, just make sure to run this script ".concat(chalk_1.default.bold('after'), " building your application but ").concat(chalk_1.default.bold('before'), " deploying!"));
160
- _b.label = 16;
161
- case 16: return [4 /*yield*/, (0, clack_utils_1.addSentryCliConfig)({ authToken: options.authToken })];
162
- case 17:
163
- _b.sent();
164
- return [2 /*return*/];
165
- }
166
- });
31
+ const clack = __importStar(require("@clack/prompts"));
32
+ const chalk_1 = __importDefault(require("chalk"));
33
+ const Sentry = __importStar(require("@sentry/node"));
34
+ const path = __importStar(require("path"));
35
+ const fs = __importStar(require("fs"));
36
+ const clack_utils_1 = require("../../utils/clack-utils");
37
+ const package_json_1 = require("../../utils/package-json");
38
+ const telemetry_1 = require("../../telemetry");
39
+ const package_manager_1 = require("../../utils/package-manager");
40
+ const SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';
41
+ let addedToBuildCommand = false;
42
+ async function configureSentryCLI(options, configureSourcemapGenerationFlow = defaultConfigureSourcemapGenerationFlow) {
43
+ const packageDotJson = await (0, clack_utils_1.getPackageDotJson)();
44
+ await (0, clack_utils_1.installPackage)({
45
+ packageName: '@sentry/cli',
46
+ alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/cli', packageDotJson),
167
47
  });
48
+ let validPath = false;
49
+ let relativeArtifactPath;
50
+ do {
51
+ const rawArtifactPath = await (0, clack_utils_1.abortIfCancelled)(clack.text({
52
+ message: 'Where are your build artifacts located?',
53
+ placeholder: `.${path.sep}out`,
54
+ validate(value) {
55
+ if (!value) {
56
+ return 'Please enter a path.';
57
+ }
58
+ },
59
+ }));
60
+ if (path.isAbsolute(rawArtifactPath)) {
61
+ relativeArtifactPath = path.relative(process.cwd(), rawArtifactPath);
62
+ }
63
+ else {
64
+ relativeArtifactPath = rawArtifactPath;
65
+ }
66
+ try {
67
+ await fs.promises.access(path.join(process.cwd(), relativeArtifactPath));
68
+ validPath = true;
69
+ }
70
+ catch {
71
+ validPath = await (0, clack_utils_1.abortIfCancelled)(clack.select({
72
+ message: `We couldn't find artifacts at ${relativeArtifactPath}. Are you sure that this is the location that contains your build artifacts?`,
73
+ options: [
74
+ {
75
+ label: 'No, let me verify.',
76
+ value: false,
77
+ },
78
+ { label: 'Yes, I am sure!', value: true },
79
+ ],
80
+ initialValue: false,
81
+ }));
82
+ }
83
+ } while (!validPath);
84
+ const relativePosixArtifactPath = relativeArtifactPath
85
+ .split(path.sep)
86
+ .join(path.posix.sep);
87
+ await configureSourcemapGenerationFlow();
88
+ await createAndAddNpmScript(options, relativePosixArtifactPath);
89
+ if (await askShouldAddToBuildCommand()) {
90
+ await (0, telemetry_1.traceStep)('sentry-cli-add-to-build-cmd', () => addSentryCommandToBuildCommand());
91
+ }
92
+ else {
93
+ clack.log.info(`No problem, just make sure to run this script ${chalk_1.default.bold('after')} building your application but ${chalk_1.default.bold('before')} deploying!`);
94
+ }
95
+ await (0, clack_utils_1.addSentryCliConfig)({ authToken: options.authToken });
168
96
  }
169
97
  exports.configureSentryCLI = configureSentryCLI;
170
- function setupNpmScriptInCI() {
171
- return __awaiter(this, void 0, void 0, function () {
172
- var addedToCI;
173
- return __generator(this, function (_a) {
174
- switch (_a.label) {
175
- case 0:
176
- if (addedToBuildCommand) {
177
- // No need to tell users to add it manually to their CI
178
- // if the script is already added to the build command
179
- return [2 /*return*/];
180
- }
181
- return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
182
- message: "Add a step to your CI pipeline that runs the ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script ").concat(chalk_1.default.bold('right after'), " building your application."),
183
- options: [
184
- { label: 'I did, continue!', value: true },
185
- {
186
- label: "I'll do it later...",
187
- value: false,
188
- hint: chalk_1.default.yellow("You need to run ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " after each build for source maps to work properly.")),
189
- },
190
- ],
191
- initialValue: true,
192
- }))];
193
- case 1:
194
- addedToCI = _a.sent();
195
- Sentry.setTag('added-ci-script', addedToCI);
196
- if (!addedToCI) {
197
- clack.log.info("Don't forget! :)");
198
- }
199
- return [2 /*return*/];
200
- }
201
- });
202
- });
98
+ async function setupNpmScriptInCI() {
99
+ if (addedToBuildCommand) {
100
+ // No need to tell users to add it manually to their CI
101
+ // if the script is already added to the build command
102
+ return;
103
+ }
104
+ const addedToCI = await (0, clack_utils_1.abortIfCancelled)(clack.select({
105
+ message: `Add a step to your CI pipeline that runs the ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script ${chalk_1.default.bold('right after')} building your application.`,
106
+ options: [
107
+ { label: 'I did, continue!', value: true },
108
+ {
109
+ label: "I'll do it later...",
110
+ value: false,
111
+ hint: chalk_1.default.yellow(`You need to run ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} after each build for source maps to work properly.`),
112
+ },
113
+ ],
114
+ initialValue: true,
115
+ }));
116
+ Sentry.setTag('added-ci-script', addedToCI);
117
+ if (!addedToCI) {
118
+ clack.log.info("Don't forget! :)");
119
+ }
203
120
  }
204
121
  exports.setupNpmScriptInCI = setupNpmScriptInCI;
205
- function createAndAddNpmScript(options, relativePosixArtifactPath) {
206
- return __awaiter(this, void 0, void 0, function () {
207
- var sentryCliNpmScript, packageDotJson;
208
- return __generator(this, function (_a) {
209
- switch (_a.label) {
210
- case 0:
211
- sentryCliNpmScript = "sentry-cli sourcemaps inject --org ".concat(options.orgSlug, " --project ").concat(options.projectSlug, " ").concat(relativePosixArtifactPath, " && sentry-cli").concat(options.selfHosted ? " --url ".concat(options.url) : '', " sourcemaps upload --org ").concat(options.orgSlug, " --project ").concat(options.projectSlug, " ").concat(relativePosixArtifactPath);
212
- return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
213
- case 1:
214
- packageDotJson = _a.sent();
215
- packageDotJson.scripts = packageDotJson.scripts || {};
216
- packageDotJson.scripts[SENTRY_NPM_SCRIPT_NAME] = sentryCliNpmScript;
217
- return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2))];
218
- case 2:
219
- _a.sent();
220
- clack.log.info("Added a ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script to your ").concat(chalk_1.default.cyan('package.json'), "."));
221
- return [2 /*return*/];
222
- }
223
- });
224
- });
122
+ async function createAndAddNpmScript(options, relativePosixArtifactPath) {
123
+ const sentryCliNpmScript = `sentry-cli sourcemaps inject --org ${options.orgSlug} --project ${options.projectSlug} ${relativePosixArtifactPath} && sentry-cli${options.selfHosted ? ` --url ${options.url}` : ''} sourcemaps upload --org ${options.orgSlug} --project ${options.projectSlug} ${relativePosixArtifactPath}`;
124
+ const packageDotJson = await (0, clack_utils_1.getPackageDotJson)();
125
+ packageDotJson.scripts = packageDotJson.scripts || {};
126
+ packageDotJson.scripts[SENTRY_NPM_SCRIPT_NAME] = sentryCliNpmScript;
127
+ await fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2));
128
+ clack.log.info(`Added a ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk_1.default.cyan('package.json')}.`);
225
129
  }
226
- function askShouldAddToBuildCommand() {
227
- return __awaiter(this, void 0, void 0, function () {
228
- var shouldAddToBuildCommand;
229
- return __generator(this, function (_a) {
230
- switch (_a.label) {
231
- case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
232
- message: "Do you want to automatically run the ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script after each production build?"),
233
- options: [
234
- {
235
- label: 'Yes',
236
- value: true,
237
- hint: 'This will modify your prod build command',
238
- },
239
- { label: 'No', value: false },
240
- ],
241
- initialValue: true,
242
- }))];
243
- case 1:
244
- shouldAddToBuildCommand = _a.sent();
245
- Sentry.setTag('modify-build-command', shouldAddToBuildCommand);
246
- return [2 /*return*/, shouldAddToBuildCommand];
247
- }
248
- });
249
- });
130
+ async function askShouldAddToBuildCommand() {
131
+ const shouldAddToBuildCommand = await (0, clack_utils_1.abortIfCancelled)(clack.select({
132
+ message: `Do you want to automatically run the ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script after each production build?`,
133
+ options: [
134
+ {
135
+ label: 'Yes',
136
+ value: true,
137
+ hint: 'This will modify your prod build command',
138
+ },
139
+ { label: 'No', value: false },
140
+ ],
141
+ initialValue: true,
142
+ }));
143
+ Sentry.setTag('modify-build-command', shouldAddToBuildCommand);
144
+ return shouldAddToBuildCommand;
250
145
  }
251
146
  /**
252
147
  * Add the sentry:sourcemaps command to the prod build command in the package.json
@@ -255,83 +150,56 @@ function askShouldAddToBuildCommand() {
255
150
  *
256
151
  * @param packageDotJson The package.json which will be modified.
257
152
  */
258
- function addSentryCommandToBuildCommand() {
259
- var _a;
260
- return __awaiter(this, void 0, void 0, function () {
261
- var packageDotJson, allNpmScripts, packageManager, buildCommand, isProdBuildCommand, _b, oldCommand;
262
- return __generator(this, function (_c) {
263
- switch (_c.label) {
264
- case 0: return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
265
- case 1:
266
- packageDotJson = _c.sent();
267
- // This usually shouldn't happen because earlier we added the
268
- // SENTRY_NPM_SCRIPT_NAME script but just to be sure
269
- packageDotJson.scripts = packageDotJson.scripts || {};
270
- allNpmScripts = Object.keys(packageDotJson.scripts).filter(function (s) { return s !== SENTRY_NPM_SCRIPT_NAME; });
271
- packageManager = (_a = (0, package_manager_1.detectPackageManger)()) !== null && _a !== void 0 ? _a : package_manager_1.NPM;
272
- buildCommand = typeof packageDotJson.scripts.build === 'string'
273
- ? 'build'
274
- : allNpmScripts.find(function (s) { return s.toLocaleLowerCase().includes('build'); });
275
- _b = !!buildCommand;
276
- if (!_b) return [3 /*break*/, 3];
277
- return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.confirm({
278
- message: "Is ".concat(chalk_1.default.cyan("".concat(packageManager.runScriptCommand, " ").concat(buildCommand)), " your production build command?"),
279
- }))];
280
- case 2:
281
- _b = (_c.sent());
282
- _c.label = 3;
283
- case 3:
284
- isProdBuildCommand = _b;
285
- if (!(allNpmScripts.length && (!buildCommand || !isProdBuildCommand))) return [3 /*break*/, 5];
286
- return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
287
- message: "Which ".concat(packageManager.name, " command in your ").concat(chalk_1.default.cyan('package.json'), " builds your application for production?"),
288
- options: allNpmScripts
289
- .map(function (script) { return ({
290
- label: script,
291
- value: script,
292
- }); })
293
- .concat({ label: 'None of the above', value: 'none' }),
294
- }))];
295
- case 4:
296
- buildCommand = _c.sent();
297
- _c.label = 5;
298
- case 5:
299
- if (!buildCommand || buildCommand === 'none') {
300
- clack.log.warn("We can only add the ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script to another `script` in your ").concat(chalk_1.default.cyan('package.json'), ".\nPlease add it manually to your prod build command."));
301
- return [2 /*return*/];
302
- }
303
- oldCommand = packageDotJson.scripts[buildCommand];
304
- if (!oldCommand) {
305
- // very unlikely to happen but nevertheless
306
- clack.log.warn("`".concat(buildCommand, "` doesn't seem to be part of your package.json scripts"));
307
- return [2 /*return*/];
308
- }
309
- packageDotJson.scripts[buildCommand] = "".concat(oldCommand, " && ").concat(packageManager.runScriptCommand, " ").concat(SENTRY_NPM_SCRIPT_NAME);
310
- return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2))];
311
- case 6:
312
- _c.sent();
313
- addedToBuildCommand = true;
314
- clack.log.info("Added ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script to your ").concat(chalk_1.default.cyan(buildCommand), " command."));
315
- return [2 /*return*/];
316
- }
317
- });
318
- });
153
+ async function addSentryCommandToBuildCommand() {
154
+ const packageDotJson = await (0, clack_utils_1.getPackageDotJson)();
155
+ // This usually shouldn't happen because earlier we added the
156
+ // SENTRY_NPM_SCRIPT_NAME script but just to be sure
157
+ packageDotJson.scripts = packageDotJson.scripts || {};
158
+ const allNpmScripts = Object.keys(packageDotJson.scripts).filter((s) => s !== SENTRY_NPM_SCRIPT_NAME);
159
+ const packageManager = (0, package_manager_1.detectPackageManger)() ?? package_manager_1.NPM;
160
+ // Heuristic to pre-select the build command:
161
+ // Often, 'build' is the prod build command, so we favour it.
162
+ // If it's not there, commands that include 'build' might be the prod build command.
163
+ let buildCommand = typeof packageDotJson.scripts.build === 'string'
164
+ ? 'build'
165
+ : allNpmScripts.find((s) => s.toLocaleLowerCase().includes('build'));
166
+ const isProdBuildCommand = !!buildCommand &&
167
+ (await (0, clack_utils_1.abortIfCancelled)(clack.confirm({
168
+ message: `Is ${chalk_1.default.cyan(`${packageManager.runScriptCommand} ${buildCommand}`)} your production build command?`,
169
+ })));
170
+ if (allNpmScripts.length && (!buildCommand || !isProdBuildCommand)) {
171
+ buildCommand = await (0, clack_utils_1.abortIfCancelled)(clack.select({
172
+ message: `Which ${packageManager.name} command in your ${chalk_1.default.cyan('package.json')} builds your application for production?`,
173
+ options: allNpmScripts
174
+ .map((script) => ({
175
+ label: script,
176
+ value: script,
177
+ }))
178
+ .concat({ label: 'None of the above', value: 'none' }),
179
+ }));
180
+ }
181
+ if (!buildCommand || buildCommand === 'none') {
182
+ clack.log.warn(`We can only add the ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script to another \`script\` in your ${chalk_1.default.cyan('package.json')}.
183
+ Please add it manually to your prod build command.`);
184
+ return;
185
+ }
186
+ const oldCommand = packageDotJson.scripts[buildCommand];
187
+ if (!oldCommand) {
188
+ // very unlikely to happen but nevertheless
189
+ clack.log.warn(`\`${buildCommand}\` doesn't seem to be part of your package.json scripts`);
190
+ return;
191
+ }
192
+ packageDotJson.scripts[buildCommand] = `${oldCommand} && ${packageManager.runScriptCommand} ${SENTRY_NPM_SCRIPT_NAME}`;
193
+ await fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2));
194
+ addedToBuildCommand = true;
195
+ clack.log.info(`Added ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk_1.default.cyan(buildCommand)} command.`);
319
196
  }
320
197
  exports.addSentryCommandToBuildCommand = addSentryCommandToBuildCommand;
321
- function defaultConfigureSourcemapGenerationFlow() {
322
- return __awaiter(this, void 0, void 0, function () {
323
- return __generator(this, function (_a) {
324
- switch (_a.label) {
325
- case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
326
- message: "Verify that your build tool is generating source maps. ".concat(chalk_1.default.dim('(Your build output folder should contain .js.map files after a build)')),
327
- options: [{ label: 'I checked. Continue!', value: true }],
328
- initialValue: true,
329
- }))];
330
- case 1:
331
- _a.sent();
332
- return [2 /*return*/];
333
- }
334
- });
335
- });
198
+ async function defaultConfigureSourcemapGenerationFlow() {
199
+ await (0, clack_utils_1.abortIfCancelled)(clack.select({
200
+ message: `Verify that your build tool is generating source maps. ${chalk_1.default.dim('(Your build output folder should contain .js.map files after a build)')}`,
201
+ options: [{ label: 'I checked. Continue!', value: true }],
202
+ initialValue: true,
203
+ }));
336
204
  }
337
205
  //# sourceMappingURL=sentry-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-cli.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/sentry-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAC1B,mDAAuC;AACvC,yCAA6B;AAC7B,qCAAyB;AACzB,uDAKiC;AAGjC,yDAA+D;AAC/D,6CAA4C;AAC5C,+DAAuE;AAEvE,IAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAEnD,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,SAAsB,kBAAkB,CACtC,OAAgD,EAChD,gCAA+F;IAA/F,iDAAA,EAAA,0EAA+F;;;;;wBAExE,qBAAM,IAAA,+BAAiB,GAAE,EAAA;;oBAA1C,cAAc,GAAG,SAAyB;oBAEhD,qBAAM,IAAA,4BAAc,EAAC;4BACnB,WAAW,EAAE,aAAa;4BAC1B,gBAAgB,EAAE,IAAA,kCAAmB,EAAC,aAAa,EAAE,cAAc,CAAC;yBACrE,CAAC,EAAA;;oBAHF,SAGE,CAAC;oBAEC,SAAS,GAAG,KAAK,CAAC;;wBAGI,qBAAM,IAAA,8BAAgB,EAC5C,KAAK,CAAC,IAAI,CAAC;wBACT,OAAO,EAAE,yCAAyC;wBAClD,WAAW,EAAE,WAAI,IAAI,CAAC,GAAG,QAAK;wBAC9B,QAAQ,YAAC,KAAK;4BACZ,IAAI,CAAC,KAAK,EAAE;gCACV,OAAO,sBAAsB,CAAC;6BAC/B;wBACH,CAAC;qBACF,CAAC,CACH,EAAA;;oBAVK,eAAe,GAAG,SAUvB;oBAED,IAAI,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;wBACpC,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE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AuC;;;;wBACpD,qBAAM,IAAA,8BAAgB,EACpB,KAAK,CAAC,MAAM,CAAC;wBACX,OAAO,EAAE,iEAA0D,eAAK,CAAC,GAAG,CAC1E,uEAAuE,CACxE,CAAE;wBACH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;wBACzD,YAAY,EAAE,IAAI;qBACnB,CAAC,CACH,EAAA;;oBARD,SAQC,CAAC;;;;;CACH","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 Sentry from '@sentry/node';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport {\n abortIfCancelled,\n addSentryCliConfig,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack-utils';\n\nimport { SourceMapUploadToolConfigurationOptions } from './types';\nimport { hasPackageInstalled } from '../../utils/package-json';\nimport { traceStep } from '../../telemetry';\nimport { detectPackageManger, NPM } from '../../utils/package-manager';\n\nconst SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';\n\nlet addedToBuildCommand = false;\n\nexport async function configureSentryCLI(\n options: SourceMapUploadToolConfigurationOptions,\n configureSourcemapGenerationFlow: () => Promise<void> = defaultConfigureSourcemapGenerationFlow,\n): Promise<void> {\n const packageDotJson = await getPackageDotJson();\n\n await installPackage({\n packageName: '@sentry/cli',\n alreadyInstalled: hasPackageInstalled('@sentry/cli', packageDotJson),\n });\n\n let validPath = false;\n let relativeArtifactPath;\n do {\n const rawArtifactPath = await abortIfCancelled(\n clack.text({\n message: 'Where are your build artifacts located?',\n placeholder: `.${path.sep}out`,\n validate(value) {\n if (!value) {\n return 'Please enter a path.';\n }\n },\n }),\n );\n\n if (path.isAbsolute(rawArtifactPath)) {\n relativeArtifactPath = path.relative(process.cwd(), rawArtifactPath);\n } else {\n relativeArtifactPath = rawArtifactPath;\n }\n\n try {\n await fs.promises.access(path.join(process.cwd(), relativeArtifactPath));\n validPath = true;\n } catch {\n validPath = await abortIfCancelled(\n clack.select({\n message: `We couldn't find artifacts at ${relativeArtifactPath}. Are you sure that this is the location that contains your build artifacts?`,\n options: [\n {\n label: 'No, let me verify.',\n value: false,\n },\n { label: 'Yes, I am sure!', value: true },\n ],\n initialValue: false,\n }),\n );\n }\n } while (!validPath);\n\n const relativePosixArtifactPath = relativeArtifactPath\n .split(path.sep)\n .join(path.posix.sep);\n\n await configureSourcemapGenerationFlow();\n\n await createAndAddNpmScript(options, relativePosixArtifactPath);\n\n if (await askShouldAddToBuildCommand()) {\n await traceStep('sentry-cli-add-to-build-cmd', () =>\n addSentryCommandToBuildCommand(),\n );\n } else {\n clack.log.info(\n `No problem, just make sure to run this script ${chalk.bold(\n 'after',\n )} building your application but ${chalk.bold('before')} deploying!`,\n );\n }\n\n await addSentryCliConfig({ authToken: options.authToken });\n}\n\nexport async function setupNpmScriptInCI(): Promise<void> {\n if (addedToBuildCommand) {\n // No need to tell users to add it manually to their CI\n // if the script is already added to the build command\n return;\n }\n\n const addedToCI = await abortIfCancelled(\n clack.select({\n message: `Add a step to your CI pipeline that runs the ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} script ${chalk.bold('right after')} building your application.`,\n options: [\n { label: 'I did, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n `You need to run ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} after each build for source maps to work properly.`,\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('added-ci-script', addedToCI);\n\n if (!addedToCI) {\n clack.log.info(\"Don't forget! :)\");\n }\n}\n\nasync function createAndAddNpmScript(\n options: SourceMapUploadToolConfigurationOptions,\n relativePosixArtifactPath: string,\n): Promise<void> {\n const sentryCliNpmScript = `sentry-cli sourcemaps inject --org ${\n options.orgSlug\n } --project ${\n options.projectSlug\n } ${relativePosixArtifactPath} && sentry-cli${\n options.selfHosted ? ` --url ${options.url}` : ''\n } sourcemaps upload --org ${options.orgSlug} --project ${\n options.projectSlug\n } ${relativePosixArtifactPath}`;\n\n const packageDotJson = await getPackageDotJson();\n\n packageDotJson.scripts = packageDotJson.scripts || {};\n packageDotJson.scripts[SENTRY_NPM_SCRIPT_NAME] = sentryCliNpmScript;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageDotJson, null, 2),\n );\n\n clack.log.info(\n `Added a ${chalk.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk.cyan(\n 'package.json',\n )}.`,\n );\n}\n\nasync function askShouldAddToBuildCommand(): Promise<boolean> {\n const shouldAddToBuildCommand = await abortIfCancelled(\n clack.select({\n message: `Do you want to automatically run the ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} script after each production build?`,\n options: [\n {\n label: 'Yes',\n value: true,\n hint: 'This will modify your prod build command',\n },\n { label: 'No', value: false },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('modify-build-command', shouldAddToBuildCommand);\n\n return shouldAddToBuildCommand;\n}\n\n/**\n * Add the sentry:sourcemaps command to the prod build command in the package.json\n * - Detect the user's build command\n * - Append the sentry:sourcemaps command to it\n *\n * @param packageDotJson The package.json which will be modified.\n */\nexport async function addSentryCommandToBuildCommand(): Promise<void> {\n const packageDotJson = await getPackageDotJson();\n // This usually shouldn't happen because earlier we added the\n // SENTRY_NPM_SCRIPT_NAME script but just to be sure\n packageDotJson.scripts = packageDotJson.scripts || {};\n\n const allNpmScripts = Object.keys(packageDotJson.scripts).filter(\n (s) => s !== SENTRY_NPM_SCRIPT_NAME,\n );\n\n const packageManager = detectPackageManger() ?? NPM;\n\n // Heuristic to pre-select the build command:\n // Often, 'build' is the prod build command, so we favour it.\n // If it's not there, commands that include 'build' might be the prod build command.\n let buildCommand =\n typeof packageDotJson.scripts.build === 'string'\n ? 'build'\n : allNpmScripts.find((s) => s.toLocaleLowerCase().includes('build'));\n\n const isProdBuildCommand =\n !!buildCommand &&\n (await abortIfCancelled(\n clack.confirm({\n message: `Is ${chalk.cyan(\n `${packageManager.runScriptCommand} ${buildCommand}`,\n )} your production build command?`,\n }),\n ));\n\n if (allNpmScripts.length && (!buildCommand || !isProdBuildCommand)) {\n buildCommand = await abortIfCancelled(\n clack.select({\n message: `Which ${packageManager.name} command in your ${chalk.cyan(\n 'package.json',\n )} builds your application for production?`,\n options: allNpmScripts\n .map((script) => ({\n label: script,\n value: script,\n }))\n .concat({ label: 'None of the above', value: 'none' }),\n }),\n );\n }\n\n if (!buildCommand || buildCommand === 'none') {\n clack.log.warn(\n `We can only add the ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} script to another \\`script\\` in your ${chalk.cyan('package.json')}.\nPlease add it manually to your prod build command.`,\n );\n return;\n }\n\n const oldCommand = packageDotJson.scripts[buildCommand];\n if (!oldCommand) {\n // very unlikely to happen but nevertheless\n clack.log.warn(\n `\\`${buildCommand}\\` doesn't seem to be part of your package.json scripts`,\n );\n return;\n }\n\n packageDotJson.scripts[\n buildCommand\n ] = `${oldCommand} && ${packageManager.runScriptCommand} ${SENTRY_NPM_SCRIPT_NAME}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageDotJson, null, 2),\n );\n\n addedToBuildCommand = true;\n\n clack.log.info(\n `Added ${chalk.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk.cyan(\n buildCommand,\n )} command.`,\n );\n}\n\nasync function defaultConfigureSourcemapGenerationFlow(): Promise<void> {\n await abortIfCancelled(\n clack.select({\n message: `Verify that your build tool is generating source maps. ${chalk.dim(\n '(Your build output folder should contain .js.map files after a build)',\n )}`,\n options: [{ label: 'I checked. Continue!', value: true }],\n initialValue: true,\n }),\n );\n}\n"]}
1
+ {"version":3,"file":"sentry-cli.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/sentry-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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AAK,YAAY,yDAAyD,CAC3E,CAAC;QACF,OAAO;KACR;IAED,cAAc,CAAC,OAAO,CACpB,YAAY,CACb,GAAG,GAAG,UAAU,OAAO,cAAc,CAAC,gBAAgB,IAAI,sBAAsB,EAAE,CAAC;IAEpF,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,EACxC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CACxC,CAAC;IAEF,mBAAmB,GAAG,IAAI,CAAC;IAE3B,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,SAAS,eAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,eAAK,CAAC,IAAI,CACtE,YAAY,CACb,WAAW,CACb,CAAC;AACJ,CAAC;AAjFD,wEAiFC;AAED,KAAK,UAAU,uCAAuC;IACpD,MAAM,IAAA,8BAAgB,EACpB,KAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,0DAA0D,eAAK,CAAC,GAAG,CAC1E,uEAAuE,CACxE,EAAE;QACH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;AACJ,CAAC","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 Sentry from '@sentry/node';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport {\n abortIfCancelled,\n addSentryCliConfig,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack-utils';\n\nimport { SourceMapUploadToolConfigurationOptions } from './types';\nimport { hasPackageInstalled } from '../../utils/package-json';\nimport { traceStep } from '../../telemetry';\nimport { detectPackageManger, NPM } from '../../utils/package-manager';\n\nconst SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';\n\nlet addedToBuildCommand = false;\n\nexport async function configureSentryCLI(\n options: SourceMapUploadToolConfigurationOptions,\n configureSourcemapGenerationFlow: () => Promise<void> = defaultConfigureSourcemapGenerationFlow,\n): Promise<void> {\n const packageDotJson = await getPackageDotJson();\n\n await installPackage({\n packageName: '@sentry/cli',\n alreadyInstalled: hasPackageInstalled('@sentry/cli', packageDotJson),\n });\n\n let validPath = false;\n let relativeArtifactPath;\n do {\n const rawArtifactPath = await abortIfCancelled(\n clack.text({\n message: 'Where are your build artifacts located?',\n placeholder: `.${path.sep}out`,\n validate(value) {\n if (!value) {\n return 'Please enter a path.';\n }\n },\n }),\n );\n\n if (path.isAbsolute(rawArtifactPath)) {\n relativeArtifactPath = path.relative(process.cwd(), rawArtifactPath);\n } else {\n relativeArtifactPath = rawArtifactPath;\n }\n\n try {\n await fs.promises.access(path.join(process.cwd(), relativeArtifactPath));\n validPath = true;\n } catch {\n validPath = await abortIfCancelled(\n clack.select({\n message: `We couldn't find artifacts at ${relativeArtifactPath}. Are you sure that this is the location that contains your build artifacts?`,\n options: [\n {\n label: 'No, let me verify.',\n value: false,\n },\n { label: 'Yes, I am sure!', value: true },\n ],\n initialValue: false,\n }),\n );\n }\n } while (!validPath);\n\n const relativePosixArtifactPath = relativeArtifactPath\n .split(path.sep)\n .join(path.posix.sep);\n\n await configureSourcemapGenerationFlow();\n\n await createAndAddNpmScript(options, relativePosixArtifactPath);\n\n if (await askShouldAddToBuildCommand()) {\n await traceStep('sentry-cli-add-to-build-cmd', () =>\n addSentryCommandToBuildCommand(),\n );\n } else {\n clack.log.info(\n `No problem, just make sure to run this script ${chalk.bold(\n 'after',\n )} building your application but ${chalk.bold('before')} deploying!`,\n );\n }\n\n await addSentryCliConfig({ authToken: options.authToken });\n}\n\nexport async function setupNpmScriptInCI(): Promise<void> {\n if (addedToBuildCommand) {\n // No need to tell users to add it manually to their CI\n // if the script is already added to the build command\n return;\n }\n\n const addedToCI = await abortIfCancelled(\n clack.select({\n message: `Add a step to your CI pipeline that runs the ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} script ${chalk.bold('right after')} building your application.`,\n options: [\n { label: 'I did, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n `You need to run ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} after each build for source maps to work properly.`,\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('added-ci-script', addedToCI);\n\n if (!addedToCI) {\n clack.log.info(\"Don't forget! :)\");\n }\n}\n\nasync function createAndAddNpmScript(\n options: SourceMapUploadToolConfigurationOptions,\n relativePosixArtifactPath: string,\n): Promise<void> {\n const sentryCliNpmScript = `sentry-cli sourcemaps inject --org ${\n options.orgSlug\n } --project ${\n options.projectSlug\n } ${relativePosixArtifactPath} && sentry-cli${\n options.selfHosted ? ` --url ${options.url}` : ''\n } sourcemaps upload --org ${options.orgSlug} --project ${\n options.projectSlug\n } ${relativePosixArtifactPath}`;\n\n const packageDotJson = await getPackageDotJson();\n\n packageDotJson.scripts = packageDotJson.scripts || {};\n packageDotJson.scripts[SENTRY_NPM_SCRIPT_NAME] = sentryCliNpmScript;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageDotJson, null, 2),\n );\n\n clack.log.info(\n `Added a ${chalk.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk.cyan(\n 'package.json',\n )}.`,\n );\n}\n\nasync function askShouldAddToBuildCommand(): Promise<boolean> {\n const shouldAddToBuildCommand = await abortIfCancelled(\n clack.select({\n message: `Do you want to automatically run the ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} script after each production build?`,\n options: [\n {\n label: 'Yes',\n value: true,\n hint: 'This will modify your prod build command',\n },\n { label: 'No', value: false },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('modify-build-command', shouldAddToBuildCommand);\n\n return shouldAddToBuildCommand;\n}\n\n/**\n * Add the sentry:sourcemaps command to the prod build command in the package.json\n * - Detect the user's build command\n * - Append the sentry:sourcemaps command to it\n *\n * @param packageDotJson The package.json which will be modified.\n */\nexport async function addSentryCommandToBuildCommand(): Promise<void> {\n const packageDotJson = await getPackageDotJson();\n // This usually shouldn't happen because earlier we added the\n // SENTRY_NPM_SCRIPT_NAME script but just to be sure\n packageDotJson.scripts = packageDotJson.scripts || {};\n\n const allNpmScripts = Object.keys(packageDotJson.scripts).filter(\n (s) => s !== SENTRY_NPM_SCRIPT_NAME,\n );\n\n const packageManager = detectPackageManger() ?? NPM;\n\n // Heuristic to pre-select the build command:\n // Often, 'build' is the prod build command, so we favour it.\n // If it's not there, commands that include 'build' might be the prod build command.\n let buildCommand =\n typeof packageDotJson.scripts.build === 'string'\n ? 'build'\n : allNpmScripts.find((s) => s.toLocaleLowerCase().includes('build'));\n\n const isProdBuildCommand =\n !!buildCommand &&\n (await abortIfCancelled(\n clack.confirm({\n message: `Is ${chalk.cyan(\n `${packageManager.runScriptCommand} ${buildCommand}`,\n )} your production build command?`,\n }),\n ));\n\n if (allNpmScripts.length && (!buildCommand || !isProdBuildCommand)) {\n buildCommand = await abortIfCancelled(\n clack.select({\n message: `Which ${packageManager.name} command in your ${chalk.cyan(\n 'package.json',\n )} builds your application for production?`,\n options: allNpmScripts\n .map((script) => ({\n label: script,\n value: script,\n }))\n .concat({ label: 'None of the above', value: 'none' }),\n }),\n );\n }\n\n if (!buildCommand || buildCommand === 'none') {\n clack.log.warn(\n `We can only add the ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} script to another \\`script\\` in your ${chalk.cyan('package.json')}.\nPlease add it manually to your prod build command.`,\n );\n return;\n }\n\n const oldCommand = packageDotJson.scripts[buildCommand];\n if (!oldCommand) {\n // very unlikely to happen but nevertheless\n clack.log.warn(\n `\\`${buildCommand}\\` doesn't seem to be part of your package.json scripts`,\n );\n return;\n }\n\n packageDotJson.scripts[\n buildCommand\n ] = `${oldCommand} && ${packageManager.runScriptCommand} ${SENTRY_NPM_SCRIPT_NAME}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageDotJson, null, 2),\n );\n\n addedToBuildCommand = true;\n\n clack.log.info(\n `Added ${chalk.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk.cyan(\n buildCommand,\n )} command.`,\n );\n}\n\nasync function defaultConfigureSourcemapGenerationFlow(): Promise<void> {\n await abortIfCancelled(\n clack.select({\n message: `Verify that your build tool is generating source maps. ${chalk.dim(\n '(Your build output folder should contain .js.map files after a build)',\n )}`,\n options: [{ label: 'I checked. Continue!', value: true }],\n initialValue: true,\n }),\n );\n}\n"]}