gen-houguyin.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // 江中猴菇饮 OTC · VOC 深度洞察报告生成入口
  2. //
  3. // 用法:node scripts/tools/gen-houguyin.js
  4. //
  5. // 输出:reports/jiangzhong-houguyin-voc-insight-report.html
  6. const fs = require('fs');
  7. const path = require('path');
  8. const { buildHTML, CHAPTERS, CHAPTER_SUBSECTIONS } = require('./houguyin-render.js');
  9. const HGY = require('./houguyin-analyze.js');
  10. const ROOT = path.resolve(__dirname, '..', '..');
  11. const OUT_PATH = path.join(ROOT, 'reports', 'jiangzhong-houguyin-voc-insight-report.html');
  12. function main() {
  13. const t0 = Date.now();
  14. console.log('╔═══════════════════════════════════════════════════════════╗');
  15. console.log('║ 江中猴菇饮 OTC · VOC 深度洞察报告生成(反向定位方法论) ║');
  16. console.log('╚═══════════════════════════════════════════════════════════╝');
  17. const data = HGY.loadMerged();
  18. const meta = HGY.getMeta(data);
  19. const stage = meta.stage;
  20. console.log(` 采集阶段: ${stage}`);
  21. console.log(` 输出: ${path.relative(ROOT, OUT_PATH)}`);
  22. // 计算 slide 总数
  23. let slideTotal = 2;
  24. for (const c of CHAPTERS) {
  25. slideTotal += 1 + (CHAPTER_SUBSECTIONS[c.key] || []).length;
  26. }
  27. console.log(` 章节: 9 大章(人群全景/未满足需求/猴菇饮机会/KANO-JTBD/场景/竞品/机会/蓝图/真声洞察)`);
  28. console.log(` slide 总数: ${slideTotal}`);
  29. if (meta.comments > 0) {
  30. console.log(` VOC 数据: ${meta.comments} 条评论 / ${Object.keys(meta.platforms || {}).length} 平台`);
  31. } else {
  32. console.log(` ⚠ VOC 数据待采集(Batch 2 将填充真实评论)`);
  33. }
  34. // 生成 HTML
  35. const html = buildHTML({
  36. product: '江中猴菇饮',
  37. collectedAt: meta.collectedAt,
  38. });
  39. // 写入
  40. fs.mkdirSync(path.dirname(OUT_PATH), { recursive: true });
  41. fs.writeFileSync(OUT_PATH, html, 'utf8');
  42. const sizeKB = (Buffer.byteLength(html, 'utf8') / 1024).toFixed(1);
  43. const ms = Date.now() - t0;
  44. console.log('');
  45. console.log(` ✅ 生成完成`);
  46. console.log(` 路径: ${path.relative(ROOT, OUT_PATH)}`);
  47. console.log(` 大小: ${sizeKB} KB`);
  48. console.log(` 耗时: ${ms} ms`);
  49. console.log(` 阶段: ${stage}`);
  50. }
  51. if (require.main === module) {
  52. main();
  53. }
  54. module.exports = { main };