-
Notifications
You must be signed in to change notification settings - Fork 842
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
Add option to print dependendies as JSON #4424
Add option to print dependendies as JSON #4424
Conversation
I think this proposal has sense and we should go that way. Format of JSON seems ok to me. |
I tried a few things for the So here are my attempts: Attempt 1: Accept format as
|
I'm not sure the benefit of pretty json outweighs the cost of the extra dependency. Perhaps you could use Edit: to be clear, I mean keep the (machine-readable) aeson output but don't prettify it, and if we want to enhance this with a prettier output then we can use yaml. |
I'll getting there! Thanks for your patience. |
Makes sense, I will remove the prettyfication of json. I was going to add yaml anyways. |
Sorry for vanishing on this. I was finding it difficult to dedicate more time to this. I think I can carve out some time in this week and the next one. Hopefully, I'll be able to figure out source information of packages. |
See #4494 for some documentation |
@akshaymankar Just reviewing open PRs. I'm unclear what next steps are here, are you still interested in pursuing this PR? |
I am waiting for @dbaynard to finish the refactoring as he mentioned here: #4561 (comment). |
@akshaymankar I've merged #4561 if you'd like to continue with this PR. |
87c57e7
to
def4e4f
Compare
aa41862
to
9fae94f
Compare
Hello, I think this PR finally is in a reviewable state, so I will remove the There is one this I am not sure of, I couldn't find any way to get location of global packages. So, their location just doesn't show up. I know they're on hackage, but I'm not sure how and if we should look that up and show that. Also, unlike discussed here, the git dependencies also show up with PS: The style tests are failing because of something unrelated. |
I won't have a chance to review this today, and probably not all week due to travel. Beforehand: can you merge in |
This ensures interface of ls dependencies remains clean and users can only pass options when they make sense [commercialhaskell#4101]
And thus remove dependency on `aeson-pretty` [commercialhaskell#4101]
9fae94f
to
5d63f6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Sorry to spoil the party, but IIUC how this is implemented, it does not really fix my issue #4481:
Yes, |
While I agree that |
@sschuberth Can you please confirm if #4994 works for your usecase? |
Yes, that PR looks very useful to cover my use-case. Thanks a lot @akshaymankar! Edit: However, there's one thing that still confuses me: The JSON-array seems to contain all (direct and transitive) dependencies in a flat list, and your change "just" makes each entry also list the names of its direct dependencies, respectively. However, what I'd like to see is a tree (if the In other words, given the JSON-array there currently seems to be no way to find out whether an entry in that array is a direct dependency or a transitive dependency. Is that correct? |
The JSON array also contains the root package(s), so you can get the list of direct dependencies from that. |
Ah, thanks for the explanation, then all looks good to me! Edit: Again one amendment: How do I know (only from looking at the JSON) which of the listed packages is the root package? |
Hmm, I think there is no straightforward way to know that. If you don't mind running another command, easiest way I can think is to run |
Shame it didn't make it into recent Stack release. We, the https://github.com/rikvdkleij/intellij-haskell users, could actually benefit from the feature, since there is way to export external dependencies' sources. I mean, the new CLI is even backward-compatible, isn't it? |
The change is not backward-compatible. I had to change |
Thank you for clarifying this for me, I've only skimmed this comment. Still, it feels like we could be fine with bit of clutter (attempt 2) if that'd be the price to have the feature sooner than later. |
@develop7 Might be worth creating another issue. I don't think I will find time to work on this for now. Maybe somebody can add some backward compatibility so this can be released sooner. |
[Fixes #4101]
Format of the JSON:
Doesn't print URL of source code yet. But I'd like to get some feedback on the format of the JSON.
Adding option to print yaml should be straightforward as
Data.Yaml
can print instances ofToJSON
.Another thing I'd like to discuss is, adding --json to options like --tree, --license, --separator is getting a bit confusing, as none of the options affect json printing. I was thinking maybe it would be better if we created another option like --format which could be text, tree, json and the --license and --separator would only be application to text and tree and we could codify that in the opts type to make sure the user gets error if they provide --license or --separator when format is json.
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!