bundler 2.1.0 → 2.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +832 -738
  3. data/README.md +6 -8
  4. data/bundler.gemspec +3 -3
  5. data/exe/bundle +3 -0
  6. data/lib/bundler.rb +15 -4
  7. data/lib/bundler/build_metadata.rb +2 -2
  8. data/lib/bundler/cli.rb +32 -11
  9. data/lib/bundler/cli/console.rb +1 -1
  10. data/lib/bundler/cli/exec.rb +3 -12
  11. data/lib/bundler/cli/gem.rb +83 -10
  12. data/lib/bundler/cli/info.rb +13 -3
  13. data/lib/bundler/cli/init.rb +1 -1
  14. data/lib/bundler/cli/install.rb +8 -16
  15. data/lib/bundler/cli/issue.rb +2 -2
  16. data/lib/bundler/cli/list.rb +11 -9
  17. data/lib/bundler/cli/outdated.rb +88 -65
  18. data/lib/bundler/cli/plugin.rb +10 -0
  19. data/lib/bundler/cli/pristine.rb +5 -0
  20. data/lib/bundler/definition.rb +32 -32
  21. data/lib/bundler/dependency.rb +0 -9
  22. data/lib/bundler/dsl.rb +1 -5
  23. data/lib/bundler/environment_preserver.rb +26 -2
  24. data/lib/bundler/errors.rb +1 -0
  25. data/lib/bundler/feature_flag.rb +0 -2
  26. data/lib/bundler/fetcher.rb +1 -0
  27. data/lib/bundler/friendly_errors.rb +4 -10
  28. data/lib/bundler/gem_helper.rb +18 -12
  29. data/lib/bundler/gem_version_promoter.rb +1 -1
  30. data/lib/bundler/injector.rb +14 -3
  31. data/lib/bundler/inline.rb +2 -2
  32. data/lib/bundler/installer.rb +29 -28
  33. data/lib/bundler/installer/gem_installer.rb +2 -2
  34. data/lib/bundler/installer/parallel_installer.rb +9 -9
  35. data/lib/bundler/lazy_specification.rb +16 -3
  36. data/lib/bundler/plugin.rb +26 -0
  37. data/lib/bundler/plugin/index.rb +9 -0
  38. data/lib/bundler/psyched_yaml.rb +0 -15
  39. data/lib/bundler/remote_specification.rb +4 -1
  40. data/lib/bundler/resolver.rb +31 -8
  41. data/lib/bundler/resolver/spec_group.rb +26 -5
  42. data/lib/bundler/rubygems_ext.rb +7 -8
  43. data/lib/bundler/rubygems_gem_installer.rb +1 -7
  44. data/lib/bundler/rubygems_integration.rb +13 -48
  45. data/lib/bundler/runtime.rb +2 -12
  46. data/lib/bundler/settings.rb +0 -3
  47. data/lib/bundler/setup.rb +5 -0
  48. data/lib/bundler/shared_helpers.rb +1 -1
  49. data/lib/bundler/source/git.rb +4 -4
  50. data/lib/bundler/source/git/git_proxy.rb +53 -58
  51. data/lib/bundler/source/path.rb +5 -1
  52. data/lib/bundler/source/path/installer.rb +7 -9
  53. data/lib/bundler/source/rubygems.rb +11 -14
  54. data/lib/bundler/stub_specification.rb +16 -4
  55. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  56. data/lib/bundler/templates/newgem/Gemfile.tt +9 -1
  57. data/lib/bundler/templates/newgem/Rakefile.tt +19 -5
  58. data/lib/bundler/templates/newgem/bin/console.tt +2 -0
  59. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  60. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  61. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +18 -0
  62. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  63. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +2 -0
  64. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  65. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -4
  66. data/lib/bundler/templates/newgem/rubocop.yml.tt +10 -0
  67. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  68. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  69. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  70. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  71. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  72. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  73. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +72 -208
  74. data/lib/bundler/vendor/thor/lib/thor.rb +0 -7
  75. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  76. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  77. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  78. data/lib/bundler/version.rb +1 -1
  79. data/man/bundle-add.1 +1 -1
  80. data/man/bundle-add.1.txt +15 -15
  81. data/man/bundle-binstubs.1 +1 -1
  82. data/man/bundle-binstubs.1.txt +10 -10
  83. data/man/bundle-cache.1 +1 -1
  84. data/man/bundle-cache.1.txt +15 -15
  85. data/man/bundle-check.1 +1 -1
  86. data/man/bundle-check.1.txt +8 -8
  87. data/man/bundle-clean.1 +1 -1
  88. data/man/bundle-clean.1.txt +6 -6
  89. data/man/bundle-config.1 +3 -9
  90. data/man/bundle-config.1.txt +271 -272
  91. data/man/bundle-config.ronn +5 -9
  92. data/man/bundle-doctor.1 +1 -1
  93. data/man/bundle-doctor.1.txt +9 -9
  94. data/man/bundle-exec.1 +1 -1
  95. data/man/bundle-exec.1.txt +84 -81
  96. data/man/bundle-gem.1 +25 -3
  97. data/man/bundle-gem.1.txt +65 -39
  98. data/man/bundle-gem.ronn +30 -7
  99. data/man/bundle-info.1 +1 -1
  100. data/man/bundle-info.1.txt +2 -2
  101. data/man/bundle-init.1 +1 -1
  102. data/man/bundle-init.1.txt +9 -9
  103. data/man/bundle-inject.1 +1 -1
  104. data/man/bundle-inject.1.txt +4 -4
  105. data/man/bundle-install.1 +1 -1
  106. data/man/bundle-install.1.txt +169 -169
  107. data/man/bundle-list.1 +7 -7
  108. data/man/bundle-list.1.txt +12 -11
  109. data/man/bundle-list.ronn +6 -6
  110. data/man/bundle-lock.1 +1 -1
  111. data/man/bundle-lock.1.txt +28 -28
  112. data/man/bundle-open.1 +1 -1
  113. data/man/bundle-open.1.txt +3 -3
  114. data/man/bundle-outdated.1 +1 -1
  115. data/man/bundle-outdated.1.txt +34 -34
  116. data/man/bundle-platform.1 +1 -1
  117. data/man/bundle-platform.1.txt +16 -16
  118. data/man/bundle-pristine.1 +1 -1
  119. data/man/bundle-pristine.1.txt +8 -8
  120. data/man/bundle-remove.1 +1 -1
  121. data/man/bundle-remove.1.txt +9 -9
  122. data/man/bundle-show.1 +1 -1
  123. data/man/bundle-show.1.txt +8 -8
  124. data/man/bundle-update.1 +1 -1
  125. data/man/bundle-update.1.txt +149 -148
  126. data/man/bundle-viz.1 +1 -1
  127. data/man/bundle-viz.1.txt +11 -11
  128. data/man/bundle.1 +1 -1
  129. data/man/bundle.1.txt +31 -31
  130. data/man/gemfile.5 +1 -1
  131. data/man/gemfile.5.txt +218 -216
  132. metadata +14 -8
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
- [![Version ](https://img.shields.io/gem/v/bundler.svg?style=flat)](https://rubygems.org/gems/bundler)
2
- [![Build Status](https://img.shields.io/travis/bundler/bundler/master.svg?style=flat)](https://travis-ci.org/bundler/bundler)
3
- [![Inline docs ](https://inch-ci.org/github/bundler/bundler.svg?style=flat)](https://inch-ci.org/github/bundler/bundler)
4
- [![Slack ](https://bundler-slackin.herokuapp.com/badge.svg)](https://bundler-slackin.herokuapp.com)
1
+ [![Version ](https://img.shields.io/gem/v/bundler.svg?style=flat)](https://rubygems.org/gems/bundler)
2
+ [![Slack ](https://bundler-slackin.herokuapp.com/badge.svg)](https://bundler-slackin.herokuapp.com)
5
3
 
6
4
  # Bundler: a gem to bundle gems
7
5
 
@@ -44,9 +42,9 @@ To get in touch with the Bundler core team and other Bundler users, please see [
44
42
 
45
43
  ### Contributing
46
44
 
47
- If you'd like to contribute to Bundler, that's awesome, and we <3 you. We've put together [the Bundler contributor guide](https://github.com/bundler/bundler/blob/master/doc/contributing/README.md) with all of the information you need to get started.
45
+ If you'd like to contribute to Bundler, that's awesome, and we <3 you. We've put together [the Bundler contributor guide](https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/README.md) with all of the information you need to get started.
48
46
 
49
- If you'd like to request a substantial change to Bundler or to the Bundler documentation, refer to the [Bundler RFC process](https://github.com/bundler/rfcs) for more information.
47
+ If you'd like to request a substantial change to Bundler or its documentation, refer to the [Bundler RFC process](https://github.com/bundler/rfcs) for more information.
50
48
 
51
49
  While some Bundler contributors are compensated by Ruby Together, the project maintainers make decisions independent of Ruby Together. As a project, we welcome contributions regardless of the author's affiliation with Ruby Together.
52
50
 
@@ -57,8 +55,8 @@ While some Bundler contributors are compensated by Ruby Together, the project ma
57
55
 
58
56
  ### Code of Conduct
59
57
 
60
- Everyone interacting in the Bundler project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Bundler code of conduct](https://github.com/bundler/bundler/blob/master/CODE_OF_CONDUCT.md).
58
+ Everyone interacting in the Bundler project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Bundler code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
61
59
 
62
60
  ### License
63
61
 
64
- Bundler is available under an [MIT License](https://github.com/bundler/bundler/blob/master/LICENSE.md).
62
+ Bundler is available under an [MIT License](https://github.com/rubygems/rubygems/blob/master/bundler/LICENSE.md).
@@ -24,10 +24,10 @@ Gem::Specification.new do |s|
24
24
 
25
25
  if s.respond_to?(:metadata=)
26
26
  s.metadata = {
27
- "bug_tracker_uri" => "https://github.com/bundler/bundler/issues",
28
- "changelog_uri" => "https://github.com/bundler/bundler/blob/master/CHANGELOG.md",
27
+ "bug_tracker_uri" => "https://github.com/rubygems/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
28
+ "changelog_uri" => "https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md",
29
29
  "homepage_uri" => "https://bundler.io/",
30
- "source_code_uri" => "https://github.com/bundler/bundler/",
30
+ "source_code_uri" => "https://github.com/rubygems/rubygems/",
31
31
  }
32
32
  end
33
33
 
data/exe/bundle CHANGED
@@ -15,6 +15,9 @@ else
15
15
  require "bundler"
16
16
  end
17
17
 
18
+ # Workaround for non-activated bundler spec due to missing https://github.com/rubygems/rubygems/commit/4e306d7bcdee924b8d80ca9db6125aa59ee4e5a3
19
+ gem "bundler", Bundler::VERSION if Gem.rubygems_version < Gem::Version.new("2.6.2")
20
+
18
21
  # Check if an older version of bundler is installed
19
22
  $LOAD_PATH.each do |path|
20
23
  next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
@@ -34,9 +34,9 @@ require_relative "bundler/build_metadata"
34
34
  # of loaded and required modules.
35
35
  #
36
36
  module Bundler
37
- environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
37
+ environment_preserver = EnvironmentPreserver.from_env
38
38
  ORIGINAL_ENV = environment_preserver.restore
39
- ENV.replace(environment_preserver.backup)
39
+ environment_preserver.replace_with_backup
40
40
  SUDO_MUTEX = Mutex.new
41
41
 
42
42
  autoload :Definition, File.expand_path("bundler/definition", __dir__)
@@ -285,7 +285,13 @@ module Bundler
285
285
 
286
286
  def app_config_path
287
287
  if app_config = ENV["BUNDLE_APP_CONFIG"]
288
- Pathname.new(app_config).expand_path(root)
288
+ app_config_pathname = Pathname.new(app_config)
289
+
290
+ if app_config_pathname.absolute?
291
+ app_config_pathname
292
+ else
293
+ app_config_pathname.expand_path(root)
294
+ end
289
295
  else
290
296
  root.join(".bundle")
291
297
  end
@@ -451,6 +457,10 @@ EOF
451
457
  Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
452
458
  end
453
459
 
460
+ def preferred_gemfile_name
461
+ Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
462
+ end
463
+
454
464
  def use_system_gems?
455
465
  configured_bundle_path.use_system_gems?
456
466
  end
@@ -512,7 +522,8 @@ EOF
512
522
  Your user account isn't allowed to install to the system RubyGems.
513
523
  You can cancel this installation and run:
514
524
 
515
- bundle install --path vendor/bundle
525
+ bundle config set --local path 'vendor/bundle'
526
+ bundle install
516
527
 
517
528
  to install the gems into ./vendor/bundle/, or you can enter your password
518
529
  and install the bundled gems to RubyGems using sudo.
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2019-12-15".freeze
8
- @git_commit_sha = "683fe9799e".freeze
7
+ @built_at = "2020-07-02".freeze
8
+ @git_commit_sha = "d15da3db73".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -122,16 +122,19 @@ module Bundler
122
122
  else command = "bundle-#{cli}"
123
123
  end
124
124
 
125
- man_path = File.expand_path("../../../man", __FILE__)
126
- man_pages = Hash[Dir.glob(File.join(man_path, "*")).grep(/.*\.\d*\Z/).collect do |f|
125
+ man_path = File.expand_path("../../../man", __FILE__)
126
+ # man files are located under ruby's mandir with the default gems of bundler
127
+ man_path = RbConfig::CONFIG["mandir"] unless File.directory?(man_path)
128
+ man_pages = Hash[Dir.glob(File.join(man_path, "**", "*")).grep(/.*\.\d*\Z/).collect do |f|
127
129
  [File.basename(f, ".*"), f]
128
130
  end]
129
131
 
130
132
  if man_pages.include?(command)
133
+ man_page = man_pages[command]
131
134
  if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
132
- Kernel.exec "man #{man_pages[command]}"
135
+ Kernel.exec "man #{man_page}"
133
136
  else
134
- puts File.read("#{man_path}/#{File.basename(man_pages[command])}.txt")
137
+ puts File.read("#{File.dirname(man_page)}/#{File.basename(man_page)}.txt")
135
138
  end
136
139
  elsif command_path = Bundler.which("bundler-#{cli}")
137
140
  Kernel.exec(command_path, "--help")
@@ -247,10 +250,12 @@ module Bundler
247
250
  def install
248
251
  SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
249
252
 
250
- %w[clean deployment frozen no-cache no-prune path shebang system without with].each do |option|
253
+ %w[clean deployment frozen no-prune path shebang system without with].each do |option|
251
254
  remembered_flag_deprecation(option)
252
255
  end
253
256
 
257
+ remembered_negative_flag_deprecation("no-deployment")
258
+
254
259
  require_relative "cli/install"
255
260
  Bundler.settings.temporary(:no_install => false) do
256
261
  Install.new(options.dup).run
@@ -342,8 +347,8 @@ module Bundler
342
347
 
343
348
  desc "list", "List all gems in the bundle"
344
349
  method_option "name-only", :type => :boolean, :banner => "print only the gem names"
345
- method_option "only-group", :type => :string, :banner => "print gems from a particular group"
346
- method_option "without-group", :type => :string, :banner => "print all gems except from a group"
350
+ method_option "only-group", :type => :array, :default => [], :banner => "print gems from a given set of groups"
351
+ method_option "without-group", :type => :array, :default => [], :banner => "print all gems except from a given set of groups"
347
352
  method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
348
353
  def list
349
354
  require_relative "cli/list"
@@ -567,8 +572,12 @@ module Bundler
567
572
  method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
568
573
  method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
569
574
  method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set gem.mit true`."
570
- method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec",
571
- :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config set gem.test rspec`."
575
+ method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set gem.rubocop true`."
576
+ method_option :test, :type => :string, :lazy_default => Bundler.settings["gem.test"] || "", :aliases => "-t", :banner => "Use the specified test framework for your library",
577
+ :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set gem.test (rspec|minitest|test-unit)`."
578
+ method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
579
+ :desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set gem.ci (github|travis|gitlab|circle)`"
580
+
572
581
  def gem(name)
573
582
  end
574
583
 
@@ -808,11 +817,23 @@ module Bundler
808
817
  nil
809
818
  end
810
819
 
820
+ def remembered_negative_flag_deprecation(name)
821
+ positive_name = name.gsub(/\Ano-/, "")
822
+ option = current_command.options[positive_name]
823
+ flag_name = "--no-" + option.switch_name.gsub(/\A--/, "")
824
+
825
+ flag_deprecation(positive_name, flag_name, option)
826
+ end
827
+
811
828
  def remembered_flag_deprecation(name)
812
829
  option = current_command.options[name]
813
830
  flag_name = option.switch_name
814
831
 
815
- name_index = ARGV.find {|arg| flag_name == arg }
832
+ flag_deprecation(name, flag_name, option)
833
+ end
834
+
835
+ def flag_deprecation(name, flag_name, option)
836
+ name_index = ARGV.find {|arg| flag_name == arg.split("=")[0] }
816
837
  return unless name_index
817
838
 
818
839
  value = options[name]
@@ -821,7 +842,7 @@ module Bundler
821
842
  Bundler::SharedHelpers.major_deprecation 2,\
822
843
  "The `#{flag_name}` flag is deprecated because it relies on being " \
823
844
  "remembered across bundler invocations, which bundler will no longer " \
824
- "do in future versions. Instead please use `bundle config set #{name} " \
845
+ "do in future versions. Instead please use `bundle config set #{name.tr("-", "_")} " \
825
846
  "'#{value}'`, and stop using this flag"
826
847
  end
827
848
  end
@@ -12,7 +12,7 @@ module Bundler
12
12
  Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
13
13
  "by `bin/console` generated by `bundle gem <name>`"
14
14
 
15
- group ? Bundler.require(:default, *group.split.map!(&:to_sym)) : Bundler.require
15
+ group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
16
16
  ARGV.clear
17
17
 
18
18
  console = get_console(Bundler.settings[:console] || "irb")
@@ -25,12 +25,12 @@ module Bundler
25
25
  SharedHelpers.set_bundle_environment
26
26
  if bin_path = Bundler.which(cmd)
27
27
  if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path)
28
- return with_verbose_rubygems { kernel_load(bin_path, *args) }
28
+ return kernel_load(bin_path, *args)
29
29
  end
30
- with_verbose_rubygems { kernel_exec(bin_path, *args) }
30
+ kernel_exec(bin_path, *args)
31
31
  else
32
32
  # exec using the given command
33
- with_verbose_rubygems { kernel_exec(cmd, *args) }
33
+ kernel_exec(cmd, *args)
34
34
  end
35
35
  end
36
36
 
@@ -89,14 +89,5 @@ module Bundler
89
89
  first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) }
90
90
  possibilities.any? {|shebang| first_line.start_with?(shebang) }
91
91
  end
92
-
93
- def with_verbose_rubygems
94
- old_ui = Gem::DefaultUserInteraction.ui
95
- Gem::DefaultUserInteraction.ui = nil
96
-
97
- yield
98
- ensure
99
- Gem::DefaultUserInteraction.ui = old_ui
100
- end
101
92
  end
102
93
  end
@@ -12,6 +12,7 @@ module Bundler
12
12
  TEST_FRAMEWORK_VERSIONS = {
13
13
  "rspec" => "3.0",
14
14
  "minitest" => "5.0",
15
+ "test-unit" => "3.0",
15
16
  }.freeze
16
17
 
17
18
  attr_reader :options, :gem_name, :thor, :name, :target
@@ -62,7 +63,7 @@ module Bundler
62
63
  ensure_safe_gem_name(name, constant_array)
63
64
 
64
65
  templates = {
65
- "Gemfile.tt" => "Gemfile",
66
+ "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
66
67
  "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
67
68
  "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
68
69
  "newgem.gemspec.tt" => "#{name}.gemspec",
@@ -83,8 +84,6 @@ module Bundler
83
84
  config[:test] = test_framework
84
85
  config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework]
85
86
 
86
- templates.merge!("travis.yml.tt" => ".travis.yml")
87
-
88
87
  case test_framework
89
88
  when "rspec"
90
89
  templates.merge!(
@@ -92,15 +91,33 @@ module Bundler
92
91
  "spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
93
92
  "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
94
93
  )
94
+ config[:test_task] = :spec
95
95
  when "minitest"
96
96
  templates.merge!(
97
- "test/test_helper.rb.tt" => "test/test_helper.rb",
98
- "test/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
97
+ "test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
98
+ "test/minitest/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
99
+ )
100
+ config[:test_task] = :test
101
+ when "test-unit"
102
+ templates.merge!(
103
+ "test/test-unit/test_helper.rb.tt" => "test/test_helper.rb",
104
+ "test/test-unit/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
99
105
  )
106
+ config[:test_task] = :test
100
107
  end
101
108
  end
102
109
 
103
- config[:test_task] = config[:test] == "minitest" ? "test" : "spec"
110
+ config[:ci] = ask_and_set_ci
111
+ case config[:ci]
112
+ when "github"
113
+ templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
114
+ when "travis"
115
+ templates.merge!("travis.yml.tt" => ".travis.yml")
116
+ when "gitlab"
117
+ templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
118
+ when "circle"
119
+ templates.merge!("circleci/config.yml.tt" => ".circleci/config.yml")
120
+ end
104
121
 
105
122
  if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
106
123
  "This means that any other developer or company will be legally allowed to use your code " \
@@ -124,6 +141,16 @@ module Bundler
124
141
  templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
125
142
  end
126
143
 
144
+ if ask_and_set(:rubocop, "Do you want to add rubocop as a dependency for gems you generate?",
145
+ "RuboCop is a static code analyzer that has out-of-the-box rules for many " \
146
+ "of the guidelines in the community style guide. " \
147
+ "For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) " \
148
+ "and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide).")
149
+ config[:rubocop] = true
150
+ Bundler.ui.info "RuboCop enabled in config"
151
+ templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
152
+ end
153
+
127
154
  templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
128
155
 
129
156
  if options[:ext]
@@ -197,11 +224,12 @@ module Bundler
197
224
  def ask_and_set_test_framework
198
225
  test_framework = options[:test] || Bundler.settings["gem.test"]
199
226
 
200
- if test_framework.nil?
227
+ if test_framework.to_s.empty?
201
228
  Bundler.ui.confirm "Do you want to generate tests with your gem?"
202
- result = Bundler.ui.ask "Type 'rspec' or 'minitest' to generate those test files now and " \
203
- "in the future. rspec/minitest/(none):"
204
- if result =~ /rspec|minitest/
229
+ Bundler.ui.info hint_text("test")
230
+
231
+ result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):"
232
+ if result =~ /rspec|minitest|test-unit/
205
233
  test_framework = result
206
234
  else
207
235
  test_framework = false
@@ -212,9 +240,54 @@ module Bundler
212
240
  Bundler.settings.set_global("gem.test", test_framework)
213
241
  end
214
242
 
243
+ if options[:test] == Bundler.settings["gem.test"]
244
+ Bundler.ui.info "#{options[:test]} is already configured, ignoring --test flag."
245
+ end
246
+
215
247
  test_framework
216
248
  end
217
249
 
250
+ def hint_text(setting)
251
+ if Bundler.settings["gem.#{setting}"] == false
252
+ "Your choice will only be applied to this gem."
253
+ else
254
+ "Future `bundle gem` calls will use your choice. " \
255
+ "This setting can be changed anytime with `bundle config gem.#{setting}`."
256
+ end
257
+ end
258
+
259
+ def ask_and_set_ci
260
+ ci_template = options[:ci] || Bundler.settings["gem.ci"]
261
+
262
+ if ci_template.to_s.empty?
263
+ Bundler.ui.confirm "Do you want to set up continuous integration for your gem? " \
264
+ "Supported services:\n" \
265
+ "* CircleCI: https://circleci.com/\n" \
266
+ "* GitHub Actions: https://github.com/features/actions\n" \
267
+ "* GitLab CI: https://docs.gitlab.com/ee/ci/\n" \
268
+ "* Travis CI: https://travis-ci.org/\n" \
269
+ "\n"
270
+ Bundler.ui.info hint_text("ci")
271
+
272
+ result = Bundler.ui.ask "Enter a CI service. github/travis/gitlab/circle/(none):"
273
+ if result =~ /github|travis|gitlab|circle/
274
+ ci_template = result
275
+ else
276
+ ci_template = false
277
+ end
278
+ end
279
+
280
+ if Bundler.settings["gem.ci"].nil?
281
+ Bundler.settings.set_global("gem.ci", ci_template)
282
+ end
283
+
284
+ if options[:ci] == Bundler.settings["gem.ci"]
285
+ Bundler.ui.info "#{options[:ci]} is already configured, ignoring --ci flag."
286
+ end
287
+
288
+ ci_template
289
+ end
290
+
218
291
  def bundler_dependency_version
219
292
  v = Gem::Version.new(Bundler::VERSION)
220
293
  req = v.segments[0..1]
@@ -40,20 +40,30 @@ module Bundler
40
40
  end
41
41
 
42
42
  def print_gem_path(spec)
43
- path = if spec.name == "bundler"
44
- File.expand_path("../../../..", __FILE__)
43
+ if spec.name == "bundler"
44
+ path = File.expand_path("../../../..", __FILE__)
45
45
  else
46
- spec.full_gem_path
46
+ path = spec.full_gem_path
47
+ unless File.directory?(path)
48
+ return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}"
49
+ end
47
50
  end
48
51
 
49
52
  Bundler.ui.info path
50
53
  end
51
54
 
52
55
  def print_gem_info(spec)
56
+ metadata = spec.metadata
53
57
  gem_info = String.new
54
58
  gem_info << " * #{spec.name} (#{spec.version}#{spec.git_version})\n"
55
59
  gem_info << "\tSummary: #{spec.summary}\n" if spec.summary
56
60
  gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage
61
+ gem_info << "\tDocumentation: #{metadata["documentation_uri"]}\n" if metadata.key?("documentation_uri")
62
+ gem_info << "\tSource Code: #{metadata["source_code_uri"]}\n" if metadata.key?("source_code_uri")
63
+ gem_info << "\tWiki: #{metadata["wiki_uri"]}\n" if metadata.key?("wiki_uri")
64
+ gem_info << "\tChangelog: #{metadata["changelog_uri"]}\n" if metadata.key?("changelog_uri")
65
+ gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri")
66
+ gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri")
57
67
  gem_info << "\tPath: #{spec.full_gem_path}\n"
58
68
  gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem?
59
69
  Bundler.ui.info gem_info
@@ -41,7 +41,7 @@ module Bundler
41
41
  private
42
42
 
43
43
  def gemfile
44
- @gemfile ||= Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
44
+ @gemfile ||= Bundler.preferred_gemfile_name
45
45
  end
46
46
  end
47
47
  end
@@ -12,8 +12,6 @@ module Bundler
12
12
 
13
13
  warn_if_root
14
14
 
15
- normalize_groups
16
-
17
15
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
18
16
 
19
17
  # Disable color in deployment mode
@@ -38,7 +36,8 @@ module Bundler
38
36
  if Bundler.feature_flag.deployment_means_frozen?
39
37
  Bundler.settings.set_command_option :deployment, true
40
38
  else
41
- Bundler.settings.set_command_option :frozen, true
39
+ Bundler.settings.set_command_option :deployment, true if options[:deployment]
40
+ Bundler.settings.set_command_option :frozen, true if options[:frozen]
42
41
  end
43
42
  end
44
43
 
@@ -151,25 +150,24 @@ module Bundler
151
150
 
152
151
  check_for_group_conflicts_in_cli_options
153
152
 
154
- Bundler.settings.set_command_option :with, nil if options[:with] == []
155
- Bundler.settings.set_command_option :without, nil if options[:without] == []
156
-
157
153
  with = options.fetch(:with, [])
158
154
  with |= Bundler.settings[:with].map(&:to_s)
159
155
  with -= options[:without] if options[:without]
156
+ with = nil if options[:with] == []
160
157
 
161
158
  without = options.fetch(:without, [])
162
159
  without |= Bundler.settings[:without].map(&:to_s)
163
160
  without -= options[:with] if options[:with]
161
+ without = nil if options[:without] == []
164
162
 
165
- options[:with] = with
166
- options[:without] = without
163
+ Bundler.settings.set_command_option :without, without
164
+ Bundler.settings.set_command_option :with, with
167
165
  end
168
166
 
169
167
  def normalize_settings
170
168
  Bundler.settings.set_command_option :path, nil if options[:system]
171
169
  Bundler.settings.temporary(:path_relative_to_cwd => false) do
172
- Bundler.settings.set_command_option :path, "vendor/bundle" if options[:deployment]
170
+ Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil?
173
171
  end
174
172
  Bundler.settings.set_command_option_if_given :path, options[:path]
175
173
  Bundler.settings.temporary(:path_relative_to_cwd => false) do
@@ -190,13 +188,7 @@ module Bundler
190
188
 
191
189
  Bundler.settings.set_command_option_if_given :clean, options["clean"]
192
190
 
193
- unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
194
- # need to nil them out first to get around validation for backwards compatibility
195
- Bundler.settings.set_command_option :without, nil
196
- Bundler.settings.set_command_option :with, nil
197
- Bundler.settings.set_command_option :without, options[:without] - options[:with]
198
- Bundler.settings.set_command_option :with, options[:with]
199
- end
191
+ normalize_groups if options[:without] || options[:with]
200
192
 
201
193
  options[:force] = options[:redownload]
202
194
  end