UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

91 lines 5.31 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 }); const vitest_1 = require("vitest"); const utils_1 = require("../utils"); const Constants_1 = require("../../lib/Constants"); const path = __importStar(require("path")); const fs_1 = __importDefault(require("fs")); //@ts-expect-error - clifty is ESM only const clifty_1 = require("clifty"); (0, vitest_1.describe)('Cloudflare-Wrangler-Sourcemaps-Wizard', () => { const projectDir = path.resolve(__dirname, '../test-applications/cloudflare-wrangler-sourcemaps-test-app'); let wizardExitCode; (0, vitest_1.beforeAll)(async () => { (0, utils_1.initGit)(projectDir); (0, utils_1.revertLocalChanges)(projectDir); wizardExitCode = await (0, clifty_1.withEnv)({ cwd: projectDir }) .defineInteraction() .step('intro', ({ expectOutput }) => { expectOutput('This wizard will help you upload source maps to Sentry'); }) .step('select wrangler', ({ expectOutput, whenAsked }) => { whenAsked('Which framework, bundler or build tool are you using?').respondWith(clifty_1.KEYS.ENTER); expectOutput('Before we get started'); expectOutput('We recommend using Vite to build your worker instead'); whenAsked('want to proceed with the Wrangler setup').respondWith(clifty_1.KEYS.ENTER); }) .step('configure source maps upload', ({ expectOutput, whenAsked }) => { expectOutput('Installing @sentry/cli'); whenAsked('Is yarn deploy your build and deploy command?', { timeout: 60000, // give CI some time to install @sentry/cli }).respondWith(clifty_1.KEYS.ENTER); expectOutput('Added a sentry:sourcemaps script to your package.json'); expectOutput('Added a postdeploy script to your package.json'); expectOutput('Modified your deploy script to enable uploading source maps'); expectOutput('Added auth token to .sentryclirc for you to test uploading source maps locally'); expectOutput('Created .sentryclirc'); }) .step('add auth token to CI/CD (skipped)', ({ whenAsked }) => { whenAsked('Are you using a CI/CD tool to build and deploy your application?').respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER); // no }) .expectOutput("That's it") .run((0, utils_1.getWizardCommand)(Constants_1.Integration.sourcemaps)); }, 60000); (0, vitest_1.afterAll)(() => { (0, utils_1.revertLocalChanges)(projectDir); (0, utils_1.cleanupGit)(projectDir); }); (0, vitest_1.it)('exits with exit code 0', () => { (0, vitest_1.expect)(wizardExitCode).toBe(0); }); (0, vitest_1.it)('adds and adjusts the respective package.json scripts', () => { const pkgJson = JSON.parse(fs_1.default.readFileSync(path.join(projectDir, 'package.json'), 'utf8')); (0, vitest_1.expect)(pkgJson?.scripts?.['sentry:sourcemaps']).toEqual(`_SENTRY_RELEASE=$(sentry-cli releases propose-version) && sentry-cli releases new $_SENTRY_RELEASE --org=${utils_1.TEST_ARGS.ORG_SLUG} --project=${utils_1.TEST_ARGS.PROJECT_SLUG} && sentry-cli sourcemaps upload --org=${utils_1.TEST_ARGS.ORG_SLUG} --project=${utils_1.TEST_ARGS.PROJECT_SLUG} --release=$_SENTRY_RELEASE --strip-prefix 'dist/..' dist`); (0, vitest_1.expect)(pkgJson?.scripts?.['postdeploy']).toEqual('yarn sentry:sourcemaps'); (0, vitest_1.expect)(pkgJson?.scripts?.['deploy']).toEqual('wrangler deploy --outdir dist --upload-source-maps --var SENTRY_RELEASE:$(sentry-cli releases propose-version)'); }); (0, vitest_1.it)('adds sentry-cli as a devDependency', () => { const pkgJson = JSON.parse(fs_1.default.readFileSync(path.join(projectDir, 'package.json'), 'utf8')); (0, vitest_1.expect)(pkgJson?.devDependencies?.['@sentry/cli']).toBeDefined(); }); (0, vitest_1.it)('adds a .sentryclirc file', () => { (0, utils_1.checkSentryCliRc)(projectDir); }); }); //# sourceMappingURL=cloudflare-wrangler-sourcemaps.test.js.map