@topojs/cli
v0.4.1
Published
CLI for TopoJS — analyze, visualize, check, optimize, export and trace statespaces
Maintainers
Readme
@topojs/cli
CLI for TopoJS — analyze, visualize, check, optimize, export, and trace statespaces from the terminal.
Installation
npm install -g @topojs/cli
# or use without installing
npx @topojs/cli <command> <file>Requirements
- Node.js >= 20
Usage
topo <command> <store.js> [options]Note:
<file>must be a compiled JS/MJS file. Build your TypeScript source first (e.g.tscortsup).
Commands
analyze
Print all nodes and topology edges for every statespace found in the file.
topo analyze dist/store.jsStatespace: Cart
────────────────────────────────────────
Nodes:
items
discount [persist]
total
canCheckout
Topology:
total ← derives(items, discount)
canCheckout ← requires(total > 0)
4 nodes, 2 edgescheck
Validate the statespace — checks for unknown nodes in topology keys, constraint violations, and high-fanout warnings. Exits with code 1 if issues are found.
topo check dist/store.jstrace
Show upstream dependencies, downstream effects, and propagation order for a specific node.
topo trace dist/store.js totalStatespace: Cart — trace 'total'
────────────────────────────────────────
Depends on:
← items
← discount
Affects:
→ canCheckout
Update order:
1. total
2. canCheckoutoptimize
Suggest optimization hints — missing cache: true on multi-dependency derivations, high-fanout nodes, and deep propagation chains.
topo optimize dist/store.jsexport
Export the graph in a machine-readable format. Supports json (default), mermaid, and dot.
topo export dist/store.js --format json
topo export dist/store.js --format mermaid
topo export dist/store.js --format dotvisualize
Open an interactive force-directed graph visualizer in the browser. Supports zoom, pan, and node dragging. Each edge type is color-coded.
topo visualize dist/store.js
topo visualize dist/store.js --port 8080Defaults to port 7331. Press Ctrl+C to stop.
Edge colors in the visualizer
| Color | Edge type |
| --------------- | -------------- |
| Blue | derives |
| Purple (dashed) | requires |
| Green (dotted) | influencedBy |
| Orange | triggers |
License
MIT
