@sentry/wizard 3.34.1 → 3.34.3
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 +9 -0
- package/dist/e2e-tests/jest.config.d.ts +1 -0
- package/dist/e2e-tests/jest.config.js +5 -0
- package/dist/e2e-tests/jest.config.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nextjs.test.js +221 -0
- package/dist/e2e-tests/tests/nextjs.test.js.map +1 -0
- package/dist/e2e-tests/tests/remix.test.js +47 -43
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.d.ts +1 -0
- package/dist/e2e-tests/tests/sveltekit.test.js +186 -0
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -0
- package/dist/e2e-tests/utils/index.d.ts +13 -2
- package/dist/e2e-tests/utils/index.js +45 -13
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/package.json +3 -5
- package/dist/src/apple/templates.d.ts +1 -1
- package/dist/src/apple/templates.js +6 -2
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.js +2 -1
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +101 -73
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +1 -0
- package/dist/src/nextjs/templates.js +5 -1
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +3 -1
- package/dist/src/utils/clack-utils.js +2 -2
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/e2e-tests/.env.example +11 -0
- package/e2e-tests/jest.config.ts +8 -1
- package/e2e-tests/package.json +14 -0
- package/e2e-tests/run.sh +15 -0
- package/e2e-tests/test-applications/nextjs-test-app/next.config.mjs +4 -0
- package/e2e-tests/test-applications/nextjs-test-app/package.json +22 -0
- package/e2e-tests/test-applications/nextjs-test-app/src/app/layout.tsx +20 -0
- package/e2e-tests/test-applications/nextjs-test-app/src/app/page.tsx +90 -0
- package/e2e-tests/test-applications/sveltekit-test-app/package.json +21 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/app.d.ts +13 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/app.html +11 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/lib/index.ts +1 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/routes/+page.svelte +2 -0
- package/e2e-tests/test-applications/sveltekit-test-app/svelte.config.js +18 -0
- package/e2e-tests/test-applications/sveltekit-test-app/vite.config.ts +6 -0
- package/e2e-tests/tests/nextjs.test.ts +161 -0
- package/e2e-tests/tests/remix.test.ts +35 -44
- package/e2e-tests/tests/sveltekit.test.ts +154 -0
- package/e2e-tests/utils/index.ts +54 -11
- package/package.json +3 -5
- package/src/apple/templates.ts +5 -1
- package/src/apple/xcode-manager.ts +2 -0
- package/src/nextjs/nextjs-wizard.ts +39 -12
- package/src/nextjs/templates.ts +15 -0
- package/src/utils/clack-utils.ts +4 -2
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
getSentryExamplePageContents,
|
|
45
45
|
getSimpleUnderscoreErrorCopyPasteSnippet,
|
|
46
46
|
getWithSentryConfigOptionsTemplate,
|
|
47
|
+
getNextjsConfigMjsTemplate,
|
|
47
48
|
} from './templates';
|
|
48
49
|
import { traceStep, withTelemetry } from '../telemetry';
|
|
49
50
|
import { getPackageVersion, hasPackageInstalled } from '../utils/package-json';
|
|
@@ -90,10 +91,11 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
90
91
|
);
|
|
91
92
|
Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const { packageManager: packageManagerFromInstallStep } =
|
|
95
|
+
await installPackage({
|
|
96
|
+
packageName: '@sentry/nextjs@^8',
|
|
97
|
+
alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],
|
|
98
|
+
});
|
|
97
99
|
|
|
98
100
|
await traceStep('configure-sdk', async () => {
|
|
99
101
|
const tunnelRoute = await askShouldSetTunnelRoute();
|
|
@@ -195,7 +197,7 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
195
197
|
|
|
196
198
|
const shouldContinue = await abortIfCancelled(
|
|
197
199
|
clack.confirm({
|
|
198
|
-
message: `Did add the code to your ${chalk.cyan(
|
|
200
|
+
message: `Did you add the code to your ${chalk.cyan(
|
|
199
201
|
path.join(...pagesLocation, underscoreErrorPageFile),
|
|
200
202
|
)} file as described above?`,
|
|
201
203
|
active: 'Yes',
|
|
@@ -277,7 +279,7 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
277
279
|
|
|
278
280
|
const shouldContinue = await abortIfCancelled(
|
|
279
281
|
clack.confirm({
|
|
280
|
-
message: `Did add the code to your ${chalk.cyan(
|
|
282
|
+
message: `Did you add the code to your ${chalk.cyan(
|
|
281
283
|
path.join(...appDirLocation, globalErrorPageFile),
|
|
282
284
|
)} file as described above?`,
|
|
283
285
|
active: 'Yes',
|
|
@@ -331,14 +333,15 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
331
333
|
await traceStep('configure-ci', () => configureCI('nextjs', authToken));
|
|
332
334
|
}
|
|
333
335
|
|
|
334
|
-
const
|
|
336
|
+
const packageManagerForOutro =
|
|
337
|
+
packageManagerFromInstallStep ?? (await getPackageManager());
|
|
335
338
|
await runPrettierIfInstalled();
|
|
336
339
|
|
|
337
340
|
clack.outro(`
|
|
338
341
|
${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${
|
|
339
342
|
shouldCreateExamplePage
|
|
340
343
|
? `\n\nYou can validate your setup by (re)starting your dev environment (e.g. ${chalk.cyan(
|
|
341
|
-
`${
|
|
344
|
+
`${packageManagerForOutro.runScriptCommand} dev`,
|
|
342
345
|
)}) and visiting ${chalk.cyan('"/sentry-example-page"')}`
|
|
343
346
|
: ''
|
|
344
347
|
}${
|
|
@@ -562,15 +565,39 @@ async function createOrMergeNextJsFiles(
|
|
|
562
565
|
if (!foundNextConfigFile) {
|
|
563
566
|
Sentry.setTag('next-config-strategy', 'create');
|
|
564
567
|
|
|
568
|
+
// Try to figure out whether the user prefers ESM
|
|
569
|
+
let isTypeModule = false;
|
|
570
|
+
try {
|
|
571
|
+
const packageJsonText = await fs.promises.readFile(
|
|
572
|
+
path.join(process.cwd(), 'package.json'),
|
|
573
|
+
'utf8',
|
|
574
|
+
);
|
|
575
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
576
|
+
const packageJson = JSON.parse(packageJsonText);
|
|
577
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
578
|
+
if (packageJson.type === 'module') {
|
|
579
|
+
isTypeModule = true;
|
|
580
|
+
}
|
|
581
|
+
} catch {
|
|
582
|
+
// noop
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// We are creating `next.config.(m)js` files by default as they are supported by the most Next.js versions
|
|
586
|
+
const configFilename = isTypeModule
|
|
587
|
+
? nextConfigPossibleFilesMap.mjs
|
|
588
|
+
: nextConfigPossibleFilesMap.js;
|
|
589
|
+
const configContent = isTypeModule
|
|
590
|
+
? getNextjsConfigMjsTemplate(withSentryConfigOptionsTemplate)
|
|
591
|
+
: getNextjsConfigCjsTemplate(withSentryConfigOptionsTemplate);
|
|
592
|
+
|
|
565
593
|
await fs.promises.writeFile(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
getNextjsConfigCjsTemplate(withSentryConfigOptionsTemplate),
|
|
594
|
+
path.join(process.cwd(), configFilename),
|
|
595
|
+
configContent,
|
|
569
596
|
{ encoding: 'utf8', flag: 'w' },
|
|
570
597
|
);
|
|
571
598
|
|
|
572
599
|
clack.log.success(
|
|
573
|
-
`Created ${chalk.cyan(
|
|
600
|
+
`Created ${chalk.cyan(configFilename)} with Sentry configuration.`,
|
|
574
601
|
);
|
|
575
602
|
|
|
576
603
|
return;
|
package/src/nextjs/templates.ts
CHANGED
|
@@ -81,6 +81,21 @@ module.exports = withSentryConfig(
|
|
|
81
81
|
`;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
export function getNextjsConfigMjsTemplate(
|
|
85
|
+
withSentryConfigOptionsTemplate: string,
|
|
86
|
+
): string {
|
|
87
|
+
return `import { withSentryConfig } from "@sentry/nextjs";
|
|
88
|
+
|
|
89
|
+
/** @type {import('next').NextConfig} */
|
|
90
|
+
const nextConfig = {};
|
|
91
|
+
|
|
92
|
+
export default withSentryConfig(
|
|
93
|
+
nextConfig,
|
|
94
|
+
${withSentryConfigOptionsTemplate}
|
|
95
|
+
);
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
|
|
84
99
|
export function getNextjsConfigCjsAppendix(
|
|
85
100
|
withSentryConfigOptionsTemplate: string,
|
|
86
101
|
): string {
|
package/src/utils/clack-utils.ts
CHANGED
|
@@ -358,7 +358,7 @@ export async function installPackage({
|
|
|
358
358
|
packageName: string;
|
|
359
359
|
alreadyInstalled: boolean;
|
|
360
360
|
askBeforeUpdating?: boolean;
|
|
361
|
-
}): Promise<
|
|
361
|
+
}): Promise<{ packageManager?: PackageManager }> {
|
|
362
362
|
return traceStep('install-package', async () => {
|
|
363
363
|
if (alreadyInstalled && askBeforeUpdating) {
|
|
364
364
|
const shouldUpdatePackage = await abortIfCancelled(
|
|
@@ -370,7 +370,7 @@ export async function installPackage({
|
|
|
370
370
|
);
|
|
371
371
|
|
|
372
372
|
if (!shouldUpdatePackage) {
|
|
373
|
-
return;
|
|
373
|
+
return {};
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
@@ -428,6 +428,8 @@ export async function installPackage({
|
|
|
428
428
|
packageName,
|
|
429
429
|
)} with ${chalk.bold(packageManager.label)}.`,
|
|
430
430
|
);
|
|
431
|
+
|
|
432
|
+
return { packageManager };
|
|
431
433
|
});
|
|
432
434
|
}
|
|
433
435
|
|