@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
|
@@ -1,599 +0,0 @@
|
|
|
1
|
-
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
-
import * as clack from '@clack/prompts';
|
|
3
|
-
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
4
|
-
import { ProxifiedModule, parseModule, writeFile } from 'magicast';
|
|
5
|
-
import * as fs from 'fs';
|
|
6
|
-
import * as Sentry from '@sentry/node';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
getLastRequireIndex,
|
|
10
|
-
hasSentryContent,
|
|
11
|
-
removeRequire,
|
|
12
|
-
} from '../utils/ast-utils';
|
|
13
|
-
import {
|
|
14
|
-
abortIfCancelled,
|
|
15
|
-
makeCodeSnippet,
|
|
16
|
-
showCopyPasteInstructions,
|
|
17
|
-
} from '../utils/clack-utils';
|
|
18
|
-
|
|
19
|
-
import * as recast from 'recast';
|
|
20
|
-
import x = recast.types;
|
|
21
|
-
import t = x.namedTypes;
|
|
22
|
-
import chalk from 'chalk';
|
|
23
|
-
|
|
24
|
-
const b = recast.types.builders;
|
|
25
|
-
|
|
26
|
-
export const metroConfigPath = 'metro.config.js';
|
|
27
|
-
|
|
28
|
-
export async function patchMetroWithSentryConfig() {
|
|
29
|
-
const mod = await parseMetroConfig();
|
|
30
|
-
|
|
31
|
-
const showInstructions = () =>
|
|
32
|
-
showCopyPasteInstructions(
|
|
33
|
-
metroConfigPath,
|
|
34
|
-
getMetroWithSentryConfigSnippet(true),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const success = await patchMetroWithSentryConfigInMemory(
|
|
38
|
-
mod,
|
|
39
|
-
showInstructions,
|
|
40
|
-
);
|
|
41
|
-
if (!success) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const saved = await writeMetroConfig(mod);
|
|
46
|
-
if (saved) {
|
|
47
|
-
clack.log.success(
|
|
48
|
-
chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),
|
|
49
|
-
);
|
|
50
|
-
} else {
|
|
51
|
-
clack.log.warn(
|
|
52
|
-
`Could not save changes to ${chalk.cyan(
|
|
53
|
-
metroConfigPath,
|
|
54
|
-
)}, please follow the manual steps.`,
|
|
55
|
-
);
|
|
56
|
-
return await showInstructions();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export async function patchMetroWithSentryConfigInMemory(
|
|
61
|
-
mod: ProxifiedModule,
|
|
62
|
-
showInstructions: () => Promise<void>,
|
|
63
|
-
): Promise<boolean> {
|
|
64
|
-
if (hasSentryContent(mod.$ast as t.Program)) {
|
|
65
|
-
const shouldContinue = await confirmPathMetroConfig();
|
|
66
|
-
if (!shouldContinue) {
|
|
67
|
-
await showInstructions();
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const configExpression = getModuleExportsAssignmentRight(
|
|
73
|
-
mod.$ast as t.Program,
|
|
74
|
-
);
|
|
75
|
-
if (!configExpression) {
|
|
76
|
-
clack.log.warn(
|
|
77
|
-
'Could not find Metro config, please follow the manual steps.',
|
|
78
|
-
);
|
|
79
|
-
await showInstructions();
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const wrappedConfig = wrapWithSentryConfig(configExpression);
|
|
84
|
-
|
|
85
|
-
const replacedModuleExportsRight = replaceModuleExportsRight(
|
|
86
|
-
mod.$ast as t.Program,
|
|
87
|
-
wrappedConfig,
|
|
88
|
-
);
|
|
89
|
-
if (!replacedModuleExportsRight) {
|
|
90
|
-
clack.log.warn(
|
|
91
|
-
'Could not automatically wrap the config export, please follow the manual steps.',
|
|
92
|
-
);
|
|
93
|
-
await showInstructions();
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const addedSentryMetroImport = addSentryMetroRequireToMetroConfig(
|
|
98
|
-
mod.$ast as t.Program,
|
|
99
|
-
);
|
|
100
|
-
if (!addedSentryMetroImport) {
|
|
101
|
-
clack.log.warn(
|
|
102
|
-
'Could not add `@sentry/react-native/metro` import to Metro config, please follow the manual steps.',
|
|
103
|
-
);
|
|
104
|
-
await showInstructions();
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
clack.log.success(
|
|
109
|
-
`Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,
|
|
110
|
-
);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export async function patchMetroConfigWithSentrySerializer() {
|
|
115
|
-
const mod = await parseMetroConfig();
|
|
116
|
-
|
|
117
|
-
const showInstructions = () =>
|
|
118
|
-
showCopyPasteInstructions(
|
|
119
|
-
metroConfigPath,
|
|
120
|
-
getMetroSentrySerializerSnippet(true),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (hasSentryContent(mod.$ast as t.Program)) {
|
|
124
|
-
const shouldContinue = await confirmPathMetroConfig();
|
|
125
|
-
if (!shouldContinue) {
|
|
126
|
-
return await showInstructions();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const configObj = getMetroConfigObject(mod.$ast as t.Program);
|
|
131
|
-
if (!configObj) {
|
|
132
|
-
clack.log.warn(
|
|
133
|
-
'Could not find Metro config object, please follow the manual steps.',
|
|
134
|
-
);
|
|
135
|
-
return showInstructions();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const addedSentrySerializer = addSentrySerializerToMetroConfig(configObj);
|
|
139
|
-
if (!addedSentrySerializer) {
|
|
140
|
-
clack.log.warn(
|
|
141
|
-
'Could not add Sentry serializer to Metro config, please follow the manual steps.',
|
|
142
|
-
);
|
|
143
|
-
return await showInstructions();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const addedSentrySerializerImport = addSentrySerializerRequireToMetroConfig(
|
|
147
|
-
mod.$ast as t.Program,
|
|
148
|
-
);
|
|
149
|
-
if (!addedSentrySerializerImport) {
|
|
150
|
-
clack.log.warn(
|
|
151
|
-
'Could not add Sentry serializer import to Metro config, please follow the manual steps.',
|
|
152
|
-
);
|
|
153
|
-
return await showInstructions();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
clack.log.success(
|
|
157
|
-
`Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
const saved = await writeMetroConfig(mod);
|
|
161
|
-
if (saved) {
|
|
162
|
-
clack.log.success(
|
|
163
|
-
chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),
|
|
164
|
-
);
|
|
165
|
-
} else {
|
|
166
|
-
clack.log.warn(
|
|
167
|
-
`Could not save changes to ${chalk.cyan(
|
|
168
|
-
metroConfigPath,
|
|
169
|
-
)}, please follow the manual steps.`,
|
|
170
|
-
);
|
|
171
|
-
return await showInstructions();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export async function unPatchMetroConfig() {
|
|
176
|
-
const mod = await parseMetroConfig();
|
|
177
|
-
|
|
178
|
-
const removedAtLeastOneRequire = removeSentryRequire(mod.$ast as t.Program);
|
|
179
|
-
const removedSerializerConfig = removeSentrySerializerFromMetroConfig(
|
|
180
|
-
mod.$ast as t.Program,
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
if (removedAtLeastOneRequire || removedSerializerConfig) {
|
|
184
|
-
const saved = await writeMetroConfig(mod);
|
|
185
|
-
if (saved) {
|
|
186
|
-
clack.log.success(
|
|
187
|
-
`Removed Sentry Metro plugin from ${chalk.cyan(metroConfigPath)}.`,
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
clack.log.warn(
|
|
192
|
-
`No Sentry Metro plugin found in ${chalk.cyan(metroConfigPath)}.`,
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function removeSentrySerializerFromMetroConfig(
|
|
198
|
-
program: t.Program,
|
|
199
|
-
): boolean {
|
|
200
|
-
const configObject = getMetroConfigObject(program);
|
|
201
|
-
if (!configObject) {
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const serializerProp = getSerializerProp(configObject);
|
|
206
|
-
if ('invalid' === serializerProp || 'undefined' === serializerProp) {
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const customSerializerProp = getCustomSerializerProp(serializerProp);
|
|
211
|
-
if (
|
|
212
|
-
'invalid' === customSerializerProp ||
|
|
213
|
-
'undefined' === customSerializerProp
|
|
214
|
-
) {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
serializerProp.value.type === 'ObjectExpression' &&
|
|
220
|
-
customSerializerProp.value.type === 'CallExpression' &&
|
|
221
|
-
customSerializerProp.value.callee.type === 'Identifier' &&
|
|
222
|
-
customSerializerProp.value.callee.name === 'createSentryMetroSerializer'
|
|
223
|
-
) {
|
|
224
|
-
if (customSerializerProp.value.arguments.length === 0) {
|
|
225
|
-
// FROM serializer: { customSerializer: createSentryMetroSerializer() }
|
|
226
|
-
// TO serializer: {}
|
|
227
|
-
let removed = false;
|
|
228
|
-
serializerProp.value.properties = serializerProp.value.properties.filter(
|
|
229
|
-
(p) => {
|
|
230
|
-
if (
|
|
231
|
-
p.type === 'ObjectProperty' &&
|
|
232
|
-
p.key.type === 'Identifier' &&
|
|
233
|
-
p.key.name === 'customSerializer'
|
|
234
|
-
) {
|
|
235
|
-
removed = true;
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
return true;
|
|
239
|
-
},
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
if (removed) {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
} else {
|
|
246
|
-
if (customSerializerProp.value.arguments[0].type !== 'SpreadElement') {
|
|
247
|
-
// FROM serializer: { customSerializer: createSentryMetroSerializer(wrapperSerializer) }
|
|
248
|
-
// TO serializer: { customSerializer: wrapperSerializer }
|
|
249
|
-
customSerializerProp.value = customSerializerProp.value.arguments[0];
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export function removeSentryRequire(program: t.Program): boolean {
|
|
259
|
-
return removeRequire(program, '@sentry');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export async function parseMetroConfig(): Promise<ProxifiedModule> {
|
|
263
|
-
const metroConfigContent = (
|
|
264
|
-
await fs.promises.readFile(metroConfigPath)
|
|
265
|
-
).toString();
|
|
266
|
-
|
|
267
|
-
return parseModule(metroConfigContent);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export async function writeMetroConfig(mod: ProxifiedModule): Promise<boolean> {
|
|
271
|
-
try {
|
|
272
|
-
await writeFile(mod.$ast, metroConfigPath);
|
|
273
|
-
} catch (e) {
|
|
274
|
-
clack.log.error(
|
|
275
|
-
`Failed to write to ${chalk.cyan(metroConfigPath)}: ${JSON.stringify(e)}`,
|
|
276
|
-
);
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
return true;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function addSentrySerializerToMetroConfig(
|
|
283
|
-
configObj: t.ObjectExpression,
|
|
284
|
-
): boolean {
|
|
285
|
-
const serializerProp = getSerializerProp(configObj);
|
|
286
|
-
if ('invalid' === serializerProp) {
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// case 1: serializer property doesn't exist yet, so we can just add it
|
|
291
|
-
if ('undefined' === serializerProp) {
|
|
292
|
-
configObj.properties.push(
|
|
293
|
-
b.objectProperty(
|
|
294
|
-
b.identifier('serializer'),
|
|
295
|
-
b.objectExpression([
|
|
296
|
-
b.objectProperty(
|
|
297
|
-
b.identifier('customSerializer'),
|
|
298
|
-
b.callExpression(b.identifier('createSentryMetroSerializer'), []),
|
|
299
|
-
),
|
|
300
|
-
]),
|
|
301
|
-
),
|
|
302
|
-
);
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const customSerializerProp = getCustomSerializerProp(serializerProp);
|
|
307
|
-
// case 2: serializer.customSerializer property doesn't exist yet, so we just add it
|
|
308
|
-
if (
|
|
309
|
-
'undefined' === customSerializerProp &&
|
|
310
|
-
serializerProp.value.type === 'ObjectExpression'
|
|
311
|
-
) {
|
|
312
|
-
serializerProp.value.properties.push(
|
|
313
|
-
b.objectProperty(
|
|
314
|
-
b.identifier('customSerializer'),
|
|
315
|
-
b.callExpression(b.identifier('createSentryMetroSerializer'), []),
|
|
316
|
-
),
|
|
317
|
-
);
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function getCustomSerializerProp(
|
|
325
|
-
prop: t.ObjectProperty,
|
|
326
|
-
): t.ObjectProperty | 'undefined' | 'invalid' {
|
|
327
|
-
const customSerializerProp =
|
|
328
|
-
prop.value.type === 'ObjectExpression' &&
|
|
329
|
-
prop.value.properties.find(
|
|
330
|
-
(p: t.ObjectProperty) =>
|
|
331
|
-
p.key.type === 'Identifier' && p.key.name === 'customSerializer',
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
if (!customSerializerProp) {
|
|
335
|
-
return 'undefined';
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (customSerializerProp.type === 'ObjectProperty') {
|
|
339
|
-
return customSerializerProp;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return 'invalid';
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function getSerializerProp(
|
|
346
|
-
obj: t.ObjectExpression,
|
|
347
|
-
): t.ObjectProperty | 'undefined' | 'invalid' {
|
|
348
|
-
const serializerProp = obj.properties.find(
|
|
349
|
-
(p: t.ObjectProperty) =>
|
|
350
|
-
p.key.type === 'Identifier' && p.key.name === 'serializer',
|
|
351
|
-
);
|
|
352
|
-
|
|
353
|
-
if (!serializerProp) {
|
|
354
|
-
return 'undefined';
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (serializerProp.type === 'ObjectProperty') {
|
|
358
|
-
return serializerProp;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return 'invalid';
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export function addSentrySerializerRequireToMetroConfig(
|
|
365
|
-
program: t.Program,
|
|
366
|
-
): boolean {
|
|
367
|
-
const lastRequireIndex = getLastRequireIndex(program);
|
|
368
|
-
const sentrySerializerRequire = createSentrySerializerRequire();
|
|
369
|
-
const sentryImportIndex = lastRequireIndex + 1;
|
|
370
|
-
if (sentryImportIndex < program.body.length) {
|
|
371
|
-
// insert after last require
|
|
372
|
-
program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);
|
|
373
|
-
} else {
|
|
374
|
-
// insert at the beginning
|
|
375
|
-
program.body.unshift(sentrySerializerRequire);
|
|
376
|
-
}
|
|
377
|
-
return true;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export function addSentryMetroRequireToMetroConfig(
|
|
381
|
-
program: t.Program,
|
|
382
|
-
): boolean {
|
|
383
|
-
const lastRequireIndex = getLastRequireIndex(program);
|
|
384
|
-
const sentryMetroRequire = createSentryMetroRequire();
|
|
385
|
-
const sentryImportIndex = lastRequireIndex + 1;
|
|
386
|
-
if (sentryImportIndex < program.body.length) {
|
|
387
|
-
// insert after last require
|
|
388
|
-
program.body.splice(lastRequireIndex + 1, 0, sentryMetroRequire);
|
|
389
|
-
} else {
|
|
390
|
-
// insert at the beginning
|
|
391
|
-
program.body.unshift(sentryMetroRequire);
|
|
392
|
-
}
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function wrapWithSentryConfig(
|
|
397
|
-
configObj: t.Identifier | t.CallExpression | t.ObjectExpression,
|
|
398
|
-
): t.CallExpression {
|
|
399
|
-
return b.callExpression(b.identifier('withSentryConfig'), [configObj]);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function replaceModuleExportsRight(
|
|
403
|
-
program: t.Program,
|
|
404
|
-
wrappedConfig: t.CallExpression,
|
|
405
|
-
): boolean {
|
|
406
|
-
const moduleExports = getModuleExports(program);
|
|
407
|
-
if (!moduleExports) {
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (moduleExports.expression.type === 'AssignmentExpression') {
|
|
412
|
-
moduleExports.expression.right = wrappedConfig;
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return false;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');
|
|
421
|
-
*/
|
|
422
|
-
function createSentrySerializerRequire() {
|
|
423
|
-
return b.variableDeclaration('const', [
|
|
424
|
-
b.variableDeclarator(
|
|
425
|
-
b.objectPattern([
|
|
426
|
-
b.objectProperty.from({
|
|
427
|
-
key: b.identifier('createSentryMetroSerializer'),
|
|
428
|
-
value: b.identifier('createSentryMetroSerializer'),
|
|
429
|
-
shorthand: true,
|
|
430
|
-
}),
|
|
431
|
-
]),
|
|
432
|
-
b.callExpression(b.identifier('require'), [
|
|
433
|
-
b.literal('@sentry/react-native/dist/js/tools/sentryMetroSerializer'),
|
|
434
|
-
]),
|
|
435
|
-
),
|
|
436
|
-
]);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Creates const {withSentryConfig} = require('@sentry/react-native/metro');
|
|
441
|
-
*/
|
|
442
|
-
function createSentryMetroRequire() {
|
|
443
|
-
return b.variableDeclaration('const', [
|
|
444
|
-
b.variableDeclarator(
|
|
445
|
-
b.objectPattern([
|
|
446
|
-
b.objectProperty.from({
|
|
447
|
-
key: b.identifier('withSentryConfig'),
|
|
448
|
-
value: b.identifier('withSentryConfig'),
|
|
449
|
-
shorthand: true,
|
|
450
|
-
}),
|
|
451
|
-
]),
|
|
452
|
-
b.callExpression(b.identifier('require'), [
|
|
453
|
-
b.literal('@sentry/react-native/metro'),
|
|
454
|
-
]),
|
|
455
|
-
),
|
|
456
|
-
]);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
async function confirmPathMetroConfig() {
|
|
460
|
-
const shouldContinue = await abortIfCancelled(
|
|
461
|
-
clack.select({
|
|
462
|
-
message: `Metro Config already contains Sentry-related code. Should the wizard modify it anyway?`,
|
|
463
|
-
options: [
|
|
464
|
-
{
|
|
465
|
-
label: 'Yes, add the Sentry Metro plugin',
|
|
466
|
-
value: true,
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
label: 'No, show me instructions to manually add the plugin',
|
|
470
|
-
value: false,
|
|
471
|
-
},
|
|
472
|
-
],
|
|
473
|
-
initialValue: true,
|
|
474
|
-
}),
|
|
475
|
-
);
|
|
476
|
-
|
|
477
|
-
if (!shouldContinue) {
|
|
478
|
-
Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return shouldContinue;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Returns value from `module.exports = value` or `const config = value`
|
|
486
|
-
*/
|
|
487
|
-
export function getMetroConfigObject(
|
|
488
|
-
program: t.Program,
|
|
489
|
-
): t.ObjectExpression | undefined {
|
|
490
|
-
// check config variable
|
|
491
|
-
const configVariable = program.body.find((s) => {
|
|
492
|
-
if (
|
|
493
|
-
s.type === 'VariableDeclaration' &&
|
|
494
|
-
s.declarations.length === 1 &&
|
|
495
|
-
s.declarations[0].type === 'VariableDeclarator' &&
|
|
496
|
-
s.declarations[0].id.type === 'Identifier' &&
|
|
497
|
-
s.declarations[0].id.name === 'config'
|
|
498
|
-
) {
|
|
499
|
-
return true;
|
|
500
|
-
}
|
|
501
|
-
return false;
|
|
502
|
-
}) as t.VariableDeclaration | undefined;
|
|
503
|
-
|
|
504
|
-
if (
|
|
505
|
-
configVariable?.declarations[0].type === 'VariableDeclarator' &&
|
|
506
|
-
configVariable?.declarations[0].init?.type === 'ObjectExpression'
|
|
507
|
-
) {
|
|
508
|
-
Sentry.setTag('metro-config', 'config-variable');
|
|
509
|
-
return configVariable.declarations[0].init;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
return getModuleExportsObject(program);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function getModuleExportsObject(
|
|
516
|
-
program: t.Program,
|
|
517
|
-
): t.ObjectExpression | undefined {
|
|
518
|
-
// check module.exports
|
|
519
|
-
const moduleExports = getModuleExportsAssignmentRight(program);
|
|
520
|
-
|
|
521
|
-
if (moduleExports?.type === 'ObjectExpression') {
|
|
522
|
-
return moduleExports;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
Sentry.setTag('metro-config', 'not-found');
|
|
526
|
-
return undefined;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
export function getModuleExportsAssignmentRight(
|
|
530
|
-
program: t.Program,
|
|
531
|
-
): t.Identifier | t.CallExpression | t.ObjectExpression | undefined {
|
|
532
|
-
// check module.exports
|
|
533
|
-
const moduleExports = getModuleExports(program);
|
|
534
|
-
|
|
535
|
-
if (
|
|
536
|
-
moduleExports?.expression.type === 'AssignmentExpression' &&
|
|
537
|
-
(moduleExports.expression.right.type === 'ObjectExpression' ||
|
|
538
|
-
moduleExports.expression.right.type === 'CallExpression' ||
|
|
539
|
-
moduleExports.expression.right.type === 'Identifier')
|
|
540
|
-
) {
|
|
541
|
-
Sentry.setTag('metro-config', 'module-exports');
|
|
542
|
-
return moduleExports?.expression.right;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
Sentry.setTag('metro-config', 'not-found');
|
|
546
|
-
return undefined;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function getModuleExports(
|
|
550
|
-
program: t.Program,
|
|
551
|
-
): t.ExpressionStatement | undefined {
|
|
552
|
-
// find module.exports
|
|
553
|
-
return program.body.find((s) => {
|
|
554
|
-
if (
|
|
555
|
-
s.type === 'ExpressionStatement' &&
|
|
556
|
-
s.expression.type === 'AssignmentExpression' &&
|
|
557
|
-
s.expression.left.type === 'MemberExpression' &&
|
|
558
|
-
s.expression.left.object.type === 'Identifier' &&
|
|
559
|
-
s.expression.left.object.name === 'module' &&
|
|
560
|
-
s.expression.left.property.type === 'Identifier' &&
|
|
561
|
-
s.expression.left.property.name === 'exports'
|
|
562
|
-
) {
|
|
563
|
-
return true;
|
|
564
|
-
}
|
|
565
|
-
return false;
|
|
566
|
-
}) as t.ExpressionStatement | undefined;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
function getMetroSentrySerializerSnippet(colors: boolean) {
|
|
570
|
-
return makeCodeSnippet(colors, (unchanged, plus, _) =>
|
|
571
|
-
unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');";
|
|
572
|
-
${plus(
|
|
573
|
-
"const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');",
|
|
574
|
-
)}
|
|
575
|
-
|
|
576
|
-
const config = {
|
|
577
|
-
${plus(`serializer: {
|
|
578
|
-
customSerializer: createSentryMetroSerializer(),
|
|
579
|
-
},`)}
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|
|
583
|
-
`),
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
function getMetroWithSentryConfigSnippet(colors: boolean) {
|
|
588
|
-
return makeCodeSnippet(colors, (unchanged, plus, _) =>
|
|
589
|
-
unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');";
|
|
590
|
-
${plus("const {withSentryConfig} = require('@sentry/react-native/metro');")}
|
|
591
|
-
|
|
592
|
-
const config = {};
|
|
593
|
-
|
|
594
|
-
module.exports = ${plus(
|
|
595
|
-
'withSentryConfig(',
|
|
596
|
-
)}mergeConfig(getDefaultConfig(__dirname), config)${plus(')')};
|
|
597
|
-
`),
|
|
598
|
-
);
|
|
599
|
-
}
|