@sentry/wizard 3.35.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 +12 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js +45 -25
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +45 -25
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/android/templates.js +1 -1
- package/dist/src/android/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +36 -23
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.d.ts +8 -1
- package/dist/src/nuxt/sdk-setup.js +149 -35
- 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 +9 -1
- package/dist/src/utils/clack-utils.js +81 -23
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-json.d.ts +5 -0
- package/dist/src/utils/package-json.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +1 -0
- package/dist/src/utils/package-manager.js +129 -0
- package/dist/src/utils/package-manager.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 +23 -3
- package/e2e-tests/tests/nuxt-4.test.ts +22 -2
- package/e2e-tests/utils/index.ts +4 -1
- package/package.json +1 -1
- package/src/android/templates.ts +0 -2
- package/src/nuxt/nuxt-wizard.ts +23 -5
- package/src/nuxt/sdk-setup.ts +166 -30
- 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 +55 -6
- package/src/utils/package-json.ts +5 -0
- package/src/utils/package-manager.ts +66 -0
- package/test/nuxt/templates.test.ts +33 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-wizard.js","sourceRoot":"","sources":["../../../src/nuxt/nuxt-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,mDAAuC;AACvC,iCAAwC;AAExC,0CAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"nuxt-wizard.js","sourceRoot":"","sources":["../../../src/nuxt/nuxt-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,mDAAuC;AACvC,gDAA0B;AAC1B,iCAAwC;AAExC,0CAAwD;AACxD,oDAc8B;AAC9B,sDAA+E;AAC/E,yCAOqB;AACrB,6CAIuB;AACvB,iCAAmC;AAEnC,SAAgB,aAAa,CAAC,OAAsB;IAClD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,OAAO;KAC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oBAE/B,qBAAM,IAAA,iCAAqB,EAAC,kBAAkB,CAAC,EAAA;;oBAA/C,SAA+C,CAAC;oBAEhD,KAAK,CAAC,KAAK,CACT,iBAAiB,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,CACtE,CAAC;;;;;CACH;AA9GD,gEA8GC;AAED,SAAS,iBAAiB,CACxB,uBAAgC,EAChC,yBAAkC;IAElC,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAEvE,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,sDAA+C,eAAK,CAAC,IAAI,CAC9D,wBAAwB,CACzB,MAAG,CAAC;KACN;IACD,IAAI,yBAAyB,EAAE;QAC7B,GAAG,IAAI,wDAAiD,eAAK,CAAC,IAAI,CAChE,uBAAuB,CACxB,4CAAyC,CAAC;KAC5C;IAED,GAAG,IAAI,yEAAkE,eAAK,CAAC,SAAS,CACtF,0DAA0D,CAC3D,CAAE,CAAC;IAEJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport { lt, minVersion } from 'semver';\nimport type { WizardOptions } from '../utils/types';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExampleComponent,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport {\n addSDKModule,\n getNuxtConfig,\n createConfigFiles,\n addNuxtOverrides,\n askDeploymentPlatform,\n confirmReadImportDocs,\n} from './sdk-setup';\nimport {\n createExampleComponent,\n createExamplePage,\n supportsExamplePage,\n} from './sdk-example';\nimport { isNuxtV4 } from './utils';\n\nexport function runNuxtWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nuxt',\n wizardOptions: options,\n },\n () => runNuxtWizardWithTelemetry(options),\n );\n}\n\nexport async function runNuxtWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Nuxt Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, 'nuxt', 'Nuxt');\n\n const nuxtVersion = getPackageVersion('nuxt', packageJson);\n Sentry.setTag('nuxt-version', nuxtVersion);\n\n const minVer = minVersion(nuxtVersion || '0.0.0');\n\n if (!nuxtVersion || !minVer || lt(minVer, '3.7.0')) {\n clack.log.warn(\n \"It seems you're using a Nuxt version <3.7.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n const { authToken, selectedProject, selfHosted, sentryUrl } =\n await getOrAskForProjectData(options, 'javascript-nuxt');\n\n const packageManager = await getPackageManager();\n\n await addNuxtOverrides(packageJson, packageManager, minVer);\n\n const sdkAlreadyInstalled = hasPackageInstalled('@sentry/nuxt', packageJson);\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/nuxt',\n alreadyInstalled: sdkAlreadyInstalled,\n packageManager,\n });\n\n await addDotEnvSentryBuildPluginFile(authToken);\n\n const nuxtConfig = await traceStep('load-nuxt-config', getNuxtConfig);\n\n const projectData = {\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n selfHosted,\n };\n\n const deploymentPlatform = await askDeploymentPlatform();\n\n await traceStep('configure-sdk', async () => {\n await addSDKModule(nuxtConfig, projectData, deploymentPlatform);\n await createConfigFiles(selectedProject.keys[0].dsn.public);\n });\n\n let shouldCreateExamplePage = false;\n let shouldCreateExampleButton = false;\n\n const isV4 = await isNuxtV4(nuxtConfig, nuxtVersion);\n const canCreateExamplePage = await supportsExamplePage(isV4);\n Sentry.setTag('supports-example-page-creation', canCreateExamplePage);\n\n if (canCreateExamplePage) {\n shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('create-example-page', async () =>\n createExamplePage(isV4, projectData),\n );\n }\n } else {\n shouldCreateExampleButton = await askShouldCreateExampleComponent();\n\n if (shouldCreateExampleButton) {\n await traceStep('create-example-component', async () =>\n createExampleComponent(isV4),\n );\n }\n }\n\n await runPrettierIfInstalled();\n\n await confirmReadImportDocs(deploymentPlatform);\n\n clack.outro(\n buildOutroMessage(shouldCreateExamplePage, shouldCreateExampleButton),\n );\n}\n\nfunction buildOutroMessage(\n shouldCreateExamplePage: boolean,\n shouldCreateExampleButton: boolean,\n): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Nuxt SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by visiting ${chalk.cyan(\n '\"/sentry-example-page\"',\n )}.`;\n }\n if (shouldCreateExampleButton) {\n msg += `\\n\\nYou can validate your setup by adding the ${chalk.cyan(\n '`SentryExampleButton`',\n )} component to a page and triggering it.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration: ${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/',\n )}`;\n\n return msg;\n}\n"]}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { SemVer } from 'semver';
|
|
2
|
+
import { PackageManager } from '../utils/package-manager';
|
|
3
|
+
import { PackageDotJson } from '../utils/package-json';
|
|
4
|
+
import { DeploymentPlatform } from './types';
|
|
1
5
|
export declare function getNuxtConfig(): Promise<string>;
|
|
6
|
+
export declare function askDeploymentPlatform(): Promise<DeploymentPlatform | symbol>;
|
|
2
7
|
export declare function addSDKModule(config: string, options: {
|
|
3
8
|
org: string;
|
|
4
9
|
project: string;
|
|
5
10
|
url: string;
|
|
6
11
|
selfHosted: boolean;
|
|
7
|
-
}): Promise<void>;
|
|
12
|
+
}, deploymentPlatform: DeploymentPlatform | symbol): Promise<void>;
|
|
8
13
|
export declare function createConfigFiles(dsn: string): Promise<void>;
|
|
14
|
+
export declare function addNuxtOverrides(packageJson: PackageDotJson, packageManager: PackageManager, nuxtMinVer: SemVer | null): Promise<void>;
|
|
15
|
+
export declare function confirmReadImportDocs(deploymentPlatform: DeploymentPlatform | symbol): Promise<void>;
|
|
@@ -69,13 +69,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
|
+
if (ar || !(i in from)) {
|
|
75
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
76
|
+
ar[i] = from[i];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
80
|
+
};
|
|
72
81
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
82
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
83
|
};
|
|
75
84
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
-
exports.createConfigFiles = exports.addSDKModule = exports.getNuxtConfig = void 0;
|
|
85
|
+
exports.confirmReadImportDocs = exports.addNuxtOverrides = exports.createConfigFiles = exports.addSDKModule = exports.askDeploymentPlatform = exports.getNuxtConfig = void 0;
|
|
77
86
|
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
78
|
-
var
|
|
87
|
+
var clack = __importStar(require("@clack/prompts"));
|
|
79
88
|
var Sentry = __importStar(require("@sentry/node"));
|
|
80
89
|
var chalk_1 = __importDefault(require("chalk"));
|
|
81
90
|
var fs_1 = __importDefault(require("fs"));
|
|
@@ -87,6 +96,10 @@ var path_1 = __importDefault(require("path"));
|
|
|
87
96
|
var templates_1 = require("./templates");
|
|
88
97
|
var clack_utils_1 = require("../utils/clack-utils");
|
|
89
98
|
var telemetry_1 = require("../telemetry");
|
|
99
|
+
var semver_1 = require("semver");
|
|
100
|
+
var package_manager_1 = require("../utils/package-manager");
|
|
101
|
+
var package_json_1 = require("../utils/package-json");
|
|
102
|
+
var types_1 = require("./types");
|
|
90
103
|
var possibleNuxtConfig = [
|
|
91
104
|
'nuxt.config.js',
|
|
92
105
|
'nuxt.config.mjs',
|
|
@@ -105,14 +118,14 @@ function getNuxtConfig() {
|
|
|
105
118
|
return fs_1.default.existsSync(path_1.default.join(process.cwd(), fileName));
|
|
106
119
|
});
|
|
107
120
|
if (!!configFile) return [3 /*break*/, 2];
|
|
108
|
-
|
|
121
|
+
clack.log.info('No Nuxt config file found, creating a new one.');
|
|
109
122
|
Sentry.setTag('nuxt-config-strategy', 'create');
|
|
110
123
|
// nuxt recommends its config to be .ts by default
|
|
111
124
|
configFile = 'nuxt.config.ts';
|
|
112
125
|
return [4 /*yield*/, fs_1.default.promises.writeFile(path_1.default.join(process.cwd(), configFile), (0, templates_1.getDefaultNuxtConfig)(), { encoding: 'utf-8', flag: 'w' })];
|
|
113
126
|
case 1:
|
|
114
127
|
_a.sent();
|
|
115
|
-
|
|
128
|
+
clack.log.success("Created ".concat(chalk_1.default.cyan('nuxt.config.ts'), "."));
|
|
116
129
|
_a.label = 2;
|
|
117
130
|
case 2: return [2 /*return*/, path_1.default.join(process.cwd(), configFile)];
|
|
118
131
|
}
|
|
@@ -120,49 +133,67 @@ function getNuxtConfig() {
|
|
|
120
133
|
});
|
|
121
134
|
}
|
|
122
135
|
exports.getNuxtConfig = getNuxtConfig;
|
|
123
|
-
function
|
|
136
|
+
function askDeploymentPlatform() {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0: return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.select({
|
|
141
|
+
message: 'Please select your deployment platform.',
|
|
142
|
+
options: types_1.deploymentPlatforms.map(function (platform) { return ({
|
|
143
|
+
value: platform,
|
|
144
|
+
label: "".concat(platform.charAt(0).toUpperCase()).concat(platform.slice(1)),
|
|
145
|
+
}); }),
|
|
146
|
+
}))];
|
|
147
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
exports.askDeploymentPlatform = askDeploymentPlatform;
|
|
153
|
+
function addSDKModule(config, options, deploymentPlatform) {
|
|
124
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
-
var mod, code, e_1;
|
|
155
|
+
var shouldTopLevelImport, mod, code, e_1;
|
|
126
156
|
return __generator(this, function (_a) {
|
|
127
157
|
switch (_a.label) {
|
|
128
158
|
case 0:
|
|
129
|
-
|
|
130
|
-
|
|
159
|
+
shouldTopLevelImport = deploymentPlatform === 'vercel' || deploymentPlatform === 'netlify';
|
|
160
|
+
if (shouldTopLevelImport) {
|
|
161
|
+
clack.log.warn("Sentry needs to be initialized before the application starts. ".concat(chalk_1.default.cyan("".concat(deploymentPlatform
|
|
162
|
+
.charAt(0)
|
|
163
|
+
.toUpperCase()).concat(deploymentPlatform.slice(1))), " 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").concat(chalk_1.default.underline('https://docs.sentry.io/platforms/javascript/guides/nuxt/install/top-level-import/'), " "));
|
|
164
|
+
}
|
|
165
|
+
_a.label = 1;
|
|
131
166
|
case 1:
|
|
167
|
+
_a.trys.push([1, 4, , 5]);
|
|
168
|
+
return [4 /*yield*/, (0, magicast_1.loadFile)(config)];
|
|
169
|
+
case 2:
|
|
132
170
|
mod = _a.sent();
|
|
133
|
-
(0, helpers_1.addNuxtModule)(mod, '@sentry/nuxt/module', 'sentry', {
|
|
134
|
-
|
|
135
|
-
});
|
|
171
|
+
(0, helpers_1.addNuxtModule)(mod, '@sentry/nuxt/module', 'sentry', __assign({ sourceMapsUploadOptions: __assign({ org: options.org, project: options.project }, (options.selfHosted && { url: options.url })) }, (shouldTopLevelImport && {
|
|
172
|
+
autoInjectServerSentry: 'top-level-import',
|
|
173
|
+
})));
|
|
136
174
|
(0, helpers_1.addNuxtModule)(mod, '@sentry/nuxt/module', 'sourcemap', {
|
|
137
175
|
client: 'hidden',
|
|
138
176
|
});
|
|
139
177
|
code = (0, magicast_1.generateCode)(mod).code;
|
|
140
178
|
return [4 /*yield*/, fs_1.default.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' })];
|
|
141
|
-
case 2:
|
|
142
|
-
_a.sent();
|
|
143
|
-
prompts_1.default.log.success("Added Sentry Nuxt Module to ".concat(chalk_1.default.cyan(path_1.default.basename(config)), "."));
|
|
144
|
-
return [3 /*break*/, 7];
|
|
145
179
|
case 3:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// eslint-disable-next-line no-console
|
|
150
|
-
console.log("\n\n".concat((0, templates_1.getNuxtModuleFallbackTemplate)(options), "\n\n"));
|
|
151
|
-
return [3 /*break*/, 6];
|
|
180
|
+
_a.sent();
|
|
181
|
+
clack.log.success("Added Sentry Nuxt Module to ".concat(chalk_1.default.cyan(path_1.default.basename(config)), "."));
|
|
182
|
+
return [3 /*break*/, 5];
|
|
152
183
|
case 4:
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
e_1 = _a.sent();
|
|
185
|
+
clack.log.error('Error while adding the Sentry Nuxt Module to the Nuxt config.');
|
|
186
|
+
clack.log.info(chalk_1.default.dim(typeof e_1 === 'object' && e_1 != null && 'toString' in e_1
|
|
155
187
|
? e_1.toString()
|
|
156
188
|
: typeof e_1 === 'string'
|
|
157
189
|
? e_1
|
|
158
190
|
: 'Unknown error'));
|
|
159
|
-
Sentry.captureException('Error while setting up the Nuxt
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
case
|
|
165
|
-
case 7: return [2 /*return*/];
|
|
191
|
+
Sentry.captureException('Error while setting up the Nuxt Module in nuxt config');
|
|
192
|
+
clack.log.warn("Please add the following settings to ".concat(chalk_1.default.cyan(path_1.default.basename(config)), ":"));
|
|
193
|
+
// eslint-disable-next-line no-console
|
|
194
|
+
console.log("\n\n".concat((0, templates_1.getNuxtModuleFallbackTemplate)(options, shouldTopLevelImport), "\n\n"));
|
|
195
|
+
return [3 /*break*/, 5];
|
|
196
|
+
case 5: return [2 /*return*/];
|
|
166
197
|
}
|
|
167
198
|
});
|
|
168
199
|
});
|
|
@@ -211,7 +242,7 @@ function createConfigFiles(dsn) {
|
|
|
211
242
|
if (tsConfigExists) {
|
|
212
243
|
existingConfigs.push(tsConfig);
|
|
213
244
|
}
|
|
214
|
-
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(
|
|
245
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.confirm({
|
|
215
246
|
message: "Found existing Sentry ".concat(configVariant, " config (").concat(existingConfigs.join(', '), "). Overwrite ").concat(existingConfigs.length > 1 ? 'them' : 'it', "?"),
|
|
216
247
|
}))];
|
|
217
248
|
case 1:
|
|
@@ -221,11 +252,11 @@ function createConfigFiles(dsn) {
|
|
|
221
252
|
if (overwriteExistingConfigs) {
|
|
222
253
|
if (jsConfigExists) {
|
|
223
254
|
fs_1.default.unlinkSync(path_1.default.join(process.cwd(), jsConfig));
|
|
224
|
-
|
|
255
|
+
clack.log.warn("Removed existing ".concat(chalk_1.default.cyan(jsConfig), "."));
|
|
225
256
|
}
|
|
226
257
|
if (tsConfigExists) {
|
|
227
258
|
fs_1.default.unlinkSync(path_1.default.join(process.cwd(), tsConfig));
|
|
228
|
-
|
|
259
|
+
clack.log.warn("Removed existing ".concat(chalk_1.default.cyan(tsConfig), "."));
|
|
229
260
|
}
|
|
230
261
|
}
|
|
231
262
|
_a.label = 2;
|
|
@@ -234,11 +265,11 @@ function createConfigFiles(dsn) {
|
|
|
234
265
|
return [4 /*yield*/, fs_1.default.promises.writeFile(path_1.default.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig), (0, templates_1.getSentryConfigContents)(dsn, configVariant, selectedFeatures), { encoding: 'utf8', flag: 'w' })];
|
|
235
266
|
case 3:
|
|
236
267
|
_a.sent();
|
|
237
|
-
|
|
268
|
+
clack.log.success("Created new ".concat(chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig), "."));
|
|
238
269
|
Sentry.setTag("created-".concat(configVariant, "-config"), true);
|
|
239
270
|
return [3 /*break*/, 5];
|
|
240
271
|
case 4:
|
|
241
|
-
|
|
272
|
+
clack.log.info("Okay, here are the changes your ".concat(chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig), " should contain:"));
|
|
242
273
|
// eslint-disable-next-line no-console
|
|
243
274
|
console.log('\n\n ' +
|
|
244
275
|
(0, templates_1.getConfigBody)(dsn, configVariant, selectedFeatures) +
|
|
@@ -272,4 +303,87 @@ function createConfigFiles(dsn) {
|
|
|
272
303
|
});
|
|
273
304
|
}
|
|
274
305
|
exports.createConfigFiles = createConfigFiles;
|
|
306
|
+
function addNuxtOverrides(packageJson, packageManager, nuxtMinVer) {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
308
|
+
var isPNPM, overrides, _i, overrides_1, _a, pkgName, pkgVersion, shouldAddOverride, iitmAlreadyInstalled, shouldInstallIitm;
|
|
309
|
+
return __generator(this, function (_b) {
|
|
310
|
+
switch (_b.label) {
|
|
311
|
+
case 0:
|
|
312
|
+
isPNPM = package_manager_1.PNPM.detect();
|
|
313
|
+
overrides = __spreadArray([
|
|
314
|
+
{
|
|
315
|
+
pkgName: '@vercel/nft',
|
|
316
|
+
pkgVersion: '^0.27.4',
|
|
317
|
+
}
|
|
318
|
+
], (nuxtMinVer && (0, semver_1.lt)(nuxtMinVer, '3.14.0')
|
|
319
|
+
? [{ pkgName: 'ofetch', pkgVersion: '^1.4.0' }]
|
|
320
|
+
: []), true);
|
|
321
|
+
clack.log.warn("To ensure Sentry can properly instrument your code it needs to add version overrides for some Nuxt dependencies".concat(isPNPM ? " and install ".concat(chalk_1.default.cyan('import-in-the-middle'), ".") : '.', "\n\nFor more info see: ").concat(chalk_1.default.underline('https://github.com/getsentry/sentry-javascript/issues/14514')).concat(isPNPM
|
|
322
|
+
? "\n\nand ".concat(chalk_1.default.underline('https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle'))
|
|
323
|
+
: ''));
|
|
324
|
+
_i = 0, overrides_1 = overrides;
|
|
325
|
+
_b.label = 1;
|
|
326
|
+
case 1:
|
|
327
|
+
if (!(_i < overrides_1.length)) return [3 /*break*/, 5];
|
|
328
|
+
_a = overrides_1[_i], pkgName = _a.pkgName, pkgVersion = _a.pkgVersion;
|
|
329
|
+
return [4 /*yield*/, (0, clack_utils_1.askShouldAddPackageOverride)(pkgName, pkgVersion)];
|
|
330
|
+
case 2:
|
|
331
|
+
shouldAddOverride = _b.sent();
|
|
332
|
+
if (!shouldAddOverride) return [3 /*break*/, 4];
|
|
333
|
+
return [4 /*yield*/, packageManager.addOverride(pkgName, pkgVersion)];
|
|
334
|
+
case 3:
|
|
335
|
+
_b.sent();
|
|
336
|
+
_b.label = 4;
|
|
337
|
+
case 4:
|
|
338
|
+
_i++;
|
|
339
|
+
return [3 /*break*/, 1];
|
|
340
|
+
case 5:
|
|
341
|
+
if (!package_manager_1.PNPM.detect()) return [3 /*break*/, 8];
|
|
342
|
+
iitmAlreadyInstalled = (0, package_json_1.hasPackageInstalled)('import-in-the-middle', packageJson);
|
|
343
|
+
Sentry.setTag('iitm-already-installed', iitmAlreadyInstalled);
|
|
344
|
+
return [4 /*yield*/, (0, clack_utils_1.askShouldInstallPackage)('import-in-the-middle')];
|
|
345
|
+
case 6:
|
|
346
|
+
shouldInstallIitm = _b.sent();
|
|
347
|
+
if (!shouldInstallIitm) return [3 /*break*/, 8];
|
|
348
|
+
return [4 /*yield*/, (0, clack_utils_1.installPackage)({
|
|
349
|
+
packageName: 'import-in-the-middle',
|
|
350
|
+
alreadyInstalled: iitmAlreadyInstalled,
|
|
351
|
+
packageManager: packageManager,
|
|
352
|
+
})];
|
|
353
|
+
case 7:
|
|
354
|
+
_b.sent();
|
|
355
|
+
_b.label = 8;
|
|
356
|
+
case 8: return [2 /*return*/];
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
exports.addNuxtOverrides = addNuxtOverrides;
|
|
362
|
+
function confirmReadImportDocs(deploymentPlatform) {
|
|
363
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
364
|
+
var canImportSentryServerConfigFile, docsUrl, shouldOpenDocs;
|
|
365
|
+
return __generator(this, function (_a) {
|
|
366
|
+
switch (_a.label) {
|
|
367
|
+
case 0:
|
|
368
|
+
canImportSentryServerConfigFile = deploymentPlatform !== 'vercel' && deploymentPlatform !== 'netlify';
|
|
369
|
+
if (!canImportSentryServerConfigFile) {
|
|
370
|
+
// Nothing to do, users have been set up with automatic top-level-import instead
|
|
371
|
+
return [2 /*return*/];
|
|
372
|
+
}
|
|
373
|
+
docsUrl = 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cli-import/#initializing-sentry-with---import';
|
|
374
|
+
clack.log.info("After building your Nuxt app, you need to ".concat(chalk_1.default.bold('--import'), " the Sentry server config file when running your app.\n\nFor more info, see:\n\n").concat(chalk_1.default.underline(docsUrl)));
|
|
375
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.confirm({ message: 'Do you want to open the docs?' }))];
|
|
376
|
+
case 1:
|
|
377
|
+
shouldOpenDocs = _a.sent();
|
|
378
|
+
if (shouldOpenDocs) {
|
|
379
|
+
(0, clack_utils_1.opn)(docsUrl, { wait: false }).catch(function () {
|
|
380
|
+
// opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return [2 /*return*/];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
exports.confirmReadImportDocs = confirmReadImportDocs;
|
|
275
389
|
//# sourceMappingURL=sdk-setup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/nuxt/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,mDAAuC;AACvC,gDAA0B;AAC1B,0CAAoB;AACpB,kFAAkF;AAClF,qCAAiE;AACjE,kFAAkF;AAClF,4CAAiD;AACjD,8CAAwB;AACxB,yCAKqB;AACrB,oDAK8B;AAC9B,0CAAyC;AAEzC,IAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC;AAEF,SAAsB,aAAa;;;;;;oBAC7B,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,UAAC,QAAQ;wBAChD,OAAA,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;oBAAjD,CAAiD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,sBAAe,eAAK,CAAC,IAAI,CACvB,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACzC,MAAG,CACL,CAAC;oDACF,MAAM,CAAC,MAAM,CAAC,kBAAW,aAAa,YAAS,EAAE,IAAI,CAAC,CAAC;;;oDAEvD,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,0CAAmC,eAAK,CAAC,IAAI,CAC3C,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACzC,qBAAkB,CACpB,CAAC;oDACF,sCAAsC;oDACtC,OAAO,CAAC,GAAG,CACT,QAAQ;wDACN,IAAA,yBAAa,EAAC,GAAG,EAAE,aAAa,EAAE,gBAAgB,CAAC;wDACnD,MAAM,CACT,CAAC;;;;;yCAEL,CAAC,EAAA;;oCAvEF,SAuEE,CAAC;;;;;0BAxEqC,EAAd,iCAAc;;;yBAAd,CAAA,4BAAc,CAAA;oBAA/B,aAAa;kDAAb,aAAa;;;;;oBAAI,IAAc,CAAA;;;;;;CA0E3C;AAhGD,8CAgGC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport fs from 'fs';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { loadFile, generateCode, MagicastError } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addNuxtModule } from 'magicast/helpers';\nimport path from 'path';\nimport {\n getConfigBody,\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from './templates';\nimport {\n abort,\n abortIfCancelled,\n featureSelectionPrompt,\n isUsingTypeScript,\n} from '../utils/clack-utils';\nimport { traceStep } from '../telemetry';\n\nconst possibleNuxtConfig = [\n 'nuxt.config.js',\n 'nuxt.config.mjs',\n 'nuxt.config.cjs',\n 'nuxt.config.ts',\n 'nuxt.config.mts',\n 'nuxt.config.cts',\n];\n\nexport async function getNuxtConfig(): Promise<string> {\n let configFile = possibleNuxtConfig.find((fileName) =>\n fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!configFile) {\n clack.log.info('No Nuxt config file found, creating a new one.');\n Sentry.setTag('nuxt-config-strategy', 'create');\n // nuxt recommends its config to be .ts by default\n configFile = 'nuxt.config.ts';\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFile),\n getDefaultNuxtConfig(),\n { encoding: 'utf-8', flag: 'w' },\n );\n\n clack.log.success(`Created ${chalk.cyan('nuxt.config.ts')}.`);\n }\n\n return path.join(process.cwd(), configFile);\n}\n\nexport async function addSDKModule(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n): Promise<void> {\n try {\n const mod = await loadFile(config);\n\n addNuxtModule(mod, '@sentry/nuxt/module', 'sentry', {\n sourceMapsUploadOptions: {\n org: options.org,\n project: options.project,\n ...(options.selfHosted && { url: options.url }),\n },\n });\n addNuxtModule(mod, '@sentry/nuxt/module', 'sourcemap', {\n client: 'hidden',\n });\n\n const { code } = generateCode(mod);\n\n await fs.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' });\n\n clack.log.success(\n `Added Sentry Nuxt Module to ${chalk.cyan(path.basename(config))}.`,\n );\n } catch (e: unknown) {\n // Cases where users spread options are not covered by magicast,\n // so we fall back to showing how to configure the nuxt config\n // manually.\n if (e instanceof MagicastError) {\n clack.log.warn(\n `Automatic configuration of ${chalk.cyan(\n path.basename(config),\n )} failed, please add the following settings:`,\n );\n // eslint-disable-next-line no-console\n console.log(`\\n\\n${getNuxtModuleFallbackTemplate(options)}\\n\\n`);\n } else {\n clack.log.error(\n 'Error while adding the Sentry Nuxt Module to the Nuxt config.',\n );\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n Sentry.captureException('Error while setting up the Nuxt SDK');\n await abort('Exiting Wizard');\n }\n }\n}\n\nexport async function createConfigFiles(dsn: string) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(dsn, configVariant, selectedFeatures),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created new ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n } else {\n clack.log.info(\n `Okay, here are the changes your ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )} should contain:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n '\\n\\n ' +\n getConfigBody(dsn, configVariant, selectedFeatures) +\n '\\n\\n',\n );\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/nuxt/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,oDAAwC;AACxC,mDAAuC;AACvC,gDAA0B;AAC1B,0CAAoB;AACpB,kFAAkF;AAClF,qCAAkD;AAClD,kFAAkF;AAClF,4CAAiD;AACjD,8CAAwB;AACxB,yCAKqB;AACrB,oDAQ8B;AAC9B,0CAAyC;AACzC,iCAAoC;AACpC,4DAAgE;AAChE,sDAA4E;AAC5E,iCAAkE;AAElE,IAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC;AAEF,SAAsB,aAAa;;;;;;oBAC7B,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,UAAC,QAAQ;wBAChD,OAAA,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;oBAAjD,CAAiD,CAClD,CAAC;yBAEE,CAAC,UAAU,EAAX,wBAAW;oBACb,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,gDA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,IAAA,kCAAmB,EAC9C,sBAAsB,EACtB,WAAW,CACZ,CAAC;oBACF,MAAM,CAAC,MAAM,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAC;oBAEpC,qBAAM,IAAA,qCAAuB,EACrD,sBAAsB,CACvB,EAAA;;oBAFK,iBAAiB,GAAG,SAEzB;yBAEG,iBAAiB,EAAjB,wBAAiB;oBACnB,qBAAM,IAAA,4BAAc,EAAC;4BACnB,WAAW,EAAE,sBAAsB;4BACnC,gBAAgB,EAAE,oBAAoB;4BACtC,cAAc,gBAAA;yBACf,CAAC,EAAA;;oBAJF,SAIE,CAAC;;;;;;CAGR;AA/DD,4CA+DC;AAED,SAAsB,qBAAqB,CACzC,kBAA+C;;;;;;oBAEzC,+BAA+B,GACnC,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,SAAS,CAAC;oBAEtE,IAAI,CAAC,+BAA+B,EAAE;wBACpC,gFAAgF;wBAChF,sBAAO;qBACR;oBAEK,OAAO,GACX,+GAA+G,CAAC;oBAElH,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,oDAA6C,eAAK,CAAC,IAAI,CACrD,UAAU,CACX,6FAAmF,eAAK,CAAC,SAAS,CACjG,OAAO,CACR,CAAE,CACJ,CAAC;oBAEqB,qBAAM,IAAA,8BAAgB,EAC3C,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAC5D,EAAA;;oBAFK,cAAc,GAAG,SAEtB;oBAED,IAAI,cAAc,EAAE;wBAClB,IAAA,iBAAG,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;4BAClC,iGAAiG;wBACnG,CAAC,CAAC,CAAC;qBACJ;;;;;CACF;AA/BD,sDA+BC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport fs from 'fs';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { loadFile, generateCode } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addNuxtModule } from 'magicast/helpers';\nimport path from 'path';\nimport {\n getConfigBody,\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from './templates';\nimport {\n abortIfCancelled,\n askShouldAddPackageOverride,\n askShouldInstallPackage,\n featureSelectionPrompt,\n installPackage,\n isUsingTypeScript,\n opn,\n} from '../utils/clack-utils';\nimport { traceStep } from '../telemetry';\nimport { lt, SemVer } from 'semver';\nimport { PackageManager, PNPM } from '../utils/package-manager';\nimport { hasPackageInstalled, PackageDotJson } from '../utils/package-json';\nimport { deploymentPlatforms, DeploymentPlatform } from './types';\n\nconst possibleNuxtConfig = [\n 'nuxt.config.js',\n 'nuxt.config.mjs',\n 'nuxt.config.cjs',\n 'nuxt.config.ts',\n 'nuxt.config.mts',\n 'nuxt.config.cts',\n];\n\nexport async function getNuxtConfig(): Promise<string> {\n let configFile = possibleNuxtConfig.find((fileName) =>\n fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!configFile) {\n clack.log.info('No Nuxt config file found, creating a new one.');\n Sentry.setTag('nuxt-config-strategy', 'create');\n // nuxt recommends its config to be .ts by default\n configFile = 'nuxt.config.ts';\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFile),\n getDefaultNuxtConfig(),\n { encoding: 'utf-8', flag: 'w' },\n );\n\n clack.log.success(`Created ${chalk.cyan('nuxt.config.ts')}.`);\n }\n\n return path.join(process.cwd(), configFile);\n}\n\nexport async function askDeploymentPlatform(): Promise<\n DeploymentPlatform | symbol\n> {\n return await abortIfCancelled(\n clack.select({\n message: 'Please select your deployment platform.',\n options: deploymentPlatforms.map((platform) => ({\n value: platform,\n label: `${platform.charAt(0).toUpperCase()}${platform.slice(1)}`,\n })),\n }),\n );\n}\n\nexport async function addSDKModule(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n deploymentPlatform: DeploymentPlatform | symbol,\n): Promise<void> {\n const shouldTopLevelImport =\n deploymentPlatform === 'vercel' || deploymentPlatform === 'netlify';\n\n if (shouldTopLevelImport) {\n clack.log.warn(\n `Sentry needs to be initialized before the application starts. ${chalk.cyan(\n `${deploymentPlatform\n .charAt(0)\n .toUpperCase()}${deploymentPlatform.slice(1)}`,\n )} 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(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/top-level-import/',\n )} `,\n );\n }\n\n try {\n const mod = await loadFile(config);\n\n addNuxtModule(mod, '@sentry/nuxt/module', 'sentry', {\n sourceMapsUploadOptions: {\n org: options.org,\n project: options.project,\n ...(options.selfHosted && { url: options.url }),\n },\n ...(shouldTopLevelImport && {\n autoInjectServerSentry: 'top-level-import',\n }),\n });\n addNuxtModule(mod, '@sentry/nuxt/module', 'sourcemap', {\n client: 'hidden',\n });\n\n const { code } = generateCode(mod);\n\n await fs.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' });\n\n clack.log.success(\n `Added Sentry Nuxt Module to ${chalk.cyan(path.basename(config))}.`,\n );\n } catch (e: unknown) {\n clack.log.error(\n 'Error while adding the Sentry Nuxt Module to the Nuxt config.',\n );\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n Sentry.captureException(\n 'Error while setting up the Nuxt Module in nuxt config',\n );\n\n clack.log.warn(\n `Please add the following settings to ${chalk.cyan(\n path.basename(config),\n )}:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n `\\n\\n${getNuxtModuleFallbackTemplate(options, shouldTopLevelImport)}\\n\\n`,\n );\n }\n}\n\nexport async function createConfigFiles(dsn: string) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(dsn, configVariant, selectedFeatures),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created new ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n } else {\n clack.log.info(\n `Okay, here are the changes your ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )} should contain:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n '\\n\\n ' +\n getConfigBody(dsn, configVariant, selectedFeatures) +\n '\\n\\n',\n );\n }\n });\n }\n}\n\nexport async function addNuxtOverrides(\n packageJson: PackageDotJson,\n packageManager: PackageManager,\n nuxtMinVer: SemVer | null,\n) {\n const isPNPM = PNPM.detect();\n\n const overrides = [\n {\n pkgName: '@vercel/nft',\n pkgVersion: '^0.27.4',\n },\n ...(nuxtMinVer && lt(nuxtMinVer, '3.14.0')\n ? [{ pkgName: 'ofetch', pkgVersion: '^1.4.0' }]\n : []),\n ];\n\n clack.log.warn(\n `To ensure Sentry can properly instrument your code it needs to add version overrides for some Nuxt dependencies${\n isPNPM ? ` and install ${chalk.cyan('import-in-the-middle')}.` : '.'\n }\\n\\nFor more info see: ${chalk.underline(\n 'https://github.com/getsentry/sentry-javascript/issues/14514',\n )}${\n isPNPM\n ? `\\n\\nand ${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle',\n )}`\n : ''\n }`,\n );\n\n for (const { pkgName, pkgVersion } of overrides) {\n const shouldAddOverride = await askShouldAddPackageOverride(\n pkgName,\n pkgVersion,\n );\n\n if (shouldAddOverride) {\n await packageManager.addOverride(pkgName, pkgVersion);\n }\n }\n\n if (PNPM.detect()) {\n // For pnpm, we want to install iitm\n // See: https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle\n const iitmAlreadyInstalled = hasPackageInstalled(\n 'import-in-the-middle',\n packageJson,\n );\n Sentry.setTag('iitm-already-installed', iitmAlreadyInstalled);\n\n const shouldInstallIitm = await askShouldInstallPackage(\n 'import-in-the-middle',\n );\n\n if (shouldInstallIitm) {\n await installPackage({\n packageName: 'import-in-the-middle',\n alreadyInstalled: iitmAlreadyInstalled,\n packageManager,\n });\n }\n }\n}\n\nexport async function confirmReadImportDocs(\n deploymentPlatform: DeploymentPlatform | symbol,\n) {\n const canImportSentryServerConfigFile =\n deploymentPlatform !== 'vercel' && deploymentPlatform !== 'netlify';\n\n if (!canImportSentryServerConfigFile) {\n // Nothing to do, users have been set up with automatic top-level-import instead\n return;\n }\n\n const docsUrl =\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cli-import/#initializing-sentry-with---import';\n\n clack.log.info(\n `After building your Nuxt app, you need to ${chalk.bold(\n '--import',\n )} the Sentry server config file when running your app.\\n\\nFor more info, see:\\n\\n${chalk.underline(\n docsUrl,\n )}`,\n );\n\n const shouldOpenDocs = await abortIfCancelled(\n clack.confirm({ message: 'Do you want to open the docs?' }),\n );\n\n if (shouldOpenDocs) {\n opn(docsUrl, { wait: false }).catch(() => {\n // opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here\n });\n }\n}\n"]}
|
|
@@ -8,7 +8,7 @@ export declare function getNuxtModuleFallbackTemplate(options: {
|
|
|
8
8
|
project: string;
|
|
9
9
|
url: string;
|
|
10
10
|
selfHosted: boolean;
|
|
11
|
-
}): string;
|
|
11
|
+
}, shouldTopLevelImport: boolean): string;
|
|
12
12
|
export declare function getSentryConfigContents(dsn: string, config: 'client' | 'server', selectedFeatures: SelectedSentryFeatures): string;
|
|
13
13
|
export declare function getConfigBody(dsn: string, variant: 'client' | 'server', selectedFeatures: SelectedSentryFeatures): string;
|
|
14
14
|
export declare function getIndexRouteTemplate(): string;
|
|
@@ -6,8 +6,10 @@ function getDefaultNuxtConfig() {
|
|
|
6
6
|
return "// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n";
|
|
7
7
|
}
|
|
8
8
|
exports.getDefaultNuxtConfig = getDefaultNuxtConfig;
|
|
9
|
-
function getNuxtModuleFallbackTemplate(options) {
|
|
10
|
-
return " modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"".concat(options.org, "\",\n project: \"").concat(options.project, "\",").concat(options.selfHosted ? "\n url: \"".concat(options.url, "\",") : '', "\n }
|
|
9
|
+
function getNuxtModuleFallbackTemplate(options, shouldTopLevelImport) {
|
|
10
|
+
return " modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"".concat(options.org, "\",\n project: \"").concat(options.project, "\",").concat(options.selfHosted ? "\n url: \"".concat(options.url, "\",") : '', "\n },").concat(shouldTopLevelImport
|
|
11
|
+
? "\n autoInjectServerSentry: \"top-level-import\","
|
|
12
|
+
: '', "\n },\n sourcemap: { client: \"hidden\" },");
|
|
11
13
|
}
|
|
12
14
|
exports.getNuxtModuleFallbackTemplate = getNuxtModuleFallbackTemplate;
|
|
13
15
|
function getSentryConfigContents(dsn, config, selectedFeatures) {
|
|
@@ -74,7 +76,7 @@ function getSentryExamplePageTemplate(options) {
|
|
|
74
76
|
}
|
|
75
77
|
exports.getSentryExamplePageTemplate = getSentryExamplePageTemplate;
|
|
76
78
|
function getSentryExampleApiTemplate() {
|
|
77
|
-
return "// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(
|
|
79
|
+
return "// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n";
|
|
78
80
|
}
|
|
79
81
|
exports.getSentryExampleApiTemplate = getSentryExampleApiTemplate;
|
|
80
82
|
function getSentryErrorButtonTemplate() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AA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AAW,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,SAAS;gBACxD,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;gBAC5B,CAAC,CAAC,IAAI,CAAC;QACX,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,MAAM,CAAC;KAChB;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC;AAlBD,sCAkBC;AAED,SAAS,6BAA6B,CACpC,GAAW,EACX,gBAAwC;IAExC,OAAO,+KAKL,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,gBAAgB,CAAC,gJAKjD,CAAC;AACF,CAAC;AAED,SAAS,6BAA6B,CACpC,GAAW,EACX,gBAAwC;IAExC,OAAO,yEAGL,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,gBAAgB,CAAC,gJAKjD,CAAC;AACF,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,qHAKa,CAAC;AACvB,CAAC;AAPD,sDAOC;AAED,SAAgB,4BAA4B,CAAC,OAI5C;IACS,IAAA,GAAG,GAAqB,OAAO,IAA5B,EAAE,GAAG,GAAgB,OAAO,IAAvB,EAAE,SAAS,GAAK,OAAO,UAAZ,CAAa;IACxC,IAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,KAAA,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,WAAA,EAAE,CAAC,CAAC;IAE3E,OAAO,k1EA4CQ,cAAc,m7BA8C9B,CAAC;AACF,CAAC;AAnGD,oEAmGC;AAED,SAAgB,2BAA2B;IACzC,OAAO,yQAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO,y8BA8CR,CAAC;AACF,CAAC;AAhDD,oEAgDC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n}): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay'],\n server: ['performance'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n import { useFetch} from '#imports'\n \n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const { error } = await useFetch('/api/sentry-example-api');\n if (error.value) {\n throw new Error('Sentry Example Frontend Error');\n }\n }\n )\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button type=\"button\" @click=\"getSentryData\"> Throw error! </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">\n Sentry Nuxt Documentation\n </a>\n </p>\n </main>\n</div>\n</template>\n\n<style scoped>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n svg {\n font-size: 4rem;\n margin: 14px 0;\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(event => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <button id=\"errorBtn\" @click=\"throwError\"> Throw Error! </button>\n</template>\n\n<style scoped>\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #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AA2B;IACzC,OAAO,sQAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO,y8BA8CR,CAAC;AACF,CAAC;AAhDD,oEAgDC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(\n options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n },\n shouldTopLevelImport: boolean,\n): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },${\n shouldTopLevelImport\n ? `\\n autoInjectServerSentry: \"top-level-import\",`\n : ''\n }\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay'],\n server: ['performance'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n import { useFetch} from '#imports'\n \n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const { error } = await useFetch('/api/sentry-example-api');\n if (error.value) {\n throw new Error('Sentry Example Frontend Error');\n }\n }\n )\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button type=\"button\" @click=\"getSentryData\"> Throw error! </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">\n Sentry Nuxt Documentation\n </a>\n </p>\n </main>\n</div>\n</template>\n\n<style scoped>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n svg {\n font-size: 4rem;\n margin: 14px 0;\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <button id=\"errorBtn\" @click=\"throwError\"> Throw Error! </button>\n</template>\n\n<style scoped>\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/nuxt/types.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;IACjC,QAAQ;IACR,SAAS;IACT,OAAO;IACP,MAAM;CACE,CAAC","sourcesContent":["export const deploymentPlatforms = [\n 'vercel',\n 'netlify',\n 'other',\n 'none',\n] as const;\n\nexport type DeploymentPlatform = (typeof deploymentPlatforms)[number];\n"]}
|
package/dist/src/nuxt/utils.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,14 +60,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
60
|
};
|
|
38
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
62
|
exports.isNuxtV4 = void 0;
|
|
63
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
64
|
+
var clack = __importStar(require("@clack/prompts"));
|
|
40
65
|
var semver_1 = require("semver");
|
|
41
66
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
42
67
|
var magicast_1 = require("magicast");
|
|
68
|
+
var clack_utils_1 = require("../utils/clack-utils");
|
|
43
69
|
function isNuxtV4(nuxtConfig, packageVersion) {
|
|
44
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var minVer, mod, config;
|
|
46
|
-
return __generator(this, function (
|
|
47
|
-
switch (
|
|
71
|
+
var minVer, mod, config, _a;
|
|
72
|
+
return __generator(this, function (_b) {
|
|
73
|
+
switch (_b.label) {
|
|
48
74
|
case 0:
|
|
49
75
|
if (!packageVersion) {
|
|
50
76
|
return [2 /*return*/, false];
|
|
@@ -53,16 +79,26 @@ function isNuxtV4(nuxtConfig, packageVersion) {
|
|
|
53
79
|
if (minVer && (0, semver_1.gte)(minVer, '4.0.0')) {
|
|
54
80
|
return [2 /*return*/, true];
|
|
55
81
|
}
|
|
56
|
-
|
|
82
|
+
_b.label = 1;
|
|
57
83
|
case 1:
|
|
58
|
-
|
|
84
|
+
_b.trys.push([1, 3, , 5]);
|
|
85
|
+
return [4 /*yield*/, (0, magicast_1.loadFile)(nuxtConfig)];
|
|
86
|
+
case 2:
|
|
87
|
+
mod = _b.sent();
|
|
59
88
|
config = mod.exports.default.$type === 'function-call'
|
|
60
89
|
? mod.exports.default.$args[0]
|
|
61
90
|
: mod.exports.default;
|
|
62
91
|
if (config && config.future && config.future.compatibilityVersion === 4) {
|
|
63
92
|
return [2 /*return*/, true];
|
|
64
93
|
}
|
|
65
|
-
return [
|
|
94
|
+
return [3 /*break*/, 5];
|
|
95
|
+
case 3:
|
|
96
|
+
_a = _b.sent();
|
|
97
|
+
return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(clack.confirm({ message: 'Are you using Nuxt version 4?' }))];
|
|
98
|
+
case 4:
|
|
99
|
+
// If we cannot parse their config, just ask.
|
|
100
|
+
return [2 /*return*/, _b.sent()];
|
|
101
|
+
case 5: return [2 /*return*/, false];
|
|
66
102
|
}
|
|
67
103
|
});
|
|
68
104
|
});
|