-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Get nx graph
data via stdout
#18689
Comments
There is actually a way. You can pass Would you be interested in making a PR? |
Hmm. I feel like there's not too much gain with Or do you think it would be worth having a separate Either way, yeah, I can probably make a PR for this. |
Exactly, We cannot remove
|
I could take this if work hasn't started on it yet. (adding the new flag + docs, docs for |
I was looking for a way to use the generated graph programatically as well and was very happy to find out about the However, I am still facing some minor issues with this feature:
On the other hand, when redirecting the stdout output to a file, it seems to be complete – obviously, this defeats the purpose of using
If this text would be printed to stderr instead it would be easy to filter out, e.g. |
This issue has been automatically marked as stale because it hasn't had any activity for 6 months. |
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior --graph stdout and --file stdout aren't documented. When printing graph to stdout, its possible for some output to get missed. ## Expected Behavior Existing flags are documented, and `--print` is more discoverable. We await stdout finishing before exiting the program. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #18689
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior --graph stdout and --file stdout aren't documented. When printing graph to stdout, its possible for some output to get missed. ## Expected Behavior Existing flags are documented, and `--print` is more discoverable. We await stdout finishing before exiting the program. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #18689 (cherry picked from commit a308e1d)
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Description
Add a mechanism to get project graph data out of nx in a manner useful for scripts.
Motivation
nx graph
by itself spins up a web server to serve an interactive graph, which is fine for humans but unusable for scripting. Sometimes it would be nice to programmatically get (for example) a list of the internal projects that a particular project depends on.Suggested Implementation
A
--stdout
option (or something similar) for thenx graph
command.Alternate Implementations
There is a workaround, though it's a bit convoluted;
nx graph
already can output JSON if you give it a--file=<something>.json
option (presumably this looks at the extension, since you can also do--file=<something>.html
and get an HTML page). Thus, with some tempfile shenanigans, you can get a one-liner that does the same kind of thing, something likebut that's ugly, and I'm honestly not sure how portable it is (my original attempts used other options of
mktemp
which aren't actually options in MacOS's version of the program).Since there's already the mechanism to output JSON, this should be a fairly simple addition. But maybe there is already a way (aside from my hack) and I just couldn't find it in the docs.
The text was updated successfully, but these errors were encountered: