mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { readdirSync, readFileSync } from 'fs'
|
|
import { join } from 'path'
|
|
|
|
interface ReadmeQuality {
|
|
file: string
|
|
hasDescription: boolean
|
|
hasInstallation: boolean
|
|
hasUsage: boolean
|
|
hasContributing: boolean
|
|
score: number
|
|
}
|
|
|
|
function validateReadmeQuality(): ReadmeQuality[] {
|
|
const results: ReadmeQuality[] = []
|
|
|
|
try {
|
|
const content = readFileSync('README.md', 'utf8')
|
|
|
|
const checks = {
|
|
hasDescription: content.toLowerCase().includes('description') || content.toLowerCase().includes('about'),
|
|
hasInstallation: content.toLowerCase().includes('install'),
|
|
hasUsage: content.toLowerCase().includes('usage') || content.toLowerCase().includes('example'),
|
|
hasContributing: content.toLowerCase().includes('contributing') || content.toLowerCase().includes('contribute')
|
|
}
|
|
|
|
const score = (Object.values(checks).filter(v => v).length / 4) * 100
|
|
|
|
results.push({
|
|
file: 'README.md',
|
|
...checks,
|
|
score
|
|
})
|
|
} catch (e) {
|
|
// README not found
|
|
}
|
|
|
|
return results
|
|
}
|
|
|
|
const results = validateReadmeQuality()
|
|
console.log(JSON.stringify({
|
|
totalChecked: results.length,
|
|
results,
|
|
timestamp: new Date().toISOString()
|
|
}, null, 2))
|