@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,4 @@
|
|
|
1
|
-
import { SentryProjectData } from '../utils/
|
|
1
|
+
import { SentryProjectData } from '../utils/types';
|
|
2
2
|
export declare function updateXcodeProject(projectPath: string, sentryProject: SentryProjectData, apiKeys: {
|
|
3
3
|
token: string;
|
|
4
4
|
}, addSPMReference: boolean, uploadSource?: boolean): void;
|
|
@@ -24,6 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.updateXcodeProject = void 0;
|
|
27
|
+
/* eslint-disable max-lines */
|
|
28
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
29
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
30
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
27
32
|
var fs = __importStar(require("fs"));
|
|
28
33
|
var templates = __importStar(require("./templates"));
|
|
29
34
|
var xcode = require('xcode');
|
|
@@ -32,7 +37,7 @@ function setDebugInformationFormat(proj) {
|
|
|
32
37
|
var xcObjects = proj.hash.project.objects;
|
|
33
38
|
var target = proj.getFirstTarget().firstTarget;
|
|
34
39
|
xcObjects.XCConfigurationList[target.buildConfigurationList].buildConfigurations.forEach(function (buildConfig) {
|
|
35
|
-
xcObjects.XCBuildConfiguration[buildConfig.value].buildSettings.DEBUG_INFORMATION_FORMAT = "
|
|
40
|
+
xcObjects.XCBuildConfiguration[buildConfig.value].buildSettings.DEBUG_INFORMATION_FORMAT = '"dwarf-with-dsym"';
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
function addSentrySPM(proj) {
|
|
@@ -42,11 +47,11 @@ function addSentrySPM(proj) {
|
|
|
42
47
|
//Check whether xcObjects already have sentry framework
|
|
43
48
|
if (xcObjects.PBXFrameworksBuildPhase) {
|
|
44
49
|
for (var key in xcObjects.PBXFrameworksBuildPhase || {}) {
|
|
45
|
-
if (!key.endsWith(
|
|
50
|
+
if (!key.endsWith('_comment')) {
|
|
46
51
|
var frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
|
|
47
52
|
for (var _i = 0, frameworks_1 = frameworks; _i < frameworks_1.length; _i++) {
|
|
48
53
|
var framework = frameworks_1[_i];
|
|
49
|
-
if (framework.comment ===
|
|
54
|
+
if (framework.comment === 'Sentry in Frameworks') {
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
57
|
}
|
|
@@ -54,17 +59,18 @@ function addSentrySPM(proj) {
|
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
xcObjects.PBXBuildFile[sentryFrameworkUUID] = {
|
|
57
|
-
isa:
|
|
62
|
+
isa: 'PBXBuildFile',
|
|
58
63
|
productRef: sentrySPMUUID,
|
|
59
|
-
productRef_comment:
|
|
64
|
+
productRef_comment: 'Sentry',
|
|
60
65
|
};
|
|
61
|
-
xcObjects.PBXBuildFile[sentryFrameworkUUID +
|
|
66
|
+
xcObjects.PBXBuildFile[sentryFrameworkUUID + '_comment'] =
|
|
67
|
+
'Sentry in Frameworks';
|
|
62
68
|
for (var key in xcObjects.PBXFrameworksBuildPhase || {}) {
|
|
63
|
-
if (!key.endsWith(
|
|
69
|
+
if (!key.endsWith('_comment')) {
|
|
64
70
|
var frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
|
|
65
71
|
frameworks.push({
|
|
66
72
|
value: sentryFrameworkUUID,
|
|
67
|
-
comment:
|
|
73
|
+
comment: 'Sentry in Frameworks',
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
76
|
}
|
|
@@ -74,7 +80,7 @@ function addSentrySPM(proj) {
|
|
|
74
80
|
}
|
|
75
81
|
target.packageProductDependencies.push({
|
|
76
82
|
value: sentrySPMUUID,
|
|
77
|
-
comment:
|
|
83
|
+
comment: 'Sentry',
|
|
78
84
|
});
|
|
79
85
|
var sentrySwiftPackageUUID = proj.generateUuid();
|
|
80
86
|
var xcProject = proj.getFirstProject().firstProject;
|
|
@@ -83,38 +89,39 @@ function addSentrySPM(proj) {
|
|
|
83
89
|
}
|
|
84
90
|
xcProject.packageReferences.push({
|
|
85
91
|
value: sentrySwiftPackageUUID,
|
|
86
|
-
comment:
|
|
92
|
+
comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
|
|
87
93
|
});
|
|
88
94
|
xcObjects.XCRemoteSwiftPackageReference = {};
|
|
89
95
|
xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {
|
|
90
|
-
isa:
|
|
91
|
-
repositoryURL: "
|
|
96
|
+
isa: 'XCRemoteSwiftPackageReference',
|
|
97
|
+
repositoryURL: '"https://github.com/getsentry/sentry-cocoa/"',
|
|
92
98
|
requirement: {
|
|
93
|
-
kind:
|
|
94
|
-
minimumVersion:
|
|
95
|
-
}
|
|
99
|
+
kind: 'upToNextMajorVersion',
|
|
100
|
+
minimumVersion: '8.0.0',
|
|
101
|
+
},
|
|
96
102
|
};
|
|
97
|
-
xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID +
|
|
103
|
+
xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + '_comment'] =
|
|
104
|
+
'XCRemoteSwiftPackageReference "sentry-cocoa"';
|
|
98
105
|
xcObjects.XCSwiftPackageProductDependency = {};
|
|
99
|
-
xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {
|
|
107
|
+
isa: 'XCSwiftPackageProductDependency',
|
|
108
|
+
package: sentrySwiftPackageUUID,
|
|
109
|
+
package_comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
|
|
110
|
+
productName: 'Sentry',
|
|
111
|
+
};
|
|
112
|
+
xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + '_comment'] =
|
|
113
|
+
'Sentry';
|
|
107
114
|
}
|
|
108
115
|
function addUploadSymbolsScript(xcodeProject, sentryProject, apiKeys, uploadSource) {
|
|
109
116
|
if (uploadSource === void 0) { uploadSource = true; }
|
|
110
117
|
var xcObjects = xcodeProject.hash.project.objects;
|
|
111
118
|
for (var scriptKey in xcObjects.PBXShellScriptBuildPhase || {}) {
|
|
112
|
-
if (!scriptKey.endsWith(
|
|
119
|
+
if (!scriptKey.endsWith('_comment')) {
|
|
113
120
|
var script = xcObjects.PBXShellScriptBuildPhase[scriptKey].shellScript;
|
|
114
121
|
//Sentry script already exists, update it
|
|
115
|
-
if (script.includes(
|
|
122
|
+
if (script.includes('sentry-cli')) {
|
|
116
123
|
delete xcObjects.PBXShellScriptBuildPhase[scriptKey];
|
|
117
|
-
delete xcObjects.PBXShellScriptBuildPhase[scriptKey +
|
|
124
|
+
delete xcObjects.PBXShellScriptBuildPhase[scriptKey + '_comment'];
|
|
118
125
|
break;
|
|
119
126
|
}
|
|
120
127
|
}
|
|
@@ -124,7 +131,7 @@ function addUploadSymbolsScript(xcodeProject, sentryProject, apiKeys, uploadSour
|
|
|
124
131
|
outputFileListPaths: [],
|
|
125
132
|
inputPaths: [templates.scriptInputPath],
|
|
126
133
|
shellPath: '/bin/sh',
|
|
127
|
-
shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, apiKeys.token, uploadSource)
|
|
134
|
+
shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, apiKeys.token, uploadSource),
|
|
128
135
|
});
|
|
129
136
|
}
|
|
130
137
|
function updateXcodeProject(projectPath, sentryProject, apiKeys, addSPMReference, uploadSource) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,sDAAsD;AACtD,qCAAyB;AAEzB,qDAAyC;AACzC,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,qDAAqD;AAErD,SAAS,yBAAyB,CAAC,IAAS;IAC1C,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,WAAW,CAAC;IAEjD,SAAS,CAAC,mBAAmB,CAC3B,MAAM,CAAC,sBAAsB,CAC9B,CAAC,mBAAmB,CAAC,OAAO,CAAC,UAAC,WAA8B;QAC3D,SAAS,CAAC,oBAAoB,CAC5B,WAAW,CAAC,KAAK,CAClB,CAAC,aAAa,CAAC,wBAAwB,GAAG,mBAAmB,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,IAAS;IAC7B,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAE5C,IAAM,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAY,CAAC;IAC1D,IAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EA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;IACpC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC5C,CAAC;AAlBD,gDAkBC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport * as fs from 'fs';\nimport { SentryProjectData } from '../utils/types';\nimport * as templates from './templates';\nconst xcode = require('xcode');\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nfunction setDebugInformationFormat(proj: any): void {\n const xcObjects = proj.hash.project.objects;\n const target = proj.getFirstTarget().firstTarget;\n\n xcObjects.XCConfigurationList[\n target.buildConfigurationList\n ].buildConfigurations.forEach((buildConfig: { value: string }) => {\n xcObjects.XCBuildConfiguration[\n buildConfig.value\n ].buildSettings.DEBUG_INFORMATION_FORMAT = '\"dwarf-with-dsym\"';\n });\n}\n\nfunction addSentrySPM(proj: any): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid() as string;\n const sentrySPMUUID = proj.generateUuid() as string;\n\n //Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n if (!key.endsWith('_comment')) {\n const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;\n for (const framework of frameworks) {\n if (framework.comment === 'Sentry in Frameworks') {\n return;\n }\n }\n }\n }\n }\n\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: 'PBXBuildFile',\n productRef: sentrySPMUUID,\n productRef_comment: 'Sentry',\n };\n xcObjects.PBXBuildFile[sentryFrameworkUUID + '_comment'] =\n 'Sentry in Frameworks';\n\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n if (!key.endsWith('_comment')) {\n const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: 'Sentry in Frameworks',\n });\n }\n }\n\n const target = proj.getFirstTarget().firstTarget;\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: 'Sentry',\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid() as string;\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n });\n\n xcObjects.XCRemoteSwiftPackageReference = {};\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: 'XCRemoteSwiftPackageReference',\n repositoryURL: '\"https://github.com/getsentry/sentry-cocoa/\"',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '8.0.0',\n },\n };\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + '_comment'] =\n 'XCRemoteSwiftPackageReference \"sentry-cocoa\"';\n\n xcObjects.XCSwiftPackageProductDependency = {};\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {\n isa: 'XCSwiftPackageProductDependency',\n package: sentrySwiftPackageUUID,\n package_comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n productName: 'Sentry',\n };\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + '_comment'] =\n 'Sentry';\n}\n\nfunction addUploadSymbolsScript(\n xcodeProject: any,\n sentryProject: SentryProjectData,\n apiKeys: { token: string },\n uploadSource = true,\n): void {\n const xcObjects = xcodeProject.hash.project.objects;\n\n for (const scriptKey in xcObjects.PBXShellScriptBuildPhase || {}) {\n if (!scriptKey.endsWith('_comment')) {\n const script = xcObjects.PBXShellScriptBuildPhase[scriptKey].shellScript;\n //Sentry script already exists, update it\n if (script.includes('sentry-cli')) {\n delete xcObjects.PBXShellScriptBuildPhase[scriptKey];\n delete xcObjects.PBXShellScriptBuildPhase[scriptKey + '_comment'];\n break;\n }\n }\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(\n sentryProject.organization.slug,\n sentryProject.slug,\n apiKeys.token,\n uploadSource,\n ),\n },\n );\n}\n\nexport function updateXcodeProject(\n projectPath: string,\n sentryProject: SentryProjectData,\n apiKeys: { token: string },\n addSPMReference: boolean,\n uploadSource = true,\n): void {\n const proj = xcode.project(projectPath);\n proj.parseSync();\n addUploadSymbolsScript(proj, sentryProject, apiKeys, uploadSource);\n if (uploadSource) {\n setDebugInformationFormat(proj);\n }\n if (addSPMReference) {\n addSentrySPM(proj);\n }\n const newContent = proj.writeSync();\n fs.writeFileSync(projectPath, newContent);\n}\n"]}
|
|
@@ -86,9 +86,9 @@ var templates_1 = require("./templates");
|
|
|
86
86
|
function runNextjsWizard(options) {
|
|
87
87
|
var _a;
|
|
88
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
var packageJson, _b,
|
|
90
|
-
return __generator(this, function (
|
|
91
|
-
switch (
|
|
89
|
+
var packageJson, _b, selectedProject, authToken, selfHosted, sentryUrl, typeScriptDetected, configVariants, _i, configVariants_1, configVariant, jsConfig, tsConfig, jsConfigExists, tsConfigExists, shouldWriteFile, existingConfigs, overwriteExistingConfigs, sentryWebpackOptionsTemplate, sentryBuildOptionsTemplate, nextConfigJs, nextConfigMjs, nextConfigJsExists, nextConfigMjsExists, nextConfgiJsContent, probablyIncludesSdk, shouldInject, injectAnyhow, nextConfgiMjsContent, probablyIncludesSdk, shouldInject, injectAnyhow, mod, expressionToWrap, newCode, _c, shouldContinue, maybePagesDirPath, maybeSrcPagesDirPath, pagesLocation, examplePageContents, mightBeUsingVercel;
|
|
90
|
+
return __generator(this, function (_d) {
|
|
91
|
+
switch (_d.label) {
|
|
92
92
|
case 0:
|
|
93
93
|
(0, clack_utils_1.printWelcome)({
|
|
94
94
|
wizardName: 'Sentry Next.js Wizard',
|
|
@@ -96,45 +96,35 @@ function runNextjsWizard(options) {
|
|
|
96
96
|
});
|
|
97
97
|
return [4 /*yield*/, (0, clack_utils_1.confirmContinueEvenThoughNoGitRepo)()];
|
|
98
98
|
case 1:
|
|
99
|
-
|
|
99
|
+
_d.sent();
|
|
100
100
|
return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
|
|
101
101
|
case 2:
|
|
102
|
-
packageJson =
|
|
102
|
+
packageJson = _d.sent();
|
|
103
103
|
return [4 /*yield*/, (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, 'next', 'Next.js')];
|
|
104
104
|
case 3:
|
|
105
|
-
|
|
106
|
-
return [4 /*yield*/, (0, clack_utils_1.
|
|
105
|
+
_d.sent();
|
|
106
|
+
return [4 /*yield*/, (0, clack_utils_1.getOrAskForProjectData)(options)];
|
|
107
107
|
case 4:
|
|
108
|
-
_b =
|
|
109
|
-
return [4 /*yield*/, (0, clack_utils_1.askForWizardLogin)({
|
|
110
|
-
promoCode: options.promoCode,
|
|
111
|
-
url: sentryUrl,
|
|
112
|
-
platform: 'javascript-nextjs',
|
|
113
|
-
})];
|
|
114
|
-
case 5:
|
|
115
|
-
_c = _e.sent(), projects = _c.projects, apiKeys = _c.apiKeys;
|
|
116
|
-
return [4 /*yield*/, (0, clack_utils_1.askForProjectSelection)(projects)];
|
|
117
|
-
case 6:
|
|
118
|
-
selectedProject = _e.sent();
|
|
108
|
+
_b = _d.sent(), selectedProject = _b.selectedProject, authToken = _b.authToken, selfHosted = _b.selfHosted, sentryUrl = _b.sentryUrl;
|
|
119
109
|
return [4 /*yield*/, (0, clack_utils_1.installPackage)({
|
|
120
110
|
packageName: '@sentry/nextjs',
|
|
121
111
|
alreadyInstalled: !!((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['@sentry/nextjs']),
|
|
122
112
|
})];
|
|
123
|
-
case
|
|
124
|
-
|
|
113
|
+
case 5:
|
|
114
|
+
_d.sent();
|
|
125
115
|
typeScriptDetected = (0, clack_utils_1.isUsingTypeScript)();
|
|
126
116
|
configVariants = ['server', 'client', 'edge'];
|
|
127
117
|
_i = 0, configVariants_1 = configVariants;
|
|
128
|
-
|
|
129
|
-
case
|
|
130
|
-
if (!(_i < configVariants_1.length)) return [3 /*break*/,
|
|
118
|
+
_d.label = 6;
|
|
119
|
+
case 6:
|
|
120
|
+
if (!(_i < configVariants_1.length)) return [3 /*break*/, 11];
|
|
131
121
|
configVariant = configVariants_1[_i];
|
|
132
122
|
jsConfig = "sentry.".concat(configVariant, ".config.js");
|
|
133
123
|
tsConfig = "sentry.".concat(configVariant, ".config.ts");
|
|
134
124
|
jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));
|
|
135
125
|
tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));
|
|
136
126
|
shouldWriteFile = true;
|
|
137
|
-
if (!(jsConfigExists || tsConfigExists)) return [3 /*break*/,
|
|
127
|
+
if (!(jsConfigExists || tsConfigExists)) return [3 /*break*/, 8];
|
|
138
128
|
existingConfigs = [];
|
|
139
129
|
if (jsConfigExists) {
|
|
140
130
|
existingConfigs.push(jsConfig);
|
|
@@ -145,8 +135,8 @@ function runNextjsWizard(options) {
|
|
|
145
135
|
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
146
136
|
message: "Found existing Sentry ".concat(configVariant, " config (").concat(existingConfigs.join(', '), "). Overwrite ").concat(existingConfigs.length > 1 ? 'them' : 'it', "?"),
|
|
147
137
|
}))];
|
|
148
|
-
case
|
|
149
|
-
overwriteExistingConfigs =
|
|
138
|
+
case 7:
|
|
139
|
+
overwriteExistingConfigs = _d.sent();
|
|
150
140
|
shouldWriteFile = overwriteExistingConfigs;
|
|
151
141
|
if (overwriteExistingConfigs) {
|
|
152
142
|
if (jsConfigExists) {
|
|
@@ -158,68 +148,68 @@ function runNextjsWizard(options) {
|
|
|
158
148
|
prompts_1.default.log.warn("Removed existing ".concat(chalk_1.default.bold(tsConfig), "."));
|
|
159
149
|
}
|
|
160
150
|
}
|
|
161
|
-
|
|
162
|
-
case
|
|
163
|
-
if (!shouldWriteFile) return [3 /*break*/,
|
|
151
|
+
_d.label = 8;
|
|
152
|
+
case 8:
|
|
153
|
+
if (!shouldWriteFile) return [3 /*break*/, 10];
|
|
164
154
|
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' })];
|
|
165
|
-
case
|
|
166
|
-
|
|
155
|
+
case 9:
|
|
156
|
+
_d.sent();
|
|
167
157
|
prompts_1.default.log.success("Created fresh ".concat(chalk_1.default.bold(typeScriptDetected ? tsConfig : jsConfig), "."));
|
|
168
|
-
|
|
169
|
-
case
|
|
158
|
+
_d.label = 10;
|
|
159
|
+
case 10:
|
|
170
160
|
_i++;
|
|
171
|
-
return [3 /*break*/,
|
|
172
|
-
case
|
|
161
|
+
return [3 /*break*/, 6];
|
|
162
|
+
case 11:
|
|
173
163
|
sentryWebpackOptionsTemplate = (0, templates_1.getNextjsWebpackPluginOptionsTemplate)(selectedProject.organization.slug, selectedProject.slug);
|
|
174
164
|
sentryBuildOptionsTemplate = (0, templates_1.getNextjsSentryBuildOptionsTemplate)();
|
|
175
165
|
nextConfigJs = 'next.config.js';
|
|
176
166
|
nextConfigMjs = 'next.config.mjs';
|
|
177
167
|
nextConfigJsExists = fs.existsSync(path.join(process.cwd(), nextConfigJs));
|
|
178
168
|
nextConfigMjsExists = fs.existsSync(path.join(process.cwd(), nextConfigMjs));
|
|
179
|
-
if (!(!nextConfigJsExists && !nextConfigMjsExists)) return [3 /*break*/,
|
|
169
|
+
if (!(!nextConfigJsExists && !nextConfigMjsExists)) return [3 /*break*/, 13];
|
|
180
170
|
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), nextConfigJs), (0, templates_1.getNextjsConfigCjsTemplate)(sentryWebpackOptionsTemplate, sentryBuildOptionsTemplate), { encoding: 'utf8', flag: 'w' })];
|
|
181
|
-
case
|
|
182
|
-
|
|
171
|
+
case 12:
|
|
172
|
+
_d.sent();
|
|
183
173
|
prompts_1.default.log.success("Created ".concat(chalk_1.default.bold('next.config.js'), " with Sentry configuration."));
|
|
184
|
-
|
|
185
|
-
case
|
|
186
|
-
if (!nextConfigJsExists) return [3 /*break*/,
|
|
174
|
+
_d.label = 13;
|
|
175
|
+
case 13:
|
|
176
|
+
if (!nextConfigJsExists) return [3 /*break*/, 17];
|
|
187
177
|
nextConfgiJsContent = fs.readFileSync(path.join(process.cwd(), nextConfigJs), 'utf8');
|
|
188
178
|
probablyIncludesSdk = nextConfgiJsContent.includes('@sentry/nextjs') &&
|
|
189
179
|
nextConfgiJsContent.includes('withSentryConfig');
|
|
190
180
|
shouldInject = true;
|
|
191
|
-
if (!probablyIncludesSdk) return [3 /*break*/,
|
|
181
|
+
if (!probablyIncludesSdk) return [3 /*break*/, 15];
|
|
192
182
|
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
193
183
|
message: "".concat(chalk_1.default.bold(nextConfigJs), " already contains Sentry SDK configuration. Should the wizard modify it anyways?"),
|
|
194
184
|
}))];
|
|
195
|
-
case
|
|
196
|
-
injectAnyhow =
|
|
185
|
+
case 14:
|
|
186
|
+
injectAnyhow = _d.sent();
|
|
197
187
|
shouldInject = injectAnyhow;
|
|
198
|
-
|
|
199
|
-
case
|
|
200
|
-
if (!shouldInject) return [3 /*break*/,
|
|
188
|
+
_d.label = 15;
|
|
189
|
+
case 15:
|
|
190
|
+
if (!shouldInject) return [3 /*break*/, 17];
|
|
201
191
|
return [4 /*yield*/, fs.promises.appendFile(path.join(process.cwd(), nextConfigJs), (0, templates_1.getNextjsConfigCjsAppendix)(sentryWebpackOptionsTemplate, sentryBuildOptionsTemplate), 'utf8')];
|
|
202
|
-
case
|
|
203
|
-
|
|
192
|
+
case 16:
|
|
193
|
+
_d.sent();
|
|
204
194
|
prompts_1.default.log.success("Added Sentry configuration to ".concat(chalk_1.default.bold(nextConfigJs), ". ").concat(chalk_1.default.dim('(you probably want to clean this up a bit!)')));
|
|
205
|
-
|
|
206
|
-
case
|
|
207
|
-
if (!nextConfigMjsExists) return [3 /*break*/,
|
|
195
|
+
_d.label = 17;
|
|
196
|
+
case 17:
|
|
197
|
+
if (!nextConfigMjsExists) return [3 /*break*/, 26];
|
|
208
198
|
nextConfgiMjsContent = fs.readFileSync(path.join(process.cwd(), nextConfigMjs), 'utf8');
|
|
209
199
|
probablyIncludesSdk = nextConfgiMjsContent.includes('@sentry/nextjs') &&
|
|
210
200
|
nextConfgiMjsContent.includes('withSentryConfig');
|
|
211
201
|
shouldInject = true;
|
|
212
|
-
if (!probablyIncludesSdk) return [3 /*break*/,
|
|
202
|
+
if (!probablyIncludesSdk) return [3 /*break*/, 19];
|
|
213
203
|
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
214
204
|
message: "".concat(chalk_1.default.bold(nextConfigMjs), " already contains Sentry SDK configuration. Should the wizard modify it anyways?"),
|
|
215
205
|
}))];
|
|
216
|
-
case
|
|
217
|
-
injectAnyhow =
|
|
206
|
+
case 18:
|
|
207
|
+
injectAnyhow = _d.sent();
|
|
218
208
|
shouldInject = injectAnyhow;
|
|
219
|
-
|
|
220
|
-
case
|
|
221
|
-
|
|
222
|
-
if (!shouldInject) return [3 /*break*/,
|
|
209
|
+
_d.label = 19;
|
|
210
|
+
case 19:
|
|
211
|
+
_d.trys.push([19, 22, , 26]);
|
|
212
|
+
if (!shouldInject) return [3 /*break*/, 21];
|
|
223
213
|
mod = (0, magicast_1.parseModule)(nextConfgiMjsContent);
|
|
224
214
|
mod.imports.$add({
|
|
225
215
|
from: '@sentry/nextjs',
|
|
@@ -234,13 +224,13 @@ function runNextjsWizard(options) {
|
|
|
234
224
|
encoding: 'utf8',
|
|
235
225
|
flag: 'w',
|
|
236
226
|
})];
|
|
237
|
-
case
|
|
238
|
-
|
|
227
|
+
case 20:
|
|
228
|
+
_d.sent();
|
|
239
229
|
prompts_1.default.log.success("Added Sentry configuration to ".concat(chalk_1.default.bold(nextConfigMjs), ". ").concat(chalk_1.default.dim('(you probably want to clean this up a bit!)')));
|
|
240
|
-
|
|
241
|
-
case
|
|
242
|
-
case
|
|
243
|
-
|
|
230
|
+
_d.label = 21;
|
|
231
|
+
case 21: return [3 /*break*/, 26];
|
|
232
|
+
case 22:
|
|
233
|
+
_c = _d.sent();
|
|
244
234
|
prompts_1.default.log.warn(chalk_1.default.yellow("Something went wrong writing to ".concat(chalk_1.default.bold(nextConfigMjs))));
|
|
245
235
|
prompts_1.default.log.info("Please put the following code snippet into ".concat(chalk_1.default.bold(nextConfigMjs), ": ").concat(chalk_1.default.dim('You probably have to clean it up a bit.'), "\n"));
|
|
246
236
|
// eslint-disable-next-line no-console
|
|
@@ -250,15 +240,15 @@ function runNextjsWizard(options) {
|
|
|
250
240
|
active: 'Yes',
|
|
251
241
|
inactive: 'No, get me out of here',
|
|
252
242
|
}))];
|
|
253
|
-
case
|
|
254
|
-
shouldContinue =
|
|
255
|
-
if (!!shouldContinue) return [3 /*break*/,
|
|
243
|
+
case 23:
|
|
244
|
+
shouldContinue = _d.sent();
|
|
245
|
+
if (!!shouldContinue) return [3 /*break*/, 25];
|
|
256
246
|
return [4 /*yield*/, (0, clack_utils_1.abort)()];
|
|
247
|
+
case 24:
|
|
248
|
+
_d.sent();
|
|
249
|
+
_d.label = 25;
|
|
250
|
+
case 25: return [3 /*break*/, 26];
|
|
257
251
|
case 26:
|
|
258
|
-
_e.sent();
|
|
259
|
-
_e.label = 27;
|
|
260
|
-
case 27: return [3 /*break*/, 28];
|
|
261
|
-
case 28:
|
|
262
252
|
maybePagesDirPath = path.join(process.cwd(), 'pages');
|
|
263
253
|
maybeSrcPagesDirPath = path.join(process.cwd(), 'src', 'pages');
|
|
264
254
|
pagesLocation = fs.existsSync(maybePagesDirPath) &&
|
|
@@ -274,7 +264,7 @@ function runNextjsWizard(options) {
|
|
|
274
264
|
recursive: true,
|
|
275
265
|
});
|
|
276
266
|
}
|
|
277
|
-
if (!pagesLocation) return [3 /*break*/,
|
|
267
|
+
if (!pagesLocation) return [3 /*break*/, 29];
|
|
278
268
|
examplePageContents = (0, templates_1.getSentryExamplePageContents)({
|
|
279
269
|
selfHosted: selfHosted,
|
|
280
270
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -282,21 +272,21 @@ function runNextjsWizard(options) {
|
|
|
282
272
|
url: sentryUrl,
|
|
283
273
|
});
|
|
284
274
|
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], pagesLocation, false), ['sentry-example-page.js'], false)), examplePageContents, { encoding: 'utf8', flag: 'w' })];
|
|
285
|
-
case
|
|
286
|
-
|
|
275
|
+
case 27:
|
|
276
|
+
_d.sent();
|
|
287
277
|
prompts_1.default.log.success("Created ".concat(chalk_1.default.bold(path.join.apply(path, __spreadArray(__spreadArray([], pagesLocation, false), ['sentry-example-page.js'], false))), "."));
|
|
288
278
|
fs.mkdirSync(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], pagesLocation, false), ['api'], false)), {
|
|
289
279
|
recursive: true,
|
|
290
280
|
});
|
|
291
281
|
return [4 /*yield*/, fs.promises.writeFile(path.join.apply(path, __spreadArray(__spreadArray([process.cwd()], pagesLocation, false), ['api',
|
|
292
282
|
'sentry-example-api.js'], false)), (0, templates_1.getSentryExampleApiRoute)(), { encoding: 'utf8', flag: 'w' })];
|
|
293
|
-
case
|
|
294
|
-
|
|
283
|
+
case 28:
|
|
284
|
+
_d.sent();
|
|
295
285
|
prompts_1.default.log.success("Created ".concat(chalk_1.default.bold(path.join.apply(path, __spreadArray(__spreadArray([], pagesLocation, false), ['api', 'sentry-example-api.js'], false))), "."));
|
|
296
|
-
|
|
297
|
-
case
|
|
298
|
-
case
|
|
299
|
-
|
|
286
|
+
_d.label = 29;
|
|
287
|
+
case 29: return [4 /*yield*/, (0, clack_utils_1.addSentryCliRc)(authToken)];
|
|
288
|
+
case 30:
|
|
289
|
+
_d.sent();
|
|
300
290
|
mightBeUsingVercel = fs.existsSync(path.join(process.cwd(), 'vercel.json'));
|
|
301
291
|
prompts_1.default.outro("".concat(chalk_1.default.green('Everything is set up!'), "\n\n ").concat(chalk_1.default.cyan('You can validate your setup by starting your dev environment (`next dev`) and visiting "/sentry-example-page".'), "\n").concat(mightBeUsingVercel
|
|
302
292
|
? "\n \u25B2 It seems like you're using Vercel. We recommend using the Sentry Vercel integration: https://vercel.com/integrations/sentry\n"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-wizard.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,qCAAyB;AACzB,4EAA4E;AAC5E,qCAA+D;AAC/D,yCAA6B;AAE7B,oDAa8B;AAE9B,yCASqB;AAErB,sCAAsC;AACtC,SAAsB,eAAe,CAAC,OAAsB;;;;;;;oBAC1D,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,uBAAuB;wBACnC,SAAS,EAAE,OAAO,CAAC,SAAS;qBAC7B,CAAC,CAAC;oBAEH,qBAAM,IAAA,gDAAkC,GAAE,EAAA;;oBAA1C,SAA0C,CAAC;oBAEvB,qBAAM,IAAA,+BAAiB,GAAE,EAAA;;oBAAvC,WAAW,GAAG,SAAyB;oBAC7C,qBAAM,IAAA,sCAAwB,EAAC,WAAW,EAAE,M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AAC;oBAEH,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,OAAT,IAAI,+BACF,OAAO,CAAC,GAAG,EAAE,GACV,aAAa,WAChB,KAAK;4BACL,uBAAuB,YAEzB,IAAA,oCAAwB,GAAE,EAC1B,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAChC,EAAA;;oBATD,SASC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,kBAAW,eAAK,CAAC,IAAI,CACnB,IAAI,CAAC,IAAI,OAAT,IAAI,kCAAS,aAAa,WAAE,KAAK,EAAE,uBAAuB,WAC3D,MAAG,CACL,CAAC;;yBAGJ,qBAAM,IAAA,4BAAc,EAAC,OAAO,CAAC,KAAK,CAAC,EAAA;;oBAAnC,SAAmC,CAAC;oBAE9B,kBAAkB,GAAG,EAAE,CAAC,UAAU,CACtC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CACxC,CAAC;oBAEF,iBAAK,CAAC,KAAK,CACT,UAAG,eAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,oBAEtC,eAAK,CAAC,IAAI,CACV,gHAAgH,CACjH,eAEF,kBAAkB;wBAChB,CAAC,CAAC,2IAEL;wBACG,CAAC,CAAC,EAAE,kBAEH,eAAK,CAAC,GAAG,CACT,sGAAsG,CACvG,CAAE,CACH,CAAC;;;;;CACH;AAlVD,0CAkVC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, parseModule } from 'magicast';\nimport * as path from 'path';\n\nimport {\n abort,\n abortIfCancelled,\n addSentryCliRc,\n askForProjectSelection,\n askForSelfHosted,\n askForWizardLogin,\n confirmContinueEvenThoughNoGitRepo,\n ensurePackageIsInstalled,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n} from '../utils/clack-utils';\nimport { WizardOptions } from '../utils/types';\nimport {\n getNextjsConfigCjsAppendix,\n getNextjsConfigCjsTemplate,\n getNextjsConfigEsmCopyPasteSnippet,\n getNextjsSentryBuildOptionsTemplate,\n getNextjsWebpackPluginOptionsTemplate,\n getSentryConfigContents,\n getSentryExampleApiRoute,\n getSentryExamplePageContents,\n} from './templates';\n\n// eslint-disable-next-line complexity\nexport async function runNextjsWizard(options: WizardOptions): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Next.js Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueEvenThoughNoGitRepo();\n\n const packageJson = await getPackageDotJson();\n await ensurePackageIsInstalled(packageJson, 'next', 'Next.js');\n\n const { url: sentryUrl, selfHosted } = await askForSelfHosted(options.url);\n\n const { projects, apiKeys } = await askForWizardLogin({\n promoCode: options.promoCode,\n url: sentryUrl,\n platform: 'javascript-nextjs',\n });\n\n const selectedProject = await askForProjectSelection(projects);\n\n await installPackage({\n packageName: '@sentry/nextjs',\n alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],\n });\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client', 'edge'] as const;\n\n for (const configVariant of configVariants) {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.bold(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.bold(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(\n selectedProject.keys[0].dsn.public,\n configVariant,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created fresh ${chalk.bold(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n }\n }\n\n const sentryWebpackOptionsTemplate = getNextjsWebpackPluginOptionsTemplate(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n const sentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate();\n\n const nextConfigJs = 'next.config.js';\n const nextConfigMjs = 'next.config.mjs';\n\n const nextConfigJsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigJs),\n );\n const nextConfigMjsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigMjs),\n );\n\n if (!nextConfigJsExists && !nextConfigMjsExists) {\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsTemplate(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.bold('next.config.js')} with Sentry configuration.`,\n );\n }\n\n if (nextConfigJsExists) {\n const nextConfgiJsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigJs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfgiJsContent.includes('@sentry/nextjs') &&\n nextConfgiJsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.bold(\n nextConfigJs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n if (shouldInject) {\n await fs.promises.appendFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsAppendix(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n 'utf8',\n );\n\n clack.log.success(\n `Added Sentry configuration to ${chalk.bold(nextConfigJs)}. ${chalk.dim(\n '(you probably want to clean this up a bit!)',\n )}`,\n );\n }\n }\n\n if (nextConfigMjsExists) {\n const nextConfgiMjsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigMjs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfgiMjsContent.includes('@sentry/nextjs') &&\n nextConfgiMjsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.bold(\n nextConfigMjs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n try {\n if (shouldInject) {\n const mod = parseModule(nextConfgiMjsContent);\n mod.imports.$add({\n from: '@sentry/nextjs',\n imported: 'withSentryConfig',\n local: 'withSentryConfig',\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n const expressionToWrap = generateCode(mod.exports.default.$ast).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.default = builders.raw(`withSentryConfig(\n ${expressionToWrap},\n ${sentryWebpackOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n)`);\n const newCode = mod.generate().code;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigMjs),\n newCode,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(\n `Added Sentry configuration to ${chalk.bold(\n nextConfigMjs,\n )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`,\n );\n }\n } catch {\n clack.log.warn(\n chalk.yellow(\n `Something went wrong writing to ${chalk.bold(nextConfigMjs)}`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.bold(\n nextConfigMjs,\n )}: ${chalk.dim('You probably have to clean it up a bit.')}\\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Are you done putting the snippet above into ${chalk.bold(\n nextConfigMjs,\n )}?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n }\n\n const maybePagesDirPath = path.join(process.cwd(), 'pages');\n const maybeSrcPagesDirPath = path.join(process.cwd(), 'src', 'pages');\n\n let pagesLocation =\n fs.existsSync(maybePagesDirPath) &&\n fs.lstatSync(maybePagesDirPath).isDirectory()\n ? ['pages']\n : fs.existsSync(maybeSrcPagesDirPath) &&\n fs.lstatSync(maybeSrcPagesDirPath).isDirectory()\n ? ['src', 'pages']\n : undefined;\n\n if (!pagesLocation) {\n pagesLocation = ['pages'];\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation), {\n recursive: true,\n });\n }\n\n if (pagesLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, 'sentry-example-page.js'),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.bold(\n path.join(...pagesLocation, 'sentry-example-page.js'),\n )}.`,\n );\n\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation, 'api'), {\n recursive: true,\n });\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...pagesLocation,\n 'api',\n 'sentry-example-api.js',\n ),\n getSentryExampleApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.bold(\n path.join(...pagesLocation, 'api', 'sentry-example-api.js'),\n )}.`,\n );\n }\n\n await addSentryCliRc(apiKeys.token);\n\n const mightBeUsingVercel = fs.existsSync(\n path.join(process.cwd(), 'vercel.json'),\n );\n\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.cyan(\n 'You can validate your setup by starting your dev environment (`next dev`) and visiting \"/sentry-example-page\".',\n )}\n${\n mightBeUsingVercel\n ? `\n ▲ It seems like you're using Vercel. We recommend using the Sentry Vercel integration: https://vercel.com/integrations/sentry\n`\n : ''\n}\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-javascript/issues',\n )}`,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nextjs-wizard.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,qCAAyB;AACzB,4EAA4E;AAC5E,qCAA+D;AAC/D,yCAA6B;AAE7B,oDAW8B;AAE9B,yCASqB;AAErB,sCAAsC;AACtC,SAAsB,eAAe,CAAC,OAAsB;;;;;;;oBAC1D,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,uBAAuB;wBACnC,SAAS,EAAE,OAAO,CAAC,SAAS;qBAC7B,CAAC,CAAC;oBAEH,qBAAM,IAAA,gDAAkC,GAAE,EAAA;;oBAA1C,SAA0C,CAAC;oBAEvB,qBAAM,IAAA,+BAAiB,GAAE,EAAA;;oBAAvC,WAAW,GAAG,SAAyB;oBAC7C,qBAAM,IA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AG,EAAE,CAChC,EAAA;;oBATD,SASC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,kBAAW,eAAK,CAAC,IAAI,CACnB,IAAI,CAAC,IAAI,OAAT,IAAI,kCAAS,aAAa,WAAE,KAAK,EAAE,uBAAuB,WAC3D,MAAG,CACL,CAAC;;yBAGJ,qBAAM,IAAA,4BAAc,EAAC,SAAS,CAAC,EAAA;;oBAA/B,SAA+B,CAAC;oBAE1B,kBAAkB,GAAG,EAAE,CAAC,UAAU,CACtC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CACxC,CAAC;oBAEF,iBAAK,CAAC,KAAK,CACT,UAAG,eAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,oBAEtC,eAAK,CAAC,IAAI,CACV,gHAAgH,CACjH,eAEF,kBAAkB;wBAChB,CAAC,CAAC,2IAEL;wBACG,CAAC,CAAC,EAAE,kBAEH,eAAK,CAAC,GAAG,CACT,sGAAsG,CACvG,CAAE,CACH,CAAC;;;;;CACH;AA3UD,0CA2UC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, parseModule } from 'magicast';\nimport * as path from 'path';\n\nimport {\n abort,\n abortIfCancelled,\n addSentryCliRc,\n confirmContinueEvenThoughNoGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n} from '../utils/clack-utils';\nimport { WizardOptions } from '../utils/types';\nimport {\n getNextjsConfigCjsAppendix,\n getNextjsConfigCjsTemplate,\n getNextjsConfigEsmCopyPasteSnippet,\n getNextjsSentryBuildOptionsTemplate,\n getNextjsWebpackPluginOptionsTemplate,\n getSentryConfigContents,\n getSentryExampleApiRoute,\n getSentryExamplePageContents,\n} from './templates';\n\n// eslint-disable-next-line complexity\nexport async function runNextjsWizard(options: WizardOptions): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Next.js Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueEvenThoughNoGitRepo();\n\n const packageJson = await getPackageDotJson();\n await ensurePackageIsInstalled(packageJson, 'next', 'Next.js');\n\n const { selectedProject, authToken, selfHosted, sentryUrl } =\n await getOrAskForProjectData(options);\n\n await installPackage({\n packageName: '@sentry/nextjs',\n alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],\n });\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client', 'edge'] as const;\n\n for (const configVariant of configVariants) {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.bold(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.bold(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(\n selectedProject.keys[0].dsn.public,\n configVariant,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created fresh ${chalk.bold(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n }\n }\n\n const sentryWebpackOptionsTemplate = getNextjsWebpackPluginOptionsTemplate(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n const sentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate();\n\n const nextConfigJs = 'next.config.js';\n const nextConfigMjs = 'next.config.mjs';\n\n const nextConfigJsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigJs),\n );\n const nextConfigMjsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigMjs),\n );\n\n if (!nextConfigJsExists && !nextConfigMjsExists) {\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsTemplate(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.bold('next.config.js')} with Sentry configuration.`,\n );\n }\n\n if (nextConfigJsExists) {\n const nextConfgiJsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigJs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfgiJsContent.includes('@sentry/nextjs') &&\n nextConfgiJsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.bold(\n nextConfigJs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n if (shouldInject) {\n await fs.promises.appendFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsAppendix(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n 'utf8',\n );\n\n clack.log.success(\n `Added Sentry configuration to ${chalk.bold(nextConfigJs)}. ${chalk.dim(\n '(you probably want to clean this up a bit!)',\n )}`,\n );\n }\n }\n\n if (nextConfigMjsExists) {\n const nextConfgiMjsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigMjs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfgiMjsContent.includes('@sentry/nextjs') &&\n nextConfgiMjsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.bold(\n nextConfigMjs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n try {\n if (shouldInject) {\n const mod = parseModule(nextConfgiMjsContent);\n mod.imports.$add({\n from: '@sentry/nextjs',\n imported: 'withSentryConfig',\n local: 'withSentryConfig',\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n const expressionToWrap = generateCode(mod.exports.default.$ast).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.default = builders.raw(`withSentryConfig(\n ${expressionToWrap},\n ${sentryWebpackOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n)`);\n const newCode = mod.generate().code;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigMjs),\n newCode,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(\n `Added Sentry configuration to ${chalk.bold(\n nextConfigMjs,\n )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`,\n );\n }\n } catch {\n clack.log.warn(\n chalk.yellow(\n `Something went wrong writing to ${chalk.bold(nextConfigMjs)}`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.bold(\n nextConfigMjs,\n )}: ${chalk.dim('You probably have to clean it up a bit.')}\\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Are you done putting the snippet above into ${chalk.bold(\n nextConfigMjs,\n )}?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n }\n\n const maybePagesDirPath = path.join(process.cwd(), 'pages');\n const maybeSrcPagesDirPath = path.join(process.cwd(), 'src', 'pages');\n\n let pagesLocation =\n fs.existsSync(maybePagesDirPath) &&\n fs.lstatSync(maybePagesDirPath).isDirectory()\n ? ['pages']\n : fs.existsSync(maybeSrcPagesDirPath) &&\n fs.lstatSync(maybeSrcPagesDirPath).isDirectory()\n ? ['src', 'pages']\n : undefined;\n\n if (!pagesLocation) {\n pagesLocation = ['pages'];\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation), {\n recursive: true,\n });\n }\n\n if (pagesLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, 'sentry-example-page.js'),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.bold(\n path.join(...pagesLocation, 'sentry-example-page.js'),\n )}.`,\n );\n\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation, 'api'), {\n recursive: true,\n });\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...pagesLocation,\n 'api',\n 'sentry-example-api.js',\n ),\n getSentryExampleApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.bold(\n path.join(...pagesLocation, 'api', 'sentry-example-api.js'),\n )}.`,\n );\n }\n\n await addSentryCliRc(authToken);\n\n const mightBeUsingVercel = fs.existsSync(\n path.join(process.cwd(), 'vercel.json'),\n );\n\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.cyan(\n 'You can validate your setup by starting your dev environment (`next dev`) and visiting \"/sentry-example-page\".',\n )}\n${\n mightBeUsingVercel\n ? `\n ▲ It seems like you're using Vercel. We recommend using the Sentry Vercel integration: https://vercel.com/integrations/sentry\n`\n : ''\n}\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-javascript/issues',\n )}`,\n );\n}\n"]}
|