@sentry/wizard 3.25.2 → 3.27.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 +20 -0
- package/dist/lib/Steps/OpenSentry.js +1 -1
- package/dist/lib/Steps/OpenSentry.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/src/nextjs/nextjs-wizard.d.ts +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +194 -99
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +7 -3
- package/dist/src/nextjs/templates.js +27 -14
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/run.js +1 -1
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/telemetry.js +10 -3
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +4 -1
- package/dist/src/utils/clack-utils.js +81 -11
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +5 -2
- package/dist/src/utils/package-manager.js +44 -56
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/types.d.ts +6 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/utils/url.js +7 -2
- package/dist/src/utils/url.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +79 -1
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +2 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/lib/Steps/OpenSentry.ts +1 -1
- package/package.json +2 -1
- package/src/nextjs/nextjs-wizard.ts +209 -101
- package/src/nextjs/templates.ts +54 -26
- package/src/run.ts +1 -1
- package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
- package/src/telemetry.ts +7 -1
- package/src/utils/clack-utils.ts +77 -7
- package/src/utils/package-manager.ts +43 -13
- package/src/utils/types.ts +7 -0
- package/src/utils/url.ts +6 -2
- package/test/nextjs/templates.test.ts +296 -2
- package/test/sourcemaps/tools/sentry-cli.test.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.27.0
|
|
4
|
+
|
|
5
|
+
- feat(nextjs): Add feature selection (#631)
|
|
6
|
+
- fix(nextjs): Don't inject replay integration in server configs (#651)
|
|
7
|
+
- fix(deps): fix(deps): Add `recast` as a direct dependency (#653)
|
|
8
|
+
- fix: Fix issue stream URL for self-hosted instances (#645)
|
|
9
|
+
- feat: Detect Yarn v2+ (#652)
|
|
10
|
+
|
|
11
|
+
Work in this release contributed by @MaximAL. Thank you for your contributions!
|
|
12
|
+
|
|
13
|
+
## 3.26.0
|
|
14
|
+
|
|
15
|
+
- fix(nextjs): Don't add '.env.sentry-build-plugin' to .gitignore if it's already there (#610)
|
|
16
|
+
- feat(nextjs): Support all `next.config` file types (#630)
|
|
17
|
+
- fix(nextjs): Update instrumentation and example creation logic for app or pages usage (#629)
|
|
18
|
+
- feat(nextjs): Prompt for `reactComponentAnnotation` (#634)
|
|
19
|
+
- fix(nextjs): Add missing Error.getInitialProps calls in Next.js error page snippets (#632)
|
|
20
|
+
- fix/feat: Improve error logging for package installation (#635)
|
|
21
|
+
- fix: Properly close open handles (#638)
|
|
22
|
+
|
|
3
23
|
## 3.25.2
|
|
4
24
|
|
|
5
25
|
- ref: Improve intro and wizard selection (#625)
|
|
@@ -105,7 +105,7 @@ var OpenSentry = /** @class */ (function (_super) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
urlToOpen = urlObj.toString();
|
|
108
|
-
opn(urlToOpen).catch(function () {
|
|
108
|
+
opn(urlToOpen, { wait: false }).catch(function () {
|
|
109
109
|
// opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here
|
|
110
110
|
});
|
|
111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wBAEpC,GAAG,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;4BACpC,iGAAiG;wBACnG,CAAC,CAAC,CAAC;wBAEH,IAAA,YAAE,GAAE,CAAC;wBACL,IAAA,WAAC,EAAC,aAAa,CAAC,CAAC;wBACjB,IAAA,eAAK,EAAC,SAAS,CAAC,CAAC;wBACjB,IAAA,WAAC,EAAC,4CAA4C,CAAC,CAAC;wBAChD,IAAA,YAAE,GAAE,CAAC;wBAEL,sBAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAC;;;wBAE3B,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;wBAC9B,qBAAS,CAAC,IAAI,EAAE,CAAC;wBACjB,IAAA,YAAE,GAAE,CAAC;wBACL,IAAA,aAAG,EACD,qCAA8B,OAAO,mCAAgC,CACtE,CAAC;wBACF,IAAA,WAAC,EACC,0EAA0E,CAC3E,CAAC;wBACF,sBAAO,EAAE,EAAC;;;;;KAEb;IACH,iBAAC;AAAD,CAAC,AA9DD,CAAgC,mBAAQ,GA8DvC;AA9DY,gCAAU","sourcesContent":["import type { Answers } from 'inquirer';\nimport { URL } from 'url';\n\nimport { mapIntegrationToPlatform } from '../Constants';\nimport { BottomBar } from '../Helper/BottomBar';\nimport { dim, green, l, nl, red } from '../Helper/Logging';\nimport { getCurrentIntegration } from '../Helper/Wizard';\nimport { BaseStep } from './BaseStep';\n\nconst opn = require('opn');\nconst r2 = require('r2');\n\nexport class OpenSentry extends BaseStep {\n public async emit(answers: Answers): Promise<Answers> {\n if (!(await getCurrentIntegration(answers).shouldEmit(answers))) {\n dim('Skipping connection to Sentry due files already patched');\n return {};\n }\n if (this._argv.skipConnect) {\n dim('Skipping connection to Sentry');\n return {};\n }\n\n const baseUrl = this._argv.url;\n\n BottomBar.show('Loading wizard...');\n this.debug(`Loading wizard for ${baseUrl}`);\n\n try {\n const data = await r2.get(`${baseUrl}api/0/wizard/`).json;\n\n BottomBar.hide();\n\n const urlObj = new URL(`${baseUrl}account/settings/wizard/${data.hash}/`);\n if (this._argv.signup) {\n urlObj.searchParams.set('signup', '1');\n // integration maps to platform in the wizard\n if (this._argv.integration) {\n const platform = mapIntegrationToPlatform(this._argv.integration);\n if (platform) {\n urlObj.searchParams.set('project_platform', platform);\n }\n }\n if (this._argv.promoCode) {\n urlObj.searchParams.set('code', this._argv.promoCode);\n }\n }\n\n const urlToOpen = urlObj.toString();\n\n opn(urlToOpen, { wait: false }).catch(() => {\n // opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here\n });\n\n nl();\n l('Please open');\n green(urlToOpen);\n l(\"in your browser (if it's not open already)\");\n nl();\n\n return { hash: data.hash };\n } catch (e) {\n this._argv.skipConnect = true;\n BottomBar.hide();\n nl();\n red(\n `Wizard couldn't connect to ${baseUrl}\\nmake sure the url is correct`,\n );\n l(\n 'But no worries, we fall back to asking you stuff instead, so here we go:',\n );\n return {};\n }\n }\n}\n"]}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wizard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0",
|
|
4
4
|
"homepage": "https://github.com/getsentry/sentry-wizard",
|
|
5
5
|
"repository": "https://github.com/getsentry/sentry-wizard",
|
|
6
6
|
"description": "Sentry wizard helping you to configure your project",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"opn": "^5.4.0",
|
|
37
37
|
"r2": "^2.0.1",
|
|
38
38
|
"read-env": "^1.3.0",
|
|
39
|
+
"recast": "^0.23.3",
|
|
39
40
|
"semver": "^7.5.3",
|
|
40
41
|
"xcode": "3.0.1",
|
|
41
42
|
"xml-js": "^1.6.11",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { WizardOptions } from '../utils/types';
|
|
1
|
+
import type { WizardOptions } from '../utils/types';
|
|
2
2
|
export declare function runNextjsWizard(options: WizardOptions): Promise<void>;
|
|
3
3
|
export declare function runNextjsWizardWithTelemetry(options: WizardOptions): Promise<void>;
|
|
@@ -131,16 +131,20 @@ function runNextjsWizardWithTelemetry(options) {
|
|
|
131
131
|
case 5:
|
|
132
132
|
_c.sent();
|
|
133
133
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('configure-sdk', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
134
|
-
var tunnelRoute;
|
|
134
|
+
var tunnelRoute, reactComponentAnnotation;
|
|
135
135
|
return __generator(this, function (_a) {
|
|
136
136
|
switch (_a.label) {
|
|
137
137
|
case 0: return [4 /*yield*/, askShouldSetTunnelRoute()];
|
|
138
138
|
case 1:
|
|
139
139
|
tunnelRoute = _a.sent();
|
|
140
|
+
return [4 /*yield*/, askShouldEnableReactComponentAnnotation()];
|
|
141
|
+
case 2:
|
|
142
|
+
reactComponentAnnotation = _a.sent();
|
|
140
143
|
return [4 /*yield*/, createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, {
|
|
141
144
|
tunnelRoute: tunnelRoute,
|
|
145
|
+
reactComponentAnnotation: reactComponentAnnotation,
|
|
142
146
|
})];
|
|
143
|
-
case
|
|
147
|
+
case 3:
|
|
144
148
|
_a.sent();
|
|
145
149
|
return [2 /*return*/];
|
|
146
150
|
}
|
|
@@ -313,11 +317,24 @@ function runNextjsWizardWithTelemetry(options) {
|
|
|
313
317
|
exports.runNextjsWizardWithTelemetry = runNextjsWizardWithTelemetry;
|
|
314
318
|
function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkConfigOptions) {
|
|
315
319
|
return __awaiter(this, void 0, void 0, function () {
|
|
316
|
-
var typeScriptDetected, configVariants, _loop_1, _i, configVariants_1, configVariant;
|
|
320
|
+
var selectedFeatures, typeScriptDetected, configVariants, _loop_1, _i, configVariants_1, configVariant;
|
|
317
321
|
var _this = this;
|
|
318
322
|
return __generator(this, function (_a) {
|
|
319
323
|
switch (_a.label) {
|
|
320
|
-
case 0:
|
|
324
|
+
case 0: return [4 /*yield*/, (0, clack_utils_1.featureSelectionPrompt)([
|
|
325
|
+
{
|
|
326
|
+
id: 'performance',
|
|
327
|
+
prompt: "Do you want to enable ".concat(chalk_1.default.bold('Tracing'), " to track the performance of your application?"),
|
|
328
|
+
enabledHint: 'recommended',
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
id: 'replay',
|
|
332
|
+
prompt: "Do you want to enable ".concat(chalk_1.default.bold('Sentry Session Replay'), " to get reproduction of frontend errors via user sessions?"),
|
|
333
|
+
enabledHint: 'recommended, but increases bundle size',
|
|
334
|
+
},
|
|
335
|
+
])];
|
|
336
|
+
case 1:
|
|
337
|
+
selectedFeatures = _a.sent();
|
|
321
338
|
typeScriptDetected = (0, clack_utils_1.isUsingTypeScript)();
|
|
322
339
|
configVariants = ['server', 'client', 'edge'];
|
|
323
340
|
_loop_1 = function (configVariant) {
|
|
@@ -361,7 +378,7 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
361
378
|
_a.label = 2;
|
|
362
379
|
case 2:
|
|
363
380
|
if (!shouldWriteFile) return [3 /*break*/, 4];
|
|
364
|
-
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig), (0, templates_1.getSentryConfigContents)(selectedProject.keys[0].dsn.public, configVariant), { encoding: 'utf8', flag: 'w' })];
|
|
381
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig), (0, templates_1.getSentryConfigContents)(selectedProject.keys[0].dsn.public, configVariant, selectedFeatures), { encoding: 'utf8', flag: 'w' })];
|
|
365
382
|
case 3:
|
|
366
383
|
_a.sent();
|
|
367
384
|
prompts_1.default.log.success("Created fresh ".concat(chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig), "."));
|
|
@@ -378,57 +395,81 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
378
395
|
});
|
|
379
396
|
};
|
|
380
397
|
_i = 0, configVariants_1 = configVariants;
|
|
381
|
-
_a.label =
|
|
382
|
-
case
|
|
383
|
-
if (!(_i < configVariants_1.length)) return [3 /*break*/,
|
|
398
|
+
_a.label = 2;
|
|
399
|
+
case 2:
|
|
400
|
+
if (!(_i < configVariants_1.length)) return [3 /*break*/, 5];
|
|
384
401
|
configVariant = configVariants_1[_i];
|
|
385
402
|
return [5 /*yield**/, _loop_1(configVariant)];
|
|
386
|
-
case 2:
|
|
387
|
-
_a.sent();
|
|
388
|
-
_a.label = 3;
|
|
389
403
|
case 3:
|
|
404
|
+
_a.sent();
|
|
405
|
+
_a.label = 4;
|
|
406
|
+
case 4:
|
|
390
407
|
_i++;
|
|
391
|
-
return [3 /*break*/,
|
|
392
|
-
case
|
|
393
|
-
var
|
|
408
|
+
return [3 /*break*/, 2];
|
|
409
|
+
case 5: return [4 /*yield*/, (0, telemetry_1.traceStep)('setup-instrumentation-hook', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
410
|
+
var hasRootAppDirectory, hasRootPagesDirectory, hasSrcDirectory, instrumentationHookLocation, instrumentationTsExists, instrumentationJsExists, srcInstrumentationTsExists, srcInstrumentationJsExists, newInstrumentationFileName, newInstrumentationHookLocation, newInstrumentationHookPath, successfullyCreated;
|
|
394
411
|
return __generator(this, function (_a) {
|
|
395
412
|
switch (_a.label) {
|
|
396
413
|
case 0:
|
|
397
|
-
|
|
398
|
-
|
|
414
|
+
hasRootAppDirectory = hasDirectoryPathFromRoot('app');
|
|
415
|
+
hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');
|
|
416
|
+
hasSrcDirectory = hasDirectoryPathFromRoot('src');
|
|
399
417
|
instrumentationTsExists = fs.existsSync(path.join(process.cwd(), 'instrumentation.ts'));
|
|
400
418
|
instrumentationJsExists = fs.existsSync(path.join(process.cwd(), 'instrumentation.js'));
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
419
|
+
srcInstrumentationTsExists = fs.existsSync(path.join(process.cwd(), 'src', 'instrumentation.ts'));
|
|
420
|
+
srcInstrumentationJsExists = fs.existsSync(path.join(process.cwd(), 'src', 'instrumentation.js'));
|
|
421
|
+
// https://nextjs.org/docs/app/building-your-application/configuring/src-directory
|
|
422
|
+
// https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation
|
|
423
|
+
// The logic for where Next.js picks up the instrumentation file is as follows:
|
|
424
|
+
// - If there is either an `app` folder or a `pages` folder in the root directory of your Next.js app, Next.js looks
|
|
425
|
+
// for an `instrumentation.ts` file in the root of the Next.js app.
|
|
426
|
+
// - Otherwise, if there is neither an `app` folder or a `pages` folder in the rood directory of your Next.js app,
|
|
427
|
+
// AND if there is an `src` folder, Next.js will look for the `instrumentation.ts` file in the `src` folder.
|
|
428
|
+
if (hasRootPagesDirectory || hasRootAppDirectory) {
|
|
429
|
+
if (instrumentationJsExists || instrumentationTsExists) {
|
|
430
|
+
instrumentationHookLocation = 'root';
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
instrumentationHookLocation = 'does-not-exist';
|
|
434
|
+
}
|
|
406
435
|
}
|
|
407
436
|
else {
|
|
408
|
-
|
|
437
|
+
if (srcInstrumentationTsExists || srcInstrumentationJsExists) {
|
|
438
|
+
instrumentationHookLocation = 'src';
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
instrumentationHookLocation = 'does-not-exist';
|
|
442
|
+
}
|
|
409
443
|
}
|
|
410
|
-
if (!(instrumentationHookLocation === 'does-not-exist')) return [3 /*break*/, 4];
|
|
411
444
|
newInstrumentationFileName = "instrumentation.".concat(typeScriptDetected ? 'ts' : 'js');
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
445
|
+
if (!(instrumentationHookLocation === 'does-not-exist')) return [3 /*break*/, 4];
|
|
446
|
+
newInstrumentationHookLocation = void 0;
|
|
447
|
+
if (hasRootPagesDirectory || hasRootAppDirectory) {
|
|
448
|
+
newInstrumentationHookLocation = 'root';
|
|
449
|
+
}
|
|
450
|
+
else if (hasSrcDirectory) {
|
|
451
|
+
newInstrumentationHookLocation = 'src';
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
newInstrumentationHookLocation = 'root';
|
|
455
|
+
}
|
|
456
|
+
newInstrumentationHookPath = newInstrumentationHookLocation === 'root'
|
|
457
|
+
? path.join(process.cwd(), newInstrumentationFileName)
|
|
458
|
+
: path.join(process.cwd(), 'src', newInstrumentationFileName);
|
|
459
|
+
return [4 /*yield*/, (0, clack_utils_1.createNewConfigFile)(newInstrumentationHookPath, (0, templates_1.getInstrumentationHookContent)(newInstrumentationHookLocation))];
|
|
417
460
|
case 1:
|
|
418
461
|
successfullyCreated = _a.sent();
|
|
419
462
|
if (!!successfullyCreated) return [3 /*break*/, 3];
|
|
420
|
-
return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)(newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(
|
|
463
|
+
return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)(newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(newInstrumentationHookLocation))];
|
|
421
464
|
case 2:
|
|
422
465
|
_a.sent();
|
|
423
466
|
_a.label = 3;
|
|
424
467
|
case 3: return [3 /*break*/, 6];
|
|
425
|
-
case 4: return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)(srcInstrumentationTsExists
|
|
468
|
+
case 4: return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)(srcInstrumentationTsExists || instrumentationTsExists
|
|
426
469
|
? 'instrumentation.ts'
|
|
427
|
-
: srcInstrumentationJsExists
|
|
470
|
+
: srcInstrumentationJsExists || instrumentationJsExists
|
|
428
471
|
? 'instrumentation.js'
|
|
429
|
-
:
|
|
430
|
-
? 'instrumentation.ts'
|
|
431
|
-
: 'instrumentation.js', (0, templates_1.getInstrumentationHookCopyPasteSnippet)(instrumentationHookLocation))];
|
|
472
|
+
: newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(instrumentationHookLocation))];
|
|
432
473
|
case 5:
|
|
433
474
|
_a.sent();
|
|
434
475
|
_a.label = 6;
|
|
@@ -436,10 +477,10 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
436
477
|
}
|
|
437
478
|
});
|
|
438
479
|
}); })];
|
|
439
|
-
case
|
|
480
|
+
case 6:
|
|
440
481
|
_a.sent();
|
|
441
482
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('setup-next-config', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
442
|
-
var withSentryConfigOptionsTemplate,
|
|
483
|
+
var withSentryConfigOptionsTemplate, nextConfigPossibleFilesMap, foundNextConfigFile, foundNextConfigFileType, foundNextConfigFileFilename, nextConfigCjsContent, probablyIncludesSdk, shouldInject, injectAnyhow, nextConfigMjsContent, probablyIncludesSdk, shouldInject, injectAnyhow, mod, expressionToWrap, newCode, _a, shouldContinue;
|
|
443
484
|
return __generator(this, function (_b) {
|
|
444
485
|
switch (_b.label) {
|
|
445
486
|
case 0:
|
|
@@ -449,28 +490,40 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
449
490
|
selfHosted: selfHosted,
|
|
450
491
|
sentryUrl: sentryUrl,
|
|
451
492
|
tunnelRoute: sdkConfigOptions.tunnelRoute,
|
|
493
|
+
reactComponentAnnotation: sdkConfigOptions.reactComponentAnnotation,
|
|
452
494
|
});
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
495
|
+
nextConfigPossibleFilesMap = {
|
|
496
|
+
js: 'next.config.js',
|
|
497
|
+
mjs: 'next.config.mjs',
|
|
498
|
+
cjs: 'next.config.cjs',
|
|
499
|
+
ts: 'next.config.ts',
|
|
500
|
+
mts: 'next.config.mts',
|
|
501
|
+
cts: 'next.config.cts',
|
|
502
|
+
};
|
|
503
|
+
foundNextConfigFile = Object.entries(nextConfigPossibleFilesMap).find(function (_a) {
|
|
504
|
+
var fileName = _a[1];
|
|
505
|
+
return fs.existsSync(path.join(process.cwd(), fileName));
|
|
506
|
+
});
|
|
507
|
+
if (!!foundNextConfigFile) return [3 /*break*/, 2];
|
|
458
508
|
Sentry.setTag('next-config-strategy', 'create');
|
|
459
|
-
return [4 /*yield*/, fs.promises.writeFile(
|
|
509
|
+
return [4 /*yield*/, fs.promises.writeFile(
|
|
510
|
+
// We are creating a `next.config.js` file by default as it is supported by the most Next.js versions
|
|
511
|
+
path.join(process.cwd(), nextConfigPossibleFilesMap.js), (0, templates_1.getNextjsConfigCjsTemplate)(withSentryConfigOptionsTemplate), { encoding: 'utf8', flag: 'w' })];
|
|
460
512
|
case 1:
|
|
461
513
|
_b.sent();
|
|
462
514
|
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan('next.config.js'), " with Sentry configuration."));
|
|
463
|
-
|
|
515
|
+
return [2 /*return*/];
|
|
464
516
|
case 2:
|
|
465
|
-
|
|
517
|
+
foundNextConfigFileType = foundNextConfigFile[0], foundNextConfigFileFilename = foundNextConfigFile[1];
|
|
518
|
+
if (!(foundNextConfigFileType === 'js' || foundNextConfigFileType === 'cjs')) return [3 /*break*/, 7];
|
|
466
519
|
Sentry.setTag('next-config-strategy', 'modify');
|
|
467
|
-
|
|
468
|
-
probablyIncludesSdk =
|
|
469
|
-
|
|
520
|
+
nextConfigCjsContent = fs.readFileSync(path.join(process.cwd(), foundNextConfigFileFilename), 'utf8');
|
|
521
|
+
probablyIncludesSdk = nextConfigCjsContent.includes('@sentry/nextjs') &&
|
|
522
|
+
nextConfigCjsContent.includes('withSentryConfig');
|
|
470
523
|
shouldInject = true;
|
|
471
524
|
if (!probablyIncludesSdk) return [3 /*break*/, 4];
|
|
472
525
|
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
473
|
-
message: "".concat(chalk_1.default.cyan(
|
|
526
|
+
message: "".concat(chalk_1.default.cyan(foundNextConfigFileFilename), " already contains Sentry SDK configuration. Should the wizard modify it anyways?"),
|
|
474
527
|
}))];
|
|
475
528
|
case 3:
|
|
476
529
|
injectAnyhow = _b.sent();
|
|
@@ -478,23 +531,26 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
478
531
|
_b.label = 4;
|
|
479
532
|
case 4:
|
|
480
533
|
if (!shouldInject) return [3 /*break*/, 6];
|
|
481
|
-
return [4 /*yield*/, fs.promises.appendFile(path.join(process.cwd(),
|
|
534
|
+
return [4 /*yield*/, fs.promises.appendFile(path.join(process.cwd(), foundNextConfigFileFilename), (0, templates_1.getNextjsConfigCjsAppendix)(withSentryConfigOptionsTemplate), 'utf8')];
|
|
482
535
|
case 5:
|
|
483
536
|
_b.sent();
|
|
484
|
-
prompts_1.default.log.success("Added Sentry configuration to ".concat(chalk_1.default.cyan(
|
|
537
|
+
prompts_1.default.log.success("Added Sentry configuration to ".concat(chalk_1.default.cyan(foundNextConfigFileFilename), ". ").concat(chalk_1.default.dim('(you probably want to clean this up a bit!)')));
|
|
485
538
|
_b.label = 6;
|
|
486
539
|
case 6:
|
|
487
540
|
Sentry.setTag('next-config-mod-result', 'success');
|
|
488
541
|
_b.label = 7;
|
|
489
542
|
case 7:
|
|
490
|
-
if (!
|
|
491
|
-
|
|
543
|
+
if (!(foundNextConfigFileType === 'mjs' ||
|
|
544
|
+
foundNextConfigFileType === 'mts' ||
|
|
545
|
+
foundNextConfigFileType === 'cts' ||
|
|
546
|
+
foundNextConfigFileType === 'ts')) return [3 /*break*/, 16];
|
|
547
|
+
nextConfigMjsContent = fs.readFileSync(path.join(process.cwd(), foundNextConfigFileFilename), 'utf8');
|
|
492
548
|
probablyIncludesSdk = nextConfigMjsContent.includes('@sentry/nextjs') &&
|
|
493
549
|
nextConfigMjsContent.includes('withSentryConfig');
|
|
494
550
|
shouldInject = true;
|
|
495
551
|
if (!probablyIncludesSdk) return [3 /*break*/, 9];
|
|
496
552
|
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
497
|
-
message: "".concat(chalk_1.default.cyan(
|
|
553
|
+
message: "".concat(chalk_1.default.cyan(foundNextConfigFileFilename), " already contains Sentry SDK configuration. Should the wizard modify it anyways?"),
|
|
498
554
|
}))];
|
|
499
555
|
case 8:
|
|
500
556
|
injectAnyhow = _b.sent();
|
|
@@ -513,25 +569,25 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
513
569
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
514
570
|
mod.exports.default = magicast_1.builders.raw("withSentryConfig(\n ".concat(expressionToWrap, ",\n ").concat(withSentryConfigOptionsTemplate, "\n)"));
|
|
515
571
|
newCode = mod.generate().code;
|
|
516
|
-
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(),
|
|
572
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), foundNextConfigFileFilename), newCode, {
|
|
517
573
|
encoding: 'utf8',
|
|
518
574
|
flag: 'w',
|
|
519
575
|
})];
|
|
520
576
|
case 10:
|
|
521
577
|
_b.sent();
|
|
522
|
-
prompts_1.default.log.success("Added Sentry configuration to ".concat(chalk_1.default.cyan(
|
|
578
|
+
prompts_1.default.log.success("Added Sentry configuration to ".concat(chalk_1.default.cyan(foundNextConfigFileFilename), ". ").concat(chalk_1.default.dim('(you probably want to clean this up a bit!)')));
|
|
523
579
|
Sentry.setTag('next-config-mod-result', 'success');
|
|
524
580
|
_b.label = 11;
|
|
525
581
|
case 11: return [3 /*break*/, 16];
|
|
526
582
|
case 12:
|
|
527
583
|
_a = _b.sent();
|
|
528
584
|
Sentry.setTag('next-config-mod-result', 'fail');
|
|
529
|
-
prompts_1.default.log.warn(chalk_1.default.yellow("Something went wrong writing to ".concat(chalk_1.default.cyan(
|
|
530
|
-
prompts_1.default.log.info("Please put the following code snippet into ".concat(chalk_1.default.cyan(
|
|
585
|
+
prompts_1.default.log.warn(chalk_1.default.yellow("Something went wrong writing to ".concat(chalk_1.default.cyan(foundNextConfigFileFilename), ".")));
|
|
586
|
+
prompts_1.default.log.info("Please put the following code snippet into ".concat(chalk_1.default.cyan(foundNextConfigFileFilename), ": ").concat(chalk_1.default.dim('You probably have to clean it up a bit.'), "\n"));
|
|
531
587
|
// eslint-disable-next-line no-console
|
|
532
588
|
console.log((0, templates_1.getNextjsConfigEsmCopyPasteSnippet)(withSentryConfigOptionsTemplate));
|
|
533
589
|
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
534
|
-
message: "Are you done putting the snippet above into ".concat(chalk_1.default.cyan(
|
|
590
|
+
message: "Are you done putting the snippet above into ".concat(chalk_1.default.cyan(foundNextConfigFileFilename), "?"),
|
|
535
591
|
active: 'Yes',
|
|
536
592
|
inactive: 'No, get me out of here',
|
|
537
593
|
}))];
|
|
@@ -547,50 +603,52 @@ function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkCon
|
|
|
547
603
|
}
|
|
548
604
|
});
|
|
549
605
|
}); })];
|
|
550
|
-
case
|
|
606
|
+
case 7:
|
|
551
607
|
_a.sent();
|
|
552
608
|
return [2 /*return*/];
|
|
553
609
|
}
|
|
554
610
|
});
|
|
555
611
|
});
|
|
556
612
|
}
|
|
613
|
+
function hasDirectoryPathFromRoot(dirnameOrDirs) {
|
|
614
|
+
var dirPath = Array.isArray(dirnameOrDirs)
|
|
615
|
+
? path.join.apply(path, __spreadArray([process.cwd()], dirnameOrDirs, false)) : path.join(process.cwd(), dirnameOrDirs);
|
|
616
|
+
return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();
|
|
617
|
+
}
|
|
557
618
|
function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
558
619
|
return __awaiter(this, void 0, void 0, function () {
|
|
559
|
-
var
|
|
620
|
+
var hasSrcDirectory, hasRootAppDirectory, hasRootPagesDirectory, hasSrcAppDirectory, hasSrcPagesDirectory, typeScriptDetected, appFolderLocation, pagesFolderLocation, newPagesFolderLocation, examplePageContents, newPageFileName, newRouteFileName, examplePageContents;
|
|
560
621
|
return __generator(this, function (_a) {
|
|
561
622
|
switch (_a.label) {
|
|
562
623
|
case 0:
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
624
|
+
hasSrcDirectory = hasDirectoryPathFromRoot('src');
|
|
625
|
+
hasRootAppDirectory = hasDirectoryPathFromRoot('app');
|
|
626
|
+
hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');
|
|
627
|
+
hasSrcAppDirectory = hasDirectoryPathFromRoot(['src', 'app']);
|
|
628
|
+
hasSrcPagesDirectory = hasDirectoryPathFromRoot(['src', 'pages']);
|
|
629
|
+
Sentry.setTag('nextjs-app-dir', hasRootAppDirectory || hasSrcAppDirectory);
|
|
568
630
|
typeScriptDetected = (0, clack_utils_1.isUsingTypeScript)();
|
|
569
|
-
|
|
570
|
-
fs.lstatSync(maybePagesDirPath).isDirectory()
|
|
571
|
-
? ['pages']
|
|
572
|
-
: fs.existsSync(maybeSrcPagesDirPath) &&
|
|
573
|
-
fs.lstatSync(maybeSrcPagesDirPath).isDirectory()
|
|
574
|
-
? ['src', 'pages']
|
|
575
|
-
: undefined;
|
|
576
|
-
appLocation = fs.existsSync(maybeAppDirPath) &&
|
|
577
|
-
fs.lstatSync(maybeAppDirPath).isDirectory()
|
|
631
|
+
appFolderLocation = hasRootAppDirectory
|
|
578
632
|
? ['app']
|
|
579
|
-
:
|
|
580
|
-
fs.lstatSync(maybeSrcAppDirPath).isDirectory()
|
|
633
|
+
: hasSrcAppDirectory
|
|
581
634
|
? ['src', 'app']
|
|
582
635
|
: undefined;
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
636
|
+
pagesFolderLocation = hasRootPagesDirectory
|
|
637
|
+
? ['pages']
|
|
638
|
+
: hasSrcPagesDirectory
|
|
639
|
+
? ['src', 'pages']
|
|
640
|
+
: undefined;
|
|
641
|
+
// If the user has neither pages nor app directory we create a pages folder for them
|
|
642
|
+
if (!appFolderLocation && !pagesFolderLocation) {
|
|
643
|
+
newPagesFolderLocation = hasSrcDirectory
|
|
644
|
+
? ['src', 'pages']
|
|
645
|
+
: ['pages'];
|
|
646
|
+
fs.mkdirSync(path.join.apply(path, __spreadArray([process.cwd()], newPagesFolderLocation, false)), {
|
|
589
647
|
recursive: true,
|
|
590
648
|
});
|
|
649
|
+
pagesFolderLocation = newPagesFolderLocation;
|
|
591
650
|
}
|
|
592
|
-
|
|
593
|
-
if (!appLocation) return [3 /*break*/, 3];
|
|
651
|
+
if (!appFolderLocation) return [3 /*break*/, 3];
|
|
594
652
|
examplePageContents = (0, templates_1.getSentryExamplePageContents)({
|
|
595
653
|
selfHosted: selfHosted,
|
|
596
654
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -598,30 +656,31 @@ function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
598
656
|
sentryUrl: sentryUrl,
|
|
599
657
|
useClient: true,
|
|
600
658
|
});
|
|
601
|
-
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
659
|
+
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], appFolderLocation, false), ['sentry-example-page'], false)), {
|
|
602
660
|
recursive: true,
|
|
603
661
|
});
|
|
604
662
|
newPageFileName = "page.".concat(typeScriptDetected ? 'tsx' : 'jsx');
|
|
605
|
-
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
663
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], appFolderLocation, false), ['sentry-example-page',
|
|
606
664
|
newPageFileName], false)), examplePageContents, { encoding: 'utf8', flag: 'w' })];
|
|
607
665
|
case 1:
|
|
608
666
|
_a.sent();
|
|
609
|
-
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([],
|
|
610
|
-
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
667
|
+
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([], appFolderLocation, false), ['sentry-example-page', newPageFileName], false))), "."));
|
|
668
|
+
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], appFolderLocation, false), ['api',
|
|
669
|
+
'sentry-example-api'], false)), {
|
|
611
670
|
recursive: true,
|
|
612
671
|
});
|
|
613
672
|
newRouteFileName = "route.".concat(typeScriptDetected ? 'ts' : 'js');
|
|
614
|
-
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
673
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], appFolderLocation, false), ['api',
|
|
615
674
|
'sentry-example-api',
|
|
616
675
|
newRouteFileName], false)), (0, templates_1.getSentryExampleAppDirApiRoute)(), { encoding: 'utf8', flag: 'w' })];
|
|
617
676
|
case 2:
|
|
618
677
|
_a.sent();
|
|
619
|
-
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([],
|
|
678
|
+
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([], appFolderLocation, false), ['api',
|
|
620
679
|
'sentry-example-api',
|
|
621
680
|
newRouteFileName], false))), "."));
|
|
622
681
|
return [3 /*break*/, 6];
|
|
623
682
|
case 3:
|
|
624
|
-
if (!
|
|
683
|
+
if (!pagesFolderLocation) return [3 /*break*/, 6];
|
|
625
684
|
examplePageContents = (0, templates_1.getSentryExamplePageContents)({
|
|
626
685
|
selfHosted: selfHosted,
|
|
627
686
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -629,18 +688,18 @@ function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
629
688
|
sentryUrl: sentryUrl,
|
|
630
689
|
useClient: false,
|
|
631
690
|
});
|
|
632
|
-
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
691
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], pagesFolderLocation, false), ['sentry-example-page.jsx'], false)), examplePageContents, { encoding: 'utf8', flag: 'w' })];
|
|
633
692
|
case 4:
|
|
634
693
|
_a.sent();
|
|
635
|
-
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([],
|
|
636
|
-
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
694
|
+
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([], pagesFolderLocation, false), ['sentry-example-page.js'], false))), "."));
|
|
695
|
+
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], pagesFolderLocation, false), ['api'], false)), {
|
|
637
696
|
recursive: true,
|
|
638
697
|
});
|
|
639
|
-
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()],
|
|
640
|
-
'sentry-example-api.js'], false)), (0, templates_1.
|
|
698
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], pagesFolderLocation, false), ['api',
|
|
699
|
+
'sentry-example-api.js'], false)), (0, templates_1.getSentryExamplePagesDirApiRoute)(), { encoding: 'utf8', flag: 'w' })];
|
|
641
700
|
case 5:
|
|
642
701
|
_a.sent();
|
|
643
|
-
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([],
|
|
702
|
+
prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan(path.join.apply(path, __spreadArray(__spreadArray([], pagesFolderLocation, false), ['api', 'sentry-example-api.js'], false))), "."));
|
|
644
703
|
_a.label = 6;
|
|
645
704
|
case 6: return [2 /*return*/];
|
|
646
705
|
}
|
|
@@ -662,7 +721,7 @@ function askShouldSetTunnelRoute() {
|
|
|
662
721
|
return __generator(this, function (_a) {
|
|
663
722
|
switch (_a.label) {
|
|
664
723
|
case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
665
|
-
message: 'Do you want to route Sentry requests in the browser through your
|
|
724
|
+
message: 'Do you want to route Sentry requests in the browser through your Next.js server to avoid ad blockers?',
|
|
666
725
|
options: [
|
|
667
726
|
{
|
|
668
727
|
label: 'Yes',
|
|
@@ -675,7 +734,7 @@ function askShouldSetTunnelRoute() {
|
|
|
675
734
|
hint: 'Browser errors and events might be blocked by ad blockers before being sent to Sentry',
|
|
676
735
|
},
|
|
677
736
|
],
|
|
678
|
-
initialValue:
|
|
737
|
+
initialValue: true,
|
|
679
738
|
}))];
|
|
680
739
|
case 1:
|
|
681
740
|
shouldSetTunnelRoute = _a.sent();
|
|
@@ -691,4 +750,40 @@ function askShouldSetTunnelRoute() {
|
|
|
691
750
|
});
|
|
692
751
|
});
|
|
693
752
|
}
|
|
753
|
+
function askShouldEnableReactComponentAnnotation() {
|
|
754
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
755
|
+
var _this = this;
|
|
756
|
+
return __generator(this, function (_a) {
|
|
757
|
+
switch (_a.label) {
|
|
758
|
+
case 0: return [4 /*yield*/, (0, telemetry_1.traceStep)('ask-react-component-annotation-option', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
759
|
+
var shouldEnableReactComponentAnnotation;
|
|
760
|
+
return __generator(this, function (_a) {
|
|
761
|
+
switch (_a.label) {
|
|
762
|
+
case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
763
|
+
message: 'Do you want to enable React component annotations to make breadcrumbs and session replays more readable?',
|
|
764
|
+
options: [
|
|
765
|
+
{
|
|
766
|
+
label: 'Yes',
|
|
767
|
+
value: true,
|
|
768
|
+
hint: 'Annotates React component names - increases bundle size',
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
label: 'No',
|
|
772
|
+
value: false,
|
|
773
|
+
hint: 'Continue without React component annotations',
|
|
774
|
+
},
|
|
775
|
+
],
|
|
776
|
+
initialValue: true,
|
|
777
|
+
}))];
|
|
778
|
+
case 1:
|
|
779
|
+
shouldEnableReactComponentAnnotation = _a.sent();
|
|
780
|
+
return [2 /*return*/, shouldEnableReactComponentAnnotation];
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
}); })];
|
|
784
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
}
|
|
694
789
|
//# sourceMappingURL=nextjs-wizard.js.map
|