summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-07-20 22:27:57 +0000
committerBundlerbot <bot@bundler.io>2019-07-20 22:27:57 +0000
commita03b11b267503c03b1b009d141b1fed6d193a9e5 (patch)
treefb3db1b7222abaa08c999083a151bc0efde60823
parent3f57b102c76fea2f701152e087c88f53df17d3d0 (diff)
parent69497adf904ef8c231316aba73db1f7524b060e5 (diff)
downloadbundler-a03b11b267503c03b1b009d141b1fed6d193a9e5.tar.gz
Merge #7249
7249: Add `bundle package` functionality to `bundle cache` r=indirect a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that the previous plan provided no migration path from the current `bundle cache` to the future one (an alias to `bundle package`). ### What was your diagnosis of the problem? My diagnosis was that we should probably tell users first that in bundler 3, `bundle cache` will have a different implementation. However, after playing around with it a bit, I noticed that the additions to `bundle cache` provided by `bundle package` are fully backwards compatible. Or maybe I'm missing something but at least all `bundle cache` tests still pass when changing the implementation under the hood to use `bundle package`. As far as I can see, the only backwards incompatible change (start caching `git` and `path` gems by default) is already covered by the exisiting `cache_all` flag), so we should be good. ### What is your fix for the problem, implemented in this PR? My fix is to remove the current implementation of `bundle cache`, and replace it with the current implementation of `bundle package`. ### Why did you choose this fix out of the possible options? I chose this fix because it allows us to remove code and it reduces confusion about `bundle cache` vs `bundle package` making them work exactly the same. On a future PR, I plan to clean this up so that everything (docs, code, tests) use `bundle cache`, and `bundle package` is left only as an alias. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--lib/bundler/cli.rb29
-rw-r--r--lib/bundler/cli/cache.rb36
-rw-r--r--lib/bundler/cli/package.rb2
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--lib/bundler/settings.rb1
-rw-r--r--spec/other/cli_dispatch_spec.rb9
-rw-r--r--spec/quality_spec.rb1
7 files changed, 7 insertions, 72 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index dd733a22ed..c7af38bcaf 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -69,7 +69,7 @@ module Bundler
Bundler.ui.info "\n"
primary_commands = ["install", "update",
- Bundler.feature_flag.cache_command_is_package? ? "cache" : "package",
+ Bundler.feature_flag.bundler_3_mode? ? "cache" : "package",
"exec", "config", "help"]
list = self.class.printable_commands(true)
@@ -410,27 +410,10 @@ module Bundler
Outdated.new(options, gems).run
end
- if Bundler.feature_flag.cache_command_is_package?
- map %w[cache] => :package
- else
- desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true
- unless Bundler.feature_flag.cache_command_is_package?
- method_option "all", :type => :boolean,
- :banner => "Include all sources (including path and git)."
- end
- method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
- def cache
- require_relative "cli/cache"
- Cache.new(options).run
- end
- end
-
- desc "#{Bundler.feature_flag.cache_command_is_package? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
- unless Bundler.feature_flag.cache_command_is_package?
- method_option "all", :type => :boolean,
- :banner => "Include all sources (including path and git)."
- end
+ desc "#{Bundler.feature_flag.bundler_3_mode? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
+ method_option "all", :type => :boolean,
+ :default => Bundler.feature_flag.cache_all?,
+ :banner => "Include all sources (including path and git)."
method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
method_option "cache-path", :type => :string, :banner =>
"Specify a different cache path than the default (vendor/cache)."
@@ -452,7 +435,7 @@ module Bundler
require_relative "cli/package"
Package.new(options).run
end
- map %w[pack] => :package
+ map %w[cache pack] => :package
desc "exec [OPTIONS]", "Run the command in context of the bundle"
method_option :keep_file_descriptors, :type => :boolean, :default => false
diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb
deleted file mode 100644
index cb7958e5d0..0000000000
--- a/lib/bundler/cli/cache.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Cache
- attr_reader :options
- def initialize(options)
- @options = options
- end
-
- def run
- Bundler.definition.validate_runtime!
- Bundler.definition.resolve_with_cache!
- setup_cache_all
- Bundler.settings.set_command_option_if_given :cache_all_platforms, options["all-platforms"]
- Bundler.load.cache
- Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"]
- Bundler.load.lock
- rescue GemNotFound => e
- Bundler.ui.error(e.message)
- Bundler.ui.warn "Run `bundle install` to install missing gems."
- exit 1
- end
-
- private
-
- def setup_cache_all
- Bundler.settings.set_command_option_if_given :cache_all, options[:all]
-
- if Bundler.definition.has_local_dependencies? && !Bundler.feature_flag.cache_all?
- Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
- "to package them as well, please pass the --all flag. This will be the default " \
- "on Bundler 3.0."
- end
- end
- end
-end
diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb
index 3fa87ff265..731677b4ec 100644
--- a/lib/bundler/cli/package.rb
+++ b/lib/bundler/cli/package.rb
@@ -34,7 +34,7 @@ module Bundler
end
def setup_cache_all
- all = options.fetch(:all, Bundler.feature_flag.cache_command_is_package? || nil)
+ all = options.fetch(:all, Bundler.feature_flag.bundler_3_mode? || nil)
Bundler.settings.set_command_option_if_given :cache_all, all
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index a45694dd8e..5e1932e626 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -32,7 +32,6 @@ module Bundler
settings_flag(:auto_clean_without_path) { bundler_3_mode? }
settings_flag(:auto_config_jobs) { bundler_3_mode? }
settings_flag(:cache_all) { bundler_3_mode? }
- settings_flag(:cache_command_is_package) { bundler_3_mode? }
settings_flag(:default_install_uses_path) { bundler_3_mode? }
settings_flag(:deployment_means_frozen) { bundler_3_mode? }
settings_flag(:disable_multisource) { bundler_3_mode? }
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 50cd04aef1..166e494f0e 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -17,7 +17,6 @@ module Bundler
auto_config_jobs
cache_all
cache_all_platforms
- cache_command_is_package
default_install_uses_path
deployment
deployment_means_frozen
diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb
index 548539ac89..0082606d7e 100644
--- a/spec/other/cli_dispatch_spec.rb
+++ b/spec/other/cli_dispatch_spec.rb
@@ -17,13 +17,4 @@ RSpec.describe "bundle command names" do
bundle "in"
expect(err).to eq("Ambiguous command in matches [info, init, inject, install]")
end
-
- context "when cache_command_is_package is set" do
- before { bundle! "config set cache_command_is_package true" }
-
- it "dispatches `bundle cache` to the package command" do
- bundle "cache --verbose"
- expect(out).to start_with "Running `bundle package --verbose`"
- end
- end
end
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index b8f2d6ed1b..e9a49ba09e 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -168,7 +168,6 @@ RSpec.describe "The library itself" do
it "documents all used settings" do
exemptions = %w[
auto_config_jobs
- cache_command_is_package
deployment_means_frozen
forget_cli_options
gem.coc