Skip to content

Commit fa643e8

Browse files
ericyangpanclaude
andcommitted
feat: add content consistency validation
- Validate article count consistency across all locales - Validate docs count consistency across all locales - Validate FAQ count consistency across all locales - Validate manifesto existence for all locales - Exit with error if validation fails to ensure content parity 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 551af3c commit fa643e8

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

scripts/generate/generate-metadata.mjs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,75 @@ ${manifestoComponentsCode}
547547
console.log(` - ${path.relative(rootDir, docsGeneratedFile)}`)
548548
console.log(` - ${path.relative(rootDir, manifestoGeneratedFile)}`)
549549

550+
// Validate that content counts are consistent across all locales
551+
console.log(`\n🔍 Validating content consistency across locales...`)
552+
let hasError = false
553+
554+
// Validate articles count consistency
555+
const articleCounts = Object.entries(articles).map(([locale, localeArticles]) => ({
556+
locale,
557+
count: localeArticles.length,
558+
}))
559+
const articleCountSet = new Set(articleCounts.map(item => item.count))
560+
if (articleCountSet.size > 1) {
561+
console.error(`❌ Articles count mismatch across locales:`)
562+
articleCounts.forEach(({ locale, count }) => {
563+
console.error(` ${locale}: ${count}`)
564+
})
565+
hasError = true
566+
}
567+
568+
// Validate docs count consistency
569+
const docCounts = Object.entries(docs).map(([locale, localeDocs]) => ({
570+
locale,
571+
count: localeDocs.length,
572+
}))
573+
const docCountSet = new Set(docCounts.map(item => item.count))
574+
if (docCountSet.size > 1) {
575+
console.error(`❌ Docs count mismatch across locales:`)
576+
docCounts.forEach(({ locale, count }) => {
577+
console.error(` ${locale}: ${count}`)
578+
})
579+
hasError = true
580+
}
581+
582+
// Validate FAQs count consistency
583+
const faqCounts = Object.entries(faqs).map(([locale, localeFaqs]) => ({
584+
locale,
585+
count: localeFaqs.length,
586+
}))
587+
const faqCountSet = new Set(faqCounts.map(item => item.count))
588+
if (faqCountSet.size > 1) {
589+
console.error(`❌ FAQs count mismatch across locales:`)
590+
faqCounts.forEach(({ locale, count }) => {
591+
console.error(` ${locale}: ${count}`)
592+
})
593+
hasError = true
594+
}
595+
596+
// Validate manifesto existence for all locales
597+
const manifestoLocales = []
598+
for (const locale of SUPPORTED_LOCALES) {
599+
const manifestoIndex = path.join(rootDir, `content/manifesto/${locale}/index.mdx`)
600+
if (fs.existsSync(manifestoIndex)) {
601+
manifestoLocales.push(locale)
602+
}
603+
}
604+
if (manifestoLocales.length !== SUPPORTED_LOCALES.length) {
605+
const missingLocales = SUPPORTED_LOCALES.filter(locale => !manifestoLocales.includes(locale))
606+
console.error(`❌ Manifesto missing for locales: ${missingLocales.join(', ')}`)
607+
hasError = true
608+
}
609+
610+
if (hasError) {
611+
console.error(
612+
`\n❌ Content consistency validation failed. Please ensure all locales have the same number of articles, docs, and FAQs.`
613+
)
614+
process.exit(1)
615+
}
616+
617+
console.log(`✅ Content consistency validation passed`)
618+
550619
// Run biome formatting on generated files
551620
console.log(`\n🎨 Formatting generated files with Biome...`)
552621
try {

0 commit comments

Comments
 (0)