#!/usr/bin/env node // ============================================================================== // 江中肝纯片 · 产品复合体 HTML 报告生成器 // 用法:node scripts/tools/gen-compound-liver.js // 输出:reports/jiangzhong-liver-compound-report.html // 依赖: // - data/jiangzhong-liver-voc.json (VOC 原始数据) // - scripts/tools/voc-analyze.js (分析层) // - scripts/tools/compound-liver-render.js (渲染层,分批次扩展) // ============================================================================== const fs = require('fs'); const path = require('path'); const { analyze } = require('./voc-analyze.js'); const { buildHTML, TOTAL_SLIDES, CHAPTERS } = require('./compound-liver-render.js'); const INPUT = path.join('data', 'jiangzhong-liver-voc.json'); const OUTPUT = path.join('reports', 'jiangzhong-liver-compound-report.html'); function mtimeStr(fp) { try { const d = new Date(fs.statSync(fp).mtime); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); } catch { return '—'; } } console.log(`╔═══════════════════════════════════════════════════════════╗`); console.log(`║ 江中肝纯片 · 产品复合体 HTML 报告生成 ║`); console.log(`╚═══════════════════════════════════════════════════════════╝`); console.log(` 输入: ${INPUT}`); console.log(` 输出: ${OUTPUT}`); console.log(` 章节: ${CHAPTERS.length} 大维度`); console.log(` slide 总数: ${TOTAL_SLIDES}`); if (!fs.existsSync(INPUT)) { console.error(`\n ❌ VOC 数据不存在:${INPUT}`); process.exit(1); } const t0 = Date.now(); const voc = JSON.parse(fs.readFileSync(INPUT, 'utf-8')); const A = analyze(voc); const collectedAt = mtimeStr(INPUT); const html = buildHTML({ product: '江中肝纯片', A, collectedAt }); fs.mkdirSync(path.dirname(OUTPUT), { recursive: true }); fs.writeFileSync(OUTPUT, html, 'utf-8'); const size = fs.statSync(OUTPUT).size; const ms = Date.now() - t0; console.log(`\n ✅ 生成完成`); console.log(` 路径: ${OUTPUT}`); console.log(` 大小: ${(size / 1024).toFixed(1)} KB`); console.log(` 耗时: ${ms} ms`); console.log(` VOC: ${A.metrics.notes} 笔记 / ${A.metrics.sampleComments} 评论 / Amazon ${A.amazon?.total || 0} 款\n`);