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

List transitive version requirements for target #1

Merged
merged 4 commits into from Mar 15, 2018

Conversation

Projects
None yet
3 participants
@olivierlacan
Contributor

olivierlacan commented Mar 14, 2018

I've often found myself wonder why bundle update wouldn't do
anything since Bundler sadly doesn't ever explain why it couldn't do
the update. This could be a step toward identifying the version
requirements for each dependent of the target gem in the Gemfile.

For now I don't do any sorting and the results are slightly confusing
because they list all transitive dependencies which have the target in
their own transitive dependency tree.

So if actioncable depends on a gem that depends on nokogiri you will
see actioncable listed as requiring nokogiri (which is technically
correct but slightly confusing).

Example output for bundle-stats versions nokogiri in a Rails app:

bundle-stats for nokogiri

depended upon by (34):
+------------------------------|-------------------+
| Name                         | Required Version  |
+------------------------------|-------------------+
| actioncable                  | >= 1.6            |
| actionmailer                 | >= 1.6            |
| actionpack                   | >= 1.6            |
| actionview                   | >= 1.6            |
| approvals                    | ~> 1.6            |
| capybara                     | >= 1.3.3          |
| capybara-screenshot          | >= 1.3.3          |
| chromedriver-helper          | ~> 1.6            |
| coercion                     | >= 1.6            |
| coffee-rails                 | >= 1.6            |
| devise                       | >= 1.6            |
| devise-two-factor            | >= 1.6            |
| draper                       | >= 1.6            |
| factory_girl_rails           | >= 1.6            |
| formtastic                   | >= 1.6            |
| google-rails                 | >= 1.6            |
| gretel                       | >= 1.6            |
| haml-rails                   | >= 1.6            |
| html2haml                    | ~> 1.6.0          |
| inline_svg                   | ~> 1.6            |
| loofah                       | >= 1.5.9          |
| prawn_rails                  | >= 1.6            |
| rails                        | >= 1.6            |
| rails-controller-testing     | >= 1.6            |
| rails-dom-testing            | >= 1.6            |
| rails-html-sanitizer         | >= 1.5.9          |
| railties                     | >= 1.6            |
| responders                   | >= 1.6            |
| rspec-rails                  | >= 1.6            |
| sassc-rails                  | >= 1.6            |
| sprockets-rails              | >= 1.6            |
| xpath                        | ~> 1.3            |
+------------------------------|-------------------+
List transitive version requirements for target
I've often found myself wonder why bundle update <target> wouldn't do
anything since Bundler sadly doesn't ever explain why it couldn't do
the update. This could be a step toward identifying the version
requirements for each dependent of the target gem in the Gemfile.

For now I don't do any sorting and the results are slightly confusing
because they list all transitive dependencies which have the target in
their own transitive dependency tree.

So if actioncable depends on a gem that depends on nokogiri you will
see actioncable listed as requiring nokogiri (which is technically
correct but slightly confusing).

Example output for `bundle-stats versions nokogiri` in a Rails app:

```
bundle-stats for nokogiri

depended upon by (34):
+------------------------------|-------------------+
| Name                         | Required Version  |
+------------------------------|-------------------+
| actioncable                  | >= 1.6            |
| actionmailer                 | >= 1.6            |
| actionpack                   | >= 1.6            |
| actionview                   | >= 1.6            |
| approvals                    | ~> 1.6            |
| capybara                     | >= 1.3.3          |
| capybara-screenshot          | >= 1.3.3          |
| chromedriver-helper          | ~> 1.6            |
| coercion                     | >= 1.6            |
| coffee-rails                 | >= 1.6            |
| devise                       | >= 1.6            |
| devise-two-factor            | >= 1.6            |
| draper                       | >= 1.6            |
| factory_girl_rails           | >= 1.6            |
| formtastic                   | >= 1.6            |
| google-rails                 | >= 1.6            |
| gretel                       | >= 1.6            |
| haml-rails                   | >= 1.6            |
| html2haml                    | ~> 1.6.0          |
| inline_svg                   | ~> 1.6            |
| loofah                       | >= 1.5.9          |
| prawn_rails                  | >= 1.6            |
| rails                        | >= 1.6            |
| rails-controller-testing     | >= 1.6            |
| rails-dom-testing            | >= 1.6            |
| rails-html-sanitizer         | >= 1.5.9          |
| railties                     | >= 1.6            |
| responders                   | >= 1.6            |
| rspec-rails                  | >= 1.6            |
| sassc-rails                  | >= 1.6            |
| sprockets-rails              | >= 1.6            |
| xpath                        | ~> 1.3            |
+------------------------------|-------------------+
```
@jmmastey

Thanks Olivier! ❤️ ❤️ ❤️

A few small requests, and I'll bump the version and release.

def first_level_dependencies(target)
raise ArgumentError, "Unknown gem #{target}" unless @tree.has_key? target
@tree[target].dependencies
end
def transitive_dependencies(target)
def transitive_dependencies(target, requirement: false)

This comment has been minimized.

@jmmastey

jmmastey Mar 14, 2018

Owner

I think this parameter is unused. Am I missing it somewhere?

This comment has been minimized.

@olivierlacan

olivierlacan Mar 15, 2018

Contributor

True, it's a relic. I'll fix it.

say "+------------------------------|-------------------+"
say ""
end

This comment has been minimized.

@jmmastey

jmmastey Mar 14, 2018

Owner

Man I need to just use tableprint :) I think I built this thing without internet access, and manually outputting strings is 💩

This comment has been minimized.

@jmmastey

jmmastey Mar 14, 2018

Owner

(note: not asking you to change it, just haven't looked at that code lately)

This comment has been minimized.

@olivierlacan

olivierlacan Mar 15, 2018

Contributor

Hey it works with no dependencies ;-)

@@ -38,6 +38,20 @@ def show(target)
end
end
desc 'Versions TARGET', 'Prints the dependency tree for a single gem in your Gemfile'

This comment has been minimized.

@jmmastey

jmmastey Mar 14, 2018

Owner

Can you correct the case on Versions here, since the actual command uses lowercase?

olivierlacan added some commits Mar 14, 2018

Attempt to sort version requirements
This relies on the Gem::Requirement#to_list method which
turns the array of comparator and version number into a single
string which probably works just the same as to_s would.

Still this outputs a much easier to read list order by the version
requirements which matters more in this listing that the dependency
names:

bundle-stats for nokogiri

depended upon by (34):
+------------------------------|-------------------+
| Name                         | Required Version  |
+------------------------------|-------------------+
| capybara-screenshot          | >= 1.3.3          |
| capybara                     | >= 1.3.3          |
| loofah                       | >= 1.5.9          |
| rails-html-sanitizer         | >= 1.5.9          |
| coffee-rails                 | >= 1.6            |
| devise                       | >= 1.6            |
| devise-two-factor            | >= 1.6            |
| draper                       | >= 1.6            |
| factory_girl_rails           | >= 1.6            |
| formtastic                   | >= 1.6            |
| google-rails                 | >= 1.6            |
| gretel                       | >= 1.6            |
| haml-rails                   | >= 1.6            |
| actioncable                  | >= 1.6            |
| actionmailer                 | >= 1.6            |
| actionpack                   | >= 1.6            |
| actionview                   | >= 1.6            |
| railties                     | >= 1.6            |
| responders                   | >= 1.6            |
| rspec-rails                  | >= 1.6            |
| sassc-rails                  | >= 1.6            |
| sprockets-rails              | >= 1.6            |
| prawn_rails                  | >= 1.6            |
| rails                        | >= 1.6            |
| rails-controller-testing     | >= 1.6            |
| rails-dom-testing            | >= 1.6            |
| xpath                        | ~> 1.3            |
| inline_svg                   | ~> 1.6            |
| chromedriver-helper          | ~> 1.6            |
| approvals                    | ~> 1.6            |
| html2haml                    | ~> 1.6.0          |
+------------------------------|-------------------+
@olivierlacan

This comment has been minimized.

Contributor

olivierlacan commented Mar 15, 2018

@jmmastey Should be good to go now.

remove vestigial parameter
related to previous change

@jmmastey jmmastey merged commit 66afdc4 into jmmastey:master Mar 15, 2018

@jmmastey

This comment has been minimized.

Owner

jmmastey commented Mar 15, 2018

Thanks @olivierlacan! Will push this version momentarily.

say "bundle-stats for #{target}"
say ""
say "depended upon by (#{stats[:top_level_dependencies].count}):\n"
say "+------------------------------|-------------------+"

This comment has been minimized.

@gmcnaughton

gmcnaughton Mar 16, 2018

Contributor

Could probably skip printing the table if count == 0 (no dependencies) 😄

This comment has been minimized.

@jmmastey

jmmastey Mar 16, 2018

Owner

Good suggestion @gmcnaughton, I may take a minute to get to this, but I'll merge a PR if you get a chance to grab it first.

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