Skip to content

v3.48.0

@MrCoder MrCoder tagged this 12 May 04:42
* feat: add CLI entry point for rendering ZenUML DSL to SVG

Adds a Bun-executable CLI (`src/cli/zenuml.ts`) that reads ZenUML DSL
from a file or stdin and renders it to SVG via the existing renderToSvg
pipeline. Supports -i/--input, -o/--output, -q/--quiet, -h/--help, and
-V/--version flags. Includes 8 subprocess-based tests covering all flag
combinations, stdin piping, and default output naming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add PNG output, scale/bgcolor/theme/config flags to CLI

Sprint 2 deliverables:
- -e/--outputFormat flag (svg|png), auto-detect from .png extension
- -s/--scale for PNG pixel density (default 2)
- -b/--backgroundColor (default white for PNG, transparent for SVG)
- -t/--theme passed through to renderToSvg
- -c/--configFile JSON config with CLI flag override precedence
- PNG rasterization via @napi-rs/canvas
- 9 new tests (17 total) covering PNG header, IHDR scale, auto-detect,
  bgcolor, config merge/override, config errors, help text, invalid format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add --check, --parse, --json modes to CLI for syntax validation and AST output

Add validate-only and parse-only modes that skip rendering entirely:
- --check validates syntax, supports multiple -i flags, reports errors grouped by file
- --parse outputs ANTLR parse tree as JSON with type/ruleName/children structure
- --check --json outputs machine-readable JSON array of per-file pass/fail results
- Rendering flags (-o, -e, -t, -s, -b) silently ignored in check/parse modes
- Parser.ErrorDetails cleared before each file parse to isolate per-file errors
- AST serializer avoids circular refs (parentCtx, symbol.source, parser back-refs)

12 new tests (29 total CLI tests), 654+ full suite passing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add glob support and multi-file rendering to CLI

Add glob pattern expansion (Bun.Glob) for -i values containing *, ?, [.
Render multiple inputs in a single invocation with progress reporting,
continue-on-error, and summary line to stderr. Support -o as directory
for batch output with auto-created subdirs. Error when -o is a single
file with multiple inputs. --parse rejects multiple inputs after expansion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve output path bug for absolute globs with -o directory

resolveOutput() used relative(cwd, resolve(input)) which produced ../..
traversals for absolute paths, causing files to escape the output directory.
Now uses basename(input) so output files always land directly in the target
directory. Also fixes duplicate mkdirSync import, adds file-existence
assertions to test (ac), and cleans up misleading test (ae) setup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(cli): add Markdown mode (--md flag, auto-detect, block rendering)

Sprint 5 implementation:
- Add `--md` flag and auto-detect Markdown mode from .md/.markdown extension
- Implement `extractZenumlBlocks(md)` — returns [{index, code, title, raw, empty}]
- Render each non-empty zenuml fenced block to {stem}-zenuml-{N}.{format}
- Replace blocks in output Markdown with ![alt](filename); remove empty blocks
- Default output: {stem}-rendered.md adjacent to input; -o - writes to stdout
- Images placed in dir of -o when specified, or input dir otherwise
- -e svg|png applies to all diagram images
- Help text updated with --md flag documentation
- Guard main() with import.meta.main so exports work from test imports
- Add 14 new tests: 4 unit (extractZenumlBlocks) + 10 integration (ak-as)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(cli): add watch mode (Sprint 6)

- Add `-w`/`--watch` flag to CliArgs, parseArgs, and printHelp
- Validate incompatibilities: --watch with --check, --parse, or stdin exits 1
- Export `startWatchMode()` with debounced per-file watchers, initial renders, and timestamped logging
- Support separate `renderMdFn` for .md files in watch mode
- SIGINT handler calls shutdown() then exits 0
- Add 10 new tests (subprocess + unit) covering all D1–D7 deliverables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Sprint 7: build, distribution, and documentation improvements

- Add "cli" dev script to package.json for local CLI invocation
- Add "files" allowlist (dist/, types/, src/cli/) to package.json
- Expand .npmignore to exclude all internal tooling dirs (.agents/, .claude/, .kiro/, skills/, docs/, scripts/, e2e/, playground/, .storybook/) and other dev-only files
- Append 'Run "zenuml --help" for usage.' to unknown-flag error (exit 1)
- Add visual section groupings to --help: Rendering, Validation, Batch & Watch, General

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Sprint 7: tighten files allowlist to specific CLI entry point

Change src/cli/ directory to src/cli/zenuml.ts in the files allowlist
so the spec test file is not included in the published package.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: inject @napi-rs/canvas context for accurate text measurement in CLI

Without this, WidthProviderOnCanvas has no canvas available in Node/Bun
and falls back to character estimates, producing incorrect participant
spacing and message positioning in both SVG and PNG output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(cli): switch PNG rasterization to headless Chromium via Playwright

Replace @napi-rs/canvas with Playwright's headless Chromium for pixel-perfect
PNG output. The browser renders CSS <style> blocks, emojis, and colored
participants identically to a real browser. A shared browser instance is
launched on first PNG render and closed on process exit via main().finally().

@napi-rs/canvas is retained solely for text measurement (setCanvasContext
injection for accurate SVG layout).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove jfrog registry URL from bun.lock for playwright-core

The lockfile had playwright-core resolved to a private jfrog registry,
causing 401 errors in CI. Reinstalled to use the default npm registry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(ci): install Playwright browsers in test job for CLI PNG tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(ci): install Chromium for playwright-core (not playwright) in test job

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(cli): remove -b/--backgroundColor flag

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(cli): add PNG snapshot regression tests using pixelmatch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: generate and verify CLI PNG snapshots in update-snapshots workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(cli): clean up generated sidecar SVG in stdout markdown test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(cli): resolve all ESLint errors in CLI module

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(cli): render markdown comments without DOMPurify in measurer

Co-Authored-By: Codex <codex@openai.com>

---------

Co-authored-by: Peng Xiao <PengXiao@sinch.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Codex <codex@openai.com>
Assets 2
Loading