@sentry/wizard 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/README.md +23 -19
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +3 -2
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +2 -2
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +20 -2
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +2 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/File.d.ts +1 -1
- package/dist/lib/Helper/File.js +1 -3
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +3 -0
- package/dist/lib/Helper/Logging.js +3 -0
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +5 -3
- package/dist/lib/Helper/Package.js +2 -2
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/SentryCli.d.ts +20 -7
- package/dist/lib/Helper/SentryCli.js +21 -13
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +9 -5
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +21 -4
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +3 -1
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +1 -2
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +14 -10
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
- package/dist/lib/Steps/Integrations/Electron.js +1 -1
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
- package/dist/lib/Steps/SentryProjectSelector.js +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
- package/dist/lib/Steps/WaitForSentry.js +4 -4
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Types.d.ts +14 -0
- package/dist/lib/Types.js +3 -0
- package/dist/lib/Types.js.map +1 -0
- package/dist/lib/__tests__/Env.js +6 -13
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/android/android-wizard.js +15 -12
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.js +1 -1
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +4 -4
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/android/manifest.js +1 -1
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/apple/apple-wizard.d.ts +2 -2
- package/dist/src/apple/apple-wizard.js +37 -118
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/check-installed-cli.d.ts +1 -0
- package/dist/src/apple/check-installed-cli.js +60 -0
- package/dist/src/apple/check-installed-cli.js.map +1 -0
- package/dist/src/apple/cocoapod.js +1 -1
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.js +1 -1
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/configure-fastlane.d.ts +5 -0
- package/dist/src/apple/configure-fastlane.js +66 -0
- package/dist/src/apple/configure-fastlane.js.map +1 -0
- package/dist/src/apple/fastlane.d.ts +1 -1
- package/dist/src/apple/fastlane.js +5 -5
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/lookup-xcode-project.d.ts +7 -0
- package/dist/src/apple/lookup-xcode-project.js +98 -0
- package/dist/src/apple/lookup-xcode-project.js.map +1 -0
- package/dist/src/apple/options.d.ts +4 -0
- package/dist/src/apple/options.js +3 -0
- package/dist/src/apple/options.js.map +1 -0
- package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
- package/dist/src/apple/search-xcode-project-at-path.js +70 -0
- package/dist/src/apple/search-xcode-project-at-path.js.map +1 -0
- package/dist/src/apple/xcode-manager.js +1 -1
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.js +3 -3
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +21 -15
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.js +4 -4
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +118 -43
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +10 -1
- package/dist/src/nextjs/templates.js +191 -63
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +21 -16
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-example.js +3 -3
- package/dist/src/nuxt/sdk-example.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.js +9 -9
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +173 -58
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/utils.js +6 -3
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +1 -1
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +4 -4
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +4 -4
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/javascript.js +7 -7
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +8 -8
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +1 -1
- package/dist/src/react-native/react-native-wizard.js +36 -31
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/uninstall.js +8 -5
- package/dist/src/react-native/uninstall.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +2 -1
- package/dist/src/react-native/xcode.js +1 -2
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +4 -1
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +23 -18
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +163 -64
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +11 -7
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +3 -1
- package/dist/src/run.js +29 -9
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.js +3 -3
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
- package/dist/src/sourcemaps/tools/esbuild.js +6 -6
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js +5 -5
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +4 -4
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +6 -6
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +15 -15
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +6 -6
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +12 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +10 -10
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +1 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +15 -14
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +126 -37
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/telemetry.js +11 -0
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +45 -7
- package/dist/src/utils/{clack-utils.js → clack/index.js} +72 -19
- package/dist/src/utils/clack/index.js.map +1 -0
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/find-files-with-extension.d.ts +1 -0
- package/dist/src/utils/find-files-with-extension.js +39 -0
- package/dist/src/utils/find-files-with-extension.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +6 -1
- package/dist/src/utils/package-manager.js +25 -19
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/sentrycli-utils.js +0 -1
- package/dist/src/utils/sentrycli-utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +4 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/android/code-tools.test.js +0 -1
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +1 -1
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +1 -1
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +1 -1
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +26 -2
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +0 -2
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +23 -23
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +128 -83
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +1 -1
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +1 -1
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +1 -1
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +5 -5
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/utils/{clack-utils.test.js → clack/index.test.js} +91 -18
- package/dist/test/utils/clack/index.test.js.map +1 -0
- package/dist/test/utils/package-manager.test.d.ts +1 -0
- package/dist/test/utils/package-manager.test.js +29 -0
- package/dist/test/utils/package-manager.test.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/test/utils/clack-utils.test.js.map +0 -1
- /package/dist/test/utils/{clack-utils.test.d.ts → clack/index.test.d.ts} +0 -0
|
@@ -42,7 +42,7 @@ const utils_1 = require("./utils");
|
|
|
42
42
|
const root_v1_1 = require("./codemods/root-v1");
|
|
43
43
|
const root_v2_1 = require("./codemods/root-v2");
|
|
44
44
|
const handle_error_1 = require("./codemods/handle-error");
|
|
45
|
-
const
|
|
45
|
+
const clack_1 = require("../utils/clack");
|
|
46
46
|
const express_server_1 = require("./codemods/express-server");
|
|
47
47
|
const REMIX_CONFIG_FILE = 'remix.config.js';
|
|
48
48
|
const REMIX_REVEAL_COMMAND = 'npx remix reveal';
|
|
@@ -74,11 +74,9 @@ function getInitCallArgs(dsn, type, selectedFeatures) {
|
|
|
74
74
|
(selectedFeatures.performance || selectedFeatures.replay)) {
|
|
75
75
|
initCallArgs.integrations = [];
|
|
76
76
|
if (selectedFeatures.performance) {
|
|
77
|
-
// @ts-expect-error - Adding Proxified AST node to the array
|
|
78
77
|
initCallArgs.integrations.push(magicast_1.builders.functionCall('Sentry.browserTracingIntegration', magicast_1.builders.raw('{ useEffect, useLocation, useMatches }')));
|
|
79
78
|
}
|
|
80
79
|
if (selectedFeatures.replay) {
|
|
81
|
-
// @ts-expect-error - Adding Proxified AST node to the array
|
|
82
80
|
initCallArgs.integrations.push(magicast_1.builders.functionCall('Sentry.replayIntegration', {
|
|
83
81
|
maskAllText: true,
|
|
84
82
|
blockAllMedia: true,
|
|
@@ -89,7 +87,10 @@ function getInitCallArgs(dsn, type, selectedFeatures) {
|
|
|
89
87
|
}
|
|
90
88
|
return initCallArgs;
|
|
91
89
|
}
|
|
92
|
-
function insertClientInitCall(dsn,
|
|
90
|
+
function insertClientInitCall(dsn,
|
|
91
|
+
// MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
originalHooksMod, selectedFeatures) {
|
|
93
94
|
const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);
|
|
94
95
|
const initCall = magicast_1.builders.functionCall('Sentry.init', initCallArgs);
|
|
95
96
|
const originalHooksModAST = originalHooksMod.$ast;
|
|
@@ -189,7 +190,7 @@ async function instrumentRootRoute(isV2, isTS) {
|
|
|
189
190
|
}
|
|
190
191
|
exports.instrumentRootRoute = instrumentRootRoute;
|
|
191
192
|
async function updateBuildScript(args) {
|
|
192
|
-
const packageJson = await (0,
|
|
193
|
+
const packageJson = await (0, clack_1.getPackageDotJson)();
|
|
193
194
|
if (!packageJson.scripts) {
|
|
194
195
|
packageJson.scripts = {};
|
|
195
196
|
}
|
|
@@ -215,7 +216,10 @@ async function updateBuildScript(args) {
|
|
|
215
216
|
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
|
|
216
217
|
}
|
|
217
218
|
exports.updateBuildScript = updateBuildScript;
|
|
218
|
-
function updateEntryClientMod(
|
|
219
|
+
function updateEntryClientMod(
|
|
220
|
+
// MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
|
+
originalEntryClientMod, dsn, selectedFeatures) {
|
|
219
223
|
originalEntryClientMod.imports.$add({
|
|
220
224
|
from: '@sentry/remix',
|
|
221
225
|
imported: '*',
|
|
@@ -255,7 +259,7 @@ async function initializeSentryOnEntryClient(dsn, isTS, selectedFeatures) {
|
|
|
255
259
|
}
|
|
256
260
|
exports.initializeSentryOnEntryClient = initializeSentryOnEntryClient;
|
|
257
261
|
async function updateStartScript(instrumentationFile) {
|
|
258
|
-
const packageJson = await (0,
|
|
262
|
+
const packageJson = await (0, clack_1.getPackageDotJson)();
|
|
259
263
|
if (!packageJson.scripts || !packageJson.scripts.start) {
|
|
260
264
|
throw new Error("Couldn't find a `start` script in your package.json. Please add one manually.");
|
|
261
265
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-setup.js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I,CAAC,IAAI,CACnC,OAAO,CAAC,GAAG,EAAE,EACb,KAAK,EACL,mBAAmB,CACpB,CAAC;IAEF,MAAM,sBAAsB,GAAG,MAAM,IAAA,mBAAQ,EAAC,mBAAmB,CAAC,CAAC;IAEnE,IAAI,IAAA,wBAAgB,EAAC,mBAAmB,EAAE,sBAAsB,CAAC,KAAK,CAAC,EAAE;QACvE,OAAO;KACR;IAED,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;QAClC,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,IAAI,IAAI,EAAE;QACR,MAAM,uBAAuB,GAAG,IAAA,oCAAqB,EACnD,sBAAsB,EACtB,mBAAmB,CACpB,CAAC;QAEF,IAAI,uBAAuB,EAAE;YAC3B,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gBAAgB,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,eAAK,CAAC,IAAI,CACxD,GAAG,mBAAmB,EAAE,CACzB,EAAE,CACJ,CAAC;SACH;KACF;IAED,MAAM,IAAA,oBAAS,EACb,sBAAsB,CAAC,IAAI,EAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CACrD,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,yDAAyD,eAAK,CAAC,IAAI,CACjE,mBAAmB,CACpB,GAAG,CACL,CAAC;AACJ,CAAC;AAjDD,sEAiDC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRootRouteV1 } from './codemods/root-v1';\nimport { instrumentRootRouteV2 } from './codemods/root-v2';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack-utils';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n future?: {\n v2_dev?: boolean;\n v2_errorBoundary?: boolean;\n v2_headers?: boolean;\n v2_meta?: boolean;\n v2_normalizeFormMethod?: boolean;\n v2_routeConvention?: boolean;\n };\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\nfunction getInitCallArgs(\n dsn: string,\n type: 'client' | 'server',\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const initCallArgs = {\n dsn,\n } as Record<string, unknown>;\n\n // Adding tracing sample rate for both client and server\n if (selectedFeatures.performance) {\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n // Adding integrations and replay options only for client\n if (\n type === 'client' &&\n (selectedFeatures.performance || selectedFeatures.replay)\n ) {\n initCallArgs.integrations = [];\n\n if (selectedFeatures.performance) {\n // @ts-expect-error - Adding Proxified AST node to the array\n initCallArgs.integrations.push(\n builders.functionCall(\n 'Sentry.browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n );\n }\n\n if (selectedFeatures.replay) {\n // @ts-expect-error - Adding Proxified AST node to the array\n initCallArgs.integrations.push(\n builders.functionCall('Sentry.replayIntegration', {\n maskAllText: true,\n blockAllMedia: true,\n }),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n return initCallArgs;\n}\n\nfunction insertClientInitCall(\n dsn: string,\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nexport function generateServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCallArgs = getInitCallArgs(dsn, 'server', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n\n return { instrumentationFile, instrumentationFileMod };\n}\n\nexport async function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const { instrumentationFile, instrumentationFileMod } =\n generateServerInstrumentationFile(dsn, selectedFeatures);\n\n await writeFile(instrumentationFileMod.$ast, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(\n remixConfig: PartialRemixConfig,\n packageJson: PackageDotJson,\n): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n const isV2Remix = gte(minVer, '2.0.0');\n\n return isV2Remix || remixConfig?.future?.v2_errorBoundary || false;\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function instrumentRootRoute(\n isV2?: boolean,\n isTS?: boolean,\n): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n if (isV2) {\n await instrumentRootRouteV2(rootFilename);\n } else {\n await instrumentRootRouteV1(rootFilename);\n }\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport function updateEntryClientMod(\n originalEntryClientMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): ProxifiedModule<any> {\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n if (selectedFeatures.performance) {\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n }\n\n insertClientInitCall(dsn, originalEntryClientMod, selectedFeatures);\n\n return originalEntryClientMod;\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n const updatedEntryClientMod = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n await writeFile(\n updatedEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isV2: boolean,\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n if (isV2) {\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/remix/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO5D,uCAAyB;AACzB,2CAA6B;AAC7B,yCAA2B;AAC3B,4DAA8C;AAE9C,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAAyC;AAEzC,uCAOkB;AAElB,wDAA0D;AAC1D,mCAIiB;AACjB,gDAA2D;AAC3D,gDAA2D;AAC3D,0DAAgE;AAChE,0CAAmD;AACnD,8DAAkF;AAclF,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEhD,SAAgB,cAAc,CAAC,IAAa;IAC1C,qCAAqC;IACrC,MAAM,mBAAmB,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IACnE,MAAM,mBAAmB,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAEnE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAC7E,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAE7E,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,U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L,CAAC;AACJ,CAAC;AAjDD,sEAiDC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { Proxified, ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRootRouteV1 } from './codemods/root-v1';\nimport { instrumentRootRouteV2 } from './codemods/root-v2';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n future?: {\n v2_dev?: boolean;\n v2_errorBoundary?: boolean;\n v2_headers?: boolean;\n v2_meta?: boolean;\n v2_normalizeFormMethod?: boolean;\n v2_routeConvention?: boolean;\n };\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\ninterface SdkAstOptions {\n dsn: string;\n tracesSampleRate?: number;\n replaysSessionSampleRate?: number;\n replaysOnErrorSampleRate?: number;\n integrations?: Array<Proxified>;\n}\n\nfunction getInitCallArgs(\n dsn: string,\n type: 'client' | 'server',\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const initCallArgs: SdkAstOptions = {\n dsn,\n };\n\n // Adding tracing sample rate for both client and server\n if (selectedFeatures.performance) {\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n // Adding integrations and replay options only for client\n if (\n type === 'client' &&\n (selectedFeatures.performance || selectedFeatures.replay)\n ) {\n initCallArgs.integrations = [] as Array<Proxified>;\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall(\n 'Sentry.browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n );\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('Sentry.replayIntegration', {\n maskAllText: true,\n blockAllMedia: true,\n }),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n return initCallArgs;\n}\n\nfunction insertClientInitCall(\n dsn: string,\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nexport function generateServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCallArgs = getInitCallArgs(dsn, 'server', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n\n return { instrumentationFile, instrumentationFileMod };\n}\n\nexport async function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const { instrumentationFile, instrumentationFileMod } =\n generateServerInstrumentationFile(dsn, selectedFeatures);\n\n await writeFile(instrumentationFileMod.$ast, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(\n remixConfig: PartialRemixConfig,\n packageJson: PackageDotJson,\n): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n const isV2Remix = gte(minVer, '2.0.0');\n\n return isV2Remix || remixConfig?.future?.v2_errorBoundary || false;\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function instrumentRootRoute(\n isV2?: boolean,\n isTS?: boolean,\n): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n if (isV2) {\n await instrumentRootRouteV2(rootFilename);\n } else {\n await instrumentRootRouteV1(rootFilename);\n }\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport function updateEntryClientMod(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryClientMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n if (selectedFeatures.performance) {\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n }\n\n insertClientInitCall(dsn, originalEntryClientMod, selectedFeatures);\n\n return originalEntryClientMod;\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n const updatedEntryClientMod = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n await writeFile(\n updatedEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isV2: boolean,\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n if (isV2) {\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
|
package/dist/src/run.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Platform } from '../lib/Constants';
|
|
2
2
|
type WizardIntegration = 'reactNative' | 'flutter' | 'ios' | 'android' | 'cordova' | 'electron' | 'nextjs' | 'nuxt' | 'remix' | 'sveltekit' | 'sourcemaps';
|
|
3
3
|
type Args = {
|
|
4
4
|
integration?: WizardIntegration;
|
|
@@ -27,6 +27,8 @@ type Args = {
|
|
|
27
27
|
saas?: boolean;
|
|
28
28
|
forceInstall?: boolean;
|
|
29
29
|
comingFrom?: string;
|
|
30
|
+
ignoreGitChanges?: boolean;
|
|
31
|
+
xcodeProjectDir?: string;
|
|
30
32
|
};
|
|
31
33
|
export declare function run(argv: Args): Promise<void>;
|
|
32
34
|
export {};
|
package/dist/src/run.js
CHANGED
|
@@ -24,20 +24,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.run = void 0;
|
|
27
|
-
// @ts-
|
|
27
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
28
28
|
const clack = __importStar(require("@clack/prompts"));
|
|
29
|
-
const clack_utils_1 = require("./utils/clack-utils");
|
|
30
29
|
const react_native_wizard_1 = require("./react-native/react-native-wizard");
|
|
30
|
+
const clack_1 = require("./utils/clack");
|
|
31
|
+
const Constants_1 = require("../lib/Constants");
|
|
32
|
+
const Env_1 = require("../lib/Helper/Env");
|
|
31
33
|
const Setup_1 = require("../lib/Setup");
|
|
32
|
-
const flutter_wizard_1 = require("./flutter/flutter-wizard");
|
|
33
34
|
const android_wizard_1 = require("./android/android-wizard");
|
|
34
35
|
const apple_wizard_1 = require("./apple/apple-wizard");
|
|
36
|
+
const flutter_wizard_1 = require("./flutter/flutter-wizard");
|
|
35
37
|
const nextjs_wizard_1 = require("./nextjs/nextjs-wizard");
|
|
36
38
|
const nuxt_wizard_1 = require("./nuxt/nuxt-wizard");
|
|
37
39
|
const remix_wizard_1 = require("./remix/remix-wizard");
|
|
38
|
-
const sveltekit_wizard_1 = require("./sveltekit/sveltekit-wizard");
|
|
39
40
|
const sourcemaps_wizard_1 = require("./sourcemaps/sourcemaps-wizard");
|
|
40
|
-
const
|
|
41
|
+
const sveltekit_wizard_1 = require("./sveltekit/sveltekit-wizard");
|
|
42
|
+
const debug_1 = require("./utils/debug");
|
|
41
43
|
const version_1 = require("./version");
|
|
42
44
|
function preSelectedProjectArgsToObject(args) {
|
|
43
45
|
if (!args.preSelectedProject) {
|
|
@@ -69,10 +71,14 @@ async function run(argv) {
|
|
|
69
71
|
...argv,
|
|
70
72
|
...(0, Env_1.readEnvironment)(),
|
|
71
73
|
};
|
|
74
|
+
// Enable debug logs if the user has passed the --debug flag
|
|
75
|
+
if (finalArgs.debug) {
|
|
76
|
+
(0, debug_1.enableDebugLogs)();
|
|
77
|
+
}
|
|
72
78
|
let integration = finalArgs.integration;
|
|
73
79
|
if (!integration) {
|
|
74
80
|
clack.intro(`Sentry Wizard ${version_1.WIZARD_VERSION}`);
|
|
75
|
-
integration = await (0,
|
|
81
|
+
integration = await (0, clack_1.abortIfCancelled)(clack.select({
|
|
76
82
|
message: 'What do you want to set up?',
|
|
77
83
|
options: [
|
|
78
84
|
{ value: 'reactNative', label: 'React Native' },
|
|
@@ -104,6 +110,7 @@ async function run(argv) {
|
|
|
104
110
|
preSelectedProject: preSelectedProjectArgsToObject(finalArgs),
|
|
105
111
|
forceInstall: finalArgs.forceInstall,
|
|
106
112
|
comingFrom: finalArgs.comingFrom,
|
|
113
|
+
ignoreGitChanges: finalArgs.ignoreGitChanges,
|
|
107
114
|
};
|
|
108
115
|
switch (integration) {
|
|
109
116
|
case 'reactNative':
|
|
@@ -116,7 +123,10 @@ async function run(argv) {
|
|
|
116
123
|
await (0, flutter_wizard_1.runFlutterWizard)(wizardOptions);
|
|
117
124
|
break;
|
|
118
125
|
case 'ios':
|
|
119
|
-
await (0, apple_wizard_1.runAppleWizard)(
|
|
126
|
+
await (0, apple_wizard_1.runAppleWizard)({
|
|
127
|
+
...wizardOptions,
|
|
128
|
+
projectDir: finalArgs.xcodeProjectDir,
|
|
129
|
+
});
|
|
120
130
|
break;
|
|
121
131
|
case 'android':
|
|
122
132
|
await (0, android_wizard_1.runAndroidWizard)(wizardOptions);
|
|
@@ -138,11 +148,21 @@ async function run(argv) {
|
|
|
138
148
|
break;
|
|
139
149
|
case 'cordova':
|
|
140
150
|
argv.integration = 'cordova';
|
|
141
|
-
void (0, Setup_1.run)(
|
|
151
|
+
void (0, Setup_1.run)({
|
|
152
|
+
...argv,
|
|
153
|
+
url: argv.url ?? '',
|
|
154
|
+
integration: Constants_1.Integration.cordova,
|
|
155
|
+
platform: argv.platform ?? [],
|
|
156
|
+
});
|
|
142
157
|
break;
|
|
143
158
|
case 'electron':
|
|
144
159
|
argv.integration = 'electron';
|
|
145
|
-
void (0, Setup_1.run)(
|
|
160
|
+
void (0, Setup_1.run)({
|
|
161
|
+
...argv,
|
|
162
|
+
url: argv.url ?? '',
|
|
163
|
+
integration: Constants_1.Integration.electron,
|
|
164
|
+
platform: argv.platform ?? [],
|
|
165
|
+
});
|
|
146
166
|
break;
|
|
147
167
|
default:
|
|
148
168
|
clack.log.error('No setup wizard selected!');
|
package/dist/src/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,4EAA0E;AAC1E,yCAAiD;AAEjD,gDAA8D;AAC9D,2CAAoD;AACpD,wCAAgD;AAChD,6DAA4D;AAC5D,uDAAsD;AACtD,6DAA4D;AAC5D,0DAAyD;AACzD,oDAAmD;AACnD,uDAAsD;AACtD,sEAAqE;AACrE,mEAAkE;AAClE,yCAAgD;AAEhD,uCAA2C;AA+C3C,SAAS,8BAA8B,CACrC,IAAU;IAEV,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;QAC5B,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,SAAS;QAC5C,UAAU,EAAE,IAAI,CAAC,kBAAkB,CAAC,UAAU;QAC9C,OAAO,EAAE;YACP,EAAE,EAAE,IAAI,CAAC,kBAAkB,CAAC,SAAS;YACrC,IAAI,EAAE;gBACJ;oBACE,GAAG,EAAE;wBACH,MAAM,EAAE,IAAI,CAAC,kB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YACZ,MAAM,IAAA,iCAAgB,EAAC,aAAa,CAAC,CAAC;YACtC,MAAM;QAER,KAAK,QAAQ;YACX,MAAM,IAAA,+BAAe,EAAC,aAAa,CAAC,CAAC;YACrC,MAAM;QAER,KAAK,MAAM;YACT,MAAM,IAAA,2BAAa,EAAC,aAAa,CAAC,CAAC;YACnC,MAAM;QAER,KAAK,OAAO;YACV,MAAM,IAAA,6BAAc,EAAC,aAAa,CAAC,CAAC;YACpC,MAAM;QAER,KAAK,WAAW;YACd,MAAM,IAAA,qCAAkB,EAAC,aAAa,CAAC,CAAC;YACxC,MAAM;QAER,KAAK,YAAY;YACf,MAAM,IAAA,uCAAmB,EAAC,aAAa,CAAC,CAAC;YACzC,MAAM;QAER,KAAK,SAAS;YACZ,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC7B,KAAK,IAAA,WAAS,EAAC;gBACb,GAAG,IAAI;gBACP,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE;gBACnB,WAAW,EAAE,uBAAW,CAAC,OAAO;gBAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;aAC9B,CAAC,CAAC;YACH,MAAM;QAER,KAAK,UAAU;YACb,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;YAC9B,KAAK,IAAA,WAAS,EAAC;gBACb,GAAG,IAAI;gBACP,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE;gBACnB,WAAW,EAAE,uBAAW,CAAC,QAAQ;gBACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;aAC9B,CAAC,CAAC;YACH,MAAM;QAER;YACE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAChD;AACH,CAAC;AAzHD,kBAyHC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\nimport { abortIfCancelled } from './utils/clack';\n\nimport { Integration, type Platform } from '../lib/Constants';\nimport { readEnvironment } from '../lib/Helper/Env';\nimport { run as legacyRun } from '../lib/Setup';\nimport { runAndroidWizard } from './android/android-wizard';\nimport { runAppleWizard } from './apple/apple-wizard';\nimport { runFlutterWizard } from './flutter/flutter-wizard';\nimport { runNextjsWizard } from './nextjs/nextjs-wizard';\nimport { runNuxtWizard } from './nuxt/nuxt-wizard';\nimport { runRemixWizard } from './remix/remix-wizard';\nimport { runSourcemapsWizard } from './sourcemaps/sourcemaps-wizard';\nimport { runSvelteKitWizard } from './sveltekit/sveltekit-wizard';\nimport { enableDebugLogs } from './utils/debug';\nimport type { PreselectedProject, WizardOptions } from './utils/types';\nimport { WIZARD_VERSION } from './version';\n\ntype WizardIntegration =\n | 'reactNative'\n | 'flutter'\n | 'ios'\n | 'android'\n | 'cordova'\n | 'electron'\n | 'nextjs'\n | 'nuxt'\n | 'remix'\n | 'sveltekit'\n | 'sourcemaps';\n\ntype Args = {\n integration?: WizardIntegration;\n\n uninstall: boolean;\n signup: boolean;\n skipConnect: boolean;\n debug: boolean;\n quiet: boolean;\n disableTelemetry: boolean;\n promoCode?: string;\n preSelectedProject?: {\n authToken: string;\n selfHosted: boolean;\n dsn: string;\n projectId: string;\n projectSlug: string;\n projectName: string;\n orgId: string;\n orgName: string;\n orgSlug: string;\n };\n url?: string;\n platform?: Platform[];\n org?: string;\n project?: string;\n saas?: boolean;\n forceInstall?: boolean;\n comingFrom?: string;\n ignoreGitChanges?: boolean;\n xcodeProjectDir?: string;\n};\n\nfunction preSelectedProjectArgsToObject(\n args: Args,\n): PreselectedProject | undefined {\n if (!args.preSelectedProject) {\n return undefined;\n }\n\n return {\n authToken: args.preSelectedProject.authToken,\n selfHosted: args.preSelectedProject.selfHosted,\n project: {\n id: args.preSelectedProject.projectId,\n keys: [\n {\n dsn: {\n public: args.preSelectedProject.dsn,\n },\n },\n ],\n organization: {\n id: args.preSelectedProject.orgId,\n name: args.preSelectedProject.orgName,\n slug: args.preSelectedProject.orgSlug,\n },\n slug: args.preSelectedProject.projectSlug,\n },\n };\n}\n\nexport async function run(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n // Enable debug logs if the user has passed the --debug flag\n if (finalArgs.debug) {\n enableDebugLogs();\n }\n\n let integration = finalArgs.integration;\n if (!integration) {\n clack.intro(`Sentry Wizard ${WIZARD_VERSION}`);\n\n integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: 'reactNative', label: 'React Native' },\n { value: 'flutter', label: 'Flutter' },\n { value: 'ios', label: 'iOS' },\n { value: 'android', label: 'Android' },\n { value: 'cordova', label: 'Cordova' },\n { value: 'electron', label: 'Electron' },\n { value: 'nextjs', label: 'Next.js' },\n { value: 'nuxt', label: 'Nuxt' },\n { value: 'remix', label: 'Remix' },\n { value: 'sveltekit', label: 'SvelteKit' },\n { value: 'sourcemaps', label: 'Configure Source Maps Upload' },\n ],\n }),\n );\n\n if (!integration) {\n clack.log.error('No integration selected. Exiting.');\n return;\n }\n\n clack.outro(`Starting ${integration} setup`);\n }\n\n const wizardOptions: WizardOptions = {\n telemetryEnabled: !finalArgs.disableTelemetry,\n promoCode: finalArgs.promoCode,\n url: finalArgs.url,\n orgSlug: finalArgs.org,\n projectSlug: finalArgs.project,\n saas: finalArgs.saas,\n preSelectedProject: preSelectedProjectArgsToObject(finalArgs),\n forceInstall: finalArgs.forceInstall,\n comingFrom: finalArgs.comingFrom,\n ignoreGitChanges: finalArgs.ignoreGitChanges,\n };\n\n switch (integration) {\n case 'reactNative':\n await runReactNativeWizard({\n ...wizardOptions,\n uninstall: finalArgs.uninstall,\n });\n break;\n\n case 'flutter':\n await runFlutterWizard(wizardOptions);\n break;\n\n case 'ios':\n await runAppleWizard({\n ...wizardOptions,\n projectDir: finalArgs.xcodeProjectDir,\n });\n break;\n\n case 'android':\n await runAndroidWizard(wizardOptions);\n break;\n\n case 'nextjs':\n await runNextjsWizard(wizardOptions);\n break;\n\n case 'nuxt':\n await runNuxtWizard(wizardOptions);\n break;\n\n case 'remix':\n await runRemixWizard(wizardOptions);\n break;\n\n case 'sveltekit':\n await runSvelteKitWizard(wizardOptions);\n break;\n\n case 'sourcemaps':\n await runSourcemapsWizard(wizardOptions);\n break;\n\n case 'cordova':\n argv.integration = 'cordova';\n void legacyRun({\n ...argv,\n url: argv.url ?? '',\n integration: Integration.cordova,\n platform: argv.platform ?? [],\n });\n break;\n\n case 'electron':\n argv.integration = 'electron';\n void legacyRun({\n ...argv,\n url: argv.url ?? '',\n integration: Integration.electron,\n platform: argv.platform ?? [],\n });\n break;\n\n default:\n clack.log.error('No setup wizard selected!');\n }\n}\n"]}
|
|
@@ -27,26 +27,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.configureCI = exports.setupCI = exports.runSourcemapsWizard = void 0;
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
31
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
32
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
33
32
|
const Sentry = __importStar(require("@sentry/node"));
|
|
34
|
-
const
|
|
33
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
34
|
+
const telemetry_1 = require("../telemetry");
|
|
35
|
+
const clack_1 = require("../utils/clack");
|
|
36
|
+
const package_manager_1 = require("../utils/package-manager");
|
|
37
|
+
const url_1 = require("../utils/url");
|
|
35
38
|
const is_unicorn_supported_1 = require("../utils/vendor/is-unicorn-supported");
|
|
36
|
-
const
|
|
39
|
+
const angular_1 = require("./tools/angular");
|
|
40
|
+
const create_react_app_1 = require("./tools/create-react-app");
|
|
41
|
+
const esbuild_1 = require("./tools/esbuild");
|
|
42
|
+
const rollup_1 = require("./tools/rollup");
|
|
37
43
|
const sentry_cli_1 = require("./tools/sentry-cli");
|
|
38
|
-
const webpack_1 = require("./tools/webpack");
|
|
39
44
|
const tsc_1 = require("./tools/tsc");
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const create_react_app_1 = require("./tools/create-react-app");
|
|
43
|
-
const sdk_version_1 = require("./utils/sdk-version");
|
|
44
|
-
const telemetry_1 = require("../telemetry");
|
|
45
|
-
const other_wizards_1 = require("./utils/other-wizards");
|
|
46
|
-
const angular_1 = require("./tools/angular");
|
|
45
|
+
const vite_1 = require("./tools/vite");
|
|
46
|
+
const webpack_1 = require("./tools/webpack");
|
|
47
47
|
const detect_tool_1 = require("./utils/detect-tool");
|
|
48
|
-
const
|
|
49
|
-
const
|
|
48
|
+
const other_wizards_1 = require("./utils/other-wizards");
|
|
49
|
+
const sdk_version_1 = require("./utils/sdk-version");
|
|
50
50
|
async function runSourcemapsWizard(options) {
|
|
51
51
|
return (0, telemetry_1.withTelemetry)({
|
|
52
52
|
enabled: options.telemetryEnabled,
|
|
@@ -56,7 +56,7 @@ async function runSourcemapsWizard(options) {
|
|
|
56
56
|
}
|
|
57
57
|
exports.runSourcemapsWizard = runSourcemapsWizard;
|
|
58
58
|
async function runSourcemapsWizardWithTelemetry(options) {
|
|
59
|
-
(0,
|
|
59
|
+
(0, clack_1.printWelcome)({
|
|
60
60
|
wizardName: 'Sentry Source Maps Upload Configuration Wizard',
|
|
61
61
|
message: `This wizard will help you upload source maps to Sentry as part of your build.
|
|
62
62
|
Thank you for using Sentry :)${options.telemetryEnabled
|
|
@@ -72,14 +72,17 @@ You can turn this off by running the wizard with the '--disable-telemetry' flag.
|
|
|
72
72
|
await (0, telemetry_1.traceStep)('run-framework-wizard', () => moreSuitableWizard(options));
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
await (0,
|
|
75
|
+
await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
|
|
76
|
+
ignoreGitChanges: options.ignoreGitChanges,
|
|
77
|
+
cwd: undefined,
|
|
78
|
+
});
|
|
76
79
|
await (0, telemetry_1.traceStep)('check-sdk-version', sdk_version_1.ensureMinimumSdkVersionIsInstalled);
|
|
77
|
-
const { selfHosted, selectedProject, sentryUrl, authToken } = await (0,
|
|
80
|
+
const { selfHosted, selectedProject, sentryUrl, authToken } = await (0, clack_1.getOrAskForProjectData)(options);
|
|
78
81
|
const selectedTool = await (0, telemetry_1.traceStep)('select-tool', askForUsedBundlerTool);
|
|
79
82
|
Sentry.setTag('selected-tool', selectedTool);
|
|
80
83
|
if (selectedTool === 'no-tool') {
|
|
81
84
|
prompts_1.default.log.info("No Problem! But in this case, there's nothing to configure :)");
|
|
82
|
-
await (0,
|
|
85
|
+
await (0, clack_1.abort)('Exiting, have a great day!', 0);
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
await (0, telemetry_1.traceStep)('tool-setup', () => startToolSetupFlow(selectedTool, {
|
|
@@ -90,10 +93,10 @@ You can turn this off by running the wizard with the '--disable-telemetry' flag.
|
|
|
90
93
|
authToken,
|
|
91
94
|
}));
|
|
92
95
|
await (0, telemetry_1.traceStep)('ci-setup', () => setupCI(selectedTool, authToken, options.comingFrom));
|
|
93
|
-
(0, telemetry_1.traceStep)('outro', () => printOutro(sentryUrl, selectedProject.organization.slug, selectedProject.id));
|
|
96
|
+
await (0, telemetry_1.traceStep)('outro', () => printOutro(sentryUrl, selectedProject.organization.slug, selectedProject.id));
|
|
94
97
|
}
|
|
95
98
|
async function askForUsedBundlerTool() {
|
|
96
|
-
const selectedTool = await (0,
|
|
99
|
+
const selectedTool = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
97
100
|
message: 'Which framework, bundler or build tool are you using?',
|
|
98
101
|
options: [
|
|
99
102
|
{
|
|
@@ -185,7 +188,7 @@ async function setupCI(selectedTool, authToken, comingFrom) {
|
|
|
185
188
|
}
|
|
186
189
|
exports.setupCI = setupCI;
|
|
187
190
|
async function configureCI(selectedTool, authToken) {
|
|
188
|
-
const isUsingCI = await (0,
|
|
191
|
+
const isUsingCI = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
189
192
|
message: `Are you using a CI/CD tool to build and deploy your application?`,
|
|
190
193
|
options: [
|
|
191
194
|
{
|
|
@@ -209,8 +212,8 @@ async function configureCI(selectedTool, authToken) {
|
|
|
209
212
|
'create-react-app',
|
|
210
213
|
].includes(selectedTool);
|
|
211
214
|
const authTokenFile = isCliBasedFlowTool
|
|
212
|
-
?
|
|
213
|
-
:
|
|
215
|
+
? clack_1.SENTRY_CLI_RC_FILE
|
|
216
|
+
: clack_1.SENTRY_DOT_ENV_FILE;
|
|
214
217
|
if (!isUsingCI) {
|
|
215
218
|
prompts_1.default.log.info(`No Problem! Just make sure that the Sentry auth token from ${chalk_1.default.cyan(authTokenFile)} is available whenever you build and deploy your app.`);
|
|
216
219
|
return;
|
|
@@ -229,7 +232,7 @@ async function setupAuthTokenInCI(authToken) {
|
|
|
229
232
|
SENTRY_AUTH_TOKEN=${authToken}
|
|
230
233
|
`));
|
|
231
234
|
prompts_1.default.log.warn(chalk_1.default.yellow('DO NOT commit this auth token to your repository!'));
|
|
232
|
-
const addedEnvVarToCI = await (0,
|
|
235
|
+
const addedEnvVarToCI = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
233
236
|
message: 'Did you configure CI as shown above?',
|
|
234
237
|
options: [
|
|
235
238
|
{ label: 'Yes, continue!', value: true },
|
|
@@ -246,9 +249,8 @@ SENTRY_AUTH_TOKEN=${authToken}
|
|
|
246
249
|
prompts_1.default.log.info("Don't forget! :)");
|
|
247
250
|
}
|
|
248
251
|
}
|
|
249
|
-
function printOutro(url, orgSlug, projectId) {
|
|
250
|
-
const packageManager = (0,
|
|
251
|
-
const buildCommand = packageManager?.buildCommand ?? 'npm run build';
|
|
252
|
+
async function printOutro(url, orgSlug, projectId) {
|
|
253
|
+
const packageManager = await (0, clack_1.getPackageManager)(package_manager_1.NPM);
|
|
252
254
|
const issueStreamUrl = (0, url_1.getIssueStreamUrl)({ url, orgSlug, projectId });
|
|
253
255
|
const arrow = (0, is_unicorn_supported_1.isUnicodeSupported)() ? '→' : '->';
|
|
254
256
|
prompts_1.default.outro(`${chalk_1.default.green("That's it - everything is set up!")}
|
|
@@ -256,7 +258,7 @@ function printOutro(url, orgSlug, projectId) {
|
|
|
256
258
|
${chalk_1.default.cyan(`Test and validate your setup locally with the following Steps:
|
|
257
259
|
|
|
258
260
|
1. Build your application in ${chalk_1.default.bold('production mode')}.
|
|
259
|
-
${chalk_1.default.gray(`${arrow} For example, run ${chalk_1.default.bold(buildCommand)}.`)}
|
|
261
|
+
${chalk_1.default.gray(`${arrow} For example, run ${chalk_1.default.bold(packageManager.buildCommand)}.`)}
|
|
260
262
|
${chalk_1.default.gray(`${arrow} You should see source map upload logs in your console.`)}
|
|
261
263
|
2. Run your application and throw a test error.
|
|
262
264
|
${chalk_1.default.gray(`${arrow} The error should appear in Sentry:`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourcemaps-wizard.js","sourceRoot":"","sources":["../../../src/sourcemaps/sourcemaps-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,6DAAmC;AACnC,kDAA0B;AAC1B,qDAAuC;AAEvC,sDAQ8B;AAC9B,+EAA0E;AAE1E,uCAAmD;AACnD,mDAA4E;AAC5E,6CAAyD;AACzD,qCAAkE;AAClE,2CAAuD;AACvD,6CAAyD;AAEzD,+DAA+E;AAC/E,qDAAyE;AACzE,4CAAwD;AACxD,yDAAyF;AACzF,6CAA0E;AAE1E,qDAAqD;AACrD,8DAA+D;AAC/D,sCAAiD;AAE1C,KAAK,UAAU,mBAAmB,CACvC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,YAAY;QACzB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAChD,CAAC;AACJ,CA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CAAC,IAAI,CAAC,iBAAiB,CAAC;QACvD,eAAK,CAAC,IAAI,CAAC,GAAG,KAAK,qBAAqB,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;QACpE,eAAK,CAAC,IAAI,CACV,GAAG,KAAK,yDAAyD,CAClE;;QAEC,eAAK,CAAC,IAAI,CAAC,GAAG,KAAK,qCAAqC,CAAC;QACzD,eAAK,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,cAAc,EAAE,CAAC;;QAExC,eAAK,CAAC,IAAI,CACV,GAAG,KAAK,yDAAyD,CAClE;IACH,CAAC;KACA,eAAK,CAAC,GAAG,CACT;;;;yDAIoD,CACrD;CACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n confirmContinueIfNoOrDirtyGitRepo,\n SENTRY_DOT_ENV_FILE,\n printWelcome,\n SENTRY_CLI_RC_FILE,\n getOrAskForProjectData,\n} from '../utils/clack-utils';\nimport { isUnicodeSupported } from '../utils/vendor/is-unicorn-supported';\nimport type { SourceMapUploadToolConfigurationOptions } from './tools/types';\nimport { configureVitePlugin } from './tools/vite';\nimport { setupNpmScriptInCI, configureSentryCLI } from './tools/sentry-cli';\nimport { configureWebPackPlugin } from './tools/webpack';\nimport { configureTscSourcemapGenerationFlow } from './tools/tsc';\nimport { configureRollupPlugin } from './tools/rollup';\nimport { configureEsbuildPlugin } from './tools/esbuild';\nimport type { WizardOptions } from '../utils/types';\nimport { configureCRASourcemapGenerationFlow } from './tools/create-react-app';\nimport { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';\nimport { configureAngularSourcemapGenerationFlow } from './tools/angular';\nimport type { SupportedTools } from './utils/detect-tool';\nimport { detectUsedTool } from './utils/detect-tool';\nimport { detectPackageManger } from '../utils/package-manager';\nimport { getIssueStreamUrl } from '../utils/url';\n\nexport async function runSourcemapsWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sourcemaps',\n wizardOptions: options,\n },\n () => runSourcemapsWizardWithTelemetry(options),\n );\n}\n\nasync function runSourcemapsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Source Maps Upload Configuration Wizard',\n message: `This wizard will help you upload source maps to Sentry as part of your build.\nThank you for using Sentry :)${\n options.telemetryEnabled\n ? `\n\n(This setup wizard sends telemetry data and crash reports to Sentry.\nYou can turn this off by running the wizard with the '--disable-telemetry' flag.)`\n : ''\n }`,\n promoCode: options.promoCode,\n });\n\n const moreSuitableWizard = await traceStep(\n 'check-framework-wizard',\n checkIfMoreSuitableWizardExistsAndAskForRedirect,\n );\n if (moreSuitableWizard) {\n await traceStep('run-framework-wizard', () => moreSuitableWizard(options));\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);\n\n const { selfHosted, selectedProject, sentryUrl, authToken } =\n await getOrAskForProjectData(options);\n\n const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);\n\n Sentry.setTag('selected-tool', selectedTool);\n\n if (selectedTool === 'no-tool') {\n clack.log.info(\n \"No Problem! But in this case, there's nothing to configure :)\",\n );\n await abort('Exiting, have a great day!', 0);\n return;\n }\n\n await traceStep('tool-setup', () =>\n startToolSetupFlow(selectedTool, {\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n authToken,\n }),\n );\n\n await traceStep('ci-setup', () =>\n setupCI(selectedTool, authToken, options.comingFrom),\n );\n\n traceStep('outro', () =>\n printOutro(\n sentryUrl,\n selectedProject.organization.slug,\n selectedProject.id,\n ),\n );\n}\n\nasync function askForUsedBundlerTool(): Promise<SupportedTools> {\n const selectedTool = await abortIfCancelled(\n clack.select({\n message: 'Which framework, bundler or build tool are you using?',\n options: [\n {\n label: 'Angular',\n value: 'angular',\n hint: 'Select this option if you are using Angular.',\n },\n {\n label: 'Create React App',\n value: 'create-react-app',\n hint: 'Select this option if you set up your app with Create React App.',\n },\n {\n label: 'Webpack',\n value: 'webpack',\n hint: 'Select this if you are using Webpack and you have access to your Webpack config.',\n },\n {\n label: 'Vite',\n value: 'vite',\n hint: 'Select this if you are using Vite and you have access to your Vite config.',\n },\n {\n label: 'esbuild',\n value: 'esbuild',\n hint: 'Select this if you are using esbuild and you have access to your esbuild config.',\n },\n {\n label: 'Rollup',\n value: 'rollup',\n hint: 'Select this if you are using Rollup and you have access to your Rollup config.',\n },\n {\n label: 'tsc',\n value: 'tsc',\n hint: 'Configure source maps when using tsc as build tool',\n },\n {\n label: 'I use another tool',\n value: 'sentry-cli',\n hint: 'This will configure source maps upload for you using sentry-cli',\n },\n {\n label: \"I don't minify, transpile or bundle my code\",\n value: 'no-tool',\n hint: 'This will exit the wizard',\n },\n ],\n initialValue: await detectUsedTool(),\n }),\n );\n\n return selectedTool;\n}\n\nasync function startToolSetupFlow(\n selctedTool: SupportedTools,\n options: SourceMapUploadToolConfigurationOptions,\n): Promise<void> {\n switch (selctedTool) {\n case 'webpack':\n await configureWebPackPlugin(options);\n break;\n case 'vite':\n await configureVitePlugin(options);\n break;\n case 'esbuild':\n await configureEsbuildPlugin(options);\n break;\n case 'rollup':\n await configureRollupPlugin(options);\n break;\n case 'tsc':\n await configureSentryCLI(options, configureTscSourcemapGenerationFlow);\n break;\n case 'create-react-app':\n await configureSentryCLI(options, configureCRASourcemapGenerationFlow);\n break;\n case 'angular':\n await configureSentryCLI(\n options,\n configureAngularSourcemapGenerationFlow,\n );\n break;\n default:\n await configureSentryCLI(options);\n break;\n }\n}\nexport async function setupCI(\n selectedTool: SupportedTools,\n authToken: string,\n comingFrom: WizardOptions['comingFrom'],\n) {\n if (comingFrom === 'vercel') {\n clack.log.info(\n 'Sentry Vercel integration is already configured. Skipping CI setup.',\n );\n Sentry.setTag('using-ci', true);\n } else {\n await traceStep('configure-ci', () => configureCI(selectedTool, authToken));\n }\n}\n\nexport async function configureCI(\n selectedTool: SupportedTools,\n authToken: string,\n): Promise<void> {\n const isUsingCI = await abortIfCancelled(\n clack.select({\n message: `Are you using a CI/CD tool to build and deploy your application?`,\n options: [\n {\n label: 'Yes',\n hint: 'I use a tool like GitHub Actions, GitLab, CircleCI, TravisCI, Jenkins, Vercel, ...',\n value: true,\n },\n {\n label: 'No',\n hint: 'I build and deploy my application manually',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('using-ci', isUsingCI);\n\n const isCliBasedFlowTool = [\n 'sentry-cli',\n 'tsc',\n 'angular',\n 'create-react-app',\n ].includes(selectedTool);\n\n const authTokenFile = isCliBasedFlowTool\n ? SENTRY_CLI_RC_FILE\n : SENTRY_DOT_ENV_FILE;\n\n if (!isUsingCI) {\n clack.log.info(\n `No Problem! Just make sure that the Sentry auth token from ${chalk.cyan(\n authTokenFile,\n )} is available whenever you build and deploy your app.`,\n );\n return;\n }\n\n if (isCliBasedFlowTool) {\n await traceStep('ci-npm-script-setup', setupNpmScriptInCI);\n }\n\n await traceStep('ci-auth-token-setup', () => setupAuthTokenInCI(authToken));\n}\n\nasync function setupAuthTokenInCI(authToken: string) {\n clack.log.step(\n 'Add the Sentry authentication token as an environment variable to your CI setup:',\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\nSENTRY_AUTH_TOKEN=${authToken}\n`),\n );\n\n clack.log.warn(\n chalk.yellow('DO NOT commit this auth token to your repository!'),\n );\n\n const addedEnvVarToCI = await abortIfCancelled(\n clack.select({\n message: 'Did you configure CI as shown above?',\n options: [\n { label: 'Yes, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n 'You need to set the auth token to upload source maps in CI',\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('added-env-var-to-ci', addedEnvVarToCI);\n\n if (!addedEnvVarToCI) {\n clack.log.info(\"Don't forget! :)\");\n }\n}\n\nfunction printOutro(url: string, orgSlug: string, projectId: string) {\n const packageManager = detectPackageManger();\n const buildCommand = packageManager?.buildCommand ?? 'npm run build';\n\n const issueStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n const arrow = isUnicodeSupported() ? '→' : '->';\n\n clack.outro(`${chalk.green(\"That's it - everything is set up!\")}\n\n ${chalk.cyan(`Test and validate your setup locally with the following Steps:\n\n 1. Build your application in ${chalk.bold('production mode')}.\n ${chalk.gray(`${arrow} For example, run ${chalk.bold(buildCommand)}.`)}\n ${chalk.gray(\n `${arrow} You should see source map upload logs in your console.`,\n )}\n 2. Run your application and throw a test error.\n ${chalk.gray(`${arrow} The error should appear in Sentry:`)}\n ${chalk.gray(`${arrow} ${issueStreamUrl}`)}\n 3. Open the error in Sentry and verify that it's source-mapped.\n ${chalk.gray(\n `${arrow} The stack trace should show your original source code.`,\n )}\n `)}\n ${chalk.dim(\n `If you encounter any issues, please refer to the Troubleshooting Guide:\n https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js\n\n If the guide doesn't help or you encounter a bug, please let us know:\n https://github.com/getsentry/sentry-javascript/issues`,\n )}\n`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sourcemaps-wizard.js","sourceRoot":"","sources":["../../../src/sourcemaps/sourcemaps-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAE1B,4CAAwD;AACxD,0CASwB;AACxB,8DAA+C;AAE/C,sCAAiD;AACjD,+EAA0E;AAC1E,6CAA0E;AAC1E,+DAA+E;AAC/E,6CAAyD;AACzD,2CAAuD;AACvD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,GAAG,MAAM,IAAA,yBAAiB,EAAC,qBAAG,CAAC,CAAC;IAEpD,MAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,IAAA,yCAAkB,GAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhD,iBAAK,CAAC,KAAK,CAAC,GAAG,eAAK,CAAC,KAAK,CAAC,mCAAmC,CAAC;;KAE5D,eAAK,CAAC,IAAI,CAAC;;kCAEkB,eAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC;QACvD,eAAK,CAAC,IAAI,CACV,GAAG,KAAK,qBAAqB,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,CACxE;QACC,eAAK,CAAC,IAAI,CACV,GAAG,KAAK,yDAAyD,CAClE;;QAEC,eAAK,CAAC,IAAI,CAAC,GAAG,KAAK,qCAAqC,CAAC;QACzD,eAAK,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,cAAc,EAAE,CAAC;;QAExC,eAAK,CAAC,IAAI,CACV,GAAG,KAAK,yDAAyD,CAClE;IACH,CAAC;KACA,eAAK,CAAC,GAAG,CACT;;;;yDAIoD,CACrD;CACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n getPackageManager,\n printWelcome,\n SENTRY_CLI_RC_FILE,\n SENTRY_DOT_ENV_FILE,\n} from '../utils/clack';\nimport { NPM } from '../utils/package-manager';\nimport type { WizardOptions } from '../utils/types';\nimport { getIssueStreamUrl } from '../utils/url';\nimport { isUnicodeSupported } from '../utils/vendor/is-unicorn-supported';\nimport { configureAngularSourcemapGenerationFlow } from './tools/angular';\nimport { configureCRASourcemapGenerationFlow } from './tools/create-react-app';\nimport { configureEsbuildPlugin } from './tools/esbuild';\nimport { configureRollupPlugin } from './tools/rollup';\nimport { configureSentryCLI, setupNpmScriptInCI } from './tools/sentry-cli';\nimport { configureTscSourcemapGenerationFlow } from './tools/tsc';\nimport type { SourceMapUploadToolConfigurationOptions } from './tools/types';\nimport { configureVitePlugin } from './tools/vite';\nimport { configureWebPackPlugin } from './tools/webpack';\nimport type { SupportedTools } from './utils/detect-tool';\nimport { detectUsedTool } from './utils/detect-tool';\nimport { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';\nimport { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';\n\nexport async function runSourcemapsWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sourcemaps',\n wizardOptions: options,\n },\n () => runSourcemapsWizardWithTelemetry(options),\n );\n}\n\nasync function runSourcemapsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Source Maps Upload Configuration Wizard',\n message: `This wizard will help you upload source maps to Sentry as part of your build.\nThank you for using Sentry :)${\n options.telemetryEnabled\n ? `\n\n(This setup wizard sends telemetry data and crash reports to Sentry.\nYou can turn this off by running the wizard with the '--disable-telemetry' flag.)`\n : ''\n }`,\n promoCode: options.promoCode,\n });\n\n const moreSuitableWizard = await traceStep(\n 'check-framework-wizard',\n checkIfMoreSuitableWizardExistsAndAskForRedirect,\n );\n if (moreSuitableWizard) {\n await traceStep('run-framework-wizard', () => moreSuitableWizard(options));\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);\n\n const { selfHosted, selectedProject, sentryUrl, authToken } =\n await getOrAskForProjectData(options);\n\n const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);\n\n Sentry.setTag('selected-tool', selectedTool);\n\n if (selectedTool === 'no-tool') {\n clack.log.info(\n \"No Problem! But in this case, there's nothing to configure :)\",\n );\n await abort('Exiting, have a great day!', 0);\n return;\n }\n\n await traceStep('tool-setup', () =>\n startToolSetupFlow(selectedTool, {\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n authToken,\n }),\n );\n\n await traceStep('ci-setup', () =>\n setupCI(selectedTool, authToken, options.comingFrom),\n );\n\n await traceStep('outro', () =>\n printOutro(\n sentryUrl,\n selectedProject.organization.slug,\n selectedProject.id,\n ),\n );\n}\n\nasync function askForUsedBundlerTool(): Promise<SupportedTools> {\n const selectedTool = await abortIfCancelled(\n clack.select({\n message: 'Which framework, bundler or build tool are you using?',\n options: [\n {\n label: 'Angular',\n value: 'angular',\n hint: 'Select this option if you are using Angular.',\n },\n {\n label: 'Create React App',\n value: 'create-react-app',\n hint: 'Select this option if you set up your app with Create React App.',\n },\n {\n label: 'Webpack',\n value: 'webpack',\n hint: 'Select this if you are using Webpack and you have access to your Webpack config.',\n },\n {\n label: 'Vite',\n value: 'vite',\n hint: 'Select this if you are using Vite and you have access to your Vite config.',\n },\n {\n label: 'esbuild',\n value: 'esbuild',\n hint: 'Select this if you are using esbuild and you have access to your esbuild config.',\n },\n {\n label: 'Rollup',\n value: 'rollup',\n hint: 'Select this if you are using Rollup and you have access to your Rollup config.',\n },\n {\n label: 'tsc',\n value: 'tsc',\n hint: 'Configure source maps when using tsc as build tool',\n },\n {\n label: 'I use another tool',\n value: 'sentry-cli',\n hint: 'This will configure source maps upload for you using sentry-cli',\n },\n {\n label: \"I don't minify, transpile or bundle my code\",\n value: 'no-tool',\n hint: 'This will exit the wizard',\n },\n ],\n initialValue: await detectUsedTool(),\n }),\n );\n\n return selectedTool;\n}\n\nasync function startToolSetupFlow(\n selctedTool: SupportedTools,\n options: SourceMapUploadToolConfigurationOptions,\n): Promise<void> {\n switch (selctedTool) {\n case 'webpack':\n await configureWebPackPlugin(options);\n break;\n case 'vite':\n await configureVitePlugin(options);\n break;\n case 'esbuild':\n await configureEsbuildPlugin(options);\n break;\n case 'rollup':\n await configureRollupPlugin(options);\n break;\n case 'tsc':\n await configureSentryCLI(options, configureTscSourcemapGenerationFlow);\n break;\n case 'create-react-app':\n await configureSentryCLI(options, configureCRASourcemapGenerationFlow);\n break;\n case 'angular':\n await configureSentryCLI(\n options,\n configureAngularSourcemapGenerationFlow,\n );\n break;\n default:\n await configureSentryCLI(options);\n break;\n }\n}\nexport async function setupCI(\n selectedTool: SupportedTools,\n authToken: string,\n comingFrom: WizardOptions['comingFrom'],\n) {\n if (comingFrom === 'vercel') {\n clack.log.info(\n 'Sentry Vercel integration is already configured. Skipping CI setup.',\n );\n Sentry.setTag('using-ci', true);\n } else {\n await traceStep('configure-ci', () => configureCI(selectedTool, authToken));\n }\n}\n\nexport async function configureCI(\n selectedTool: SupportedTools,\n authToken: string,\n): Promise<void> {\n const isUsingCI = await abortIfCancelled(\n clack.select({\n message: `Are you using a CI/CD tool to build and deploy your application?`,\n options: [\n {\n label: 'Yes',\n hint: 'I use a tool like GitHub Actions, GitLab, CircleCI, TravisCI, Jenkins, Vercel, ...',\n value: true,\n },\n {\n label: 'No',\n hint: 'I build and deploy my application manually',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('using-ci', isUsingCI);\n\n const isCliBasedFlowTool = [\n 'sentry-cli',\n 'tsc',\n 'angular',\n 'create-react-app',\n ].includes(selectedTool);\n\n const authTokenFile = isCliBasedFlowTool\n ? SENTRY_CLI_RC_FILE\n : SENTRY_DOT_ENV_FILE;\n\n if (!isUsingCI) {\n clack.log.info(\n `No Problem! Just make sure that the Sentry auth token from ${chalk.cyan(\n authTokenFile,\n )} is available whenever you build and deploy your app.`,\n );\n return;\n }\n\n if (isCliBasedFlowTool) {\n await traceStep('ci-npm-script-setup', setupNpmScriptInCI);\n }\n\n await traceStep('ci-auth-token-setup', () => setupAuthTokenInCI(authToken));\n}\n\nasync function setupAuthTokenInCI(authToken: string) {\n clack.log.step(\n 'Add the Sentry authentication token as an environment variable to your CI setup:',\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\nSENTRY_AUTH_TOKEN=${authToken}\n`),\n );\n\n clack.log.warn(\n chalk.yellow('DO NOT commit this auth token to your repository!'),\n );\n\n const addedEnvVarToCI = await abortIfCancelled(\n clack.select({\n message: 'Did you configure CI as shown above?',\n options: [\n { label: 'Yes, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n 'You need to set the auth token to upload source maps in CI',\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('added-env-var-to-ci', addedEnvVarToCI);\n\n if (!addedEnvVarToCI) {\n clack.log.info(\"Don't forget! :)\");\n }\n}\n\nasync function printOutro(\n url: string,\n orgSlug: string,\n projectId: string,\n): Promise<void> {\n const packageManager = await getPackageManager(NPM);\n\n const issueStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n const arrow = isUnicodeSupported() ? '→' : '->';\n\n clack.outro(`${chalk.green(\"That's it - everything is set up!\")}\n\n ${chalk.cyan(`Test and validate your setup locally with the following Steps:\n\n 1. Build your application in ${chalk.bold('production mode')}.\n ${chalk.gray(\n `${arrow} For example, run ${chalk.bold(packageManager.buildCommand)}.`,\n )}\n ${chalk.gray(\n `${arrow} You should see source map upload logs in your console.`,\n )}\n 2. Run your application and throw a test error.\n ${chalk.gray(`${arrow} The error should appear in Sentry:`)}\n ${chalk.gray(`${arrow} ${issueStreamUrl}`)}\n 3. Open the error in Sentry and verify that it's source-mapped.\n ${chalk.gray(\n `${arrow} The stack trace should show your original source code.`,\n )}\n `)}\n ${chalk.dim(\n `If you encounter any issues, please refer to the Troubleshooting Guide:\n https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js\n\n If the guide doesn't help or you encounter a bug, please let us know:\n https://github.com/getsentry/sentry-javascript/issues`,\n )}\n`);\n}\n"]}
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.configureAngularSourcemapGenerationFlow = void 0;
|
|
7
|
-
// @ts-
|
|
7
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
8
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const
|
|
10
|
+
const clack_1 = require("../../utils/clack");
|
|
11
11
|
const angularJsonTemplate = chalk_1.default.gray(`{
|
|
12
12
|
"projects": {
|
|
13
13
|
"your-project": {
|
|
@@ -26,7 +26,7 @@ async function configureAngularSourcemapGenerationFlow() {
|
|
|
26
26
|
// Intentially logging directly to console here so that the code can be copied/pasted directly
|
|
27
27
|
// eslint-disable-next-line no-console
|
|
28
28
|
console.log(angularJsonTemplate);
|
|
29
|
-
await (0,
|
|
29
|
+
await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
30
30
|
message: `Verify that you are generating source maps when building your Angular app.`,
|
|
31
31
|
options: [
|
|
32
32
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/angular.ts"],"names":[],"mappings":";;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"angular.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/angular.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,6CAAqD;AAErD,MAAM,mBAAmB,GAAG,eAAK,CAAC,IAAI,CAAC;;;;;;cAMzB,eAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC;;;;;;EAMlD,CAAC,CAAC;AAEG,KAAK,UAAU,uCAAuC;IAC3D,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yCAAyC,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAC5E,CAAC;IAEF,8FAA8F;IAC9F,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEjC,MAAM,IAAA,wBAAgB,EACpB,iBAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,4EAA4E;QACrF,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,YAAY;gBACnB,IAAI,EAAE,8DAA8D;gBACpE,KAAK,EAAE,IAAI;aACZ;SACF;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;AACJ,CAAC;AAtBD,0FAsBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { abortIfCancelled } from '../../utils/clack';\n\nconst angularJsonTemplate = chalk.gray(`{\n \"projects\": {\n \"your-project\": {\n \"architect\": {\n \"build\": {\n \"options\": {\n ${chalk.greenBright(`\"sourceMap\": true`)}\n },\n },\n }\n }\n }\n}`);\n\nexport async function configureAngularSourcemapGenerationFlow(): Promise<void> {\n clack.log.info(\n `Enable generating source maps in your ${chalk.bold('angular.json')} file:`,\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(angularJsonTemplate);\n\n await abortIfCancelled(\n clack.select({\n message: `Verify that you are generating source maps when building your Angular app.`,\n options: [\n {\n label: 'I checked!',\n hint: 'My build output folder contains .js.map files after a build.',\n value: true,\n },\n ],\n initialValue: true,\n }),\n );\n}\n"]}
|
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.configureCRASourcemapGenerationFlow = void 0;
|
|
7
|
-
// @ts-
|
|
7
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
8
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
|
-
const
|
|
9
|
+
const clack_1 = require("../../utils/clack");
|
|
10
10
|
async function configureCRASourcemapGenerationFlow() {
|
|
11
|
-
await (0,
|
|
11
|
+
await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
12
12
|
message: `Verify that you are generating source maps when building your React app.\nGenerally this should already happen unless you set the GENERATE_SOURCEMAPS environment variable to false.`,
|
|
13
13
|
options: [
|
|
14
14
|
{
|