38 lines
1.9 KiB
JavaScript
38 lines
1.9 KiB
JavaScript
import { createRequire } from 'node:module'
|
|
import { mkdir, writeFile } from 'node:fs/promises'
|
|
import { fileURLToPath } from 'node:url'
|
|
import path from 'node:path'
|
|
import { captureYcodePlatformFonts } from './verify-font-platform-parity.mjs'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
|
|
const outputPath = path.resolve(projectRoot, process.argv[2] ?? '.tmp/ycode-font-platform-selftest-reference.json')
|
|
const samples = [
|
|
{ category: 'assistant-name', text: 'YCode' },
|
|
{ category: 'chinese-body', text: '中文字体字形探针:你好,世界!这是用于复现的正文样本。' },
|
|
{ category: 'english-body', text: 'Typography fixture: The quick brown fox jumps over 13 lazy dogs.' },
|
|
{ category: 'user-bubble', text: '请对照这条用户消息的 glyph count,其中包含 English。' },
|
|
{ category: 'code', text: 'const greeting = "你好, YCode";\nconsole.log(greeting);' }
|
|
]
|
|
|
|
const captured = await captureYcodePlatformFonts(samples)
|
|
const report = {
|
|
schemaVersion: 1,
|
|
source: { kind: 'ycode-electron-self-test', description: 'Local YCode Electron fixture; this is not WorkBuddy evidence.' },
|
|
evidenceId: `local-ycode-font-fixture-${Date.now()}`,
|
|
version: `YCode ${require('../../package.json').version}`,
|
|
capturedAt: new Date().toISOString(),
|
|
environment: captured.environment,
|
|
samples: captured.samples,
|
|
missing: []
|
|
}
|
|
await mkdir(path.dirname(outputPath), { recursive: true })
|
|
await writeFile(outputPath, `${JSON.stringify(report, null, 2)}\n`)
|
|
console.log(JSON.stringify({
|
|
kind: report.source.kind,
|
|
evidenceId: report.evidenceId,
|
|
version: report.version,
|
|
samples: report.samples.map((sample) => ({ category: sample.category, fontFamily: sample.fontFamily, platformFonts: sample.platformFonts })),
|
|
outputPath: path.relative(projectRoot, outputPath).replaceAll('\\', '/')
|
|
}, null, 2))
|