bundler 2.6.9 → 4.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2229 -1879
  3. data/README.md +11 -11
  4. data/bundler.gemspec +5 -5
  5. data/lib/bundler/build_metadata.rb +10 -11
  6. data/lib/bundler/capistrano.rb +1 -19
  7. data/lib/bundler/checksum.rb +6 -0
  8. data/lib/bundler/cli/add.rb +10 -0
  9. data/lib/bundler/cli/cache.rb +1 -12
  10. data/lib/bundler/cli/common.rb +21 -4
  11. data/lib/bundler/cli/config.rb +1 -2
  12. data/lib/bundler/cli/console.rb +5 -0
  13. data/lib/bundler/cli/exec.rb +29 -4
  14. data/lib/bundler/cli/gem.rb +90 -64
  15. data/lib/bundler/cli/install.rb +15 -90
  16. data/lib/bundler/cli/issue.rb +2 -2
  17. data/lib/bundler/cli/list.rb +33 -2
  18. data/lib/bundler/cli/lock.rb +5 -5
  19. data/lib/bundler/cli/outdated.rb +1 -1
  20. data/lib/bundler/cli/plugin.rb +5 -1
  21. data/lib/bundler/cli/pristine.rb +5 -1
  22. data/lib/bundler/cli/show.rb +3 -7
  23. data/lib/bundler/cli/update.rb +5 -5
  24. data/lib/bundler/cli.rb +162 -127
  25. data/lib/bundler/compact_index_client.rb +1 -6
  26. data/lib/bundler/current_ruby.rb +17 -5
  27. data/lib/bundler/definition.rb +201 -117
  28. data/lib/bundler/dependency.rb +1 -1
  29. data/lib/bundler/deployment.rb +1 -64
  30. data/lib/bundler/digest.rb +1 -1
  31. data/lib/bundler/dsl.rb +48 -48
  32. data/lib/bundler/environment_preserver.rb +1 -0
  33. data/lib/bundler/errors.rb +1 -5
  34. data/lib/bundler/feature_flag.rb +5 -35
  35. data/lib/bundler/fetcher/compact_index.rb +1 -1
  36. data/lib/bundler/fetcher/dependency.rb +9 -2
  37. data/lib/bundler/fetcher/downloader.rb +33 -8
  38. data/lib/bundler/fetcher/gem_remote_fetcher.rb +6 -0
  39. data/lib/bundler/fetcher.rb +49 -19
  40. data/lib/bundler/friendly_errors.rb +4 -3
  41. data/lib/bundler/index.rb +7 -9
  42. data/lib/bundler/injector.rb +1 -2
  43. data/lib/bundler/inline.rb +9 -1
  44. data/lib/bundler/installer/gem_installer.rb +14 -11
  45. data/lib/bundler/installer/parallel_installer.rb +74 -36
  46. data/lib/bundler/installer.rb +6 -19
  47. data/lib/bundler/lazy_specification.rb +47 -20
  48. data/lib/bundler/lockfile_generator.rb +17 -2
  49. data/lib/bundler/lockfile_parser.rb +19 -6
  50. data/lib/bundler/man/bundle-add.1 +1 -1
  51. data/lib/bundler/man/bundle-binstubs.1 +3 -6
  52. data/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  53. data/lib/bundler/man/bundle-cache.1 +2 -14
  54. data/lib/bundler/man/bundle-cache.1.ronn +1 -14
  55. data/lib/bundler/man/bundle-check.1 +2 -5
  56. data/lib/bundler/man/bundle-check.1.ronn +0 -5
  57. data/lib/bundler/man/bundle-clean.1 +1 -1
  58. data/lib/bundler/man/bundle-config.1 +206 -148
  59. data/lib/bundler/man/bundle-config.1.ronn +136 -119
  60. data/lib/bundler/man/bundle-console.1 +1 -1
  61. data/lib/bundler/man/bundle-doctor.1 +43 -4
  62. data/lib/bundler/man/bundle-doctor.1.ronn +48 -4
  63. data/lib/bundler/man/bundle-env.1 +1 -1
  64. data/lib/bundler/man/bundle-exec.1 +2 -5
  65. data/lib/bundler/man/bundle-exec.1.ronn +1 -5
  66. data/lib/bundler/man/bundle-fund.1 +1 -1
  67. data/lib/bundler/man/bundle-gem.1 +64 -44
  68. data/lib/bundler/man/bundle-gem.1.ronn +10 -9
  69. data/lib/bundler/man/bundle-help.1 +1 -1
  70. data/lib/bundler/man/bundle-info.1 +1 -1
  71. data/lib/bundler/man/bundle-init.1 +1 -1
  72. data/lib/bundler/man/bundle-install.1 +16 -59
  73. data/lib/bundler/man/bundle-install.1.ronn +27 -108
  74. data/lib/bundler/man/bundle-issue.1 +1 -1
  75. data/lib/bundler/man/bundle-licenses.1 +1 -1
  76. data/lib/bundler/man/bundle-list.1 +6 -1
  77. data/lib/bundler/man/bundle-list.1.ronn +5 -0
  78. data/lib/bundler/man/bundle-lock.1 +1 -1
  79. data/lib/bundler/man/bundle-open.1 +1 -1
  80. data/lib/bundler/man/bundle-outdated.1 +1 -1
  81. data/lib/bundler/man/bundle-platform.1 +1 -1
  82. data/lib/bundler/man/bundle-plugin.1 +33 -15
  83. data/lib/bundler/man/bundle-plugin.1.ronn +36 -15
  84. data/lib/bundler/man/bundle-pristine.1 +1 -1
  85. data/lib/bundler/man/bundle-remove.1 +2 -8
  86. data/lib/bundler/man/bundle-remove.1.ronn +1 -8
  87. data/lib/bundler/man/bundle-show.1 +2 -5
  88. data/lib/bundler/man/bundle-show.1.ronn +0 -4
  89. data/lib/bundler/man/bundle-update.1 +5 -5
  90. data/lib/bundler/man/bundle-update.1.ronn +4 -4
  91. data/lib/bundler/man/bundle-version.1 +1 -1
  92. data/lib/bundler/man/bundle.1 +1 -10
  93. data/lib/bundler/man/bundle.1.ronn +0 -9
  94. data/lib/bundler/man/gemfile.5 +32 -1
  95. data/lib/bundler/man/gemfile.5.ronn +28 -0
  96. data/lib/bundler/man/index.txt +0 -2
  97. data/lib/bundler/match_platform.rb +31 -12
  98. data/lib/bundler/materialization.rb +3 -3
  99. data/lib/bundler/plugin/api/source.rb +8 -0
  100. data/lib/bundler/plugin/index.rb +6 -0
  101. data/lib/bundler/plugin/installer.rb +2 -11
  102. data/lib/bundler/plugin/source_list.rb +1 -1
  103. data/lib/bundler/plugin.rb +7 -4
  104. data/lib/bundler/resolver/package.rb +2 -1
  105. data/lib/bundler/resolver/strategy.rb +6 -3
  106. data/lib/bundler/resolver.rb +20 -4
  107. data/lib/bundler/retry.rb +30 -4
  108. data/lib/bundler/ruby_dsl.rb +17 -12
  109. data/lib/bundler/ruby_version.rb +1 -3
  110. data/lib/bundler/rubygems_ext.rb +117 -121
  111. data/lib/bundler/rubygems_gem_installer.rb +5 -4
  112. data/lib/bundler/rubygems_integration.rb +13 -12
  113. data/lib/bundler/runtime.rb +14 -3
  114. data/lib/bundler/self_manager.rb +34 -43
  115. data/lib/bundler/settings/validator.rb +5 -21
  116. data/lib/bundler/settings.rb +17 -32
  117. data/lib/bundler/shared_helpers.rb +12 -18
  118. data/lib/bundler/source/gemspec.rb +4 -0
  119. data/lib/bundler/source/git/git_proxy.rb +55 -29
  120. data/lib/bundler/source/git.rb +2 -3
  121. data/lib/bundler/source/metadata.rb +4 -0
  122. data/lib/bundler/source/path.rb +12 -7
  123. data/lib/bundler/source/rubygems.rb +59 -43
  124. data/lib/bundler/source/rubygems_aggregate.rb +4 -1
  125. data/lib/bundler/source.rb +3 -1
  126. data/lib/bundler/source_list.rb +5 -50
  127. data/lib/bundler/source_map.rb +8 -7
  128. data/lib/bundler/spec_set.rb +9 -14
  129. data/lib/bundler/stub_specification.rb +1 -0
  130. data/lib/bundler/templates/Executable +0 -11
  131. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  132. data/lib/bundler/templates/newgem/Cargo.toml.tt +6 -0
  133. data/lib/bundler/templates/newgem/Rakefile.tt +5 -0
  134. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  135. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +8 -1
  136. data/lib/bundler/templates/newgem/ext/newgem/build.rs.tt +5 -0
  137. data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  138. data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  139. data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  140. data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  141. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +13 -2
  142. data/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt +69 -0
  143. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +12 -1
  144. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  145. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -1
  146. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -11
  147. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +8 -0
  148. data/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +6 -0
  149. data/lib/bundler/ui/shell.rb +12 -8
  150. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  151. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  152. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  153. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  154. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  155. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +2 -1
  156. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +84 -42
  157. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  158. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  159. data/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -2
  160. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  161. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  162. data/lib/bundler/vendor/thor/lib/thor.rb +1 -1
  163. data/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  164. data/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  165. data/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  166. data/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  167. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  168. data/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  169. data/lib/bundler/version.rb +10 -2
  170. data/lib/bundler/vlad.rb +1 -14
  171. data/lib/bundler/worker.rb +12 -4
  172. data/lib/bundler.rb +20 -40
  173. metadata +13 -25
  174. data/lib/bundler/cli/inject.rb +0 -60
  175. data/lib/bundler/cli/viz.rb +0 -31
  176. data/lib/bundler/gem_helpers.rb +0 -144
  177. data/lib/bundler/graph.rb +0 -152
  178. data/lib/bundler/man/bundle-inject.1 +0 -31
  179. data/lib/bundler/man/bundle-inject.1.ronn +0 -32
  180. data/lib/bundler/man/bundle-viz.1 +0 -30
  181. data/lib/bundler/man/bundle-viz.1.ronn +0 -36
  182. data/lib/bundler/similarity_detector.rb +0 -63
  183. data/lib/bundler/templates/Executable.bundler +0 -109
  184. data/lib/bundler/vendor/connection_pool/.document +0 -1
  185. data/lib/bundler/vendor/fileutils/.document +0 -1
  186. data/lib/bundler/vendor/net-http-persistent/.document +0 -1
  187. data/lib/bundler/vendor/pub_grub/.document +0 -1
  188. data/lib/bundler/vendor/securerandom/.document +0 -1
  189. data/lib/bundler/vendor/thor/.document +0 -1
  190. data/lib/bundler/vendor/tsort/.document +0 -1
  191. data/lib/bundler/vendor/uri/.document +0 -1
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pathname"
4
-
5
3
  module Bundler
6
4
  class CLI
7
5
  Bundler.require_thor_actions
@@ -15,6 +13,8 @@ module Bundler
15
13
  "test-unit" => "3.0",
16
14
  }.freeze
17
15
 
16
+ DEFAULT_GITHUB_USERNAME = "[USERNAME]"
17
+
18
18
  attr_reader :options, :gem_name, :thor, :name, :target, :extension
19
19
 
20
20
  def initialize(options, gem_name, thor)
@@ -26,12 +26,11 @@ module Bundler
26
26
  thor.destination_root = nil
27
27
 
28
28
  @name = @gem_name
29
- @target = SharedHelpers.pwd.join(gem_name)
29
+ @target = Pathname.new(SharedHelpers.pwd).join(gem_name)
30
30
 
31
31
  @extension = options[:ext]
32
32
 
33
33
  validate_ext_name if @extension
34
- validate_rust_builder_rubygems_version if @extension == "rust"
35
34
  end
36
35
 
37
36
  def run
@@ -48,13 +47,16 @@ module Bundler
48
47
  git_author_name = use_git ? `git config user.name`.chomp : ""
49
48
  git_username = use_git ? `git config github.user`.chomp : ""
50
49
  git_user_email = use_git ? `git config user.email`.chomp : ""
50
+ github_username = github_username(git_username)
51
51
 
52
- github_username = if options[:github_username].nil?
53
- git_username
54
- elsif options[:github_username] == false
55
- ""
52
+ if github_username.empty?
53
+ homepage_uri = "TODO: Put your gem's website or public repo URL here."
54
+ source_code_uri = "TODO: Put your gem's public repo URL here."
55
+ changelog_uri = "TODO: Put your gem's CHANGELOG.md URL here."
56
56
  else
57
- options[:github_username]
57
+ homepage_uri = "https://github.com/#{github_username}/#{name}"
58
+ source_code_uri = "https://github.com/#{github_username}/#{name}"
59
+ changelog_uri = "https://github.com/#{github_username}/#{name}/blob/main/CHANGELOG.md"
58
60
  end
59
61
 
60
62
  config = {
@@ -69,12 +71,17 @@ module Bundler
69
71
  test: options[:test],
70
72
  ext: extension,
71
73
  exe: options[:exe],
74
+ bundle: options[:bundle],
72
75
  bundler_version: bundler_dependency_version,
73
76
  git: use_git,
74
- github_username: github_username.empty? ? "[USERNAME]" : github_username,
77
+ github_username: github_username.empty? ? DEFAULT_GITHUB_USERNAME : github_username,
75
78
  required_ruby_version: required_ruby_version,
76
79
  rust_builder_required_rubygems_version: rust_builder_required_rubygems_version,
77
80
  minitest_constant_name: minitest_constant_name,
81
+ ignore_paths: %w[bin/],
82
+ homepage_uri: homepage_uri,
83
+ source_code_uri: source_code_uri,
84
+ changelog_uri: changelog_uri,
78
85
  }
79
86
  ensure_safe_gem_name(name, constant_array)
80
87
 
@@ -95,7 +102,18 @@ module Bundler
95
102
  bin/setup
96
103
  ]
97
104
 
98
- templates.merge!("gitignore.tt" => ".gitignore") if use_git
105
+ case Bundler.preferred_gemfile_name
106
+ when "Gemfile"
107
+ config[:ignore_paths] << "Gemfile"
108
+ when "gems.rb"
109
+ config[:ignore_paths] << "gems.rb"
110
+ config[:ignore_paths] << "gems.locked"
111
+ end
112
+
113
+ if use_git
114
+ templates.merge!("gitignore.tt" => ".gitignore")
115
+ config[:ignore_paths] << ".gitignore"
116
+ end
99
117
 
100
118
  if test_framework = ask_and_set_test_framework
101
119
  config[:test] = test_framework
@@ -109,6 +127,8 @@ module Bundler
109
127
  "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
110
128
  )
111
129
  config[:test_task] = :spec
130
+ config[:ignore_paths] << ".rspec"
131
+ config[:ignore_paths] << "spec/"
112
132
  when "minitest"
113
133
  # Generate path for minitest target file (FileList["test/**/test_*.rb"])
114
134
  # foo => test/test_foo.rb
@@ -123,12 +143,14 @@ module Bundler
123
143
  "test/minitest/test_newgem.rb.tt" => "test/#{minitest_namespaced_path}.rb"
124
144
  )
125
145
  config[:test_task] = :test
146
+ config[:ignore_paths] << "test/"
126
147
  when "test-unit"
127
148
  templates.merge!(
128
149
  "test/test-unit/test_helper.rb.tt" => "test/test_helper.rb",
129
150
  "test/test-unit/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
130
151
  )
131
152
  config[:test_task] = :test
153
+ config[:ignore_paths] << "test/"
132
154
  end
133
155
  end
134
156
 
@@ -136,19 +158,22 @@ module Bundler
136
158
  case config[:ci]
137
159
  when "github"
138
160
  templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
139
- config[:ci_config_path] = ".github "
161
+ if extension == "rust"
162
+ templates.merge!("github/workflows/build-gems.yml.tt" => ".github/workflows/build-gems.yml")
163
+ end
164
+ config[:ignore_paths] << ".github/"
140
165
  when "gitlab"
141
166
  templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
142
- config[:ci_config_path] = ".gitlab-ci.yml "
167
+ config[:ignore_paths] << ".gitlab-ci.yml"
143
168
  when "circle"
144
169
  templates.merge!("circleci/config.yml.tt" => ".circleci/config.yml")
145
- config[:ci_config_path] = ".circleci "
170
+ config[:ignore_paths] << ".circleci/"
146
171
  end
147
172
 
148
173
  if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
149
- "This means that any other developer or company will be legally allowed to use your code " \
150
- "for free as long as they admit you created it. You can read more about the MIT license " \
151
- "at https://choosealicense.com/licenses/mit.")
174
+ "Using a MIT license means that any other developer or company will be legally allowed " \
175
+ "to use your code for free as long as they admit you created it. You can read more about " \
176
+ "the MIT license at https://choosealicense.com/licenses/mit.")
152
177
  config[:mit] = true
153
178
  Bundler.ui.info "MIT License enabled in config"
154
179
  templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
@@ -156,12 +181,8 @@ module Bundler
156
181
 
157
182
  if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
158
183
  "Codes of conduct can increase contributions to your project by contributors who " \
159
- "prefer collaborative, safe spaces. You can read more about the code of conduct at " \
160
- "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
161
- "of enforcing it, so be sure that you are prepared to do that. Be sure that your email " \
162
- "address is specified as a contact in the generated code of conduct so that people know " \
163
- "who to contact in case of a violation. For suggestions about " \
164
- "how to enforce codes of conduct, see https://bit.ly/coc-enforcement.")
184
+ "prefer safe, respectful, productive, and collaborative spaces. \n" \
185
+ "See https://github.com/ruby/rubygems/blob/master/CODE_OF_CONDUCT.md")
165
186
  config[:coc] = true
166
187
  Bundler.ui.info "Code of conduct enabled in config"
167
188
  templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
@@ -185,10 +206,12 @@ module Bundler
185
206
  config[:linter_version] = rubocop_version
186
207
  Bundler.ui.info "RuboCop enabled in config"
187
208
  templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
209
+ config[:ignore_paths] << ".rubocop.yml"
188
210
  when "standard"
189
211
  config[:linter_version] = standard_version
190
212
  Bundler.ui.info "Standard enabled in config"
191
213
  templates.merge!("standard.yml.tt" => ".standard.yml")
214
+ config[:ignore_paths] << ".standard.yml"
192
215
  end
193
216
 
194
217
  if config[:exe]
@@ -208,18 +231,31 @@ module Bundler
208
231
  templates.merge!(
209
232
  "Cargo.toml.tt" => "Cargo.toml",
210
233
  "ext/newgem/Cargo.toml.tt" => "ext/#{name}/Cargo.toml",
234
+ "ext/newgem/build.rs.tt" => "ext/#{name}/build.rs",
211
235
  "ext/newgem/extconf-rust.rb.tt" => "ext/#{name}/extconf.rb",
212
236
  "ext/newgem/src/lib.rs.tt" => "ext/#{name}/src/lib.rs",
213
237
  )
214
238
  end
215
239
 
240
+ if extension == "go"
241
+ templates.merge!(
242
+ "ext/newgem/go.mod.tt" => "ext/#{name}/go.mod",
243
+ "ext/newgem/extconf-go.rb.tt" => "ext/#{name}/extconf.rb",
244
+ "ext/newgem/newgem.h.tt" => "ext/#{name}/#{underscored_name}.h",
245
+ "ext/newgem/newgem.go.tt" => "ext/#{name}/#{underscored_name}.go",
246
+ "ext/newgem/newgem-go.c.tt" => "ext/#{name}/#{underscored_name}.c",
247
+ )
248
+
249
+ config[:go_module_username] = config[:github_username] == DEFAULT_GITHUB_USERNAME ? "username" : config[:github_username]
250
+ end
251
+
216
252
  if target.exist? && !target.directory?
217
253
  Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
218
254
  exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
219
255
  end
220
256
 
221
257
  if use_git
222
- Bundler.ui.info "Initializing git repo in #{target}"
258
+ Bundler.ui.info "\nInitializing git repo in #{target}"
223
259
  require "shellwords"
224
260
  `git init #{target.to_s.shellescape}`
225
261
 
@@ -241,26 +277,33 @@ module Bundler
241
277
  IO.popen(%w[git add .], { chdir: target }, &:read)
242
278
  end
243
279
 
280
+ if config[:bundle]
281
+ Bundler.ui.info "Running bundle install in the new gem directory."
282
+ Dir.chdir(target) do
283
+ system("bundle install")
284
+ end
285
+ end
286
+
244
287
  # Open gemspec in editor
245
288
  open_editor(options["edit"], target.join("#{name}.gemspec")) if options[:edit]
246
289
 
247
- Bundler.ui.info "Gem '#{name}' was successfully created. " \
248
- "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
290
+ Bundler.ui.info "\nGem '#{name}' was successfully created. " \
291
+ "For more information on making a RubyGem visit https://guides.rubygems.org/make-your-own-gem/"
249
292
  end
250
293
 
251
294
  private
252
295
 
253
296
  def resolve_name(name)
254
- SharedHelpers.pwd.join(name).basename.to_s
297
+ Pathname.new(SharedHelpers.pwd).join(name).basename.to_s
255
298
  end
256
299
 
257
- def ask_and_set(key, header, message)
300
+ def ask_and_set(key, prompt, explanation)
258
301
  choice = options[key]
259
302
  choice = Bundler.settings["gem.#{key}"] if choice.nil?
260
303
 
261
304
  if choice.nil?
262
- Bundler.ui.confirm header
263
- choice = Bundler.ui.yes? "#{message} y/(n):"
305
+ Bundler.ui.info "\n#{explanation}"
306
+ choice = Bundler.ui.yes? "#{prompt} y/(n):"
264
307
  Bundler.settings.set_global("gem.#{key}", choice)
265
308
  end
266
309
 
@@ -282,7 +325,7 @@ module Bundler
282
325
  test_framework = options[:test] || Bundler.settings["gem.test"]
283
326
 
284
327
  if test_framework.to_s.empty?
285
- Bundler.ui.confirm "Do you want to generate tests with your gem?"
328
+ Bundler.ui.info "\nDo you want to generate tests with your gem?"
286
329
  Bundler.ui.info hint_text("test")
287
330
 
288
331
  result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):"
@@ -322,12 +365,11 @@ module Bundler
322
365
  ci_template = options[:ci] || Bundler.settings["gem.ci"]
323
366
 
324
367
  if ci_template.to_s.empty?
325
- Bundler.ui.confirm "Do you want to set up continuous integration for your gem? " \
368
+ Bundler.ui.info "\nDo you want to set up continuous integration for your gem? " \
326
369
  "Supported services:\n" \
327
370
  "* CircleCI: https://circleci.com/\n" \
328
371
  "* GitHub Actions: https://github.com/features/actions\n" \
329
- "* GitLab CI: https://docs.gitlab.com/ee/ci/\n" \
330
- "\n"
372
+ "* GitLab CI: https://docs.gitlab.com/ee/ci/\n"
331
373
  Bundler.ui.info hint_text("ci")
332
374
 
333
375
  result = Bundler.ui.ask "Enter a CI service. github/gitlab/circle/(none):"
@@ -352,14 +394,12 @@ module Bundler
352
394
  def ask_and_set_linter
353
395
  return if skip?(:linter)
354
396
  linter_template = options[:linter] || Bundler.settings["gem.linter"]
355
- linter_template = deprecated_rubocop_option if linter_template.nil?
356
397
 
357
398
  if linter_template.to_s.empty?
358
- Bundler.ui.confirm "Do you want to add a code linter and formatter to your gem? " \
399
+ Bundler.ui.info "\nDo you want to add a code linter and formatter to your gem? " \
359
400
  "Supported Linters:\n" \
360
401
  "* RuboCop: https://rubocop.org\n" \
361
- "* Standard: https://github.com/standardrb/standard\n" \
362
- "\n"
402
+ "* Standard: https://github.com/standardrb/standard\n"
363
403
  Bundler.ui.info hint_text("linter")
364
404
 
365
405
  result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
@@ -386,27 +426,6 @@ module Bundler
386
426
  linter_template
387
427
  end
388
428
 
389
- def deprecated_rubocop_option
390
- if !options[:rubocop].nil?
391
- if options[:rubocop]
392
- Bundler::SharedHelpers.major_deprecation 2,
393
- "--rubocop is deprecated, use --linter=rubocop",
394
- removed_message: "--rubocop has been removed, use --linter=rubocop"
395
- "rubocop"
396
- else
397
- Bundler::SharedHelpers.major_deprecation 2,
398
- "--no-rubocop is deprecated, use --linter",
399
- removed_message: "--no-rubocop has been removed, use --linter"
400
- false
401
- end
402
- elsif !Bundler.settings["gem.rubocop"].nil?
403
- Bundler::SharedHelpers.major_deprecation 2,
404
- "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead",
405
- removed_message: "config gem.rubocop has been removed; we've updated your config to use gem.linter instead"
406
- Bundler.settings["gem.rubocop"] ? "rubocop" : false
407
- end
408
- end
409
-
410
429
  def bundler_dependency_version
411
430
  v = Gem::Version.new(Bundler::VERSION)
412
431
  req = v.segments[0..1]
@@ -420,6 +439,10 @@ module Bundler
420
439
  exit 1
421
440
  end
422
441
 
442
+ if /[A-Z]/.match?(name)
443
+ Bundler.ui.warn "Gem names with capital letters are not recommended. Please use only lowercase letters, numbers, and hyphens."
444
+ end
445
+
423
446
  constant_name = constant_array.join("::")
424
447
 
425
448
  existing_constant = constant_array.inject(Object) do |c, s|
@@ -446,7 +469,7 @@ module Bundler
446
469
  end
447
470
 
448
471
  def required_ruby_version
449
- "3.1.0"
472
+ "3.2.0"
450
473
  end
451
474
 
452
475
  def rubocop_version
@@ -457,10 +480,13 @@ module Bundler
457
480
  "1.3"
458
481
  end
459
482
 
460
- def validate_rust_builder_rubygems_version
461
- if Gem::Version.new(rust_builder_required_rubygems_version) > Gem.rubygems_version
462
- Bundler.ui.error "Your RubyGems version (#{Gem.rubygems_version}) is too old to build Rust extension. Please update your RubyGems using `gem update --system` or any other way and try again."
463
- exit 1
483
+ def github_username(git_username)
484
+ if options[:github_username].nil?
485
+ git_username
486
+ elsif options[:github_username] == false
487
+ ""
488
+ else
489
+ options[:github_username]
464
490
  end
465
491
  end
466
492
  end
@@ -20,54 +20,32 @@ module Bundler
20
20
 
21
21
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
22
22
 
23
- # Disable color in deployment mode
24
- Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
25
-
26
23
  if target_rbconfig_path = options[:"target-rbconfig"]
27
24
  Bundler.rubygems.set_target_rbconfig(target_rbconfig_path)
28
25
  end
29
26
 
30
- check_for_options_conflicts
31
-
32
27
  check_trust_policy
33
28
 
34
- if options[:deployment] || options[:frozen] || Bundler.frozen_bundle?
35
- unless Bundler.default_lockfile.exist?
36
- flag = "--deployment flag" if options[:deployment]
37
- flag ||= "--frozen flag" if options[:frozen]
38
- flag ||= "deployment setting" if Bundler.settings[:deployment]
39
- flag ||= "frozen setting" if Bundler.settings[:frozen]
40
- raise ProductionError, "The #{flag} requires a lockfile. Please make " \
41
- "sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
42
- "before deploying."
43
- end
44
-
45
- options[:local] = true if Bundler.app_cache.exist?
46
-
47
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
48
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
49
- end
50
-
51
- # When install is called with --no-deployment, disable deployment mode
52
- if options[:deployment] == false
53
- Bundler.settings.set_command_option :frozen, nil
54
- options[:system] = true
29
+ if Bundler.frozen_bundle? && !Bundler.default_lockfile.exist?
30
+ flag = "deployment setting" if Bundler.settings[:deployment]
31
+ flag = "frozen setting" if Bundler.settings[:frozen]
32
+ raise ProductionError, "The #{flag} requires a lockfile. Please make " \
33
+ "sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
34
+ "before deploying."
55
35
  end
56
36
 
57
37
  normalize_settings
58
38
 
59
39
  Bundler::Fetcher.disable_endpoint = options["full-index"]
60
40
 
61
- if options["binstubs"]
62
- Bundler::SharedHelpers.major_deprecation 2,
63
- "The --binstubs option will be removed in favor of `bundle binstubs --all`",
64
- removed_message: "The --binstubs option have been removed in favor of `bundle binstubs --all`"
65
- end
66
-
67
- Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
41
+ Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.settings[:plugins]
68
42
 
69
- definition = Bundler.definition
43
+ # For install we want to enable strict validation
44
+ # (rather than some optimizations we perform at app runtime).
45
+ definition = Bundler.definition(strict: true)
70
46
  definition.validate_runtime!
47
+ definition.lockfile = options["lockfile"] if options["lockfile"]
48
+ definition.lockfile = false if options["no-lock"]
71
49
 
72
50
  installer = Installer.install(Bundler.root, definition, options)
73
51
 
@@ -87,8 +65,6 @@ module Bundler
87
65
 
88
66
  Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
89
67
 
90
- warn_ambiguous_gems
91
-
92
68
  if CLI::Common.clean_after_install?
93
69
  require_relative "clean"
94
70
  Bundler::CLI::Clean.new(options).run
@@ -114,26 +90,10 @@ module Bundler
114
90
  end
115
91
 
116
92
  def gems_installed_for(definition)
117
- count = definition.specs.count
93
+ count = definition.specs.count {|spec| spec.name != "bundler" }
118
94
  "#{count} #{count == 1 ? "gem" : "gems"} now installed"
119
95
  end
120
96
 
121
- def check_for_group_conflicts_in_cli_options
122
- conflicting_groups = Array(options[:without]) & Array(options[:with])
123
- return if conflicting_groups.empty?
124
- raise InvalidOption, "You can't list a group in both with and without." \
125
- " The offending groups are: #{conflicting_groups.join(", ")}."
126
- end
127
-
128
- def check_for_options_conflicts
129
- if (options[:path] || options[:deployment]) && options[:system]
130
- error_message = String.new
131
- error_message << "You have specified both --path as well as --system. Please choose only one option.\n" if options[:path]
132
- error_message << "You have specified both --deployment as well as --system. Please choose only one option.\n" if options[:deployment]
133
- raise InvalidOption.new(error_message)
134
- end
135
- end
136
-
137
97
  def check_trust_policy
138
98
  trust_policy = options["trust-policy"]
139
99
  unless Bundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy)
@@ -143,30 +103,11 @@ module Bundler
143
103
  Bundler.settings.set_command_option_if_given :"trust-policy", trust_policy
144
104
  end
145
105
 
146
- def normalize_groups
147
- check_for_group_conflicts_in_cli_options
148
-
149
- # need to nil them out first to get around validation for backwards compatibility
150
- Bundler.settings.set_command_option :without, nil
151
- Bundler.settings.set_command_option :with, nil
152
- Bundler.settings.set_command_option :without, options[:without]
153
- Bundler.settings.set_command_option :with, options[:with]
154
- end
155
-
156
106
  def normalize_settings
157
- Bundler.settings.set_command_option :path, nil if options[:system]
158
- Bundler.settings.set_command_option_if_given :path, options[:path]
159
-
160
107
  if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
161
- Bundler.settings.temporary(path_relative_to_cwd: false) do
162
- Bundler.settings.set_command_option :path, "bundle"
163
- end
108
+ Bundler.settings.set_command_option :path, "bundle"
164
109
  end
165
110
 
166
- bin_option = options["binstubs"]
167
- bin_option = nil if bin_option&.empty?
168
- Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
169
-
170
111
  Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
171
112
 
172
113
  Bundler.settings.set_command_option_if_given :jobs, options["jobs"]
@@ -177,23 +118,7 @@ module Bundler
177
118
 
178
119
  Bundler.settings.set_command_option_if_given :clean, options["clean"]
179
120
 
180
- normalize_groups if options[:without] || options[:with]
181
-
182
- options[:force] = options[:redownload]
183
- end
184
-
185
- def warn_ambiguous_gems
186
- # TODO: remove this when we drop Bundler 1.x support
187
- Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris|
188
- Bundler.ui.warn "Warning: the gem '#{name}' was found in multiple sources."
189
- Bundler.ui.warn "Installed from: #{installed_from_uri}"
190
- Bundler.ui.warn "Also found in:"
191
- also_found_in_uris.each {|uri| Bundler.ui.warn " * #{uri}" }
192
- Bundler.ui.warn "You should add a source requirement to restrict this gem to your preferred source."
193
- Bundler.ui.warn "For example:"
194
- Bundler.ui.warn " gem '#{name}', :source => '#{installed_from_uri}'"
195
- Bundler.ui.warn "Then uninstall the gem '#{name}' (or delete all bundled gems) and then install again."
196
- end
121
+ options[:force] = options[:redownload] if options[:redownload]
197
122
  end
198
123
  end
199
124
  end
@@ -10,7 +10,7 @@ module Bundler
10
10
  be sure to check out these resources:
11
11
 
12
12
  1. Check out our troubleshooting guide for quick fixes to common issues:
13
- https://github.com/rubygems/rubygems/blob/master/doc/bundler/TROUBLESHOOTING.md
13
+ https://github.com/ruby/rubygems/blob/master/doc/bundler/TROUBLESHOOTING.md
14
14
 
15
15
  2. Instructions for common Bundler uses can be found on the documentation
16
16
  site: https://bundler.io/
@@ -22,7 +22,7 @@ module Bundler
22
22
  still aren't working the way you expect them to, please let us know so
23
23
  that we can diagnose and help fix the problem you're having, by filling
24
24
  in the new issue form located at
25
- https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
25
+ https://github.com/ruby/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
26
26
  and copy and pasting the information below.
27
27
 
28
28
  EOS
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  module Bundler
4
6
  class CLI::List
5
7
  def initialize(options)
6
8
  @options = options
7
9
  @without_group = options["without-group"].map(&:to_sym)
8
10
  @only_group = options["only-group"].map(&:to_sym)
11
+ @format = options["format"]
9
12
  end
10
13
 
11
14
  def run
@@ -25,6 +28,36 @@ module Bundler
25
28
  end
26
29
  end.reject {|s| s.name == "bundler" }.sort_by(&:name)
27
30
 
31
+ case @format
32
+ when "json"
33
+ print_json(specs: specs)
34
+ when nil
35
+ print_human(specs: specs)
36
+ else
37
+ raise InvalidOption, "Unknown option`--format=#{@format}`. Supported formats: `json`"
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def print_json(specs:)
44
+ gems = if @options["name-only"]
45
+ specs.map {|s| { name: s.name } }
46
+ else
47
+ specs.map do |s|
48
+ {
49
+ name: s.name,
50
+ version: s.version.to_s,
51
+ git_version: s.git_version&.strip,
52
+ }.tap do |h|
53
+ h[:path] = s.full_gem_path if @options["paths"]
54
+ end
55
+ end
56
+ end
57
+ Bundler.ui.info({ gems: gems }.to_json)
58
+ end
59
+
60
+ def print_human(specs:)
28
61
  return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
29
62
 
30
63
  return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"]
@@ -37,8 +70,6 @@ module Bundler
37
70
  Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
38
71
  end
39
72
 
40
- private
41
-
42
73
  def verify_group_exists(groups)
43
74
  (@without_group + @only_group).each do |group|
44
75
  raise InvalidOption, "`#{group}` group could not be found." unless groups.include?(group)
@@ -35,11 +35,8 @@ module Bundler
35
35
  update = { bundler: bundler }
36
36
  end
37
37
 
38
- file = options[:lockfile]
39
- file = file ? Pathname.new(file).expand_path : Bundler.default_lockfile
40
-
41
38
  Bundler.settings.temporary(frozen: false) do
42
- definition = Bundler.definition(update, file)
39
+ definition = Bundler.definition(update, Bundler.default_lockfile)
43
40
  definition.add_checksums if options["add-checksums"]
44
41
 
45
42
  Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
@@ -71,8 +68,11 @@ module Bundler
71
68
  if print
72
69
  puts definition.to_lock
73
70
  else
71
+ file = options[:lockfile]
72
+ file = file ? Pathname.new(file).expand_path : Bundler.default_lockfile
73
+
74
74
  puts "Writing lockfile to #{file}"
75
- definition.lock
75
+ definition.write_lock(file, false)
76
76
  end
77
77
  end
78
78
 
@@ -155,7 +155,7 @@ module Bundler
155
155
 
156
156
  return active_spec if strict
157
157
 
158
- active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
158
+ active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.installable_on_platform?(current_spec.platform) }.sort_by(&:version)
159
159
  if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
160
160
  active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
161
161
  end
@@ -10,11 +10,15 @@ module Bundler
10
10
  method_option "source", type: :string, default: nil, banner: "URL of the RubyGems source to fetch the plugin from"
11
11
  method_option "version", type: :string, default: nil, banner: "The version of the plugin to fetch"
12
12
  method_option "git", type: :string, default: nil, banner: "URL of the git repo to fetch from"
13
- method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (deprecated)"
13
+ method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (removed)"
14
14
  method_option "branch", type: :string, default: nil, banner: "The git branch to checkout"
15
15
  method_option "ref", type: :string, default: nil, banner: "The git revision to check out"
16
16
  method_option "path", type: :string, default: nil, banner: "Path of a local gem to directly use"
17
17
  def install(*plugins)
18
+ if options.key?(:local_git)
19
+ raise InvalidOption, "--local_git has been removed, use --git"
20
+ end
21
+
18
22
  Bundler::Plugin.install(plugins, options)
19
23
  end
20
24
 
@@ -11,6 +11,7 @@ module Bundler
11
11
  definition = Bundler.definition
12
12
  definition.validate_runtime!
13
13
  installer = Bundler::Installer.new(Bundler.root, definition)
14
+ git_sources = []
14
15
 
15
16
  ProcessLock.lock do
16
17
  installed_specs = definition.specs.reject do |spec|
@@ -41,6 +42,9 @@ module Bundler
41
42
  end
42
43
  FileUtils.rm_rf spec.extension_dir
43
44
  FileUtils.rm_rf spec.full_gem_path
45
+
46
+ next if git_sources.include?(source)
47
+ git_sources << source
44
48
  else
45
49
  Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
46
50
  next
@@ -49,7 +53,7 @@ module Bundler
49
53
  true
50
54
  end.map(&:name)
51
55
 
52
- jobs = installer.send(:installation_parallelization)
56
+ jobs = Bundler.settings.installation_parallelization
53
57
  pristine_count = definition.specs.count - installed_specs.count
54
58
  # allow a pristining a single gem to skip the parallel worker
55
59
  jobs = [jobs, pristine_count].min