Nx: [Feature Request] Save dependency graph to image file

Created on 14 Nov 2019  路  5Comments  路  Source: nrwl/nx

Expected Behavior

Be able to save the dependency graph in an image file.
Something like: yarn nx affected:dep-graph --saveAs="dep-graph.png"

Current Behavior

It is not possible to save the graph as an image with yarn nx dep-graph cmd

Context

The final goal would be to be able to post this image in new pull request with github actions for example

core enhancement

Most helpful comment

I'm investigating how we can implement outputting the dep graph as an image. A recent PR added the ability to output a static HTML version of the dep graph: https://github.com/nrwl/nx/pull/3049. Look for the static HTML option in our next release.

All 5 comments

An option to save it as an html file would also be nice. I would like to include it in my compodoc generated documentation. Right now I have a build step that starts the server, curls it, and writes the output to file.
package.json

...
scripts: {
"affected:dep-graph": "nx affected:dep-graph",
"scrape-dep-graph": "sleep 10; mkdir -p dist/dep-graph && curl -s http://localhost:4211 > dist/dep-graph/index.html && exit 0",
}

yarn run-p --race affected:dep-graph scrape-dep-graph

then my .compodocrc.json

{
  "assetsFolder": "dist/dep-graph"
}

Hi all,

I would like to implement this feature behind the file flag, as it currently outputs the dep graph as a json file.
So, once implemented, one could invoke it with:
nx affected:dep-graph --file=output.html or
nx affected:dep-graph --file=output.png

The easiest option to implement is the "export to html". The implementation is there already. It just needs a bit of refactoring.

About the possibility to export to png...The only thing I came up with is to use puppeeter to make a screenshot of the html. TBH, I am not a fan of this, because this includes another dependency (:-1: ), which will increase nx's size and has to be maintained.

What do you guys say? Do you know any better alternative on how to generate a png?

I came to almost the same conclusion. I wasn't a fan of adding a dependency to make a dom in image (or capturing a url).

The other idea I had is to redo the graph with a tool supporting Command Line Rendering ( anychart, vega, ...)
but 馃し鈥嶁檪

I'm investigating how we can implement outputting the dep graph as an image. A recent PR added the ability to output a static HTML version of the dep graph: https://github.com/nrwl/nx/pull/3049. Look for the static HTML option in our next release.

Hi, sorry about this.

This was mislabeled as stale. We are testing ways to mark _not reproducible_ issues as stale so that we can focus on actionable items but our initial experiment was too broad and unintentionally labeled this issue as stale.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zachnewburgh picture zachnewburgh  路  3Comments

markphip picture markphip  路  3Comments

jon301 picture jon301  路  3Comments

MichaelWarneke picture MichaelWarneke  路  3Comments

olakara picture olakara  路  3Comments