bundler 2.5.9 → 2.5.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +136 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/check.rb +1 -1
  5. data/lib/bundler/cli/fund.rb +1 -1
  6. data/lib/bundler/cli/gem.rb +8 -15
  7. data/lib/bundler/cli/install.rb +1 -1
  8. data/lib/bundler/cli.rb +31 -48
  9. data/lib/bundler/compact_index_client/cache.rb +47 -72
  10. data/lib/bundler/compact_index_client/parser.rb +84 -0
  11. data/lib/bundler/compact_index_client.rb +51 -80
  12. data/lib/bundler/constants.rb +8 -1
  13. data/lib/bundler/definition.rb +120 -74
  14. data/lib/bundler/dependency.rb +2 -1
  15. data/lib/bundler/endpoint_specification.rb +11 -0
  16. data/lib/bundler/env.rb +1 -1
  17. data/lib/bundler/environment_preserver.rb +2 -20
  18. data/lib/bundler/errors.rb +14 -0
  19. data/lib/bundler/fetcher/compact_index.rb +15 -24
  20. data/lib/bundler/force_platform.rb +0 -2
  21. data/lib/bundler/gem_helper.rb +1 -1
  22. data/lib/bundler/gem_helpers.rb +14 -7
  23. data/lib/bundler/injector.rb +3 -5
  24. data/lib/bundler/installer/gem_installer.rb +0 -1
  25. data/lib/bundler/installer/standalone.rb +0 -3
  26. data/lib/bundler/installer.rb +9 -11
  27. data/lib/bundler/lazy_specification.rb +1 -0
  28. data/lib/bundler/man/bundle-add.1 +1 -1
  29. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  30. data/lib/bundler/man/bundle-cache.1 +1 -1
  31. data/lib/bundler/man/bundle-check.1 +3 -1
  32. data/lib/bundler/man/bundle-check.1.ronn +3 -0
  33. data/lib/bundler/man/bundle-clean.1 +1 -1
  34. data/lib/bundler/man/bundle-config.1 +2 -4
  35. data/lib/bundler/man/bundle-config.1.ronn +1 -4
  36. data/lib/bundler/man/bundle-console.1 +1 -1
  37. data/lib/bundler/man/bundle-doctor.1 +1 -1
  38. data/lib/bundler/man/bundle-exec.1 +1 -1
  39. data/lib/bundler/man/bundle-gem.1 +7 -1
  40. data/lib/bundler/man/bundle-gem.1.ronn +11 -0
  41. data/lib/bundler/man/bundle-help.1 +1 -1
  42. data/lib/bundler/man/bundle-info.1 +1 -1
  43. data/lib/bundler/man/bundle-init.1 +1 -1
  44. data/lib/bundler/man/bundle-inject.1 +1 -1
  45. data/lib/bundler/man/bundle-install.1 +1 -1
  46. data/lib/bundler/man/bundle-list.1 +1 -1
  47. data/lib/bundler/man/bundle-lock.1 +1 -1
  48. data/lib/bundler/man/bundle-open.1 +1 -1
  49. data/lib/bundler/man/bundle-outdated.1 +1 -1
  50. data/lib/bundler/man/bundle-platform.1 +1 -1
  51. data/lib/bundler/man/bundle-plugin.1 +1 -1
  52. data/lib/bundler/man/bundle-pristine.1 +1 -1
  53. data/lib/bundler/man/bundle-remove.1 +1 -1
  54. data/lib/bundler/man/bundle-show.1 +1 -1
  55. data/lib/bundler/man/bundle-update.1 +1 -1
  56. data/lib/bundler/man/bundle-version.1 +1 -1
  57. data/lib/bundler/man/bundle-viz.1 +1 -1
  58. data/lib/bundler/man/bundle.1 +1 -1
  59. data/lib/bundler/man/gemfile.5 +1 -1
  60. data/lib/bundler/plugin/api/source.rb +1 -0
  61. data/lib/bundler/resolver/base.rb +4 -0
  62. data/lib/bundler/resolver/candidate.rb +4 -16
  63. data/lib/bundler/resolver/package.rb +4 -0
  64. data/lib/bundler/resolver/spec_group.rb +20 -2
  65. data/lib/bundler/resolver.rb +18 -9
  66. data/lib/bundler/rubygems_ext.rb +105 -23
  67. data/lib/bundler/rubygems_gem_installer.rb +35 -2
  68. data/lib/bundler/rubygems_integration.rb +16 -2
  69. data/lib/bundler/runtime.rb +1 -6
  70. data/lib/bundler/self_manager.rb +23 -3
  71. data/lib/bundler/settings.rb +12 -9
  72. data/lib/bundler/setup.rb +6 -0
  73. data/lib/bundler/shared_helpers.rb +6 -4
  74. data/lib/bundler/source/git/git_proxy.rb +8 -0
  75. data/lib/bundler/source/git.rb +43 -16
  76. data/lib/bundler/source/metadata.rb +2 -0
  77. data/lib/bundler/source/path.rb +0 -13
  78. data/lib/bundler/source/rubygems.rb +31 -30
  79. data/lib/bundler/source_list.rb +28 -4
  80. data/lib/bundler/spec_set.rb +16 -14
  81. data/lib/bundler/stub_specification.rb +8 -0
  82. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  83. data/lib/bundler/vendored_net_http.rb +17 -6
  84. data/lib/bundler/version.rb +1 -1
  85. data/lib/bundler/yaml_serializer.rb +2 -9
  86. data/lib/bundler.rb +26 -1
  87. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b343f681293b03c25fbc82c8d4c323154aec1af8dc5f34e619779c7f4d4c634b
4
- data.tar.gz: 0566537e3cc941f3160e5060c806f0418907cca56e8d0e56a5b79dbb7d9bd94f
3
+ metadata.gz: 60cb5ee8526a6f8eb3c413e7d3d2ae8c9b32315685862943fc2a956f2fdcd5a1
4
+ data.tar.gz: 52aa4c3a435ed97c8dbc2adcfa51dc6d2113fefcb5020df0a5b0be3b605cc49f
5
5
  SHA512:
6
- metadata.gz: 2effd5a50b198e6113853e8d695bcc98d396f6bc0d036e55756a7615755fa8f7498fbab09f7b51d13aef5fe0c2acd1de807c16f7446c5a188de18f7793ebab4b
7
- data.tar.gz: 8cdafdd6dbe2da1aa03e44717211fc88440974c03c2057f57ecf514c5b9253d1aa7f1e9994758bcfb5ba614435b0853d070dfe32bfd25a7a033f45b03db86ca2
6
+ metadata.gz: afafe4e932d1840de3938e609f45555b1fbdf3fea481ee6d395a1f1458d579606d2f5ac64edc90d74799d9b117aae3fd1028b6d3a660df97e087bb9f6475d583
7
+ data.tar.gz: fd8907298e40c98124857ea7bf2594953d962946b66da695ce929db2623e67dacbee7dec6500a3dfb89cb6308377a26c305a25cd28a7083432ec10baf0d59810
data/CHANGELOG.md CHANGED
@@ -1,3 +1,139 @@
1
+ # 2.5.17 (August 1, 2024)
2
+
3
+ ## Enhancements:
4
+
5
+ - Print better log message when current platform is not present in the lockfile [#7891](https://github.com/rubygems/rubygems/pull/7891)
6
+ - Explicitly encode `Gem::Dependency` to yaml [#7867](https://github.com/rubygems/rubygems/pull/7867)
7
+ - Enable lockfile checksums on future Bundler 3 when there's no previous lockfile [#7805](https://github.com/rubygems/rubygems/pull/7805)
8
+
9
+ ## Bug fixes:
10
+
11
+ - Fix truffleruby removing gems from lockfile [#7795](https://github.com/rubygems/rubygems/pull/7795)
12
+ - Fix `bundle check` exit code when gem git source is not checked out [#7894](https://github.com/rubygems/rubygems/pull/7894)
13
+ - Generate gems.rb from Gemfile.tt template for `bundle-gem` [#7853](https://github.com/rubygems/rubygems/pull/7853)
14
+ - Fix git source cache being used as the install location [#4469](https://github.com/rubygems/rubygems/pull/4469)
15
+ - Fix `bundle exec gem uninstall` [#7886](https://github.com/rubygems/rubygems/pull/7886)
16
+
17
+ # 2.5.16 (July 18, 2024)
18
+
19
+ ## Bug fixes:
20
+
21
+ - Fix platform removal regression when `platforms:` used in the Gemfile [#7864](https://github.com/rubygems/rubygems/pull/7864)
22
+ - Fix standalone script when default gems with extensions are used [#7870](https://github.com/rubygems/rubygems/pull/7870)
23
+ - Fix another case of `bundle lock --add-platform` doing nothing [#7848](https://github.com/rubygems/rubygems/pull/7848)
24
+ - Fix bad error messages when using `bundle add` with frozen mode set [#7845](https://github.com/rubygems/rubygems/pull/7845)
25
+ - Fix generic platform gems getting incorrectly removed from lockfile [#7833](https://github.com/rubygems/rubygems/pull/7833)
26
+
27
+ ## Performance:
28
+
29
+ - Use `caller_locations` instead of splitting `caller` [#7708](https://github.com/rubygems/rubygems/pull/7708)
30
+
31
+ # 2.5.15 (July 9, 2024)
32
+
33
+ ## Enhancements:
34
+
35
+ - Support `--no-test`, `--no-ci`, and `--no-linter` options [#7780](https://github.com/rubygems/rubygems/pull/7780)
36
+ - Allow bundle command in new gems with invalid metadata [#7707](https://github.com/rubygems/rubygems/pull/7707)
37
+
38
+ ## Bug fixes:
39
+
40
+ - Protect creating RubyGems binstubs with a file lock [#7841](https://github.com/rubygems/rubygems/pull/7841)
41
+ - Only allow valid values for `--test`, `--ci`, and `--linter` options [#7801](https://github.com/rubygems/rubygems/pull/7801)
42
+ - Fix `bundle lock --add-platform <current_platform>` doing nothing [#7803](https://github.com/rubygems/rubygems/pull/7803)
43
+ - Print a proper error when bin dir does not have writable permission bit [#7794](https://github.com/rubygems/rubygems/pull/7794)
44
+
45
+ ## Documentation:
46
+
47
+ - Regenerate bundler docs for June 2024 [#7787](https://github.com/rubygems/rubygems/pull/7787)
48
+
49
+ # 2.5.14 (June 21, 2024)
50
+
51
+ ## Bug fixes:
52
+
53
+ - Fix credentials being re-added when re-resolving without a full unlock [#7767](https://github.com/rubygems/rubygems/pull/7767)
54
+ - Fix `bundle update <gem_name>` edge case [#7770](https://github.com/rubygems/rubygems/pull/7770)
55
+ - Fix `bundle fund` when the gemfile contains optional groups [#7758](https://github.com/rubygems/rubygems/pull/7758)
56
+
57
+ # 2.5.13 (June 14, 2024)
58
+
59
+ ## Bug fixes:
60
+
61
+ - Fix funding metadata not being printed in some situations [#7746](https://github.com/rubygems/rubygems/pull/7746)
62
+ - Make sure to not re-resolve when a not fully specific local platform is locked [#7751](https://github.com/rubygems/rubygems/pull/7751)
63
+ - Don't print bug report template when bin dir is not writable [#7748](https://github.com/rubygems/rubygems/pull/7748)
64
+
65
+ # 2.5.12 (June 13, 2024)
66
+
67
+ ## Enhancements:
68
+
69
+ - Keep credentials in lockfile if they are already there [#7720](https://github.com/rubygems/rubygems/pull/7720)
70
+ - Auto switch to locked bundler version even when using binstubs [#7719](https://github.com/rubygems/rubygems/pull/7719)
71
+ - Don't validate local gemspecs twice unnecessarily [#7725](https://github.com/rubygems/rubygems/pull/7725)
72
+ - Improve default gem handling by treating default gems as any other gem [#7673](https://github.com/rubygems/rubygems/pull/7673)
73
+
74
+ ## Bug fixes:
75
+
76
+ - Fix slow and incorrect resolution when adding `sorbet` to a Gemfile and the lockfile only includes "RUBY" in the platforms section [#7731](https://github.com/rubygems/rubygems/pull/7731)
77
+ - Fix duplicated config keys generated when `fallback_timeout` uri option is used [#7704](https://github.com/rubygems/rubygems/pull/7704)
78
+ - Fix `bundle exec` no longer working in truffleruby after explicit `require` of `pathname` was removed [#7703](https://github.com/rubygems/rubygems/pull/7703)
79
+ - Don't let `bundle config` report a path without a Gemfile as "local app" [#7687](https://github.com/rubygems/rubygems/pull/7687)
80
+
81
+ ## Documentation:
82
+
83
+ - Clarify BUNDLE_USER_CONFIG is a file [#7668](https://github.com/rubygems/rubygems/pull/7668)
84
+
85
+ # 2.5.11 (May 28, 2024)
86
+
87
+ ## Deprecations:
88
+
89
+ - Deprecate Bundler constants [#7653](https://github.com/rubygems/rubygems/pull/7653)
90
+
91
+ ## Enhancements:
92
+
93
+ - Bump `bundle gem` generated COC to Contributor Covenant 2.1 [#7692](https://github.com/rubygems/rubygems/pull/7692)
94
+ - Retry a full clone when git server does not support shallow capabilities [#7649](https://github.com/rubygems/rubygems/pull/7649)
95
+
96
+ ## Bug fixes:
97
+
98
+ - Fix regression when caching gems from secondary sources [#7659](https://github.com/rubygems/rubygems/pull/7659)
99
+ - Fix error when Bundler installation is corrupted [#7642](https://github.com/rubygems/rubygems/pull/7642)
100
+ - Fix crash caused by RubyGems `require` gem activation logic running before Bundler can properly register its own monkeypatches [#7647](https://github.com/rubygems/rubygems/pull/7647)
101
+
102
+ ## Performance:
103
+
104
+ - Update cache checksums to decrease string allocations [#7637](https://github.com/rubygems/rubygems/pull/7637)
105
+ - Fix performance regression in applications with a local cache [#7680](https://github.com/rubygems/rubygems/pull/7680)
106
+
107
+ ## Documentation:
108
+
109
+ - Recommend `bin/rake` over `rake` in contributing docs [#7648](https://github.com/rubygems/rubygems/pull/7648)
110
+ - Monthly man update for May 2024 [#7640](https://github.com/rubygems/rubygems/pull/7640)
111
+ - Clarify Bundler support policy [#7633](https://github.com/rubygems/rubygems/pull/7633)
112
+
113
+ # 2.5.10 (May 3, 2024)
114
+
115
+ ## Security:
116
+
117
+ - Never write credentials to lockfiles [#7560](https://github.com/rubygems/rubygems/pull/7560)
118
+
119
+ ## Enhancements:
120
+
121
+ - Add auto_install support to require "bundler/setup" [#6561](https://github.com/rubygems/rubygems/pull/6561)
122
+ - Add `--glob` flag to `bundle add` [#7557](https://github.com/rubygems/rubygems/pull/7557)
123
+
124
+ ## Bug fixes:
125
+
126
+ - Make sure `bundle update <specific_gems>` can always update to the latest resolvable version of each requested gem [#7558](https://github.com/rubygems/rubygems/pull/7558)
127
+ - Show better error when installed gemspecs are unreadable [#7603](https://github.com/rubygems/rubygems/pull/7603)
128
+ - Fix `bundle update` not working on an out of sync lockfile [#7607](https://github.com/rubygems/rubygems/pull/7607)
129
+ - Don't upcase Windows ENV before backing it up [#7574](https://github.com/rubygems/rubygems/pull/7574)
130
+ - Properly resolve aliases when `bundle help` is run [#7601](https://github.com/rubygems/rubygems/pull/7601)
131
+ - Fix issue installing gems with linux-musl variant on non musl linux [#7583](https://github.com/rubygems/rubygems/pull/7583)
132
+
133
+ ## Documentation:
134
+
135
+ - Clarify `bundle check` behaviour in docs [#7613](https://github.com/rubygems/rubygems/pull/7613)
136
+
1
137
  # 2.5.9 (April 12, 2024)
2
138
 
3
139
  ## Bug fixes:
@@ -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 = "2024-04-12".freeze
8
- @git_commit_sha = "4304697e0c".freeze
7
+ @built_at = "2024-08-01".freeze
8
+ @git_commit_sha = "74d92b2502".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -17,7 +17,7 @@ module Bundler
17
17
  begin
18
18
  definition.resolve_only_locally!
19
19
  not_installed = definition.missing_specs
20
- rescue GemNotFound, SolveFailure
20
+ rescue GemNotFound, GitError, SolveFailure
21
21
  Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
22
22
  Bundler.ui.warn "Install missing gems with `bundle install`."
23
23
  exit 1
@@ -16,7 +16,7 @@ module Bundler
16
16
  deps = if groups.any?
17
17
  Bundler.definition.dependencies_for(groups)
18
18
  else
19
- Bundler.definition.current_dependencies
19
+ Bundler.definition.requested_dependencies
20
20
  end
21
21
 
22
22
  fund_info = deps.each_with_object([]) do |dep, arr|
@@ -32,7 +32,6 @@ module Bundler
32
32
 
33
33
  validate_ext_name if @extension
34
34
  validate_rust_builder_rubygems_version if @extension == "rust"
35
- travis_removal_info
36
35
  end
37
36
 
38
37
  def run
@@ -80,7 +79,7 @@ module Bundler
80
79
  ensure_safe_gem_name(name, constant_array)
81
80
 
82
81
  templates = {
83
- "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
82
+ "Gemfile.tt" => Bundler.preferred_gemfile_name,
84
83
  "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
85
84
  "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
86
85
  "sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",
@@ -276,6 +275,7 @@ module Bundler
276
275
  end
277
276
 
278
277
  def ask_and_set_test_framework
278
+ return if skip?(:test)
279
279
  test_framework = options[:test] || Bundler.settings["gem.test"]
280
280
 
281
281
  if test_framework.to_s.empty?
@@ -301,6 +301,10 @@ module Bundler
301
301
  test_framework
302
302
  end
303
303
 
304
+ def skip?(option)
305
+ options.key?(option) && options[option].nil?
306
+ end
307
+
304
308
  def hint_text(setting)
305
309
  if Bundler.settings["gem.#{setting}"] == false
306
310
  "Your choice will only be applied to this gem."
@@ -311,6 +315,7 @@ module Bundler
311
315
  end
312
316
 
313
317
  def ask_and_set_ci
318
+ return if skip?(:ci)
314
319
  ci_template = options[:ci] || Bundler.settings["gem.ci"]
315
320
 
316
321
  if ci_template.to_s.empty?
@@ -342,6 +347,7 @@ module Bundler
342
347
  end
343
348
 
344
349
  def ask_and_set_linter
350
+ return if skip?(:linter)
345
351
  linter_template = options[:linter] || Bundler.settings["gem.linter"]
346
352
  linter_template = deprecated_rubocop_option if linter_template.nil?
347
353
 
@@ -448,19 +454,6 @@ module Bundler
448
454
  "1.3"
449
455
  end
450
456
 
451
- # TODO: remove at next minor release
452
- def travis_removal_info
453
- if options[:ci] == "travis"
454
- Bundler.ui.error "Support for Travis CI was removed from gem skeleton generator."
455
- exit 1
456
- end
457
-
458
- if Bundler.settings["gem.ci"] == "travis"
459
- Bundler.ui.error "Support for Travis CI was removed from gem skeleton generator, but it is present in bundle config. Please configure another provider using `bundle config set gem.ci SERVICE` (where SERVICE is one of github/gitlab/circle) or unset configuration using `bundle config unset gem.ci`."
460
- exit 1
461
- end
462
- end
463
-
464
457
  def validate_rust_builder_rubygems_version
465
458
  if Gem::Version.new(rust_builder_required_rubygems_version) > Gem.rubygems_version
466
459
  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."
@@ -14,7 +14,7 @@ module Bundler
14
14
 
15
15
  Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
16
16
 
17
- Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
17
+ Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
18
18
 
19
19
  # Disable color in deployment mode
20
20
  Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
data/lib/bundler/cli.rb CHANGED
@@ -5,6 +5,7 @@ require_relative "vendored_thor"
5
5
  module Bundler
6
6
  class CLI < Thor
7
7
  require_relative "cli/common"
8
+ require_relative "cli/install"
8
9
 
9
10
  package_name "Bundler"
10
11
 
@@ -64,12 +65,12 @@ module Bundler
64
65
  Bundler.reset_settings_and_root!
65
66
  end
66
67
 
67
- Bundler.self_manager.restart_with_locked_bundler_if_needed
68
+ Bundler.auto_switch
68
69
 
69
70
  Bundler.settings.set_command_option_if_given :retry, options[:retry]
70
71
 
71
72
  current_cmd = args.last[:current_command].name
72
- auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
73
+ Bundler.auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
73
74
  rescue UnknownArgumentError => e
74
75
  raise InvalidOption, e.message
75
76
  ensure
@@ -109,11 +110,13 @@ module Bundler
109
110
  default_task(Bundler.feature_flag.default_cli_command)
110
111
 
111
112
  class_option "no-color", type: :boolean, desc: "Disable colorization in output"
112
- class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
113
- desc: "Specify the number of times you wish to attempt network commands"
113
+ class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
114
+ desc: "Specify the number of times you wish to attempt network commands"
114
115
  class_option "verbose", type: :boolean, desc: "Enable verbose output mode", aliases: "-V"
115
116
 
116
117
  def help(cli = nil)
118
+ cli = self.class.all_aliases[cli] if self.class.all_aliases[cli]
119
+
117
120
  case cli
118
121
  when "gemfile" then command = "gemfile"
119
122
  when nil then command = "bundle"
@@ -257,15 +260,15 @@ module Bundler
257
260
  method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
258
261
  method_option "group", aliases: "-g", type: :array, banner: "Update a specific group"
259
262
  method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
260
- method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
261
- method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
263
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
264
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
262
265
  method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)"
263
266
  method_option "redownload", type: :boolean, aliases: "--force", banner: "Force downloading every gem."
264
267
  method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock"
265
268
  method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
266
- method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
267
- method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
268
- method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
269
+ method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
270
+ method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
271
+ method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
269
272
  method_option "pre", type: :boolean, banner: "Always choose the highest allowed version when updating gems, regardless of prerelease status"
270
273
  method_option "strict", type: :boolean, banner: "Do not allow any gem to be updated past latest --patch | --minor | --major"
271
274
  method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
@@ -347,6 +350,7 @@ module Bundler
347
350
  method_option "github", type: :string
348
351
  method_option "branch", type: :string
349
352
  method_option "ref", type: :string
353
+ method_option "glob", type: :string, banner: "The location of a dependency's .gemspec, expanded within Ruby (single quotes recommended)"
350
354
  method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it"
351
355
  method_option "optimistic", type: :boolean, banner: "Adds optimistic declaration of version to gem"
352
356
  method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem"
@@ -393,11 +397,11 @@ module Bundler
393
397
  end
394
398
 
395
399
  desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
396
- method_option "all", type: :boolean,
397
- default: Bundler.feature_flag.cache_all?,
398
- banner: "Include all sources (including path and git)."
400
+ method_option "all", type: :boolean,
401
+ default: Bundler.feature_flag.cache_all?,
402
+ banner: "Include all sources (including path and git)."
399
403
  method_option "all-platforms", type: :boolean, banner: "Include gems for all platforms present in the lockfile, not only the current one"
400
- method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
404
+ method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
401
405
  method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
402
406
  method_option "no-install", type: :boolean, banner: "Don't install the gems, only update the cache."
403
407
  method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
@@ -546,10 +550,13 @@ module Bundler
546
550
  method_option :rubocop, type: :boolean, desc: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
547
551
  method_option :changelog, type: :boolean, desc: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
548
552
  method_option :test, type: :string, lazy_default: Bundler.settings["gem.test"] || "", aliases: "-t", banner: "Use the specified test framework for your library",
553
+ enum: %w[rspec minitest test-unit],
549
554
  desc: "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
550
555
  method_option :ci, type: :string, lazy_default: Bundler.settings["gem.ci"] || "",
556
+ enum: %w[github gitlab circle],
551
557
  desc: "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
552
558
  method_option :linter, type: :string, lazy_default: Bundler.settings["gem.linter"] || "",
559
+ enum: %w[rubocop standard],
553
560
  desc: "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
554
561
  method_option :github_username, type: :string, default: Bundler.settings["gem.github_username"], banner: "Set your username on GitHub", desc: "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
555
562
 
@@ -598,7 +605,7 @@ module Bundler
598
605
  end
599
606
 
600
607
  desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", hide: true
601
- method_option "source", type: :string, banner: "Install gem from the given source"
608
+ method_option "source", type: :string, banner: "Install gem from the given source"
602
609
  method_option "group", type: :string, banner: "Install gem into a bundler group"
603
610
  def inject(name, version)
604
611
  SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
@@ -608,16 +615,16 @@ module Bundler
608
615
 
609
616
  desc "lock", "Creates a lockfile without installing"
610
617
  method_option "update", type: :array, lazy_default: true, banner: "ignore the existing lockfile, update all gems by default, or update list of given gems"
611
- method_option "local", type: :boolean, default: false, banner: "do not attempt to fetch remote gemspecs and use the local gem cache only"
612
- method_option "print", type: :boolean, default: false, banner: "print the lockfile to STDOUT instead of writing to the file system"
618
+ method_option "local", type: :boolean, default: false, banner: "do not attempt to fetch remote gemspecs and use the local gem cache only"
619
+ method_option "print", type: :boolean, default: false, banner: "print the lockfile to STDOUT instead of writing to the file system"
613
620
  method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
614
621
  method_option "lockfile", type: :string, default: nil, banner: "the path the lockfile should be written to"
615
622
  method_option "full-index", type: :boolean, default: false, banner: "Fall back to using the single-file index of all gems"
616
623
  method_option "add-platform", type: :array, default: [], banner: "Add a new platform to the lockfile"
617
- method_option "remove-platform", type: :array, default: [], banner: "Remove a platform from the lockfile"
618
- method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
619
- method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
620
- method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
624
+ method_option "remove-platform", type: :array, default: [], banner: "Remove a platform from the lockfile"
625
+ method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
626
+ method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
627
+ method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
621
628
  method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
622
629
  method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
623
630
  method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
@@ -682,7 +689,6 @@ module Bundler
682
689
  exec_used = args.index {|a| exec_commands.include? a }
683
690
 
684
691
  command = args.find {|a| bundler_commands.include? a }
685
- command = all_aliases[command] if all_aliases[command]
686
692
 
687
693
  if exec_used && help_used
688
694
  if exec_used + help_used == 1
@@ -735,26 +741,6 @@ module Bundler
735
741
 
736
742
  private
737
743
 
738
- # Automatically invoke `bundle install` and resume if
739
- # Bundler.settings[:auto_install] exists. This is set through config cmd
740
- # `bundle config set --global auto_install 1`.
741
- #
742
- # Note that this method `nil`s out the global Definition object, so it
743
- # should be called first, before you instantiate anything like an
744
- # `Installer` that'll keep a reference to the old one instead.
745
- def auto_install
746
- return unless Bundler.settings[:auto_install]
747
-
748
- begin
749
- Bundler.definition.specs
750
- rescue GemNotFound, GitError
751
- Bundler.ui.info "Automatically installing missing gems."
752
- Bundler.reset!
753
- invoke :install, []
754
- Bundler.reset!
755
- end
756
- end
757
-
758
744
  def current_command
759
745
  _, _, config = @_initializer
760
746
  config[:current_command]
@@ -784,13 +770,10 @@ module Bundler
784
770
 
785
771
  return unless SharedHelpers.md5_available?
786
772
 
787
- latest = Fetcher::CompactIndex.
788
- new(nil, Source::Rubygems::Remote.new(Gem::URI("https://rubygems.org")), nil, nil).
789
- send(:compact_index_client).
790
- instance_variable_get(:@cache).
791
- dependencies("bundler").
792
- map {|d| Gem::Version.new(d.first) }.
793
- max
773
+ require_relative "vendored_uri"
774
+ remote = Source::Rubygems::Remote.new(Gem::URI("https://rubygems.org"))
775
+ cache_path = Bundler.user_cache.join("compact_index", remote.cache_slug)
776
+ latest = Bundler::CompactIndexClient.new(cache_path).latest_version("bundler")
794
777
  return unless latest
795
778
 
796
779
  current = Gem::Version.new(VERSION)
@@ -7,114 +7,89 @@ module Bundler
7
7
  class Cache
8
8
  attr_reader :directory
9
9
 
10
- def initialize(directory)
10
+ def initialize(directory, fetcher = nil)
11
11
  @directory = Pathname.new(directory).expand_path
12
- info_roots.each {|dir| mkdir(dir) }
13
- mkdir(info_etag_root)
12
+ @updater = Updater.new(fetcher) if fetcher
13
+ @mutex = Thread::Mutex.new
14
+ @endpoints = Set.new
15
+
16
+ @info_root = mkdir("info")
17
+ @special_characters_info_root = mkdir("info-special-characters")
18
+ @info_etag_root = mkdir("info-etags")
14
19
  end
15
20
 
16
21
  def names
17
- lines(names_path)
22
+ fetch("names", names_path, names_etag_path)
18
23
  end
19
24
 
20
- def names_path
21
- directory.join("names")
25
+ def versions
26
+ fetch("versions", versions_path, versions_etag_path)
22
27
  end
23
28
 
24
- def names_etag_path
25
- directory.join("names.etag")
26
- end
29
+ def info(name, remote_checksum = nil)
30
+ path = info_path(name)
27
31
 
28
- def versions
29
- versions_by_name = Hash.new {|hash, key| hash[key] = [] }
30
- info_checksums_by_name = {}
31
-
32
- lines(versions_path).each do |line|
33
- name, versions_string, info_checksum = line.split(" ", 3)
34
- info_checksums_by_name[name] = info_checksum || ""
35
- versions_string.split(",") do |version|
36
- delete = version.delete_prefix!("-")
37
- version = version.split("-", 2).unshift(name)
38
- if delete
39
- versions_by_name[name].delete(version)
40
- else
41
- versions_by_name[name] << version
42
- end
43
- end
32
+ if remote_checksum && remote_checksum != SharedHelpers.checksum_for_file(path, :MD5)
33
+ fetch("info/#{name}", path, info_etag_path(name))
34
+ else
35
+ Bundler::CompactIndexClient.debug { "update skipped info/#{name} (#{remote_checksum ? "versions index checksum is nil" : "versions index checksum matches local"})" }
36
+ read(path)
44
37
  end
45
-
46
- [versions_by_name, info_checksums_by_name]
47
- end
48
-
49
- def versions_path
50
- directory.join("versions")
51
38
  end
52
39
 
53
- def versions_etag_path
54
- directory.join("versions.etag")
40
+ def reset!
41
+ @mutex.synchronize { @endpoints.clear }
55
42
  end
56
43
 
57
- def checksums
58
- checksums = {}
59
-
60
- lines(versions_path).each do |line|
61
- name, _, checksum = line.split(" ", 3)
62
- checksums[name] = checksum
63
- end
64
-
65
- checksums
66
- end
44
+ private
67
45
 
68
- def dependencies(name)
69
- lines(info_path(name)).map do |line|
70
- parse_gem(line)
71
- end
72
- end
46
+ def names_path = directory.join("names")
47
+ def names_etag_path = directory.join("names.etag")
48
+ def versions_path = directory.join("versions")
49
+ def versions_etag_path = directory.join("versions.etag")
73
50
 
74
51
  def info_path(name)
75
52
  name = name.to_s
53
+ # TODO: converge this into the info_root by hashing all filenames like info_etag_path
76
54
  if /[^a-z0-9_-]/.match?(name)
77
55
  name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
78
- info_roots.last.join(name)
56
+ @special_characters_info_root.join(name)
79
57
  else
80
- info_roots.first.join(name)
58
+ @info_root.join(name)
81
59
  end
82
60
  end
83
61
 
84
62
  def info_etag_path(name)
85
63
  name = name.to_s
86
- info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
64
+ @info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
87
65
  end
88
66
 
89
- private
90
-
91
- def mkdir(dir)
92
- SharedHelpers.filesystem_access(dir) do
93
- FileUtils.mkdir_p(dir)
67
+ def mkdir(name)
68
+ directory.join(name).tap do |dir|
69
+ SharedHelpers.filesystem_access(dir) do
70
+ FileUtils.mkdir_p(dir)
71
+ end
94
72
  end
95
73
  end
96
74
 
97
- def lines(path)
98
- return [] unless path.file?
99
- lines = SharedHelpers.filesystem_access(path, :read, &:read).split("\n")
100
- header = lines.index("---")
101
- header ? lines[header + 1..-1] : lines
102
- end
75
+ def fetch(remote_path, path, etag_path)
76
+ if already_fetched?(remote_path)
77
+ Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
78
+ else
79
+ Bundler::CompactIndexClient.debug { "fetching #{remote_path}" }
80
+ @updater&.update(remote_path, path, etag_path)
81
+ end
103
82
 
104
- def parse_gem(line)
105
- @dependency_parser ||= GemParser.new
106
- @dependency_parser.parse(line)
83
+ read(path)
107
84
  end
108
85
 
109
- def info_roots
110
- [
111
- directory.join("info"),
112
- directory.join("info-special-characters"),
113
- ]
86
+ def already_fetched?(remote_path)
87
+ @mutex.synchronize { !@endpoints.add?(remote_path) }
114
88
  end
115
89
 
116
- def info_etag_root
117
- directory.join("info-etags")
90
+ def read(path)
91
+ return unless path.file?
92
+ SharedHelpers.filesystem_access(path, :read, &:read)
118
93
  end
119
94
  end
120
95
  end