An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.
fix(capture): create nested screenshot output directories
Rudy Celekli5ced5980f6a9
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bf7b18d..d60e54d 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -25,6 +25,9 @@ jobs:with:node-version: 22+ - name: Capture regressions+ run: node --test scripts/capture.test.mjs+- name: Dial indicatorrun: |node examples/dial-indicator/build.mjsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8152ae2..6edda3c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha### Fixed+- `scripts/capture.mjs` now creates the output directory for screenshots, including nested paths under `shots/`.+- `examples/test-rig/` drew its glass button dark in the light theme. `stretch.css` now has light values for its own colours.### Changeddiff --git a/scripts/capture.mjs b/scripts/capture.mjsindex 755bb0a..854ccc0 100644--- a/scripts/capture.mjs+++ b/scripts/capture.mjs@@ -1,7 +1,7 @@import { spawn } from "node:child_process";-import { existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";import { homedir, tmpdir } from "node:os";-import { join, resolve } from "node:path";+import { dirname, join, resolve } from "node:path";import { pathToFileURL } from "node:url";if (typeof WebSocket === "undefined" && !process.execArgv.includes("--experimental-websocket")) {@@ -199,6 +199,7 @@ async function main() {}const shoot = async (path, clip, scale) => {const shot = await send("Page.captureScreenshot", { format: "png", captureBeyondViewport: true, clip: { ...clip, scale } });+ mkdirSync(dirname(path), { recursive: true });writeFileSync(path, Buffer.from(shot.result.data, "base64"));};const clipOf = () => {diff --git a/scripts/capture.test.mjs b/scripts/capture.test.mjsnew file mode 100644index 0000000..f489748--- /dev/null+++ b/scripts/capture.test.mjs@@ -0,0 +1,42 @@+import assert from "node:assert/strict";+import { execFile } from "node:child_process";+import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { promisify } from "node:util";+import { fileURLToPath } from "node:url";+import test from "node:test";++const execute = promisify(execFile);+const capture = fileURLToPath(new URL("capture.mjs", import.meta.url));++test("capture creates nested output directories for initial and timed screenshots", async () => {+ const directory = await mkdtemp(join(tmpdir(), "anatomy-capture-"));+ try {+ const page = join(directory, "figure.html");+ const output = join(directory, "shots", "closeups", "figure.png");+ await writeFile(page, '<!doctype html><div class="iso-plate" style="width:200px;height:100px;background:papayawhip">Figure</div>');+ const result = await execute(process.execPath, [capture, page, "--out", output, "--wait", "0", "--times", "20", "--scale", "1"], { timeout: 30000 });+ assert.match(result.stdout, /console: clean/);+ for (const name of [output, output.replace(/\.png$/, "-20.png")]) {+ const png = await readFile(name);+ assert.deepEqual([...png.subarray(0, 8)], [137, 80, 78, 71, 13, 10, 26, 10]);+ assert.ok(png.length > 100);+ }+ } finally {+ await rm(directory, { recursive: true, force: true });+ }+});++test("capture retains existing-directory output", async () => {+ const directory = await mkdtemp(join(tmpdir(), "anatomy-capture-"));+ try {+ const page = join(directory, "figure.html");+ const output = join(directory, "figure.png");+ await writeFile(page, '<!doctype html><div class="iso-plate" style="width:200px;height:100px;background:papayawhip">Figure</div>');+ await execute(process.execPath, [capture, page, "--out", output, "--wait", "0"], { timeout: 30000 });+ assert.ok((await readFile(output)).length > 100);+ } finally {+ await rm(directory, { recursive: true, force: true });+ }+});