@sentry/wizard 4.0.0 → 4.0.2
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 +11 -2
- package/dist/NextJs/configs/next.config.js +1 -1
- package/dist/bin.js +2 -1
- package/dist/bin.js.map +1 -1
- package/dist/bump-version.js +28 -0
- package/dist/craft-pre-release.sh +2 -0
- package/dist/lib/Steps/Initial.js +2 -12
- package/dist/lib/Steps/Initial.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js +1 -1
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/src/nextjs/templates.js +1 -1
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/run.js +2 -18
- package/dist/src/run.js.map +1 -1
- package/dist/src/telemetry.js +2 -16
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +16 -0
- package/dist/src/utils/clack-utils.js +53 -45
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +7 -0
- package/dist/src/version.js.map +1 -0
- package/dist/test/nextjs/templates.test.js +4 -4
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/utils/clack-utils.test.js +52 -0
- package/dist/test/utils/clack-utils.test.js.map +1 -1
- package/package.json +5 -2
- 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/COPYING +0 -3575
- package/bin.ts +0 -143
- package/codecov.yml +0 -15
- package/e2e-tests/.env.example +0 -11
- package/e2e-tests/README.md +0 -63
- package/e2e-tests/jest.config.ts +0 -22
- package/e2e-tests/package.json +0 -14
- package/e2e-tests/run.sh +0 -15
- package/e2e-tests/test-applications/apple/damaged-missing-configuration-list/Project.xcodeproj/project.pbxproj +0 -52
- package/e2e-tests/test-applications/apple/damaged-missing-configuration-list/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +0 -78
- package/e2e-tests/test-applications/apple/no-targets/Project.xcodeproj/project.pbxproj +0 -62
- package/e2e-tests/test-applications/apple/no-targets/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +0 -78
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project.xcodeproj/project.pbxproj +0 -470
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +0 -78
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project1/ContentView.swift +0 -7
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project1/Project1App.swift +0 -10
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project2/ContentView.swift +0 -7
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project2/Project2App.swift +0 -10
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/project.pbxproj +0 -382
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/xcshareddata/xcschemes/Project.xcscheme +0 -78
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Sources/ContentView.swift +0 -7
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Sources/MainApp.swift +0 -10
- package/e2e-tests/test-applications/flutter-test-app/.metadata +0 -45
- package/e2e-tests/test-applications/flutter-test-app/README.md +0 -16
- package/e2e-tests/test-applications/flutter-test-app/analysis_options.yaml +0 -28
- package/e2e-tests/test-applications/flutter-test-app/android/app/build.gradle +0 -44
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/debug/AndroidManifest.xml +0 -7
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/AndroidManifest.xml +0 -45
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/kotlin/com/example/flutter_magic/MainActivity.kt +0 -5
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/drawable/launch_background.xml +0 -12
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/drawable-v21/launch_background.xml +0 -12
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/values/styles.xml +0 -18
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/values-night/styles.xml +0 -18
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/profile/AndroidManifest.xml +0 -7
- package/e2e-tests/test-applications/flutter-test-app/android/build.gradle +0 -18
- package/e2e-tests/test-applications/flutter-test-app/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/e2e-tests/test-applications/flutter-test-app/android/gradle.properties +0 -3
- package/e2e-tests/test-applications/flutter-test-app/android/settings.gradle +0 -25
- package/e2e-tests/test-applications/flutter-test-app/lib/main.dart +0 -125
- package/e2e-tests/test-applications/flutter-test-app/linux/CMakeLists.txt +0 -145
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/CMakeLists.txt +0 -88
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugin_registrant.cc +0 -11
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugin_registrant.h +0 -15
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugins.cmake +0 -23
- package/e2e-tests/test-applications/flutter-test-app/linux/main.cc +0 -6
- package/e2e-tests/test-applications/flutter-test-app/linux/my_application.cc +0 -124
- package/e2e-tests/test-applications/flutter-test-app/linux/my_application.h +0 -18
- package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/Flutter-Debug.xcconfig +0 -2
- package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/Flutter-Release.xcconfig +0 -2
- package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/GeneratedPluginRegistrant.swift +0 -10
- package/e2e-tests/test-applications/flutter-test-app/macos/Podfile +0 -43
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/AppDelegate.swift +0 -9
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -68
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Base.lproj/MainMenu.xib +0 -343
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/AppInfo.xcconfig +0 -14
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Debug.xcconfig +0 -2
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Release.xcconfig +0 -2
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Warnings.xcconfig +0 -13
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/DebugProfile.entitlements +0 -12
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Info.plist +0 -32
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/MainFlutterWindow.swift +0 -15
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Release.entitlements +0 -8
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/project.pbxproj +0 -705
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +0 -98
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcworkspace/contents.xcworkspacedata +0 -7
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/e2e-tests/test-applications/flutter-test-app/macos/RunnerTests/RunnerTests.swift +0 -12
- package/e2e-tests/test-applications/flutter-test-app/pubspec.lock +0 -213
- package/e2e-tests/test-applications/flutter-test-app/pubspec.yaml +0 -89
- package/e2e-tests/test-applications/flutter-test-app/test/widget_test.dart +0 -30
- package/e2e-tests/test-applications/flutter-test-app/web/favicon.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-192.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-512.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-maskable-192.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-maskable-512.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/index.html +0 -38
- package/e2e-tests/test-applications/flutter-test-app/web/manifest.json +0 -35
- package/e2e-tests/test-applications/flutter-test-app/windows/CMakeLists.txt +0 -108
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/CMakeLists.txt +0 -109
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugin_registrant.cc +0 -11
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugin_registrant.h +0 -15
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugins.cmake +0 -23
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/CMakeLists.txt +0 -40
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/Runner.rc +0 -121
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/flutter_window.cpp +0 -71
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/flutter_window.h +0 -33
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/main.cpp +0 -43
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/resource.h +0 -16
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/resources/app_icon.ico +0 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/runner.exe.manifest +0 -14
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/utils.cpp +0 -65
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/utils.h +0 -19
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/win32_window.cpp +0 -288
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/win32_window.h +0 -102
- package/e2e-tests/test-applications/nextjs-test-app/next.config.mjs +0 -4
- package/e2e-tests/test-applications/nextjs-test-app/package.json +0 -22
- package/e2e-tests/test-applications/nextjs-test-app/src/app/layout.tsx +0 -20
- package/e2e-tests/test-applications/nextjs-test-app/src/app/page.tsx +0 -90
- package/e2e-tests/test-applications/nuxt-3-test-app/README.md +0 -75
- package/e2e-tests/test-applications/nuxt-3-test-app/nuxt.config.ts +0 -5
- package/e2e-tests/test-applications/nuxt-3-test-app/package.json +0 -18
- package/e2e-tests/test-applications/nuxt-3-test-app/public/favicon.ico +0 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/public/robots.txt +0 -1
- package/e2e-tests/test-applications/nuxt-4-test-app/README.md +0 -75
- package/e2e-tests/test-applications/nuxt-4-test-app/nuxt.config.ts +0 -6
- package/e2e-tests/test-applications/nuxt-4-test-app/package.json +0 -18
- package/e2e-tests/test-applications/nuxt-4-test-app/public/favicon.ico +0 -0
- package/e2e-tests/test-applications/nuxt-4-test-app/public/robots.txt +0 -1
- package/e2e-tests/test-applications/remix-test-app/app/entry.client.tsx +0 -18
- package/e2e-tests/test-applications/remix-test-app/app/entry.server.tsx +0 -140
- package/e2e-tests/test-applications/remix-test-app/app/root.tsx +0 -30
- package/e2e-tests/test-applications/remix-test-app/app/routes/_index.tsx +0 -48
- package/e2e-tests/test-applications/remix-test-app/app/tailwind.css +0 -3
- package/e2e-tests/test-applications/remix-test-app/package.json +0 -37
- package/e2e-tests/test-applications/remix-test-app/postcss.config.js +0 -6
- package/e2e-tests/test-applications/remix-test-app/tailwind.config.ts +0 -9
- package/e2e-tests/test-applications/remix-test-app/vite.config.ts +0 -16
- package/e2e-tests/test-applications/sveltekit-test-app/package.json +0 -21
- package/e2e-tests/test-applications/sveltekit-test-app/src/app.d.ts +0 -13
- package/e2e-tests/test-applications/sveltekit-test-app/src/app.html +0 -11
- package/e2e-tests/test-applications/sveltekit-test-app/src/lib/index.ts +0 -1
- package/e2e-tests/test-applications/sveltekit-test-app/src/routes/+page.svelte +0 -2
- package/e2e-tests/test-applications/sveltekit-test-app/svelte.config.js +0 -18
- package/e2e-tests/test-applications/sveltekit-test-app/vite.config.ts +0 -6
- package/e2e-tests/tests/flutter.test.ts +0 -127
- package/e2e-tests/tests/nextjs.test.ts +0 -161
- package/e2e-tests/tests/nuxt-3.test.ts +0 -189
- package/e2e-tests/tests/nuxt-4.test.ts +0 -188
- package/e2e-tests/tests/remix.test.ts +0 -277
- package/e2e-tests/tests/sveltekit.test.ts +0 -284
- package/e2e-tests/utils/index.ts +0 -456
- package/index.ts +0 -2
- package/lib/Constants.ts +0 -118
- package/lib/Helper/BottomBar.ts +0 -28
- package/lib/Helper/Env.ts +0 -7
- package/lib/Helper/File.ts +0 -65
- package/lib/Helper/Git.ts +0 -39
- package/lib/Helper/Logging.ts +0 -44
- package/lib/Helper/MergeConfig.ts +0 -19
- package/lib/Helper/Package.ts +0 -80
- package/lib/Helper/SentryCli.ts +0 -139
- package/lib/Helper/Wizard.ts +0 -58
- package/lib/Helper/__tests__/File.ts +0 -15
- package/lib/Helper/__tests__/MergeConfig.ts +0 -98
- package/lib/Helper/__tests__/SentryCli.ts +0 -86
- package/lib/Helper/test-fixtures/next.config.1-merged.js +0 -18
- package/lib/Helper/test-fixtures/next.config.1.js +0 -6
- package/lib/Helper/test-fixtures/next.config.2.js +0 -8
- package/lib/Helper/test-fixtures/next.config.3-merged.js +0 -21
- package/lib/Helper/test-fixtures/next.config.3.js +0 -9
- package/lib/Helper/test-fixtures/next.config.4-merged.js +0 -21
- package/lib/Helper/test-fixtures/next.config.4.js +0 -9
- package/lib/Setup.ts +0 -40
- package/lib/Steps/BaseStep.ts +0 -25
- package/lib/Steps/ChooseIntegration.ts +0 -144
- package/lib/Steps/ConfigureProject.ts +0 -10
- package/lib/Steps/Initial.ts +0 -35
- package/lib/Steps/Integrations/BaseIntegration.ts +0 -42
- package/lib/Steps/Integrations/Cordova.ts +0 -283
- package/lib/Steps/Integrations/Electron.ts +0 -164
- package/lib/Steps/Integrations/MobileProject.ts +0 -72
- package/lib/Steps/OpenSentry.ts +0 -80
- package/lib/Steps/PromptForParameters.ts +0 -200
- package/lib/Steps/Result.ts +0 -22
- package/lib/Steps/SentryProjectSelector.ts +0 -83
- package/lib/Steps/ShouldConfigure.ts +0 -10
- package/lib/Steps/WaitForSentry.ts +0 -56
- package/lib/Steps/Welcome.ts +0 -21
- package/lib/Steps/index.ts +0 -10
- package/lib/__tests__/Env.ts +0 -29
- package/scripts/NextJs/configs/_error.js +0 -39
- package/scripts/NextJs/configs/next.config.js +0 -36
- package/scripts/NextJs/configs/next.config.template.js +0 -12
- package/scripts/NextJs/configs/sentry.client.config.js +0 -17
- package/scripts/NextJs/configs/sentry.edge.config.js +0 -17
- package/scripts/NextJs/configs/sentry.server.config.js +0 -17
- package/scripts/NextJs/sentry_sample_error.js +0 -47
- package/scripts/craft-pre-release.sh +0 -10
- package/src/android/android-wizard.ts +0 -192
- package/src/android/code-tools.ts +0 -170
- package/src/android/gradle.ts +0 -250
- package/src/android/manifest.ts +0 -180
- package/src/android/templates.ts +0 -86
- package/src/apple/apple-wizard.ts +0 -269
- package/src/apple/cocoapod.ts +0 -73
- package/src/apple/code-tools.ts +0 -147
- package/src/apple/fastlane.ts +0 -170
- package/src/apple/templates.ts +0 -65
- package/src/apple/xcode-manager.ts +0 -404
- package/src/flutter/code-tools.ts +0 -284
- package/src/flutter/flutter-wizard.ts +0 -164
- package/src/flutter/templates.ts +0 -90
- package/src/nextjs/nextjs-wizard.ts +0 -1007
- package/src/nextjs/templates.ts +0 -525
- package/src/nextjs/utils.ts +0 -21
- package/src/nuxt/nuxt-wizard.ts +0 -188
- package/src/nuxt/sdk-example.ts +0 -135
- package/src/nuxt/sdk-setup.ts +0 -352
- package/src/nuxt/templates.ts +0 -303
- package/src/nuxt/types.ts +0 -8
- package/src/nuxt/utils.ts +0 -42
- package/src/react-native/expo-env-file.ts +0 -55
- package/src/react-native/expo-metro.ts +0 -212
- package/src/react-native/expo.ts +0 -175
- package/src/react-native/git.ts +0 -25
- package/src/react-native/glob.ts +0 -13
- package/src/react-native/gradle.ts +0 -26
- package/src/react-native/javascript.ts +0 -103
- package/src/react-native/metro.ts +0 -599
- package/src/react-native/options.ts +0 -5
- package/src/react-native/react-native-wizard.ts +0 -512
- package/src/react-native/uninstall.ts +0 -109
- package/src/react-native/xcode.ts +0 -302
- package/src/remix/codemods/express-server.ts +0 -44
- package/src/remix/codemods/handle-error.ts +0 -118
- package/src/remix/codemods/root-common.ts +0 -63
- package/src/remix/codemods/root-v1.ts +0 -41
- package/src/remix/codemods/root-v2.ts +0 -153
- package/src/remix/remix-wizard.ts +0 -261
- package/src/remix/sdk-example.ts +0 -120
- package/src/remix/sdk-setup.ts +0 -546
- package/src/remix/templates.ts +0 -11
- package/src/remix/utils.ts +0 -96
- package/src/run.ts +0 -211
- package/src/sourcemaps/sourcemaps-wizard.ts +0 -364
- package/src/sourcemaps/tools/angular.ts +0 -42
- package/src/sourcemaps/tools/create-react-app.ts +0 -19
- package/src/sourcemaps/tools/esbuild.ts +0 -65
- package/src/sourcemaps/tools/nextjs.ts +0 -114
- package/src/sourcemaps/tools/remix.ts +0 -90
- package/src/sourcemaps/tools/rollup.ts +0 -67
- package/src/sourcemaps/tools/sentry-cli.ts +0 -287
- package/src/sourcemaps/tools/tsc.ts +0 -144
- package/src/sourcemaps/tools/types.ts +0 -11
- package/src/sourcemaps/tools/vite.ts +0 -300
- package/src/sourcemaps/tools/webpack.ts +0 -383
- package/src/sourcemaps/utils/detect-tool.ts +0 -46
- package/src/sourcemaps/utils/other-wizards.ts +0 -167
- package/src/sourcemaps/utils/sdk-version.ts +0 -266
- package/src/sveltekit/sdk-example.ts +0 -56
- package/src/sveltekit/sdk-setup.ts +0 -667
- package/src/sveltekit/sveltekit-wizard.ts +0 -192
- package/src/sveltekit/templates.ts +0 -185
- package/src/sveltekit/utils.ts +0 -50
- package/src/telemetry.ts +0 -144
- package/src/utils/ast-utils.ts +0 -270
- package/src/utils/bash.ts +0 -57
- package/src/utils/clack-utils.ts +0 -1536
- package/src/utils/debug.ts +0 -20
- package/src/utils/package-json.ts +0 -51
- package/src/utils/package-manager.ts +0 -172
- package/src/utils/release-registry.ts +0 -19
- package/src/utils/semver.ts +0 -33
- package/src/utils/sentrycli-utils.ts +0 -24
- package/src/utils/string.ts +0 -7
- package/src/utils/types.ts +0 -77
- package/src/utils/url.ts +0 -27
- package/src/utils/vendor/is-unicorn-supported.ts +0 -29
- package/test/android/code-tools.test.ts +0 -49
- package/test/apple/cocoapod.test.ts +0 -310
- package/test/apple/code-tools.test.ts +0 -1042
- package/test/apple/fastfile.test.ts +0 -555
- package/test/apple/templates.test.ts +0 -191
- package/test/apple/xcode-manager.test.ts +0 -1068
- package/test/flutter/code-tools.test.ts +0 -212
- package/test/flutter/templates.test.ts +0 -100
- package/test/nextjs/templates.test.ts +0 -429
- package/test/nuxt/templates.test.ts +0 -255
- package/test/react-native/expo-metro.test.ts +0 -81
- package/test/react-native/expo.test.ts +0 -86
- package/test/react-native/gradle.test.ts +0 -310
- package/test/react-native/javascript.test.ts +0 -134
- package/test/react-native/metro.test.ts +0 -396
- package/test/react-native/xcode.test.ts +0 -401
- package/test/remix/client-entry.test.ts +0 -122
- package/test/remix/server-instrumentation.test.ts +0 -36
- package/test/sourcemaps/tools/sentry-cli.test.ts +0 -57
- package/test/sourcemaps/tools/tsc.test.ts +0 -181
- package/test/sourcemaps/tools/vite.test.ts +0 -149
- package/test/sourcemaps/tools/webpack.test.ts +0 -303
- package/test/sveltekit/templates.test.ts +0 -152
- package/test/utils/ast-utils.test.ts +0 -264
- package/test/utils/clack-utils.test.ts +0 -224
- package/types/read-env.d.ts +0 -3
- package/types/xcode.d.ts +0 -527
package/src/nuxt/templates.ts
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import { getIssueStreamUrl } from '../utils/url';
|
|
2
|
-
|
|
3
|
-
type SelectedSentryFeatures = {
|
|
4
|
-
performance: boolean;
|
|
5
|
-
replay: boolean;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export function getDefaultNuxtConfig(): string {
|
|
9
|
-
return `// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
10
|
-
export default defineNuxtConfig({
|
|
11
|
-
compatibilityDate: '2024-04-03',
|
|
12
|
-
devtools: { enabled: true }
|
|
13
|
-
})
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getNuxtModuleFallbackTemplate(
|
|
18
|
-
options: {
|
|
19
|
-
org: string;
|
|
20
|
-
project: string;
|
|
21
|
-
url: string;
|
|
22
|
-
selfHosted: boolean;
|
|
23
|
-
},
|
|
24
|
-
shouldTopLevelImport: boolean,
|
|
25
|
-
): string {
|
|
26
|
-
return ` modules: ["@sentry/nuxt/module"],
|
|
27
|
-
sentry: {
|
|
28
|
-
sourceMapsUploadOptions: {
|
|
29
|
-
org: "${options.org}",
|
|
30
|
-
project: "${options.project}",${
|
|
31
|
-
options.selfHosted ? `\n url: "${options.url}",` : ''
|
|
32
|
-
}
|
|
33
|
-
},${
|
|
34
|
-
shouldTopLevelImport
|
|
35
|
-
? `\n autoInjectServerSentry: "top-level-import",`
|
|
36
|
-
: ''
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
sourcemap: { client: "hidden" },`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function getSentryConfigContents(
|
|
43
|
-
dsn: string,
|
|
44
|
-
config: 'client' | 'server',
|
|
45
|
-
selectedFeatures: SelectedSentryFeatures,
|
|
46
|
-
): string {
|
|
47
|
-
if (config === 'client') {
|
|
48
|
-
return getSentryClientConfigContents(dsn, selectedFeatures);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return getSentryServerConfigContents(dsn, selectedFeatures);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {
|
|
55
|
-
performance: [
|
|
56
|
-
' // We recommend adjusting this value in production, or using tracesSampler',
|
|
57
|
-
' // for finer control',
|
|
58
|
-
' tracesSampleRate: 1.0,',
|
|
59
|
-
].join('\n'),
|
|
60
|
-
replay: [
|
|
61
|
-
' // This sets the sample rate to be 10%. You may want this to be 100% while',
|
|
62
|
-
' // in development and sample at a lower rate in production',
|
|
63
|
-
' replaysSessionSampleRate: 0.1,',
|
|
64
|
-
' ',
|
|
65
|
-
' // If the entire session is not sampled, use the below sample rate to sample',
|
|
66
|
-
' // sessions when an error occurs.',
|
|
67
|
-
' replaysOnErrorSampleRate: 1.0,',
|
|
68
|
-
' ',
|
|
69
|
-
" // If you don't want to use Session Replay, just remove the line below:",
|
|
70
|
-
' integrations: [Sentry.replayIntegration()],',
|
|
71
|
-
].join('\n'),
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const featuresMap: Record<
|
|
75
|
-
'client' | 'server',
|
|
76
|
-
Array<keyof SelectedSentryFeatures>
|
|
77
|
-
> = {
|
|
78
|
-
client: ['performance', 'replay'],
|
|
79
|
-
server: ['performance'],
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export function getConfigBody(
|
|
83
|
-
dsn: string,
|
|
84
|
-
variant: 'client' | 'server',
|
|
85
|
-
selectedFeatures: SelectedSentryFeatures,
|
|
86
|
-
) {
|
|
87
|
-
return [
|
|
88
|
-
`dsn: "${dsn}",`,
|
|
89
|
-
Object.entries(selectedFeatures)
|
|
90
|
-
.map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {
|
|
91
|
-
return featuresMap[variant].includes(feature) && activated
|
|
92
|
-
? featuresConfigMap[feature]
|
|
93
|
-
: null;
|
|
94
|
-
})
|
|
95
|
-
.filter(Boolean)
|
|
96
|
-
.join('\n\n'),
|
|
97
|
-
]
|
|
98
|
-
.filter(Boolean)
|
|
99
|
-
.join('\n\n');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function getSentryClientConfigContents(
|
|
103
|
-
dsn: string,
|
|
104
|
-
selectedFeatures: SelectedSentryFeatures,
|
|
105
|
-
): string {
|
|
106
|
-
return `import * as Sentry from "@sentry/nuxt";
|
|
107
|
-
|
|
108
|
-
Sentry.init({
|
|
109
|
-
// If set up, you can use your runtime config here
|
|
110
|
-
// dsn: useRuntimeConfig().public.sentry.dsn,
|
|
111
|
-
${getConfigBody(dsn, 'client', selectedFeatures)}
|
|
112
|
-
|
|
113
|
-
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
114
|
-
debug: false,
|
|
115
|
-
});
|
|
116
|
-
`;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function getSentryServerConfigContents(
|
|
120
|
-
dsn: string,
|
|
121
|
-
selectedFeatures: SelectedSentryFeatures,
|
|
122
|
-
): string {
|
|
123
|
-
return `import * as Sentry from "@sentry/nuxt";
|
|
124
|
-
|
|
125
|
-
Sentry.init({
|
|
126
|
-
${getConfigBody(dsn, 'server', selectedFeatures)}
|
|
127
|
-
|
|
128
|
-
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
129
|
-
debug: false,
|
|
130
|
-
});
|
|
131
|
-
`;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function getIndexRouteTemplate(): string {
|
|
135
|
-
return `<!--
|
|
136
|
-
This is just to verify the sentry-example-page.
|
|
137
|
-
Feel free to delete this file.
|
|
138
|
-
-->
|
|
139
|
-
|
|
140
|
-
<template></template>`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export function getSentryExamplePageTemplate(options: {
|
|
144
|
-
url: string;
|
|
145
|
-
org: string;
|
|
146
|
-
projectId: string;
|
|
147
|
-
}): string {
|
|
148
|
-
const { url, org, projectId } = options;
|
|
149
|
-
const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });
|
|
150
|
-
|
|
151
|
-
return `<!--
|
|
152
|
-
This is just a very simple page with a button to throw an example error.
|
|
153
|
-
Feel free to delete this file.
|
|
154
|
-
-->
|
|
155
|
-
|
|
156
|
-
<script setup>
|
|
157
|
-
import * as Sentry from '@sentry/nuxt';
|
|
158
|
-
import { useFetch} from '#imports'
|
|
159
|
-
|
|
160
|
-
function getSentryData() {
|
|
161
|
-
Sentry.startSpan(
|
|
162
|
-
{
|
|
163
|
-
name: 'Example Frontend Span',
|
|
164
|
-
op: 'test'
|
|
165
|
-
},
|
|
166
|
-
async () => {
|
|
167
|
-
const { error } = await useFetch('/api/sentry-example-api');
|
|
168
|
-
if (error.value) {
|
|
169
|
-
throw new Error('Sentry Example Frontend Error');
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
</script>
|
|
175
|
-
|
|
176
|
-
<template>
|
|
177
|
-
<title>Sentry Onboarding</title>
|
|
178
|
-
<div>
|
|
179
|
-
<main>
|
|
180
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 44">
|
|
181
|
-
<path
|
|
182
|
-
fill="currentColor"
|
|
183
|
-
d="M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z"
|
|
184
|
-
/>
|
|
185
|
-
</svg>
|
|
186
|
-
<p>
|
|
187
|
-
Get Started with this <strong>simple Example:</strong>
|
|
188
|
-
</p>
|
|
189
|
-
|
|
190
|
-
<p>1. Send us a sample error:</p>
|
|
191
|
-
<button type="button" @click="getSentryData"> Throw error! </button>
|
|
192
|
-
|
|
193
|
-
<p>
|
|
194
|
-
2. Look for the error on the
|
|
195
|
-
<a href="${issuesPageLink}">Issues Page</a>.
|
|
196
|
-
</p>
|
|
197
|
-
<p style="margin-top: 24px;">
|
|
198
|
-
For more information, take a look at the
|
|
199
|
-
<a href="https://docs.sentry.io/platforms/javascript/guides/nuxt/">
|
|
200
|
-
Sentry Nuxt Documentation
|
|
201
|
-
</a>
|
|
202
|
-
</p>
|
|
203
|
-
</main>
|
|
204
|
-
</div>
|
|
205
|
-
</template>
|
|
206
|
-
|
|
207
|
-
<style scoped>
|
|
208
|
-
main {
|
|
209
|
-
display: flex;
|
|
210
|
-
flex-direction: column;
|
|
211
|
-
justify-content: center;
|
|
212
|
-
align-items: center;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
svg {
|
|
216
|
-
font-size: 4rem;
|
|
217
|
-
margin: 14px 0;
|
|
218
|
-
height: 1em;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
button {
|
|
222
|
-
padding: 12px;
|
|
223
|
-
cursor: pointer;
|
|
224
|
-
background-color: rgb(54, 45, 89);
|
|
225
|
-
border-radius: 4px;
|
|
226
|
-
border: none;
|
|
227
|
-
color: white;
|
|
228
|
-
font-size: 1em;
|
|
229
|
-
margin: 1em;
|
|
230
|
-
transition: all 0.25s ease-in-out;
|
|
231
|
-
}
|
|
232
|
-
button:hover {
|
|
233
|
-
background-color: #8c5393;
|
|
234
|
-
box-shadow: 4px;
|
|
235
|
-
box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);
|
|
236
|
-
}
|
|
237
|
-
button:active {
|
|
238
|
-
background-color: #c73852;
|
|
239
|
-
}
|
|
240
|
-
</style>
|
|
241
|
-
`;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export function getSentryExampleApiTemplate() {
|
|
245
|
-
return `// This is just a very simple API route that throws an example error.
|
|
246
|
-
// Feel free to delete this file.
|
|
247
|
-
import { defineEventHandler } from '#imports';
|
|
248
|
-
|
|
249
|
-
export default defineEventHandler(() => {
|
|
250
|
-
throw new Error("Sentry Example API Route Error");
|
|
251
|
-
});
|
|
252
|
-
`;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export function getSentryErrorButtonTemplate() {
|
|
256
|
-
return `<!--
|
|
257
|
-
This is just a very simple component that throws an example error.
|
|
258
|
-
Feel free to delete this file.
|
|
259
|
-
-->
|
|
260
|
-
|
|
261
|
-
<script setup>
|
|
262
|
-
import * as Sentry from '@sentry/nuxt';
|
|
263
|
-
|
|
264
|
-
const throwError = () => {
|
|
265
|
-
Sentry.startSpan(
|
|
266
|
-
{
|
|
267
|
-
name: 'Example Frontend Span',
|
|
268
|
-
op: 'test'
|
|
269
|
-
},
|
|
270
|
-
() => {
|
|
271
|
-
throw new Error('Sentry Example Error');
|
|
272
|
-
}
|
|
273
|
-
)
|
|
274
|
-
};
|
|
275
|
-
</script>
|
|
276
|
-
|
|
277
|
-
<template>
|
|
278
|
-
<button id="errorBtn" @click="throwError"> Throw Error! </button>
|
|
279
|
-
</template>
|
|
280
|
-
|
|
281
|
-
<style scoped>
|
|
282
|
-
button {
|
|
283
|
-
padding: 12px;
|
|
284
|
-
cursor: pointer;
|
|
285
|
-
background-color: rgb(54, 45, 89);
|
|
286
|
-
border-radius: 4px;
|
|
287
|
-
border: none;
|
|
288
|
-
color: white;
|
|
289
|
-
font-size: 1em;
|
|
290
|
-
margin: 1em;
|
|
291
|
-
transition: all 0.25s ease-in-out;
|
|
292
|
-
}
|
|
293
|
-
button:hover {
|
|
294
|
-
background-color: #8c5393;
|
|
295
|
-
box-shadow: 4px;
|
|
296
|
-
box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);
|
|
297
|
-
}
|
|
298
|
-
button:active {
|
|
299
|
-
background-color: #c73852;
|
|
300
|
-
}
|
|
301
|
-
</style>
|
|
302
|
-
`;
|
|
303
|
-
}
|
package/src/nuxt/types.ts
DELETED
package/src/nuxt/utils.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
-
import * as clack from '@clack/prompts';
|
|
3
|
-
import { gte, minVersion } from 'semver';
|
|
4
|
-
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
5
|
-
import { loadFile } from 'magicast';
|
|
6
|
-
import { abortIfCancelled } from '../utils/clack-utils';
|
|
7
|
-
|
|
8
|
-
export async function isNuxtV4(
|
|
9
|
-
nuxtConfig: string,
|
|
10
|
-
packageVersion: string | undefined,
|
|
11
|
-
) {
|
|
12
|
-
if (!packageVersion) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const minVer = minVersion(packageVersion);
|
|
17
|
-
if (minVer && gte(minVer, '4.0.0')) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// At the time of writing, nuxt 4 is not on its own
|
|
22
|
-
// major yet. We must read the `compatibilityVersion`
|
|
23
|
-
// from the nuxt config.
|
|
24
|
-
try {
|
|
25
|
-
const mod = await loadFile(nuxtConfig);
|
|
26
|
-
const config =
|
|
27
|
-
mod.exports.default.$type === 'function-call'
|
|
28
|
-
? mod.exports.default.$args[0]
|
|
29
|
-
: mod.exports.default;
|
|
30
|
-
|
|
31
|
-
if (config && config.future && config.future.compatibilityVersion === 4) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
} catch {
|
|
35
|
-
// If we cannot parse their config, just ask.
|
|
36
|
-
return await abortIfCancelled(
|
|
37
|
-
clack.confirm({ message: 'Are you using Nuxt version 4?' }),
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
-
import * as clack from '@clack/prompts';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import * as Sentry from '@sentry/node';
|
|
6
|
-
import { RNCliSetupConfigContent } from './react-native-wizard';
|
|
7
|
-
import { addToGitignore } from './git';
|
|
8
|
-
|
|
9
|
-
const EXPO_ENV_LOCAL_FILE = '.env.local';
|
|
10
|
-
|
|
11
|
-
export async function addExpoEnvLocal(
|
|
12
|
-
options: RNCliSetupConfigContent,
|
|
13
|
-
): Promise<boolean> {
|
|
14
|
-
const newContent = `#DO NOT COMMIT THIS\nSENTRY_AUTH_TOKEN=${options.authToken}\n`;
|
|
15
|
-
|
|
16
|
-
const added = await addToGitignore(EXPO_ENV_LOCAL_FILE);
|
|
17
|
-
if (added) {
|
|
18
|
-
clack.log.success(
|
|
19
|
-
`Added ${chalk.cyan(EXPO_ENV_LOCAL_FILE)} to .gitignore.`,
|
|
20
|
-
);
|
|
21
|
-
} else {
|
|
22
|
-
clack.log.error(
|
|
23
|
-
`Could not add ${chalk.cyan(
|
|
24
|
-
EXPO_ENV_LOCAL_FILE,
|
|
25
|
-
)} to .gitignore, please add it to not commit your auth key.`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!fs.existsSync(EXPO_ENV_LOCAL_FILE)) {
|
|
30
|
-
try {
|
|
31
|
-
await fs.promises.writeFile(EXPO_ENV_LOCAL_FILE, newContent);
|
|
32
|
-
Sentry.setTag('expo-env-local', 'written');
|
|
33
|
-
clack.log.success(`Written ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);
|
|
34
|
-
return true;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
Sentry.setTag('expo-env-local', 'write-error');
|
|
37
|
-
clack.log.error(`Unable to write ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
Sentry.setTag('expo-env-local', 'exists');
|
|
43
|
-
clack.log.info(`Updating existing ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
await fs.promises.appendFile(EXPO_ENV_LOCAL_FILE, newContent);
|
|
47
|
-
Sentry.setTag('expo-env-local', 'updated');
|
|
48
|
-
clack.log.success(`Updated ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);
|
|
49
|
-
return true;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
Sentry.setTag('expo-env-local', 'update-error');
|
|
52
|
-
clack.log.error(`Unable to update ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
3
|
-
import * as clack from '@clack/prompts';
|
|
4
|
-
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
5
|
-
import type { ProxifiedModule } from 'magicast';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import * as Sentry from '@sentry/node';
|
|
8
|
-
|
|
9
|
-
import { getLastRequireIndex, hasSentryContent } from '../utils/ast-utils';
|
|
10
|
-
import {
|
|
11
|
-
makeCodeSnippet,
|
|
12
|
-
showCopyPasteInstructions,
|
|
13
|
-
} from '../utils/clack-utils';
|
|
14
|
-
|
|
15
|
-
import { metroConfigPath, parseMetroConfig, writeMetroConfig } from './metro';
|
|
16
|
-
|
|
17
|
-
import * as recast from 'recast';
|
|
18
|
-
import x = recast.types;
|
|
19
|
-
import t = x.namedTypes;
|
|
20
|
-
|
|
21
|
-
const b = recast.types.builders;
|
|
22
|
-
|
|
23
|
-
export async function addSentryToExpoMetroConfig() {
|
|
24
|
-
if (!fs.existsSync(metroConfigPath)) {
|
|
25
|
-
const success = await createSentryExpoMetroConfig();
|
|
26
|
-
if (!success) {
|
|
27
|
-
Sentry.setTag('expo-metro-config', 'create-new-error');
|
|
28
|
-
return await showInstructions();
|
|
29
|
-
}
|
|
30
|
-
Sentry.setTag('expo-metro-config', 'created-new');
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const mod = await parseMetroConfig();
|
|
35
|
-
|
|
36
|
-
let didPatch = false;
|
|
37
|
-
try {
|
|
38
|
-
didPatch = patchMetroInMemory(mod);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
// noop
|
|
41
|
-
}
|
|
42
|
-
if (!didPatch) {
|
|
43
|
-
Sentry.setTag('expo-metro-config', 'patch-error');
|
|
44
|
-
clack.log.error(
|
|
45
|
-
`Could not patch ${chalk.cyan(
|
|
46
|
-
metroConfigPath,
|
|
47
|
-
)} with Sentry configuration.`,
|
|
48
|
-
);
|
|
49
|
-
return await showInstructions();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const saved = await writeMetroConfig(mod);
|
|
53
|
-
if (saved) {
|
|
54
|
-
Sentry.setTag('expo-metro-config', 'patch-saved');
|
|
55
|
-
clack.log.success(
|
|
56
|
-
chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),
|
|
57
|
-
);
|
|
58
|
-
} else {
|
|
59
|
-
Sentry.setTag('expo-metro-config', 'patch-save-error');
|
|
60
|
-
clack.log.warn(
|
|
61
|
-
`Could not save changes to ${chalk.cyan(
|
|
62
|
-
metroConfigPath,
|
|
63
|
-
)}, please follow the manual steps.`,
|
|
64
|
-
);
|
|
65
|
-
return await showInstructions();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function patchMetroInMemory(mod: ProxifiedModule): boolean {
|
|
70
|
-
const ast = mod.$ast as t.Program;
|
|
71
|
-
|
|
72
|
-
if (hasSentryContent(ast)) {
|
|
73
|
-
clack.log.warn(
|
|
74
|
-
`The ${chalk.cyan(
|
|
75
|
-
metroConfigPath,
|
|
76
|
-
)} file already has Sentry configuration.`,
|
|
77
|
-
);
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let didReplaceDefaultConfigCall = false;
|
|
82
|
-
|
|
83
|
-
recast.visit(ast, {
|
|
84
|
-
visitVariableDeclaration(path) {
|
|
85
|
-
const { node } = path;
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
// path is require("expo/metro-config")
|
|
89
|
-
// and only getDefaultConfig is being destructured
|
|
90
|
-
// then remove the entire declaration
|
|
91
|
-
node.declarations.length > 0 &&
|
|
92
|
-
node.declarations[0].type === 'VariableDeclarator' &&
|
|
93
|
-
node.declarations[0].init &&
|
|
94
|
-
node.declarations[0].init.type === 'CallExpression' &&
|
|
95
|
-
node.declarations[0].init.callee &&
|
|
96
|
-
node.declarations[0].init.callee.type === 'Identifier' &&
|
|
97
|
-
node.declarations[0].init.callee.name === 'require' &&
|
|
98
|
-
node.declarations[0].init.arguments[0].type === 'StringLiteral' &&
|
|
99
|
-
node.declarations[0].init.arguments[0].value === 'expo/metro-config' &&
|
|
100
|
-
node.declarations[0].id.type === 'ObjectPattern' &&
|
|
101
|
-
node.declarations[0].id.properties.length === 1 &&
|
|
102
|
-
node.declarations[0].id.properties[0].type === 'ObjectProperty' &&
|
|
103
|
-
node.declarations[0].id.properties[0].key.type === 'Identifier' &&
|
|
104
|
-
node.declarations[0].id.properties[0].key.name === 'getDefaultConfig'
|
|
105
|
-
) {
|
|
106
|
-
path.prune();
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
this.traverse(path);
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
visitCallExpression(path) {
|
|
114
|
-
const { node } = path;
|
|
115
|
-
if (
|
|
116
|
-
// path is getDefaultConfig
|
|
117
|
-
// then rename it to getSentryExpoConfig
|
|
118
|
-
node.callee.type === 'Identifier' &&
|
|
119
|
-
node.callee.name === 'getDefaultConfig'
|
|
120
|
-
) {
|
|
121
|
-
node.callee.name = 'getSentryExpoConfig';
|
|
122
|
-
didReplaceDefaultConfigCall = true;
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this.traverse(path);
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (!didReplaceDefaultConfigCall) {
|
|
131
|
-
clack.log.warn(
|
|
132
|
-
`Could not find \`getDefaultConfig\` in ${chalk.cyan(metroConfigPath)}.`,
|
|
133
|
-
);
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
addSentryExpoConfigRequire(ast);
|
|
138
|
-
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function addSentryExpoConfigRequire(program: t.Program) {
|
|
143
|
-
const lastRequireIndex = getLastRequireIndex(program);
|
|
144
|
-
const sentryExpoConfigRequire = createSentryExpoConfigRequire();
|
|
145
|
-
program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Creates const { getSentryExpoConfig } = require("@sentry/react-native/metro");
|
|
150
|
-
*/
|
|
151
|
-
function createSentryExpoConfigRequire() {
|
|
152
|
-
return b.variableDeclaration('const', [
|
|
153
|
-
b.variableDeclarator(
|
|
154
|
-
b.objectPattern([
|
|
155
|
-
b.objectProperty.from({
|
|
156
|
-
key: b.identifier('getSentryExpoConfig'),
|
|
157
|
-
value: b.identifier('getSentryExpoConfig'),
|
|
158
|
-
shorthand: true,
|
|
159
|
-
}),
|
|
160
|
-
]),
|
|
161
|
-
b.callExpression(b.identifier('require'), [
|
|
162
|
-
b.literal('@sentry/react-native/metro'),
|
|
163
|
-
]),
|
|
164
|
-
),
|
|
165
|
-
]);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function createSentryExpoMetroConfig(): Promise<boolean> {
|
|
169
|
-
const snippet = `const { getSentryExpoConfig } = require("@sentry/react-native/metro");
|
|
170
|
-
|
|
171
|
-
const config = getSentryExpoConfig(__dirname);
|
|
172
|
-
|
|
173
|
-
module.exports = config;
|
|
174
|
-
`;
|
|
175
|
-
try {
|
|
176
|
-
await fs.promises.writeFile(metroConfigPath, snippet);
|
|
177
|
-
} catch (e) {
|
|
178
|
-
clack.log.error(
|
|
179
|
-
`Could not create ${chalk.cyan(
|
|
180
|
-
metroConfigPath,
|
|
181
|
-
)} with Sentry configuration.`,
|
|
182
|
-
);
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
clack.log.success(
|
|
186
|
-
`Created ${chalk.cyan(metroConfigPath)} with Sentry configuration.`,
|
|
187
|
-
);
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function showInstructions() {
|
|
192
|
-
return showCopyPasteInstructions(
|
|
193
|
-
metroConfigPath,
|
|
194
|
-
getMetroWithSentryExpoConfigSnippet(true),
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function getMetroWithSentryExpoConfigSnippet(colors: boolean): string {
|
|
199
|
-
return makeCodeSnippet(colors, (unchanged, plus, minus) =>
|
|
200
|
-
unchanged(`${minus(
|
|
201
|
-
`// const { getDefaultConfig } = require("expo/metro-config");`,
|
|
202
|
-
)}
|
|
203
|
-
${plus(
|
|
204
|
-
`const { getSentryExpoConfig } = require("@sentry/react-native/metro");`,
|
|
205
|
-
)}
|
|
206
|
-
|
|
207
|
-
${minus(`// const config = getDefaultConfig(__dirname);`)}
|
|
208
|
-
${plus(`const config = getSentryExpoConfig(__dirname);`)}
|
|
209
|
-
|
|
210
|
-
module.exports = config;`),
|
|
211
|
-
);
|
|
212
|
-
}
|