-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-healer.ts
More file actions
36 lines (28 loc) Β· 1.1 KB
/
test-healer.ts
File metadata and controls
36 lines (28 loc) Β· 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { scanHTML } from './lib/accessibility/axe-scanner'
import { healHTML } from './lib/healer/fix-generator'
import fs from 'fs'
import path from 'path'
async function main() {
// 1. Load broken HTML
const htmlPath = path.join(process.cwd(), 'public/demo-sites/broken.html')
const html = fs.readFileSync(htmlPath, 'utf-8')
console.log('π Loaded broken.html')
// 2. Scan
console.log('π Scanning...')
const scanResult = await scanHTML(html)
console.log(` Found ${scanResult.violations.length} violations.`)
// 3. Heal
console.log('π Healing...')
const healResult = await healHTML(html, scanResult.violations)
console.log('π Healer Report:')
healResult.fixes.forEach(f => {
console.log(` β
Fixed ${f.issueId}`)
console.log(` Original: ${f.originalCode}`)
console.log(` Fixed: ${f.fixedCode.replace(/\n/g, '')}`)
})
// 4. Save result
const fixedPath = path.join(process.cwd(), 'public/demo-sites/fixed.html')
fs.writeFileSync(fixedPath, healResult.fixedHTML)
console.log(`πΎ Saved fixed HTML to ${fixedPath}`)
}
main().catch(console.error)