merge-font-assets.mjs 1.2 KB

12345678910111213141516171819202122232425
  1. // 把 tools/font-assets.json 合并进 public/cockpit/assets/manifest.json 的 fonts 块。
  2. // 幂等:反复运行结果一致;不改动既有 entries(图标)与 release 之外的任何字段。
  3. // 用法:node scripts/merge-font-assets.mjs
  4. import { readFileSync, writeFileSync } from 'node:fs'
  5. import { join, dirname } from 'node:path'
  6. import { fileURLToPath } from 'node:url'
  7. const here = dirname(fileURLToPath(import.meta.url))
  8. const ROOT = join(here, '..', '..', '..')
  9. const manifestPath = join(ROOT, 'public', 'cockpit', 'assets', 'manifest.json')
  10. const built = JSON.parse(readFileSync(join(here, 'font-assets.json'), 'utf8'))
  11. const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
  12. manifest.fonts = {
  13. note: '字体授权门禁的事实来源(规格 11):entries 里的字体条目必须命中 licenses 里「证据齐全」的一条,否则解析阶段不可用、走系统回退。',
  14. subsetTextChars: built.subsetTextChars,
  15. licenses: built.licenses,
  16. entries: built.entries,
  17. }
  18. writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n', 'utf8')
  19. console.log('merged fonts block:',
  20. built.licenses.length, 'licenses /', built.entries.length, 'entries',
  21. '| release:', manifest.release)