@sentry/wizard 3.36.0 → 3.37.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 +7 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js +7 -13
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +7 -13
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +26 -20
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.d.ts +6 -2
- package/dist/src/nuxt/sdk-setup.js +106 -43
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.d.ts +1 -1
- package/dist/src/nuxt/templates.js +5 -3
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/types.d.ts +2 -0
- package/dist/src/nuxt/types.js +10 -0
- package/dist/src/nuxt/types.js.map +1 -0
- package/dist/src/nuxt/utils.js +42 -6
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +5 -0
- package/dist/src/utils/clack-utils.js +15 -3
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +10 -1
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/e2e-tests/test-applications/nuxt-4-test-app/README.md +75 -0
- package/e2e-tests/test-applications/nuxt-4-test-app/nuxt.config.ts +6 -0
- package/e2e-tests/test-applications/nuxt-4-test-app/package.json +18 -0
- package/e2e-tests/test-applications/nuxt-4-test-app/public/favicon.ico +0 -0
- package/e2e-tests/test-applications/nuxt-4-test-app/public/robots.txt +1 -0
- package/e2e-tests/tests/nuxt-3.test.ts +6 -9
- package/e2e-tests/tests/nuxt-4.test.ts +6 -9
- package/package.json +1 -1
- package/src/nuxt/nuxt-wizard.ts +11 -4
- package/src/nuxt/sdk-setup.ts +134 -37
- package/src/nuxt/templates.ts +15 -8
- package/src/nuxt/types.ts +8 -0
- package/src/nuxt/utils.ts +17 -7
- package/src/utils/clack-utils.ts +13 -1
- package/test/nuxt/templates.test.ts +33 -6
|
@@ -43,32 +43,29 @@ async function runWizardOnNuxtProject(projectDir: string): Promise<void> {
|
|
|
43
43
|
'Please select your package manager.',
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const nftOverridePrompted =
|
|
47
47
|
packageManagerPrompted &&
|
|
48
48
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
49
49
|
// Selecting `yarn` as the package manager
|
|
50
50
|
[KEYS.DOWN, KEYS.ENTER],
|
|
51
|
-
|
|
52
|
-
'Do you want to add an override for nitropack version ~2.9.7?',
|
|
51
|
+
'Do you want to add an override for @vercel/nft version ^0.27.4?',
|
|
53
52
|
{
|
|
54
53
|
timeout: 240_000,
|
|
55
54
|
},
|
|
56
55
|
));
|
|
57
56
|
|
|
58
|
-
const
|
|
59
|
-
|
|
57
|
+
const deploymentPlatformPrompted =
|
|
58
|
+
nftOverridePrompted &&
|
|
60
59
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
61
|
-
// Selecting `yes` to downgrade nitropack
|
|
62
60
|
KEYS.ENTER,
|
|
63
|
-
'
|
|
64
|
-
// 'Do you want to install version',
|
|
61
|
+
'Please select your deployment platform.',
|
|
65
62
|
{
|
|
66
63
|
timeout: 240_000,
|
|
67
64
|
},
|
|
68
65
|
));
|
|
69
66
|
|
|
70
67
|
const tracingOptionPrompted =
|
|
71
|
-
|
|
68
|
+
deploymentPlatformPrompted &&
|
|
72
69
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
73
70
|
KEYS.ENTER,
|
|
74
71
|
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wizard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.37.0",
|
|
4
4
|
"homepage": "https://github.com/getsentry/sentry-wizard",
|
|
5
5
|
"repository": "https://github.com/getsentry/sentry-wizard",
|
|
6
6
|
"description": "Sentry wizard helping you to configure your project",
|
package/src/nuxt/nuxt-wizard.ts
CHANGED
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
getNuxtConfig,
|
|
27
27
|
createConfigFiles,
|
|
28
28
|
addNuxtOverrides,
|
|
29
|
+
askDeploymentPlatform,
|
|
30
|
+
confirmReadImportDocs,
|
|
29
31
|
} from './sdk-setup';
|
|
30
32
|
import {
|
|
31
33
|
createExampleComponent,
|
|
@@ -93,7 +95,7 @@ export async function runNuxtWizardWithTelemetry(
|
|
|
93
95
|
|
|
94
96
|
const packageManager = await getPackageManager();
|
|
95
97
|
|
|
96
|
-
await addNuxtOverrides(packageManager, minVer);
|
|
98
|
+
await addNuxtOverrides(packageJson, packageManager, minVer);
|
|
97
99
|
|
|
98
100
|
const sdkAlreadyInstalled = hasPackageInstalled('@sentry/nuxt', packageJson);
|
|
99
101
|
Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);
|
|
@@ -116,8 +118,10 @@ export async function runNuxtWizardWithTelemetry(
|
|
|
116
118
|
selfHosted,
|
|
117
119
|
};
|
|
118
120
|
|
|
121
|
+
const deploymentPlatform = await askDeploymentPlatform();
|
|
122
|
+
|
|
119
123
|
await traceStep('configure-sdk', async () => {
|
|
120
|
-
await addSDKModule(nuxtConfig, projectData);
|
|
124
|
+
await addSDKModule(nuxtConfig, projectData, deploymentPlatform);
|
|
121
125
|
await createConfigFiles(selectedProject.keys[0].dsn.public);
|
|
122
126
|
});
|
|
123
127
|
|
|
@@ -148,6 +152,8 @@ export async function runNuxtWizardWithTelemetry(
|
|
|
148
152
|
|
|
149
153
|
await runPrettierIfInstalled();
|
|
150
154
|
|
|
155
|
+
await confirmReadImportDocs(deploymentPlatform);
|
|
156
|
+
|
|
151
157
|
clack.outro(
|
|
152
158
|
buildOutroMessage(shouldCreateExamplePage, shouldCreateExampleButton),
|
|
153
159
|
);
|
|
@@ -170,8 +176,9 @@ function buildOutroMessage(
|
|
|
170
176
|
)} component to a page and triggering it.`;
|
|
171
177
|
}
|
|
172
178
|
|
|
173
|
-
msg += `\n\nCheck out the SDK documentation for further configuration:
|
|
174
|
-
https://docs.sentry.io/platforms/javascript/guides/nuxt
|
|
179
|
+
msg += `\n\nCheck out the SDK documentation for further configuration: ${chalk.underline(
|
|
180
|
+
'https://docs.sentry.io/platforms/javascript/guides/nuxt/',
|
|
181
|
+
)}`;
|
|
175
182
|
|
|
176
183
|
return msg;
|
|
177
184
|
}
|
package/src/nuxt/sdk-setup.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
2
|
-
import clack from '@clack/prompts';
|
|
2
|
+
import * as clack from '@clack/prompts';
|
|
3
3
|
import * as Sentry from '@sentry/node';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
7
|
-
import { loadFile, generateCode
|
|
7
|
+
import { loadFile, generateCode } from 'magicast';
|
|
8
8
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
9
9
|
import { addNuxtModule } from 'magicast/helpers';
|
|
10
10
|
import path from 'path';
|
|
@@ -15,15 +15,19 @@ import {
|
|
|
15
15
|
getSentryConfigContents,
|
|
16
16
|
} from './templates';
|
|
17
17
|
import {
|
|
18
|
-
abort,
|
|
19
18
|
abortIfCancelled,
|
|
20
19
|
askShouldAddPackageOverride,
|
|
20
|
+
askShouldInstallPackage,
|
|
21
21
|
featureSelectionPrompt,
|
|
22
|
+
installPackage,
|
|
22
23
|
isUsingTypeScript,
|
|
24
|
+
opn,
|
|
23
25
|
} from '../utils/clack-utils';
|
|
24
26
|
import { traceStep } from '../telemetry';
|
|
25
27
|
import { lt, SemVer } from 'semver';
|
|
26
|
-
import { PackageManager } from '../utils/package-manager';
|
|
28
|
+
import { PackageManager, PNPM } from '../utils/package-manager';
|
|
29
|
+
import { hasPackageInstalled, PackageDotJson } from '../utils/package-json';
|
|
30
|
+
import { deploymentPlatforms, DeploymentPlatform } from './types';
|
|
27
31
|
|
|
28
32
|
const possibleNuxtConfig = [
|
|
29
33
|
'nuxt.config.js',
|
|
@@ -57,10 +61,40 @@ export async function getNuxtConfig(): Promise<string> {
|
|
|
57
61
|
return path.join(process.cwd(), configFile);
|
|
58
62
|
}
|
|
59
63
|
|
|
64
|
+
export async function askDeploymentPlatform(): Promise<
|
|
65
|
+
DeploymentPlatform | symbol
|
|
66
|
+
> {
|
|
67
|
+
return await abortIfCancelled(
|
|
68
|
+
clack.select({
|
|
69
|
+
message: 'Please select your deployment platform.',
|
|
70
|
+
options: deploymentPlatforms.map((platform) => ({
|
|
71
|
+
value: platform,
|
|
72
|
+
label: `${platform.charAt(0).toUpperCase()}${platform.slice(1)}`,
|
|
73
|
+
})),
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
60
78
|
export async function addSDKModule(
|
|
61
79
|
config: string,
|
|
62
80
|
options: { org: string; project: string; url: string; selfHosted: boolean },
|
|
81
|
+
deploymentPlatform: DeploymentPlatform | symbol,
|
|
63
82
|
): Promise<void> {
|
|
83
|
+
const shouldTopLevelImport =
|
|
84
|
+
deploymentPlatform === 'vercel' || deploymentPlatform === 'netlify';
|
|
85
|
+
|
|
86
|
+
if (shouldTopLevelImport) {
|
|
87
|
+
clack.log.warn(
|
|
88
|
+
`Sentry needs to be initialized before the application starts. ${chalk.cyan(
|
|
89
|
+
`${deploymentPlatform
|
|
90
|
+
.charAt(0)
|
|
91
|
+
.toUpperCase()}${deploymentPlatform.slice(1)}`,
|
|
92
|
+
)} does not support this yet.\n\nWe will inject the Sentry server-side config at the top of your Nuxt server entry file instead.\n\nThis comes with some restrictions, for more info see:\n\n${chalk.underline(
|
|
93
|
+
'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/top-level-import/',
|
|
94
|
+
)} `,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
64
98
|
try {
|
|
65
99
|
const mod = await loadFile(config);
|
|
66
100
|
|
|
@@ -70,6 +104,9 @@ export async function addSDKModule(
|
|
|
70
104
|
project: options.project,
|
|
71
105
|
...(options.selfHosted && { url: options.url }),
|
|
72
106
|
},
|
|
107
|
+
...(shouldTopLevelImport && {
|
|
108
|
+
autoInjectServerSentry: 'top-level-import',
|
|
109
|
+
}),
|
|
73
110
|
});
|
|
74
111
|
addNuxtModule(mod, '@sentry/nuxt/module', 'sourcemap', {
|
|
75
112
|
client: 'hidden',
|
|
@@ -83,33 +120,31 @@ export async function addSDKModule(
|
|
|
83
120
|
`Added Sentry Nuxt Module to ${chalk.cyan(path.basename(config))}.`,
|
|
84
121
|
);
|
|
85
122
|
} catch (e: unknown) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
await abort('Exiting Wizard');
|
|
112
|
-
}
|
|
123
|
+
clack.log.error(
|
|
124
|
+
'Error while adding the Sentry Nuxt Module to the Nuxt config.',
|
|
125
|
+
);
|
|
126
|
+
clack.log.info(
|
|
127
|
+
chalk.dim(
|
|
128
|
+
typeof e === 'object' && e != null && 'toString' in e
|
|
129
|
+
? e.toString()
|
|
130
|
+
: typeof e === 'string'
|
|
131
|
+
? e
|
|
132
|
+
: 'Unknown error',
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
Sentry.captureException(
|
|
136
|
+
'Error while setting up the Nuxt Module in nuxt config',
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
clack.log.warn(
|
|
140
|
+
`Please add the following settings to ${chalk.cyan(
|
|
141
|
+
path.basename(config),
|
|
142
|
+
)}:`,
|
|
143
|
+
);
|
|
144
|
+
// eslint-disable-next-line no-console
|
|
145
|
+
console.log(
|
|
146
|
+
`\n\n${getNuxtModuleFallbackTemplate(options, shouldTopLevelImport)}\n\n`,
|
|
147
|
+
);
|
|
113
148
|
}
|
|
114
149
|
}
|
|
115
150
|
|
|
@@ -212,14 +247,13 @@ export async function createConfigFiles(dsn: string) {
|
|
|
212
247
|
}
|
|
213
248
|
|
|
214
249
|
export async function addNuxtOverrides(
|
|
250
|
+
packageJson: PackageDotJson,
|
|
215
251
|
packageManager: PackageManager,
|
|
216
252
|
nuxtMinVer: SemVer | null,
|
|
217
253
|
) {
|
|
254
|
+
const isPNPM = PNPM.detect();
|
|
255
|
+
|
|
218
256
|
const overrides = [
|
|
219
|
-
{
|
|
220
|
-
pkgName: 'nitropack',
|
|
221
|
-
pkgVersion: '~2.9.7',
|
|
222
|
-
},
|
|
223
257
|
{
|
|
224
258
|
pkgName: '@vercel/nft',
|
|
225
259
|
pkgVersion: '^0.27.4',
|
|
@@ -230,9 +264,17 @@ export async function addNuxtOverrides(
|
|
|
230
264
|
];
|
|
231
265
|
|
|
232
266
|
clack.log.warn(
|
|
233
|
-
`To ensure Sentry can properly instrument your code it needs to add version overrides for some Nuxt dependencies
|
|
267
|
+
`To ensure Sentry can properly instrument your code it needs to add version overrides for some Nuxt dependencies${
|
|
268
|
+
isPNPM ? ` and install ${chalk.cyan('import-in-the-middle')}.` : '.'
|
|
269
|
+
}\n\nFor more info see: ${chalk.underline(
|
|
234
270
|
'https://github.com/getsentry/sentry-javascript/issues/14514',
|
|
235
|
-
)}
|
|
271
|
+
)}${
|
|
272
|
+
isPNPM
|
|
273
|
+
? `\n\nand ${chalk.underline(
|
|
274
|
+
'https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle',
|
|
275
|
+
)}`
|
|
276
|
+
: ''
|
|
277
|
+
}`,
|
|
236
278
|
);
|
|
237
279
|
|
|
238
280
|
for (const { pkgName, pkgVersion } of overrides) {
|
|
@@ -245,4 +287,59 @@ export async function addNuxtOverrides(
|
|
|
245
287
|
await packageManager.addOverride(pkgName, pkgVersion);
|
|
246
288
|
}
|
|
247
289
|
}
|
|
290
|
+
|
|
291
|
+
if (PNPM.detect()) {
|
|
292
|
+
// For pnpm, we want to install iitm
|
|
293
|
+
// See: https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle
|
|
294
|
+
const iitmAlreadyInstalled = hasPackageInstalled(
|
|
295
|
+
'import-in-the-middle',
|
|
296
|
+
packageJson,
|
|
297
|
+
);
|
|
298
|
+
Sentry.setTag('iitm-already-installed', iitmAlreadyInstalled);
|
|
299
|
+
|
|
300
|
+
const shouldInstallIitm = await askShouldInstallPackage(
|
|
301
|
+
'import-in-the-middle',
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
if (shouldInstallIitm) {
|
|
305
|
+
await installPackage({
|
|
306
|
+
packageName: 'import-in-the-middle',
|
|
307
|
+
alreadyInstalled: iitmAlreadyInstalled,
|
|
308
|
+
packageManager,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export async function confirmReadImportDocs(
|
|
315
|
+
deploymentPlatform: DeploymentPlatform | symbol,
|
|
316
|
+
) {
|
|
317
|
+
const canImportSentryServerConfigFile =
|
|
318
|
+
deploymentPlatform !== 'vercel' && deploymentPlatform !== 'netlify';
|
|
319
|
+
|
|
320
|
+
if (!canImportSentryServerConfigFile) {
|
|
321
|
+
// Nothing to do, users have been set up with automatic top-level-import instead
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const docsUrl =
|
|
326
|
+
'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cli-import/#initializing-sentry-with---import';
|
|
327
|
+
|
|
328
|
+
clack.log.info(
|
|
329
|
+
`After building your Nuxt app, you need to ${chalk.bold(
|
|
330
|
+
'--import',
|
|
331
|
+
)} the Sentry server config file when running your app.\n\nFor more info, see:\n\n${chalk.underline(
|
|
332
|
+
docsUrl,
|
|
333
|
+
)}`,
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
const shouldOpenDocs = await abortIfCancelled(
|
|
337
|
+
clack.confirm({ message: 'Do you want to open the docs?' }),
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
if (shouldOpenDocs) {
|
|
341
|
+
opn(docsUrl, { wait: false }).catch(() => {
|
|
342
|
+
// opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here
|
|
343
|
+
});
|
|
344
|
+
}
|
|
248
345
|
}
|
package/src/nuxt/templates.ts
CHANGED
|
@@ -14,12 +14,15 @@ export default defineNuxtConfig({
|
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function getNuxtModuleFallbackTemplate(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
export function getNuxtModuleFallbackTemplate(
|
|
18
|
+
options: {
|
|
19
|
+
org: string;
|
|
20
|
+
project: string;
|
|
21
|
+
url: string;
|
|
22
|
+
selfHosted: boolean;
|
|
23
|
+
},
|
|
24
|
+
shouldTopLevelImport: boolean,
|
|
25
|
+
): string {
|
|
23
26
|
return ` modules: ["@sentry/nuxt/module"],
|
|
24
27
|
sentry: {
|
|
25
28
|
sourceMapsUploadOptions: {
|
|
@@ -27,7 +30,11 @@ export function getNuxtModuleFallbackTemplate(options: {
|
|
|
27
30
|
project: "${options.project}",${
|
|
28
31
|
options.selfHosted ? `\n url: "${options.url}",` : ''
|
|
29
32
|
}
|
|
30
|
-
}
|
|
33
|
+
},${
|
|
34
|
+
shouldTopLevelImport
|
|
35
|
+
? `\n autoInjectServerSentry: "top-level-import",`
|
|
36
|
+
: ''
|
|
37
|
+
}
|
|
31
38
|
},
|
|
32
39
|
sourcemap: { client: "hidden" },`;
|
|
33
40
|
}
|
|
@@ -239,7 +246,7 @@ export function getSentryExampleApiTemplate() {
|
|
|
239
246
|
// Feel free to delete this file.
|
|
240
247
|
import { defineEventHandler } from '#imports';
|
|
241
248
|
|
|
242
|
-
export default defineEventHandler(
|
|
249
|
+
export default defineEventHandler(() => {
|
|
243
250
|
throw new Error("Sentry Example API Route Error");
|
|
244
251
|
});
|
|
245
252
|
`;
|
package/src/nuxt/utils.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
+
import * as clack from '@clack/prompts';
|
|
1
3
|
import { gte, minVersion } from 'semver';
|
|
2
4
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
3
5
|
import { loadFile } from 'magicast';
|
|
6
|
+
import { abortIfCancelled } from '../utils/clack-utils';
|
|
4
7
|
|
|
5
8
|
export async function isNuxtV4(
|
|
6
9
|
nuxtConfig: string,
|
|
@@ -18,14 +21,21 @@ export async function isNuxtV4(
|
|
|
18
21
|
// At the time of writing, nuxt 4 is not on its own
|
|
19
22
|
// major yet. We must read the `compatibilityVersion`
|
|
20
23
|
// from the nuxt config.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
try {
|
|
25
|
+
const mod = await loadFile(nuxtConfig);
|
|
26
|
+
const config =
|
|
27
|
+
mod.exports.default.$type === 'function-call'
|
|
28
|
+
? mod.exports.default.$args[0]
|
|
29
|
+
: mod.exports.default;
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
if (config && config.future && config.future.compatibilityVersion === 4) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
// If we cannot parse their config, just ask.
|
|
36
|
+
return await abortIfCancelled(
|
|
37
|
+
clack.confirm({ message: 'Are you using Nuxt version 4?' }),
|
|
38
|
+
);
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
return false;
|
package/src/utils/clack-utils.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { debug } from './debug';
|
|
21
21
|
import { fulfillsVersionRange } from './semver';
|
|
22
22
|
|
|
23
|
-
const opn = require('opn') as (
|
|
23
|
+
export const opn = require('opn') as (
|
|
24
24
|
url: string,
|
|
25
25
|
options?: {
|
|
26
26
|
wait?: boolean;
|
|
@@ -1492,6 +1492,18 @@ export async function featureSelectionPrompt<F extends ReadonlyArray<Feature>>(
|
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
1494
|
|
|
1495
|
+
export async function askShouldInstallPackage(
|
|
1496
|
+
pkgName: string,
|
|
1497
|
+
): Promise<boolean> {
|
|
1498
|
+
return traceStep(`ask-install-package`, () =>
|
|
1499
|
+
abortIfCancelled(
|
|
1500
|
+
clack.confirm({
|
|
1501
|
+
message: `Do you want to install ${chalk.cyan(pkgName)}?`,
|
|
1502
|
+
}),
|
|
1503
|
+
),
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1495
1507
|
export async function askShouldAddPackageOverride(
|
|
1496
1508
|
pkgName: string,
|
|
1497
1509
|
pkgVersion: string,
|
|
@@ -206,12 +206,38 @@ describe('Nuxt code templates', () => {
|
|
|
206
206
|
|
|
207
207
|
describe('getNuxtModuleFallbackTemplate', () => {
|
|
208
208
|
it('generates configuration options for the nuxt config', () => {
|
|
209
|
-
const template = getNuxtModuleFallbackTemplate(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
const template = getNuxtModuleFallbackTemplate(
|
|
210
|
+
{
|
|
211
|
+
org: 'my-org',
|
|
212
|
+
project: 'my-project',
|
|
213
|
+
url: 'https://sentry.io',
|
|
214
|
+
selfHosted: false,
|
|
215
|
+
},
|
|
216
|
+
false,
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
expect(template).toMatchInlineSnapshot(`
|
|
220
|
+
" modules: ["@sentry/nuxt/module"],
|
|
221
|
+
sentry: {
|
|
222
|
+
sourceMapsUploadOptions: {
|
|
223
|
+
org: "my-org",
|
|
224
|
+
project: "my-project",
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
sourcemap: { client: "hidden" },"
|
|
228
|
+
`);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('generates configuration options for the nuxt config with top level import', () => {
|
|
232
|
+
const template = getNuxtModuleFallbackTemplate(
|
|
233
|
+
{
|
|
234
|
+
org: 'my-org',
|
|
235
|
+
project: 'my-project',
|
|
236
|
+
url: 'https://sentry.io',
|
|
237
|
+
selfHosted: false,
|
|
238
|
+
},
|
|
239
|
+
true,
|
|
240
|
+
);
|
|
215
241
|
|
|
216
242
|
expect(template).toMatchInlineSnapshot(`
|
|
217
243
|
" modules: ["@sentry/nuxt/module"],
|
|
@@ -220,6 +246,7 @@ describe('Nuxt code templates', () => {
|
|
|
220
246
|
org: "my-org",
|
|
221
247
|
project: "my-project",
|
|
222
248
|
},
|
|
249
|
+
autoInjectServerSentry: "top-level-import",
|
|
223
250
|
},
|
|
224
251
|
sourcemap: { client: "hidden" },"
|
|
225
252
|
`);
|