#!/usr/bin/env node /** Bind the complete-course evidence with SHA-256 and write the task manifest. */ import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import { execFileSync } from "node:child_process"; import { fileURLToPath } from "node:url"; const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../.."); const OUT = path.join(REPO, "tests/golden/COMPLETE-TUTORIAL-001"); const VIDEO_DIR = path.join(REPO, "web/app/public/tutorial/complete/video"); const html = path.join(REPO, "web/app/public/tutorial/complete/index.html"); const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex"); const artifact = (file) => fs.existsSync(file) ? { path: file, bytes: fs.statSync(file).size, sha256: sha256(file) } : null; const readJson = (file) => fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")) : null; const probe = (file) => { if (!fs.existsSync(file)) return null; try { return JSON.parse(execFileSync("/usr/bin/ffprobe", ["-v", "error", "-show_entries", "format=duration,size:stream=codec_type,codec_name,width,height", "-of", "json", file], { encoding: "utf8" })); } catch { return null; } }; const walkthrough = readJson(path.join(OUT, "capture-report.json")); const backend = readJson(path.join(OUT, "backend/backend-report.json")); const videoReport = readJson(path.join(OUT, "video/video-report.json")); const mp4 = path.join(VIDEO_DIR, "complete-course-720p.mp4"); const vtt = path.join(VIDEO_DIR, "complete-course.zh-Hans.vtt"); const poster = path.join(VIDEO_DIR, "poster.jpg"); const narration = path.join(OUT, "video/narration.wav"); const mediaProbe = probe(mp4); const manifest = { schemaVersion: 1, task: "COMPLETE-TUTORIAL-001", status: "IMPLEMENTED_NOT_USER_ACCEPTED", generatedAt: new Date().toISOString(), assets: { pbrSourceCatalog: { path: "/home/mes123456/workinf_Blender_Wasm/re/5000PBR精简版/5000+ PBR catalog.blend", sha256: "54942f057f913c9923752ba0d4ddcfa6d1f77e98c5e812b83409fb128968c125" }, monkeyGlb: { path: "/home/mes123456/workinf_Blender_Wasm/re/猴头.glb", sha256: "60267d607b63ceb5bfc972342a9ff17310d6978ff632f240ecb963c4d5a7e003" }, }, lanes: { local: "http://127.0.0.1:5184/?ui=web (Vite dev, Chromium hardware)", backend: "http://127.0.0.1:5176/?ui=web (web/dist + deployment server + native Blender 5.2.0 LTS)", }, walkthrough: { status: walkthrough?.status ?? null, modules: walkthrough?.modules?.length ?? 0, steps: walkthrough?.modules?.reduce((total, module) => total + module.steps.length, 0) ?? 0, gaps: walkthrough?.gaps?.length ?? null, report: artifact(path.join(OUT, "capture-report.json")), screenshots: fs.existsSync(path.join(OUT, "walkthrough")) ? fs.readdirSync(path.join(OUT, "walkthrough")).length : 0, }, backend: { status: backend?.status ?? null, checks: backend?.checks?.length ?? 0, report: artifact(path.join(OUT, "backend/backend-report.json")), }, manual: { html: artifact(html), source: artifact(path.join(REPO, "tools/web/course/complete-course.json")), chapters: 24, steps: 90, }, video: { status: videoReport?.status ?? null, mp4: artifact(mp4), vtt: artifact(vtt), poster: artifact(poster), narration: artifact(narration), probe: mediaProbe, report: artifact(path.join(OUT, "video/video-report.json")), timeline: artifact(path.join(OUT, "video/timeline.json")), }, }; fs.writeFileSync(path.join(OUT, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`); console.log(JSON.stringify({ status: manifest.status, walkthrough: manifest.walkthrough.status, backend: manifest.backend.status, video: manifest.video.status, manifest: path.join(OUT, "manifest.json") }, null, 2));