@sentry/wizard 3.7.1 → 3.8.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 +11 -0
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +12 -26
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.js +2 -2
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +5 -6
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
- package/dist/package.json +3 -3
- package/dist/src/apple/apple-wizard.js +31 -2
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/cocoapod.d.ts +2 -0
- package/dist/src/apple/cocoapod.js +122 -0
- package/dist/src/apple/cocoapod.js.map +1 -0
- package/dist/src/apple/code-tools.js +22 -12
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/fastlane.d.ts +2 -0
- package/dist/src/apple/fastlane.js +179 -0
- package/dist/src/apple/fastlane.js.map +1 -0
- package/dist/src/apple/templates.d.ts +1 -0
- package/dist/src/apple/templates.js +7 -3
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +1 -1
- package/dist/src/apple/xcode-manager.js +35 -28
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +71 -81
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +61 -46
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.d.ts +3 -0
- package/dist/src/sourcemaps/tools/nextjs.js +135 -0
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -0
- package/dist/src/sourcemaps/tools/sentry-cli.js +120 -16
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +1 -0
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +35 -12
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sveltekit/sentry-cli-setup.d.ts +1 -1
- package/dist/src/sveltekit/sentry-cli-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +14 -8
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/bash.d.ts +2 -1
- package/dist/src/utils/bash.js +14 -2
- package/dist/src/utils/bash.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +7 -14
- package/dist/src/utils/clack-utils.js +46 -2
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-json.d.ts +1 -1
- package/dist/src/utils/package-json.js.map +1 -1
- package/dist/src/utils/types.d.ts +24 -0
- package/dist/src/utils/types.js.map +1 -1
- package/lib/Helper/__tests__/MergeConfig.ts +9 -4
- package/lib/Steps/ChooseIntegration.ts +13 -3
- package/lib/Steps/Integrations/Cordova.ts +3 -3
- package/lib/Steps/Integrations/Electron.ts +1 -2
- package/lib/Steps/Integrations/MobileProject.ts +1 -1
- package/lib/Steps/Integrations/ReactNative.ts +16 -14
- package/lib/Steps/Integrations/__tests__/ReactNative.ts +24 -15
- package/package-lock.json +2 -2
- package/package.json +3 -3
- package/src/apple/apple-wizard.ts +35 -3
- package/src/apple/cocoapod.ts +57 -0
- package/src/apple/code-tools.ts +80 -57
- package/src/apple/fastlane.ts +160 -0
- package/src/apple/templates.ts +26 -10
- package/src/apple/xcode-manager.ts +137 -120
- package/src/nextjs/nextjs-wizard.ts +4 -13
- package/src/sourcemaps/sourcemaps-wizard.ts +40 -28
- package/src/sourcemaps/tools/nextjs.ts +114 -0
- package/src/sourcemaps/tools/sentry-cli.ts +134 -8
- package/src/sourcemaps/utils/detect-tool.ts +3 -1
- package/src/sourcemaps/utils/other-wizards.ts +32 -13
- package/src/sveltekit/sentry-cli-setup.ts +1 -1
- package/src/sveltekit/sveltekit-wizard.ts +3 -0
- package/src/utils/bash.ts +43 -30
- package/src/utils/clack-utils.ts +42 -14
- package/src/utils/package-json.ts +1 -1
- package/src/utils/types.ts +22 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -82,6 +93,7 @@ var url_1 = require("url");
|
|
|
82
93
|
var other_wizards_1 = require("./utils/other-wizards");
|
|
83
94
|
var angular_1 = require("./tools/angular");
|
|
84
95
|
var detect_tool_1 = require("./utils/detect-tool");
|
|
96
|
+
var nextjs_1 = require("./tools/nextjs");
|
|
85
97
|
function runSourcemapsWizard(options) {
|
|
86
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
87
99
|
return __generator(this, function (_a) {
|
|
@@ -95,9 +107,9 @@ function runSourcemapsWizard(options) {
|
|
|
95
107
|
exports.runSourcemapsWizard = runSourcemapsWizard;
|
|
96
108
|
function runSourcemapsWizardWithTelemetry(options) {
|
|
97
109
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
var moreSuitableWizard, _a,
|
|
99
|
-
return __generator(this, function (
|
|
100
|
-
switch (
|
|
110
|
+
var moreSuitableWizard, _a, selfHosted, selectedProject, sentryUrl, authToken, wizardOptionsWithPreSelectedProject, selectedTool;
|
|
111
|
+
return __generator(this, function (_b) {
|
|
112
|
+
switch (_b.label) {
|
|
101
113
|
case 0:
|
|
102
114
|
(0, clack_utils_1.printWelcome)({
|
|
103
115
|
wizardName: 'Sentry Source Maps Upload Configuration Wizard',
|
|
@@ -108,52 +120,44 @@ function runSourcemapsWizardWithTelemetry(options) {
|
|
|
108
120
|
});
|
|
109
121
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('check-framework-wizard', other_wizards_1.checkIfMoreSuitableWizardExistsAndAskForRedirect)];
|
|
110
122
|
case 1:
|
|
111
|
-
moreSuitableWizard =
|
|
123
|
+
moreSuitableWizard = _b.sent();
|
|
112
124
|
if (!moreSuitableWizard) return [3 /*break*/, 3];
|
|
113
125
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('run-framework-wizard', function () { return moreSuitableWizard(options); })];
|
|
114
126
|
case 2:
|
|
115
|
-
|
|
127
|
+
_b.sent();
|
|
116
128
|
return [2 /*return*/];
|
|
117
129
|
case 3: return [4 /*yield*/, (0, telemetry_1.traceStep)('detect-git', clack_utils_1.confirmContinueEvenThoughNoGitRepo)];
|
|
118
130
|
case 4:
|
|
119
|
-
|
|
131
|
+
_b.sent();
|
|
120
132
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('check-sdk-version', sdk_version_1.ensureMinimumSdkVersionIsInstalled)];
|
|
121
133
|
case 5:
|
|
122
|
-
|
|
123
|
-
return [4 /*yield*/, (0,
|
|
134
|
+
_b.sent();
|
|
135
|
+
return [4 /*yield*/, (0, clack_utils_1.getOrAskForProjectData)(options)];
|
|
124
136
|
case 6:
|
|
125
|
-
_a =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
})];
|
|
132
|
-
case 7:
|
|
133
|
-
_b = _c.sent(), projects = _b.projects, apiKeys = _b.apiKeys;
|
|
134
|
-
return [4 /*yield*/, (0, telemetry_1.traceStep)('select-project', function () {
|
|
135
|
-
return (0, clack_utils_1.askForProjectSelection)(projects);
|
|
136
|
-
})];
|
|
137
|
-
case 8:
|
|
138
|
-
selectedProject = _c.sent();
|
|
137
|
+
_a = _b.sent(), selfHosted = _a.selfHosted, selectedProject = _a.selectedProject, sentryUrl = _a.sentryUrl, authToken = _a.authToken;
|
|
138
|
+
wizardOptionsWithPreSelectedProject = __assign(__assign({}, options), { preSelectedProject: {
|
|
139
|
+
project: selectedProject,
|
|
140
|
+
authToken: authToken,
|
|
141
|
+
selfHosted: selfHosted,
|
|
142
|
+
} });
|
|
139
143
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('select-tool', askForUsedBundlerTool)];
|
|
140
|
-
case
|
|
141
|
-
selectedTool =
|
|
144
|
+
case 7:
|
|
145
|
+
selectedTool = _b.sent();
|
|
142
146
|
Sentry.setTag('selected-tool', selectedTool);
|
|
143
147
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('tool-setup', function () {
|
|
144
148
|
return startToolSetupFlow(selectedTool, {
|
|
145
|
-
selfHosted: selfHosted,
|
|
146
149
|
orgSlug: selectedProject.organization.slug,
|
|
147
150
|
projectSlug: selectedProject.slug,
|
|
151
|
+
selfHosted: selfHosted,
|
|
148
152
|
url: sentryUrl,
|
|
149
|
-
authToken:
|
|
150
|
-
});
|
|
153
|
+
authToken: authToken,
|
|
154
|
+
}, wizardOptionsWithPreSelectedProject);
|
|
151
155
|
})];
|
|
152
|
-
case
|
|
153
|
-
|
|
154
|
-
return [4 /*yield*/, (0, telemetry_1.traceStep)('ci-setup', function () { return configureCI(selectedTool,
|
|
155
|
-
case
|
|
156
|
-
|
|
156
|
+
case 8:
|
|
157
|
+
_b.sent();
|
|
158
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('ci-setup', function () { return configureCI(selectedTool, authToken); })];
|
|
159
|
+
case 9:
|
|
160
|
+
_b.sent();
|
|
157
161
|
(0, telemetry_1.traceStep)('outro', function () {
|
|
158
162
|
return printOutro(sentryUrl, selectedProject.organization.slug, selectedProject.id);
|
|
159
163
|
});
|
|
@@ -184,6 +188,11 @@ function askForUsedBundlerTool() {
|
|
|
184
188
|
value: 'create-react-app',
|
|
185
189
|
hint: 'Select this option if you set up your app with Create React App.',
|
|
186
190
|
},
|
|
191
|
+
{
|
|
192
|
+
label: 'Next.js',
|
|
193
|
+
value: 'nextjs',
|
|
194
|
+
hint: 'Select this option if you want to set up source maps in a NextJS project.',
|
|
195
|
+
},
|
|
187
196
|
{
|
|
188
197
|
label: 'Webpack',
|
|
189
198
|
value: 'webpack',
|
|
@@ -226,7 +235,7 @@ function askForUsedBundlerTool() {
|
|
|
226
235
|
});
|
|
227
236
|
});
|
|
228
237
|
}
|
|
229
|
-
function startToolSetupFlow(selctedTool, options) {
|
|
238
|
+
function startToolSetupFlow(selctedTool, options, wizardOptions) {
|
|
230
239
|
return __awaiter(this, void 0, void 0, function () {
|
|
231
240
|
var _a;
|
|
232
241
|
return __generator(this, function (_b) {
|
|
@@ -241,48 +250,53 @@ function startToolSetupFlow(selctedTool, options) {
|
|
|
241
250
|
case 'tsc': return [3 /*break*/, 9];
|
|
242
251
|
case 'create-react-app': return [3 /*break*/, 11];
|
|
243
252
|
case 'angular': return [3 /*break*/, 13];
|
|
253
|
+
case 'nextjs': return [3 /*break*/, 15];
|
|
244
254
|
}
|
|
245
|
-
return [3 /*break*/,
|
|
255
|
+
return [3 /*break*/, 17];
|
|
246
256
|
case 1: return [4 /*yield*/, (0, webpack_1.configureWebPackPlugin)(options)];
|
|
247
257
|
case 2:
|
|
248
258
|
_b.sent();
|
|
249
|
-
return [3 /*break*/,
|
|
259
|
+
return [3 /*break*/, 19];
|
|
250
260
|
case 3: return [4 /*yield*/, (0, vite_1.configureVitePlugin)(options)];
|
|
251
261
|
case 4:
|
|
252
262
|
_b.sent();
|
|
253
|
-
return [3 /*break*/,
|
|
263
|
+
return [3 /*break*/, 19];
|
|
254
264
|
case 5: return [4 /*yield*/, (0, esbuild_1.configureEsbuildPlugin)(options)];
|
|
255
265
|
case 6:
|
|
256
266
|
_b.sent();
|
|
257
|
-
return [3 /*break*/,
|
|
267
|
+
return [3 /*break*/, 19];
|
|
258
268
|
case 7: return [4 /*yield*/, (0, rollup_1.configureRollupPlugin)(options)];
|
|
259
269
|
case 8:
|
|
260
270
|
_b.sent();
|
|
261
|
-
return [3 /*break*/,
|
|
271
|
+
return [3 /*break*/, 19];
|
|
262
272
|
case 9: return [4 /*yield*/, (0, sentry_cli_1.configureSentryCLI)(options, tsc_1.configureTscSourcemapGenerationFlow)];
|
|
263
273
|
case 10:
|
|
264
274
|
_b.sent();
|
|
265
|
-
return [3 /*break*/,
|
|
275
|
+
return [3 /*break*/, 19];
|
|
266
276
|
case 11: return [4 /*yield*/, (0, sentry_cli_1.configureSentryCLI)(options, create_react_app_1.configureCRASourcemapGenerationFlow)];
|
|
267
277
|
case 12:
|
|
268
278
|
_b.sent();
|
|
269
|
-
return [3 /*break*/,
|
|
279
|
+
return [3 /*break*/, 19];
|
|
270
280
|
case 13: return [4 /*yield*/, (0, sentry_cli_1.configureSentryCLI)(options, angular_1.configureAngularSourcemapGenerationFlow)];
|
|
271
281
|
case 14:
|
|
272
282
|
_b.sent();
|
|
273
|
-
return [3 /*break*/,
|
|
274
|
-
case 15: return [4 /*yield*/, (0,
|
|
283
|
+
return [3 /*break*/, 19];
|
|
284
|
+
case 15: return [4 /*yield*/, (0, nextjs_1.configureNextJsSourceMapsUpload)(options, wizardOptions)];
|
|
275
285
|
case 16:
|
|
276
286
|
_b.sent();
|
|
277
|
-
return [3 /*break*/,
|
|
278
|
-
case 17: return [
|
|
287
|
+
return [3 /*break*/, 19];
|
|
288
|
+
case 17: return [4 /*yield*/, (0, sentry_cli_1.configureSentryCLI)(options)];
|
|
289
|
+
case 18:
|
|
290
|
+
_b.sent();
|
|
291
|
+
return [3 /*break*/, 19];
|
|
292
|
+
case 19: return [2 /*return*/];
|
|
279
293
|
}
|
|
280
294
|
});
|
|
281
295
|
});
|
|
282
296
|
}
|
|
283
297
|
function configureCI(selectedTool, authToken) {
|
|
284
298
|
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var isUsingCI, isCliBasedFlowTool, authTokenFile;
|
|
299
|
+
var isUsingCI, isCliBasedFlowTool, usesSentryCliRc, authTokenFile;
|
|
286
300
|
return __generator(this, function (_a) {
|
|
287
301
|
switch (_a.label) {
|
|
288
302
|
case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
@@ -310,7 +324,8 @@ function configureCI(selectedTool, authToken) {
|
|
|
310
324
|
'angular',
|
|
311
325
|
'create-react-app',
|
|
312
326
|
].includes(selectedTool);
|
|
313
|
-
|
|
327
|
+
usesSentryCliRc = selectedTool === 'nextjs';
|
|
328
|
+
authTokenFile = isCliBasedFlowTool || usesSentryCliRc
|
|
314
329
|
? clack_utils_1.SENTRY_CLI_RC_FILE
|
|
315
330
|
: clack_utils_1.SENTRY_DOT_ENV_FILE;
|
|
316
331
|
if (!isUsingCI) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourcemaps-wizard.js","sourceRoot":"","sources":["../../../src/sourcemaps/sourcemaps-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,mDAAuC;AAEvC,oDAU8B;AAC9B,6EAA0E;AAE1E,qCAAmD;AACnD,iDAA4E;AAC5E,2CAAyD;AACzD,mCAAkE;AAClE,yCAAuD;AACvD,2CAAyD;AAEzD,6DAA+E;AAC/E,mDAAyE;AACzE,0CAA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AAqB,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAG,CAAC,qBACpE,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,yEAEC,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,wCAAqC,CAAC,qBACzD,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,cAAI,cAAc,CAAE,CAAC,yFAExC,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,UACH,CAAC,kBACA,eAAK,CAAC,GAAG,CACT,6RAIoD,CACrD,OACH,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 abortIfCancelled,\n askForProjectSelection,\n askForSelfHosted,\n askForWizardLogin,\n confirmContinueEvenThoughNoGitRepo,\n detectPackageManager,\n SENTRY_DOT_ENV_FILE,\n printWelcome,\n SENTRY_CLI_RC_FILE,\n} from '../utils/clack-utils';\nimport { isUnicodeSupported } from '../utils/vendor/is-unicorn-supported';\nimport { 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 { WizardOptions } from '../utils/types';\nimport { configureCRASourcemapGenerationFlow } from './tools/create-react-app';\nimport { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { URL } from 'url';\nimport { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';\nimport { configureAngularSourcemapGenerationFlow } from './tools/angular';\nimport { detectUsedTool, SupportedTools } from './utils/detect-tool';\n\nexport async function runSourcemapsWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sourcemaps',\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 traceStep('detect-git', confirmContinueEvenThoughNoGitRepo);\n\n await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);\n\n const { url: sentryUrl, selfHosted } = await traceStep(\n 'ask-self-hosted',\n () => askForSelfHosted(options.url),\n );\n\n const { projects, apiKeys } = await traceStep('login', () =>\n askForWizardLogin({\n promoCode: options.promoCode,\n url: sentryUrl,\n }),\n );\n\n const selectedProject = await traceStep('select-project', () =>\n askForProjectSelection(projects),\n );\n\n const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);\n\n Sentry.setTag('selected-tool', selectedTool);\n\n await traceStep('tool-setup', () =>\n startToolSetupFlow(selectedTool, {\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n authToken: apiKeys.token,\n }),\n );\n\n await traceStep('ci-setup', () => configureCI(selectedTool, apiKeys.token));\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: SupportedTools | symbol = 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: 'None of the above',\n value: 'sentry-cli',\n hint: 'This will configure source maps upload for you using sentry-cli',\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}\n\nasync 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, ...',\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 pacMan = detectPackageManager() || 'npm';\n const buildCommand = `'${pacMan}${pacMan === 'npm' ? ' run' : ''} build'`;\n\n const urlObject = new URL(url);\n urlObject.host = `${orgSlug}.${urlObject.host}`;\n urlObject.pathname = '/issues/';\n urlObject.searchParams.set('project', projectId);\n\n const issueStreamUrl = urlObject.toString();\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,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,mDAAuC;AAEvC,oDAQ8B;AAC9B,6EAA0E;AAE1E,qCAAmD;AACnD,iDAA4E;AAC5E,2CAAyD;AACzD,mCAAkE;AAClE,yCAAuD;AACvD,2CAAyD;AAEzD,6DAA+E;AAC/E,mDAAyE;AACzE,0CAAwD;AACxD,2BAA0B;AAC1B,uDAAyF;AACzF,2CAA0E;AAC1E,mDAAqE;AACrE,yCAAiE;AAEjE,SAAsB,mBAAmB,CACvC,OAAsB;;;YAEtB,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,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zD,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,cAAI,cAAc,CAAE,CAAC,yFAExC,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,UACH,CAAC,kBACA,eAAK,CAAC,GAAG,CACT,6RAIoD,CACrD,OACH,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 abortIfCancelled,\n confirmContinueEvenThoughNoGitRepo,\n detectPackageManager,\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 { 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 { WizardOptions } from '../utils/types';\nimport { configureCRASourcemapGenerationFlow } from './tools/create-react-app';\nimport { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { URL } from 'url';\nimport { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';\nimport { configureAngularSourcemapGenerationFlow } from './tools/angular';\nimport { detectUsedTool, SupportedTools } from './utils/detect-tool';\nimport { configureNextJsSourceMapsUpload } from './tools/nextjs';\n\nexport async function runSourcemapsWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sourcemaps',\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 traceStep('detect-git', confirmContinueEvenThoughNoGitRepo);\n\n await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);\n\n const { selfHosted, selectedProject, sentryUrl, authToken } =\n await getOrAskForProjectData(options);\n\n const wizardOptionsWithPreSelectedProject = {\n ...options,\n preSelectedProject: {\n project: selectedProject,\n authToken,\n selfHosted,\n },\n };\n\n const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);\n\n Sentry.setTag('selected-tool', selectedTool);\n\n await traceStep('tool-setup', () =>\n startToolSetupFlow(\n selectedTool,\n {\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n authToken,\n },\n wizardOptionsWithPreSelectedProject,\n ),\n );\n\n await traceStep('ci-setup', () => configureCI(selectedTool, authToken));\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: SupportedTools | symbol = 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: 'Next.js',\n value: 'nextjs',\n hint: 'Select this option if you want to set up source maps in a NextJS project.',\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: 'None of the above',\n value: 'sentry-cli',\n hint: 'This will configure source maps upload for you using sentry-cli',\n },\n ],\n initialValue: await detectUsedTool(),\n }),\n );\n\n return selectedTool;\n}\n\nasync function startToolSetupFlow(\n selctedTool: SupportedTools,\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\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 case 'nextjs':\n await configureNextJsSourceMapsUpload(options, wizardOptions);\n break;\n default:\n await configureSentryCLI(options);\n break;\n }\n}\n\nasync 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, ...',\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 // some non-cli-based flows also use the .sentryclirc file\n const usesSentryCliRc = selectedTool === 'nextjs';\n\n const authTokenFile =\n isCliBasedFlowTool || usesSentryCliRc\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 pacMan = detectPackageManager() || 'npm';\n const buildCommand = `'${pacMan}${pacMan === 'npm' ? ' run' : ''} build'`;\n\n const urlObject = new URL(url);\n urlObject.host = `${orgSlug}.${urlObject.host}`;\n urlObject.pathname = '/issues/';\n urlObject.searchParams.set('project', projectId);\n\n const issueStreamUrl = urlObject.toString();\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"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.configureNextJsSourceMapsUpload = void 0;
|
|
66
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
67
|
+
var clack = __importStar(require("@clack/prompts"));
|
|
68
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
69
|
+
var nextjs_wizard_1 = require("../../nextjs/nextjs-wizard");
|
|
70
|
+
var telemetry_1 = require("../../telemetry");
|
|
71
|
+
var clack_utils_1 = require("../../utils/clack-utils");
|
|
72
|
+
var Sentry = __importStar(require("@sentry/node"));
|
|
73
|
+
var getCodeSnippet = function (options) {
|
|
74
|
+
return chalk_1.default.grey("\n ".concat(chalk_1.default.greenBright('const { withSentryConfig } = require("@sentry/nextjs");'), "\n\n const nextConfig = {\n // your existing next config\n };\n \n ").concat(chalk_1.default.greenBright("const sentryWebpackPluginOptions = {\n org: \"".concat(options.orgSlug, "\",\n project: \"").concat(options.projectSlug, "\",").concat(options.selfHosted ? "\n url: \"".concat(options.url, "\",") : '', "\n };")), "\n \n ").concat(chalk_1.default.greenBright("const sentryOptions = {\n // Upload additional client files (increases upload size)\n widenClientFileUpload: true,\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n };"), "\n \n ").concat(chalk_1.default.greenBright("module.exports = withSentryConfig(\n nextConfig,\n sentryWebpackPluginOptions,\n sentryOptions\n );"), " \n"));
|
|
75
|
+
};
|
|
76
|
+
var configureNextJsSourceMapsUpload = function (options, wizardOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
var shouldRedirect;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
clack.log
|
|
82
|
+
.info("Source Maps upload for Next.js is configured automatically by default if you run the Sentry Wizard for Next.JS.\nBut don't worry, we can redirect you to the wizard now!\n\nIn case you already tried the wizard, we can also show you how to configure your ".concat(chalk_1.default.cyan('next.config.js'), " file manually instead."));
|
|
83
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
|
|
84
|
+
message: 'Do you want to run the Sentry Wizard for Next.JS now?',
|
|
85
|
+
options: [
|
|
86
|
+
{
|
|
87
|
+
label: 'Yes, run the wizard!',
|
|
88
|
+
value: true,
|
|
89
|
+
hint: 'The wizard can also configure your SDK setup',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: 'No, show me how to configure it manually',
|
|
93
|
+
value: false,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
}))];
|
|
97
|
+
case 1:
|
|
98
|
+
shouldRedirect = _a.sent();
|
|
99
|
+
Sentry.setTag('redirect-nextjs-wizard', shouldRedirect);
|
|
100
|
+
if (!shouldRedirect) return [3 /*break*/, 3];
|
|
101
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('run-nextjs-wizard', function () { return (0, nextjs_wizard_1.runNextjsWizard)(wizardOptions); })];
|
|
102
|
+
case 2:
|
|
103
|
+
_a.sent();
|
|
104
|
+
clack.intro('Sentry Source Maps Upload Configuration Wizard');
|
|
105
|
+
clack.log.info("Welcome back to the Source Maps wizard - we're almost done ;)");
|
|
106
|
+
return [3 /*break*/, 6];
|
|
107
|
+
case 3:
|
|
108
|
+
clack.log.info("Add the following code to your ".concat(chalk_1.default.cyan('next.config.js'), ":"));
|
|
109
|
+
// Intentionally logging directly to console here
|
|
110
|
+
// eslint-disable-next-line no-console
|
|
111
|
+
console.log(getCodeSnippet(options));
|
|
112
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('nextjs-manual-nextconfigjs', function () {
|
|
113
|
+
return (0, clack_utils_1.abortIfCancelled)(clack.select({
|
|
114
|
+
message: 'Did you copy the code above?',
|
|
115
|
+
options: [{ label: 'Yes, continue!', value: true }],
|
|
116
|
+
initialValue: true,
|
|
117
|
+
}));
|
|
118
|
+
})];
|
|
119
|
+
case 4:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('nextjs-manual-sentryclirc', function () {
|
|
122
|
+
return (0, clack_utils_1.addSentryCliRc)(options.authToken);
|
|
123
|
+
})];
|
|
124
|
+
case 5:
|
|
125
|
+
_a.sent();
|
|
126
|
+
_a.label = 6;
|
|
127
|
+
case 6:
|
|
128
|
+
clack.log
|
|
129
|
+
.info("In case you still run into problems, check out our docs to further debug your setup:\n\nUploading Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-source-maps\n \nTroubleshooting Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/");
|
|
130
|
+
return [2 /*return*/];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}); };
|
|
134
|
+
exports.configureNextJsSourceMapsUpload = configureNextJsSourceMapsUpload;
|
|
135
|
+
//# sourceMappingURL=nextjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextjs.js","sourceRoot":"","sources":["../../../../src/sourcemaps/tools/nextjs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAC1B,4DAA6D;AAC7D,6CAA4C;AAC5C,uDAA2E;AAK3E,mDAAuC;AAEvC,IAAM,cAAc,GAAG,UAAC,OAAgD;IACtE,OAAA,eAAK,CAAC,IAAI,CAAC,cACT,eAAK,CAAC,WAAW,CACjB,yDAAyD,CAC1D,uFAMC,eAAK,CAAC,WAAW,CAAC,2DACV,OAAO,CAAC,OAAO,iCACX,OAAO,CAAC,WAAW,gBAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,uBAAe,OAAO,CAAC,GAAG,QAAI,CAAC,CAAC,CAAC,EAAE,WAEvD,CAAC,qBAEF,eAAK,CAAC,WAAW,CAAC,qNAMjB,CAAC,qBAEF,eAAK,CAAC,WAAW,CAAC,+GAIjB,CAAC,SACL,CAAC;AA7BA,CA6BA,CAAC;AAEI,IAAM,+BAA+B,GAAG,UAC7C,OAAgD,EAChD,aAA4B;;;;;gBAE5B,KAAK,CAAC,GAAG;qBACN,IAAI,CAAC,uQAGyE,eAAK,CAAC,IAAI,CACzF,gBAAgB,CACjB,4BAAyB,CAAC,CAAC;gBAEI,qBAAM,IAAA,8BAAgB,EACpD,KAAK,CAAC,MAAM,CAAC;wBACX,OAAO,EAAE,uDAAuD;wBAChE,OAAO,EAAE;4BACP;gCACE,KAAK,EAAE,sBAAsB;gCAC7B,KAAK,EAAE,IAAI;gCACX,IAAI,EAAE,8CAA8C;6BACrD;4BACD;gCACE,KAAK,EAAE,0CAA0C;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ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { runNextjsWizard } from '../../nextjs/nextjs-wizard';\nimport { traceStep } from '../../telemetry';\nimport { abortIfCancelled, addSentryCliRc } from '../../utils/clack-utils';\nimport { WizardOptions } from '../../utils/types';\n\nimport { SourceMapUploadToolConfigurationOptions } from './types';\n\nimport * as Sentry from '@sentry/node';\n\nconst getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>\n chalk.grey(`\n ${chalk.greenBright(\n 'const { withSentryConfig } = require(\"@sentry/nextjs\");',\n )}\n\n const nextConfig = {\n // your existing next config\n };\n \n ${chalk.greenBright(`const sentryWebpackPluginOptions = {\n org: \"${options.orgSlug}\",\n project: \"${options.projectSlug}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n };`)}\n \n ${chalk.greenBright(`const sentryOptions = {\n // Upload additional client files (increases upload size)\n widenClientFileUpload: true,\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n };`)}\n \n ${chalk.greenBright(`module.exports = withSentryConfig(\n nextConfig,\n sentryWebpackPluginOptions,\n sentryOptions\n );`)} \n`);\n\nexport const configureNextJsSourceMapsUpload = async (\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n) => {\n clack.log\n .info(`Source Maps upload for Next.js is configured automatically by default if you run the Sentry Wizard for Next.JS.\nBut don't worry, we can redirect you to the wizard now!\n\nIn case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(\n 'next.config.js',\n )} file manually instead.`);\n\n const shouldRedirect: boolean = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run the Sentry Wizard for Next.JS now?',\n options: [\n {\n label: 'Yes, run the wizard!',\n value: true,\n hint: 'The wizard can also configure your SDK setup',\n },\n {\n label: 'No, show me how to configure it manually',\n value: false,\n },\n ],\n }),\n );\n\n Sentry.setTag('redirect-nextjs-wizard', shouldRedirect);\n\n if (shouldRedirect) {\n await traceStep('run-nextjs-wizard', () => runNextjsWizard(wizardOptions));\n clack.intro('Sentry Source Maps Upload Configuration Wizard');\n clack.log.info(\n \"Welcome back to the Source Maps wizard - we're almost done ;)\",\n );\n } else {\n clack.log.info(\n `Add the following code to your ${chalk.cyan('next.config.js')}:`,\n );\n\n // Intentionally logging directly to console here\n // eslint-disable-next-line no-console\n console.log(getCodeSnippet(options));\n\n await traceStep('nextjs-manual-nextconfigjs', () =>\n abortIfCancelled(\n clack.select({\n message: 'Did you copy the code above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n ),\n );\n\n await traceStep('nextjs-manual-sentryclirc', () =>\n addSentryCliRc(options.authToken),\n );\n }\n\n clack.log\n .info(`In case you still run into problems, check out our docs to further debug your setup:\n\nUploading Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-source-maps\n \nTroubleshooting Source Maps:\nhttps://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/`);\n};\n"]}
|
|
@@ -71,7 +71,9 @@ var path = __importStar(require("path"));
|
|
|
71
71
|
var fs = __importStar(require("fs"));
|
|
72
72
|
var clack_utils_1 = require("../../utils/clack-utils");
|
|
73
73
|
var package_json_1 = require("../../utils/package-json");
|
|
74
|
-
var
|
|
74
|
+
var telemetry_1 = require("../../telemetry");
|
|
75
|
+
var SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';
|
|
76
|
+
var addedToBuildCommand = false;
|
|
75
77
|
function configureSentryCLI(options, configureSourcemapGenerationFlow) {
|
|
76
78
|
if (configureSourcemapGenerationFlow === void 0) { configureSourcemapGenerationFlow = defaultConfigureSourcemapGenerationFlow; }
|
|
77
79
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -143,8 +145,20 @@ function configureSentryCLI(options, configureSourcemapGenerationFlow) {
|
|
|
143
145
|
return [4 /*yield*/, createAndAddNpmScript(packageDotJson, options, relativePosixArtifactPath)];
|
|
144
146
|
case 12:
|
|
145
147
|
_b.sent();
|
|
146
|
-
return [4 /*yield*/, (
|
|
148
|
+
return [4 /*yield*/, askShouldAddToBuildCommand()];
|
|
147
149
|
case 13:
|
|
150
|
+
if (!_b.sent()) return [3 /*break*/, 15];
|
|
151
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('sentry-cli-add-to-build-cmd', function () {
|
|
152
|
+
return addSentryCommandToBuildCommand(packageDotJson);
|
|
153
|
+
})];
|
|
154
|
+
case 14:
|
|
155
|
+
_b.sent();
|
|
156
|
+
return [3 /*break*/, 16];
|
|
157
|
+
case 15:
|
|
158
|
+
prompts_1.default.log.info("No problem, just make sure to run this script ".concat(chalk_1.default.bold('after'), " building your application but ").concat(chalk_1.default.bold('before'), " deploying!"));
|
|
159
|
+
_b.label = 16;
|
|
160
|
+
case 16: return [4 /*yield*/, (0, clack_utils_1.addSentryCliRc)(options.authToken)];
|
|
161
|
+
case 17:
|
|
148
162
|
_b.sent();
|
|
149
163
|
return [2 /*return*/];
|
|
150
164
|
}
|
|
@@ -157,18 +171,24 @@ function setupNpmScriptInCI() {
|
|
|
157
171
|
var addedToCI;
|
|
158
172
|
return __generator(this, function (_a) {
|
|
159
173
|
switch (_a.label) {
|
|
160
|
-
case 0:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
case 0:
|
|
175
|
+
if (addedToBuildCommand) {
|
|
176
|
+
// No need to tell users to add it manually to their CI
|
|
177
|
+
// if the script is already added to the build command
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
181
|
+
message: "Add a step to your CI pipeline that runs the ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script ").concat(chalk_1.default.bold('right after'), " building your application."),
|
|
182
|
+
options: [
|
|
183
|
+
{ label: 'I did, continue!', value: true },
|
|
184
|
+
{
|
|
185
|
+
label: "I'll do it later...",
|
|
186
|
+
value: false,
|
|
187
|
+
hint: chalk_1.default.yellow("You need to run ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " after each build for source maps to work properly.")),
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
initialValue: true,
|
|
191
|
+
}))];
|
|
172
192
|
case 1:
|
|
173
193
|
addedToCI = _a.sent();
|
|
174
194
|
Sentry.setTag('added-ci-script', addedToCI);
|
|
@@ -189,11 +209,95 @@ function createAndAddNpmScript(packageDotJson, options, relativePosixArtifactPat
|
|
|
189
209
|
case 0:
|
|
190
210
|
sentryCliNpmScript = "sentry-cli sourcemaps inject --org ".concat(options.orgSlug, " --project ").concat(options.projectSlug, " ").concat(relativePosixArtifactPath, " && sentry-cli").concat(options.selfHosted ? " --url ".concat(options.url) : '', " sourcemaps upload --org ").concat(options.orgSlug, " --project ").concat(options.projectSlug, " ").concat(relativePosixArtifactPath);
|
|
191
211
|
packageDotJson.scripts = packageDotJson.scripts || {};
|
|
192
|
-
packageDotJson.scripts[
|
|
212
|
+
packageDotJson.scripts[SENTRY_NPM_SCRIPT_NAME] = sentryCliNpmScript;
|
|
193
213
|
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2))];
|
|
194
214
|
case 1:
|
|
195
215
|
_a.sent();
|
|
196
|
-
prompts_1.default.log.info("Added a ".concat(chalk_1.default.cyan(
|
|
216
|
+
prompts_1.default.log.info("Added a ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script to your ").concat(chalk_1.default.cyan('package.json'), "."));
|
|
217
|
+
return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function askShouldAddToBuildCommand() {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
var shouldAddToBuildCommand;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
228
|
+
message: "Do you want to automatically run the ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script after each production build?"),
|
|
229
|
+
options: [
|
|
230
|
+
{
|
|
231
|
+
label: 'Yes',
|
|
232
|
+
value: true,
|
|
233
|
+
hint: 'This will modify your prod build comamnd',
|
|
234
|
+
},
|
|
235
|
+
{ label: 'No', value: false },
|
|
236
|
+
],
|
|
237
|
+
initialValue: true,
|
|
238
|
+
}))];
|
|
239
|
+
case 1:
|
|
240
|
+
shouldAddToBuildCommand = _a.sent();
|
|
241
|
+
Sentry.setTag('modify-build-command', shouldAddToBuildCommand);
|
|
242
|
+
return [2 /*return*/, shouldAddToBuildCommand];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Add the sentry:sourcemaps command to the prod build command in the package.json
|
|
249
|
+
* - Detect the user's build command
|
|
250
|
+
* - Append the sentry:sourcemaps command to it
|
|
251
|
+
*
|
|
252
|
+
* @param packageDotJson The package.json which will be modified.
|
|
253
|
+
*/
|
|
254
|
+
function addSentryCommandToBuildCommand(packageDotJson) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
+
var allNpmScripts, pacMan, buildCommand, isProdBuildCommand, _a;
|
|
257
|
+
return __generator(this, function (_b) {
|
|
258
|
+
switch (_b.label) {
|
|
259
|
+
case 0:
|
|
260
|
+
// This usually shouldn't happen because earlier we added the
|
|
261
|
+
// SENTRY_NPM_SCRIPT_NAME script but just to be sure
|
|
262
|
+
packageDotJson.scripts = packageDotJson.scripts || {};
|
|
263
|
+
allNpmScripts = Object.keys(packageDotJson.scripts).filter(function (s) { return s !== SENTRY_NPM_SCRIPT_NAME; });
|
|
264
|
+
pacMan = (0, clack_utils_1.detectPackageManager)() || 'npm';
|
|
265
|
+
buildCommand = packageDotJson.scripts.build ||
|
|
266
|
+
allNpmScripts.find(function (s) { return s.toLocaleLowerCase().includes('build'); });
|
|
267
|
+
_a = !!buildCommand;
|
|
268
|
+
if (!_a) return [3 /*break*/, 2];
|
|
269
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
270
|
+
message: "Is ".concat(chalk_1.default.cyan("".concat(pacMan, " run ").concat(buildCommand)), " your production build command?"),
|
|
271
|
+
}))];
|
|
272
|
+
case 1:
|
|
273
|
+
_a = (_b.sent());
|
|
274
|
+
_b.label = 2;
|
|
275
|
+
case 2:
|
|
276
|
+
isProdBuildCommand = _a;
|
|
277
|
+
if (!(allNpmScripts.length && (!buildCommand || !isProdBuildCommand))) return [3 /*break*/, 4];
|
|
278
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
279
|
+
message: "Which ".concat(pacMan, " command in your ").concat(chalk_1.default.cyan('package.json'), " builds your application for production?"),
|
|
280
|
+
options: allNpmScripts
|
|
281
|
+
.map(function (script) { return ({
|
|
282
|
+
label: script,
|
|
283
|
+
value: script,
|
|
284
|
+
}); })
|
|
285
|
+
.concat({ label: 'None of the above', value: 'none' }),
|
|
286
|
+
}))];
|
|
287
|
+
case 3:
|
|
288
|
+
buildCommand = _b.sent();
|
|
289
|
+
_b.label = 4;
|
|
290
|
+
case 4:
|
|
291
|
+
if (!buildCommand || buildCommand === 'none') {
|
|
292
|
+
prompts_1.default.log.warn("We can only add the ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script to another `script` in your ").concat(chalk_1.default.cyan('package.json'), ".\nPlease add it manually to your prod build command."));
|
|
293
|
+
return [2 /*return*/];
|
|
294
|
+
}
|
|
295
|
+
packageDotJson.scripts[buildCommand] = "".concat(buildCommand, " && ").concat(pacMan, " run ").concat(SENTRY_NPM_SCRIPT_NAME);
|
|
296
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageDotJson, null, 2))];
|
|
297
|
+
case 5:
|
|
298
|
+
_b.sent();
|
|
299
|
+
addedToBuildCommand = true;
|
|
300
|
+
prompts_1.default.log.info("Added ".concat(chalk_1.default.cyan(SENTRY_NPM_SCRIPT_NAME), " script to your ").concat(chalk_1.default.cyan(buildCommand), " command."));
|
|
197
301
|
return [2 /*return*/];
|
|
198
302
|
}
|
|
199
303
|
});
|