Conversation
d4b7f20 to
4831906
Compare
|
Can you change the target branch of this to |
|
|
668acd3 to
831214f
Compare
|
@segiddins Now this is reviewable 😄 |
lib/bundler/cli/change.rb
Outdated
| require "bundler/cli/add" | ||
| CLI::Add.new(@pass_options, [@gem_name]).run | ||
| rescue StandardError => e | ||
| Bundler.ui.error e |
There was a problem hiding this comment.
should the error be re-raised instead, after restoring the initial gemfile?
There was a problem hiding this comment.
It is shown as error do we need to raise an exception?
There was a problem hiding this comment.
yes, we should let the FriendlyErrors module handle showing the error to the user, and ensure we exit with the proper exit code
lib/bundler/cli/change.rb
Outdated
|
|
||
| private | ||
|
|
||
| def set_version_options |
There was a problem hiding this comment.
can you add a comment explaining what this method is trying to do ?
lib/bundler/shared_helpers.rb
Outdated
|
|
||
| # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies. | ||
| # @param [String] contents Content to written to Gemfile. | ||
| def write_to_gemfile(gemfile_path, contents) |
There was a problem hiding this comment.
this should probably just be write_file
spec/commands/change_spec.rb
Outdated
| it "throws error" do | ||
| bundle "change rack" | ||
|
|
||
| expect(out).to include("Please supply atleast one option to change.") |
lib/bundler/cli/change.rb
Outdated
|
|
||
| set_version_options | ||
|
|
||
| @pass_options["source"] = @options[:source] if @options[:source] |
There was a problem hiding this comment.
should this also handle path/git ?
There was a problem hiding this comment.
Should they be editable? We would have to do something to persist them 🤔 as add does not take these flags
There was a problem hiding this comment.
Also @segiddins , these are valid keys we also need to persist them! I think we may have to change our approach? Maybe we can use this?
There was a problem hiding this comment.
yeah we definitely need to persist all keys
a612020 to
d6faf03
Compare
| "Adds gem to the Gemfile but does not install it" | ||
| method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem" | ||
| method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem" | ||
| method_option "pessimistic", :type => :boolean, :banner => "Adds pessimistic declaration of version to gem" |
There was a problem hiding this comment.
this option needs to be tested
lib/bundler/cli.rb
Outdated
| Provide flexibilty of editing gemfile from command line by providing option to change gem properties. | ||
| D | ||
| method_option "version", :aliases => "-v", :type => :string | ||
| method_option "group", :aliases => "-g", :type => :string |
There was a problem hiding this comment.
let's not add this aliases for now
lib/bundler/cli/change.rb
Outdated
| CLI::Add.new(@pass_options, [@gem_name]).run | ||
| rescue StandardError => e | ||
| SharedHelpers.write_file(Bundler.default_gemfile, initial_gemfile) | ||
| FriendlyErrors.log_error(e) |
There was a problem hiding this comment.
I think instead of this, we should just raise
There was a problem hiding this comment.
After rescue then again we should raise error?
There was a problem hiding this comment.
yes -- the rescue here is only to restore the initial gemfile
lib/bundler/cli/change.rb
Outdated
|
|
||
| raise InvalidOption, "`#{@gem_name}` could not be found in the Gemfile." unless @dep | ||
|
|
||
| @pass_options = {} |
There was a problem hiding this comment.
maybe call this add_options, and instead of making it an ivar, pass it into set_group_options / set_version_options
lib/bundler/cli/change.rb
Outdated
|
|
||
| definition = Bundler.definition | ||
|
|
||
| @dep = definition.dependencies.find {|d| d.name == @gem_name } |
There was a problem hiding this comment.
same as below, shouldn't be an ivar
| ## DESCRIPTION | ||
| Provide flexibilty of editing gemfile from command line by providing option to change gem properties. | ||
|
|
||
| Example: |
There was a problem hiding this comment.
this example should show the before & after gemfiles
spec/commands/change_spec.rb
Outdated
| gem "rspec" | ||
| end | ||
|
|
||
| gem "rack", "~> 1.0", :group => [:dev1] |
There was a problem hiding this comment.
this should either be :group => :dev1 or :groups => [:dev1]
There was a problem hiding this comment.
We will have to change the injector https://github.com/bundler/bundler/blob/master/spec/commands/add_spec.rb#L72
| source "file://#{gem_repo1}" | ||
|
|
||
| gem "rack", "~> 1.0", :group => [:dev] | ||
| gem "weakling", ">= 0.0.1" |
There was a problem hiding this comment.
please add a test that changes both of these 2 gems into the test group
spec/commands/change_spec.rb
Outdated
| it "changes version of the gem" do | ||
| bundle! "change rack --version 0.9.1" | ||
|
|
||
| expect(bundled_app("Gemfile").read).to include("gem \"rack\", \"~> 0.9.1\", :group => [:dev]") |
There was a problem hiding this comment.
use single quotes to avoid having to escape the double quotes
| it "throws error" do | ||
| bundle "change rake --group dev1" | ||
|
|
||
| expect(out).to include("`rake` could not be found in the Gemfile.") |
There was a problem hiding this comment.
please test that failure does not change the gemfile
expect { bundle ... }.not_to change { gemfile }There was a problem hiding this comment.
No operation is done on gemfile until this.
There was a problem hiding this comment.
right but we should test that that's the case :)
dcc43e9 to
ec7d142
Compare
|
This looks like a great 1st implementation of the @colby-swandale @deivid-rodriguez review would be appreciated 🙏 |
|
|
||
| raise InvalidOption, "`#{@gem_name}` could not be found in the Gemfile." unless dep | ||
|
|
||
| check_for_unsupported_options(dep) |
There was a problem hiding this comment.
I am in process of writing test for this function. Still to figure out how to skip before hook for one test.
5c38781 to
4660a3e
Compare
4660a3e to
f3a30c5
Compare
f3a30c5 to
8eaa22f
Compare
Fix for unique groups and specs for mutiple groups
|
@segiddins @colby-swandale The milestone seems to be have passed 😅 |
|
Is it just me, but I don't see any benefits of adding and using this? It is much easier to make changes directly in Gemfile and run |
Currently, this command uses
removeandaddinternally (reason for so many commits, though only last five, are related to this command).Closes #6581