@sentry/wizard 3.26.0 → 3.28.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 +15 -0
- package/dist/package.json +2 -1
- package/dist/src/nextjs/nextjs-wizard.js +81 -25
- 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/sveltekit/sdk-setup.js +64 -43
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.d.ts +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +8 -2
- package/dist/src/sveltekit/templates.js +11 -5
- package/dist/src/sveltekit/templates.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/dist/test/sveltekit/templates.test.d.ts +1 -0
- package/dist/test/sveltekit/templates.test.js +43 -0
- package/dist/test/sveltekit/templates.test.js.map +1 -0
- package/package.json +2 -1
- package/src/nextjs/nextjs-wizard.ts +67 -7
- package/src/nextjs/templates.ts +35 -22
- package/src/run.ts +1 -1
- package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
- package/src/sveltekit/sdk-setup.ts +100 -22
- package/src/sveltekit/sveltekit-wizard.ts +1 -1
- package/src/sveltekit/templates.ts +36 -10
- 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
- package/test/sveltekit/templates.test.ts +152 -0
|
@@ -15,7 +15,11 @@ import { builders, generateCode, loadFile, parseModule } from 'magicast';
|
|
|
15
15
|
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
16
16
|
import { addVitePlugin } from 'magicast/helpers';
|
|
17
17
|
import { getClientHooksTemplate, getServerHooksTemplate } from './templates';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
abortIfCancelled,
|
|
20
|
+
featureSelectionPrompt,
|
|
21
|
+
isUsingTypeScript,
|
|
22
|
+
} from '../utils/clack-utils';
|
|
19
23
|
import { debug } from '../utils/debug';
|
|
20
24
|
import { findFile, hasSentryContent } from '../utils/ast-utils';
|
|
21
25
|
|
|
@@ -50,6 +54,23 @@ export async function createOrMergeSvelteKitFiles(
|
|
|
50
54
|
projectInfo: ProjectInfo,
|
|
51
55
|
svelteConfig: PartialSvelteConfig,
|
|
52
56
|
): Promise<void> {
|
|
57
|
+
const selectedFeatures = await featureSelectionPrompt([
|
|
58
|
+
{
|
|
59
|
+
id: 'performance',
|
|
60
|
+
prompt: `Do you want to enable ${chalk.bold(
|
|
61
|
+
'Tracing',
|
|
62
|
+
)} to track the performance of your application?`,
|
|
63
|
+
enabledHint: 'recommended',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'replay',
|
|
67
|
+
prompt: `Do you want to enable ${chalk.bold(
|
|
68
|
+
'Sentry Session Replay',
|
|
69
|
+
)} to get a video-like reproduction of errors during a user session?`,
|
|
70
|
+
enabledHint: 'recommended, but increases bundle size',
|
|
71
|
+
},
|
|
72
|
+
] as const);
|
|
73
|
+
|
|
53
74
|
const { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);
|
|
54
75
|
|
|
55
76
|
// full file paths with correct file ending (or undefined if not found)
|
|
@@ -68,9 +89,19 @@ export async function createOrMergeSvelteKitFiles(
|
|
|
68
89
|
);
|
|
69
90
|
if (!originalClientHooksFile) {
|
|
70
91
|
clack.log.info('No client hooks file found, creating a new one.');
|
|
71
|
-
await createNewHooksFile(
|
|
92
|
+
await createNewHooksFile(
|
|
93
|
+
`${clientHooksPath}.${fileEnding}`,
|
|
94
|
+
'client',
|
|
95
|
+
dsn,
|
|
96
|
+
selectedFeatures,
|
|
97
|
+
);
|
|
72
98
|
} else {
|
|
73
|
-
await mergeHooksFile(
|
|
99
|
+
await mergeHooksFile(
|
|
100
|
+
originalClientHooksFile,
|
|
101
|
+
'client',
|
|
102
|
+
dsn,
|
|
103
|
+
selectedFeatures,
|
|
104
|
+
);
|
|
74
105
|
}
|
|
75
106
|
|
|
76
107
|
Sentry.setTag(
|
|
@@ -79,9 +110,19 @@ export async function createOrMergeSvelteKitFiles(
|
|
|
79
110
|
);
|
|
80
111
|
if (!originalServerHooksFile) {
|
|
81
112
|
clack.log.info('No server hooks file found, creating a new one.');
|
|
82
|
-
await createNewHooksFile(
|
|
113
|
+
await createNewHooksFile(
|
|
114
|
+
`${serverHooksPath}.${fileEnding}`,
|
|
115
|
+
'server',
|
|
116
|
+
dsn,
|
|
117
|
+
selectedFeatures,
|
|
118
|
+
);
|
|
83
119
|
} else {
|
|
84
|
-
await mergeHooksFile(
|
|
120
|
+
await mergeHooksFile(
|
|
121
|
+
originalServerHooksFile,
|
|
122
|
+
'server',
|
|
123
|
+
dsn,
|
|
124
|
+
selectedFeatures,
|
|
125
|
+
);
|
|
85
126
|
}
|
|
86
127
|
|
|
87
128
|
if (viteConfig) {
|
|
@@ -123,11 +164,15 @@ async function createNewHooksFile(
|
|
|
123
164
|
hooksFileDest: string,
|
|
124
165
|
hooktype: 'client' | 'server',
|
|
125
166
|
dsn: string,
|
|
167
|
+
selectedFeatures: {
|
|
168
|
+
performance: boolean;
|
|
169
|
+
replay: boolean;
|
|
170
|
+
},
|
|
126
171
|
): Promise<void> {
|
|
127
172
|
const filledTemplate =
|
|
128
173
|
hooktype === 'client'
|
|
129
|
-
? getClientHooksTemplate(dsn)
|
|
130
|
-
: getServerHooksTemplate(dsn);
|
|
174
|
+
? getClientHooksTemplate(dsn, selectedFeatures)
|
|
175
|
+
: getServerHooksTemplate(dsn, selectedFeatures);
|
|
131
176
|
|
|
132
177
|
await fs.promises.mkdir(path.dirname(hooksFileDest), { recursive: true });
|
|
133
178
|
await fs.promises.writeFile(hooksFileDest, filledTemplate);
|
|
@@ -151,6 +196,10 @@ async function mergeHooksFile(
|
|
|
151
196
|
hooksFile: string,
|
|
152
197
|
hookType: 'client' | 'server',
|
|
153
198
|
dsn: string,
|
|
199
|
+
selectedFeatures: {
|
|
200
|
+
performance: boolean;
|
|
201
|
+
replay: boolean;
|
|
202
|
+
},
|
|
154
203
|
): Promise<void> {
|
|
155
204
|
const originalHooksMod = await loadFile(hooksFile);
|
|
156
205
|
|
|
@@ -184,9 +233,9 @@ Skipping adding Sentry functionality to.`,
|
|
|
184
233
|
await modifyAndRecordFail(
|
|
185
234
|
() => {
|
|
186
235
|
if (hookType === 'client') {
|
|
187
|
-
insertClientInitCall(dsn, originalHooksMod);
|
|
236
|
+
insertClientInitCall(dsn, originalHooksMod, selectedFeatures);
|
|
188
237
|
} else {
|
|
189
|
-
insertServerInitCall(dsn, originalHooksMod);
|
|
238
|
+
insertServerInitCall(dsn, originalHooksMod, selectedFeatures);
|
|
190
239
|
}
|
|
191
240
|
},
|
|
192
241
|
'init-call-injection',
|
|
@@ -224,20 +273,38 @@ function insertClientInitCall(
|
|
|
224
273
|
dsn: string,
|
|
225
274
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
226
275
|
originalHooksMod: ProxifiedModule<any>,
|
|
276
|
+
selectedFeatures: {
|
|
277
|
+
performance: boolean;
|
|
278
|
+
replay: boolean;
|
|
279
|
+
},
|
|
227
280
|
): void {
|
|
228
281
|
const initCallComment = `
|
|
229
|
-
// If you don't want to use Session Replay, remove the \`Replay\` integration,
|
|
282
|
+
// If you don't want to use Session Replay, remove the \`Replay\` integration,
|
|
230
283
|
// \`replaysSessionSampleRate\` and \`replaysOnErrorSampleRate\` options.`;
|
|
231
284
|
|
|
285
|
+
const initArgs: {
|
|
286
|
+
dsn: string;
|
|
287
|
+
tracesSampleRate?: number;
|
|
288
|
+
replaysSessionSampleRate?: number;
|
|
289
|
+
replaysOnErrorSampleRate?: number;
|
|
290
|
+
integrations?: string[];
|
|
291
|
+
} = {
|
|
292
|
+
dsn,
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
if (selectedFeatures.performance) {
|
|
296
|
+
initArgs.tracesSampleRate = 1.0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (selectedFeatures.replay) {
|
|
300
|
+
initArgs.replaysSessionSampleRate = 0.1;
|
|
301
|
+
initArgs.replaysOnErrorSampleRate = 1.0;
|
|
302
|
+
initArgs.integrations = [builders.functionCall('Sentry.replayIntegration')];
|
|
303
|
+
}
|
|
304
|
+
|
|
232
305
|
// This assignment of any values is fine because we're just creating a function call in magicast
|
|
233
306
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
234
|
-
const initCall = builders.functionCall('Sentry.init',
|
|
235
|
-
dsn,
|
|
236
|
-
tracesSampleRate: 1.0,
|
|
237
|
-
replaysSessionSampleRate: 0.1,
|
|
238
|
-
replaysOnErrorSampleRate: 1.0,
|
|
239
|
-
integrations: [builders.functionCall('Sentry.replayIntegration')],
|
|
240
|
-
});
|
|
307
|
+
const initCall = builders.functionCall('Sentry.init', initArgs);
|
|
241
308
|
|
|
242
309
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
243
310
|
const initCallWithComment = builders.raw(
|
|
@@ -262,13 +329,24 @@ function insertServerInitCall(
|
|
|
262
329
|
dsn: string,
|
|
263
330
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
331
|
originalHooksMod: ProxifiedModule<any>,
|
|
332
|
+
selectedFeatures: {
|
|
333
|
+
performance: boolean;
|
|
334
|
+
},
|
|
265
335
|
): void {
|
|
336
|
+
const initArgs: {
|
|
337
|
+
dsn: string;
|
|
338
|
+
tracesSampleRate?: number;
|
|
339
|
+
} = {
|
|
340
|
+
dsn,
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
if (selectedFeatures.performance) {
|
|
344
|
+
initArgs.tracesSampleRate = 1.0;
|
|
345
|
+
}
|
|
346
|
+
|
|
266
347
|
// This assignment of any values is fine because we're just creating a function call in magicast
|
|
267
348
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
268
|
-
const initCall = builders.functionCall('Sentry.init',
|
|
269
|
-
dsn,
|
|
270
|
-
tracesSampleRate: 1.0,
|
|
271
|
-
});
|
|
349
|
+
const initCall = builders.functionCall('Sentry.init', initArgs);
|
|
272
350
|
|
|
273
351
|
const originalHooksModAST = originalHooksMod.$ast as Program;
|
|
274
352
|
|
|
@@ -546,7 +624,7 @@ export default defineConfig({
|
|
|
546
624
|
sourceMapsUploadOptions: {
|
|
547
625
|
org: '${org}',
|
|
548
626
|
project: '${project}',${selfHosted ? `\n url: '${url}',` : ''}
|
|
549
|
-
}
|
|
627
|
+
}
|
|
550
628
|
}),`)}
|
|
551
629
|
sveltekit(),
|
|
552
630
|
]
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
printWelcome,
|
|
18
18
|
} from '../utils/clack-utils';
|
|
19
19
|
import { getPackageVersion, hasPackageInstalled } from '../utils/package-json';
|
|
20
|
-
import { WizardOptions } from '../utils/types';
|
|
20
|
+
import type { WizardOptions } from '../utils/types';
|
|
21
21
|
import { createExamplePage } from './sdk-example';
|
|
22
22
|
import { createOrMergeSvelteKitFiles, loadSvelteConfig } from './sdk-setup';
|
|
23
23
|
import { traceStep, withTelemetry } from '../telemetry';
|
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
export function getClientHooksTemplate(
|
|
1
|
+
export function getClientHooksTemplate(
|
|
2
|
+
dsn: string,
|
|
3
|
+
selectedFeatures: {
|
|
4
|
+
performance: boolean;
|
|
5
|
+
replay: boolean;
|
|
6
|
+
},
|
|
7
|
+
) {
|
|
2
8
|
return `import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
3
9
|
import * as Sentry from '@sentry/sveltekit';
|
|
4
10
|
|
|
5
11
|
Sentry.init({
|
|
6
12
|
dsn: '${dsn}',
|
|
13
|
+
${
|
|
14
|
+
selectedFeatures.performance
|
|
15
|
+
? `
|
|
7
16
|
tracesSampleRate: 1.0,
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
`
|
|
18
|
+
: ''
|
|
19
|
+
}
|
|
20
|
+
${
|
|
21
|
+
selectedFeatures.replay
|
|
22
|
+
? ` // This sets the sample rate to be 10%. You may want this to be 100% while
|
|
10
23
|
// in development and sample at a lower rate in production
|
|
11
24
|
replaysSessionSampleRate: 0.1,
|
|
12
25
|
|
|
13
26
|
// If the entire session is not sampled, use the below sample rate to sample
|
|
14
27
|
// sessions when an error occurs.
|
|
15
28
|
replaysOnErrorSampleRate: 1.0,
|
|
16
|
-
|
|
29
|
+
|
|
17
30
|
// If you don't want to use Session Replay, just remove the line below:
|
|
18
|
-
integrations: [replayIntegration()]
|
|
31
|
+
integrations: [replayIntegration()],`
|
|
32
|
+
: ''
|
|
33
|
+
}
|
|
19
34
|
});
|
|
20
35
|
|
|
21
36
|
// If you have a custom error handler, pass it to \`handleErrorWithSentry\`
|
|
@@ -23,17 +38,28 @@ export const handleError = handleErrorWithSentry();
|
|
|
23
38
|
`;
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
export function getServerHooksTemplate(
|
|
41
|
+
export function getServerHooksTemplate(
|
|
42
|
+
dsn: string,
|
|
43
|
+
selectedFeatures: {
|
|
44
|
+
performance: boolean;
|
|
45
|
+
replay: boolean;
|
|
46
|
+
},
|
|
47
|
+
) {
|
|
27
48
|
return `import { sequence } from "@sveltejs/kit/hooks";
|
|
28
49
|
import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
|
|
29
50
|
import * as Sentry from '@sentry/sveltekit';
|
|
30
51
|
|
|
31
52
|
Sentry.init({
|
|
32
53
|
dsn: '${dsn}',
|
|
54
|
+
${
|
|
55
|
+
selectedFeatures.performance
|
|
56
|
+
? `
|
|
33
57
|
tracesSampleRate: 1.0,
|
|
34
|
-
|
|
58
|
+
`
|
|
59
|
+
: ''
|
|
60
|
+
}
|
|
35
61
|
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
|
|
36
|
-
// spotlight: import.meta.env.DEV,
|
|
62
|
+
// spotlight: import.meta.env.DEV,
|
|
37
63
|
});
|
|
38
64
|
|
|
39
65
|
// If you have custom handlers, make sure to place them after \`sentryHandle()\` in the \`sequence\` function.
|
|
@@ -57,9 +83,9 @@ export function getSentryExampleSveltePage(options: {
|
|
|
57
83
|
? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`
|
|
58
84
|
: `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;
|
|
59
85
|
|
|
60
|
-
return `<!--
|
|
86
|
+
return `<!--
|
|
61
87
|
This is just a very simple page with a button to throw an example error.
|
|
62
|
-
Feel free to delete this file and the entire sentry route.
|
|
88
|
+
Feel free to delete this file and the entire sentry route.
|
|
63
89
|
-->
|
|
64
90
|
|
|
65
91
|
<script>
|
package/src/utils/clack-utils.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { setInterval } from 'timers';
|
|
|
10
10
|
import { URL } from 'url';
|
|
11
11
|
import * as Sentry from '@sentry/node';
|
|
12
12
|
import { hasPackageInstalled, PackageDotJson } from './package-json';
|
|
13
|
-
import { SentryProjectData, WizardOptions } from './types';
|
|
13
|
+
import { Feature, SentryProjectData, WizardOptions } from './types';
|
|
14
14
|
import { traceStep } from '../telemetry';
|
|
15
15
|
import {
|
|
16
16
|
detectPackageManger,
|
|
@@ -1277,3 +1277,36 @@ export async function askShouldCreateExamplePage(
|
|
|
1277
1277
|
),
|
|
1278
1278
|
);
|
|
1279
1279
|
}
|
|
1280
|
+
|
|
1281
|
+
export async function featureSelectionPrompt<F extends ReadonlyArray<Feature>>(
|
|
1282
|
+
features: F,
|
|
1283
|
+
): Promise<{ [key in F[number]['id']]: boolean }> {
|
|
1284
|
+
return traceStep('feature-selection', async () => {
|
|
1285
|
+
const selectedFeatures: Record<string, boolean> = {};
|
|
1286
|
+
|
|
1287
|
+
for (const feature of features) {
|
|
1288
|
+
const selected = await abortIfCancelled(
|
|
1289
|
+
clack.select({
|
|
1290
|
+
message: feature.prompt,
|
|
1291
|
+
initialValue: true,
|
|
1292
|
+
options: [
|
|
1293
|
+
{
|
|
1294
|
+
value: true,
|
|
1295
|
+
label: 'Yes',
|
|
1296
|
+
hint: feature.enabledHint,
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
value: false,
|
|
1300
|
+
label: 'No',
|
|
1301
|
+
hint: feature.disabledHint,
|
|
1302
|
+
},
|
|
1303
|
+
],
|
|
1304
|
+
}),
|
|
1305
|
+
);
|
|
1306
|
+
|
|
1307
|
+
selectedFeatures[feature.id] = selected;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
return selectedFeatures as { [key in F[number]['id']]: boolean };
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
@@ -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();
|