@sentry/wizard 3.42.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.node-cache/node-v22.14.0-darwin-arm64 +0 -0
- package/.node-cache/node-v22.14.0-darwin-x64 +0 -0
- package/.node-cache/node-v22.14.0-linux-arm64 +0 -0
- package/.node-cache/node-v22.14.0-linux-x64 +0 -0
- package/.node-cache/node-v22.14.0-win-x64.exe +0 -0
- package/CHANGELOG.md +30 -0
- package/COPYING +3575 -0
- package/bin.ts +85 -80
- package/dist/bin.js +44 -35
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/jest.config.js +1 -1
- package/dist/e2e-tests/jest.config.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +62 -147
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs.test.js +77 -175
- package/dist/e2e-tests/tests/nextjs.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +61 -162
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +62 -163
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +147 -189
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +133 -187
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +113 -195
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.js +5 -5
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/BottomBar.d.ts +1 -1
- package/dist/lib/Helper/BottomBar.js +14 -15
- package/dist/lib/Helper/BottomBar.js.map +1 -1
- package/dist/lib/Helper/Env.js +5 -2
- package/dist/lib/Helper/Env.js.map +1 -1
- package/dist/lib/Helper/File.js +14 -27
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Git.js +24 -59
- package/dist/lib/Helper/Git.js.map +1 -1
- package/dist/lib/Helper/Logging.js +2 -2
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/MergeConfig.js +4 -4
- package/dist/lib/Helper/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +4 -1
- package/dist/lib/Helper/Package.js +12 -38
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/SentryCli.js +77 -149
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +29 -124
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/File.js +4 -4
- package/dist/lib/Helper/__tests__/File.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +24 -24
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +33 -23
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.js +23 -85
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/BaseStep.js +8 -8
- package/dist/lib/Steps/BaseStep.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +80 -125
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/ConfigureProject.js +6 -66
- package/dist/lib/Steps/ConfigureProject.js.map +1 -1
- package/dist/lib/Steps/Initial.js +16 -104
- package/dist/lib/Steps/Initial.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +24 -118
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +95 -183
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js +87 -145
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +40 -148
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/OpenSentry.js +63 -126
- package/dist/lib/Steps/OpenSentry.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.js +110 -206
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/Result.js +19 -79
- package/dist/lib/Steps/Result.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js +57 -148
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/ShouldConfigure.js +6 -66
- package/dist/lib/Steps/ShouldConfigure.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.js +43 -120
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Steps/Welcome.js +17 -76
- package/dist/lib/Steps/Welcome.js.map +1 -1
- package/dist/lib/__tests__/Env.js +3 -3
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/android/android-wizard.js +100 -176
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.js +24 -33
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +106 -165
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/android/manifest.js +26 -27
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/android/templates.js +76 -23
- package/dist/src/android/templates.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +129 -225
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/cocoapod.js +47 -109
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.js +32 -35
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/fastlane.js +51 -97
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.js +41 -5
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +2 -2
- package/dist/src/apple/xcode-manager.js +93 -108
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.js +79 -127
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +75 -136
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.js +48 -12
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +527 -805
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.js +380 -40
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nextjs/utils.js +5 -5
- package/dist/src/nextjs/utils.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +91 -188
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-example.js +68 -137
- package/dist/src/nuxt/sdk-example.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.d.ts +4 -4
- package/dist/src/nuxt/sdk-setup.js +180 -336
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +195 -18
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/utils.js +29 -76
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +41 -94
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.d.ts +1 -1
- package/dist/src/react-native/expo-metro.js +75 -130
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +61 -114
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/git.js +23 -56
- package/dist/src/react-native/git.js.map +1 -1
- package/dist/src/react-native/glob.js +3 -3
- package/dist/src/react-native/glob.js.map +1 -1
- package/dist/src/react-native/gradle.js +4 -4
- package/dist/src/react-native/gradle.js.map +1 -1
- package/dist/src/react-native/javascript.js +51 -95
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +176 -296
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +267 -418
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/uninstall.js +37 -80
- package/dist/src/react-native/uninstall.js.map +1 -1
- package/dist/src/react-native/xcode.js +57 -55
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/codemods/express-server.js +27 -82
- package/dist/src/remix/codemods/express-server.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +28 -31
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/codemods/root-common.js +11 -11
- package/dist/src/remix/codemods/root-common.js.map +1 -1
- package/dist/src/remix/codemods/root-v1.js +17 -67
- package/dist/src/remix/codemods/root-v1.js.map +1 -1
- package/dist/src/remix/codemods/root-v2.js +89 -140
- package/dist/src/remix/codemods/root-v2.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +181 -343
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +84 -66
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +161 -293
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/remix/templates.js +10 -2
- package/dist/src/remix/templates.js.map +1 -1
- package/dist/src/remix/utils.js +13 -14
- package/dist/src/remix/utils.js.map +1 -1
- package/dist/src/run.js +106 -178
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +248 -372
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.js +32 -66
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.js +14 -59
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
- package/dist/src/sourcemaps/tools/esbuild.js +34 -77
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.d.ts +2 -2
- package/dist/src/sourcemaps/tools/nextjs.js +75 -102
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +53 -93
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +35 -76
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +157 -289
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +68 -134
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +111 -196
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.d.ts +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +158 -260
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +9 -54
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +77 -144
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +112 -191
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +20 -70
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +250 -411
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +107 -191
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +147 -13
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/sveltekit/utils.js +3 -3
- package/dist/src/sveltekit/utils.js.map +1 -1
- package/dist/src/telemetry.d.ts +2 -2
- package/dist/src/telemetry.js +58 -108
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/ast-utils.js +39 -54
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/bash.js +28 -75
- package/dist/src/utils/bash.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +3 -7
- package/dist/src/utils/clack-utils.js +688 -1083
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/debug.js +6 -10
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/package-json.js +5 -6
- package/dist/src/utils/package-json.js.map +1 -1
- package/dist/src/utils/package-manager.js +65 -139
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/release-registry.js +12 -59
- package/dist/src/utils/release-registry.js.map +1 -1
- package/dist/src/utils/semver.js +3 -4
- package/dist/src/utils/semver.js.map +1 -1
- package/dist/src/utils/sentrycli-utils.js +4 -4
- package/dist/src/utils/sentrycli-utils.js.map +1 -1
- package/dist/src/utils/url.js +5 -6
- package/dist/src/utils/url.js.map +1 -1
- package/dist/test/android/code-tools.test.js +18 -18
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +154 -299
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +375 -263
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +319 -271
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +114 -30
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +230 -234
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +119 -48
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +63 -20
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +332 -43
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +161 -33
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +61 -15
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/expo.test.js +37 -17
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/gradle.test.js +260 -28
- package/dist/test/react-native/gradle.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +85 -19
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +261 -187
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +243 -62
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +81 -21
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/remix/server-instrumentation.test.js +21 -8
- package/dist/test/remix/server-instrumentation.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +20 -72
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/tsc.test.js +142 -68
- package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +106 -75
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/webpack.test.js +226 -102
- package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +117 -18
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +99 -58
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack-utils.test.js +142 -247
- package/dist/test/utils/clack-utils.test.js.map +1 -1
- package/e2e-tests/package.json +1 -1
- package/e2e-tests/tests/flutter.test.ts +20 -20
- package/e2e-tests/tests/nextjs.test.ts +2 -2
- package/e2e-tests/tests/nuxt-3.test.ts +4 -4
- package/e2e-tests/tests/nuxt-4.test.ts +3 -3
- package/e2e-tests/tests/remix.test.ts +3 -3
- package/e2e-tests/tests/sveltekit.test.ts +3 -3
- package/e2e-tests/utils/index.ts +33 -15
- package/lib/Helper/BottomBar.ts +1 -1
- package/lib/Helper/Env.ts +1 -1
- package/lib/Helper/Package.ts +12 -10
- package/lib/Helper/SentryCli.ts +18 -27
- package/lib/Helper/Wizard.ts +1 -2
- package/lib/Setup.ts +4 -5
- package/lib/Steps/ChooseIntegration.ts +40 -8
- package/lib/Steps/Initial.ts +17 -26
- package/lib/Steps/Integrations/BaseIntegration.ts +2 -8
- package/lib/Steps/Integrations/Cordova.ts +9 -15
- package/lib/Steps/Integrations/Electron.ts +23 -20
- package/lib/Steps/Integrations/MobileProject.ts +18 -15
- package/lib/Steps/OpenSentry.ts +12 -7
- package/lib/Steps/PromptForParameters.ts +12 -19
- package/lib/Steps/SentryProjectSelector.ts +30 -29
- package/lib/Steps/WaitForSentry.ts +29 -23
- package/package.json +12 -8
- package/src/apple/xcode-manager.ts +10 -10
- package/src/nextjs/templates.ts +2 -6
- package/src/nuxt/sdk-setup.ts +21 -18
- package/src/react-native/expo-metro.ts +2 -2
- package/src/react-native/react-native-wizard.ts +1 -2
- package/src/react-native/uninstall.ts +1 -2
- package/src/react-native/xcode.ts +1 -1
- package/src/run.ts +12 -5
- package/src/sourcemaps/tools/nextjs.ts +2 -5
- package/src/sourcemaps/tools/webpack.ts +3 -3
- package/src/telemetry.ts +27 -7
- package/src/utils/clack-utils.ts +50 -47
- package/test/apple/cocoapod.test.ts +4 -0
- package/test/apple/fastfile.test.ts +12 -7
- package/test/apple/xcode-manager.test.ts +13 -11
- package/test/nextjs/templates.test.ts +0 -12
- package/test/utils/clack-utils.test.ts +40 -50
- package/types/read-env.d.ts +3 -0
- package/types/xcode.d.ts +1 -0
- package/dist/package.json +0 -128
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -33,131 +22,67 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
22
|
__setModuleDefault(result, mod);
|
|
34
23
|
return result;
|
|
35
24
|
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
|
-
if (ar || !(i in from)) {
|
|
75
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
76
|
-
ar[i] = from[i];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
80
|
-
};
|
|
81
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
82
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
27
|
};
|
|
84
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
29
|
exports.loadSvelteConfig = exports.createOrMergeSvelteKitFiles = void 0;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const url = __importStar(require("url"));
|
|
33
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
34
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
91
35
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
92
|
-
|
|
36
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
93
37
|
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
94
|
-
|
|
38
|
+
const magicast_1 = require("magicast");
|
|
95
39
|
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
prompts_1.default.log.info('No server hooks file found, creating a new one.');
|
|
143
|
-
return [4 /*yield*/, createNewHooksFile("".concat(serverHooksPath, ".").concat(fileEnding), 'server', dsn, selectedFeatures)];
|
|
144
|
-
case 6:
|
|
145
|
-
_b.sent();
|
|
146
|
-
return [3 /*break*/, 9];
|
|
147
|
-
case 7: return [4 /*yield*/, mergeHooksFile(originalServerHooksFile, 'server', dsn, selectedFeatures)];
|
|
148
|
-
case 8:
|
|
149
|
-
_b.sent();
|
|
150
|
-
_b.label = 9;
|
|
151
|
-
case 9:
|
|
152
|
-
if (!viteConfig) return [3 /*break*/, 11];
|
|
153
|
-
return [4 /*yield*/, modifyViteConfig(viteConfig, projectInfo)];
|
|
154
|
-
case 10:
|
|
155
|
-
_b.sent();
|
|
156
|
-
_b.label = 11;
|
|
157
|
-
case 11: return [2 /*return*/];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
40
|
+
const helpers_1 = require("magicast/helpers");
|
|
41
|
+
const templates_1 = require("./templates");
|
|
42
|
+
const clack_utils_1 = require("../utils/clack-utils");
|
|
43
|
+
const debug_1 = require("../utils/debug");
|
|
44
|
+
const ast_utils_1 = require("../utils/ast-utils");
|
|
45
|
+
const telemetry_1 = require("../telemetry");
|
|
46
|
+
const SVELTE_CONFIG_FILE = 'svelte.config.js';
|
|
47
|
+
async function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
|
|
48
|
+
const selectedFeatures = await (0, clack_utils_1.featureSelectionPrompt)([
|
|
49
|
+
{
|
|
50
|
+
id: 'performance',
|
|
51
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Tracing')} to track the performance of your application?`,
|
|
52
|
+
enabledHint: 'recommended',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'replay',
|
|
56
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Sentry Session Replay')} to get a video-like reproduction of errors during a user session?`,
|
|
57
|
+
enabledHint: 'recommended, but increases bundle size',
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
const { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);
|
|
61
|
+
// full file paths with correct file ending (or undefined if not found)
|
|
62
|
+
const originalClientHooksFile = (0, ast_utils_1.findFile)(clientHooksPath);
|
|
63
|
+
const originalServerHooksFile = (0, ast_utils_1.findFile)(serverHooksPath);
|
|
64
|
+
const viteConfig = (0, ast_utils_1.findFile)(path.resolve(process.cwd(), 'vite.config'));
|
|
65
|
+
const fileEnding = (0, clack_utils_1.isUsingTypeScript)() ? 'ts' : 'js';
|
|
66
|
+
const { dsn } = projectInfo;
|
|
67
|
+
Sentry.setTag('client-hooks-file-strategy', originalClientHooksFile ? 'merge' : 'create');
|
|
68
|
+
if (!originalClientHooksFile) {
|
|
69
|
+
prompts_1.default.log.info('No client hooks file found, creating a new one.');
|
|
70
|
+
await createNewHooksFile(`${clientHooksPath}.${fileEnding}`, 'client', dsn, selectedFeatures);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
await mergeHooksFile(originalClientHooksFile, 'client', dsn, selectedFeatures);
|
|
74
|
+
}
|
|
75
|
+
Sentry.setTag('server-hooks-file-strategy', originalServerHooksFile ? 'merge' : 'create');
|
|
76
|
+
if (!originalServerHooksFile) {
|
|
77
|
+
prompts_1.default.log.info('No server hooks file found, creating a new one.');
|
|
78
|
+
await createNewHooksFile(`${serverHooksPath}.${fileEnding}`, 'server', dsn, selectedFeatures);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
await mergeHooksFile(originalServerHooksFile, 'server', dsn, selectedFeatures);
|
|
82
|
+
}
|
|
83
|
+
if (viteConfig) {
|
|
84
|
+
await modifyViteConfig(viteConfig, projectInfo);
|
|
85
|
+
}
|
|
161
86
|
}
|
|
162
87
|
exports.createOrMergeSvelteKitFiles = createOrMergeSvelteKitFiles;
|
|
163
88
|
/**
|
|
@@ -165,16 +90,15 @@ exports.createOrMergeSvelteKitFiles = createOrMergeSvelteKitFiles;
|
|
|
165
90
|
* If users specified a custom location, we'll use that. Otherwise, we'll use the default.
|
|
166
91
|
*/
|
|
167
92
|
function getHooksConfigDirs(svelteConfig) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
var userClientHooksPath = relativeUserClientHooksPath &&
|
|
93
|
+
const relativeUserClientHooksPath = svelteConfig?.kit?.files?.hooks?.client;
|
|
94
|
+
const relativeUserServerHooksPath = svelteConfig?.kit?.files?.hooks?.server;
|
|
95
|
+
const userClientHooksPath = relativeUserClientHooksPath &&
|
|
172
96
|
path.resolve(process.cwd(), relativeUserClientHooksPath);
|
|
173
|
-
|
|
97
|
+
const userServerHooksPath = relativeUserServerHooksPath &&
|
|
174
98
|
path.resolve(process.cwd(), relativeUserServerHooksPath);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
99
|
+
const defaulHooksDir = path.resolve(process.cwd(), 'src');
|
|
100
|
+
const defaultClientHooksPath = path.resolve(defaulHooksDir, 'hooks.client'); // file ending missing on purpose
|
|
101
|
+
const defaultServerHooksPath = path.resolve(defaulHooksDir, 'hooks.server'); // same here
|
|
178
102
|
return {
|
|
179
103
|
clientHooksPath: userClientHooksPath || defaultClientHooksPath,
|
|
180
104
|
serverHooksPath: userServerHooksPath || defaultServerHooksPath,
|
|
@@ -183,27 +107,14 @@ function getHooksConfigDirs(svelteConfig) {
|
|
|
183
107
|
/**
|
|
184
108
|
* Reads the template, replaces the dsn placeholder with the actual dsn and writes the file to @param hooksFileDest
|
|
185
109
|
*/
|
|
186
|
-
function createNewHooksFile(hooksFileDest, hooktype, dsn, selectedFeatures) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
: (0, templates_1.getServerHooksTemplate)(dsn, selectedFeatures);
|
|
195
|
-
return [4 /*yield*/, fs.promises.mkdir(path.dirname(hooksFileDest), { recursive: true })];
|
|
196
|
-
case 1:
|
|
197
|
-
_a.sent();
|
|
198
|
-
return [4 /*yield*/, fs.promises.writeFile(hooksFileDest, filledTemplate)];
|
|
199
|
-
case 2:
|
|
200
|
-
_a.sent();
|
|
201
|
-
prompts_1.default.log.success("Created ".concat(hooksFileDest));
|
|
202
|
-
Sentry.setTag("created-".concat(hooktype, "-hooks"), 'success');
|
|
203
|
-
return [2 /*return*/];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
});
|
|
110
|
+
async function createNewHooksFile(hooksFileDest, hooktype, dsn, selectedFeatures) {
|
|
111
|
+
const filledTemplate = hooktype === 'client'
|
|
112
|
+
? (0, templates_1.getClientHooksTemplate)(dsn, selectedFeatures)
|
|
113
|
+
: (0, templates_1.getServerHooksTemplate)(dsn, selectedFeatures);
|
|
114
|
+
await fs.promises.mkdir(path.dirname(hooksFileDest), { recursive: true });
|
|
115
|
+
await fs.promises.writeFile(hooksFileDest, filledTemplate);
|
|
116
|
+
prompts_1.default.log.success(`Created ${hooksFileDest}`);
|
|
117
|
+
Sentry.setTag(`created-${hooktype}-hooks`, 'success');
|
|
207
118
|
}
|
|
208
119
|
/**
|
|
209
120
|
* Merges the users' hooks file with Sentry-related code.
|
|
@@ -216,79 +127,50 @@ function createNewHooksFile(hooksFileDest, hooktype, dsn, selectedFeatures) {
|
|
|
216
127
|
* Additionally in Server hook:
|
|
217
128
|
* - add handle hook handler
|
|
218
129
|
*/
|
|
219
|
-
function mergeHooksFile(hooksFile, hookType, dsn, selectedFeatures) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
case 3:
|
|
255
|
-
_a.sent();
|
|
256
|
-
return [4 /*yield*/, modifyAndRecordFail(function () { return wrapHandleError(originalHooksMod); }, 'wrap-handle-error', file)];
|
|
257
|
-
case 4:
|
|
258
|
-
_a.sent();
|
|
259
|
-
if (!(hookType === 'server')) return [3 /*break*/, 6];
|
|
260
|
-
return [4 /*yield*/, modifyAndRecordFail(function () { return wrapHandle(originalHooksMod); }, 'wrap-handle', 'server-hooks')];
|
|
261
|
-
case 5:
|
|
262
|
-
_a.sent();
|
|
263
|
-
_a.label = 6;
|
|
264
|
-
case 6: return [4 /*yield*/, modifyAndRecordFail(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
265
|
-
var modifiedCode;
|
|
266
|
-
return __generator(this, function (_a) {
|
|
267
|
-
switch (_a.label) {
|
|
268
|
-
case 0:
|
|
269
|
-
modifiedCode = originalHooksMod.generate().code;
|
|
270
|
-
return [4 /*yield*/, fs.promises.writeFile(hooksFile, modifiedCode)];
|
|
271
|
-
case 1:
|
|
272
|
-
_a.sent();
|
|
273
|
-
return [2 /*return*/];
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}); }, 'write-file', file)];
|
|
277
|
-
case 7:
|
|
278
|
-
_a.sent();
|
|
279
|
-
prompts_1.default.log.success("Added Sentry code to ".concat(hooksFile));
|
|
280
|
-
Sentry.setTag("modified-".concat(hookType, "-hooks"), 'success');
|
|
281
|
-
return [2 /*return*/];
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
});
|
|
130
|
+
async function mergeHooksFile(hooksFile, hookType, dsn, selectedFeatures) {
|
|
131
|
+
const originalHooksMod = await (0, magicast_1.loadFile)(hooksFile);
|
|
132
|
+
const file = `${hookType}-hooks`;
|
|
133
|
+
if ((0, ast_utils_1.hasSentryContent)(originalHooksMod.$ast)) {
|
|
134
|
+
// We don't want to mess with files that already have Sentry content.
|
|
135
|
+
// Let's just bail out at this point.
|
|
136
|
+
prompts_1.default.log.warn(`File ${chalk_1.default.cyan(path.basename(hooksFile))} already contains Sentry code.
|
|
137
|
+
Skipping adding Sentry functionality to.`);
|
|
138
|
+
Sentry.setTag(`modified-${file}`, 'fail');
|
|
139
|
+
Sentry.setTag(`${file}-fail-reason`, 'has-sentry-content');
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
await modifyAndRecordFail(() => originalHooksMod.imports.$add({
|
|
143
|
+
from: '@sentry/sveltekit',
|
|
144
|
+
imported: '*',
|
|
145
|
+
local: 'Sentry',
|
|
146
|
+
}), 'import-injection', file);
|
|
147
|
+
await modifyAndRecordFail(() => {
|
|
148
|
+
if (hookType === 'client') {
|
|
149
|
+
insertClientInitCall(dsn, originalHooksMod, selectedFeatures);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
insertServerInitCall(dsn, originalHooksMod, selectedFeatures);
|
|
153
|
+
}
|
|
154
|
+
}, 'init-call-injection', file);
|
|
155
|
+
await modifyAndRecordFail(() => wrapHandleError(originalHooksMod), 'wrap-handle-error', file);
|
|
156
|
+
if (hookType === 'server') {
|
|
157
|
+
await modifyAndRecordFail(() => wrapHandle(originalHooksMod), 'wrap-handle', 'server-hooks');
|
|
158
|
+
}
|
|
159
|
+
await modifyAndRecordFail(async () => {
|
|
160
|
+
const modifiedCode = originalHooksMod.generate().code;
|
|
161
|
+
await fs.promises.writeFile(hooksFile, modifiedCode);
|
|
162
|
+
}, 'write-file', file);
|
|
163
|
+
prompts_1.default.log.success(`Added Sentry code to ${hooksFile}`);
|
|
164
|
+
Sentry.setTag(`modified-${hookType}-hooks`, 'success');
|
|
285
165
|
}
|
|
286
166
|
function insertClientInitCall(dsn,
|
|
287
167
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
168
|
originalHooksMod, selectedFeatures) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
169
|
+
const initCallComment = `
|
|
170
|
+
// If you don't want to use Session Replay, remove the \`Replay\` integration,
|
|
171
|
+
// \`replaysSessionSampleRate\` and \`replaysOnErrorSampleRate\` options.`;
|
|
172
|
+
const initArgs = {
|
|
173
|
+
dsn,
|
|
292
174
|
};
|
|
293
175
|
if (selectedFeatures.performance) {
|
|
294
176
|
initArgs.tracesSampleRate = 1.0;
|
|
@@ -300,13 +182,13 @@ originalHooksMod, selectedFeatures) {
|
|
|
300
182
|
}
|
|
301
183
|
// This assignment of any values is fine because we're just creating a function call in magicast
|
|
302
184
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
303
|
-
|
|
185
|
+
const initCall = magicast_1.builders.functionCall('Sentry.init', initArgs);
|
|
304
186
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
305
|
-
|
|
187
|
+
const initCallWithComment = magicast_1.builders.raw(
|
|
306
188
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
189
|
+
`${initCallComment}\n${(0, magicast_1.generateCode)(initCall).code}`);
|
|
190
|
+
const originalHooksModAST = originalHooksMod.$ast;
|
|
191
|
+
const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);
|
|
310
192
|
originalHooksModAST.body.splice(initCallInsertionIndex, 0,
|
|
311
193
|
// @ts-ignore - string works here because the AST is proxified by magicast
|
|
312
194
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -315,17 +197,17 @@ originalHooksMod, selectedFeatures) {
|
|
|
315
197
|
function insertServerInitCall(dsn,
|
|
316
198
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
199
|
originalHooksMod, selectedFeatures) {
|
|
318
|
-
|
|
319
|
-
dsn
|
|
200
|
+
const initArgs = {
|
|
201
|
+
dsn,
|
|
320
202
|
};
|
|
321
203
|
if (selectedFeatures.performance) {
|
|
322
204
|
initArgs.tracesSampleRate = 1.0;
|
|
323
205
|
}
|
|
324
206
|
// This assignment of any values is fine because we're just creating a function call in magicast
|
|
325
207
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
208
|
+
const initCall = magicast_1.builders.functionCall('Sentry.init', initArgs);
|
|
209
|
+
const originalHooksModAST = originalHooksMod.$ast;
|
|
210
|
+
const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);
|
|
329
211
|
originalHooksModAST.body.splice(initCallInsertionIndex, 0,
|
|
330
212
|
// @ts-ignore - string works here because the AST is proxified by magicast
|
|
331
213
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -333,11 +215,11 @@ originalHooksMod, selectedFeatures) {
|
|
|
333
215
|
}
|
|
334
216
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
335
217
|
function wrapHandleError(mod) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
namedExports.forEach(
|
|
340
|
-
|
|
218
|
+
const modAst = mod.exports.$ast;
|
|
219
|
+
const namedExports = modAst.body.filter((node) => node.type === 'ExportNamedDeclaration');
|
|
220
|
+
let foundHandleError = false;
|
|
221
|
+
namedExports.forEach((modExport) => {
|
|
222
|
+
const declaration = modExport.declaration;
|
|
341
223
|
if (!declaration) {
|
|
342
224
|
return;
|
|
343
225
|
}
|
|
@@ -346,24 +228,24 @@ function wrapHandleError(mod) {
|
|
|
346
228
|
return;
|
|
347
229
|
}
|
|
348
230
|
foundHandleError = true;
|
|
349
|
-
|
|
231
|
+
const userCode = (0, magicast_1.generateCode)(declaration).code;
|
|
350
232
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
351
|
-
mod.exports.handleError = magicast_1.builders.raw(
|
|
233
|
+
mod.exports.handleError = magicast_1.builders.raw(`Sentry.handleErrorWithSentry(${userCode.replace('handleError', '_handleError')})`);
|
|
352
234
|
// because magicast doesn't overwrite the original function export, we need to remove it manually
|
|
353
|
-
modAst.body = modAst.body.filter(
|
|
235
|
+
modAst.body = modAst.body.filter((node) => node !== modExport);
|
|
354
236
|
}
|
|
355
237
|
else if (declaration.type === 'VariableDeclaration') {
|
|
356
|
-
|
|
357
|
-
declarations.forEach(
|
|
238
|
+
const declarations = declaration.declarations;
|
|
239
|
+
declarations.forEach((declaration) => {
|
|
358
240
|
// @ts-ignore - id should always have a name in this case
|
|
359
241
|
if (!declaration.id || declaration.id.name !== 'handleError') {
|
|
360
242
|
return;
|
|
361
243
|
}
|
|
362
244
|
foundHandleError = true;
|
|
363
|
-
|
|
364
|
-
|
|
245
|
+
const userCode = declaration.init;
|
|
246
|
+
const stringifiedUserCode = userCode ? (0, magicast_1.generateCode)(userCode).code : '';
|
|
365
247
|
// @ts-ignore - we can just place a string here, magicast will convert it to a node
|
|
366
|
-
declaration.init =
|
|
248
|
+
declaration.init = `Sentry.handleErrorWithSentry(${stringifiedUserCode})`;
|
|
367
249
|
});
|
|
368
250
|
}
|
|
369
251
|
});
|
|
@@ -374,11 +256,11 @@ function wrapHandleError(mod) {
|
|
|
374
256
|
}
|
|
375
257
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
376
258
|
function wrapHandle(mod) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
namedExports.forEach(
|
|
381
|
-
|
|
259
|
+
const modAst = mod.exports.$ast;
|
|
260
|
+
const namedExports = modAst.body.filter((node) => node.type === 'ExportNamedDeclaration');
|
|
261
|
+
let foundHandle = false;
|
|
262
|
+
namedExports.forEach((modExport) => {
|
|
263
|
+
const declaration = modExport.declaration;
|
|
382
264
|
if (!declaration) {
|
|
383
265
|
return;
|
|
384
266
|
}
|
|
@@ -387,23 +269,23 @@ function wrapHandle(mod) {
|
|
|
387
269
|
return;
|
|
388
270
|
}
|
|
389
271
|
foundHandle = true;
|
|
390
|
-
|
|
272
|
+
const userCode = (0, magicast_1.generateCode)(declaration).code;
|
|
391
273
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
392
|
-
mod.exports.handle = magicast_1.builders.raw(
|
|
274
|
+
mod.exports.handle = magicast_1.builders.raw(`sequence(Sentry.sentryHandle(), ${userCode.replace('handle', '_handle')})`);
|
|
393
275
|
// because of an issue with magicast, we need to remove the original export
|
|
394
|
-
modAst.body = modAst.body.filter(
|
|
276
|
+
modAst.body = modAst.body.filter((node) => node !== modExport);
|
|
395
277
|
}
|
|
396
278
|
else if (declaration.type === 'VariableDeclaration') {
|
|
397
|
-
|
|
398
|
-
declarations.forEach(
|
|
279
|
+
const declarations = declaration.declarations;
|
|
280
|
+
declarations.forEach((declaration) => {
|
|
399
281
|
// @ts-ignore - id should always have a name in this case
|
|
400
282
|
if (!declaration.id || declaration.id.name !== 'handle') {
|
|
401
283
|
return;
|
|
402
284
|
}
|
|
403
|
-
|
|
404
|
-
|
|
285
|
+
const userCode = declaration.init;
|
|
286
|
+
const stringifiedUserCode = userCode ? (0, magicast_1.generateCode)(userCode).code : '';
|
|
405
287
|
// @ts-ignore - we can just place a string here, magicast will convert it to a node
|
|
406
|
-
declaration.init =
|
|
288
|
+
declaration.init = `sequence(Sentry.sentryHandle(), ${stringifiedUserCode})`;
|
|
407
289
|
foundHandle = true;
|
|
408
290
|
});
|
|
409
291
|
}
|
|
@@ -425,145 +307,113 @@ function wrapHandle(mod) {
|
|
|
425
307
|
// It's possible sequence is already imported. in this case, magicast throws but that's fine.
|
|
426
308
|
}
|
|
427
309
|
}
|
|
428
|
-
function loadSvelteConfig() {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
prompts_1.default.log.error("Couldn't load ".concat(SVELTE_CONFIG_FILE, ".\nPlease make sure, you're running this wizard with Node 16 or newer"));
|
|
449
|
-
prompts_1.default.log.info(chalk_1.default.dim(typeof e_1 === 'object' && e_1 != null && 'toString' in e_1
|
|
450
|
-
? e_1.toString()
|
|
451
|
-
: typeof e_1 === 'string'
|
|
452
|
-
? e_1
|
|
453
|
-
: 'Unknown error'));
|
|
454
|
-
return [2 /*return*/, {}];
|
|
455
|
-
case 4: return [2 /*return*/];
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
});
|
|
310
|
+
async function loadSvelteConfig() {
|
|
311
|
+
const configFilePath = path.join(process.cwd(), SVELTE_CONFIG_FILE);
|
|
312
|
+
try {
|
|
313
|
+
if (!fs.existsSync(configFilePath)) {
|
|
314
|
+
return {};
|
|
315
|
+
}
|
|
316
|
+
const configUrl = url.pathToFileURL(configFilePath).href;
|
|
317
|
+
const svelteConfigModule = (await import(configUrl));
|
|
318
|
+
return svelteConfigModule?.default || {};
|
|
319
|
+
}
|
|
320
|
+
catch (e) {
|
|
321
|
+
prompts_1.default.log.error(`Couldn't load ${SVELTE_CONFIG_FILE}.
|
|
322
|
+
Please make sure, you're running this wizard with Node 16 or newer`);
|
|
323
|
+
prompts_1.default.log.info(chalk_1.default.dim(typeof e === 'object' && e != null && 'toString' in e
|
|
324
|
+
? e.toString()
|
|
325
|
+
: typeof e === 'string'
|
|
326
|
+
? e
|
|
327
|
+
: 'Unknown error'));
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
459
330
|
}
|
|
460
331
|
exports.loadSvelteConfig = loadSvelteConfig;
|
|
461
|
-
function modifyViteConfig(viteConfigPath, projectInfo) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
case 0:
|
|
500
|
-
code = (0, magicast_1.generateCode)(viteModule_1.$ast).code;
|
|
501
|
-
return [4 /*yield*/, fs.promises.writeFile(viteConfigPath, code)];
|
|
502
|
-
case 1:
|
|
503
|
-
_a.sent();
|
|
504
|
-
return [2 /*return*/];
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
}); }, 'write-file', 'vite-cfg')];
|
|
508
|
-
case 4:
|
|
509
|
-
_a.sent();
|
|
510
|
-
return [3 /*break*/, 7];
|
|
511
|
-
case 5:
|
|
512
|
-
e_2 = _a.sent();
|
|
513
|
-
(0, debug_1.debug)(e_2);
|
|
514
|
-
return [4 /*yield*/, showFallbackViteCopyPasteSnippet(viteConfigPath, getViteConfigCodeSnippet(org, project, selfHosted, url))];
|
|
515
|
-
case 6:
|
|
516
|
-
_a.sent();
|
|
517
|
-
Sentry.captureException('Sveltekit Vite Config Modification Fail');
|
|
518
|
-
return [3 /*break*/, 7];
|
|
519
|
-
case 7:
|
|
520
|
-
prompts_1.default.log.success("Added Sentry code to ".concat(prettyViteConfigFilename));
|
|
521
|
-
Sentry.setTag("modified-vite-cfg", 'success');
|
|
522
|
-
return [2 /*return*/];
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
});
|
|
332
|
+
async function modifyViteConfig(viteConfigPath, projectInfo) {
|
|
333
|
+
const viteConfigContent = (await fs.promises.readFile(viteConfigPath, 'utf-8')).toString();
|
|
334
|
+
const { org, project, url, selfHosted } = projectInfo;
|
|
335
|
+
const prettyViteConfigFilename = chalk_1.default.cyan(path.basename(viteConfigPath));
|
|
336
|
+
try {
|
|
337
|
+
const viteModule = (0, magicast_1.parseModule)(viteConfigContent);
|
|
338
|
+
if ((0, ast_utils_1.hasSentryContent)(viteModule.$ast)) {
|
|
339
|
+
prompts_1.default.log.warn(`File ${prettyViteConfigFilename} already contains Sentry code.
|
|
340
|
+
Skipping adding Sentry functionality to.`);
|
|
341
|
+
Sentry.setTag(`modified-vite-cfg`, 'fail');
|
|
342
|
+
Sentry.setTag(`vite-cfg-fail-reason`, 'has-sentry-content');
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
await modifyAndRecordFail(() => (0, helpers_1.addVitePlugin)(viteModule, {
|
|
346
|
+
imported: 'sentrySvelteKit',
|
|
347
|
+
from: '@sentry/sveltekit',
|
|
348
|
+
constructor: 'sentrySvelteKit',
|
|
349
|
+
options: {
|
|
350
|
+
sourceMapsUploadOptions: {
|
|
351
|
+
org,
|
|
352
|
+
project,
|
|
353
|
+
...(selfHosted && { url }),
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
index: 0,
|
|
357
|
+
}), 'add-vite-plugin', 'vite-cfg');
|
|
358
|
+
await modifyAndRecordFail(async () => {
|
|
359
|
+
const code = (0, magicast_1.generateCode)(viteModule.$ast).code;
|
|
360
|
+
await fs.promises.writeFile(viteConfigPath, code);
|
|
361
|
+
}, 'write-file', 'vite-cfg');
|
|
362
|
+
}
|
|
363
|
+
catch (e) {
|
|
364
|
+
(0, debug_1.debug)(e);
|
|
365
|
+
await showFallbackViteCopyPasteSnippet(viteConfigPath, getViteConfigCodeSnippet(org, project, selfHosted, url));
|
|
366
|
+
Sentry.captureException('Sveltekit Vite Config Modification Fail');
|
|
367
|
+
}
|
|
368
|
+
prompts_1.default.log.success(`Added Sentry code to ${prettyViteConfigFilename}`);
|
|
369
|
+
Sentry.setTag(`modified-vite-cfg`, 'success');
|
|
526
370
|
}
|
|
527
|
-
function showFallbackViteCopyPasteSnippet(viteConfigPath, codeSnippet) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
],
|
|
545
|
-
initialValue: true,
|
|
546
|
-
}))];
|
|
547
|
-
case 1:
|
|
548
|
-
_a.sent();
|
|
549
|
-
return [2 /*return*/];
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
});
|
|
371
|
+
async function showFallbackViteCopyPasteSnippet(viteConfigPath, codeSnippet) {
|
|
372
|
+
const viteConfigFilename = path.basename(viteConfigPath);
|
|
373
|
+
prompts_1.default.log.warning(`Couldn't automatically modify your ${chalk_1.default.cyan(viteConfigFilename)}
|
|
374
|
+
${chalk_1.default.dim(`This sometimes happens when we encounter more complex vite configs.
|
|
375
|
+
It may not seem like it but sometimes our magical powers are limited ;)`)}`);
|
|
376
|
+
prompts_1.default.log.info("But don't worry - it's super easy to do this yourself!");
|
|
377
|
+
prompts_1.default.log.step(`Add the following code to your ${chalk_1.default.cyan(viteConfigFilename)}:`);
|
|
378
|
+
// Intentionally logging to console here for easier copy/pasting
|
|
379
|
+
// eslint-disable-next-line no-console
|
|
380
|
+
console.log(codeSnippet);
|
|
381
|
+
await (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
382
|
+
message: 'Did you copy the snippet above?',
|
|
383
|
+
options: [
|
|
384
|
+
{ label: 'Yes!', value: true, hint: "Great, that's already it!" },
|
|
385
|
+
],
|
|
386
|
+
initialValue: true,
|
|
387
|
+
}));
|
|
553
388
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
};
|
|
389
|
+
const getViteConfigCodeSnippet = (org, project, selfHosted, url) => chalk_1.default.gray(`
|
|
390
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
391
|
+
import { defineConfig } from 'vite';
|
|
392
|
+
${chalk_1.default.greenBright("import { sentrySvelteKit } from '@sentry/sveltekit'")}
|
|
393
|
+
|
|
394
|
+
export default defineConfig({
|
|
395
|
+
plugins: [
|
|
396
|
+
// Make sure \`sentrySvelteKit\` is registered before \`sveltekit\`
|
|
397
|
+
${chalk_1.default.greenBright(`sentrySvelteKit({
|
|
398
|
+
sourceMapsUploadOptions: {
|
|
399
|
+
org: '${org}',
|
|
400
|
+
project: '${project}',${selfHosted ? `\n url: '${url}',` : ''}
|
|
401
|
+
}
|
|
402
|
+
}),`)}
|
|
403
|
+
sveltekit(),
|
|
404
|
+
]
|
|
405
|
+
});
|
|
406
|
+
`);
|
|
557
407
|
/**
|
|
558
408
|
* We want to insert the init call on top of the file but after all import statements
|
|
559
409
|
*/
|
|
560
410
|
function getInitCallInsertionIndex(originalHooksModAST) {
|
|
561
411
|
// We need to deep-copy here because reverse mutates in place
|
|
562
|
-
|
|
563
|
-
|
|
412
|
+
const copiedBodyNodes = [...originalHooksModAST.body];
|
|
413
|
+
const lastImportDeclaration = copiedBodyNodes
|
|
564
414
|
.reverse()
|
|
565
|
-
.find(
|
|
566
|
-
|
|
415
|
+
.find((node) => node.type === 'ImportDeclaration');
|
|
416
|
+
const initCallInsertionIndex = lastImportDeclaration
|
|
567
417
|
? originalHooksModAST.body.indexOf(lastImportDeclaration) + 1
|
|
568
418
|
: 0;
|
|
569
419
|
return initCallInsertionIndex;
|
|
@@ -573,25 +423,14 @@ function getInitCallInsertionIndex(originalHooksModAST) {
|
|
|
573
423
|
* In case of a failure, a tag is set with @param reason as a fail reason
|
|
574
424
|
* and the error is rethrown.
|
|
575
425
|
*/
|
|
576
|
-
function modifyAndRecordFail(modifyCallback, reason, fileType) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
_a.sent();
|
|
586
|
-
return [3 /*break*/, 3];
|
|
587
|
-
case 2:
|
|
588
|
-
e_3 = _a.sent();
|
|
589
|
-
Sentry.setTag("modified-".concat(fileType), 'fail');
|
|
590
|
-
Sentry.setTag("".concat(fileType, "-mod-fail-reason"), reason);
|
|
591
|
-
throw e_3;
|
|
592
|
-
case 3: return [2 /*return*/];
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
});
|
|
426
|
+
async function modifyAndRecordFail(modifyCallback, reason, fileType) {
|
|
427
|
+
try {
|
|
428
|
+
await (0, telemetry_1.traceStep)(`${fileType}-${reason}`, modifyCallback);
|
|
429
|
+
}
|
|
430
|
+
catch (e) {
|
|
431
|
+
Sentry.setTag(`modified-${fileType}`, 'fail');
|
|
432
|
+
Sentry.setTag(`${fileType}-mod-fail-reason`, reason);
|
|
433
|
+
throw e;
|
|
434
|
+
}
|
|
596
435
|
}
|
|
597
436
|
//# sourceMappingURL=sdk-setup.js.map
|