vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
31 lines (30 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertV1Design = assertV1Design;
const utils_js_1 = require("./utils.js");
function assertV1Design(pageConfigs, pageFilesAll) {
const isOldDesign = pageFilesAll === true || (pageFilesAll !== false && pageFilesAll.length > 0);
const isV1Design = pageConfigs === true || (pageConfigs !== false && pageConfigs.length > 0);
if (isV1Design && isOldDesign) {
const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
const indent = '- ';
if (typeof pageConfigs !== 'boolean') {
(0, utils_js_1.assert)(pageConfigs.length > 0);
const filesV1 = (0, utils_js_1.unique)(pageConfigs
.map((p) => Object.values(p.configValueSources).map((sources) => sources
.map((c) => c.definedAt)
.map((definedAt) => (definedAt.definedBy ? null : definedAt.filePathAbsoluteUserRootDir))
.filter(utils_js_1.isNotNullish)
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
.flat(2));
lines.push(...['V1 design files:', ...filesV1]);
}
if (typeof pageFilesAll !== 'boolean') {
(0, utils_js_1.assert)(pageFilesAll.length > 0);
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
lines.push(...['Old design files:', ...filesOld]);
}
(0, utils_js_1.assertUsage)(false, lines.join('\n'));
}
(0, utils_js_1.assertWarning)(!isOldDesign, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
}