@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
|
@@ -3,145 +3,162 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
|
-
import { SentryCli } from '../../lib/Helper/SentryCli';
|
|
7
|
-
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
8
|
-
import clack from '@clack/prompts';
|
|
9
|
-
import chalk from 'chalk';
|
|
10
6
|
import * as fs from 'fs';
|
|
11
|
-
import
|
|
7
|
+
import { SentryProjectData } from '../utils/types';
|
|
12
8
|
import * as templates from './templates';
|
|
13
9
|
const xcode = require('xcode');
|
|
14
10
|
|
|
15
|
-
import { SentryProjectData } from '../utils/clack-utils';
|
|
16
11
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
17
12
|
|
|
18
13
|
function setDebugInformationFormat(proj: any): void {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
const xcObjects = proj.hash.project.objects;
|
|
15
|
+
const target = proj.getFirstTarget().firstTarget;
|
|
16
|
+
|
|
17
|
+
xcObjects.XCConfigurationList[
|
|
18
|
+
target.buildConfigurationList
|
|
19
|
+
].buildConfigurations.forEach((buildConfig: { value: string }) => {
|
|
20
|
+
xcObjects.XCBuildConfiguration[
|
|
21
|
+
buildConfig.value
|
|
22
|
+
].buildSettings.DEBUG_INFORMATION_FORMAT = '"dwarf-with-dsym"';
|
|
23
|
+
});
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
function addSentrySPM(proj: any): void {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const sentryFrameworkUUID = proj.generateUuid() as string;
|
|
31
|
-
const sentrySPMUUID = proj.generateUuid() as string;
|
|
32
|
-
|
|
33
|
-
//Check whether xcObjects already have sentry framework
|
|
34
|
-
if (xcObjects.PBXFrameworksBuildPhase) {
|
|
35
|
-
for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {
|
|
36
|
-
if (!key.endsWith("_comment")) {
|
|
37
|
-
const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
|
|
38
|
-
for (const framework of frameworks) {
|
|
39
|
-
if (framework.comment === "Sentry in Frameworks") {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
27
|
+
const xcObjects = proj.hash.project.objects;
|
|
46
28
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
productRef: sentrySPMUUID,
|
|
50
|
-
productRef_comment: "Sentry",
|
|
51
|
-
};
|
|
52
|
-
xcObjects.PBXBuildFile[sentryFrameworkUUID + "_comment"] = "Sentry in Frameworks";
|
|
29
|
+
const sentryFrameworkUUID = proj.generateUuid() as string;
|
|
30
|
+
const sentrySPMUUID = proj.generateUuid() as string;
|
|
53
31
|
|
|
32
|
+
//Check whether xcObjects already have sentry framework
|
|
33
|
+
if (xcObjects.PBXFrameworksBuildPhase) {
|
|
54
34
|
for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
if (!key.endsWith('_comment')) {
|
|
36
|
+
const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
|
|
37
|
+
for (const framework of frameworks) {
|
|
38
|
+
if (framework.comment === 'Sentry in Frameworks') {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
61
41
|
}
|
|
42
|
+
}
|
|
62
43
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
xcObjects.PBXBuildFile[sentryFrameworkUUID] = {
|
|
47
|
+
isa: 'PBXBuildFile',
|
|
48
|
+
productRef: sentrySPMUUID,
|
|
49
|
+
productRef_comment: 'Sentry',
|
|
50
|
+
};
|
|
51
|
+
xcObjects.PBXBuildFile[sentryFrameworkUUID + '_comment'] =
|
|
52
|
+
'Sentry in Frameworks';
|
|
53
|
+
|
|
54
|
+
for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {
|
|
55
|
+
if (!key.endsWith('_comment')) {
|
|
56
|
+
const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
|
|
57
|
+
frameworks.push({
|
|
58
|
+
value: sentryFrameworkUUID,
|
|
59
|
+
comment: 'Sentry in Frameworks',
|
|
60
|
+
});
|
|
67
61
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const target = proj.getFirstTarget().firstTarget;
|
|
65
|
+
if (!target.packageProductDependencies) {
|
|
66
|
+
target.packageProductDependencies = [];
|
|
67
|
+
}
|
|
68
|
+
target.packageProductDependencies.push({
|
|
69
|
+
value: sentrySPMUUID,
|
|
70
|
+
comment: 'Sentry',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const sentrySwiftPackageUUID = proj.generateUuid() as string;
|
|
74
|
+
const xcProject = proj.getFirstProject().firstProject;
|
|
75
|
+
if (!xcProject.packageReferences) {
|
|
76
|
+
xcProject.packageReferences = [];
|
|
77
|
+
}
|
|
78
|
+
xcProject.packageReferences.push({
|
|
79
|
+
value: sentrySwiftPackageUUID,
|
|
80
|
+
comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
xcObjects.XCRemoteSwiftPackageReference = {};
|
|
84
|
+
xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {
|
|
85
|
+
isa: 'XCRemoteSwiftPackageReference',
|
|
86
|
+
repositoryURL: '"https://github.com/getsentry/sentry-cocoa/"',
|
|
87
|
+
requirement: {
|
|
88
|
+
kind: 'upToNextMajorVersion',
|
|
89
|
+
minimumVersion: '8.0.0',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + '_comment'] =
|
|
93
|
+
'XCRemoteSwiftPackageReference "sentry-cocoa"';
|
|
94
|
+
|
|
95
|
+
xcObjects.XCSwiftPackageProductDependency = {};
|
|
96
|
+
xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {
|
|
97
|
+
isa: 'XCSwiftPackageProductDependency',
|
|
98
|
+
package: sentrySwiftPackageUUID,
|
|
99
|
+
package_comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
|
|
100
|
+
productName: 'Sentry',
|
|
101
|
+
};
|
|
102
|
+
xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + '_comment'] =
|
|
103
|
+
'Sentry';
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
function addUploadSymbolsScript(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
function addUploadSymbolsScript(
|
|
107
|
+
xcodeProject: any,
|
|
108
|
+
sentryProject: SentryProjectData,
|
|
109
|
+
apiKeys: { token: string },
|
|
110
|
+
uploadSource = true,
|
|
111
|
+
): void {
|
|
112
|
+
const xcObjects = xcodeProject.hash.project.objects;
|
|
113
|
+
|
|
114
|
+
for (const scriptKey in xcObjects.PBXShellScriptBuildPhase || {}) {
|
|
115
|
+
if (!scriptKey.endsWith('_comment')) {
|
|
116
|
+
const script = xcObjects.PBXShellScriptBuildPhase[scriptKey].shellScript;
|
|
117
|
+
//Sentry script already exists, update it
|
|
118
|
+
if (script.includes('sentry-cli')) {
|
|
119
|
+
delete xcObjects.PBXShellScriptBuildPhase[scriptKey];
|
|
120
|
+
delete xcObjects.PBXShellScriptBuildPhase[scriptKey + '_comment'];
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
118
123
|
}
|
|
124
|
+
}
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
xcodeProject.addBuildPhase(
|
|
127
|
+
[],
|
|
128
|
+
'PBXShellScriptBuildPhase',
|
|
129
|
+
'Upload Debug Symbols to Sentry',
|
|
130
|
+
null,
|
|
131
|
+
{
|
|
132
|
+
inputFileListPaths: [],
|
|
133
|
+
outputFileListPaths: [],
|
|
134
|
+
inputPaths: [templates.scriptInputPath],
|
|
135
|
+
shellPath: '/bin/sh',
|
|
136
|
+
shellScript: templates.getRunScriptTemplate(
|
|
137
|
+
sentryProject.organization.slug,
|
|
138
|
+
sentryProject.slug,
|
|
139
|
+
apiKeys.token,
|
|
140
|
+
uploadSource,
|
|
141
|
+
),
|
|
142
|
+
},
|
|
143
|
+
);
|
|
133
144
|
}
|
|
134
145
|
|
|
135
|
-
export function updateXcodeProject(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
146
|
+
export function updateXcodeProject(
|
|
147
|
+
projectPath: string,
|
|
148
|
+
sentryProject: SentryProjectData,
|
|
149
|
+
apiKeys: { token: string },
|
|
150
|
+
addSPMReference: boolean,
|
|
151
|
+
uploadSource = true,
|
|
152
|
+
): void {
|
|
153
|
+
const proj = xcode.project(projectPath);
|
|
154
|
+
proj.parseSync();
|
|
155
|
+
addUploadSymbolsScript(proj, sentryProject, apiKeys, uploadSource);
|
|
156
|
+
if (uploadSource) {
|
|
157
|
+
setDebugInformationFormat(proj);
|
|
158
|
+
}
|
|
159
|
+
if (addSPMReference) {
|
|
160
|
+
addSentrySPM(proj);
|
|
161
|
+
}
|
|
162
|
+
const newContent = proj.writeSync();
|
|
163
|
+
fs.writeFileSync(projectPath, newContent);
|
|
164
|
+
}
|
|
@@ -11,11 +11,9 @@ import {
|
|
|
11
11
|
abort,
|
|
12
12
|
abortIfCancelled,
|
|
13
13
|
addSentryCliRc,
|
|
14
|
-
askForProjectSelection,
|
|
15
|
-
askForSelfHosted,
|
|
16
|
-
askForWizardLogin,
|
|
17
14
|
confirmContinueEvenThoughNoGitRepo,
|
|
18
15
|
ensurePackageIsInstalled,
|
|
16
|
+
getOrAskForProjectData,
|
|
19
17
|
getPackageDotJson,
|
|
20
18
|
installPackage,
|
|
21
19
|
isUsingTypeScript,
|
|
@@ -45,15 +43,8 @@ export async function runNextjsWizard(options: WizardOptions): Promise<void> {
|
|
|
45
43
|
const packageJson = await getPackageDotJson();
|
|
46
44
|
await ensurePackageIsInstalled(packageJson, 'next', 'Next.js');
|
|
47
45
|
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
-
const { projects, apiKeys } = await askForWizardLogin({
|
|
51
|
-
promoCode: options.promoCode,
|
|
52
|
-
url: sentryUrl,
|
|
53
|
-
platform: 'javascript-nextjs',
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const selectedProject = await askForProjectSelection(projects);
|
|
46
|
+
const { selectedProject, authToken, selfHosted, sentryUrl } =
|
|
47
|
+
await getOrAskForProjectData(options);
|
|
57
48
|
|
|
58
49
|
await installPackage({
|
|
59
50
|
packageName: '@sentry/nextjs',
|
|
@@ -349,7 +340,7 @@ export async function runNextjsWizard(options: WizardOptions): Promise<void> {
|
|
|
349
340
|
);
|
|
350
341
|
}
|
|
351
342
|
|
|
352
|
-
await addSentryCliRc(
|
|
343
|
+
await addSentryCliRc(authToken);
|
|
353
344
|
|
|
354
345
|
const mightBeUsingVercel = fs.existsSync(
|
|
355
346
|
path.join(process.cwd(), 'vercel.json'),
|
|
@@ -5,14 +5,12 @@ import * as Sentry from '@sentry/node';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
abortIfCancelled,
|
|
8
|
-
askForProjectSelection,
|
|
9
|
-
askForSelfHosted,
|
|
10
|
-
askForWizardLogin,
|
|
11
8
|
confirmContinueEvenThoughNoGitRepo,
|
|
12
9
|
detectPackageManager,
|
|
13
10
|
SENTRY_DOT_ENV_FILE,
|
|
14
11
|
printWelcome,
|
|
15
12
|
SENTRY_CLI_RC_FILE,
|
|
13
|
+
getOrAskForProjectData,
|
|
16
14
|
} from '../utils/clack-utils';
|
|
17
15
|
import { isUnicodeSupported } from '../utils/vendor/is-unicorn-supported';
|
|
18
16
|
import { SourceMapUploadToolConfigurationOptions } from './tools/types';
|
|
@@ -30,6 +28,7 @@ import { URL } from 'url';
|
|
|
30
28
|
import { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';
|
|
31
29
|
import { configureAngularSourcemapGenerationFlow } from './tools/angular';
|
|
32
30
|
import { detectUsedTool, SupportedTools } from './utils/detect-tool';
|
|
31
|
+
import { configureNextJsSourceMapsUpload } from './tools/nextjs';
|
|
33
32
|
|
|
34
33
|
export async function runSourcemapsWizard(
|
|
35
34
|
options: WizardOptions,
|
|
@@ -73,37 +72,37 @@ You can turn this off by running the wizard with the '--disable-telemetry' flag.
|
|
|
73
72
|
|
|
74
73
|
await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);
|
|
75
74
|
|
|
76
|
-
const {
|
|
77
|
-
|
|
78
|
-
() => askForSelfHosted(options.url),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const { projects, apiKeys } = await traceStep('login', () =>
|
|
82
|
-
askForWizardLogin({
|
|
83
|
-
promoCode: options.promoCode,
|
|
84
|
-
url: sentryUrl,
|
|
85
|
-
}),
|
|
86
|
-
);
|
|
75
|
+
const { selfHosted, selectedProject, sentryUrl, authToken } =
|
|
76
|
+
await getOrAskForProjectData(options);
|
|
87
77
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
const wizardOptionsWithPreSelectedProject = {
|
|
79
|
+
...options,
|
|
80
|
+
preSelectedProject: {
|
|
81
|
+
project: selectedProject,
|
|
82
|
+
authToken,
|
|
83
|
+
selfHosted,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
91
86
|
|
|
92
87
|
const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);
|
|
93
88
|
|
|
94
89
|
Sentry.setTag('selected-tool', selectedTool);
|
|
95
90
|
|
|
96
91
|
await traceStep('tool-setup', () =>
|
|
97
|
-
startToolSetupFlow(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
startToolSetupFlow(
|
|
93
|
+
selectedTool,
|
|
94
|
+
{
|
|
95
|
+
orgSlug: selectedProject.organization.slug,
|
|
96
|
+
projectSlug: selectedProject.slug,
|
|
97
|
+
selfHosted,
|
|
98
|
+
url: sentryUrl,
|
|
99
|
+
authToken,
|
|
100
|
+
},
|
|
101
|
+
wizardOptionsWithPreSelectedProject,
|
|
102
|
+
),
|
|
104
103
|
);
|
|
105
104
|
|
|
106
|
-
await traceStep('ci-setup', () => configureCI(selectedTool,
|
|
105
|
+
await traceStep('ci-setup', () => configureCI(selectedTool, authToken));
|
|
107
106
|
|
|
108
107
|
traceStep('outro', () =>
|
|
109
108
|
printOutro(
|
|
@@ -129,6 +128,11 @@ async function askForUsedBundlerTool(): Promise<SupportedTools> {
|
|
|
129
128
|
value: 'create-react-app',
|
|
130
129
|
hint: 'Select this option if you set up your app with Create React App.',
|
|
131
130
|
},
|
|
131
|
+
{
|
|
132
|
+
label: 'Next.js',
|
|
133
|
+
value: 'nextjs',
|
|
134
|
+
hint: 'Select this option if you want to set up source maps in a NextJS project.',
|
|
135
|
+
},
|
|
132
136
|
{
|
|
133
137
|
label: 'Webpack',
|
|
134
138
|
value: 'webpack',
|
|
@@ -170,6 +174,7 @@ async function askForUsedBundlerTool(): Promise<SupportedTools> {
|
|
|
170
174
|
async function startToolSetupFlow(
|
|
171
175
|
selctedTool: SupportedTools,
|
|
172
176
|
options: SourceMapUploadToolConfigurationOptions,
|
|
177
|
+
wizardOptions: WizardOptions,
|
|
173
178
|
): Promise<void> {
|
|
174
179
|
switch (selctedTool) {
|
|
175
180
|
case 'webpack':
|
|
@@ -196,6 +201,9 @@ async function startToolSetupFlow(
|
|
|
196
201
|
configureAngularSourcemapGenerationFlow,
|
|
197
202
|
);
|
|
198
203
|
break;
|
|
204
|
+
case 'nextjs':
|
|
205
|
+
await configureNextJsSourceMapsUpload(options, wizardOptions);
|
|
206
|
+
break;
|
|
199
207
|
default:
|
|
200
208
|
await configureSentryCLI(options);
|
|
201
209
|
break;
|
|
@@ -234,9 +242,13 @@ async function configureCI(
|
|
|
234
242
|
'create-react-app',
|
|
235
243
|
].includes(selectedTool);
|
|
236
244
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
// some non-cli-based flows also use the .sentryclirc file
|
|
246
|
+
const usesSentryCliRc = selectedTool === 'nextjs';
|
|
247
|
+
|
|
248
|
+
const authTokenFile =
|
|
249
|
+
isCliBasedFlowTool || usesSentryCliRc
|
|
250
|
+
? SENTRY_CLI_RC_FILE
|
|
251
|
+
: SENTRY_DOT_ENV_FILE;
|
|
240
252
|
|
|
241
253
|
if (!isUsingCI) {
|
|
242
254
|
clack.log.info(
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
+
import * as clack from '@clack/prompts';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { runNextjsWizard } from '../../nextjs/nextjs-wizard';
|
|
5
|
+
import { traceStep } from '../../telemetry';
|
|
6
|
+
import { abortIfCancelled, addSentryCliRc } from '../../utils/clack-utils';
|
|
7
|
+
import { WizardOptions } from '../../utils/types';
|
|
8
|
+
|
|
9
|
+
import { SourceMapUploadToolConfigurationOptions } from './types';
|
|
10
|
+
|
|
11
|
+
import * as Sentry from '@sentry/node';
|
|
12
|
+
|
|
13
|
+
const getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>
|
|
14
|
+
chalk.grey(`
|
|
15
|
+
${chalk.greenBright(
|
|
16
|
+
'const { withSentryConfig } = require("@sentry/nextjs");',
|
|
17
|
+
)}
|
|
18
|
+
|
|
19
|
+
const nextConfig = {
|
|
20
|
+
// your existing next config
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
${chalk.greenBright(`const sentryWebpackPluginOptions = {
|
|
24
|
+
org: "${options.orgSlug}",
|
|
25
|
+
project: "${options.projectSlug}",${
|
|
26
|
+
options.selfHosted ? `\n url: "${options.url}",` : ''
|
|
27
|
+
}
|
|
28
|
+
};`)}
|
|
29
|
+
|
|
30
|
+
${chalk.greenBright(`const sentryOptions = {
|
|
31
|
+
// Upload additional client files (increases upload size)
|
|
32
|
+
widenClientFileUpload: true,
|
|
33
|
+
|
|
34
|
+
// Hides source maps from generated client bundles
|
|
35
|
+
hideSourceMaps: true,
|
|
36
|
+
};`)}
|
|
37
|
+
|
|
38
|
+
${chalk.greenBright(`module.exports = withSentryConfig(
|
|
39
|
+
nextConfig,
|
|
40
|
+
sentryWebpackPluginOptions,
|
|
41
|
+
sentryOptions
|
|
42
|
+
);`)}
|
|
43
|
+
`);
|
|
44
|
+
|
|
45
|
+
export const configureNextJsSourceMapsUpload = async (
|
|
46
|
+
options: SourceMapUploadToolConfigurationOptions,
|
|
47
|
+
wizardOptions: WizardOptions,
|
|
48
|
+
) => {
|
|
49
|
+
clack.log
|
|
50
|
+
.info(`Source Maps upload for Next.js is configured automatically by default if you run the Sentry Wizard for Next.JS.
|
|
51
|
+
But don't worry, we can redirect you to the wizard now!
|
|
52
|
+
|
|
53
|
+
In case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(
|
|
54
|
+
'next.config.js',
|
|
55
|
+
)} file manually instead.`);
|
|
56
|
+
|
|
57
|
+
const shouldRedirect: boolean = await abortIfCancelled(
|
|
58
|
+
clack.select({
|
|
59
|
+
message: 'Do you want to run the Sentry Wizard for Next.JS now?',
|
|
60
|
+
options: [
|
|
61
|
+
{
|
|
62
|
+
label: 'Yes, run the wizard!',
|
|
63
|
+
value: true,
|
|
64
|
+
hint: 'The wizard can also configure your SDK setup',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: 'No, show me how to configure it manually',
|
|
68
|
+
value: false,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
Sentry.setTag('redirect-nextjs-wizard', shouldRedirect);
|
|
75
|
+
|
|
76
|
+
if (shouldRedirect) {
|
|
77
|
+
await traceStep('run-nextjs-wizard', () => runNextjsWizard(wizardOptions));
|
|
78
|
+
clack.intro('Sentry Source Maps Upload Configuration Wizard');
|
|
79
|
+
clack.log.info(
|
|
80
|
+
"Welcome back to the Source Maps wizard - we're almost done ;)",
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
clack.log.info(
|
|
84
|
+
`Add the following code to your ${chalk.cyan('next.config.js')}:`,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Intentionally logging directly to console here
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.log(getCodeSnippet(options));
|
|
90
|
+
|
|
91
|
+
await traceStep('nextjs-manual-nextconfigjs', () =>
|
|
92
|
+
abortIfCancelled(
|
|
93
|
+
clack.select({
|
|
94
|
+
message: 'Did you copy the code above?',
|
|
95
|
+
options: [{ label: 'Yes, continue!', value: true }],
|
|
96
|
+
initialValue: true,
|
|
97
|
+
}),
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
await traceStep('nextjs-manual-sentryclirc', () =>
|
|
102
|
+
addSentryCliRc(options.authToken),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
clack.log
|
|
107
|
+
.info(`In case you still run into problems, check out our docs to further debug your setup:
|
|
108
|
+
|
|
109
|
+
Uploading Source Maps:
|
|
110
|
+
https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-source-maps
|
|
111
|
+
|
|
112
|
+
Troubleshooting Source Maps:
|
|
113
|
+
https://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/`);
|
|
114
|
+
};
|