← GPT-AI-LP
CODE · 2.0 KB

scripts/render-real-cli-e2e.mjs

Workspace snapshot · 08/31 23:51

import { existsSync } from "node:fs";
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
import { auditWireframe } from "../api/quality-gate.js";
import { exportHtml } from "../src/export-html.js";
import {
  parseHeadlineResult,
  parseLpResult,
  parseQualityGate,
} from "../src/runtime-prompt.js";

const output = new URL("../output/real-e2e-v2/", import.meta.url);
const resultFile = existsSync(new URL("structure-result-v2.json", output))
  ? "structure-result-v2.json"
  : "structure-result.json";
const raw = await readFile(new URL(resultFile, output), "utf8");
const project = JSON.parse(await readFile(new URL("project.json", output), "utf8"));
const sections = parseLpResult(raw);
const headlines = parseHeadlineResult(raw);
const qualityGate = parseQualityGate(raw);
const audit = auditWireframe(sections, project.answers, qualityGate);

await mkdir(new URL("images/", output), { recursive: true });
await copyFile(
  new URL("../assets/qa/hero-textless-v1.png", import.meta.url),
  new URL("images/hero.png", output),
);

const html = exportHtml(
  project,
  sections,
  {
    id: "documentary-evidence",
    name: "Evidence Editorial",
    concept: "制作現場の実画面と判断基準を主役にする",
    type: "ゴシック × 明朝 / documentary evidence",
    palette: ["#13251f", "#f0643a", "#f4f1e8"],
  },
  [{ sectionId: sections[0].id, src: "images/hero.png" }],
);

await writeFile(new URL("index.html", output), html, "utf8");
await writeFile(
  new URL("qa-summary.json", output),
  JSON.stringify({
    sectionCount: sections.length,
    headlineCount: headlines.length,
    knownCount: qualityGate.known.length,
    hypothesisCount: qualityGate.hypotheses.length,
    unconfirmedCount: qualityGate.unconfirmed.length,
    automaticChecks: { passed: audit.passed, total: audit.total },
    mustViolations: audit.mustViolations,
    humanChecks: audit.humanChecks,
  }, null, 2),
  "utf8",
);

console.log(new URL("index.html", output).pathname);