46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
// E17: create LineAssembly and insert all 88 part links from the E16 checkpoint.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { createSceneRunner } from "../../../carrier-course/lib/scene.mjs";
|
|
import { createAssembly, insertLinks } from "../../lib/assembly.mjs";
|
|
|
|
export async function run({ page, rec, script, stillsDir, rawDir }) {
|
|
const scene = createSceneRunner({ rec, page, script });
|
|
const shot = name => rec.shot(stillsDir, name);
|
|
const log = [];
|
|
const logStep = entry => {
|
|
log.push({ at: new Date().toISOString(), ...entry });
|
|
fs.writeFileSync(path.join(rawDir, "live-log.json"), `${JSON.stringify(log, null, 2)}\n`);
|
|
};
|
|
let linksTask = null;
|
|
let result = null;
|
|
|
|
await scene("S00", async () => { await shot("S00-title"); });
|
|
|
|
await scene("S01", async () => {
|
|
linksTask = await createAssembly(page, { document: "LineAssembly", label: "生产线总装" });
|
|
logStep({ step: "created" });
|
|
await shot("S01-assembly");
|
|
});
|
|
|
|
await scene("S02", async () => {
|
|
result = await insertLinks(page, linksTask, "line-course-E16.FCStd", 88);
|
|
logStep({ step: "inserted", count: result.items.length });
|
|
await shot("S02-links");
|
|
});
|
|
|
|
await scene("S03", async () => {
|
|
if (result.items.length !== 88) throw new Error(`expected 88 links, got ${result.items.length}`);
|
|
logStep({ step: "audit", count: result.items.length });
|
|
await shot("S03-audit");
|
|
});
|
|
|
|
await scene("S04", async () => {
|
|
fs.writeFileSync(path.join(rawDir, "E17-state.json"), `${JSON.stringify({
|
|
schema: "freecad-web-line-course/E17/state/v1", generatedAt: new Date().toISOString(),
|
|
links: result.linkNames, log,
|
|
}, null, 2)}\n`);
|
|
await shot("S04-recap");
|
|
});
|
|
}
|