Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 24s
Build & Deploy / 🧪 QA (push) Successful in 1m8s
Build & Deploy / 🏗️ Build (push) Failing after 2m50s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
120 lines
4.0 KiB
JavaScript
120 lines
4.0 KiB
JavaScript
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
// Mapping of German slugs to English slugs (based on messages/en.json)
|
|
const slugMapping = {
|
|
'agb.mdx': 'terms.mdx',
|
|
'bohrtechnik.mdx': 'bohrtechnik.mdx', // Mapped via Slugs.pages
|
|
'datenschutz.mdx': 'privacy-policy.mdx',
|
|
'glasfaser.mdx': 'glasfaser.mdx', // Mapped via Slugs.pages
|
|
'home.mdx': 'home.mdx',
|
|
'impressum.mdx': 'imprint.mdx',
|
|
'kabeltiefbau.mdx': 'kabeltiefbau.mdx', // Mapped via Slugs.pages
|
|
'karriere.mdx': 'karriere.mdx',
|
|
'kompetenzen.mdx': 'kompetenzen.mdx',
|
|
'messen.mdx': 'messen.mdx',
|
|
'planung.mdx': 'planung.mdx', // Mapped via Slugs.pages
|
|
'team.mdx': 'team.mdx',
|
|
'ueber-uns.mdx': 'ueber-uns.mdx',
|
|
'vermessung.mdx': 'vermessung.mdx', // Mapped via Slugs.pages
|
|
'zertifikate.mdx': 'zertifikate.mdx'
|
|
};
|
|
|
|
const DE_DIR = './content/de';
|
|
const EN_DIR = './content/en';
|
|
|
|
function extractComponents(content) {
|
|
// Regex to match MDX/JSX components like <HeroSection ... /> or <HeroSection>...</HeroSection>
|
|
const componentRegex = /<([A-Z][a-zA-Z0-9]+)/g;
|
|
const components = [];
|
|
let match;
|
|
while ((match = componentRegex.exec(content)) !== null) {
|
|
components.push(match[1]);
|
|
}
|
|
return components;
|
|
}
|
|
|
|
function verifyParity() {
|
|
console.log('🔍 Starting MDX Component Parity Verification...');
|
|
let hasError = false;
|
|
|
|
for (const [deFile, enFile] of Object.entries(slugMapping)) {
|
|
const dePath = path.join(DE_DIR, deFile);
|
|
const enPath = path.join(EN_DIR, enFile);
|
|
|
|
if (!fs.existsSync(dePath)) {
|
|
console.error(`❌ German file missing: ${dePath}`);
|
|
hasError = true;
|
|
continue;
|
|
}
|
|
if (!fs.existsSync(enPath)) {
|
|
console.error(`❌ English file missing: ${enPath}`);
|
|
hasError = true;
|
|
continue;
|
|
}
|
|
|
|
const deContent = fs.readFileSync(dePath, 'utf-8');
|
|
const enContent = fs.readFileSync(enPath, 'utf-8');
|
|
|
|
const deComponents = extractComponents(deContent);
|
|
const enComponents = extractComponents(enContent);
|
|
|
|
// Assert length and names match in sequence
|
|
const deComponentsStr = deComponents.join(', ');
|
|
const enComponentsStr = enComponents.join(', ');
|
|
|
|
if (deComponentsStr !== enComponentsStr) {
|
|
console.error(`❌ Component mismatch in ${deFile} ➔ ${enFile}`);
|
|
console.error(` DE Components: [${deComponentsStr}]`);
|
|
console.error(` EN Components: [${enComponentsStr}]`);
|
|
hasError = true;
|
|
} else {
|
|
console.log(`✅ ${deFile} ➔ ${enFile} matched perfectly [${deComponentsStr}]`);
|
|
}
|
|
}
|
|
|
|
// Also verify subfolders like referenzen
|
|
const deRefsDir = path.join(DE_DIR, 'referenzen');
|
|
const enRefsDir = path.join(EN_DIR, 'referenzen');
|
|
|
|
if (fs.existsSync(deRefsDir) && fs.existsSync(enRefsDir)) {
|
|
const deRefFiles = fs.readdirSync(deRefsDir).filter(f => f.endsWith('.mdx'));
|
|
for (const refFile of deRefFiles) {
|
|
const dePath = path.join(deRefsDir, refFile);
|
|
const enPath = path.join(enRefsDir, refFile);
|
|
|
|
if (fs.existsSync(enPath)) {
|
|
const deContent = fs.readFileSync(dePath, 'utf-8');
|
|
const enContent = fs.readFileSync(enPath, 'utf-8');
|
|
|
|
const deComponents = extractComponents(deContent);
|
|
const enComponents = extractComponents(enContent);
|
|
|
|
const deComponentsStr = deComponents.join(', ');
|
|
const enComponentsStr = enComponents.join(', ');
|
|
|
|
if (deComponentsStr !== enComponentsStr) {
|
|
console.error(`❌ Component mismatch in referenzen/${refFile}`);
|
|
console.error(` DE Components: [${deComponentsStr}]`);
|
|
console.error(` EN Components: [${enComponentsStr}]`);
|
|
hasError = true;
|
|
} else {
|
|
console.log(`✅ referenzen/${refFile} matched perfectly [${deComponentsStr}]`);
|
|
}
|
|
} else {
|
|
console.error(`❌ English reference file missing: ${enPath}`);
|
|
hasError = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (hasError) {
|
|
console.error('\n❌ Parity verification failed.');
|
|
process.exit(1);
|
|
} else {
|
|
console.log('\n🎉 ALL MDX pages are 100% structurally identical in both German and English!');
|
|
}
|
|
}
|
|
|
|
verifyParity();
|