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

Create developer friendly API #1

Open
BrunnerLivio opened this issue Sep 10, 2018 · 3 comments
Open

Create developer friendly API #1

BrunnerLivio opened this issue Sep 10, 2018 · 3 comments

Comments

@BrunnerLivio
Copy link

BrunnerLivio commented Sep 10, 2018

Hello everyone,
Firstly; Thanks for sharing this awesome project!

I want to generate this graph automatically inside a Pipeline, so I can automatically use the graph as build artifact on every release. This. would require an easy developer interface as npm package and / or as CLI tool.

As CLI I could imagine something like that:

npm-dependency-graph “@angular/core,@angular/common” —filter “@angular” > graph.svg

or as package

import * as NpmDependenyGraph from “npm-dependency-graph”;

// Returns buffer
NpmDependenyGraph.generate({
  packages: [@angular/core, @angular/common’],
  filter: [@angular”]
})

Are there any plans for this, or have I missed something in the documenation?

Cheers,
Livio

Edit: sorry for the bad formatting. Currently on mobile😅

@JanKoehnlein
Copy link

There are no such plans currently, but contributions are always welcome!

The tricky part would be to mimic the browser's rendering. As in SVG, you cannot make boxes as large as their contents, we need to grab the bounds of elements first before doing the layout. As this is also affected by CSS (e.g. font sizes), we do a hidden rendering cycle in the browser to grab these bounds.

@BrunnerLivio
Copy link
Author

BrunnerLivio commented Sep 15, 2018

Hmm I see. Is this hard to implement or maybe it would be easier to just use chrome headless?
I'll do a PR if I have a decent solution :)

@spoenemann
Copy link
Member

Might be that Puppeteer can help with that, but I never tried it.

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

3 participants