diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/console.rb | 3 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 5 | ||||
-rw-r--r-- | lib/bundler/deployment.rb | 6 | ||||
-rw-r--r-- | lib/bundler/dsl.rb | 36 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 22 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 8 | ||||
-rw-r--r-- | lib/bundler/source_list.rb | 15 | ||||
-rw-r--r-- | lib/bundler/ui/shell.rb | 8 | ||||
-rw-r--r-- | lib/bundler/ui/silent.rb | 3 |
10 files changed, 99 insertions, 11 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index d6afd275..ed81ffbf 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -31,6 +31,7 @@ module Bundler raise InvalidOption, e.message ensure self.options ||= {} + Bundler.settings.cli_flags_given = !options.empty? Bundler.ui = UI::Shell.new(options) Bundler.ui.level = "debug" if options["verbose"] @@ -231,9 +232,11 @@ module Bundler method_option "outdated", :type => :boolean, :banner => "Show verbose output including whether gems are outdated." def show(gem_name = nil) + Bundler::SharedHelpers.major_deprecation("use `bundle show` instead of `bundle list`") if ARGV[0] == "list" require "bundler/cli/show" Show.new(options, gem_name).run end + # TODO: 2.0 remove `bundle list` map %w(list) => "show" desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem" @@ -348,6 +351,7 @@ module Bundler desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded" def console(group = nil) + # TODO: Remove for 2.0 require "bundler/cli/console" Console.new(options, group).run end diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb index 5e72cdbf..715abf25 100644 --- a/lib/bundler/cli/console.rb +++ b/lib/bundler/cli/console.rb @@ -8,6 +8,9 @@ module Bundler end def run + Bundler::SharedHelpers.major_deprecation "bundle console will be replaced " \ + "by `bin/console` generated by `bundle gem <name>`" + group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require ARGV.clear diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 07950c90..2dee4a5a 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -55,6 +55,11 @@ module Bundler Bundler::Fetcher.disable_endpoint = options["full-index"] + if options["binstubs"] + Bundler::SharedHelpers.major_deprecation \ + "the --binstubs option will be removed in favor of `bundle binstubs`" + end + # rubygems plugins sometimes hook into the gem install process Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb index 23968e70..94f2fac6 100644 --- a/lib/bundler/deployment.rb +++ b/lib/bundler/deployment.rb @@ -1,4 +1,10 @@ # frozen_string_literal: true + +require "bundler/shared_helpers" +Bundler::SharedHelpers.major_deprecation "Bundler no longer integrates with " \ + "Capistrano, but Capistrano provides its own integration with " \ + "Bundler via the capistrano-bundler gem. Use it instead." + module Bundler class Deployment def self.define_task(context, task_method = :task, opts = {}) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 04ef641b..0436b58f 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -265,13 +265,25 @@ module Bundler # "https://github.com/#{repo_name}.git" # end repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") - "git://github.com/#{repo_name}.git" + # TODO: 2.0 upgrade this setting to the default + if Bundler.settings["github.https"] + "https://github.com/#{repo_name}.git" + else + warn_github_source_change(repo_name) + "git://github.com/#{repo_name}.git" + end end - git_source(:gist) {|repo_name| "https://gist.github.com/#{repo_name}.git" } + # TODO: 2.0 remove this deprecated git source + git_source(:gist) do |repo_name| + warn_deprecated_git_source(:gist, 'https://gist.github.com/#{repo_name}.git') + "https://gist.github.com/#{repo_name}.git" + end + # TODO: 2.0 remove this deprecated git source git_source(:bitbucket) do |repo_name| user_name, repo_name = repo_name.split "/" + warn_deprecated_git_source(:bitbucket, 'https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git') repo_name ||= user_name "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git" end @@ -403,13 +415,14 @@ module Bundler def check_primary_source_safety(source) return unless source.rubygems_primary_remotes.any? + # TODO: 2.0 upgrade from setting to default if Bundler.settings[:disable_multisource] raise GemspecError, "Warning: this Gemfile contains multiple primary sources. " \ "Each source after the first must include a block to indicate which gems " \ "should come from that source. To downgrade this error to a warning, run " \ "`bundle config --delete disable_multisource`" else - Bundler.ui.warn "Warning: this Gemfile contains multiple primary sources. " \ + Bundler::SharedHelpers.major_deprecation "Your Gemfile contains multiple primary sources. " \ "Using `source` more than once without a block is a security risk, and " \ "may result in installing unexpected gems. To resolve this warning, use " \ "a block to indicate which gems should come from the secondary source. " \ @@ -418,6 +431,23 @@ module Bundler end end + def warn_github_source_change(repo_name) + # TODO: 2.0 remove deprecation + Bundler::SharedHelpers.major_deprecation "The :github option uses the git: protocol, which is not secure. " \ + "Bundler 2.0 will use the https: protocol, which is secure. Enable this change now by " \ + "running `bundle config github.https true`." + end + + def warn_deprecated_git_source(name, repo_string) + # TODO: 2.0 remove deprecation + Bundler::SharedHelpers.major_deprecation <<-EOS +The :#{name} git source is deprecated, and will be removed in Bundler 2.0. Add this code to your Gemfile to ensure it continues to work: + git_source(:#{name}) do |repo_name| + "#{repo_string}" + end + EOS + end + class DSLError < GemfileError # @return [String] the description that should be presented to the user. # diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 46333c89..ff0b1460 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -31,10 +31,13 @@ module Bundler :timeout => 10, }.freeze + attr_accessor :cli_flags_given + def initialize(root = nil) - @root = root - @local_config = load_config(local_config_file) - @global_config = load_config(global_config_file) + @root = root + @local_config = load_config(local_config_file) + @global_config = load_config(global_config_file) + @cli_flags_given = false end def [](name) @@ -54,6 +57,19 @@ module Bundler end def []=(key, value) + if cli_flags_given + command = if value.nil? + "bundle config --delete #{key}" + else + "bundle config #{key} #{Array(value).join(":")}" + end + + Bundler::SharedHelpers.major_deprecation \ + "flags passed to commands " \ + "will no longer be automatically remembered. Instead please set flags " \ + "you want remembered between commands using `bundle config " \ + "<setting name> <setting value>`, i.e. `#{command}`" + end local_config_file || raise(GemfileNotFound, "Could not locate Gemfile") set_key(key, value, @local_config, local_config_file) end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index df0fffba..efbedeb3 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -128,6 +128,7 @@ module Bundler end def print_major_deprecations! + deprecate_gemfile(find_gemfile) if find_gemfile == find_file("Gemfile") if RUBY_VERSION < "2" major_deprecation("Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}") end @@ -140,7 +141,6 @@ module Bundler def find_gemfile given = ENV["BUNDLE_GEMFILE"] return given if given && !given.empty? - find_file("Gemfile", "gems.rb") end @@ -230,6 +230,12 @@ module Bundler true end + def deprecate_gemfile(gemfile) + return unless gemfile && File.basename(gemfile) == "Gemfile" + Bundler::SharedHelpers.major_deprecation \ + "gems.rb and gems.locked will be prefered to Gemfile and Gemfile.lock." + end + extend self end end diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb index fdc77cb2..b6ce6029 100644 --- a/lib/bundler/source_list.rb +++ b/lib/bundler/source_list.rb @@ -22,7 +22,9 @@ module Bundler end def add_git_source(options = {}) - add_source_to_list Source::Git.new(options), git_sources + add_source_to_list(Source::Git.new(options), git_sources).tap do |source| + warn_on_git_protocol(source) + end end def add_rubygems_source(options = {}) @@ -109,5 +111,16 @@ module Bundler def combine_rubygems_sources Source::Rubygems.new("remotes" => rubygems_remotes) end + + def warn_on_git_protocol(source) + return if Bundler.settings["git.allow_insecure"] + + if source.uri =~ /^git\:/ + Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \ + "which transmits data without encryption. Disable this warning with " \ + "`bundle config git.allow_insecure true`, or switch to the `https` " \ + "protocol to keep your data secure." + end + end end end diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index df41d727..195bd56a 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -95,6 +95,14 @@ module Bundler end end + def tell_err(message, color = nil, newline = nil) + buffer = @shell.send(:prepare_message, message, *color) + buffer << "\n" if newline && !message.to_s.end_with?("\n") + + @shell.send(:stderr).print(buffer) + @shell.send(:stderr).flush + end + def strip_leading_spaces(text) spaces = text[/\A\s+/, 0] spaces ? text.gsub(/#{spaces}/, "") : text diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb index 19ff7311..367eaa58 100644 --- a/lib/bundler/ui/silent.rb +++ b/lib/bundler/ui/silent.rb @@ -41,9 +41,6 @@ module Bundler def trace(message, newline = nil) end - def major_deprecation(message) - end - def silence yield end |