@sentry/wizard 4.4.0 → 4.6.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 (228) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +23 -19
  3. package/dist/bin.js +13 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/e2e-tests/tests/nextjs-14.test.js +4 -5
  6. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  7. package/dist/e2e-tests/tests/nextjs-15.test.js +3 -5
  8. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  9. package/dist/e2e-tests/utils/index.d.ts +1 -1
  10. package/dist/e2e-tests/utils/index.js +20 -2
  11. package/dist/e2e-tests/utils/index.js.map +1 -1
  12. package/dist/lib/Constants.d.ts +2 -0
  13. package/dist/lib/Constants.js.map +1 -1
  14. package/dist/lib/Helper/File.d.ts +1 -1
  15. package/dist/lib/Helper/File.js +1 -3
  16. package/dist/lib/Helper/File.js.map +1 -1
  17. package/dist/lib/Helper/Logging.d.ts +3 -0
  18. package/dist/lib/Helper/Logging.js +3 -0
  19. package/dist/lib/Helper/Logging.js.map +1 -1
  20. package/dist/lib/Helper/Package.d.ts +5 -3
  21. package/dist/lib/Helper/Package.js +2 -2
  22. package/dist/lib/Helper/Package.js.map +1 -1
  23. package/dist/lib/Helper/SentryCli.d.ts +20 -7
  24. package/dist/lib/Helper/SentryCli.js +21 -13
  25. package/dist/lib/Helper/SentryCli.js.map +1 -1
  26. package/dist/lib/Helper/Wizard.js +9 -5
  27. package/dist/lib/Helper/Wizard.js.map +1 -1
  28. package/dist/lib/Helper/__tests__/SentryCli.js +21 -4
  29. package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
  30. package/dist/lib/Setup.d.ts +3 -1
  31. package/dist/lib/Setup.js.map +1 -1
  32. package/dist/lib/Steps/Integrations/BaseIntegration.js +1 -2
  33. package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
  34. package/dist/lib/Steps/Integrations/Cordova.js +14 -10
  35. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  36. package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
  37. package/dist/lib/Steps/Integrations/Electron.js +1 -1
  38. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  39. package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
  40. package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
  41. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  42. package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
  43. package/dist/lib/Steps/PromptForParameters.js.map +1 -1
  44. package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
  45. package/dist/lib/Steps/SentryProjectSelector.js +1 -1
  46. package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
  47. package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
  48. package/dist/lib/Steps/WaitForSentry.js +4 -4
  49. package/dist/lib/Steps/WaitForSentry.js.map +1 -1
  50. package/dist/lib/Types.d.ts +14 -0
  51. package/dist/lib/Types.js +3 -0
  52. package/dist/lib/Types.js.map +1 -0
  53. package/dist/lib/__tests__/Env.js +6 -13
  54. package/dist/lib/__tests__/Env.js.map +1 -1
  55. package/dist/src/android/android-wizard.js +15 -12
  56. package/dist/src/android/android-wizard.js.map +1 -1
  57. package/dist/src/android/code-tools.js +1 -1
  58. package/dist/src/android/code-tools.js.map +1 -1
  59. package/dist/src/android/gradle.js +4 -4
  60. package/dist/src/android/gradle.js.map +1 -1
  61. package/dist/src/android/manifest.js +1 -1
  62. package/dist/src/android/manifest.js.map +1 -1
  63. package/dist/src/apple/apple-wizard.d.ts +2 -2
  64. package/dist/src/apple/apple-wizard.js +37 -118
  65. package/dist/src/apple/apple-wizard.js.map +1 -1
  66. package/dist/src/apple/check-installed-cli.d.ts +1 -0
  67. package/dist/src/apple/check-installed-cli.js +60 -0
  68. package/dist/src/apple/check-installed-cli.js.map +1 -0
  69. package/dist/src/apple/cocoapod.js +1 -1
  70. package/dist/src/apple/cocoapod.js.map +1 -1
  71. package/dist/src/apple/code-tools.js +1 -1
  72. package/dist/src/apple/code-tools.js.map +1 -1
  73. package/dist/src/apple/configure-fastlane.d.ts +5 -0
  74. package/dist/src/apple/configure-fastlane.js +66 -0
  75. package/dist/src/apple/configure-fastlane.js.map +1 -0
  76. package/dist/src/apple/fastlane.d.ts +1 -1
  77. package/dist/src/apple/fastlane.js +5 -5
  78. package/dist/src/apple/fastlane.js.map +1 -1
  79. package/dist/src/apple/lookup-xcode-project.d.ts +7 -0
  80. package/dist/src/apple/lookup-xcode-project.js +98 -0
  81. package/dist/src/apple/lookup-xcode-project.js.map +1 -0
  82. package/dist/src/apple/options.d.ts +4 -0
  83. package/dist/src/apple/options.js +3 -0
  84. package/dist/src/apple/options.js.map +1 -0
  85. package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
  86. package/dist/src/apple/search-xcode-project-at-path.js +70 -0
  87. package/dist/src/apple/search-xcode-project-at-path.js.map +1 -0
  88. package/dist/src/apple/xcode-manager.js +1 -1
  89. package/dist/src/apple/xcode-manager.js.map +1 -1
  90. package/dist/src/flutter/code-tools.js +3 -3
  91. package/dist/src/flutter/code-tools.js.map +1 -1
  92. package/dist/src/flutter/flutter-wizard.js +21 -15
  93. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  94. package/dist/src/flutter/templates.js +4 -4
  95. package/dist/src/flutter/templates.js.map +1 -1
  96. package/dist/src/nextjs/nextjs-wizard.js +118 -67
  97. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  98. package/dist/src/nextjs/templates.d.ts +11 -3
  99. package/dist/src/nextjs/templates.js +193 -71
  100. package/dist/src/nextjs/templates.js.map +1 -1
  101. package/dist/src/nuxt/nuxt-wizard.js +21 -16
  102. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  103. package/dist/src/nuxt/sdk-example.js +3 -3
  104. package/dist/src/nuxt/sdk-example.js.map +1 -1
  105. package/dist/src/nuxt/sdk-setup.js +9 -9
  106. package/dist/src/nuxt/sdk-setup.js.map +1 -1
  107. package/dist/src/nuxt/templates.js +173 -58
  108. package/dist/src/nuxt/templates.js.map +1 -1
  109. package/dist/src/nuxt/utils.js +6 -3
  110. package/dist/src/nuxt/utils.js.map +1 -1
  111. package/dist/src/react-native/expo-env-file.js +1 -1
  112. package/dist/src/react-native/expo-env-file.js.map +1 -1
  113. package/dist/src/react-native/expo-metro.js +4 -4
  114. package/dist/src/react-native/expo-metro.js.map +1 -1
  115. package/dist/src/react-native/expo.js +4 -4
  116. package/dist/src/react-native/expo.js.map +1 -1
  117. package/dist/src/react-native/javascript.js +7 -7
  118. package/dist/src/react-native/javascript.js.map +1 -1
  119. package/dist/src/react-native/metro.js +8 -8
  120. package/dist/src/react-native/metro.js.map +1 -1
  121. package/dist/src/react-native/react-native-wizard.d.ts +1 -1
  122. package/dist/src/react-native/react-native-wizard.js +36 -31
  123. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  124. package/dist/src/react-native/uninstall.js +8 -5
  125. package/dist/src/react-native/uninstall.js.map +1 -1
  126. package/dist/src/react-native/xcode.d.ts +2 -1
  127. package/dist/src/react-native/xcode.js +1 -2
  128. package/dist/src/react-native/xcode.js.map +1 -1
  129. package/dist/src/remix/codemods/handle-error.js +4 -1
  130. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  131. package/dist/src/remix/remix-wizard.js +23 -18
  132. package/dist/src/remix/remix-wizard.js.map +1 -1
  133. package/dist/src/remix/sdk-example.js +163 -64
  134. package/dist/src/remix/sdk-example.js.map +1 -1
  135. package/dist/src/remix/sdk-setup.js +11 -7
  136. package/dist/src/remix/sdk-setup.js.map +1 -1
  137. package/dist/src/run.d.ts +3 -1
  138. package/dist/src/run.js +29 -9
  139. package/dist/src/run.js.map +1 -1
  140. package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
  141. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  142. package/dist/src/sourcemaps/tools/angular.js +3 -3
  143. package/dist/src/sourcemaps/tools/angular.js.map +1 -1
  144. package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
  145. package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
  146. package/dist/src/sourcemaps/tools/esbuild.js +6 -6
  147. package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
  148. package/dist/src/sourcemaps/tools/nextjs.js +5 -5
  149. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  150. package/dist/src/sourcemaps/tools/remix.js +4 -4
  151. package/dist/src/sourcemaps/tools/remix.js.map +1 -1
  152. package/dist/src/sourcemaps/tools/rollup.js +6 -6
  153. package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
  154. package/dist/src/sourcemaps/tools/sentry-cli.js +23 -16
  155. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  156. package/dist/src/sourcemaps/tools/tsc.js +6 -6
  157. package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
  158. package/dist/src/sourcemaps/tools/vite.js +12 -12
  159. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  160. package/dist/src/sourcemaps/tools/webpack.js +10 -10
  161. package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
  162. package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
  163. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  164. package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
  165. package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
  166. package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
  167. package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
  168. package/dist/src/sveltekit/sdk-example.js +1 -1
  169. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  170. package/dist/src/sveltekit/sdk-setup.js +15 -14
  171. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  172. package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
  173. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  174. package/dist/src/sveltekit/templates.js +126 -37
  175. package/dist/src/sveltekit/templates.js.map +1 -1
  176. package/dist/src/telemetry.js +11 -0
  177. package/dist/src/telemetry.js.map +1 -1
  178. package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +54 -15
  179. package/dist/src/utils/{clack-utils.js → clack/index.js} +107 -24
  180. package/dist/src/utils/clack/index.js.map +1 -0
  181. package/dist/src/utils/debug.js +1 -1
  182. package/dist/src/utils/debug.js.map +1 -1
  183. package/dist/src/utils/find-files-with-extension.d.ts +1 -0
  184. package/dist/src/utils/find-files-with-extension.js +39 -0
  185. package/dist/src/utils/find-files-with-extension.js.map +1 -0
  186. package/dist/src/utils/package-manager.d.ts +6 -1
  187. package/dist/src/utils/package-manager.js +32 -27
  188. package/dist/src/utils/package-manager.js.map +1 -1
  189. package/dist/src/utils/sentrycli-utils.js +0 -1
  190. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  191. package/dist/src/utils/types.d.ts +4 -0
  192. package/dist/src/utils/types.js.map +1 -1
  193. package/dist/src/version.d.ts +1 -1
  194. package/dist/src/version.js +1 -1
  195. package/dist/src/version.js.map +1 -1
  196. package/dist/test/android/code-tools.test.js +0 -1
  197. package/dist/test/android/code-tools.test.js.map +1 -1
  198. package/dist/test/apple/cocoapod.test.js +1 -1
  199. package/dist/test/apple/cocoapod.test.js.map +1 -1
  200. package/dist/test/apple/code-tools.test.js +1 -1
  201. package/dist/test/apple/code-tools.test.js.map +1 -1
  202. package/dist/test/apple/fastfile.test.js +1 -1
  203. package/dist/test/apple/fastfile.test.js.map +1 -1
  204. package/dist/test/apple/xcode-manager.test.js +26 -2
  205. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  206. package/dist/test/flutter/code-tools.test.js +0 -2
  207. package/dist/test/flutter/code-tools.test.js.map +1 -1
  208. package/dist/test/flutter/templates.test.js +23 -23
  209. package/dist/test/flutter/templates.test.js.map +1 -1
  210. package/dist/test/nextjs/templates.test.js +127 -133
  211. package/dist/test/nextjs/templates.test.js.map +1 -1
  212. package/dist/test/react-native/expo-metro.test.js +1 -1
  213. package/dist/test/react-native/expo-metro.test.js.map +1 -1
  214. package/dist/test/react-native/javascript.test.js +1 -1
  215. package/dist/test/react-native/javascript.test.js.map +1 -1
  216. package/dist/test/react-native/metro.test.js +1 -1
  217. package/dist/test/react-native/metro.test.js.map +1 -1
  218. package/dist/test/sourcemaps/tools/sentry-cli.test.js +14 -3
  219. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  220. package/dist/test/utils/{clack-utils.test.js → clack/index.test.js} +131 -41
  221. package/dist/test/utils/clack/index.test.js.map +1 -0
  222. package/dist/test/utils/package-manager.test.d.ts +1 -0
  223. package/dist/test/utils/package-manager.test.js +29 -0
  224. package/dist/test/utils/package-manager.test.js.map +1 -0
  225. package/package.json +1 -1
  226. package/dist/src/utils/clack-utils.js.map +0 -1
  227. package/dist/test/utils/clack-utils.test.js.map +0 -1
  228. /package/dist/test/utils/{clack-utils.test.d.ts → clack/index.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"create-react-app.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/create-react-app.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAyE;AACzE,6DAAmC;AACnC,yDAA2D;AAEpD,KAAK,UAAU,mCAAmC;IACvD,MAAM,IAAA,8BAAgB,EACpB,iBAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,sLAAsL;QAC/L,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,YAAY;gBACnB,IAAI,EAAE,8DAA8D;gBACpE,KAAK,EAAE,IAAI;aACZ;SACF;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,kFAcC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport { abortIfCancelled } from '../../utils/clack-utils';\n\nexport async function configureCRASourcemapGenerationFlow(): Promise<void> {\n await abortIfCancelled(\n clack.select({\n message: `Verify that you are generating source maps when building your React app.\\nGenerally this should already happen unless you set the GENERATE_SOURCEMAPS environment variable to false.`,\n options: [\n {\n label: 'I checked!',\n hint: 'My build output folder contains .js.map files after a build.',\n value: true,\n },\n ],\n initialValue: true,\n }),\n );\n}\n"]}
1
+ {"version":3,"file":"create-react-app.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/create-react-app.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,6CAAqD;AAE9C,KAAK,UAAU,mCAAmC;IACvD,MAAM,IAAA,wBAAgB,EACpB,iBAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,sLAAsL;QAC/L,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,YAAY;gBACnB,IAAI,EAAE,8DAA8D;gBACpE,KAAK,EAAE,IAAI;aACZ;SACF;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,kFAcC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport { abortIfCancelled } from '../../utils/clack';\n\nexport async function configureCRASourcemapGenerationFlow(): Promise<void> {\n await abortIfCancelled(\n clack.select({\n message: `Verify that you are generating source maps when building your React app.\\nGenerally this should already happen unless you set the GENERATE_SOURCEMAPS environment variable to false.`,\n options: [\n {\n label: 'I checked!',\n hint: 'My build output folder contains .js.map files after a build.',\n value: true,\n },\n ],\n initialValue: true,\n }),\n );\n}\n"]}
@@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.configureEsbuildPlugin = void 0;
30
- // @ts-ignore - clack is ESM and TS complains about that. It works though
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
31
  const prompts_1 = __importStar(require("@clack/prompts"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
- const clack_utils_1 = require("../../utils/clack-utils");
33
+ const clack_1 = require("../../utils/clack");
34
34
  const package_json_1 = require("../../utils/package-json");
35
35
  const getCodeSnippet = (options) => chalk_1.default.gray(`
36
36
  ${chalk_1.default.greenBright('const { sentryEsbuildPlugin } = require("@sentry/esbuild-plugin");')}
@@ -48,20 +48,20 @@ require("esbuild").build({
48
48
  });
49
49
  `);
50
50
  const configureEsbuildPlugin = async (options) => {
51
- await (0, clack_utils_1.installPackage)({
51
+ await (0, clack_1.installPackage)({
52
52
  packageName: '@sentry/esbuild-plugin',
53
- alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/esbuild-plugin', await (0, clack_utils_1.getPackageDotJson)()),
53
+ alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/esbuild-plugin', await (0, clack_1.getPackageDotJson)()),
54
54
  });
55
55
  prompts_1.default.log.step(`Add the following code to your esbuild config:`);
56
56
  // Intentially logging directly to console here so that the code can be copied/pasted directly
57
57
  // eslint-disable-next-line no-console
58
58
  console.log(getCodeSnippet(options));
59
- await (0, clack_utils_1.abortIfCancelled)((0, prompts_1.select)({
59
+ await (0, clack_1.abortIfCancelled)((0, prompts_1.select)({
60
60
  message: 'Did you copy the snippet above?',
61
61
  options: [{ label: 'Yes, continue!', value: true }],
62
62
  initialValue: true,
63
63
  }));
64
- await (0, clack_utils_1.addDotEnvSentryBuildPluginFile)(options.authToken);
64
+ await (0, clack_1.addDotEnvSentryBuildPluginFile)(options.authToken);
65
65
  };
66
66
  exports.configureEsbuildPlugin = configureEsbuildPlugin;
67
67
  //# sourceMappingURL=esbuild.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/esbuild.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,0DAA+C;AAC/C,kDAA0B;AAC1B,yDAKiC;AACjC,2DAA+D;AAO/D,MAAM,cAAc,GAAG,CAAC,OAAgD,EAAE,EAAE,CAC1E,eAAK,CAAC,IAAI,CAAC;EACX,eAAK,CAAC,WAAW,CACjB,oEAAoE,CACrE;;;IAGG,eAAK,CAAC,WAAW,CACjB,6DAA6D,CAC9D;;;MAGG,eAAK,CAAC,WAAW,CAAC;;cAEV,OAAO,CAAC,OAAO;kBACX,OAAO,CAAC,WAAW,KAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAC1D;QACI,CAAC;;;CAGR,CAAC,CAAC;AAEI,MAAM,sBAAsB,GACjC,KAAK,EAAE,OAAO,EAAE,EAAE;IAChB,MAAM,IAAA,4BAAc,EAAC;QACnB,WAAW,EAAE,wBAAwB;QACrC,gBAAgB,EAAE,IAAA,kCAAmB,EACnC,wBAAwB,EACxB,MAAM,IAAA,+BAAiB,GAAE,CAC1B;KACF,CAAC,CAAC;IAEH,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAEjE,8FAA8F;IAC9F,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAErC,MAAM,IAAA,8BAAgB,EACpB,IAAA,gBAAM,EAAC;QACL,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;IAEF,MAAM,IAAA,4CAA8B,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC1D,CAAC,CAAC;AAzBS,QAAA,sBAAsB,0BAyB/B","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack, { select } from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack-utils';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.gray(`\n${chalk.greenBright(\n 'const { sentryEsbuildPlugin } = require(\"@sentry/esbuild-plugin\");',\n)}\n\nrequire(\"esbuild\").build({\n ${chalk.greenBright(\n 'sourcemap: true, // Source map generation must be turned on',\n )}\n plugins: [\n // Put the Sentry esbuild plugin after all other plugins\n ${chalk.greenBright(`sentryEsbuildPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n }),`)}\n ],\n});\n`);\n\nexport const configureEsbuildPlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/esbuild-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/esbuild-plugin',\n await getPackageDotJson(),\n ),\n });\n\n clack.log.step(`Add the following code to your esbuild config:`);\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await abortIfCancelled(\n select({\n message: 'Did you copy the snippet above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n"]}
1
+ {"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/esbuild.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,0DAA+C;AAC/C,kDAA0B;AAC1B,6CAK2B;AAC3B,2DAA+D;AAO/D,MAAM,cAAc,GAAG,CAAC,OAAgD,EAAE,EAAE,CAC1E,eAAK,CAAC,IAAI,CAAC;EACX,eAAK,CAAC,WAAW,CACjB,oEAAoE,CACrE;;;IAGG,eAAK,CAAC,WAAW,CACjB,6DAA6D,CAC9D;;;MAGG,eAAK,CAAC,WAAW,CAAC;;cAEV,OAAO,CAAC,OAAO;kBACX,OAAO,CAAC,WAAW,KAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAC1D;QACI,CAAC;;;CAGR,CAAC,CAAC;AAEI,MAAM,sBAAsB,GACjC,KAAK,EAAE,OAAO,EAAE,EAAE;IAChB,MAAM,IAAA,sBAAc,EAAC;QACnB,WAAW,EAAE,wBAAwB;QACrC,gBAAgB,EAAE,IAAA,kCAAmB,EACnC,wBAAwB,EACxB,MAAM,IAAA,yBAAiB,GAAE,CAC1B;KACF,CAAC,CAAC;IAEH,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAEjE,8FAA8F;IAC9F,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAErC,MAAM,IAAA,wBAAgB,EACpB,IAAA,gBAAM,EAAC;QACL,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;IAEF,MAAM,IAAA,sCAA8B,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC1D,CAAC,CAAC;AAzBS,QAAA,sBAAsB,0BAyB/B","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack, { select } from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.gray(`\n${chalk.greenBright(\n 'const { sentryEsbuildPlugin } = require(\"@sentry/esbuild-plugin\");',\n)}\n\nrequire(\"esbuild\").build({\n ${chalk.greenBright(\n 'sourcemap: true, // Source map generation must be turned on',\n )}\n plugins: [\n // Put the Sentry esbuild plugin after all other plugins\n ${chalk.greenBright(`sentryEsbuildPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n }),`)}\n ],\n});\n`);\n\nexport const configureEsbuildPlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/esbuild-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/esbuild-plugin',\n await getPackageDotJson(),\n ),\n });\n\n clack.log.step(`Add the following code to your esbuild config:`);\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await abortIfCancelled(\n select({\n message: 'Did you copy the snippet above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n"]}
@@ -27,12 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.configureNextJsSourceMapsUpload = void 0;
30
- // @ts-ignore - clack is ESM and TS complains about that. It works though
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
31
  const clack = __importStar(require("@clack/prompts"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
33
  const nextjs_wizard_1 = require("../../nextjs/nextjs-wizard");
34
34
  const telemetry_1 = require("../../telemetry");
35
- const clack_utils_1 = require("../../utils/clack-utils");
35
+ const clack_1 = require("../../utils/clack");
36
36
  const Sentry = __importStar(require("@sentry/node"));
37
37
  const getCodeSnippet = (options) => chalk_1.default.grey(`
38
38
  ${chalk_1.default.greenBright('const { withSentryConfig } = require("@sentry/nextjs");')}
@@ -63,7 +63,7 @@ const configureNextJsSourceMapsUpload = async (options, wizardOptions) => {
63
63
  But don't worry, we can redirect you to the wizard now!
64
64
 
65
65
  In case you already tried the wizard, we can also show you how to configure your ${chalk_1.default.cyan('next.config.js')} file manually instead.`);
66
- const shouldRedirect = await (0, clack_utils_1.abortIfCancelled)(clack.select({
66
+ const shouldRedirect = await (0, clack_1.abortIfCancelled)(clack.select({
67
67
  message: 'Do you want to run the Sentry Wizard for Next.JS now?',
68
68
  options: [
69
69
  {
@@ -88,12 +88,12 @@ In case you already tried the wizard, we can also show you how to configure your
88
88
  // Intentionally logging directly to console here
89
89
  // eslint-disable-next-line no-console
90
90
  console.log(getCodeSnippet(options));
91
- await (0, telemetry_1.traceStep)('nextjs-manual-nextconfigjs', () => (0, clack_utils_1.abortIfCancelled)(clack.select({
91
+ await (0, telemetry_1.traceStep)('nextjs-manual-nextconfigjs', () => (0, clack_1.abortIfCancelled)(clack.select({
92
92
  message: 'Did you copy the code above?',
93
93
  options: [{ label: 'Yes, continue!', value: true }],
94
94
  initialValue: true,
95
95
  })));
96
- await (0, telemetry_1.traceStep)('nextjs-manual-sentryclirc', () => (0, clack_utils_1.addDotEnvSentryBuildPluginFile)(options.authToken));
96
+ await (0, telemetry_1.traceStep)('nextjs-manual-sentryclirc', () => (0, clack_1.addDotEnvSentryBuildPluginFile)(options.authToken));
97
97
  }
98
98
  clack.log
99
99
  .info(`In case you still run into problems, check out our docs to further debug your setup:
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/nextjs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,sDAAwC;AACxC,kDAA0B;AAC1B,8DAA6D;AAC7D,+CAA4C;AAC5C,yDAGiC;AAKjC,qDAA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QACL,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,kCAAkC,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAClE,CAAC;QAEF,iDAAiD;QACjD,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QAErC,MAAM,IAAA,qBAAS,EAAC,4BAA4B,EAAE,GAAG,EAAE,CACjD,IAAA,8BAAgB,EACd,KAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,8BAA8B;YACvC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACnD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CACF,CAAC;QAEF,MAAM,IAAA,qBAAS,EAAC,2BAA2B,EAAE,GAAG,EAAE,CAChD,IAAA,4CAA8B,EAAC,OAAO,CAAC,SAAS,CAAC,CAClD,CAAC;KACH;IAED,KAAK,CAAC,GAAG;SACN,IAAI,CAAC;;;;;;2EAMiE,CAAC,CAAC;AAC7E,CAAC,CAAC;AArEW,QAAA,+BAA+B,mCAqE1C","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 { runNextjsWizard } from '../../nextjs/nextjs-wizard';\nimport { traceStep } from '../../telemetry';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n} from '../../utils/clack-utils';\nimport type { WizardOptions } from '../../utils/types';\n\nimport type { SourceMapUploadToolConfigurationOptions } from './types';\n\nimport * as Sentry from '@sentry/node';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.grey(`\n ${chalk.greenBright(\n 'const { withSentryConfig } = require(\"@sentry/nextjs\");',\n )}\n\n const nextConfig = {\n // your existing next config\n };\n\n ${chalk.greenBright(`const sentryWebpackPluginOptions = {\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n };`)}\n\n ${chalk.greenBright(`const sentryOptions = {\n // Upload additional client files (increases upload size)\n widenClientFileUpload: true,\n };`)}\n\n ${chalk.greenBright(`module.exports = withSentryConfig(\n nextConfig,\n sentryWebpackPluginOptions,\n sentryOptions\n );`)}\n`);\n\nexport const configureNextJsSourceMapsUpload = async (\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n) => {\n clack.log\n .info(`Source Maps upload for Next.js is configured automatically by default if you run the Sentry Wizard for Next.JS.\nBut don't worry, we can redirect you to the wizard now!\n\nIn case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(\n 'next.config.js',\n )} file manually instead.`);\n\n const shouldRedirect: boolean = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run the Sentry Wizard for Next.JS now?',\n options: [\n {\n label: 'Yes, run the wizard!',\n value: true,\n hint: 'The wizard can also configure your SDK setup',\n },\n {\n label: 'No, show me how to configure it manually',\n value: false,\n },\n ],\n }),\n );\n\n Sentry.setTag('redirect-nextjs-wizard', shouldRedirect);\n\n if (shouldRedirect) {\n await traceStep('run-nextjs-wizard', () => runNextjsWizard(wizardOptions));\n clack.intro('Sentry Source Maps Upload Configuration Wizard');\n clack.log.info(\n \"Welcome back to the Source Maps wizard - we're almost done ;)\",\n );\n } else {\n clack.log.info(\n `Add the following code to your ${chalk.cyan('next.config.js')}:`,\n );\n\n // Intentionally logging directly to console here\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await traceStep('nextjs-manual-nextconfigjs', () =>\n abortIfCancelled(\n clack.select({\n message: 'Did you copy the code above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n ),\n );\n\n await traceStep('nextjs-manual-sentryclirc', () =>\n addDotEnvSentryBuildPluginFile(options.authToken),\n );\n }\n\n clack.log\n .info(`In case you still run into problems, check out our docs to further debug your setup:\n\nUploading Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-source-maps\n\nTroubleshooting Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/`);\n};\n"]}
1
+ {"version":3,"file":"nextjs.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/nextjs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,8DAA6D;AAC7D,+CAA4C;AAC5C,6CAG2B;AAK3B,qDAAuC;AAEvC,MAAM,cAAc,GAAG,CAAC,OAAgD,EAAE,EAAE,CAC1E,eAAK,CAAC,IAAI,CAAC;IACT,eAAK,CAAC,WAAW,CACjB,yDAAyD,CAC1D;;;;;;IAMC,eAAK,CAAC,WAAW,CAAC;YACV,OAAO,CAAC,OAAO;gBACX,OAAO,CAAC,WAAW,KAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EACxD;KACG,CAAC;;IAEF,eAAK,CAAC,WAAW,CAAC;;;KAGjB,CAAC;;IAEF,eAAK,CAAC,WAAW,CAAC;;;;KAIjB,CAAC;CACL,CAAC,CAAC;AAEI,MAAM,+BAA+B,GAAG,KAAK,EAClD,OAAgD,EAChD,aAA4B,EAC5B,EAAE;IACF,KAAK,CAAC,GAAG;SACN,IAAI,CAAC;;;mFAGyE,eAAK,CAAC,IAAI,CACzF,gBAAgB,CACjB,yBAAyB,CAAC,CAAC;IAE5B,MAAM,cAAc,GAAY,MAAM,IAAA,wBAAgB,EACpD,KAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,uDAAuD;QAChE,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,sBAAsB;gBAC7B,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,8CAA8C;aACrD;YACD;gBACE,KAAK,EAAE,0CAA0C;gBACjD,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;IAExD,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,qBAAS,EAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAA,+BAAe,EAAC,aAAa,CAAC,CAAC,CAAC;QAC3E,KAAK,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC9D,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,+DAA+D,CAChE,CAAC;KACH;SAAM;QACL,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,kCAAkC,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAClE,CAAC;QAEF,iDAAiD;QACjD,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QAErC,MAAM,IAAA,qBAAS,EAAC,4BAA4B,EAAE,GAAG,EAAE,CACjD,IAAA,wBAAgB,EACd,KAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,8BAA8B;YACvC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACnD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CACF,CAAC;QAEF,MAAM,IAAA,qBAAS,EAAC,2BAA2B,EAAE,GAAG,EAAE,CAChD,IAAA,sCAA8B,EAAC,OAAO,CAAC,SAAS,CAAC,CAClD,CAAC;KACH;IAED,KAAK,CAAC,GAAG;SACN,IAAI,CAAC;;;;;;2EAMiE,CAAC,CAAC;AAC7E,CAAC,CAAC;AArEW,QAAA,+BAA+B,mCAqE1C","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { runNextjsWizard } from '../../nextjs/nextjs-wizard';\nimport { traceStep } from '../../telemetry';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n} from '../../utils/clack';\nimport type { WizardOptions } from '../../utils/types';\n\nimport type { SourceMapUploadToolConfigurationOptions } from './types';\n\nimport * as Sentry from '@sentry/node';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.grey(`\n ${chalk.greenBright(\n 'const { withSentryConfig } = require(\"@sentry/nextjs\");',\n )}\n\n const nextConfig = {\n // your existing next config\n };\n\n ${chalk.greenBright(`const sentryWebpackPluginOptions = {\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n };`)}\n\n ${chalk.greenBright(`const sentryOptions = {\n // Upload additional client files (increases upload size)\n widenClientFileUpload: true,\n };`)}\n\n ${chalk.greenBright(`module.exports = withSentryConfig(\n nextConfig,\n sentryWebpackPluginOptions,\n sentryOptions\n );`)}\n`);\n\nexport const configureNextJsSourceMapsUpload = async (\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n) => {\n clack.log\n .info(`Source Maps upload for Next.js is configured automatically by default if you run the Sentry Wizard for Next.JS.\nBut don't worry, we can redirect you to the wizard now!\n\nIn case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(\n 'next.config.js',\n )} file manually instead.`);\n\n const shouldRedirect: boolean = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run the Sentry Wizard for Next.JS now?',\n options: [\n {\n label: 'Yes, run the wizard!',\n value: true,\n hint: 'The wizard can also configure your SDK setup',\n },\n {\n label: 'No, show me how to configure it manually',\n value: false,\n },\n ],\n }),\n );\n\n Sentry.setTag('redirect-nextjs-wizard', shouldRedirect);\n\n if (shouldRedirect) {\n await traceStep('run-nextjs-wizard', () => runNextjsWizard(wizardOptions));\n clack.intro('Sentry Source Maps Upload Configuration Wizard');\n clack.log.info(\n \"Welcome back to the Source Maps wizard - we're almost done ;)\",\n );\n } else {\n clack.log.info(\n `Add the following code to your ${chalk.cyan('next.config.js')}:`,\n );\n\n // Intentionally logging directly to console here\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await traceStep('nextjs-manual-nextconfigjs', () =>\n abortIfCancelled(\n clack.select({\n message: 'Did you copy the code above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n ),\n );\n\n await traceStep('nextjs-manual-sentryclirc', () =>\n addDotEnvSentryBuildPluginFile(options.authToken),\n );\n }\n\n clack.log\n .info(`In case you still run into problems, check out our docs to further debug your setup:\n\nUploading Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-source-maps\n\nTroubleshooting Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/`);\n};\n"]}
@@ -27,19 +27,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.configureRemixSourceMapsUpload = void 0;
30
- // @ts-ignore - clack is ESM and TS complains about that. It works though
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
31
  const clack = __importStar(require("@clack/prompts"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
33
  const remix_wizard_1 = require("../../remix/remix-wizard");
34
34
  const telemetry_1 = require("../../telemetry");
35
- const clack_utils_1 = require("../../utils/clack-utils");
35
+ const clack_1 = require("../../utils/clack");
36
36
  const Sentry = __importStar(require("@sentry/node"));
37
37
  const configureRemixSourceMapsUpload = async (options, wizardOptions) => {
38
38
  clack.log
39
39
  .info(`Source Maps upload for Remix is configured automatically by default if you run the Sentry Wizard for Remix.
40
40
  But don't worry, we can redirect you to the wizard now!
41
41
  In case you already tried the wizard, we can also show you how to configure your ${chalk_1.default.cyan('remix.config.js')} file manually instead.`);
42
- const shouldRedirect = await (0, clack_utils_1.abortIfCancelled)(clack.select({
42
+ const shouldRedirect = await (0, clack_1.abortIfCancelled)(clack.select({
43
43
  message: 'Do you want to run the Sentry Wizard for Remix now?',
44
44
  options: [
45
45
  {
@@ -69,7 +69,7 @@ In case you already tried the wizard, we can also show you how to configure your
69
69
 
70
70
  To see all available options for ${chalk_1.default.cyan('sentry-upload-sourcemaps')}, run ${chalk_1.default.cyan('sentry-upload-sourcemaps --help')}
71
71
  `);
72
- await (0, clack_utils_1.abortIfCancelled)(clack.select({
72
+ await (0, clack_1.abortIfCancelled)(clack.select({
73
73
  message: 'Did you finish configuring your build and prod scripts?',
74
74
  options: [{ label: 'Yes, continue!', value: true }],
75
75
  initialValue: true,
@@ -1 +1 @@
1
- {"version":3,"file":"remix.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/remix.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,sDAAwC;AACxC,kDAA0B;AAC1B,2DAA0D;AAC1D,+CAA4C;AAC5C,yDAA2D;AAI3D,qDAAuC;AAEhC,MAAM,8BAA8B,GAAG,KAAK,EACjD,OAAgD,EAChD,aAA4B,EAC5B,EAAE;IACF,KAAK,CAAC,GAAG;SACN,IAAI,CAAC;;mFAEyE,eAAK,CAAC,IAAI,CACzF,iBAAiB,CAClB,yBAAyB,CAAC,CAAC;IAE5B,MAAM,cAAc,GAAY,MAAM,IAAA,8BAAgB,EACpD,KAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,qDAAqD;QAC9D,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,sBAAsB;gBAC7B,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,8CAA8C;aACrD;YACD;gBACE,KAAK,EAAE,0CAA0C;gBACjD,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,qBAAS,EAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAA,6BAAc,EAAC,aAAa,CAAC,CAAC,CAAC;QACzE,KAAK,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC9D,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,+DAA+D,CAChE,CAAC;KACH;SAAM;QACL,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,uBAAuB,eAAK,CAAC,IAAI,CAC/B,yBAAyB,CAC1B,wCAAwC,eAAK,CAAC,IAAI,CACjD,0BAA0B,CAC3B,YAAY,CACd,CAAC;QAEF,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAe,eAAK,CAAC,IAAI,CACvB,0BAA0B,CAC3B,4BAA4B,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,CACrE,CAAC;QAEF,8FAA8F;QAC9F,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;;mCAEgB,eAAK,CAAC,IAAI,CACvC,0BAA0B,CAC3B,SAAS,eAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC;CAC1D,CAAC,CAAC;QAEC,MAAM,IAAA,8BAAgB,EACpB,KAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,yDAAyD;YAClE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACnD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;KACH;AACH,CAAC,CAAC;AAtEW,QAAA,8BAA8B,kCAsEzC;AAEF,MAAM,WAAW,GAAG,eAAK,CAAC,IAAI,CAAC;;IAE3B,eAAK,CAAC,WAAW,CACjB,gEAAgE,CACjE;;CAEF,CAAC,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 { runRemixWizard } from '../../remix/remix-wizard';\nimport { traceStep } from '../../telemetry';\nimport { abortIfCancelled } from '../../utils/clack-utils';\nimport type { WizardOptions } from '../../utils/types';\nimport type { SourceMapUploadToolConfigurationOptions } from './types';\n\nimport * as Sentry from '@sentry/node';\n\nexport const configureRemixSourceMapsUpload = async (\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n) => {\n clack.log\n .info(`Source Maps upload for Remix is configured automatically by default if you run the Sentry Wizard for Remix.\nBut don't worry, we can redirect you to the wizard now!\nIn case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(\n 'remix.config.js',\n )} file manually instead.`);\n\n const shouldRedirect: boolean = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run the Sentry Wizard for Remix now?',\n options: [\n {\n label: 'Yes, run the wizard!',\n value: true,\n hint: 'The wizard can also configure your SDK setup',\n },\n {\n label: 'No, show me how to configure it manually',\n value: false,\n },\n ],\n }),\n );\n\n Sentry.setTag('redirect-remix-wizard', shouldRedirect);\n\n if (shouldRedirect) {\n await traceStep('run-remix-wizard', () => runRemixWizard(wizardOptions));\n clack.intro('Sentry Source Maps Upload Configuration Wizard');\n clack.log.info(\n \"Welcome back to the Source Maps wizard - we're almost done ;)\",\n );\n } else {\n clack.log.step(\n `Build your app with ${chalk.cyan(\n 'remix build --sourcemap',\n )}, then upload your source maps using ${chalk.cyan(\n 'sentry-upload-sourcemaps',\n )} cli tool.`,\n );\n\n clack.log.step(\n `You can add ${chalk.cyan(\n 'sentry-upload-sourcemaps',\n )} to your build script in ${chalk.cyan('package.json')} like this:`,\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(codeSnippet);\n\n clack.log.step(`or run it manually after building your app.\n\nTo see all available options for ${chalk.cyan(\n 'sentry-upload-sourcemaps',\n )}, run ${chalk.cyan('sentry-upload-sourcemaps --help')}\n`);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you finish configuring your build and prod scripts?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n }\n};\n\nconst codeSnippet = chalk.gray(`\n\"scripts\": {\n ${chalk.greenBright(\n '\"build\": \"remix build --sourcemap && sentry-upload-sourcemaps\"',\n )};\n}\n`);\n"]}
1
+ {"version":3,"file":"remix.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/remix.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,2DAA0D;AAC1D,+CAA4C;AAC5C,6CAAqD;AAIrD,qDAAuC;AAEhC,MAAM,8BAA8B,GAAG,KAAK,EACjD,OAAgD,EAChD,aAA4B,EAC5B,EAAE;IACF,KAAK,CAAC,GAAG;SACN,IAAI,CAAC;;mFAEyE,eAAK,CAAC,IAAI,CACzF,iBAAiB,CAClB,yBAAyB,CAAC,CAAC;IAE5B,MAAM,cAAc,GAAY,MAAM,IAAA,wBAAgB,EACpD,KAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,qDAAqD;QAC9D,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,sBAAsB;gBAC7B,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,8CAA8C;aACrD;YACD;gBACE,KAAK,EAAE,0CAA0C;gBACjD,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,qBAAS,EAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAA,6BAAc,EAAC,aAAa,CAAC,CAAC,CAAC;QACzE,KAAK,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC9D,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,+DAA+D,CAChE,CAAC;KACH;SAAM;QACL,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,uBAAuB,eAAK,CAAC,IAAI,CAC/B,yBAAyB,CAC1B,wCAAwC,eAAK,CAAC,IAAI,CACjD,0BAA0B,CAC3B,YAAY,CACd,CAAC;QAEF,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAe,eAAK,CAAC,IAAI,CACvB,0BAA0B,CAC3B,4BAA4B,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,CACrE,CAAC;QAEF,8FAA8F;QAC9F,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;;mCAEgB,eAAK,CAAC,IAAI,CACvC,0BAA0B,CAC3B,SAAS,eAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC;CAC1D,CAAC,CAAC;QAEC,MAAM,IAAA,wBAAgB,EACpB,KAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,yDAAyD;YAClE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACnD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;KACH;AACH,CAAC,CAAC;AAtEW,QAAA,8BAA8B,kCAsEzC;AAEF,MAAM,WAAW,GAAG,eAAK,CAAC,IAAI,CAAC;;IAE3B,eAAK,CAAC,WAAW,CACjB,gEAAgE,CACjE;;CAEF,CAAC,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { runRemixWizard } from '../../remix/remix-wizard';\nimport { traceStep } from '../../telemetry';\nimport { abortIfCancelled } from '../../utils/clack';\nimport type { WizardOptions } from '../../utils/types';\nimport type { SourceMapUploadToolConfigurationOptions } from './types';\n\nimport * as Sentry from '@sentry/node';\n\nexport const configureRemixSourceMapsUpload = async (\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n) => {\n clack.log\n .info(`Source Maps upload for Remix is configured automatically by default if you run the Sentry Wizard for Remix.\nBut don't worry, we can redirect you to the wizard now!\nIn case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(\n 'remix.config.js',\n )} file manually instead.`);\n\n const shouldRedirect: boolean = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run the Sentry Wizard for Remix now?',\n options: [\n {\n label: 'Yes, run the wizard!',\n value: true,\n hint: 'The wizard can also configure your SDK setup',\n },\n {\n label: 'No, show me how to configure it manually',\n value: false,\n },\n ],\n }),\n );\n\n Sentry.setTag('redirect-remix-wizard', shouldRedirect);\n\n if (shouldRedirect) {\n await traceStep('run-remix-wizard', () => runRemixWizard(wizardOptions));\n clack.intro('Sentry Source Maps Upload Configuration Wizard');\n clack.log.info(\n \"Welcome back to the Source Maps wizard - we're almost done ;)\",\n );\n } else {\n clack.log.step(\n `Build your app with ${chalk.cyan(\n 'remix build --sourcemap',\n )}, then upload your source maps using ${chalk.cyan(\n 'sentry-upload-sourcemaps',\n )} cli tool.`,\n );\n\n clack.log.step(\n `You can add ${chalk.cyan(\n 'sentry-upload-sourcemaps',\n )} to your build script in ${chalk.cyan('package.json')} like this:`,\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(codeSnippet);\n\n clack.log.step(`or run it manually after building your app.\n\nTo see all available options for ${chalk.cyan(\n 'sentry-upload-sourcemaps',\n )}, run ${chalk.cyan('sentry-upload-sourcemaps --help')}\n`);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you finish configuring your build and prod scripts?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n }\n};\n\nconst codeSnippet = chalk.gray(`\n\"scripts\": {\n ${chalk.greenBright(\n '\"build\": \"remix build --sourcemap && sentry-upload-sourcemaps\"',\n )};\n}\n`);\n"]}
@@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.configureRollupPlugin = void 0;
30
- // @ts-ignore - clack is ESM and TS complains about that. It works though
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
31
  const prompts_1 = __importStar(require("@clack/prompts"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
- const clack_utils_1 = require("../../utils/clack-utils");
33
+ const clack_1 = require("../../utils/clack");
34
34
  const package_json_1 = require("../../utils/package-json");
35
35
  const getCodeSnippet = (options) => chalk_1.default.gray(`
36
36
  ${chalk_1.default.greenBright('import { sentryRollupPlugin } from "@sentry/rollup-plugin";')}
@@ -50,20 +50,20 @@ export default {
50
50
  };
51
51
  `);
52
52
  const configureRollupPlugin = async (options) => {
53
- await (0, clack_utils_1.installPackage)({
53
+ await (0, clack_1.installPackage)({
54
54
  packageName: '@sentry/rollup-plugin',
55
- alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/rollup-plugin', await (0, clack_utils_1.getPackageDotJson)()),
55
+ alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/rollup-plugin', await (0, clack_1.getPackageDotJson)()),
56
56
  });
57
57
  prompts_1.default.log.step(`Add the following code to your rollup config:`);
58
58
  // Intentionally logging directly to console here so that the code can be copied/pasted directly
59
59
  // eslint-disable-next-line no-console
60
60
  console.log(getCodeSnippet(options));
61
- await (0, clack_utils_1.abortIfCancelled)((0, prompts_1.select)({
61
+ await (0, clack_1.abortIfCancelled)((0, prompts_1.select)({
62
62
  message: 'Did you copy the snippet above?',
63
63
  options: [{ label: 'Yes, continue!', value: true }],
64
64
  initialValue: true,
65
65
  }));
66
- await (0, clack_utils_1.addDotEnvSentryBuildPluginFile)(options.authToken);
66
+ await (0, clack_1.addDotEnvSentryBuildPluginFile)(options.authToken);
67
67
  };
68
68
  exports.configureRollupPlugin = configureRollupPlugin;
69
69
  //# sourceMappingURL=rollup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,0DAA+C;AAC/C,kDAA0B;AAC1B,yDAKiC;AACjC,2DAA+D;AAO/D,MAAM,cAAc,GAAG,CAAC,OAAgD,EAAE,EAAE,CAC1E,eAAK,CAAC,IAAI,CAAC;EACX,eAAK,CAAC,WAAW,CACjB,6DAA6D,CAC9D;;;;MAIK,eAAK,CAAC,WAAW,CACjB,6DAA6D,CAC9D;;;;MAIC,eAAK,CAAC,WAAW,CAAC;;cAEV,OAAO,CAAC,OAAO;kBACX,OAAO,CAAC,WAAW,KAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAC1D;QACI,CAAC;;;CAGR,CAAC,CAAC;AAEI,MAAM,qBAAqB,GAChC,KAAK,EAAE,OAAO,EAAE,EAAE;IAChB,MAAM,IAAA,4BAAc,EAAC;QACnB,WAAW,EAAE,uBAAuB;QACpC,gBAAgB,EAAE,IAAA,kCAAmB,EACnC,uBAAuB,EACvB,MAAM,IAAA,+BAAiB,GAAE,CAC1B;KACF,CAAC,CAAC;IAEH,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAEhE,gGAAgG;IAChG,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAErC,MAAM,IAAA,8BAAgB,EACpB,IAAA,gBAAM,EAAC;QACL,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;IAEF,MAAM,IAAA,4CAA8B,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC1D,CAAC,CAAC;AAzBS,QAAA,qBAAqB,yBAyB9B","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack, { select } from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack-utils';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.gray(`\n${chalk.greenBright(\n 'import { sentryRollupPlugin } from \"@sentry/rollup-plugin\";',\n)}\n\nexport default {\n output: {\n ${chalk.greenBright(\n 'sourcemap: true, // Source map generation must be turned on',\n )}\n },\n plugins: [\n // Put the Sentry rollup plugin after all other plugins\n ${chalk.greenBright(`sentryRollupPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n }),`)}\n ],\n};\n`);\n\nexport const configureRollupPlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/rollup-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/rollup-plugin',\n await getPackageDotJson(),\n ),\n });\n\n clack.log.step(`Add the following code to your rollup config:`);\n\n // Intentionally logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await abortIfCancelled(\n select({\n message: 'Did you copy the snippet above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,0DAA+C;AAC/C,kDAA0B;AAC1B,6CAK2B;AAC3B,2DAA+D;AAO/D,MAAM,cAAc,GAAG,CAAC,OAAgD,EAAE,EAAE,CAC1E,eAAK,CAAC,IAAI,CAAC;EACX,eAAK,CAAC,WAAW,CACjB,6DAA6D,CAC9D;;;;MAIK,eAAK,CAAC,WAAW,CACjB,6DAA6D,CAC9D;;;;MAIC,eAAK,CAAC,WAAW,CAAC;;cAEV,OAAO,CAAC,OAAO;kBACX,OAAO,CAAC,WAAW,KAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAC1D;QACI,CAAC;;;CAGR,CAAC,CAAC;AAEI,MAAM,qBAAqB,GAChC,KAAK,EAAE,OAAO,EAAE,EAAE;IAChB,MAAM,IAAA,sBAAc,EAAC;QACnB,WAAW,EAAE,uBAAuB;QACpC,gBAAgB,EAAE,IAAA,kCAAmB,EACnC,uBAAuB,EACvB,MAAM,IAAA,yBAAiB,GAAE,CAC1B;KACF,CAAC,CAAC;IAEH,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAEhE,gGAAgG;IAChG,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAErC,MAAM,IAAA,wBAAgB,EACpB,IAAA,gBAAM,EAAC;QACL,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;IAEF,MAAM,IAAA,sCAA8B,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC1D,CAAC,CAAC;AAzBS,QAAA,qBAAqB,yBAyB9B","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack, { select } from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.gray(`\n${chalk.greenBright(\n 'import { sentryRollupPlugin } from \"@sentry/rollup-plugin\";',\n)}\n\nexport default {\n output: {\n ${chalk.greenBright(\n 'sourcemap: true, // Source map generation must be turned on',\n )}\n },\n plugins: [\n // Put the Sentry rollup plugin after all other plugins\n ${chalk.greenBright(`sentryRollupPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n }),`)}\n ],\n};\n`);\n\nexport const configureRollupPlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/rollup-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/rollup-plugin',\n await getPackageDotJson(),\n ),\n });\n\n clack.log.step(`Add the following code to your rollup config:`);\n\n // Intentionally logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await abortIfCancelled(\n select({\n message: 'Did you copy the snippet above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n"]}
@@ -27,28 +27,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.addSentryCommandToBuildCommand = exports.setupNpmScriptInCI = exports.configureSentryCLI = void 0;
30
- // @ts-ignore - clack is ESM and TS complains about that. It works though
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
31
  const clack = __importStar(require("@clack/prompts"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
33
  const Sentry = __importStar(require("@sentry/node"));
34
34
  const path = __importStar(require("path"));
35
35
  const fs = __importStar(require("fs"));
36
- const clack_utils_1 = require("../../utils/clack-utils");
36
+ const clack_1 = require("../../utils/clack");
37
37
  const package_json_1 = require("../../utils/package-json");
38
38
  const telemetry_1 = require("../../telemetry");
39
39
  const package_manager_1 = require("../../utils/package-manager");
40
40
  const SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';
41
41
  let addedToBuildCommand = false;
42
42
  async function configureSentryCLI(options, configureSourcemapGenerationFlow = defaultConfigureSourcemapGenerationFlow) {
43
- const packageDotJson = await (0, clack_utils_1.getPackageDotJson)();
44
- await (0, clack_utils_1.installPackage)({
43
+ const packageDotJson = await (0, clack_1.getPackageDotJson)();
44
+ await (0, clack_1.installPackage)({
45
45
  packageName: '@sentry/cli',
46
46
  alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/cli', packageDotJson),
47
47
  });
48
48
  let validPath = false;
49
49
  let relativeArtifactPath;
50
50
  do {
51
- const rawArtifactPath = await (0, clack_utils_1.abortIfCancelled)(clack.text({
51
+ const rawArtifactPath = await (0, clack_1.abortIfCancelled)(clack.text({
52
52
  message: 'Where are your build artifacts located?',
53
53
  placeholder: `.${path.sep}out`,
54
54
  validate(value) {
@@ -68,7 +68,7 @@ async function configureSentryCLI(options, configureSourcemapGenerationFlow = de
68
68
  validPath = true;
69
69
  }
70
70
  catch {
71
- validPath = await (0, clack_utils_1.abortIfCancelled)(clack.select({
71
+ validPath = await (0, clack_1.abortIfCancelled)(clack.select({
72
72
  message: `We couldn't find artifacts at ${relativeArtifactPath}. Are you sure that this is the location that contains your build artifacts?`,
73
73
  options: [
74
74
  {
@@ -92,7 +92,7 @@ async function configureSentryCLI(options, configureSourcemapGenerationFlow = de
92
92
  else {
93
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
94
  }
95
- await (0, clack_utils_1.addSentryCliConfig)({ authToken: options.authToken });
95
+ await (0, clack_1.addSentryCliConfig)({ authToken: options.authToken });
96
96
  }
97
97
  exports.configureSentryCLI = configureSentryCLI;
98
98
  async function setupNpmScriptInCI() {
@@ -101,7 +101,7 @@ async function setupNpmScriptInCI() {
101
101
  // if the script is already added to the build command
102
102
  return;
103
103
  }
104
- const addedToCI = await (0, clack_utils_1.abortIfCancelled)(clack.select({
104
+ const addedToCI = await (0, clack_1.abortIfCancelled)(clack.select({
105
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
106
  options: [
107
107
  { label: 'I did, continue!', value: true },
@@ -121,14 +121,14 @@ async function setupNpmScriptInCI() {
121
121
  exports.setupNpmScriptInCI = setupNpmScriptInCI;
122
122
  async function createAndAddNpmScript(options, relativePosixArtifactPath) {
123
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)();
124
+ const packageDotJson = await (0, clack_1.getPackageDotJson)();
125
125
  packageDotJson.scripts = packageDotJson.scripts || {};
126
126
  packageDotJson.scripts[SENTRY_NPM_SCRIPT_NAME] = sentryCliNpmScript;
127
127
  await fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2));
128
128
  clack.log.info(`Added a ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk_1.default.cyan('package.json')}.`);
129
129
  }
130
130
  async function askShouldAddToBuildCommand() {
131
- const shouldAddToBuildCommand = await (0, clack_utils_1.abortIfCancelled)(clack.select({
131
+ const shouldAddToBuildCommand = await (0, clack_1.abortIfCancelled)(clack.select({
132
132
  message: `Do you want to automatically run the ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script after each production build?`,
133
133
  options: [
134
134
  {
@@ -151,12 +151,12 @@ async function askShouldAddToBuildCommand() {
151
151
  * @param packageDotJson The package.json which will be modified.
152
152
  */
153
153
  async function addSentryCommandToBuildCommand() {
154
- const packageDotJson = await (0, clack_utils_1.getPackageDotJson)();
154
+ const packageDotJson = await (0, clack_1.getPackageDotJson)();
155
155
  // This usually shouldn't happen because earlier we added the
156
156
  // SENTRY_NPM_SCRIPT_NAME script but just to be sure
157
157
  packageDotJson.scripts = packageDotJson.scripts || {};
158
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;
159
+ const packageManager = await (0, clack_1.getPackageManager)(package_manager_1.NPM);
160
160
  // Heuristic to pre-select the build command:
161
161
  // Often, 'build' is the prod build command, so we favour it.
162
162
  // If it's not there, commands that include 'build' might be the prod build command.
@@ -164,11 +164,11 @@ async function addSentryCommandToBuildCommand() {
164
164
  ? 'build'
165
165
  : allNpmScripts.find((s) => s.toLocaleLowerCase().includes('build'));
166
166
  const isProdBuildCommand = !!buildCommand &&
167
- (await (0, clack_utils_1.abortIfCancelled)(clack.confirm({
167
+ (await (0, clack_1.abortIfCancelled)(clack.confirm({
168
168
  message: `Is ${chalk_1.default.cyan(`${packageManager.runScriptCommand} ${buildCommand}`)} your production build command?`,
169
169
  })));
170
170
  if (allNpmScripts.length && (!buildCommand || !isProdBuildCommand)) {
171
- buildCommand = await (0, clack_utils_1.abortIfCancelled)(clack.select({
171
+ buildCommand = await (0, clack_1.abortIfCancelled)(clack.select({
172
172
  message: `Which ${packageManager.name} command in your ${chalk_1.default.cyan('package.json')} builds your application for production?`,
173
173
  options: allNpmScripts
174
174
  .map((script) => ({
@@ -189,14 +189,21 @@ Please add it manually to your prod build command.`);
189
189
  clack.log.warn(`\`${buildCommand}\` doesn't seem to be part of your package.json scripts`);
190
190
  return;
191
191
  }
192
- packageDotJson.scripts[buildCommand] = `${oldCommand} && ${packageManager.runScriptCommand} ${SENTRY_NPM_SCRIPT_NAME}`;
192
+ const newCommand = `${oldCommand} && ${packageManager.runScriptCommand} ${SENTRY_NPM_SCRIPT_NAME}`;
193
+ if (oldCommand.endsWith(SENTRY_NPM_SCRIPT_NAME)) {
194
+ clack.log.info(`It seems like ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} is already part of your ${chalk_1.default.cyan(buildCommand)} command. Will not add it again.
195
+ Current command: ${chalk_1.default.dim(oldCommand)}
196
+ Would have injected: ${chalk_1.default.dim(newCommand)}`);
197
+ return;
198
+ }
199
+ packageDotJson.scripts[buildCommand] = newCommand;
193
200
  await fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2));
194
201
  addedToBuildCommand = true;
195
202
  clack.log.info(`Added ${chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME)} script to your ${chalk_1.default.cyan(buildCommand)} command.`);
196
203
  }
197
204
  exports.addSentryCommandToBuildCommand = addSentryCommandToBuildCommand;
198
205
  async function defaultConfigureSourcemapGenerationFlow() {
199
- await (0, clack_utils_1.abortIfCancelled)(clack.select({
206
+ await (0, clack_1.abortIfCancelled)(clack.select({
200
207
  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
208
  options: [{ label: 'I checked. Continue!', value: true }],
202
209
  initialValue: true,
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-cli.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/sentry-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,sDAAwC;AACxC,kDAA0B;AAC1B,qDAAuC;AACvC,2CAA6B;AAC7B,uCAAyB;AACzB,yDAKiC;AAGjC,2DAA+D;AAC/D,+CAA4C;AAC5C,iEAAuE;AAEvE,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAEnD,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEzB,KAAK,UAAU,kBAAkB,CACtC,OAAgD,EAChD,mCAAwD,uCA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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"]}
1
+ {"version":3,"file":"sentry-cli.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/sentry-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,qDAAuC;AACvC,2CAA6B;AAC7B,uCAAyB;AACzB,6CAM2B;AAG3B,2DAA+D;AAC/D,+CAA4C;AAC5C,iEAAkD;AAElD,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAEnD,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEzB,KAAK,UAAU,kBAAkB,CACtC,OAAgD,EAChD,mCAAwD,uCAAuC;IAE/F,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAEjD,MAAM,IAAA,sBAAc,EAAC;QACnB,WAAW,EAAE,aAAa;QAC1B,gBAAgB,EAAE,IAAA,kCAAmB,EAAC,aAAa,EAAE,cAAc,CAAC;KACrE,CAAC,CAAC;IAEH,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,oBAAoB,CAAC;IACzB,GAAG;QACD,MAAM,eAAe,GAAG,MAAM,IAAA,wBAAgB,EAC5C,KAAK,CAAC,IAAI,CAAC;YACT,OAAO,EAAE,yCAAyC;YAClD,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,KAAK;YAC9B,QAAQ,CAAC,KAAK;gBACZ,IAAI,CAAC,KAAK,EAAE;oBACV,OAAO,sBAAsB,CAAC;iBAC/B;YACH,CAAC;SACF,CAAC,CACH,CAAC;QAEF,IAAI,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;YACpC,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EA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B,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-expect-error - 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 getPackageManager,\n installPackage,\n} from '../../utils/clack';\n\nimport { SourceMapUploadToolConfigurationOptions } from './types';\nimport { hasPackageInstalled } from '../../utils/package-json';\nimport { traceStep } from '../../telemetry';\nimport { 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 = await getPackageManager(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 const newCommand = `${oldCommand} && ${packageManager.runScriptCommand} ${SENTRY_NPM_SCRIPT_NAME}`;\n\n if (oldCommand.endsWith(SENTRY_NPM_SCRIPT_NAME)) {\n clack.log.info(\n `It seems like ${chalk.cyan(\n SENTRY_NPM_SCRIPT_NAME,\n )} is already part of your ${chalk.cyan(\n buildCommand,\n )} command. Will not add it again.\nCurrent command: ${chalk.dim(oldCommand)}\nWould have injected: ${chalk.dim(newCommand)}`,\n );\n\n return;\n }\n\n packageDotJson.scripts[buildCommand] = newCommand;\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"]}
@@ -31,14 +31,14 @@ const fs = __importStar(require("fs"));
31
31
  const path = __importStar(require("path"));
32
32
  const recast = __importStar(require("recast"));
33
33
  const Sentry = __importStar(require("@sentry/node"));
34
- // @ts-ignore - clack is ESM and TS complains about that. It works though
34
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
35
35
  const clack = __importStar(require("@clack/prompts"));
36
36
  const chalk_1 = __importDefault(require("chalk"));
37
- const clack_utils_1 = require("../../utils/clack-utils");
37
+ const clack_1 = require("../../utils/clack");
38
38
  const ast_utils_1 = require("../../utils/ast-utils");
39
39
  const debug_1 = require("../../utils/debug");
40
40
  const b = recast.types.builders;
41
- const getCodeSnippet = (colors) => (0, clack_utils_1.makeCodeSnippet)(colors, (unchanged, plus, _) => unchanged(`{
41
+ const getCodeSnippet = (colors) => (0, clack_1.makeCodeSnippet)(colors, (unchanged, plus, _) => unchanged(`{
42
42
  "compilerOptions": {
43
43
  ${plus('"sourceMap": true,')}
44
44
  ${plus('"inlineSources": true,')}
@@ -50,13 +50,13 @@ const getCodeSnippet = (colors) => (0, clack_utils_1.makeCodeSnippet)(colors, (u
50
50
  }`));
51
51
  async function configureTscSourcemapGenerationFlow() {
52
52
  const tsConfigPath = (0, ast_utils_1.findFile)(path.join(process.cwd(), 'tsconfig'), ['.json']) ??
53
- (await (0, clack_utils_1.askForToolConfigPath)('TypeScript', 'tsconfig.json'));
53
+ (await (0, clack_1.askForToolConfigPath)('TypeScript', 'tsconfig.json'));
54
54
  let successfullyAdded = false;
55
55
  if (tsConfigPath) {
56
56
  successfullyAdded = await enableSourcemaps(tsConfigPath);
57
57
  }
58
58
  else {
59
- successfullyAdded = await (0, clack_utils_1.createNewConfigFile)(path.join(process.cwd(), 'tsconfig.json'), getCodeSnippet(false));
59
+ successfullyAdded = await (0, clack_1.createNewConfigFile)(path.join(process.cwd(), 'tsconfig.json'), getCodeSnippet(false));
60
60
  Sentry.setTag('created-new-config', successfullyAdded ? 'success' : 'fail');
61
61
  }
62
62
  if (successfullyAdded) {
@@ -65,7 +65,7 @@ async function configureTscSourcemapGenerationFlow() {
65
65
  }
66
66
  else {
67
67
  Sentry.setTag('ast-mod', 'fail');
68
- await (0, clack_utils_1.showCopyPasteInstructions)('tsconfig.json', getCodeSnippet(true), 'This ensures that source maps are generated correctly');
68
+ await (0, clack_1.showCopyPasteInstructions)('tsconfig.json', getCodeSnippet(true), 'This ensures that source maps are generated correctly');
69
69
  }
70
70
  }
71
71
  exports.configureTscSourcemapGenerationFlow = configureTscSourcemapGenerationFlow;
@@ -1 +1 @@
1
- {"version":3,"file":"tsc.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/tsc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAAiC;AAEjC,qDAAuC;AAEvC,yEAAyE;AACzE,sDAAwC;AACxC,kDAA0B;AAE1B,yDAKiC;AACjC,qDAM+B;AAC/B,6CAA0C;AAE1C,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,MAAe,EAAE,EAAE,CACzC,IAAA,6BAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAC7C,SAAS,CACP;;MAEA,IAAI,CAAC,oBAAoB,CAAC;MAC1B,IAAI,CAAC,wBAAwB,CAAC;;;;MAI9B,IAAI,CAAC,mBAAmB,CAAC;;EAE7B,CACG,CACF,CAAC;AAEG,KAAK,UAAU,mCAAmC;IACvD,MAAM,YAAY,GAChB,IAAA,oBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QACzD,CAAC,MAAM,IAAA,kCAAoB,EAAC,YAAY,EAAE,eAAe,CAAC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import * as path from 'path';\n\nimport * as recast from 'recast';\n\nimport * as Sentry from '@sentry/node';\n\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n askForToolConfigPath,\n createNewConfigFile,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../../utils/clack-utils';\nimport {\n findFile,\n getOrSetObjectProperty,\n parseJsonC,\n printJsonC,\n setOrUpdateObjectProperty,\n} from '../../utils/ast-utils';\nimport { debug } from '../../utils/debug';\n\nconst b = recast.types.builders;\n\nconst getCodeSnippet = (colors: boolean) =>\n makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(\n `{\n \"compilerOptions\": {\n ${plus('\"sourceMap\": true,')}\n ${plus('\"inlineSources\": true,')}\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix from\n // generated source code references. This will improve issue grouping in Sentry.\n ${plus('\"sourceRoot\": \"/\"')}\n }\n}`,\n ),\n );\n\nexport async function configureTscSourcemapGenerationFlow(): Promise<void> {\n const tsConfigPath =\n findFile(path.join(process.cwd(), 'tsconfig'), ['.json']) ??\n (await askForToolConfigPath('TypeScript', 'tsconfig.json'));\n\n let successfullyAdded = false;\n if (tsConfigPath) {\n successfullyAdded = await enableSourcemaps(tsConfigPath);\n } else {\n successfullyAdded = await createNewConfigFile(\n path.join(process.cwd(), 'tsconfig.json'),\n getCodeSnippet(false),\n );\n Sentry.setTag('created-new-config', successfullyAdded ? 'success' : 'fail');\n }\n\n if (successfullyAdded) {\n Sentry.setTag('ast-mod', 'success');\n clack.log.info(\n `We recommend checking the ${\n tsConfigPath ? 'modified' : 'added'\n } file after the wizard finished to ensure it works with your build setup.`,\n );\n } else {\n Sentry.setTag('ast-mod', 'fail');\n await showCopyPasteInstructions(\n 'tsconfig.json',\n getCodeSnippet(true),\n 'This ensures that source maps are generated correctly',\n );\n }\n}\n\n/**\n * Modifies tsconfig.json (@param tsConfigPath) to enable source maps generation.\n *\n * Exported only for testing\n */\nexport async function enableSourcemaps(tsConfigPath: string): Promise<boolean> {\n try {\n const tsConfig = await fs.promises.readFile(tsConfigPath, 'utf-8');\n\n const { ast, jsonObject } = parseJsonC(tsConfig.toString());\n\n if (!jsonObject || !ast) {\n // this will only happen if the input file isn't valid JSON-C\n Sentry.setTag('ast-mod-fail-reason', 'original-file-invalid');\n return false;\n }\n\n const compilerOptionsProp = getOrSetObjectProperty(\n jsonObject,\n 'compilerOptions',\n b.objectExpression([]),\n );\n\n const compilerOptionsObj = compilerOptionsProp.value;\n\n if (!compilerOptionsObj || compilerOptionsObj.type !== 'ObjectExpression') {\n // a valid compilerOptions prop should always be an object expression\n Sentry.setTag('ast-mod-fail-reason', 'original-file-invalid');\n return false;\n }\n\n setOrUpdateObjectProperty(\n compilerOptionsObj,\n 'sourceMap',\n b.booleanLiteral(true),\n );\n\n setOrUpdateObjectProperty(\n compilerOptionsObj,\n 'inlineSources',\n b.booleanLiteral(true),\n );\n\n setOrUpdateObjectProperty(\n compilerOptionsObj,\n 'sourceRoot',\n b.stringLiteral('/'),\n 'Set `sourceRoot` to \"/\" to strip the build path prefix\\nfrom generated source code references.\\nThis improves issue grouping in Sentry.',\n );\n\n const code = printJsonC(ast);\n\n await fs.promises.writeFile(tsConfigPath, code);\n\n clack.log.success(\n `Enabled source maps generation in ${chalk.cyan(\n path.basename(tsConfigPath || 'tsconfig.json'),\n )}.`,\n );\n\n return true;\n } catch (e) {\n debug(e);\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"tsc.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/tsc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAAiC;AAEjC,qDAAuC;AAEvC,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,6CAK2B;AAC3B,qDAM+B;AAC/B,6CAA0C;AA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,GAAG,CAAC,EACpB,0IAA0I,CAC3I,CAAC;QAEF,MAAM,IAAI,GAAG,IAAA,sBAAU,EAAC,GAAG,CAAC,CAAC;QAE7B,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAEhD,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,qCAAqC,eAAK,CAAC,IAAI,CAC7C,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,eAAe,CAAC,CAC/C,GAAG,CACL,CAAC;QAEF,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;QACT,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AA7DD,4CA6DC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport * as recast from 'recast';\n\nimport * as Sentry from '@sentry/node';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n askForToolConfigPath,\n createNewConfigFile,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../../utils/clack';\nimport {\n findFile,\n getOrSetObjectProperty,\n parseJsonC,\n printJsonC,\n setOrUpdateObjectProperty,\n} from '../../utils/ast-utils';\nimport { debug } from '../../utils/debug';\n\nconst b = recast.types.builders;\n\nconst getCodeSnippet = (colors: boolean) =>\n makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(\n `{\n \"compilerOptions\": {\n ${plus('\"sourceMap\": true,')}\n ${plus('\"inlineSources\": true,')}\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix from\n // generated source code references. This will improve issue grouping in Sentry.\n ${plus('\"sourceRoot\": \"/\"')}\n }\n}`,\n ),\n );\n\nexport async function configureTscSourcemapGenerationFlow(): Promise<void> {\n const tsConfigPath =\n findFile(path.join(process.cwd(), 'tsconfig'), ['.json']) ??\n (await askForToolConfigPath('TypeScript', 'tsconfig.json'));\n\n let successfullyAdded = false;\n if (tsConfigPath) {\n successfullyAdded = await enableSourcemaps(tsConfigPath);\n } else {\n successfullyAdded = await createNewConfigFile(\n path.join(process.cwd(), 'tsconfig.json'),\n getCodeSnippet(false),\n );\n Sentry.setTag('created-new-config', successfullyAdded ? 'success' : 'fail');\n }\n\n if (successfullyAdded) {\n Sentry.setTag('ast-mod', 'success');\n clack.log.info(\n `We recommend checking the ${\n tsConfigPath ? 'modified' : 'added'\n } file after the wizard finished to ensure it works with your build setup.`,\n );\n } else {\n Sentry.setTag('ast-mod', 'fail');\n await showCopyPasteInstructions(\n 'tsconfig.json',\n getCodeSnippet(true),\n 'This ensures that source maps are generated correctly',\n );\n }\n}\n\n/**\n * Modifies tsconfig.json (@param tsConfigPath) to enable source maps generation.\n *\n * Exported only for testing\n */\nexport async function enableSourcemaps(tsConfigPath: string): Promise<boolean> {\n try {\n const tsConfig = await fs.promises.readFile(tsConfigPath, 'utf-8');\n\n const { ast, jsonObject } = parseJsonC(tsConfig.toString());\n\n if (!jsonObject || !ast) {\n // this will only happen if the input file isn't valid JSON-C\n Sentry.setTag('ast-mod-fail-reason', 'original-file-invalid');\n return false;\n }\n\n const compilerOptionsProp = getOrSetObjectProperty(\n jsonObject,\n 'compilerOptions',\n b.objectExpression([]),\n );\n\n const compilerOptionsObj = compilerOptionsProp.value;\n\n if (!compilerOptionsObj || compilerOptionsObj.type !== 'ObjectExpression') {\n // a valid compilerOptions prop should always be an object expression\n Sentry.setTag('ast-mod-fail-reason', 'original-file-invalid');\n return false;\n }\n\n setOrUpdateObjectProperty(\n compilerOptionsObj,\n 'sourceMap',\n b.booleanLiteral(true),\n );\n\n setOrUpdateObjectProperty(\n compilerOptionsObj,\n 'inlineSources',\n b.booleanLiteral(true),\n );\n\n setOrUpdateObjectProperty(\n compilerOptionsObj,\n 'sourceRoot',\n b.stringLiteral('/'),\n 'Set `sourceRoot` to \"/\" to strip the build path prefix\\nfrom generated source code references.\\nThis improves issue grouping in Sentry.',\n );\n\n const code = printJsonC(ast);\n\n await fs.promises.writeFile(tsConfigPath, code);\n\n clack.log.success(\n `Enabled source maps generation in ${chalk.cyan(\n path.basename(tsConfigPath || 'tsconfig.json'),\n )}.`,\n );\n\n return true;\n } catch (e) {\n debug(e);\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n}\n"]}