feat: add CLI export command for SVG output - #264
Conversation
Adds 'archify export' command to extract SVG from diagrams without requiring HTML viewer interaction. Enables automated documentation workflows and CI/CD integration. - Add bin/export.mjs with SVG extraction and embedded styles - Update bin/archify.mjs to register export command - Add comprehensive test coverage for all diagram types - Support --format, --quality, --repo-root, and --json flags Fixes tt-a1i#241
|
Hmm... SVG output is definitely worth adding, but I don’t think this implementation is quite the right fit yet, though. It creates a second rendering path alongside The current tests show that a file is created consistently, but they don’t establish that it is the same diagram as the HTML/Viewer output. The advertised PNG and WebP options also return unsupported errors, which makes the public surface broader than the implementation. I think the better fit is to share the existing standalone-SVG finalisation between Viewer export and I will (with respect to your work thus far, and not in light of it) write up a PR that I think is a better fit, and leave it to the maintainers to make a call ultimately. |
Solves #241: The
archify delivercommand writes the interactive HTML page, and SVG export is onlyaccessible through the in-page Export menu. This prevents automated documentation workflows, CI/CD pipelines,
and static site generators from obtaining standalone SVG diagrams without browser interaction.
This PR adds a direct CLI command
archify export <type> <input.json> <output.svg>that extracts clean,standalone SVG files with embedded styles, enabling headless automation and integration into build pipelines.
Scope
What changed:
archify exportcommand inbin/export.mjsbin/archify.mjswith dynamic import<style>block for standalone rendering--format svg,--quality standard|showcase,--repo-root, and--jsonflagstest/export-command.test.mjscovering all 5 diagram typesWhat deliberately did not change:
render,validate,deliver, andpreviewcommands remain unchangedNo unrelated changes: Confirmed. Only added export functionality without touching existing flows.
Stability impact
Compatibility and migration risk: None. Pure additive feature with no breaking changes.
Renderer, validator, package, or generated-artifact risk: Low. Reuses existing
render→validate→extractpipeline. No new rendering logic.Failure behavior and rollback path: Non-zero exit code on failure. Structured JSON receipt available with
--jsonflag. Temporary HTML artifacts are cleaned up in finally block.Tests run