@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
|
@@ -22,137 +22,73 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
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;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
64
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
29
|
exports.getSentryAppConfigJsonCodeSnippet = exports.addWithSentryToAppConfigJson = exports.patchExpoAppConfig = exports.printSentryExpoMigrationOutro = exports.SENTRY_PLUGIN_FUNCTION_NAME = exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = exports.SENTRY_EXPO_PLUGIN_NAME = void 0;
|
|
66
30
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
31
|
+
const clack = __importStar(require("@clack/prompts"));
|
|
32
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
33
|
+
const fs = __importStar(require("fs"));
|
|
34
|
+
const os_1 = require("os");
|
|
35
|
+
const utils_1 = require("@sentry/utils");
|
|
36
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
37
|
+
const clack_utils_1 = require("../utils/clack-utils");
|
|
38
|
+
const telemetry_1 = require("../telemetry");
|
|
75
39
|
exports.SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';
|
|
76
40
|
exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';
|
|
77
41
|
exports.SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';
|
|
78
|
-
|
|
42
|
+
const APP_CONFIG_JSON = `app.json`;
|
|
79
43
|
function printSentryExpoMigrationOutro() {
|
|
80
|
-
clack.outro(
|
|
44
|
+
clack.outro(`Deprecated ${chalk_1.default.cyan('sentry-expo')} package installed in your dependencies. Please follow the migration guide at ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-native/migration/sentry-expo/')}`);
|
|
81
45
|
}
|
|
82
46
|
exports.printSentryExpoMigrationOutro = printSentryExpoMigrationOutro;
|
|
83
47
|
/**
|
|
84
48
|
* Finds app.json in the project root and add Sentry Expo `withSentry` plugin.
|
|
85
49
|
*/
|
|
86
|
-
function patchExpoAppConfig(options) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
100
|
-
case 2: return [4 /*yield*/, patchAppConfigJson(APP_CONFIG_JSON, options)];
|
|
101
|
-
case 3:
|
|
102
|
-
patched = _a.sent();
|
|
103
|
-
if (!!patched) return [3 /*break*/, 5];
|
|
104
|
-
return [4 /*yield*/, showInstructions()];
|
|
105
|
-
case 4: return [2 /*return*/, _a.sent()];
|
|
106
|
-
case 5: return [2 /*return*/];
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
50
|
+
async function patchExpoAppConfig(options) {
|
|
51
|
+
function showInstructions() {
|
|
52
|
+
return (0, clack_utils_1.showCopyPasteInstructions)(APP_CONFIG_JSON, getSentryAppConfigJsonCodeSnippet(options), 'This ensures auto upload of source maps during native app build.');
|
|
53
|
+
}
|
|
54
|
+
const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);
|
|
55
|
+
Sentry.setTag('app-config-file-status', appConfigJsonExists ? 'found' : 'not-found');
|
|
56
|
+
if (!appConfigJsonExists) {
|
|
57
|
+
return await showInstructions();
|
|
58
|
+
}
|
|
59
|
+
const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);
|
|
60
|
+
if (!patched) {
|
|
61
|
+
return await showInstructions();
|
|
62
|
+
}
|
|
110
63
|
}
|
|
111
64
|
exports.patchExpoAppConfig = patchExpoAppConfig;
|
|
112
|
-
function patchAppConfigJson(path, options) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return [4 /*yield*/, fs.promises.writeFile(path, patchedContent)];
|
|
130
|
-
case 3:
|
|
131
|
-
_a.sent();
|
|
132
|
-
return [3 /*break*/, 5];
|
|
133
|
-
case 4:
|
|
134
|
-
error_1 = _a.sent();
|
|
135
|
-
Sentry.setTag('app-config-file-status', 'json-write-error');
|
|
136
|
-
clack.log.error("Unable to write ".concat(chalk_1.default.cyan('app.config.json'), "."));
|
|
137
|
-
return [2 /*return*/, false];
|
|
138
|
-
case 5:
|
|
139
|
-
Sentry.setTag('app-config-file-status', 'json-write-success');
|
|
140
|
-
clack.log.success("Added Sentry Expo plugin to ".concat(chalk_1.default.cyan('app.config.json'), "."));
|
|
141
|
-
return [2 /*return*/, true];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
65
|
+
async function patchAppConfigJson(path, options) {
|
|
66
|
+
const appConfigContent = (await fs.promises.readFile(path, { encoding: 'utf-8' })).toString();
|
|
67
|
+
const patchedContent = (0, telemetry_1.traceStep)('app-config-json-patch', () => addWithSentryToAppConfigJson(appConfigContent, options));
|
|
68
|
+
if (patchedContent === null) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await fs.promises.writeFile(path, patchedContent);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
Sentry.setTag('app-config-file-status', 'json-write-error');
|
|
76
|
+
clack.log.error(`Unable to write ${chalk_1.default.cyan('app.config.json')}.`);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
Sentry.setTag('app-config-file-status', 'json-write-success');
|
|
80
|
+
clack.log.success(`Added Sentry Expo plugin to ${chalk_1.default.cyan('app.config.json')}.`);
|
|
81
|
+
return true;
|
|
145
82
|
}
|
|
146
83
|
function addWithSentryToAppConfigJson(appConfigContent, options) {
|
|
147
|
-
var _a, _b;
|
|
148
84
|
try {
|
|
149
85
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
150
|
-
|
|
151
|
-
|
|
86
|
+
const parsedAppConfig = JSON.parse(appConfigContent);
|
|
87
|
+
const includesWithSentry = appConfigContent.includes(exports.SENTRY_EXPO_PLUGIN_NAME) ||
|
|
152
88
|
appConfigContent.includes(exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);
|
|
153
89
|
if (includesWithSentry) {
|
|
154
90
|
Sentry.setTag('app-config-file-status', 'already-patched');
|
|
155
|
-
clack.log.warn(
|
|
91
|
+
clack.log.warn(`Your ${chalk_1.default.cyan('app.config.json')} already includes the Sentry Expo plugin.`);
|
|
156
92
|
return null;
|
|
157
93
|
}
|
|
158
94
|
if (parsedAppConfig.expo !== undefined &&
|
|
@@ -166,8 +102,8 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
|
|
|
166
102
|
Sentry.setTag('app-config-file-status', 'invalid-json');
|
|
167
103
|
return null;
|
|
168
104
|
}
|
|
169
|
-
parsedAppConfig.expo =
|
|
170
|
-
parsedAppConfig.expo.plugins =
|
|
105
|
+
parsedAppConfig.expo = parsedAppConfig.expo ?? {};
|
|
106
|
+
parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];
|
|
171
107
|
parsedAppConfig.expo.plugins.push([
|
|
172
108
|
exports.SENTRY_EXPO_PLUGIN_NAME,
|
|
173
109
|
{
|
|
@@ -180,15 +116,26 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
|
|
|
180
116
|
}
|
|
181
117
|
catch (error) {
|
|
182
118
|
Sentry.setTag('app-config-file-status', 'invalid-json');
|
|
183
|
-
clack.log.error(
|
|
119
|
+
clack.log.error(`Unable to parse your ${chalk_1.default.cyan('app.config.json')}. Make sure it has a valid format!`);
|
|
184
120
|
return null;
|
|
185
121
|
}
|
|
186
122
|
}
|
|
187
123
|
exports.addWithSentryToAppConfigJson = addWithSentryToAppConfigJson;
|
|
188
|
-
function getSentryAppConfigJsonCodeSnippet(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
124
|
+
function getSentryAppConfigJsonCodeSnippet({ url, project, org, }) {
|
|
125
|
+
return (0, clack_utils_1.makeCodeSnippet)(true, (unchanged, plus, _minus) => {
|
|
126
|
+
return unchanged(`{
|
|
127
|
+
"name": "my app",
|
|
128
|
+
"plugins": [
|
|
129
|
+
${plus(`[
|
|
130
|
+
"@sentry/react-native/expo",
|
|
131
|
+
{
|
|
132
|
+
"url": "${url}",
|
|
133
|
+
"project": "${project}",
|
|
134
|
+
"organization": "${org}"
|
|
135
|
+
}
|
|
136
|
+
]`)}
|
|
137
|
+
],
|
|
138
|
+
}`);
|
|
192
139
|
});
|
|
193
140
|
}
|
|
194
141
|
exports.getSentryAppConfigJsonCodeSnippet = getSentryAppConfigJsonCodeSnippet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":"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","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport { EOL } from 'os';\n\nimport { isPlainObject } from '@sentry/utils';\nimport * as Sentry from '@sentry/node';\nimport {\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { traceStep } from '../telemetry';\n\nexport const SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';\nexport const DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';\n\nexport const SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';\n\nconst APP_CONFIG_JSON = `app.json`;\n\nexport interface AppConfigJson {\n expo?: {\n plugins?: Array<[string, undefined | Record<string, unknown>]>;\n };\n}\n\nexport function printSentryExpoMigrationOutro(): void {\n clack.outro(\n `Deprecated ${chalk.cyan(\n 'sentry-expo',\n )} package installed in your dependencies. Please follow the migration guide at ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/migration/sentry-expo/',\n )}`,\n );\n}\n\n/**\n * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.\n */\nexport async function patchExpoAppConfig(options: RNCliSetupConfigContent) {\n function showInstructions() {\n return showCopyPasteInstructions(\n APP_CONFIG_JSON,\n getSentryAppConfigJsonCodeSnippet(options),\n 'This ensures auto upload of source maps during native app build.',\n );\n }\n\n const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);\n\n Sentry.setTag(\n 'app-config-file-status',\n appConfigJsonExists ? 'found' : 'not-found',\n );\n if (!appConfigJsonExists) {\n return await showInstructions();\n }\n\n const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);\n if (!patched) {\n return await showInstructions();\n }\n}\n\nasync function patchAppConfigJson(\n path: string,\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const appConfigContent = (\n await fs.promises.readFile(path, { encoding: 'utf-8' })\n ).toString();\n const patchedContent = traceStep('app-config-json-patch', () =>\n addWithSentryToAppConfigJson(appConfigContent, options),\n );\n if (patchedContent === null) {\n return false;\n }\n\n try {\n await fs.promises.writeFile(path, patchedContent);\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'json-write-error');\n clack.log.error(`Unable to write ${chalk.cyan('app.config.json')}.`);\n return false;\n }\n Sentry.setTag('app-config-file-status', 'json-write-success');\n clack.log.success(\n `Added Sentry Expo plugin to ${chalk.cyan('app.config.json')}.`,\n );\n return true;\n}\n\nexport function addWithSentryToAppConfigJson(\n appConfigContent: string,\n options: RNCliSetupConfigContent,\n): string | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedAppConfig: AppConfigJson = JSON.parse(appConfigContent);\n const includesWithSentry =\n appConfigContent.includes(SENTRY_EXPO_PLUGIN_NAME) ||\n appConfigContent.includes(DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);\n\n if (includesWithSentry) {\n Sentry.setTag('app-config-file-status', 'already-patched');\n clack.log.warn(\n `Your ${chalk.cyan(\n 'app.config.json',\n )} already includes the Sentry Expo plugin.`,\n );\n return null;\n }\n\n if (\n parsedAppConfig.expo !== undefined &&\n !isPlainObject(parsedAppConfig.expo)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n if (\n parsedAppConfig.expo &&\n parsedAppConfig.expo.plugins !== undefined &&\n !Array.isArray(parsedAppConfig.expo.plugins)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n\n parsedAppConfig.expo = parsedAppConfig.expo ?? {};\n parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];\n parsedAppConfig.expo.plugins.push([\n SENTRY_EXPO_PLUGIN_NAME,\n {\n url: options.url,\n project: options.project,\n organization: options.org,\n },\n ]);\n\n return JSON.stringify(parsedAppConfig, null, 2) + EOL;\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n}\n\nexport function getSentryAppConfigJsonCodeSnippet({\n url,\n project,\n org,\n}: Omit<RNCliSetupConfigContent, 'authToken'>) {\n return makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`{\n \"name\": \"my app\",\n \"plugins\": [\n ${plus(`[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"${url}\",\n \"project\": \"${project}\",\n \"organization\": \"${org}\"\n }\n ]`)}\n ],\n}`);\n });\n}\n"]}
|
|
@@ -22,64 +22,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
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;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
26
|
exports.addToGitignore = void 0;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
function addToGitignore(filepath) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const GITIGNORE_FILENAME = '.gitignore';
|
|
29
|
+
async function addToGitignore(filepath) {
|
|
30
|
+
/**
|
|
31
|
+
* Don't check whether the given file is ignored because:
|
|
32
|
+
* 1. It's tricky to check it without git.
|
|
33
|
+
* 2. Git might not be installed or accessible.
|
|
34
|
+
* 3. It's convenient to use a module to interact with git, but it would
|
|
35
|
+
* increase the size x2 approximately. Docs say to run the Wizard without
|
|
36
|
+
* installing it, and duplicating the size would slow the set-up down.
|
|
37
|
+
* 4. The Wizard is meant to be run once.
|
|
38
|
+
* 5. A message is logged informing users it's been added to the gitignore.
|
|
39
|
+
* 6. It will be added to the gitignore as many times as it runs - not a big
|
|
40
|
+
* deal.
|
|
41
|
+
* 7. It's straightforward to remove it from the gitignore.
|
|
42
|
+
*/
|
|
43
|
+
try {
|
|
44
|
+
await fs.promises.appendFile(GITIGNORE_FILENAME, `\n${filepath}\n`);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
83
50
|
}
|
|
84
51
|
exports.addToGitignore = addToGitignore;
|
|
85
52
|
//# sourceMappingURL=git.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/react-native/git.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/react-native/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAEjC,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD;;;;;;;;;;;;OAYG;IACH,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE,KAAK,QAAQ,IAAI,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AApBD,wCAoBC","sourcesContent":["import * as fs from 'fs';\n\nconst GITIGNORE_FILENAME = '.gitignore';\n\nexport async function addToGitignore(filepath: string): Promise<boolean> {\n /**\n * Don't check whether the given file is ignored because:\n * 1. It's tricky to check it without git.\n * 2. Git might not be installed or accessible.\n * 3. It's convenient to use a module to interact with git, but it would\n * increase the size x2 approximately. Docs say to run the Wizard without\n * installing it, and duplicating the size would slow the set-up down.\n * 4. The Wizard is meant to be run once.\n * 5. A message is logged informing users it's been added to the gitignore.\n * 6. It will be added to the gitignore as many times as it runs - not a big\n * deal.\n * 7. It's straightforward to remove it from the gitignore.\n */\n try {\n await fs.promises.appendFile(GITIGNORE_FILENAME, `\\n${filepath}\\n`);\n return true;\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -24,12 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getFirstMatchedPath = exports.APP_BUILD_GRADLE = exports.XCODE_PROJECT = void 0;
|
|
27
|
-
|
|
27
|
+
const glob = __importStar(require("glob"));
|
|
28
28
|
exports.XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';
|
|
29
29
|
exports.APP_BUILD_GRADLE = '**/app/build.gradle';
|
|
30
|
-
|
|
30
|
+
const IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];
|
|
31
31
|
function getFirstMatchedPath(pattern) {
|
|
32
|
-
|
|
32
|
+
const matches = glob.sync(pattern, {
|
|
33
33
|
ignore: IGNORE_PATTERNS,
|
|
34
34
|
});
|
|
35
35
|
return matches[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/react-native/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/react-native/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAEhB,QAAA,aAAa,GAAG,iCAAiC,CAAC;AAClD,QAAA,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACzE,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,eAAe;KACxB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAND,kDAMC","sourcesContent":["import * as glob from 'glob';\n\nexport const XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';\nexport const APP_BUILD_GRADLE = '**/app/build.gradle';\n\nconst IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];\nexport function getFirstMatchedPath(pattern: string): string | undefined {\n const matches = glob.sync(pattern, {\n ignore: IGNORE_PATTERNS,\n });\n\n return matches[0];\n}\n"]}
|
|
@@ -24,14 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.writeAppBuildGradle = exports.removeRNSentryGradlePlugin = exports.addRNSentryGradlePlugin = exports.doesAppBuildGradleIncludeRNSentryGradlePlugin = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const applyFrom = `apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")`;
|
|
29
29
|
function doesAppBuildGradleIncludeRNSentryGradlePlugin(content) {
|
|
30
30
|
return content.includes('sentry.gradle');
|
|
31
31
|
}
|
|
32
32
|
exports.doesAppBuildGradleIncludeRNSentryGradlePlugin = doesAppBuildGradleIncludeRNSentryGradlePlugin;
|
|
33
33
|
function addRNSentryGradlePlugin(content) {
|
|
34
|
-
return content.replace(/^android {/m,
|
|
34
|
+
return content.replace(/^android {/m, (match) => `${applyFrom}\n${match}`);
|
|
35
35
|
}
|
|
36
36
|
exports.addRNSentryGradlePlugin = addRNSentryGradlePlugin;
|
|
37
37
|
function removeRNSentryGradlePlugin(content) {
|
|
@@ -39,7 +39,7 @@ function removeRNSentryGradlePlugin(content) {
|
|
|
39
39
|
}
|
|
40
40
|
exports.removeRNSentryGradlePlugin = removeRNSentryGradlePlugin;
|
|
41
41
|
function writeAppBuildGradle(path, newContent) {
|
|
42
|
-
|
|
42
|
+
const currentContent = fs.readFileSync(path, 'utf-8');
|
|
43
43
|
if (newContent === currentContent) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,MAAM,SAAS,GAAG,6IAA6I,CAAC;AAEhK,SAAgB,6CAA6C,CAC3D,OAAe;IAEf,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAJD,sGAIC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,0DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,gEAEC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,UAAkB;IAClE,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAPD,kDAOC","sourcesContent":["import * as fs from 'fs';\n\nconst applyFrom = `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`;\n\nexport function doesAppBuildGradleIncludeRNSentryGradlePlugin(\n content: string,\n): boolean {\n return content.includes('sentry.gradle');\n}\n\nexport function addRNSentryGradlePlugin(content: string): string {\n return content.replace(/^android {/m, (match) => `${applyFrom}\\n${match}`);\n}\n\nexport function removeRNSentryGradlePlugin(content: string): string {\n return content.replace(/^\\s*apply from:.*sentry\\.gradle.*;?\\s*?\\r?\\n/m, '');\n}\n\nexport function writeAppBuildGradle(path: string, newContent: string): void {\n const currentContent = fs.readFileSync(path, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(path, newContent, 'utf-8');\n}\n"]}
|
|
@@ -22,42 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
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;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
@@ -65,79 +29,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
65
29
|
exports.getSentryInitPlainTextSnippet = exports.getSentryInitColoredCodeSnippet = exports.doesJsCodeIncludeSdkSentryImport = exports.addSentryInitWithSdkImport = exports.addSentryInit = void 0;
|
|
66
30
|
/* eslint-disable max-lines */
|
|
67
31
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
function addSentryInit(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
if (includesSentry) {
|
|
106
|
-
Sentry.setTag('app-js-file-status', 'already-includes-sentry');
|
|
107
|
-
prompts_1.default.log.warn("".concat(chalk_1.default.cyan(jsRelativePath), " already includes Sentry. We wont't add it again."));
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
(0, telemetry_1.traceStep)('add-sentry-init', function () {
|
|
111
|
-
var newContent = addSentryInitWithSdkImport(js, { dsn: dsn });
|
|
112
|
-
prompts_1.default.log.success("Added ".concat(chalk_1.default.cyan('Sentry.init'), " to ").concat(chalk_1.default.cyan(jsRelativePath), "."));
|
|
113
|
-
fs.writeFileSync(jsPath, newContent, 'utf-8');
|
|
114
|
-
});
|
|
115
|
-
Sentry.setTag('app-js-file-status', 'added-sentry-init');
|
|
116
|
-
prompts_1.default.log.success(chalk_1.default.green("".concat(chalk_1.default.cyan(jsRelativePath), " changes saved.")));
|
|
117
|
-
return [2 /*return*/];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
32
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
33
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
34
|
+
const path = __importStar(require("path"));
|
|
35
|
+
const process = __importStar(require("process"));
|
|
36
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
38
|
+
const telemetry_1 = require("../telemetry");
|
|
39
|
+
const clack_utils_1 = require("../utils/clack-utils");
|
|
40
|
+
const glob_1 = require("./glob");
|
|
41
|
+
const react_native_wizard_1 = require("./react-native-wizard");
|
|
42
|
+
async function addSentryInit({ dsn }) {
|
|
43
|
+
const prefixGlob = '{.,./src,./app}';
|
|
44
|
+
const suffixGlob = '@(j|t|cj|mj)s?(x)';
|
|
45
|
+
const universalGlob = `@(App|_layout).${suffixGlob}`;
|
|
46
|
+
const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;
|
|
47
|
+
const jsPath = (0, telemetry_1.traceStep)('find-app-js-file', () => (0, glob_1.getFirstMatchedPath)(jsFileGlob));
|
|
48
|
+
Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
|
|
49
|
+
if (!jsPath) {
|
|
50
|
+
prompts_1.default.log.warn(`Could not find main App file. Place the following code snippet close to the Apps Root component.`);
|
|
51
|
+
await (0, clack_utils_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryInitColoredCodeSnippet(dsn), 'This ensures the Sentry SDK is ready to capture errors.');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const jsRelativePath = path.relative(process.cwd(), jsPath);
|
|
55
|
+
const js = fs.readFileSync(jsPath, 'utf-8');
|
|
56
|
+
const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {
|
|
57
|
+
sdkPackageName: react_native_wizard_1.RN_SDK_PACKAGE,
|
|
58
|
+
});
|
|
59
|
+
if (includesSentry) {
|
|
60
|
+
Sentry.setTag('app-js-file-status', 'already-includes-sentry');
|
|
61
|
+
prompts_1.default.log.warn(`${chalk_1.default.cyan(jsRelativePath)} already includes Sentry. We wont't add it again.`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
(0, telemetry_1.traceStep)('add-sentry-init', () => {
|
|
65
|
+
const newContent = addSentryInitWithSdkImport(js, { dsn });
|
|
66
|
+
prompts_1.default.log.success(`Added ${chalk_1.default.cyan('Sentry.init')} to ${chalk_1.default.cyan(jsRelativePath)}.`);
|
|
67
|
+
fs.writeFileSync(jsPath, newContent, 'utf-8');
|
|
120
68
|
});
|
|
69
|
+
Sentry.setTag('app-js-file-status', 'added-sentry-init');
|
|
70
|
+
prompts_1.default.log.success(chalk_1.default.green(`${chalk_1.default.cyan(jsRelativePath)} changes saved.`));
|
|
121
71
|
}
|
|
122
72
|
exports.addSentryInit = addSentryInit;
|
|
123
|
-
function addSentryInitWithSdkImport(js,
|
|
124
|
-
|
|
125
|
-
|
|
73
|
+
function addSentryInitWithSdkImport(js, { dsn }) {
|
|
74
|
+
return js.replace(/^([^]*)(import\s+[^;]*?;$)/m, (match) => `${match}
|
|
75
|
+
${getSentryInitPlainTextSnippet(dsn)}`);
|
|
126
76
|
}
|
|
127
77
|
exports.addSentryInitWithSdkImport = addSentryInitWithSdkImport;
|
|
128
|
-
function doesJsCodeIncludeSdkSentryImport(js,
|
|
129
|
-
var sdkPackageName = _a.sdkPackageName;
|
|
78
|
+
function doesJsCodeIncludeSdkSentryImport(js, { sdkPackageName }) {
|
|
130
79
|
return !!js.match(sdkPackageName);
|
|
131
80
|
}
|
|
132
81
|
exports.doesJsCodeIncludeSdkSentryImport = doesJsCodeIncludeSdkSentryImport;
|
|
133
82
|
function getSentryInitColoredCodeSnippet(dsn) {
|
|
134
|
-
return (0, clack_utils_1.makeCodeSnippet)(true,
|
|
83
|
+
return (0, clack_utils_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
|
|
135
84
|
return plus(getSentryInitPlainTextSnippet(dsn));
|
|
136
85
|
});
|
|
137
86
|
}
|
|
138
87
|
exports.getSentryInitColoredCodeSnippet = getSentryInitColoredCodeSnippet;
|
|
139
88
|
function getSentryInitPlainTextSnippet(dsn) {
|
|
140
|
-
return
|
|
89
|
+
return `import * as Sentry from '@sentry/react-native';
|
|
90
|
+
|
|
91
|
+
Sentry.init({
|
|
92
|
+
dsn: '${dsn}',
|
|
93
|
+
|
|
94
|
+
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
|
|
95
|
+
// spotlight: __DEV__,
|
|
96
|
+
});`;
|
|
141
97
|
}
|
|
142
98
|
exports.getSentryInitPlainTextSnippet = getSentryInitPlainTextSnippet;
|
|
143
99
|
//# sourceMappingURL=javascript.js.map
|