diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-03-15 20:05:13 +0100 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-03-15 20:10:25 +0100 |
commit | 4d2fc80329aa8de95399999a1cf4e90b6beb8c25 (patch) | |
tree | 1a6b25584578873828287444eab1b23e21dc3c11 | |
parent | 1971ba4059f1855d6a4b240c3ea85ec5b1130ea6 (diff) | |
download | bundler-4d2fc80329aa8de95399999a1cf4e90b6beb8c25.tar.gz |
Add actionable suggestions to config deprecationmove_bundle_config_deprecation_to_bundler_2
-rw-r--r-- | lib/bundler/cli/config.rb | 14 | ||||
-rw-r--r-- | spec/other/major_deprecation_spec.rb | 112 |
2 files changed, 119 insertions, 7 deletions
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index f412e80829..1df2a55d9a 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -14,8 +14,20 @@ module Bundler scope_options method_option :delete, :type => :boolean, :banner => "delete" def base(name = nil, *value) + new_args = + if ARGV.size == 1 + ["config", "list"] + elsif ARGV.include?("--delete") + ARGV.map {|arg| arg == "--delete" ? "unset" : arg } + elsif ARGV.include?("--global") || ARGV.include?("--local") || ARGV.size == 3 + ["config", "set", *ARGV[1..-1]] + else + ["config", "get", ARGV[1]] + end + SharedHelpers.major_deprecation 2, - "Using the `config` command without a subcommand [list, get, set, unset]" + "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead." + Base.new(options, name, value, self).run end diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index e330f6bb38..9bd5fd1b2e 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -53,16 +53,116 @@ RSpec.describe "major deprecations" do end describe "bundle config" do - before do - bundle! "config" + describe "old list interface" do + before do + bundle! "config" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.") + end end - it "does not warn when no options are given", :bundler => "< 2" do - expect(deprecations).to be_empty + describe "old get interface" do + before do + bundle! "config waka" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.") + end end - it "warns when no options are given", :bundler => "2" do - expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset]") + describe "old set interface" do + before do + bundle! "config waka wakapun" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.") + end + end + + describe "old set interface with --local" do + before do + bundle! "config --local waka wakapun" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.") + end + end + + describe "old set interface with --global" do + before do + bundle! "config --global waka wakapun" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.") + end + end + + describe "old unset interface" do + before do + bundle! "config --delete waka" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.") + end + end + + describe "old unset interface with --local" do + before do + bundle! "config --delete --local waka" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.") + end + end + + describe "old unset interface with --global" do + before do + bundle! "config --delete --global waka" + end + + it "does not warn", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.") + end end end |