Skip to content

Add option to print dependencies as tree - #4339

Merged
dbaynard merged 3 commits into
commercialhaskell:masterfrom
akshaymankar:dependency-tree
Nov 16, 2018
Merged

dbaynard merged 3 commits into
commercialhaskell:masterfrom
akshaymankar:dependency-tree

Conversation

@akshaymankar

@akshaymankar akshaymankar commented Oct 4, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #4101

Checklist

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

I think this is pretty discoverable by stack ls dependencies --help so I didn't add anything to the docs.

How did I test this?

Unfortunately, manually. The listDependencies function was directly printing and had no tests and I built on top of that without much thought of testing. So, I couldn't add any automated tests.
Here is output from stack ls dependencies --depth=0 --tree on the stack repository:

Packages
├── curator mkVersion [2,0,0,0]
├── pantry mkVersion [0,1,0,0]
└── stack mkVersion [1,10,0]

Depth=1 onwards, the output becomes really large, so I will not paste it here.
Additionally, if you could me some pointers around how to test this, I would be happy to add tests.

@mihaimaruseac mihaimaruseac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just skimmed through this now, looks good.

With regards to a test you could make an integration test, then parse the output string to see if it contains what you are expecting to.

@dbaynard

Copy link
Copy Markdown
Contributor

@akshaymankar Do shout if you need more pointers! We'll be happy to help.

@akshaymankar

Copy link
Copy Markdown
Contributor Author

Hi, I am sorry, I got a little busy. I saw the integration tests, it seems easy enough. I will probably write the tests by the end of this week.

@akshaymankar

Copy link
Copy Markdown
Contributor Author

I have added two tests, one for testing the whole dependency tree and another for testing that the --depth flag is respected.

@akshaymankar

Copy link
Copy Markdown
Contributor Author

Looks like tests have failed due to some connection timeouts, I have rebased on top of lastest master and pushed again. Hopefully this will re-run the tests and they will pass. 🤞

@dbaynard

Copy link
Copy Markdown
Contributor

Don't worry about Travis — CI doesn't run integration tests, anyway, so we'll have to run them ourselves before merging.

@dbaynard

Copy link
Copy Markdown
Contributor

Your integration test is failing on my build — I'll investigate but I'm sure it's my setup, or something minor (it's more worrying if other tests fail 👍)

@dbaynard
dbaynard merged commit be2f2ea into commercialhaskell:master Nov 16, 2018
@dbaynard

Copy link
Copy Markdown
Contributor

Thanks, @akshaymankar! Would you like to tackle the next items on #4101 (comment)?

@akshaymankar

Copy link
Copy Markdown
Contributor Author

@dbaynard I would love to. Let me know if you have (or know of other people having) any preferences for the structure of the data. If not, I will look at other tools and post a comment about it before implementing on #4101.

@akshaymankar
akshaymankar deleted the dependency-tree branch November 18, 2018 10:27
Comment thread src/Stack/Dot.hs
payloadText opts payload =
if listDepsLicense opts
then maybe "<unknown>" (Text.pack . display . either licenseFromSPDX id) (payloadLicense payload)
else maybe "<unknown>" (Text.pack . show) (payloadVersion payload)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to use display rather than show, actually, to get an output without the mkVersion labels — but I'd need to check to confirm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, I was so invested in printing the tree that I forgot about version.
I've created a PR with the fix: #4413

@dbaynard

Copy link
Copy Markdown
Contributor

I'll reply there.

I would like to change the current representation, slightly — I missed it earlier. It can go in the next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants