UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

67 lines (66 loc) 3.13 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.configureEsbuildPlugin = void 0; // @ts-expect-error - clack is ESM and TS complains about that. It works though const prompts_1 = __importStar(require("@clack/prompts")); const chalk_1 = __importDefault(require("chalk")); const clack_1 = require("../../utils/clack"); const package_json_1 = require("../../utils/package-json"); const getCodeSnippet = (options) => chalk_1.default.gray(` ${chalk_1.default.greenBright('const { sentryEsbuildPlugin } = require("@sentry/esbuild-plugin");')} require("esbuild").build({ ${chalk_1.default.greenBright('sourcemap: true, // Source map generation must be turned on')} plugins: [ // Put the Sentry esbuild plugin after all other plugins ${chalk_1.default.greenBright(`sentryEsbuildPlugin({ authToken: process.env.SENTRY_AUTH_TOKEN, org: "${options.orgSlug}", project: "${options.projectSlug}",${options.selfHosted ? `\n url: "${options.url}",` : ''} }),`)} ], }); `); const configureEsbuildPlugin = async (options) => { await (0, clack_1.installPackage)({ packageName: '@sentry/esbuild-plugin', alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/esbuild-plugin', await (0, clack_1.getPackageDotJson)()), }); prompts_1.default.log.step(`Add the following code to your esbuild config:`); // Intentially logging directly to console here so that the code can be copied/pasted directly // eslint-disable-next-line no-console console.log(getCodeSnippet(options)); await (0, clack_1.abortIfCancelled)((0, prompts_1.select)({ message: 'Did you copy the snippet above?', options: [{ label: 'Yes, continue!', value: true }], initialValue: true, })); await (0, clack_1.addDotEnvSentryBuildPluginFile)(options.authToken); }; exports.configureEsbuildPlugin = configureEsbuildPlugin; //# sourceMappingURL=esbuild.js.map