Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI tool? #149

Open
piranna opened this issue Sep 24, 2023 · 5 comments
Open

CLI tool? #149

piranna opened this issue Sep 24, 2023 · 5 comments

Comments

@piranna
Copy link

piranna commented Sep 24, 2023

Is there any way to use this as a headless CLI tool? Provide a package.json file as argument, and get the SVG content in stdout.

@piranna
Copy link
Author

piranna commented Sep 24, 2023

Is being done the rendering server side? If so, it could be done with just a single fetch() request...

@broofa
Copy link
Collaborator

broofa commented Sep 30, 2023

This is not something I've designed for so, no, there's no simple way to render graphs on the server at the moment.

It might be possible to generate graphs with puppeteer, but I haven't explored that.

The core SVG is created by generating a DOT document and running that through graphviz. So another option would be to write a script to do something similar and then call into one of the many availalbe language APIs for graphviz to generate the diagram. But NPMGraph also does direct DOM manipulation of the SVG graph for selection, colorizing, and other other view-related behavior, so this approach wouldn't capture those aspects of the graph.

@broofa
Copy link
Collaborator

broofa commented Oct 24, 2023

@piranna Have you looked at https://www.npmjs.com/package/madge? 'Would be curious to hear your thoughts on how that tool does/doesn't overlap with what a headless npmgraph might provide.

@piranna
Copy link
Author

piranna commented Oct 24, 2023

@piranna Have you looked at npmjs.com/package/madge? 'Would be curious to hear your thoughts on how that tool does/doesn't overlap with what a headless npmgraph might provide.

Yes, in fact I'm using it :-) It generates the graph at modules level, not at packages level. For me it's useful to detect circular references in complex code bases that can lead to bugs.

@broofa
Copy link
Collaborator

broofa commented Oct 25, 2023

FWIW, I've just published the first version of the npmgraph CLI. It's not what you're asking for here, but may still be of interest. It's basically a fancy URL-opener for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants