@sentry/wizard
Version:
Sentry wizard helping you to configure your project
80 lines • 4.17 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 path = __importStar(require("path"));
const MergeConfig_1 = require("../MergeConfig");
const vitest_1 = require("vitest");
const configPath = path.join(__dirname, '..', 'test-fixtures/next.config.js');
const templatePath = path.join(__dirname, '..', '..', '..', 'scripts/NextJs/configs/next.config.template.js');
function configFileNames(num) {
const sourcePath = path.join(__dirname, '..', `test-fixtures/next.config.${num}.js`);
const mergedPath = path.join(__dirname, '..', `test-fixtures/next.config.${num}-merged.js`);
return { sourcePath, mergedPath };
}
(0, vitest_1.describe)('Merging next.config.js', () => {
(0, vitest_1.afterEach)(() => {
fs.unlinkSync(configPath);
});
(0, vitest_1.test)('merge basic next.config.js return true', () => {
const { sourcePath } = configFileNames(1);
fs.copyFileSync(sourcePath, configPath);
(0, vitest_1.expect)((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(true);
});
(0, vitest_1.test)('merge basic next.config.js', () => {
const { sourcePath, mergedPath } = configFileNames(1);
fs.copyFileSync(sourcePath, configPath);
(0, MergeConfig_1.mergeConfigFile)(configPath, templatePath);
(0, vitest_1.expect)(fs.readFileSync(configPath, 'utf8')).toEqual(fs.readFileSync(mergedPath, 'utf8'));
});
(0, vitest_1.test)('merge invalid javascript config return false', () => {
const { sourcePath } = configFileNames(2);
fs.copyFileSync(sourcePath, configPath);
(0, vitest_1.expect)((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(false);
});
(0, vitest_1.test)('merge more complicated next.config.js return true', () => {
const { sourcePath } = configFileNames(3);
fs.copyFileSync(sourcePath, configPath);
(0, vitest_1.expect)((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(true);
});
(0, vitest_1.test)('merge more complicated next.config.js', () => {
const { sourcePath, mergedPath } = configFileNames(3);
fs.copyFileSync(sourcePath, configPath);
(0, MergeConfig_1.mergeConfigFile)(configPath, templatePath);
(0, vitest_1.expect)(fs.readFileSync(configPath, 'utf8')).toEqual(fs.readFileSync(mergedPath, 'utf8'));
});
(0, vitest_1.test)('merge next.config.js with function return true', () => {
const { sourcePath } = configFileNames(4);
fs.copyFileSync(sourcePath, configPath);
(0, vitest_1.expect)((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(true);
});
(0, vitest_1.test)('merge next.config.js with function', () => {
const { sourcePath, mergedPath } = configFileNames(4);
fs.copyFileSync(sourcePath, configPath);
(0, MergeConfig_1.mergeConfigFile)(configPath, templatePath);
(0, vitest_1.expect)(fs.readFileSync(configPath, 'utf8')).toEqual(fs.readFileSync(mergedPath, 'utf8'));
});
});
//# sourceMappingURL=MergeConfig.js.map