@sentry/wizard 4.5.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.
- package/CHANGELOG.md +17 -1
- package/README.md +23 -19
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +3 -2
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +2 -2
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +20 -2
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +2 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/File.d.ts +1 -1
- package/dist/lib/Helper/File.js +1 -3
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +3 -0
- package/dist/lib/Helper/Logging.js +3 -0
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +5 -3
- package/dist/lib/Helper/Package.js +2 -2
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/SentryCli.d.ts +20 -7
- package/dist/lib/Helper/SentryCli.js +21 -13
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +9 -5
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +21 -4
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +3 -1
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +1 -2
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +14 -10
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
- package/dist/lib/Steps/Integrations/Electron.js +1 -1
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
- package/dist/lib/Steps/SentryProjectSelector.js +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
- package/dist/lib/Steps/WaitForSentry.js +4 -4
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Types.d.ts +14 -0
- package/dist/lib/Types.js +3 -0
- package/dist/lib/Types.js.map +1 -0
- package/dist/lib/__tests__/Env.js +6 -13
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/android/android-wizard.js +15 -12
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.js +1 -1
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +4 -4
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/android/manifest.js +1 -1
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/apple/apple-wizard.d.ts +2 -2
- package/dist/src/apple/apple-wizard.js +37 -118
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/check-installed-cli.d.ts +1 -0
- package/dist/src/apple/check-installed-cli.js +60 -0
- package/dist/src/apple/check-installed-cli.js.map +1 -0
- package/dist/src/apple/cocoapod.js +1 -1
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.js +1 -1
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/configure-fastlane.d.ts +5 -0
- package/dist/src/apple/configure-fastlane.js +66 -0
- package/dist/src/apple/configure-fastlane.js.map +1 -0
- package/dist/src/apple/fastlane.d.ts +1 -1
- package/dist/src/apple/fastlane.js +5 -5
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/lookup-xcode-project.d.ts +7 -0
- package/dist/src/apple/lookup-xcode-project.js +98 -0
- package/dist/src/apple/lookup-xcode-project.js.map +1 -0
- package/dist/src/apple/options.d.ts +4 -0
- package/dist/src/apple/options.js +3 -0
- package/dist/src/apple/options.js.map +1 -0
- package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
- package/dist/src/apple/search-xcode-project-at-path.js +70 -0
- package/dist/src/apple/search-xcode-project-at-path.js.map +1 -0
- package/dist/src/apple/xcode-manager.js +1 -1
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.js +3 -3
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +21 -15
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.js +4 -4
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +118 -43
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +10 -1
- package/dist/src/nextjs/templates.js +191 -63
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +21 -16
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-example.js +3 -3
- package/dist/src/nuxt/sdk-example.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.js +9 -9
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +173 -58
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/utils.js +6 -3
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +1 -1
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +4 -4
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +4 -4
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/javascript.js +7 -7
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +8 -8
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +1 -1
- package/dist/src/react-native/react-native-wizard.js +36 -31
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/uninstall.js +8 -5
- package/dist/src/react-native/uninstall.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +2 -1
- package/dist/src/react-native/xcode.js +1 -2
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +4 -1
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +23 -18
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +163 -64
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +11 -7
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +3 -1
- package/dist/src/run.js +29 -9
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.js +3 -3
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
- package/dist/src/sourcemaps/tools/esbuild.js +6 -6
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js +5 -5
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +4 -4
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +6 -6
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +15 -15
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +6 -6
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +12 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +10 -10
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +1 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +15 -14
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +126 -37
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/telemetry.js +11 -0
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +45 -7
- package/dist/src/utils/{clack-utils.js → clack/index.js} +72 -19
- package/dist/src/utils/clack/index.js.map +1 -0
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/find-files-with-extension.d.ts +1 -0
- package/dist/src/utils/find-files-with-extension.js +39 -0
- package/dist/src/utils/find-files-with-extension.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +6 -1
- package/dist/src/utils/package-manager.js +25 -19
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/sentrycli-utils.js +0 -1
- package/dist/src/utils/sentrycli-utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +4 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/android/code-tools.test.js +0 -1
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +1 -1
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +1 -1
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +1 -1
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +26 -2
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +0 -2
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +23 -23
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +128 -83
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +1 -1
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +1 -1
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +1 -1
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +5 -5
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/utils/{clack-utils.test.js → clack/index.test.js} +91 -18
- package/dist/test/utils/clack/index.test.js.map +1 -0
- package/dist/test/utils/package-manager.test.d.ts +1 -0
- package/dist/test/utils/package-manager.test.js +29 -0
- package/dist/test/utils/package-manager.test.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/test/utils/clack-utils.test.js.map +0 -1
- /package/dist/test/utils/{clack-utils.test.d.ts → clack/index.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/vite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,sDAAwC;AACxC,4EAA4E;AAC5E,uCAAqD;AACrD,4EAA4E;AAC5E,8CAAiD;AAIjD,+CAAiC;AAEjC,qDAAuC;AAEvC,kDAA0B;AAC1B,yDASiC;AACjC,2DAA+D;AAM/D,qDAAmE;AAEnE,2CAA6B;AAC7B,uCAAyB;AACzB,6CAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAC3B,OAAgD,EAChD,MAAe,EACf,EAAE,CACF,IAAA,6BAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAC7C,SAAS,CAAC;EACZ,IAAI,CAAC,yDAAyD,CAAC;;;;MAI3D,IAAI,CAAC,6DAA6D,CAAC;;;;MAInE,IAAI,CAAC;;cAEG,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;;IAEL,CAAC,CACF,CAAC;AAEG,MAAM,mBAAmB,GAC9B,KAAK,EAAE,OAAO,EAAE,EAAE;IAChB,MAAM,IAAA,4BAAc,EAAC;QACnB,WAAW,EAAE,qBAAqB;QAClC,gBAAgB,EAAE,IAAA,kCAAmB,EACnC,qBAAqB,EACrB,MAAM,IAAA,+BAAiB,GAAE,CAC1B;KACF,CAAC,CAAC;IAEH,MAAM,cAAc,GAClB,IAAA,oBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE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AI,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,0BAA0B,CACf,CAAC;IAEhC,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,aAAa,CAAC,WAAW,CAAC,IAAI,KAAK,kBAAkB,EAAE;QACzD,OAAO,aAAa,CAAC,WAAW,CAAC;KAClC;IAED,IACE,aAAa,CAAC,WAAW,CAAC,IAAI,KAAK,gBAAgB;QACnD,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,EAClE;QACA,OAAO,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KAC/C;IAED,IAAI,aAAa,CAAC,WAAW,CAAC,IAAI,KAAK,YAAY,EAAE;QACnD,MAAM,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC;QAChD,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC1C;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,cAAc,CACrB,QAAgB,EAChB,OAAkB;IAElB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE;YACvC,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE;gBAC3C,IACE,WAAW,CAAC,IAAI,KAAK,oBAAoB;oBACzC,WAAW,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY;oBACpC,WAAW,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ;oBAChC,WAAW,CAAC,IAAI,EAAE,IAAI,KAAK,kBAAkB,EAC7C;oBACA,OAAO,WAAW,CAAC,IAAI,CAAC;iBACzB;aACF;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { addVitePlugin } from 'magicast/helpers';\n\nimport type { namedTypes as t } from 'ast-types';\n\nimport * as recast from 'recast';\n\nimport * as Sentry from '@sentry/node';\n\nimport chalk from 'chalk';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askForToolConfigPath,\n createNewConfigFile,\n getPackageDotJson,\n installPackage,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../../utils/clack-utils';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\nimport { findFile, hasSentryContent } from '../../utils/ast-utils';\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { debug } from '../../utils/debug';\n\nconst getViteConfigSnippet = (\n options: SourceMapUploadToolConfigurationOptions,\n colors: boolean,\n) =>\n makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`import { defineConfig } from \"vite\";\n${plus('import { sentryVitePlugin } from \"@sentry/vite-plugin\";')}\n\nexport default defineConfig({\n build: {\n ${plus('sourcemap: true, // Source map generation must be turned on')}\n },\n plugins: [\n // Put the Sentry vite plugin after all other plugins\n ${plus(`sentryVitePlugin({\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 configureVitePlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/vite-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/vite-plugin',\n await getPackageDotJson(),\n ),\n });\n\n const viteConfigPath =\n findFile(path.resolve(process.cwd(), 'vite.config')) ??\n (await askForToolConfigPath('Vite', 'vite.config.js'));\n\n let successfullyAdded = false;\n if (viteConfigPath) {\n successfullyAdded = await addVitePluginToConfig(viteConfigPath, options);\n } else {\n successfullyAdded = await createNewConfigFile(\n path.join(process.cwd(), 'vite.config.js'),\n getViteConfigSnippet(options, false),\n 'More information about vite configs: https://vitejs.dev/config/',\n );\n Sentry.setTag(\n 'created-new-config',\n successfullyAdded ? 'success' : 'fail',\n );\n }\n\n if (successfullyAdded) {\n clack.log.info(\n `We recommend checking the ${\n viteConfigPath ? 'modified' : 'added'\n } file after the wizard finished to ensure it works with your build setup.`,\n );\n\n Sentry.setTag('ast-mod', 'success');\n } else {\n Sentry.setTag('ast-mod', 'fail');\n await showCopyPasteInstructions(\n path.basename(viteConfigPath || 'vite.config.js'),\n getViteConfigSnippet(options, true),\n );\n }\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n\nexport async function addVitePluginToConfig(\n viteConfigPath: string,\n options: SourceMapUploadToolConfigurationOptions,\n): Promise<boolean> {\n try {\n const prettyViteConfigFilename = chalk.cyan(path.basename(viteConfigPath));\n\n const viteConfigContent = (\n await fs.promises.readFile(viteConfigPath)\n ).toString();\n\n const mod = parseModule(viteConfigContent);\n\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `${prettyViteConfigFilename} already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Vite plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n return false;\n }\n }\n\n const enabledSourcemaps = enableSourcemapGeneration(mod.$ast as t.Program);\n if (!enabledSourcemaps) {\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n\n const { orgSlug: org, projectSlug: project, selfHosted, url } = options;\n\n addVitePlugin(mod, {\n imported: 'sentryVitePlugin',\n from: '@sentry/vite-plugin',\n constructor: 'sentryVitePlugin',\n options: {\n org,\n project,\n ...(selfHosted && { url }),\n },\n });\n\n const code = generateCode(mod.$ast).code;\n\n await fs.promises.writeFile(viteConfigPath, code);\n\n clack.log.success(\n `Added the Sentry Vite plugin to ${prettyViteConfigFilename} and enabled source maps`,\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\nfunction enableSourcemapGeneration(program: t.Program): boolean {\n const configObj = getViteConfigObject(program);\n\n if (!configObj) {\n return false;\n }\n\n const b = recast.types.builders;\n\n const buildProp = configObj.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'build',\n );\n\n // case 1: build property doesn't exist yet, so we can just add it\n if (!buildProp) {\n configObj.properties.push(\n b.objectProperty(\n b.identifier('build'),\n b.objectExpression([\n b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),\n ]),\n ),\n );\n return true;\n }\n\n const isValidBuildProp =\n buildProp.type === 'ObjectProperty' &&\n buildProp.value.type === 'ObjectExpression';\n\n if (!isValidBuildProp) {\n return false;\n }\n\n const sourceMapsProp =\n buildProp.value.type === 'ObjectExpression' &&\n buildProp.value.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'sourcemap',\n );\n\n // case 2: build.sourcemap property doesn't exist yet, so we just add it\n if (!sourceMapsProp && buildProp.value.type === 'ObjectExpression') {\n buildProp.value.properties.push(\n b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),\n );\n return true;\n }\n\n if (!sourceMapsProp || sourceMapsProp.type !== 'ObjectProperty') {\n return false;\n }\n\n // case 3: build.sourcemap property exists, and it's set to 'hidden'\n if (\n sourceMapsProp.value.type === 'StringLiteral' &&\n sourceMapsProp.value.value === 'hidden'\n ) {\n // nothing to do for us\n return true;\n }\n\n // case 4: build.sourcemap property exists, but it's not enabled, so we set it to true\n // or it is already true in which case this is a noop\n sourceMapsProp.value = b.booleanLiteral(true);\n return true;\n}\n\nfunction getViteConfigObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n const defaultExport = program.body.find(\n (s) => s.type === 'ExportDefaultDeclaration',\n ) as t.ExportDefaultDeclaration;\n\n if (!defaultExport) {\n return undefined;\n }\n\n if (defaultExport.declaration.type === 'ObjectExpression') {\n return defaultExport.declaration;\n }\n\n if (\n defaultExport.declaration.type === 'CallExpression' &&\n defaultExport.declaration.arguments[0].type === 'ObjectExpression'\n ) {\n return defaultExport.declaration.arguments[0];\n }\n\n if (defaultExport.declaration.type === 'Identifier') {\n const configId = defaultExport.declaration.name;\n return findConfigNode(configId, program);\n }\n\n return undefined;\n}\n\nfunction findConfigNode(\n configId: string,\n program: t.Program,\n): t.ObjectExpression | undefined {\n for (const node of program.body) {\n if (node.type === 'VariableDeclaration') {\n for (const declaration of node.declarations) {\n if (\n declaration.type === 'VariableDeclarator' &&\n declaration.id.type === 'Identifier' &&\n declaration.id.name === configId &&\n declaration.init?.type === 'ObjectExpression'\n ) {\n return declaration.init;\n }\n }\n }\n }\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/vite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kFAAkF;AAClF,uCAAqD;AACrD,kFAAkF;AAClF,8CAAiD;AAIjD,+CAAiC;AAEjC,qDAAuC;AAEvC,kDAA0B;AAC1B,6CAS2B;AAC3B,2DAA+D;AAM/D,qDAAmE;AAEnE,2CAA6B;AAC7B,uCAAyB;AACzB,6CAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAC3B,OAAgD,EAChD,MAAe,EACf,EAAE,CACF,IAAA,uBAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAC7C,SAAS,CAAC;EACZ,IAAI,CAAC,yDAAyD,CAAC;;;;M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AAC;AAED,SAAS,cAAc,CACrB,QAAgB,EAChB,OAAkB;IAElB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE;YACvC,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE;gBAC3C,IACE,WAAW,CAAC,IAAI,KAAK,oBAAoB;oBACzC,WAAW,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY;oBACpC,WAAW,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ;oBAChC,WAAW,CAAC,IAAI,EAAE,IAAI,KAAK,kBAAkB,EAC7C;oBACA,OAAO,WAAW,CAAC,IAAI,CAAC;iBACzB;aACF;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addVitePlugin } from 'magicast/helpers';\n\nimport type { namedTypes as t } from 'ast-types';\n\nimport * as recast from 'recast';\n\nimport * as Sentry from '@sentry/node';\n\nimport chalk from 'chalk';\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askForToolConfigPath,\n createNewConfigFile,\n getPackageDotJson,\n installPackage,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../../utils/clack';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\nimport { findFile, hasSentryContent } from '../../utils/ast-utils';\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { debug } from '../../utils/debug';\n\nconst getViteConfigSnippet = (\n options: SourceMapUploadToolConfigurationOptions,\n colors: boolean,\n) =>\n makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`import { defineConfig } from \"vite\";\n${plus('import { sentryVitePlugin } from \"@sentry/vite-plugin\";')}\n\nexport default defineConfig({\n build: {\n ${plus('sourcemap: true, // Source map generation must be turned on')}\n },\n plugins: [\n // Put the Sentry vite plugin after all other plugins\n ${plus(`sentryVitePlugin({\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 configureVitePlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/vite-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/vite-plugin',\n await getPackageDotJson(),\n ),\n });\n\n const viteConfigPath =\n findFile(path.resolve(process.cwd(), 'vite.config')) ??\n (await askForToolConfigPath('Vite', 'vite.config.js'));\n\n let successfullyAdded = false;\n if (viteConfigPath) {\n successfullyAdded = await addVitePluginToConfig(viteConfigPath, options);\n } else {\n successfullyAdded = await createNewConfigFile(\n path.join(process.cwd(), 'vite.config.js'),\n getViteConfigSnippet(options, false),\n 'More information about vite configs: https://vitejs.dev/config/',\n );\n Sentry.setTag(\n 'created-new-config',\n successfullyAdded ? 'success' : 'fail',\n );\n }\n\n if (successfullyAdded) {\n clack.log.info(\n `We recommend checking the ${\n viteConfigPath ? 'modified' : 'added'\n } file after the wizard finished to ensure it works with your build setup.`,\n );\n\n Sentry.setTag('ast-mod', 'success');\n } else {\n Sentry.setTag('ast-mod', 'fail');\n await showCopyPasteInstructions(\n path.basename(viteConfigPath || 'vite.config.js'),\n getViteConfigSnippet(options, true),\n );\n }\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n\nexport async function addVitePluginToConfig(\n viteConfigPath: string,\n options: SourceMapUploadToolConfigurationOptions,\n): Promise<boolean> {\n try {\n const prettyViteConfigFilename = chalk.cyan(path.basename(viteConfigPath));\n\n const viteConfigContent = (\n await fs.promises.readFile(viteConfigPath)\n ).toString();\n\n const mod = parseModule(viteConfigContent);\n\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `${prettyViteConfigFilename} already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Vite plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n return false;\n }\n }\n\n const enabledSourcemaps = enableSourcemapGeneration(mod.$ast as t.Program);\n if (!enabledSourcemaps) {\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n\n const { orgSlug: org, projectSlug: project, selfHosted, url } = options;\n\n addVitePlugin(mod, {\n imported: 'sentryVitePlugin',\n from: '@sentry/vite-plugin',\n constructor: 'sentryVitePlugin',\n options: {\n org,\n project,\n ...(selfHosted && { url }),\n },\n });\n\n const code = generateCode(mod.$ast).code;\n\n await fs.promises.writeFile(viteConfigPath, code);\n\n clack.log.success(\n `Added the Sentry Vite plugin to ${prettyViteConfigFilename} and enabled source maps`,\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\nfunction enableSourcemapGeneration(program: t.Program): boolean {\n const configObj = getViteConfigObject(program);\n\n if (!configObj) {\n return false;\n }\n\n const b = recast.types.builders;\n\n const buildProp = configObj.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'build',\n );\n\n // case 1: build property doesn't exist yet, so we can just add it\n if (!buildProp) {\n configObj.properties.push(\n b.objectProperty(\n b.identifier('build'),\n b.objectExpression([\n b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),\n ]),\n ),\n );\n return true;\n }\n\n const isValidBuildProp =\n buildProp.type === 'ObjectProperty' &&\n buildProp.value.type === 'ObjectExpression';\n\n if (!isValidBuildProp) {\n return false;\n }\n\n const sourceMapsProp =\n buildProp.value.type === 'ObjectExpression' &&\n buildProp.value.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'sourcemap',\n );\n\n // case 2: build.sourcemap property doesn't exist yet, so we just add it\n if (!sourceMapsProp && buildProp.value.type === 'ObjectExpression') {\n buildProp.value.properties.push(\n b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),\n );\n return true;\n }\n\n if (!sourceMapsProp || sourceMapsProp.type !== 'ObjectProperty') {\n return false;\n }\n\n // case 3: build.sourcemap property exists, and it's set to 'hidden'\n if (\n sourceMapsProp.value.type === 'StringLiteral' &&\n sourceMapsProp.value.value === 'hidden'\n ) {\n // nothing to do for us\n return true;\n }\n\n // case 4: build.sourcemap property exists, but it's not enabled, so we set it to true\n // or it is already true in which case this is a noop\n sourceMapsProp.value = b.booleanLiteral(true);\n return true;\n}\n\nfunction getViteConfigObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n const defaultExport = program.body.find(\n (s) => s.type === 'ExportDefaultDeclaration',\n ) as t.ExportDefaultDeclaration;\n\n if (!defaultExport) {\n return undefined;\n }\n\n if (defaultExport.declaration.type === 'ObjectExpression') {\n return defaultExport.declaration;\n }\n\n if (\n defaultExport.declaration.type === 'CallExpression' &&\n defaultExport.declaration.arguments[0].type === 'ObjectExpression'\n ) {\n return defaultExport.declaration.arguments[0];\n }\n\n if (defaultExport.declaration.type === 'Identifier') {\n const configId = defaultExport.declaration.name;\n return findConfigNode(configId, program);\n }\n\n return undefined;\n}\n\nfunction findConfigNode(\n configId: string,\n program: t.Program,\n): t.ObjectExpression | undefined {\n for (const node of program.body) {\n if (node.type === 'VariableDeclaration') {\n for (const declaration of node.declarations) {\n if (\n declaration.type === 'VariableDeclarator' &&\n declaration.id.type === 'Identifier' &&\n declaration.id.name === configId &&\n declaration.init?.type === 'ObjectExpression'\n ) {\n return declaration.init;\n }\n }\n }\n }\n return undefined;\n}\n"]}
|
|
@@ -29,16 +29,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.modifyWebpackConfig = exports.configureWebPackPlugin = void 0;
|
|
30
30
|
const path = __importStar(require("node:path"));
|
|
31
31
|
const fs = __importStar(require("node:fs"));
|
|
32
|
-
// @ts-
|
|
32
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
33
33
|
const clack = __importStar(require("@clack/prompts"));
|
|
34
34
|
const chalk_1 = __importDefault(require("chalk"));
|
|
35
35
|
const recast = __importStar(require("recast"));
|
|
36
36
|
const Sentry = __importStar(require("@sentry/node"));
|
|
37
|
-
const
|
|
37
|
+
const clack_1 = require("../../utils/clack");
|
|
38
38
|
const package_json_1 = require("../../utils/package-json");
|
|
39
39
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
40
40
|
const debug_1 = require("../../utils/debug");
|
|
41
|
-
const getCodeSnippet = (options, colors) => (0,
|
|
41
|
+
const getCodeSnippet = (options, colors) => (0, clack_1.makeCodeSnippet)(colors, (unchanged, plus) => unchanged(`${plus('const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");')}
|
|
42
42
|
|
|
43
43
|
module.exports = {
|
|
44
44
|
// ... other options
|
|
@@ -53,18 +53,18 @@ module.exports = {
|
|
|
53
53
|
],
|
|
54
54
|
}`));
|
|
55
55
|
const configureWebPackPlugin = async (options) => {
|
|
56
|
-
await (0,
|
|
56
|
+
await (0, clack_1.installPackage)({
|
|
57
57
|
packageName: '@sentry/webpack-plugin',
|
|
58
|
-
alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/webpack-plugin', await (0,
|
|
58
|
+
alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/webpack-plugin', await (0, clack_1.getPackageDotJson)()),
|
|
59
59
|
});
|
|
60
60
|
const webpackConfigPath = (0, ast_utils_1.findFile)(path.resolve(process.cwd(), 'webpack.config')) ??
|
|
61
|
-
(await (0,
|
|
61
|
+
(await (0, clack_1.askForToolConfigPath)('Webpack', 'webpack.config.js'));
|
|
62
62
|
let successfullyAdded = false;
|
|
63
63
|
if (webpackConfigPath) {
|
|
64
64
|
successfullyAdded = await modifyWebpackConfig(webpackConfigPath, options);
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
successfullyAdded = await (0,
|
|
67
|
+
successfullyAdded = await (0, clack_1.createNewConfigFile)(path.join(process.cwd(), 'webpack.config.js'), getCodeSnippet(options, false), 'More information about Webpack configs: https://vitejs.dev/config/');
|
|
68
68
|
Sentry.setTag('created-new-config', successfullyAdded ? 'success' : 'fail');
|
|
69
69
|
}
|
|
70
70
|
if (successfullyAdded) {
|
|
@@ -73,9 +73,9 @@ const configureWebPackPlugin = async (options) => {
|
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
75
|
Sentry.setTag('ast-mod', 'fail');
|
|
76
|
-
await (0,
|
|
76
|
+
await (0, clack_1.showCopyPasteInstructions)(path.basename(webpackConfigPath || 'webpack.config.js'), getCodeSnippet(options, true));
|
|
77
77
|
}
|
|
78
|
-
await (0,
|
|
78
|
+
await (0, clack_1.addDotEnvSentryBuildPluginFile)(options.authToken);
|
|
79
79
|
};
|
|
80
80
|
exports.configureWebPackPlugin = configureWebPackPlugin;
|
|
81
81
|
/**
|
|
@@ -139,7 +139,7 @@ async function modifyWebpackConfig(webpackConfigPath, options) {
|
|
|
139
139
|
exports.modifyWebpackConfig = modifyWebpackConfig;
|
|
140
140
|
async function shouldModifyWebpackConfig(program, prettyConfigFilename) {
|
|
141
141
|
if ((0, ast_utils_1.hasSentryContent)(program)) {
|
|
142
|
-
const shouldContinue = await (0,
|
|
142
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(clack.select({
|
|
143
143
|
message: `Seems like ${prettyConfigFilename} already contains Sentry-related code. Should the wizard modify it anyway?`,
|
|
144
144
|
options: [
|
|
145
145
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../../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gBAC/B,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY;gBAC1B,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ,CACzB,CACJ,CAAC;QAEF,MAAM,UAAU,GAAG,iBAAiB,EAAE,YAAY,CAAC,IAAI,CACrD,CAAC,CAAC,EAA6B,EAAE,CAC/B,CAAC,CAAC,IAAI,KAAK,oBAAoB;YAC/B,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY;YAC1B,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ,CACzB,CAAC;QAEF,OAAO,UAAU,EAAE,IAAI,EAAE,IAAI,KAAK,kBAAkB;YAClD,CAAC,CAAC,UAAU,CAAC,IAAI;YACjB,CAAC,CAAC,SAAS,CAAC;KACf;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAC1B,OAAkB;IAElB,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CACrC,CAAC,CAAC,EAA8B,EAAE,CAChC,CAAC,CAAC,IAAI,KAAK,qBAAqB;QAChC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,sBAAsB;QAC5C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,kBAAkB;QAC7C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;QAC9C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC1C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;QAChD,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAChD,CAAC;IACF,OAAO,aAAa,EAAE,UAAoC,CAAC;AAC7D,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\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 * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport * as Sentry from '@sentry/node';\n\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askForToolConfigPath,\n createNewConfigFile,\n getPackageDotJson,\n installPackage,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../../utils/clack-utils';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport type {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\n\nimport { findFile, hasSentryContent } from '../../utils/ast-utils';\nimport { debug } from '../../utils/debug';\n\nconst getCodeSnippet = (\n options: SourceMapUploadToolConfigurationOptions,\n colors: boolean,\n) =>\n makeCodeSnippet(colors, (unchanged, plus) =>\n unchanged(`${plus(\n 'const { sentryWebpackPlugin } = require(\"@sentry/webpack-plugin\");',\n )}\n\nmodule.exports = {\n // ... other options\n ${plus('devtool: \"source-map\", // Source map generation must be turned on')}\n plugins: [\n // Put the Sentry Webpack plugin after all other plugins\n ${plus(`sentryWebpackPlugin({\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 configureWebPackPlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/webpack-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/webpack-plugin',\n await getPackageDotJson(),\n ),\n });\n\n const webpackConfigPath =\n findFile(path.resolve(process.cwd(), 'webpack.config')) ??\n (await askForToolConfigPath('Webpack', 'webpack.config.js'));\n\n let successfullyAdded = false;\n if (webpackConfigPath) {\n successfullyAdded = await modifyWebpackConfig(webpackConfigPath, options);\n } else {\n successfullyAdded = await createNewConfigFile(\n path.join(process.cwd(), 'webpack.config.js'),\n getCodeSnippet(options, false),\n 'More information about Webpack configs: https://vitejs.dev/config/',\n );\n Sentry.setTag(\n 'created-new-config',\n successfullyAdded ? 'success' : 'fail',\n );\n }\n\n if (successfullyAdded) {\n clack.log.info(\n `We recommend checking the ${\n webpackConfigPath ? 'modified' : 'added'\n } file after the wizard finished to ensure it works with your build setup.`,\n );\n\n Sentry.setTag('ast-mod', 'success');\n } else {\n Sentry.setTag('ast-mod', 'fail');\n await showCopyPasteInstructions(\n path.basename(webpackConfigPath || 'webpack.config.js'),\n getCodeSnippet(options, true),\n );\n }\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n\n/**\n * Modifies a webpack config file to enable source map generation and add the Sentry webpack plugin\n * exported only for testing\n */\nexport async function modifyWebpackConfig(\n webpackConfigPath: string,\n options: SourceMapUploadToolConfigurationOptions,\n): Promise<boolean> {\n try {\n const webpackConfig = await fs.promises.readFile(webpackConfigPath, {\n encoding: 'utf-8',\n });\n\n const prettyConfigFilename = chalk.cyan(path.basename(webpackConfigPath));\n\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const program = recast.parse(webpackConfig.toString()).program as t.Program;\n\n if (!(await shouldModifyWebpackConfig(program, prettyConfigFilename))) {\n // Sentry tag is set in shouldModifyWebpackConfig\n return false;\n }\n\n const exportStmt = getCjsModuleExports(program);\n if (!exportStmt) {\n // We only care about CJS at the moment since it's probably the most widely used format for webpack configs.\n debug(`Could not find module.exports = {...} in ${webpackConfigPath}.`);\n Sentry.setTag('ast-mod-fail-reason', 'config-object-not-found');\n return false;\n }\n\n const configObject = getWebpackConfigObject(exportStmt, program);\n\n if (!configObject) {\n debug(`Couldn't find config object in ${webpackConfigPath}`);\n Sentry.setTag('ast-mod-fail-reason', 'config-object-not-found');\n return false;\n }\n\n const enabledSourcemaps = enableSourcemapsGeneration(configObject);\n\n if (enabledSourcemaps) {\n clack.log.success(\n `Enabled source map generation in ${prettyConfigFilename}.`,\n );\n } else {\n clack.log.warn(\n `Couldn't enable source maps generation in ${prettyConfigFilename} Please follow the instructions below.`,\n );\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n\n const addedPlugin = addSentryWebpackPlugin(program, configObject, options);\n if (addedPlugin) {\n clack.log.success(\n `Added Sentry webpack plugin to ${prettyConfigFilename}.`,\n );\n } else {\n clack.log.warn(\n `Couldn't add Sentry webpack plugin to ${prettyConfigFilename}. Please follow the instructions below.`,\n );\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n\n const code = recast.print(program).code;\n await fs.promises.writeFile(webpackConfigPath, code);\n\n return true;\n } catch (e) {\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n debug(e);\n return false;\n }\n}\n\nasync function shouldModifyWebpackConfig(\n program: t.Program,\n prettyConfigFilename: string,\n) {\n if (hasSentryContent(program)) {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `Seems like ${prettyConfigFilename} already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Webpack plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n return false;\n }\n }\n\n return true;\n}\n\nfunction addSentryWebpackPlugin(\n program: t.Program,\n configObj: t.ObjectExpression,\n options: SourceMapUploadToolConfigurationOptions,\n) {\n const b = addSentryWebpackPluginImport(program);\n\n const sentryPluginCall = b.callExpression(\n b.identifier('sentryWebpackPlugin'),\n [\n b.objectExpression([\n b.objectProperty(\n b.identifier('authToken'),\n b.identifier('process.env.SENTRY_AUTH_TOKEN'),\n ),\n b.objectProperty(b.identifier('org'), b.stringLiteral(options.orgSlug)),\n b.objectProperty(\n b.identifier('project'),\n b.stringLiteral(options.projectSlug),\n ),\n ...(options.selfHosted\n ? [\n b.objectProperty(\n b.identifier('url'),\n b.stringLiteral(options.url),\n ),\n ]\n : []),\n ]),\n ],\n );\n\n const pluginsProp = configObj.properties.find(\n (p): p is t.Property =>\n p.type === 'Property' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'plugins',\n );\n\n if (pluginsProp) {\n if (pluginsProp.value.type === 'ArrayExpression') {\n pluginsProp.value.elements.push(sentryPluginCall);\n } else {\n pluginsProp.value = b.arrayExpression([sentryPluginCall]);\n }\n return true;\n }\n\n configObj.properties.push(\n b.objectProperty(\n b.identifier('plugins'),\n b.arrayExpression([sentryPluginCall]),\n ),\n );\n\n return true;\n}\n\nfunction addSentryWebpackPluginImport(program: t.Program) {\n const b = recast.types.builders;\n\n const sentryPluginRequireStmt = b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('sentryWebpackPlugin'),\n value: b.identifier('sentryWebpackPlugin'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.stringLiteral('@sentry/webpack-plugin'),\n ]),\n ),\n ]);\n\n program.body.unshift(sentryPluginRequireStmt);\n return b;\n}\n\nfunction enableSourcemapsGeneration(configObj: t.ObjectExpression): boolean {\n const b = recast.types.builders;\n\n const devtoolProp = configObj.properties.find(\n (p): p is t.Property =>\n p.type === 'Property' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'devtool',\n );\n\n if (devtoolProp) {\n // devtool can have quite a lot of source maps values.\n // see: https://webpack.js.org/configuration/devtool/#devtool\n // For Sentry to work best, we should set it to \"source-map\" or \"hidden-source-map\"\n // Heuristic:\n // - all values that contain \"hidden\" will be set to \"hidden-source-map\"\n // - all other values will be set to \"source-map\"\n if (\n (devtoolProp.value.type === 'Literal' ||\n devtoolProp.value.type === 'StringLiteral') &&\n devtoolProp.value.value?.toString().startsWith('hidden-')\n ) {\n devtoolProp.value = b.stringLiteral('hidden-source-map');\n } else {\n devtoolProp.value = b.stringLiteral('source-map');\n }\n return true;\n }\n\n configObj.properties.push(\n b.objectProperty(b.identifier('devtool'), b.stringLiteral('source-map')),\n );\n\n return true;\n}\n\nfunction getWebpackConfigObject(\n moduleExports: t.AssignmentExpression,\n program: t.Program,\n): t.ObjectExpression | undefined {\n const rhs = moduleExports.right;\n if (rhs.type === 'ObjectExpression') {\n return rhs;\n }\n if (rhs.type === 'Identifier') {\n const configId = rhs.name;\n\n const configDeclaration = program.body.find(\n (s): s is t.VariableDeclaration =>\n s.type === 'VariableDeclaration' &&\n !!s.declarations.find(\n (d) =>\n d.type === 'VariableDeclarator' &&\n d.id.type === 'Identifier' &&\n d.id.name === configId,\n ),\n );\n\n const declarator = configDeclaration?.declarations.find(\n (d): d is t.VariableDeclarator =>\n d.type === 'VariableDeclarator' &&\n d.id.type === 'Identifier' &&\n d.id.name === configId,\n );\n\n return declarator?.init?.type === 'ObjectExpression'\n ? declarator.init\n : undefined;\n }\n\n return undefined;\n}\n\nfunction getCjsModuleExports(\n program: t.Program,\n): t.AssignmentExpression | undefined {\n const moduleExports = program.body.find(\n (s): s is t.ExpressionStatement =>\n s.type === 'ExpressionStatement' &&\n s.expression.type === 'AssignmentExpression' &&\n s.expression.left.type === 'MemberExpression' &&\n s.expression.left.object.type === 'Identifier' &&\n s.expression.left.object.name === 'module' &&\n s.expression.left.property.type === 'Identifier' &&\n s.expression.left.property.name === 'exports',\n );\n return moduleExports?.expression as t.AssignmentExpression;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/webpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAE9B,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,+CAAiC;AAIjC,qDAAuC;AAEvC,6CAS2B;AAC3B,2DAA+D;AAO/D,qDAAmE;AACnE,6CAA0C;AAE1C,MAAM,cAAc,GAAG,CACrB,OAAgD,EAChD,MAAe,EACf,EAAE,CACF,IAAA,uBAAe,EAAC,MAAM,EAAE,CAAC,SAAS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Q,CACzB,CAAC;QAEF,OAAO,UAAU,EAAE,IAAI,EAAE,IAAI,KAAK,kBAAkB;YAClD,CAAC,CAAC,UAAU,CAAC,IAAI;YACjB,CAAC,CAAC,SAAS,CAAC;KACf;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAC1B,OAAkB;IAElB,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CACrC,CAAC,CAAC,EAA8B,EAAE,CAChC,CAAC,CAAC,IAAI,KAAK,qBAAqB;QAChC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,sBAAsB;QAC5C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,kBAAkB;QAC7C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;QAC9C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC1C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;QAChD,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAChD,CAAC;IACF,OAAO,aAAa,EAAE,UAAoC,CAAC;AAC7D,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\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 * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport * as Sentry from '@sentry/node';\n\nimport {\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askForToolConfigPath,\n createNewConfigFile,\n getPackageDotJson,\n installPackage,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../../utils/clack';\nimport { hasPackageInstalled } from '../../utils/package-json';\n\nimport type {\n SourceMapUploadToolConfigurationFunction,\n SourceMapUploadToolConfigurationOptions,\n} from './types';\n\nimport { findFile, hasSentryContent } from '../../utils/ast-utils';\nimport { debug } from '../../utils/debug';\n\nconst getCodeSnippet = (\n options: SourceMapUploadToolConfigurationOptions,\n colors: boolean,\n) =>\n makeCodeSnippet(colors, (unchanged, plus) =>\n unchanged(`${plus(\n 'const { sentryWebpackPlugin } = require(\"@sentry/webpack-plugin\");',\n )}\n\nmodule.exports = {\n // ... other options\n ${plus('devtool: \"source-map\", // Source map generation must be turned on')}\n plugins: [\n // Put the Sentry Webpack plugin after all other plugins\n ${plus(`sentryWebpackPlugin({\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 configureWebPackPlugin: SourceMapUploadToolConfigurationFunction =\n async (options) => {\n await installPackage({\n packageName: '@sentry/webpack-plugin',\n alreadyInstalled: hasPackageInstalled(\n '@sentry/webpack-plugin',\n await getPackageDotJson(),\n ),\n });\n\n const webpackConfigPath =\n findFile(path.resolve(process.cwd(), 'webpack.config')) ??\n (await askForToolConfigPath('Webpack', 'webpack.config.js'));\n\n let successfullyAdded = false;\n if (webpackConfigPath) {\n successfullyAdded = await modifyWebpackConfig(webpackConfigPath, options);\n } else {\n successfullyAdded = await createNewConfigFile(\n path.join(process.cwd(), 'webpack.config.js'),\n getCodeSnippet(options, false),\n 'More information about Webpack configs: https://vitejs.dev/config/',\n );\n Sentry.setTag(\n 'created-new-config',\n successfullyAdded ? 'success' : 'fail',\n );\n }\n\n if (successfullyAdded) {\n clack.log.info(\n `We recommend checking the ${\n webpackConfigPath ? 'modified' : 'added'\n } file after the wizard finished to ensure it works with your build setup.`,\n );\n\n Sentry.setTag('ast-mod', 'success');\n } else {\n Sentry.setTag('ast-mod', 'fail');\n await showCopyPasteInstructions(\n path.basename(webpackConfigPath || 'webpack.config.js'),\n getCodeSnippet(options, true),\n );\n }\n\n await addDotEnvSentryBuildPluginFile(options.authToken);\n };\n\n/**\n * Modifies a webpack config file to enable source map generation and add the Sentry webpack plugin\n * exported only for testing\n */\nexport async function modifyWebpackConfig(\n webpackConfigPath: string,\n options: SourceMapUploadToolConfigurationOptions,\n): Promise<boolean> {\n try {\n const webpackConfig = await fs.promises.readFile(webpackConfigPath, {\n encoding: 'utf-8',\n });\n\n const prettyConfigFilename = chalk.cyan(path.basename(webpackConfigPath));\n\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const program = recast.parse(webpackConfig.toString()).program as t.Program;\n\n if (!(await shouldModifyWebpackConfig(program, prettyConfigFilename))) {\n // Sentry tag is set in shouldModifyWebpackConfig\n return false;\n }\n\n const exportStmt = getCjsModuleExports(program);\n if (!exportStmt) {\n // We only care about CJS at the moment since it's probably the most widely used format for webpack configs.\n debug(`Could not find module.exports = {...} in ${webpackConfigPath}.`);\n Sentry.setTag('ast-mod-fail-reason', 'config-object-not-found');\n return false;\n }\n\n const configObject = getWebpackConfigObject(exportStmt, program);\n\n if (!configObject) {\n debug(`Couldn't find config object in ${webpackConfigPath}`);\n Sentry.setTag('ast-mod-fail-reason', 'config-object-not-found');\n return false;\n }\n\n const enabledSourcemaps = enableSourcemapsGeneration(configObject);\n\n if (enabledSourcemaps) {\n clack.log.success(\n `Enabled source map generation in ${prettyConfigFilename}.`,\n );\n } else {\n clack.log.warn(\n `Couldn't enable source maps generation in ${prettyConfigFilename} Please follow the instructions below.`,\n );\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n\n const addedPlugin = addSentryWebpackPlugin(program, configObject, options);\n if (addedPlugin) {\n clack.log.success(\n `Added Sentry webpack plugin to ${prettyConfigFilename}.`,\n );\n } else {\n clack.log.warn(\n `Couldn't add Sentry webpack plugin to ${prettyConfigFilename}. Please follow the instructions below.`,\n );\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n return false;\n }\n\n const code = recast.print(program).code;\n await fs.promises.writeFile(webpackConfigPath, code);\n\n return true;\n } catch (e) {\n Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');\n debug(e);\n return false;\n }\n}\n\nasync function shouldModifyWebpackConfig(\n program: t.Program,\n prettyConfigFilename: string,\n) {\n if (hasSentryContent(program)) {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `Seems like ${prettyConfigFilename} already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Webpack plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n return false;\n }\n }\n\n return true;\n}\n\nfunction addSentryWebpackPlugin(\n program: t.Program,\n configObj: t.ObjectExpression,\n options: SourceMapUploadToolConfigurationOptions,\n) {\n const b = addSentryWebpackPluginImport(program);\n\n const sentryPluginCall = b.callExpression(\n b.identifier('sentryWebpackPlugin'),\n [\n b.objectExpression([\n b.objectProperty(\n b.identifier('authToken'),\n b.identifier('process.env.SENTRY_AUTH_TOKEN'),\n ),\n b.objectProperty(b.identifier('org'), b.stringLiteral(options.orgSlug)),\n b.objectProperty(\n b.identifier('project'),\n b.stringLiteral(options.projectSlug),\n ),\n ...(options.selfHosted\n ? [\n b.objectProperty(\n b.identifier('url'),\n b.stringLiteral(options.url),\n ),\n ]\n : []),\n ]),\n ],\n );\n\n const pluginsProp = configObj.properties.find(\n (p): p is t.Property =>\n p.type === 'Property' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'plugins',\n );\n\n if (pluginsProp) {\n if (pluginsProp.value.type === 'ArrayExpression') {\n pluginsProp.value.elements.push(sentryPluginCall);\n } else {\n pluginsProp.value = b.arrayExpression([sentryPluginCall]);\n }\n return true;\n }\n\n configObj.properties.push(\n b.objectProperty(\n b.identifier('plugins'),\n b.arrayExpression([sentryPluginCall]),\n ),\n );\n\n return true;\n}\n\nfunction addSentryWebpackPluginImport(program: t.Program) {\n const b = recast.types.builders;\n\n const sentryPluginRequireStmt = b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('sentryWebpackPlugin'),\n value: b.identifier('sentryWebpackPlugin'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.stringLiteral('@sentry/webpack-plugin'),\n ]),\n ),\n ]);\n\n program.body.unshift(sentryPluginRequireStmt);\n return b;\n}\n\nfunction enableSourcemapsGeneration(configObj: t.ObjectExpression): boolean {\n const b = recast.types.builders;\n\n const devtoolProp = configObj.properties.find(\n (p): p is t.Property =>\n p.type === 'Property' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'devtool',\n );\n\n if (devtoolProp) {\n // devtool can have quite a lot of source maps values.\n // see: https://webpack.js.org/configuration/devtool/#devtool\n // For Sentry to work best, we should set it to \"source-map\" or \"hidden-source-map\"\n // Heuristic:\n // - all values that contain \"hidden\" will be set to \"hidden-source-map\"\n // - all other values will be set to \"source-map\"\n if (\n (devtoolProp.value.type === 'Literal' ||\n devtoolProp.value.type === 'StringLiteral') &&\n devtoolProp.value.value?.toString().startsWith('hidden-')\n ) {\n devtoolProp.value = b.stringLiteral('hidden-source-map');\n } else {\n devtoolProp.value = b.stringLiteral('source-map');\n }\n return true;\n }\n\n configObj.properties.push(\n b.objectProperty(b.identifier('devtool'), b.stringLiteral('source-map')),\n );\n\n return true;\n}\n\nfunction getWebpackConfigObject(\n moduleExports: t.AssignmentExpression,\n program: t.Program,\n): t.ObjectExpression | undefined {\n const rhs = moduleExports.right;\n if (rhs.type === 'ObjectExpression') {\n return rhs;\n }\n if (rhs.type === 'Identifier') {\n const configId = rhs.name;\n\n const configDeclaration = program.body.find(\n (s): s is t.VariableDeclaration =>\n s.type === 'VariableDeclaration' &&\n !!s.declarations.find(\n (d) =>\n d.type === 'VariableDeclarator' &&\n d.id.type === 'Identifier' &&\n d.id.name === configId,\n ),\n );\n\n const declarator = configDeclaration?.declarations.find(\n (d): d is t.VariableDeclarator =>\n d.type === 'VariableDeclarator' &&\n d.id.type === 'Identifier' &&\n d.id.name === configId,\n );\n\n return declarator?.init?.type === 'ObjectExpression'\n ? declarator.init\n : undefined;\n }\n\n return undefined;\n}\n\nfunction getCjsModuleExports(\n program: t.Program,\n): t.AssignmentExpression | undefined {\n const moduleExports = program.body.find(\n (s): s is t.ExpressionStatement =>\n s.type === 'ExpressionStatement' &&\n s.expression.type === 'AssignmentExpression' &&\n s.expression.left.type === 'MemberExpression' &&\n s.expression.left.object.type === 'Identifier' &&\n s.expression.left.object.name === 'module' &&\n s.expression.left.property.type === 'Identifier' &&\n s.expression.left.property.name === 'exports',\n );\n return moduleExports?.expression as t.AssignmentExpression;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.detectUsedTool = exports.TOOL_PACKAGE_MAP = void 0;
|
|
4
|
-
const
|
|
4
|
+
const clack_1 = require("../../utils/clack");
|
|
5
5
|
const package_json_1 = require("../../utils/package-json");
|
|
6
6
|
// A map of package names pointing to the tool slug.
|
|
7
7
|
// The order is important, because we want to detect the most specific tool first.
|
|
@@ -17,7 +17,7 @@ exports.TOOL_PACKAGE_MAP = {
|
|
|
17
17
|
typescript: 'tsc',
|
|
18
18
|
};
|
|
19
19
|
async function detectUsedTool() {
|
|
20
|
-
const packageJson = await (0,
|
|
20
|
+
const packageJson = await (0, clack_1.getPackageDotJson)();
|
|
21
21
|
const foundToolPackage = (0, package_json_1.findInstalledPackageFromList)(Object.keys(exports.TOOL_PACKAGE_MAP), packageJson);
|
|
22
22
|
if (foundToolPackage) {
|
|
23
23
|
return exports.TOOL_PACKAGE_MAP[foundToolPackage.name];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-tool.js","sourceRoot":"","sources":["../../../../src/sourcemaps/utils/detect-tool.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"detect-tool.js","sourceRoot":"","sources":["../../../../src/sourcemaps/utils/detect-tool.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AACtD,2DAAwE;AAexE,oDAAoD;AACpD,kFAAkF;AAClF,sEAAsE;AACtE,YAAY;AACC,QAAA,gBAAgB,GAAmC;IAC9D,eAAe,EAAE,SAAS;IAC1B,kBAAkB,EAAE,kBAAkB;IACtC,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEK,KAAK,UAAU,cAAc;IAClC,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,MAAM,gBAAgB,GAAG,IAAA,2CAA4B,EACnD,MAAM,CAAC,IAAI,CAAC,wBAAgB,CAAC,EAC7B,WAAW,CACZ,CAAC;IAEF,IAAI,gBAAgB,EAAE;QACpB,OAAO,wBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;KAChD;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAbD,wCAaC","sourcesContent":["import { getPackageDotJson } from '../../utils/clack';\nimport { findInstalledPackageFromList } from '../../utils/package-json';\n\nexport type SupportedTools =\n | 'webpack'\n | 'vite'\n | 'rollup'\n | 'esbuild'\n | 'tsc'\n | 'sentry-cli'\n | 'create-react-app'\n | 'angular'\n | 'nextjs'\n | 'remix'\n | 'no-tool';\n\n// A map of package names pointing to the tool slug.\n// The order is important, because we want to detect the most specific tool first.\n// For instance, webpack needs to come before tsc because typescript c\n// Similarly\nexport const TOOL_PACKAGE_MAP: Record<string, SupportedTools> = {\n '@angular/core': 'angular',\n 'create-react-app': 'create-react-app',\n webpack: 'webpack',\n vite: 'vite',\n esbuild: 'esbuild',\n rollup: 'rollup',\n typescript: 'tsc',\n};\n\nexport async function detectUsedTool(): Promise<SupportedTools> {\n const packageJson = await getPackageDotJson();\n\n const foundToolPackage = findInstalledPackageFromList(\n Object.keys(TOOL_PACKAGE_MAP),\n packageJson,\n );\n\n if (foundToolPackage) {\n return TOOL_PACKAGE_MAP[foundToolPackage.name];\n }\n\n return 'sentry-cli';\n}\n"]}
|
|
@@ -27,11 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.checkIfMoreSuitableWizardExistsAndAskForRedirect = void 0;
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
31
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
32
32
|
const chalk_1 = __importDefault(require("chalk"));
|
|
33
33
|
const sveltekit_wizard_1 = require("../../sveltekit/sveltekit-wizard");
|
|
34
|
-
const
|
|
34
|
+
const clack_1 = require("../../utils/clack");
|
|
35
35
|
const package_json_1 = require("../../utils/package-json");
|
|
36
36
|
const Sentry = __importStar(require("@sentry/node"));
|
|
37
37
|
const childProcess = __importStar(require("child_process"));
|
|
@@ -61,7 +61,7 @@ async function checkIfMoreSuitableWizardExistsAndAskForRedirect() {
|
|
|
61
61
|
exports.checkIfMoreSuitableWizardExistsAndAskForRedirect = checkIfMoreSuitableWizardExistsAndAskForRedirect;
|
|
62
62
|
async function checkIfMoreSuitableWizardExists() {
|
|
63
63
|
Sentry.setTag('using-wrong-wizard', false);
|
|
64
|
-
const packageJson = await (0,
|
|
64
|
+
const packageJson = await (0, clack_1.getPackageDotJson)();
|
|
65
65
|
const installedSdkPackage = (0, package_json_1.findInstalledPackageFromList)(Object.keys(sdkMap), packageJson);
|
|
66
66
|
if (!installedSdkPackage) {
|
|
67
67
|
return undefined;
|
|
@@ -92,7 +92,7 @@ ${sourcemapsDocsLink}
|
|
|
92
92
|
Troubleshooting Source Maps:
|
|
93
93
|
${troubleshootingDocsLink}
|
|
94
94
|
`);
|
|
95
|
-
const nextStep = await (0,
|
|
95
|
+
const nextStep = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
96
96
|
message: `Do you want to run the ${frameworkName} wizard now?`,
|
|
97
97
|
options: [
|
|
98
98
|
{
|
|
@@ -116,7 +116,7 @@ ${troubleshootingDocsLink}
|
|
|
116
116
|
case 'redirect':
|
|
117
117
|
return wizard;
|
|
118
118
|
case 'stop':
|
|
119
|
-
await (0,
|
|
119
|
+
await (0, clack_1.abort)('Exiting Wizard', 0);
|
|
120
120
|
break;
|
|
121
121
|
default:
|
|
122
122
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"other-wizards.js","sourceRoot":"","sources":["../../../../src/sourcemaps/utils/other-wizards.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"other-wizards.js","sourceRoot":"","sources":["../../../../src/sourcemaps/utils/other-wizards.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uEAAsE;AAEtE,6CAA+E;AAC/E,2DAGkC;AAElC,qDAAuC;AAGvC,4DAA8C;AAY9C,MAAM,MAAM,GAAkC;IAC5C,mBAAmB,EAAE;QACnB,aAAa,EAAE,WAAW;QAC1B,gBAAgB,EAAE,eAAe;QACjC,kBAAkB,EAChB,yGAAyG;QAC3G,uBAAuB,EACrB,6FAA6F;QAC/F,MAAM,EAAE,qCAAkB;KAC3B;IACD,sBAAsB,EAAE;QACtB,aAAa,EAAE,cAAc;QAC7B,gBAAgB,EAAE,cAAc;QAChC,kBAAkB,EAChB,2DAA2D;QAC7D,uBAAuB,EACrB,4EAA4E;QAC9E,MAAM,EAAE,oBAAoB;KAC7B;CACF,CAAC;AAEK,KAAK,UAAU,gDAAgD;IAGpE,MAAM,OAAO,GAAG,MAAM,+BAA+B,EAAE,CAAC;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iBAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,0BAA0B,aAAa,cAAc;QAC9D,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG,eAAK,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;aACtC;YACD;gBACE,KAAK,EAAE,+BAA+B;gBACtC,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,KAAK,EAAE,gCAAgC;gBACvC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,kBAAkB;aACzB;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;IAEjD,QAAQ,QAAQ,EAAE;QAChB,KAAK,UAAU;YACb,OAAO,MAAM,CAAC;QAChB,KAAK,MAAM;YACT,MAAM,IAAA,aAAK,EAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YACjC,MAAM;QACR;YACE,OAAO,SAAS,CAAC;KACpB;AACH,CAAC;AAED,SAAS,oBAAoB;IAC3B,MAAM,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,UAAU,CAAC,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IAEhD,IAAI;QACF,YAAY,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE;YACzC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;YAClB,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;KACJ;IAAC,MAAM;QACN,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;KACzB;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { runSvelteKitWizard } from '../../sveltekit/sveltekit-wizard';\n\nimport { abort, abortIfCancelled, getPackageDotJson } from '../../utils/clack';\nimport {\n findInstalledPackageFromList,\n hasPackageInstalled,\n} from '../../utils/package-json';\n\nimport * as Sentry from '@sentry/node';\nimport { WizardOptions } from '../../utils/types';\n\nimport * as childProcess from 'child_process';\n\ntype WizardFunction = (options: WizardOptions) => Promise<void>;\n\ntype FrameworkInfo = {\n frameworkName: string;\n frameworkPackage: string;\n troubleshootingDocsLink: string;\n sourcemapsDocsLink: string;\n wizard: WizardFunction;\n};\n\nconst sdkMap: Record<string, FrameworkInfo> = {\n '@sentry/sveltekit': {\n frameworkName: 'SvelteKit',\n frameworkPackage: '@sveltejs/kit',\n sourcemapsDocsLink:\n 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/#configure-source-maps-upload',\n troubleshootingDocsLink:\n 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/sourcemaps/troubleshooting_js/',\n wizard: runSvelteKitWizard,\n },\n '@sentry/react-native': {\n frameworkName: 'React Native',\n frameworkPackage: 'react-native',\n sourcemapsDocsLink:\n 'https://docs.sentry.io/platforms/react-native/sourcemaps/',\n troubleshootingDocsLink:\n 'https://docs.sentry.io/platforms/react-native/troubleshooting/#source-maps',\n wizard: runReactNativeWizard,\n },\n};\n\nexport async function checkIfMoreSuitableWizardExistsAndAskForRedirect(): Promise<\n WizardFunction | undefined\n> {\n const sdkName = await checkIfMoreSuitableWizardExists();\n\n if (!sdkName) {\n return undefined;\n }\n\n return await askForRedirect(sdkName);\n}\n\nasync function checkIfMoreSuitableWizardExists(): Promise<string | undefined> {\n Sentry.setTag('using-wrong-wizard', false);\n\n const packageJson = await getPackageDotJson();\n\n const installedSdkPackage = findInstalledPackageFromList(\n Object.keys(sdkMap),\n packageJson,\n );\n\n if (!installedSdkPackage) {\n return undefined;\n }\n\n const sdkPackageName = installedSdkPackage.name;\n\n const { frameworkPackage } = sdkMap[sdkPackageName];\n\n if (!hasPackageInstalled(frameworkPackage, packageJson)) {\n // The user has installed the SDK but not the framework.\n // Maybe it's a false positive and the user is using a different framework.\n // Let's not redirect them to the framework wizard in that case.\n return undefined;\n }\n\n Sentry.setTag('using-wrong-wizard', true);\n\n return sdkPackageName;\n}\n\nasync function askForRedirect(\n sdkName: string,\n): Promise<WizardFunction | undefined> {\n const { frameworkName, sourcemapsDocsLink, troubleshootingDocsLink, wizard } =\n sdkMap[sdkName];\n\n clack.log.warn(\n `${chalk.yellow(\n `It seems like you're using this wizard in a ${frameworkName} project.`,\n )}\n\nWe recommend using our dedicated ${frameworkName} wizard instead of this wizard.\nThe ${frameworkName} wizard will set up our ${sdkName} SDK and also configure uploading source maps for you.\n\nIf you already tried the ${frameworkName} wizard and it didn't work for you, check out the following guides:\n\nManual source maps configuration for ${frameworkName}:\n${sourcemapsDocsLink}\n\nTroubleshooting Source Maps:\n${troubleshootingDocsLink}\n`,\n );\n\n const nextStep: 'redirect' | 'continue' | 'stop' = await abortIfCancelled(\n clack.select({\n message: `Do you want to run the ${frameworkName} wizard now?`,\n options: [\n {\n label: 'Yes',\n value: 'redirect',\n hint: `${chalk.green('Recommended')}`,\n },\n {\n label: 'No, continue with this wizard',\n value: 'continue',\n },\n {\n label: \"No, I'll check out the guides \",\n value: 'stop',\n hint: 'Exit this wizard',\n },\n ],\n }),\n );\n\n Sentry.setTag('wrong-wizard-decision', nextStep);\n\n switch (nextStep) {\n case 'redirect':\n return wizard;\n case 'stop':\n await abort('Exiting Wizard', 0);\n break;\n default:\n return undefined;\n }\n}\n\nfunction runReactNativeWizard(): Promise<void> {\n const [runner, ...wizardArgs] = [...process.argv];\n wizardArgs.push('--integration', 'reactNative');\n\n try {\n childProcess.spawnSync(runner, wizardArgs, {\n cwd: process.cwd(),\n stdio: 'inherit',\n });\n } catch {\n return Promise.reject();\n }\n\n return Promise.resolve();\n}\n"]}
|
|
@@ -27,11 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ensureMinimumSdkVersionIsInstalled = void 0;
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
31
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
32
32
|
const chalk_1 = __importDefault(require("chalk"));
|
|
33
33
|
const semver_1 = require("semver");
|
|
34
|
-
const
|
|
34
|
+
const clack_1 = require("../../utils/clack");
|
|
35
35
|
const Sentry = __importStar(require("@sentry/node"));
|
|
36
36
|
const package_json_1 = require("../../utils/package-json");
|
|
37
37
|
const MINIMUM_DEBUG_ID_SDK_VERSION = '7.47.0';
|
|
@@ -80,7 +80,7 @@ const SENTRY_SDK_PACKAGE_NAMES = [
|
|
|
80
80
|
* -> We tell users to manually upgrade (migrate between majors)
|
|
81
81
|
*/
|
|
82
82
|
async function ensureMinimumSdkVersionIsInstalled() {
|
|
83
|
-
const installedSdkPackage = (0, package_json_1.findInstalledPackageFromList)(SENTRY_SDK_PACKAGE_NAMES, await (0,
|
|
83
|
+
const installedSdkPackage = (0, package_json_1.findInstalledPackageFromList)(SENTRY_SDK_PACKAGE_NAMES, await (0, clack_1.getPackageDotJson)());
|
|
84
84
|
// Case 1:
|
|
85
85
|
if (!installedSdkPackage) {
|
|
86
86
|
return await handleNoSdkInstalled();
|
|
@@ -117,7 +117,7 @@ async function handleManuallyUpdateSdk(minInstalledVersion) {
|
|
|
117
117
|
.info(`When upgrading from a version older than 7.0.0, make sure to follow the migration guide:
|
|
118
118
|
https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#upgrading-from-6x-to-7x
|
|
119
119
|
`);
|
|
120
|
-
const didUpdate = await (0,
|
|
120
|
+
const didUpdate = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
121
121
|
message: 'Did you update your SDK to the latest version?',
|
|
122
122
|
options: [
|
|
123
123
|
{
|
|
@@ -136,7 +136,7 @@ https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#upgradi
|
|
|
136
136
|
}
|
|
137
137
|
async function handleAutoUpdateSdk(packageName) {
|
|
138
138
|
Sentry.setTag('initial-sdk-version', '>=7.0.0 <7.47.0');
|
|
139
|
-
const shouldUpdate = await (0,
|
|
139
|
+
const shouldUpdate = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
140
140
|
message: 'Do you want to automatically update your SDK to the latest version?',
|
|
141
141
|
options: [
|
|
142
142
|
{
|
|
@@ -153,7 +153,7 @@ async function handleAutoUpdateSdk(packageName) {
|
|
|
153
153
|
initialValue: true,
|
|
154
154
|
}));
|
|
155
155
|
if (shouldUpdate) {
|
|
156
|
-
await (0,
|
|
156
|
+
await (0, clack_1.installPackage)({
|
|
157
157
|
packageName,
|
|
158
158
|
alreadyInstalled: true,
|
|
159
159
|
askBeforeUpdating: false, // we already did this above
|
|
@@ -169,7 +169,7 @@ We recommend setting up the SDK before continuing with the source maps wizard.
|
|
|
169
169
|
|
|
170
170
|
${chalk_1.default.dim(`Take a look at our docs to get started:
|
|
171
171
|
https://docs.sentry.io/`)}`);
|
|
172
|
-
const installedSDK = await (0,
|
|
172
|
+
const installedSDK = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
173
173
|
message: 'Did you set up your Sentry SDK?',
|
|
174
174
|
options: [
|
|
175
175
|
{ label: 'Yes, continue!', value: true },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-version.js","sourceRoot":"","sources":["../../../../src/sourcemaps/utils/sdk-version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,6DAAmC;AACnC,kDAA0B;AAC1B,mCAA+C;AAC/C,yDAIiC;AAEjC,qDAAuC;AACvC,2DAAwE;AAExE,MAAM,4BAA4B,GAAG,QAAQ,CAAC;AAE9C,+DAA+D;AAC/D,qEAAqE;AACrE,0EAA0E;AAC1E,qDAAqD;AACrD,MAAM,wBAAwB,GAAG;IAC/B,2DAA2D;IAC3D,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,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,MAAM,CACX,qBAAqB,EACrB,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,eAAe,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,0BAAkC,EAClC,gBAAwB;IAExB,IAAI;QACF,wEAAwE;QACxE,2EAA2E;QAC3E,iEAAiE;QACjE,MAAM,mBAAmB,GAAG,IAAA,mBAAU,EAAC,0BAA0B,CAAC,EAAE,OAAO,CAAC;QAC5E,IAAI,mBAAmB,EAAE;YACvB,OAAO,mBAAmB,CAAC;SAC5B;KACF;IAAC,MAAM;QACN,kDAAkD;KACnD;IAED,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAChD,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,GAAG,eAAK,CAAC,MAAM,CACb,uDAAuD,gBAAgB,OAAO,0BAA0B,IAAI,CAC7G;;8DAEyD,eAAK,CAAC,IAAI,CAClE,4BAA4B,CAC7B;KACA,CACF,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { minVersion, satisfies } from 'semver';\nimport {\n abortIfCancelled,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack-utils';\n\nimport * as Sentry from '@sentry/node';\nimport { findInstalledPackageFromList } from '../../utils/package-json';\n\nconst MINIMUM_DEBUG_ID_SDK_VERSION = '7.47.0';\n\n// This array is orderd by the SDKs we want to check for first.\n// The reason is that some SDKs depend on others and some users might\n// have added the dependencies to their package.json. We want to make sure\n// that we actually detect the \"top-level\" SDK first.\nconst SENTRY_SDK_PACKAGE_NAMES = [\n // SDKs using other framework SDKs need to be checked first\n '@sentry/astro',\n '@sentry/gatsby',\n '@sentry/nextjs',\n '@sentry/nuxt',\n '@sentry/remix',\n '@sentry/solidstart',\n '@sentry/sveltekit',\n\n // Framework SDKs\n '@sentry/angular',\n '@sentry/angular-ivy',\n '@sentry/aws-serverless',\n '@sentry/bun',\n '@sentry/ember',\n '@sentry/google-cloud-serverless',\n '@sentry/nestjs',\n '@sentry/react',\n '@sentry/solid',\n '@sentry/svelte',\n '@sentry/vue',\n '@sentry/serverless',\n\n // Base SDKs\n '@sentry/browser',\n '@sentry/node',\n '@sentry/deno',\n];\n\n/**\n * Check for a minimum SDK version and prompt the user to upgrade if necessary.\n * We distinguish between 4 cases here:\n *\n * 1. Users didn't install any SDK yet\n * -> We tell them to install an SDK and then continue with the wizard\n * 2. Users installed an SDK in the range >=7.47.0\n * -> All good, no need to do anything!\n * 3. Users installed an SDK in the range >=7.0.0 <= 7.46.0\n * -> We ask if they want to auto-update to the latest version\n * 4. Users installed an SDK in the range <7.x\n * -> We tell users to manually upgrade (migrate between majors)\n */\nexport async function ensureMinimumSdkVersionIsInstalled(): Promise<void> {\n const installedSdkPackage = findInstalledPackageFromList(\n SENTRY_SDK_PACKAGE_NAMES,\n await getPackageDotJson(),\n );\n\n // Case 1:\n if (!installedSdkPackage) {\n return await handleNoSdkInstalled();\n }\n\n const { name: installedSdkName, version: installedSdkVersionOrRange } =\n installedSdkPackage;\n\n Sentry.setTag('installed-sdk', installedSdkName);\n\n const minInstalledVersion = getMinInstalledVersion(\n installedSdkVersionOrRange,\n installedSdkName,\n );\n\n if (!minInstalledVersion) {\n // This is handled in the getMinInstalledVersion function\n return;\n }\n\n const hasDebugIdCompatibleSdkVersion = satisfies(\n minInstalledVersion,\n `>=${MINIMUM_DEBUG_ID_SDK_VERSION}`,\n );\n\n // Case 2:\n if (hasDebugIdCompatibleSdkVersion) {\n Sentry.setTag('initial-sdk-version', '>=7.47.0');\n return;\n }\n\n const hasV7SdkVersion = satisfies(minInstalledVersion, '>=7.0.0');\n\n clack.log.warn(\n `${chalk.yellowBright(\n `It seems like you're using an outdated version (${installedSdkVersionOrRange}) of the ${chalk.bold(\n installedSdkName,\n )} SDK.`,\n )}\nUploading source maps is easiest with an SDK from version ${chalk.bold(\n MINIMUM_DEBUG_ID_SDK_VERSION,\n )} or newer. \n`,\n );\n\n // Case 3:\n if (hasV7SdkVersion) {\n await handleAutoUpdateSdk(installedSdkName);\n return;\n }\n\n // Case 4:\n await handleManuallyUpdateSdk(minInstalledVersion);\n}\n\nasync function handleManuallyUpdateSdk(minInstalledVersion: string) {\n Sentry.setTag(\n 'initial-sdk-version',\n `${satisfies(minInstalledVersion, '>=6.0.0') ? '6.x' : '<6.0.0'}`,\n );\n\n clack.log\n .info(`When upgrading from a version older than 7.0.0, make sure to follow the migration guide:\nhttps://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#upgrading-from-6x-to-7x\n`);\n\n const didUpdate = await abortIfCancelled(\n clack.select({\n message: 'Did you update your SDK to the latest version?',\n options: [\n {\n label: 'Yes!',\n value: true,\n },\n {\n label: \"No, I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n `Remember to update your SDK to at least ${MINIMUM_DEBUG_ID_SDK_VERSION}.`,\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag(\n 'resolved-sdk-status',\n didUpdate ? 'updated-manually' : 'update-later',\n );\n}\n\nasync function handleAutoUpdateSdk(packageName: string) {\n Sentry.setTag('initial-sdk-version', '>=7.0.0 <7.47.0');\n\n const shouldUpdate = await abortIfCancelled(\n clack.select({\n message:\n 'Do you want to automatically update your SDK to the latest version?',\n options: [\n {\n label: 'Yes!',\n value: true,\n hint: chalk.green('Recommended'),\n },\n {\n label: \"No, I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n `Remember to update your SDK to at least ${MINIMUM_DEBUG_ID_SDK_VERSION}.`,\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n if (shouldUpdate) {\n await installPackage({\n packageName,\n alreadyInstalled: true,\n askBeforeUpdating: false, // we already did this above\n });\n }\n\n Sentry.setTag(\n 'resolved-sdk-status',\n shouldUpdate ? 'updated-automatically' : 'update-later',\n );\n}\n\nasync function handleNoSdkInstalled(): Promise<void> {\n Sentry.setTag('initial-sdk-version', 'none');\n Sentry.setTag('installed-sdk', 'none');\n\n clack.log.warn(\n `${chalk.yellowBright(\n `It seems like you didn't yet install a Sentry SDK in your project.`,\n )}\nWe recommend setting up the SDK before continuing with the source maps wizard.\n\n${chalk.dim(`Take a look at our docs to get started:\nhttps://docs.sentry.io/`)}`,\n );\n\n const installedSDK = await abortIfCancelled(\n clack.select({\n message: 'Did you set up your Sentry SDK?',\n options: [\n { label: 'Yes, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n 'You need to set up an SDK before you can use Sentry',\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag(\n 'resolved-sdk-status',\n installedSDK ? 'installed-manually' : 'install-later',\n );\n}\n\nfunction getMinInstalledVersion(\n installedSdkVersionOrRange: string,\n installedSdkName: string,\n): string | undefined {\n try {\n // If `minVersion` is unable to parse the version it will throw an error\n // However, it will also return `null` if the parameter is undefined, which\n // we explicitly checked before but the typing doesn't know that.\n const minInstalledVersion = minVersion(installedSdkVersionOrRange)?.version;\n if (minInstalledVersion) {\n return minInstalledVersion;\n }\n } catch {\n // handling this, along with the `null` case below\n }\n\n Sentry.setTag('initial-sdk-version', 'unknown');\n clack.log.warn(\n `${chalk.yellow(\n `Could not parse the version of your installed SDK (\"${installedSdkName}\": \"${installedSdkVersionOrRange}\")`,\n )}\n\nPlease make sure that your Sentry SDK is updated to version ${chalk.bold(\n MINIMUM_DEBUG_ID_SDK_VERSION,\n )} or newer.\n `,\n );\n\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-version.js","sourceRoot":"","sources":["../../../../src/sourcemaps/utils/sdk-version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAA+C;AAC/C,6CAI2B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,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE;YACxC;gBACE,KAAK,EAAE,qBAAqB;gBAC5B,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,eAAK,CAAC,MAAM,CAChB,qDAAqD,CACtD;aACF;SACF;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,MAAM,CACX,qBAAqB,EACrB,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,eAAe,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,0BAAkC,EAClC,gBAAwB;IAExB,IAAI;QACF,wEAAwE;QACxE,2EAA2E;QAC3E,iEAAiE;QACjE,MAAM,mBAAmB,GAAG,IAAA,mBAAU,EAAC,0BAA0B,CAAC,EAAE,OAAO,CAAC;QAC5E,IAAI,mBAAmB,EAAE;YACvB,OAAO,mBAAmB,CAAC;SAC5B;KACF;IAAC,MAAM;QACN,kDAAkD;KACnD;IAED,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAChD,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,GAAG,eAAK,CAAC,MAAM,CACb,uDAAuD,gBAAgB,OAAO,0BAA0B,IAAI,CAC7G;;8DAEyD,eAAK,CAAC,IAAI,CAClE,4BAA4B,CAC7B;KACA,CACF,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { minVersion, satisfies } from 'semver';\nimport {\n abortIfCancelled,\n getPackageDotJson,\n installPackage,\n} from '../../utils/clack';\n\nimport * as Sentry from '@sentry/node';\nimport { findInstalledPackageFromList } from '../../utils/package-json';\n\nconst MINIMUM_DEBUG_ID_SDK_VERSION = '7.47.0';\n\n// This array is orderd by the SDKs we want to check for first.\n// The reason is that some SDKs depend on others and some users might\n// have added the dependencies to their package.json. We want to make sure\n// that we actually detect the \"top-level\" SDK first.\nconst SENTRY_SDK_PACKAGE_NAMES = [\n // SDKs using other framework SDKs need to be checked first\n '@sentry/astro',\n '@sentry/gatsby',\n '@sentry/nextjs',\n '@sentry/nuxt',\n '@sentry/remix',\n '@sentry/solidstart',\n '@sentry/sveltekit',\n\n // Framework SDKs\n '@sentry/angular',\n '@sentry/angular-ivy',\n '@sentry/aws-serverless',\n '@sentry/bun',\n '@sentry/ember',\n '@sentry/google-cloud-serverless',\n '@sentry/nestjs',\n '@sentry/react',\n '@sentry/solid',\n '@sentry/svelte',\n '@sentry/vue',\n '@sentry/serverless',\n\n // Base SDKs\n '@sentry/browser',\n '@sentry/node',\n '@sentry/deno',\n];\n\n/**\n * Check for a minimum SDK version and prompt the user to upgrade if necessary.\n * We distinguish between 4 cases here:\n *\n * 1. Users didn't install any SDK yet\n * -> We tell them to install an SDK and then continue with the wizard\n * 2. Users installed an SDK in the range >=7.47.0\n * -> All good, no need to do anything!\n * 3. Users installed an SDK in the range >=7.0.0 <= 7.46.0\n * -> We ask if they want to auto-update to the latest version\n * 4. Users installed an SDK in the range <7.x\n * -> We tell users to manually upgrade (migrate between majors)\n */\nexport async function ensureMinimumSdkVersionIsInstalled(): Promise<void> {\n const installedSdkPackage = findInstalledPackageFromList(\n SENTRY_SDK_PACKAGE_NAMES,\n await getPackageDotJson(),\n );\n\n // Case 1:\n if (!installedSdkPackage) {\n return await handleNoSdkInstalled();\n }\n\n const { name: installedSdkName, version: installedSdkVersionOrRange } =\n installedSdkPackage;\n\n Sentry.setTag('installed-sdk', installedSdkName);\n\n const minInstalledVersion = getMinInstalledVersion(\n installedSdkVersionOrRange,\n installedSdkName,\n );\n\n if (!minInstalledVersion) {\n // This is handled in the getMinInstalledVersion function\n return;\n }\n\n const hasDebugIdCompatibleSdkVersion = satisfies(\n minInstalledVersion,\n `>=${MINIMUM_DEBUG_ID_SDK_VERSION}`,\n );\n\n // Case 2:\n if (hasDebugIdCompatibleSdkVersion) {\n Sentry.setTag('initial-sdk-version', '>=7.47.0');\n return;\n }\n\n const hasV7SdkVersion = satisfies(minInstalledVersion, '>=7.0.0');\n\n clack.log.warn(\n `${chalk.yellowBright(\n `It seems like you're using an outdated version (${installedSdkVersionOrRange}) of the ${chalk.bold(\n installedSdkName,\n )} SDK.`,\n )}\nUploading source maps is easiest with an SDK from version ${chalk.bold(\n MINIMUM_DEBUG_ID_SDK_VERSION,\n )} or newer. \n`,\n );\n\n // Case 3:\n if (hasV7SdkVersion) {\n await handleAutoUpdateSdk(installedSdkName);\n return;\n }\n\n // Case 4:\n await handleManuallyUpdateSdk(minInstalledVersion);\n}\n\nasync function handleManuallyUpdateSdk(minInstalledVersion: string) {\n Sentry.setTag(\n 'initial-sdk-version',\n `${satisfies(minInstalledVersion, '>=6.0.0') ? '6.x' : '<6.0.0'}`,\n );\n\n clack.log\n .info(`When upgrading from a version older than 7.0.0, make sure to follow the migration guide:\nhttps://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#upgrading-from-6x-to-7x\n`);\n\n const didUpdate = await abortIfCancelled(\n clack.select({\n message: 'Did you update your SDK to the latest version?',\n options: [\n {\n label: 'Yes!',\n value: true,\n },\n {\n label: \"No, I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n `Remember to update your SDK to at least ${MINIMUM_DEBUG_ID_SDK_VERSION}.`,\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag(\n 'resolved-sdk-status',\n didUpdate ? 'updated-manually' : 'update-later',\n );\n}\n\nasync function handleAutoUpdateSdk(packageName: string) {\n Sentry.setTag('initial-sdk-version', '>=7.0.0 <7.47.0');\n\n const shouldUpdate = await abortIfCancelled(\n clack.select({\n message:\n 'Do you want to automatically update your SDK to the latest version?',\n options: [\n {\n label: 'Yes!',\n value: true,\n hint: chalk.green('Recommended'),\n },\n {\n label: \"No, I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n `Remember to update your SDK to at least ${MINIMUM_DEBUG_ID_SDK_VERSION}.`,\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n if (shouldUpdate) {\n await installPackage({\n packageName,\n alreadyInstalled: true,\n askBeforeUpdating: false, // we already did this above\n });\n }\n\n Sentry.setTag(\n 'resolved-sdk-status',\n shouldUpdate ? 'updated-automatically' : 'update-later',\n );\n}\n\nasync function handleNoSdkInstalled(): Promise<void> {\n Sentry.setTag('initial-sdk-version', 'none');\n Sentry.setTag('installed-sdk', 'none');\n\n clack.log.warn(\n `${chalk.yellowBright(\n `It seems like you didn't yet install a Sentry SDK in your project.`,\n )}\nWe recommend setting up the SDK before continuing with the source maps wizard.\n\n${chalk.dim(`Take a look at our docs to get started:\nhttps://docs.sentry.io/`)}`,\n );\n\n const installedSDK = await abortIfCancelled(\n clack.select({\n message: 'Did you set up your Sentry SDK?',\n options: [\n { label: 'Yes, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n 'You need to set up an SDK before you can use Sentry',\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag(\n 'resolved-sdk-status',\n installedSDK ? 'installed-manually' : 'install-later',\n );\n}\n\nfunction getMinInstalledVersion(\n installedSdkVersionOrRange: string,\n installedSdkName: string,\n): string | undefined {\n try {\n // If `minVersion` is unable to parse the version it will throw an error\n // However, it will also return `null` if the parameter is undefined, which\n // we explicitly checked before but the typing doesn't know that.\n const minInstalledVersion = minVersion(installedSdkVersionOrRange)?.version;\n if (minInstalledVersion) {\n return minInstalledVersion;\n }\n } catch {\n // handling this, along with the `null` case below\n }\n\n Sentry.setTag('initial-sdk-version', 'unknown');\n clack.log.warn(\n `${chalk.yellow(\n `Could not parse the version of your installed SDK (\"${installedSdkName}\": \"${installedSdkVersionOrRange}\")`,\n )}\n\nPlease make sure that your Sentry SDK is updated to version ${chalk.bold(\n MINIMUM_DEBUG_ID_SDK_VERSION,\n )} or newer.\n `,\n );\n\n return undefined;\n}\n"]}
|
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.createExamplePage = void 0;
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const path = __importStar(require("path"));
|
|
32
|
-
// @ts-
|
|
32
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
33
33
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
34
34
|
const templates_1 = require("./templates");
|
|
35
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B
|
|
1
|
+
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+EAA+E;AAC/E,6DAAmC;AAGnC,2CAGqB;AAErB;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,YAAiC,EACjC,YAKC;IAED,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,IAAI,YAAY,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CACnC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAC7C,CAAC;IAEF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QACnC,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yDAAyD,eAAe,EAAE,CAC3E,CAAC;QACF,EAAE,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACpD;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;KAChC;SAAM;QACL,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,uDAAuD,IAAI,CAAC,QAAQ,CAClE,gBAAgB,CACjB,wCAAwC,CAC1C,CAAC;QACF,OAAO;KACR;IAED,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,EAC3C,IAAA,sCAA0B,EAAC,YAAY,CAAC,CACzC,CAAC;IAEF,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,EACzC,IAAA,oCAAwB,GAAE,CAC3B,CAAC;AACJ,CAAC;AAzCD,8CAyCC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport { PartialSvelteConfig } from './sdk-setup';\nimport {\n getSentryExampleApiRoute,\n getSentryExampleSveltePage,\n} from './templates';\n\n/**\n * Creates example page and API route to test Sentry\n */\nexport async function createExamplePage(\n svelteConfig: PartialSvelteConfig,\n projectProps: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n },\n): Promise<void> {\n const routesDirectory = svelteConfig.kit?.files?.routes || 'src/routes';\n const exampleRoutePath = path.resolve(\n path.join(routesDirectory, 'sentry-example'),\n );\n\n if (!fs.existsSync(routesDirectory)) {\n clack.log.warn(\n `Couldn't find your routes directory. Creating it now: ${routesDirectory}`,\n );\n fs.mkdirSync(routesDirectory, { recursive: true });\n }\n\n if (!fs.existsSync(exampleRoutePath)) {\n fs.mkdirSync(exampleRoutePath);\n } else {\n clack.log.warn(\n `It seems like a sentry example page already exists (${path.basename(\n exampleRoutePath,\n )}). Skipping creation of example route.`,\n );\n return;\n }\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+page.svelte'),\n getSentryExampleSveltePage(projectProps),\n );\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+server.js'),\n getSentryExampleApiRoute(),\n );\n}\n"]}
|
|
@@ -32,20 +32,20 @@ const path = __importStar(require("path"));
|
|
|
32
32
|
const url = __importStar(require("url"));
|
|
33
33
|
const chalk_1 = __importDefault(require("chalk"));
|
|
34
34
|
const Sentry = __importStar(require("@sentry/node"));
|
|
35
|
-
|
|
35
|
+
//@ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
36
36
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
37
|
-
// @ts-
|
|
37
|
+
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
38
38
|
const magicast_1 = require("magicast");
|
|
39
|
-
// @ts-
|
|
39
|
+
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
40
40
|
const helpers_1 = require("magicast/helpers");
|
|
41
41
|
const templates_1 = require("./templates");
|
|
42
|
-
const
|
|
42
|
+
const clack_1 = require("../utils/clack");
|
|
43
43
|
const debug_1 = require("../utils/debug");
|
|
44
44
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
45
45
|
const telemetry_1 = require("../telemetry");
|
|
46
46
|
const SVELTE_CONFIG_FILE = 'svelte.config.js';
|
|
47
47
|
async function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
|
|
48
|
-
const selectedFeatures = await (0,
|
|
48
|
+
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
|
|
49
49
|
{
|
|
50
50
|
id: 'performance',
|
|
51
51
|
prompt: `Do you want to enable ${chalk_1.default.bold('Tracing')} to track the performance of your application?`,
|
|
@@ -62,7 +62,7 @@ async function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
|
|
|
62
62
|
const originalClientHooksFile = (0, ast_utils_1.findFile)(clientHooksPath);
|
|
63
63
|
const originalServerHooksFile = (0, ast_utils_1.findFile)(serverHooksPath);
|
|
64
64
|
const viteConfig = (0, ast_utils_1.findFile)(path.resolve(process.cwd(), 'vite.config'));
|
|
65
|
-
const fileEnding = (0,
|
|
65
|
+
const fileEnding = (0, clack_1.isUsingTypeScript)() ? 'ts' : 'js';
|
|
66
66
|
const { dsn } = projectInfo;
|
|
67
67
|
Sentry.setTag('client-hooks-file-strategy', originalClientHooksFile ? 'merge' : 'create');
|
|
68
68
|
if (!originalClientHooksFile) {
|
|
@@ -190,7 +190,7 @@ originalHooksMod, selectedFeatures) {
|
|
|
190
190
|
const originalHooksModAST = originalHooksMod.$ast;
|
|
191
191
|
const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);
|
|
192
192
|
originalHooksModAST.body.splice(initCallInsertionIndex, 0,
|
|
193
|
-
// @ts-
|
|
193
|
+
// @ts-expect-error - string works here because the AST is proxified by magicast
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
195
195
|
(0, magicast_1.generateCode)(initCallWithComment).code);
|
|
196
196
|
}
|
|
@@ -209,7 +209,7 @@ originalHooksMod, selectedFeatures) {
|
|
|
209
209
|
const originalHooksModAST = originalHooksMod.$ast;
|
|
210
210
|
const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);
|
|
211
211
|
originalHooksModAST.body.splice(initCallInsertionIndex, 0,
|
|
212
|
-
// @ts-
|
|
212
|
+
// @ts-expect-error - string works here because the AST is proxified by magicast
|
|
213
213
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
214
214
|
(0, magicast_1.generateCode)(initCall).code);
|
|
215
215
|
}
|
|
@@ -237,14 +237,14 @@ function wrapHandleError(mod) {
|
|
|
237
237
|
else if (declaration.type === 'VariableDeclaration') {
|
|
238
238
|
const declarations = declaration.declarations;
|
|
239
239
|
declarations.forEach((declaration) => {
|
|
240
|
-
// @ts-
|
|
240
|
+
// @ts-expect-error - id should always have a name in this case
|
|
241
241
|
if (!declaration.id || declaration.id.name !== 'handleError') {
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
foundHandleError = true;
|
|
245
245
|
const userCode = declaration.init;
|
|
246
246
|
const stringifiedUserCode = userCode ? (0, magicast_1.generateCode)(userCode).code : '';
|
|
247
|
-
// @ts-
|
|
247
|
+
// @ts-expect-error - we can just place a string here, magicast will convert it to a node
|
|
248
248
|
declaration.init = `Sentry.handleErrorWithSentry(${stringifiedUserCode})`;
|
|
249
249
|
});
|
|
250
250
|
}
|
|
@@ -278,13 +278,14 @@ function wrapHandle(mod) {
|
|
|
278
278
|
else if (declaration.type === 'VariableDeclaration') {
|
|
279
279
|
const declarations = declaration.declarations;
|
|
280
280
|
declarations.forEach((declaration) => {
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
if (!declaration.id ||
|
|
282
|
+
declaration.id.type !== 'Identifier' ||
|
|
283
|
+
(declaration.id.name && declaration.id.name !== 'handle')) {
|
|
283
284
|
return;
|
|
284
285
|
}
|
|
285
286
|
const userCode = declaration.init;
|
|
286
287
|
const stringifiedUserCode = userCode ? (0, magicast_1.generateCode)(userCode).code : '';
|
|
287
|
-
// @ts-
|
|
288
|
+
// @ts-expect-error - we can just place a string here, magicast will convert it to a node
|
|
288
289
|
declaration.init = `sequence(Sentry.sentryHandle(), ${stringifiedUserCode})`;
|
|
289
290
|
foundHandle = true;
|
|
290
291
|
});
|
|
@@ -378,7 +379,7 @@ It may not seem like it but sometimes our magical powers are limited ;)`)}`);
|
|
|
378
379
|
// Intentionally logging to console here for easier copy/pasting
|
|
379
380
|
// eslint-disable-next-line no-console
|
|
380
381
|
console.log(codeSnippet);
|
|
381
|
-
await (0,
|
|
382
|
+
await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
382
383
|
message: 'Did you copy the snippet above?',
|
|
383
384
|
options: [
|
|
384
385
|
{ label: 'Yes!', value: true, hint: "Great, that's already it!" },
|