mattbrictson / bundleup

A friendlier CLI for Bundler’s `update` and `outdated` commands.
MIT License
193 stars 6 forks source link

Improve internal API to make bundleup easier to use in Ruby scripts #214

Closed inkstak closed 1 year ago

inkstak commented 1 year ago

I would like to integrate bundleup into an overall update script and perform actions accordingly to the gems that have been updated.

For example:

updates = Bundleup::CLI.new([]).run

if updates.any? && confirm?("Some gems have been updated, would you like to run tests ?")
  system "bundle exec rspec" 
end

if updates.include?("rubocop") && confirm?("Rubocop has been updated, would you like to run cops ?")
  system "bundle exec rubocop"
end

if updates.any? && confirm?("Would you like to commit changes?")
  system "git commit -m \"Update gems dependencies\" -- Gemfile.lock"
end

If you might consider these changes, I will try to add tests.

mattbrictson commented 1 year ago

Interesting idea! Let me think this over. I am not opposed to it, but it seems weird for CLI#run to return a value. A CLI, by nature, takes its inputs and provides its outputs via the command-line. So getting back an object from run doesn't feel right.

I would rather the updates be obtained by an explicit method, rather than a return value.

Something like this:

cli = Bundleup::Cli.new([])
cli.run
updates = cli.updated_gems

It's a small distinction. Would that work for you?

inkstak commented 1 year ago

I understand and by extension it could open the way to a pinned_gems method for those who need it.

mattbrictson commented 1 year ago

@inkstak great! If you could make that small refactor and add a test, I'll merge this in. I'm also happy to add a test later, if you get stuck on that part.

inkstak commented 1 year ago

Done ! Some tests added and passing. Feel free to refactor as you want ;)

mattbrictson commented 1 year ago

Nice! Tests look great. Much appreciated! 🙏