@sentry/wizard
Version:
Sentry wizard helping you to configure your project
83 lines • 3.55 kB
JavaScript
;
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const sentry_cli_1 = require("../../../src/sourcemaps/tools/sentry-cli");
const packageManagerHelpers = __importStar(require("../../../src/utils/package-manager"));
const clack_1 = require("../../../src/utils/clack");
const vitest_1 = require("vitest");
const writeFileSpy = vitest_1.vi
.spyOn(fs.promises, 'writeFile')
.mockImplementation(() => Promise.resolve());
vitest_1.vi.mock('@clack/prompts', () => {
return {
log: {
info: vitest_1.vi.fn(),
success: vitest_1.vi.fn(),
},
confirm: vitest_1.vi.fn().mockResolvedValue(true),
isCancel: vitest_1.vi.fn().mockReturnValue(false),
};
});
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
vitest_1.vi.mock('../../../src/utils/clack', async () => ({
...(await vitest_1.vi.importActual('../../../src/utils/clack')),
getPackageDotJson: vitest_1.vi.fn().mockResolvedValue({
scripts: {
build: 'tsc',
},
version: '1.0.0',
}),
}));
(0, vitest_1.describe)('addSentryCommandToBuildCommand', () => {
(0, vitest_1.afterEach)(() => {
vitest_1.vi.clearAllMocks();
});
vitest_1.it.each([
[
packageManagerHelpers.NPM,
packageManagerHelpers.PNPM,
packageManagerHelpers.YARN_V1,
packageManagerHelpers.YARN_V2,
packageManagerHelpers.BUN,
packageManagerHelpers.DENO,
],
])('adds the cli command to the script command (%s)', async (_, pacMan) => {
vitest_1.vi.spyOn(packageManagerHelpers, '_detectPackageManger').mockReturnValue(pacMan);
await (0, sentry_cli_1.addSentryCommandToBuildCommand)();
(0, vitest_1.expect)(writeFileSpy).toHaveBeenCalledWith(vitest_1.expect.stringContaining('package.json'), vitest_1.expect.stringContaining(`tsc && ${pacMan.runScriptCommand} sentry:sourcemaps`));
});
(0, vitest_1.it)('does not add the cli command to the script command if it is already in there', async () => {
vitest_1.vi.mocked(clack_1.getPackageDotJson).mockResolvedValue({
scripts: {
build: 'tsc && sentry:sourcemaps',
},
version: '1.0.0',
});
await (0, sentry_cli_1.addSentryCommandToBuildCommand)();
(0, vitest_1.expect)(writeFileSpy).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=sentry-cli.test.js.map