Crates.io | dependency-tree-svg |
lib.rs | dependency-tree-svg |
version | 0.1.2 |
source | src |
created_at | 2024-07-10 22:06:41.697726 |
updated_at | 2024-07-10 22:08:24.806059 |
description | a package to generate a self-contained interactive SVG file from a dependency graph |
homepage | |
repository | |
max_upload_size | |
id | 1298805 |
size | 14,823 |
dependency-tree-svg
This crate generates self-contained SVG files based on given JSON file with dependencies.
Dependencies must have the following format:
{
"root": [
"packageName1"
],
"packageName1": [
"dependency1",
"dependency2"
],
"dependency1": [
"sub-dependency2"
]
}
Then if you run
$ cargo run --bin run --features=lexopt -- --datafile data.json --write-to output.svg
You'll get an SVG file in output.svg
which looks like this:
This tree is interactive, by clicking on the packageName1
you'll get
This crate is a library, here's the interface:
fn generate_svg() {
let file = std::fs::File::open("dependencies.json").unwrap();
let reader = std::io::BufReader::new(file);
let input: dependency_tree_svg::Input = serde_json::from_reader(reader)?;
let box_size = 80;
let svg = dependency_tree_svg::compile_svg(input, box_size);
std::fs::write("output.svg", svg).unwrap();
}
npm install
npm run build:dev
to start esbuild
in watch modeassets/main.svg
in the browserassets/
directorynpm run test:node
To release:
npm run build:release
(to get minified JS)cargo publish --allow-dirty
(because generated JS files are not under git)