@sentry/wizard 3.26.0 → 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 +10 -0
- package/dist/package.json +2 -1
- package/dist/src/nextjs/nextjs-wizard.js +30 -17
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +4 -1
- package/dist/src/nextjs/templates.js +18 -7
- 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/utils/clack-utils.d.ts +4 -1
- package/dist/src/utils/clack-utils.js +47 -1
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +4 -1
- package/dist/src/utils/package-manager.js +40 -5
- 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 +65 -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/package.json +2 -1
- package/src/nextjs/nextjs-wizard.ts +23 -4
- package/src/nextjs/templates.ts +35 -22
- package/src/run.ts +1 -1
- package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
- package/src/utils/clack-utils.ts +34 -1
- package/src/utils/package-manager.ts +38 -4
- package/src/utils/types.ts +7 -0
- package/src/utils/url.ts +6 -2
- package/test/nextjs/templates.test.ts +240 -2
- package/test/sourcemaps/tools/sentry-cli.test.ts +2 -1
|
@@ -14,6 +14,7 @@ export interface PackageManager {
|
|
|
14
14
|
/* The command that the package manager uses to run a script from package.json */
|
|
15
15
|
runScriptCommand: string;
|
|
16
16
|
flags: string;
|
|
17
|
+
detect: () => boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export const BUN: PackageManager = {
|
|
@@ -24,15 +25,46 @@ export const BUN: PackageManager = {
|
|
|
24
25
|
buildCommand: 'bun run build',
|
|
25
26
|
runScriptCommand: 'bun run',
|
|
26
27
|
flags: '',
|
|
28
|
+
detect: () => fs.existsSync(path.join(process.cwd(), BUN.lockFile)),
|
|
27
29
|
};
|
|
28
|
-
export const
|
|
30
|
+
export const YARN_V1: PackageManager = {
|
|
29
31
|
name: 'yarn',
|
|
30
|
-
label: 'Yarn',
|
|
32
|
+
label: 'Yarn V1',
|
|
31
33
|
lockFile: 'yarn.lock',
|
|
32
34
|
installCommand: 'yarn add',
|
|
33
35
|
buildCommand: 'yarn build',
|
|
34
36
|
runScriptCommand: 'yarn',
|
|
35
37
|
flags: '--ignore-workspace-root-check',
|
|
38
|
+
detect: () => {
|
|
39
|
+
try {
|
|
40
|
+
return fs
|
|
41
|
+
.readFileSync(path.join(process.cwd(), YARN_V1.lockFile), 'utf-8')
|
|
42
|
+
.slice(0, 500)
|
|
43
|
+
.includes('yarn lockfile v1');
|
|
44
|
+
} catch (e) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/** YARN V2/3/4 */
|
|
50
|
+
export const YARN_V2: PackageManager = {
|
|
51
|
+
name: 'yarn',
|
|
52
|
+
label: 'Yarn V2/3/4',
|
|
53
|
+
lockFile: 'yarn.lock',
|
|
54
|
+
installCommand: 'yarn add',
|
|
55
|
+
buildCommand: 'yarn build',
|
|
56
|
+
runScriptCommand: 'yarn',
|
|
57
|
+
flags: '',
|
|
58
|
+
detect: () => {
|
|
59
|
+
try {
|
|
60
|
+
return fs
|
|
61
|
+
.readFileSync(path.join(process.cwd(), YARN_V2.lockFile), 'utf-8')
|
|
62
|
+
.slice(0, 500)
|
|
63
|
+
.includes('__metadata');
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
36
68
|
};
|
|
37
69
|
export const PNPM: PackageManager = {
|
|
38
70
|
name: 'pnpm',
|
|
@@ -42,6 +74,7 @@ export const PNPM: PackageManager = {
|
|
|
42
74
|
buildCommand: 'pnpm build',
|
|
43
75
|
runScriptCommand: 'pnpm',
|
|
44
76
|
flags: '--ignore-workspace-root-check',
|
|
77
|
+
detect: () => fs.existsSync(path.join(process.cwd(), PNPM.lockFile)),
|
|
45
78
|
};
|
|
46
79
|
export const NPM: PackageManager = {
|
|
47
80
|
name: 'npm',
|
|
@@ -51,14 +84,15 @@ export const NPM: PackageManager = {
|
|
|
51
84
|
buildCommand: 'npm run build',
|
|
52
85
|
runScriptCommand: 'npm run',
|
|
53
86
|
flags: '',
|
|
87
|
+
detect: () => fs.existsSync(path.join(process.cwd(), NPM.lockFile)),
|
|
54
88
|
};
|
|
55
89
|
|
|
56
|
-
export const packageManagers = [BUN,
|
|
90
|
+
export const packageManagers = [BUN, YARN_V1, YARN_V2, PNPM, NPM];
|
|
57
91
|
|
|
58
92
|
export function detectPackageManger(): PackageManager | null {
|
|
59
93
|
return traceStep('detect-package-manager', () => {
|
|
60
94
|
for (const packageManager of packageManagers) {
|
|
61
|
-
if (
|
|
95
|
+
if (packageManager.detect()) {
|
|
62
96
|
Sentry.setTag('package-manager', packageManager.name);
|
|
63
97
|
return packageManager;
|
|
64
98
|
}
|
package/src/utils/types.ts
CHANGED
package/src/utils/url.ts
CHANGED
|
@@ -15,8 +15,12 @@ export function getIssueStreamUrl({
|
|
|
15
15
|
projectId: string;
|
|
16
16
|
}): string {
|
|
17
17
|
const urlObject = new URL(url);
|
|
18
|
-
urlObject.host
|
|
19
|
-
|
|
18
|
+
if (urlObject.host === 'sentry.io') {
|
|
19
|
+
urlObject.host = `${orgSlug}.${urlObject.host}`;
|
|
20
|
+
urlObject.pathname = '/issues/';
|
|
21
|
+
} else {
|
|
22
|
+
urlObject.pathname = `/organizations/${orgSlug}/issues/`;
|
|
23
|
+
}
|
|
20
24
|
urlObject.searchParams.set('project', projectId);
|
|
21
25
|
|
|
22
26
|
return urlObject.toString();
|
|
@@ -1,6 +1,244 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getSentryConfigContents,
|
|
3
|
+
getWithSentryConfigOptionsTemplate,
|
|
4
|
+
} from '../../src/nextjs/templates';
|
|
5
|
+
|
|
6
|
+
describe('Next.js code templates', () => {
|
|
7
|
+
describe('getSentryConfigContents', () => {
|
|
8
|
+
describe('client-side', () => {
|
|
9
|
+
it('generates client-side Sentry config with all features enabled', () => {
|
|
10
|
+
const template = getSentryConfigContents('my-dsn', 'client', {
|
|
11
|
+
performance: true,
|
|
12
|
+
replay: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
expect(template).toMatchInlineSnapshot(`
|
|
16
|
+
"// This file configures the initialization of Sentry on the client.
|
|
17
|
+
// The config you add here will be used whenever a users loads a page in their browser.
|
|
18
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
19
|
+
|
|
20
|
+
import * as Sentry from "@sentry/nextjs";
|
|
21
|
+
|
|
22
|
+
Sentry.init({
|
|
23
|
+
dsn: "my-dsn",
|
|
24
|
+
|
|
25
|
+
// Add optional integrations for additional features
|
|
26
|
+
integrations: [
|
|
27
|
+
Sentry.replayIntegration(),
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
31
|
+
tracesSampleRate: 1,
|
|
32
|
+
|
|
33
|
+
// Define how likely Replay events are sampled.
|
|
34
|
+
// This sets the sample rate to be 10%. You may want this to be 100% while
|
|
35
|
+
// in development and sample at a lower rate in production
|
|
36
|
+
replaysSessionSampleRate: 0.1,
|
|
37
|
+
|
|
38
|
+
// Define how likely Replay events are sampled when an error occurs.
|
|
39
|
+
replaysOnErrorSampleRate: 1.0,
|
|
40
|
+
|
|
41
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
42
|
+
debug: false,
|
|
43
|
+
});
|
|
44
|
+
"
|
|
45
|
+
`);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('generates client-side Sentry config with performance monitoring disabled', () => {
|
|
49
|
+
const template = getSentryConfigContents('my-dsn', 'client', {
|
|
50
|
+
performance: false,
|
|
51
|
+
replay: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(template).toMatchInlineSnapshot(`
|
|
55
|
+
"// This file configures the initialization of Sentry on the client.
|
|
56
|
+
// The config you add here will be used whenever a users loads a page in their browser.
|
|
57
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
58
|
+
|
|
59
|
+
import * as Sentry from "@sentry/nextjs";
|
|
60
|
+
|
|
61
|
+
Sentry.init({
|
|
62
|
+
dsn: "my-dsn",
|
|
63
|
+
|
|
64
|
+
// Add optional integrations for additional features
|
|
65
|
+
integrations: [
|
|
66
|
+
Sentry.replayIntegration(),
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
// Define how likely Replay events are sampled.
|
|
70
|
+
// This sets the sample rate to be 10%. You may want this to be 100% while
|
|
71
|
+
// in development and sample at a lower rate in production
|
|
72
|
+
replaysSessionSampleRate: 0.1,
|
|
73
|
+
|
|
74
|
+
// Define how likely Replay events are sampled when an error occurs.
|
|
75
|
+
replaysOnErrorSampleRate: 1.0,
|
|
76
|
+
|
|
77
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
78
|
+
debug: false,
|
|
79
|
+
});
|
|
80
|
+
"
|
|
81
|
+
`);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('generates client-side Sentry config with session replay disabled', () => {
|
|
85
|
+
const template = getSentryConfigContents('my-dsn', 'client', {
|
|
86
|
+
performance: true,
|
|
87
|
+
replay: false,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(template).toMatchInlineSnapshot(`
|
|
91
|
+
"// This file configures the initialization of Sentry on the client.
|
|
92
|
+
// The config you add here will be used whenever a users loads a page in their browser.
|
|
93
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
94
|
+
|
|
95
|
+
import * as Sentry from "@sentry/nextjs";
|
|
96
|
+
|
|
97
|
+
Sentry.init({
|
|
98
|
+
dsn: "my-dsn",
|
|
99
|
+
|
|
100
|
+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
101
|
+
tracesSampleRate: 1,
|
|
102
|
+
|
|
103
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
104
|
+
debug: false,
|
|
105
|
+
});
|
|
106
|
+
"
|
|
107
|
+
`);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('server-side', () => {
|
|
112
|
+
it('generates server-side Sentry config with all features enabled', () => {
|
|
113
|
+
const template = getSentryConfigContents('my-dsn', 'server', {
|
|
114
|
+
performance: true,
|
|
115
|
+
replay: true,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(template).toMatchInlineSnapshot(`
|
|
119
|
+
"// This file configures the initialization of Sentry on the server.
|
|
120
|
+
// The config you add here will be used whenever the server handles a request.
|
|
121
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
122
|
+
|
|
123
|
+
import * as Sentry from "@sentry/nextjs";
|
|
124
|
+
|
|
125
|
+
Sentry.init({
|
|
126
|
+
dsn: "my-dsn",
|
|
127
|
+
|
|
128
|
+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
129
|
+
tracesSampleRate: 1,
|
|
130
|
+
|
|
131
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
132
|
+
debug: false,
|
|
133
|
+
});
|
|
134
|
+
"
|
|
135
|
+
`);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('generates server-side Sentry config with performance monitoring disabled', () => {
|
|
139
|
+
const template = getSentryConfigContents('my-dsn', 'server', {
|
|
140
|
+
performance: false,
|
|
141
|
+
replay: true,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
expect(template).toMatchInlineSnapshot(`
|
|
145
|
+
"// This file configures the initialization of Sentry on the server.
|
|
146
|
+
// The config you add here will be used whenever the server handles a request.
|
|
147
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
148
|
+
|
|
149
|
+
import * as Sentry from "@sentry/nextjs";
|
|
150
|
+
|
|
151
|
+
Sentry.init({
|
|
152
|
+
dsn: "my-dsn",
|
|
153
|
+
|
|
154
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
155
|
+
debug: false,
|
|
156
|
+
});
|
|
157
|
+
"
|
|
158
|
+
`);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('generates server-side Sentry config with spotlight disabled', () => {
|
|
162
|
+
const template = getSentryConfigContents('my-dsn', 'server', {
|
|
163
|
+
performance: true,
|
|
164
|
+
replay: true,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
expect(template).toMatchInlineSnapshot(`
|
|
168
|
+
"// This file configures the initialization of Sentry on the server.
|
|
169
|
+
// The config you add here will be used whenever the server handles a request.
|
|
170
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
171
|
+
|
|
172
|
+
import * as Sentry from "@sentry/nextjs";
|
|
173
|
+
|
|
174
|
+
Sentry.init({
|
|
175
|
+
dsn: "my-dsn",
|
|
176
|
+
|
|
177
|
+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
178
|
+
tracesSampleRate: 1,
|
|
179
|
+
|
|
180
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
181
|
+
debug: false,
|
|
182
|
+
});
|
|
183
|
+
"
|
|
184
|
+
`);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('edge', () => {
|
|
189
|
+
it('generates edge Sentry config with all features enabled', () => {
|
|
190
|
+
const template = getSentryConfigContents('my-dsn', 'edge', {
|
|
191
|
+
performance: true,
|
|
192
|
+
replay: true,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
expect(template).toMatchInlineSnapshot(`
|
|
196
|
+
"// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
|
|
197
|
+
// The config you add here will be used whenever one of the edge features is loaded.
|
|
198
|
+
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
|
|
199
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
200
|
+
|
|
201
|
+
import * as Sentry from "@sentry/nextjs";
|
|
202
|
+
|
|
203
|
+
Sentry.init({
|
|
204
|
+
dsn: "my-dsn",
|
|
205
|
+
|
|
206
|
+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
207
|
+
tracesSampleRate: 1,
|
|
208
|
+
|
|
209
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
210
|
+
debug: false,
|
|
211
|
+
});
|
|
212
|
+
"
|
|
213
|
+
`);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('generates edge Sentry config with performance monitoring disabled', () => {
|
|
217
|
+
const template = getSentryConfigContents('my-dsn', 'edge', {
|
|
218
|
+
performance: false,
|
|
219
|
+
replay: true,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
expect(template).toMatchInlineSnapshot(`
|
|
223
|
+
"// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
|
|
224
|
+
// The config you add here will be used whenever one of the edge features is loaded.
|
|
225
|
+
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
|
|
226
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
227
|
+
|
|
228
|
+
import * as Sentry from "@sentry/nextjs";
|
|
229
|
+
|
|
230
|
+
Sentry.init({
|
|
231
|
+
dsn: "my-dsn",
|
|
232
|
+
|
|
233
|
+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
234
|
+
debug: false,
|
|
235
|
+
});
|
|
236
|
+
"
|
|
237
|
+
`);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
2
241
|
|
|
3
|
-
describe('NextJS code templates', () => {
|
|
4
242
|
describe('getWithSentryConfigOptionsTemplate', () => {
|
|
5
243
|
it('generates options for SaaS', () => {
|
|
6
244
|
const template = getWithSentryConfigOptionsTemplate({
|
|
@@ -38,7 +38,8 @@ describe('addSentryCommandToBuildCommand', () => {
|
|
|
38
38
|
[
|
|
39
39
|
packageManagerHelpers.NPM,
|
|
40
40
|
packageManagerHelpers.PNPM,
|
|
41
|
-
packageManagerHelpers.
|
|
41
|
+
packageManagerHelpers.YARN_V1,
|
|
42
|
+
packageManagerHelpers.YARN_V2,
|
|
42
43
|
packageManagerHelpers.BUN,
|
|
43
44
|
],
|
|
44
45
|
])('adds the cli command to the script command (%s)', async (_, pacMan) => {
|