bundler 1.14.6 → 1.15.0.pre.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 (131) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +1 -1
  3. data/.rubocop_todo.yml +131 -43
  4. data/.travis.yml +5 -5
  5. data/CHANGELOG.md +52 -8
  6. data/CONTRIBUTING.md +10 -29
  7. data/README.md +13 -6
  8. data/Rakefile +4 -2
  9. data/bin/rubocop +1 -1
  10. data/doc/README.md +30 -0
  11. data/doc/TROUBLESHOOTING.md +64 -0
  12. data/doc/contributing/BUG_TRIAGE.md +36 -0
  13. data/doc/contributing/COMMUNITY.md +13 -0
  14. data/doc/contributing/GETTING_HELP.md +11 -0
  15. data/doc/contributing/HOW_YOU_CAN_HELP.md +27 -0
  16. data/doc/contributing/ISSUES.md +51 -0
  17. data/doc/contributing/README.md +38 -0
  18. data/doc/development/NEW_FEATURES.md +10 -0
  19. data/doc/development/PULL_REQUESTS.md +40 -0
  20. data/doc/development/README.md +19 -0
  21. data/doc/development/RELEASING.md +9 -0
  22. data/doc/development/SETUP.md +29 -0
  23. data/doc/documentation/README.md +29 -0
  24. data/doc/documentation/VISION.md +26 -0
  25. data/doc/documentation/WRITING.md +54 -0
  26. data/exe/bundle +4 -1
  27. data/lib/bundler.rb +20 -13
  28. data/lib/bundler/cli.rb +67 -3
  29. data/lib/bundler/cli/add.rb +26 -0
  30. data/lib/bundler/cli/config.rb +24 -6
  31. data/lib/bundler/cli/gem.rb +13 -8
  32. data/lib/bundler/cli/info.rb +51 -0
  33. data/lib/bundler/cli/inject.rb +8 -2
  34. data/lib/bundler/cli/install.rb +1 -1
  35. data/lib/bundler/cli/issue.rb +40 -0
  36. data/lib/bundler/cli/outdated.rb +16 -18
  37. data/lib/bundler/cli/pristine.rb +33 -0
  38. data/lib/bundler/cli/viz.rb +1 -1
  39. data/lib/bundler/definition.rb +64 -48
  40. data/lib/bundler/dsl.rb +6 -0
  41. data/lib/bundler/endpoint_specification.rb +3 -9
  42. data/lib/bundler/env.rb +3 -3
  43. data/lib/bundler/errors.rb +1 -1
  44. data/lib/bundler/fetcher/downloader.rb +3 -2
  45. data/lib/bundler/gem_helper.rb +5 -0
  46. data/lib/bundler/index.rb +9 -3
  47. data/lib/bundler/injector.rb +32 -11
  48. data/lib/bundler/installer.rb +1 -1
  49. data/lib/bundler/installer/parallel_installer.rb +15 -1
  50. data/lib/bundler/lazy_specification.rb +6 -0
  51. data/lib/bundler/lockfile_parser.rb +42 -34
  52. data/lib/bundler/mirror.rb +2 -0
  53. data/lib/bundler/plugin.rb +5 -1
  54. data/lib/bundler/plugin/api/source.rb +1 -1
  55. data/lib/bundler/plugin/index.rb +2 -0
  56. data/lib/bundler/remote_specification.rb +16 -7
  57. data/lib/bundler/resolver.rb +13 -3
  58. data/lib/bundler/rubygems_ext.rb +8 -3
  59. data/lib/bundler/rubygems_integration.rb +85 -36
  60. data/lib/bundler/runtime.rb +4 -1
  61. data/lib/bundler/settings.rb +2 -1
  62. data/lib/bundler/setup.rb +1 -1
  63. data/lib/bundler/shared_helpers.rb +26 -1
  64. data/lib/bundler/source.rb +17 -1
  65. data/lib/bundler/source/git.rb +16 -0
  66. data/lib/bundler/source/path.rb +13 -3
  67. data/lib/bundler/source/path/installer.rb +2 -2
  68. data/lib/bundler/source/rubygems.rb +5 -2
  69. data/lib/bundler/spec_set.rb +22 -13
  70. data/lib/bundler/stub_specification.rb +64 -2
  71. data/lib/bundler/templates/Executable +1 -1
  72. data/lib/bundler/templates/Executable.standalone +5 -5
  73. data/lib/bundler/templates/newgem/Gemfile.tt +2 -2
  74. data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
  75. data/lib/bundler/templates/newgem/README.md.tt +12 -6
  76. data/lib/bundler/templates/newgem/Rakefile.tt +5 -5
  77. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
  78. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
  79. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +6 -6
  80. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
  81. data/lib/bundler/templates/newgem/newgem.gemspec.tt +9 -9
  82. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +3 -0
  83. data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
  84. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
  85. data/lib/bundler/ui/shell.rb +9 -6
  86. data/lib/bundler/vendor/thor/lib/thor.rb +31 -23
  87. data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -22
  88. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  89. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  90. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
  91. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +8 -8
  92. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +23 -12
  93. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +10 -14
  94. data/lib/bundler/vendor/thor/lib/thor/base.rb +30 -30
  95. data/lib/bundler/vendor/thor/lib/thor/command.rb +9 -9
  96. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +9 -1
  97. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
  98. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
  99. data/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
  100. data/lib/bundler/vendor/thor/lib/thor/group.rb +12 -12
  101. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
  102. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
  103. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
  104. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +40 -19
  105. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +7 -5
  106. data/lib/bundler/vendor/thor/lib/thor/runner.rb +25 -25
  107. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  108. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +41 -26
  109. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
  110. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
  111. data/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  112. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  113. data/lib/bundler/version.rb +14 -1
  114. data/lib/bundler/version_ranges.rb +75 -0
  115. data/lib/bundler/worker.rb +2 -1
  116. data/man/bundle-check.ronn +26 -0
  117. data/man/bundle-clean.ronn +18 -0
  118. data/man/bundle-config.ronn +4 -1
  119. data/man/bundle-info.ronn +17 -0
  120. data/man/bundle-init.ronn +18 -0
  121. data/man/bundle-inject.ronn +22 -0
  122. data/man/bundle-open.ronn +19 -0
  123. data/man/bundle-show.ronn +20 -0
  124. data/man/bundle-update.ronn +5 -2
  125. data/man/bundle-viz.ronn +30 -0
  126. data/man/bundle.ronn +3 -0
  127. data/man/gemfile.5.ronn +24 -64
  128. data/task/release.rake +115 -0
  129. metadata +49 -5
  130. data/DEVELOPMENT.md +0 -150
  131. data/ISSUES.md +0 -117
@@ -0,0 +1,19 @@
1
+ # Development
2
+
3
+ So, you're ready to start contributing to Bundler! You've come to the right place. Here you'll find an overview of how to work on Bundler locally and a description of the process from code to release.
4
+
5
+ ##[Development setup](SETUP.md)
6
+
7
+ Guidelines for setting up your local development environment.
8
+
9
+ ##[Submitting pull requests](PULL_REQUESTS.md)
10
+
11
+ An overview of our preferred PR process, including how to run the test suite and what to expect when you submit code for review.
12
+
13
+ ##[Adding new features](NEW_FEATURES.md)
14
+
15
+ Guidelines for proposing and writing new features for Bundler.
16
+
17
+ ##[Releasing Bundler](RELEASING.md)
18
+
19
+ A broad-strokes overview of the release process adhered to by the Bundler core team.
@@ -0,0 +1,9 @@
1
+ # Releasing
2
+
3
+ _Release process documentation is in progress, see [PR 5252](https://github.com/bundler/bundler/pull/5252)._
4
+
5
+ ## Beta testing
6
+
7
+ Early releases require heavy testing, especially across various system setups. We :heart: testers, and are big fans of anyone who can run `gem install bundler --pre` and try out upcoming releases in their development and staging environments.
8
+
9
+ There may not always be prereleases or beta versions of Bundler. The Bundler team will tweet from the [@bundlerio account](http://twitter.com/bundlerio) when a prerelease or beta version becomes available. You are also always welcome to try checking out master and building a gem yourself if you want to try out the latest changes.
@@ -0,0 +1,29 @@
1
+ # Development setup
2
+
3
+ Bundler doesn't use a Gemfile to list development dependencies, because when we tried it we couldn't tell if we were awake or it was just another level of dreams. To work on Bundler, you'll probably want to do a couple of things.
4
+
5
+ 1. Install `groff-base` and `graphviz` packages using your package manager, e.g for ubuntu
6
+
7
+ $ sudo apt-get install graphviz groff-base -y
8
+
9
+ and for OS X (with brew installed)
10
+
11
+ $ brew install graphviz homebrew/dupes/groff
12
+
13
+ 2. Install Bundler's development dependencies
14
+
15
+ $ bin/rake spec:deps
16
+
17
+ 3. Run the test suite, to make sure things are working
18
+
19
+ $ bin/rake spec
20
+
21
+ 4. Set up a shell alias to run Bundler from your clone, e.g. a Bash alias:
22
+
23
+ $ alias dbundle='BUNDLE_TRAMPOLINE_DISABLE=1 ruby -I /path/to/bundler/lib /path/to/bundler/exe/bundle'
24
+
25
+ The `BUNDLE_TRAMPOLINE_DISABLE` environment variable ensures that the version of Bundler in `/path/to/bundler/lib` will be used. Without that environment setting, Bundler will automatically download, install, and run the version of Bundler listed in `Gemfile.lock`. With that set up, you can test changes you've made to Bundler by running `dbundle`, without interfering with the regular `bundle` command.
26
+
27
+ ## Debugging with `pry`
28
+
29
+ To dive into the code with Pry: `RUBYOPT=-rpry dbundle` to require pry and then run commands.
@@ -0,0 +1,29 @@
1
+ # Documentation
2
+
3
+ Code needs explanation, and sometimes those who know the code well have trouble explaining it to someone just getting into it. Because of that, we welcome documentation suggestions and patches from everyone, especially if they are brand new to using Bundler.
4
+
5
+ Currently, Bundler has two main sources of documentation:
6
+
7
+ 1. built-in `help` (including usage information and man pages)
8
+ 2. [Bundler documentation site](http://bundler.io)
9
+
10
+ If you have a suggestion or proposed change for [bundler.io](http://bundler.io), please open an issue or send a pull request to the [bundler-site](https://github.com/bundler/bundler-site) repository.
11
+
12
+ Not sure where to write documentation? In general, follow these guidelines:
13
+
14
+ * For an explanation of a specific Bundler command (ex: `bundle clean`): make changes to the man pages
15
+ * For longer explanations or usage guides (ex: "Using Bundler with Rails"): create new documentation within the [bundler-site](https://github.com/bundler/bundler-site) repository
16
+
17
+ If you are unsure where to begin, ping [@feministy](https://github.com/feministy) or [@indirect](https://github.com/indirect) in the Bundler Slack ([get an invite here](../contributing/GETTING_HELP.md)).
18
+
19
+ ## [Writing docs for man pages)](WRITING.md)
20
+
21
+ If you’d like to submit a patch to the man pages, you're in the right place! Details on editing and previewing changes to man pages can be found here.
22
+
23
+ ## [Documentation vision](VISION.md)
24
+
25
+ Just like Bundler, we have a grand plan (really, a wish list of sorts) for Bundler documentation. Preview our hopes and dreams for our documentation here.
26
+
27
+ ## Translations
28
+
29
+ We don't currently have any translations, but please reach out to us if you would like to help get this going.
@@ -0,0 +1,26 @@
1
+ # Documentation vision
2
+
3
+ Currently, documentation for using Bundler is spread across two places:
4
+
5
+ 1. built-in `help` (including usage information and man pages)
6
+ 2. [Bundler documentation site](http://bundler.io)
7
+
8
+ Additional documentation about using Bundler to publish gems can also be found on the [RubyGems guides](http://guides.rubygems.org/).
9
+
10
+ ## Goals
11
+
12
+ Bundler documentation should provide users with assistance:
13
+
14
+ 1. Installing Bundler
15
+ 2. Using Bundler to manage an application's dependencies
16
+ 3. Using Bundler to create, package, and publish gems
17
+
18
+ Our goal is to provide three types of documentation:
19
+
20
+ * High level overviews that provide topical guidance
21
+ * Step-by-step tutorials
22
+ * Command-specific reference material for the CLI
23
+
24
+ Additionally, this documentation should be readily available in a logical place and easy to follow.
25
+
26
+ Someday, we'd like to create deep-dive reference material about the inner workings of Bundler. However, while this is part of our overall vision for Bundler documentation, it is not the focus of our current work.
@@ -0,0 +1,54 @@
1
+ # Writing docs for man pages
2
+
3
+ A primary source of help for Bundler users are the man pages: the output printed when you run `bundle help` (or `bundler help`). These pages can be a little tricky to format and preview, but are pretty straightforward once you get the hang of it.
4
+
5
+ _Note: `bundler` and `bundle` may be used interchangeably in the CLI. This guide uses `bundle` because it's cuter._
6
+
7
+ ## What goes in man pages?
8
+
9
+ We use man pages for Bundler commands used in the CLI (command line interface). They can vary in length from large (see `bundle install`) to very short (see `bundle clean`).
10
+
11
+ To see a list of commands available in the Bundler CLI, type:
12
+
13
+ $ bundle help
14
+
15
+ Our goal is to have a man page for every command.
16
+
17
+ Don't see a man page for a command? Make a new page and send us a PR! We also welcome edits to existing pages.
18
+
19
+ ## Creating a new man page
20
+
21
+ To create a new man page, simply create a new `.ronn` file in the `man/` directory.
22
+
23
+ For example: to create a man page for the command `bundle cookies` (not a real command, sadly), I would create a file `man/bundle-cookies.ronn` and add my documentation there.
24
+
25
+ ## Formatting
26
+
27
+ Our man pages use ronn formatting, a combination of Markdown and standard man page conventions. It can be a little weird getting used to it at first, especially if you've used Markdown a lot.
28
+
29
+ [The ronn guide formatting guide](https://rtomayko.github.io/ronn/ronn.7.html) provides a good overview of the common types of formatting.
30
+
31
+ In general, make your page look like the other pages: utilize sections like `##OPTIONS` and formatting like code blocks and definition lists where appropriate.
32
+
33
+ If you're not sure if the formatting looks right, that's ok! Make a pull request with what you've got and we'll take a peek.
34
+
35
+ ## Previewing
36
+
37
+ To preview your changes as they will print out for Bundler users, you'll need to run a series of commands:
38
+
39
+ ```
40
+ $ rake spec:deps
41
+ $ rake man:build
42
+ $ man man/bundle-cookies.1
43
+ ```
44
+
45
+ If you make more changes to `bundle-cookies.ronn`, you'll need to run the `rake man:build` again before previewing.
46
+
47
+ ## Testing
48
+
49
+ We have tests for our documentation! The most important test file to run before you make your pull request is the one for the `help` command and another for documentation quality.
50
+
51
+ ```
52
+ $ rspec ./spec/commands/help_spec.rb
53
+ $ rspec ./spec/quality_spec.rb
54
+ ```
data/exe/bundle CHANGED
@@ -2,7 +2,10 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Exit cleanly from an early interrupt
5
- Signal.trap("INT") { exit 1 }
5
+ Signal.trap("INT") do
6
+ Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
7
+ exit 1
8
+ end
6
9
 
7
10
  update = "update".start_with?(ARGV.first || " ") && ARGV.find {|a| a.start_with?("--bundler") }
8
11
  update &&= update =~ /--bundler(?:=(.+))?/ && $1 || "> 0.a"
@@ -55,6 +55,7 @@ module Bundler
55
55
  autoload :StubSpecification, "bundler/stub_specification"
56
56
  autoload :UI, "bundler/ui"
57
57
  autoload :URICredentialsFilter, "bundler/uri_credentials_filter"
58
+ autoload :VersionRanges, "bundler/version_ranges"
58
59
 
59
60
  class << self
60
61
  attr_writer :bundle_path
@@ -412,20 +413,20 @@ EOF
412
413
 
413
414
  def load_gemspec_uncached(file, validate = false)
414
415
  path = Pathname.new(file)
415
- # Eval the gemspec from its parent directory, because some gemspecs
416
- # depend on "./" relative paths.
417
- SharedHelpers.chdir(path.dirname.to_s) do
418
- contents = path.read
419
- spec = if contents[0..2] == "---" # YAML header
420
- eval_yaml_gemspec(path, contents)
421
- else
416
+ contents = path.read
417
+ spec = if contents.start_with?("---") # YAML header
418
+ eval_yaml_gemspec(path, contents)
419
+ else
420
+ # Eval the gemspec from its parent directory, because some gemspecs
421
+ # depend on "./" relative paths.
422
+ SharedHelpers.chdir(path.dirname.to_s) do
422
423
  eval_gemspec(path, contents)
423
424
  end
424
- return unless spec
425
- spec.loaded_from = path.expand_path.to_s
426
- Bundler.rubygems.validate(spec) if validate
427
- spec
428
425
  end
426
+ return unless spec
427
+ spec.loaded_from = path.expand_path.to_s
428
+ Bundler.rubygems.validate(spec) if validate
429
+ spec
429
430
  end
430
431
 
431
432
  def clear_gemspec_cache
@@ -442,6 +443,12 @@ EOF
442
443
  end
443
444
 
444
445
  def reset!
446
+ reset_paths!
447
+ Plugin.reset!
448
+ reset_rubygems!
449
+ end
450
+
451
+ def reset_paths!
445
452
  @root = nil
446
453
  @settings = nil
447
454
  @definition = nil
@@ -451,9 +458,9 @@ EOF
451
458
  @bundle_path = nil
452
459
  @bin_path = nil
453
460
  @user_home = nil
461
+ end
454
462
 
455
- Plugin.reset!
456
-
463
+ def reset_rubygems!
457
464
  return unless defined?(@rubygems) && @rubygems
458
465
  rubygems.undo_replacements
459
466
  rubygems.reset
@@ -13,6 +13,7 @@ module Bundler
13
13
  Bundler.ui = UI::Shell.new
14
14
  raise e
15
15
  ensure
16
+ warn_on_outdated_bundler
16
17
  Bundler::SharedHelpers.print_major_deprecations!
17
18
  end
18
19
 
@@ -22,10 +23,12 @@ module Bundler
22
23
 
23
24
  def initialize(*args)
24
25
  super
25
- Bundler.reset!
26
26
 
27
27
  custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
28
- ENV["BUNDLE_GEMFILE"] = File.expand_path(custom_gemfile) if custom_gemfile && !custom_gemfile.empty?
28
+ if custom_gemfile && !custom_gemfile.empty?
29
+ ENV["BUNDLE_GEMFILE"] = File.expand_path(custom_gemfile)
30
+ Bundler.reset_paths!
31
+ end
29
32
 
30
33
  Bundler.settings[:retry] = options[:retry] if options[:retry]
31
34
 
@@ -84,6 +87,9 @@ module Bundler
84
87
  end
85
88
  end
86
89
 
90
+ # Ensure `bundle help --no-color` is valid
91
+ all_commands["help"].disable_class_options = false
92
+
87
93
  def self.handle_no_command_error(command, has_namespace = $thor_runner)
88
94
  if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
89
95
  return Bundler::Plugin.exec_command(command, ARGV[1..-1])
@@ -238,6 +244,13 @@ module Bundler
238
244
  # TODO: 2.0 remove `bundle list`
239
245
  map %w(list) => "show"
240
246
 
247
+ desc "info GEM [OPTIONS]", "Show information for the given gem"
248
+ method_option "path", :type => :boolean, :banner => "Print full path to gem"
249
+ def info(gem_name)
250
+ require "bundler/cli/info"
251
+ Info.new(options, gem_name).run
252
+ end
253
+
241
254
  desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem"
242
255
  long_desc <<-D
243
256
  Generate binstubs for executables in [GEM]. Binstubs are put into bin,
@@ -255,6 +268,19 @@ module Bundler
255
268
  Binstubs.new(options, gems).run
256
269
  end
257
270
 
271
+ desc "add GEM VERSION", "Add gem to Gemfile and run bundle install"
272
+ long_desc <<-D
273
+ Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step.
274
+ D
275
+ method_option "version", :aliases => "-v", :type => :string
276
+ method_option "group", :aliases => "-g", :type => :string
277
+ method_option "source", :aliases => "-s", :type => :string
278
+
279
+ def add(gem_name)
280
+ require "bundler/cli/add"
281
+ Add.new(options.dup, gem_name).run
282
+ end
283
+
258
284
  desc "outdated GEM [OPTIONS]", "list installed gems with newer versions available"
259
285
  long_desc <<-D
260
286
  Outdated lists the names and versions of gems that have a newer version available
@@ -347,6 +373,7 @@ module Bundler
347
373
  will show the current value, as well as any superceded values and
348
374
  where they were specified.
349
375
  D
376
+ method_option "parseable", :type => :boolean, :banner => "Use minimal formatting for more parseable output"
350
377
  def config(*args)
351
378
  require "bundler/cli/config"
352
379
  Config.new(options, args, self).run
@@ -461,10 +488,14 @@ module Bundler
461
488
  end
462
489
 
463
490
  desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile"
491
+ method_option "source", :type => :string, :banner =>
492
+ "Install gem from the given source"
493
+ method_option "group", :type => :string, :banner =>
494
+ "Install gem into a bundler group"
464
495
  def inject(name, version)
465
496
  SharedHelpers.major_deprecation "The `inject` command has been replaced by the `add` command"
466
497
  require "bundler/cli/inject"
467
- Inject.new(options, name, version).run
498
+ Inject.new(options.dup, name, version).run
468
499
  end
469
500
 
470
501
  desc "lock", "Creates a lockfile without installing"
@@ -517,6 +548,18 @@ module Bundler
517
548
  Doctor.new(options).run
518
549
  end
519
550
 
551
+ desc "issue", "Learn how to report an issue in Bundler"
552
+ def issue
553
+ require "bundler/cli/issue"
554
+ Issue.new.run
555
+ end
556
+
557
+ desc "pristine", "Restores installed gems to pristine condition from files located in the gem cache. Gem installed from a git repository will be issued `git checkout --force`."
558
+ def pristine
559
+ require "bundler/cli/pristine"
560
+ Pristine.new.run
561
+ end
562
+
520
563
  if Bundler.feature_flag.plugins?
521
564
  require "bundler/cli/plugin"
522
565
  desc "plugin SUBCOMMAND ...ARGS", "manage the bundler plugins"
@@ -579,5 +622,26 @@ module Bundler
579
622
  command.reject!(&:empty?)
580
623
  Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
581
624
  end
625
+
626
+ def self.warn_on_outdated_bundler
627
+ return if Bundler.settings[:disable_version_check]
628
+
629
+ latest = Fetcher::CompactIndex.
630
+ new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil).
631
+ send(:compact_index_client).
632
+ instance_variable_get(:@cache).
633
+ dependencies("bundler").
634
+ map {|d| Gem::Version.new(d.first) }.
635
+ max
636
+ return unless latest
637
+
638
+ current = Gem::Version.new(VERSION)
639
+ return if current >= latest
640
+
641
+ Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\nTo update, run `gem install bundler#{" --pre" if latest.prerelease?}`"
642
+ rescue
643
+ nil
644
+ end
645
+ private_class_method :warn_on_outdated_bundler
582
646
  end
583
647
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require "bundler/cli/common"
3
+
4
+ module Bundler
5
+ class CLI::Add
6
+ def initialize(options, gem_name)
7
+ @gem_name = gem_name
8
+ @options = options
9
+ @options[:group] = @options[:group].split(",").map(&:strip) if !@options[:group].nil? && !@options[:group].empty?
10
+ end
11
+
12
+ def run
13
+ version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip)
14
+
15
+ unless version.nil?
16
+ version.each do |v|
17
+ raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
18
+ end
19
+ end
20
+ dependency = Bundler::Dependency.new(@gem_name, version, @options)
21
+
22
+ Injector.inject([dependency], :conservative_versioning => @options[:version].nil?) # Perform conservative versioning only when version is not specified
23
+ Installer.install(Bundler.root, Bundler.definition)
24
+ end
25
+ end
26
+ end
@@ -33,6 +33,13 @@ module Bundler
33
33
  end
34
34
 
35
35
  if args.empty?
36
+ if options[:parseable]
37
+ if value = Bundler.settings[name]
38
+ Bundler.ui.info("#{name}=#{value}")
39
+ end
40
+ return
41
+ end
42
+
36
43
  confirm(name)
37
44
  return
38
45
  end
@@ -44,11 +51,20 @@ module Bundler
44
51
  private
45
52
 
46
53
  def confirm_all
47
- Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
48
- Bundler.settings.all.each do |setting|
49
- Bundler.ui.confirm "#{setting}"
50
- show_pretty_values_for(setting)
51
- Bundler.ui.confirm ""
54
+ if @options[:parseable]
55
+ thor.with_padding do
56
+ Bundler.settings.all.each do |setting|
57
+ val = Bundler.settings[setting]
58
+ Bundler.ui.info "#{setting}=#{val}"
59
+ end
60
+ end
61
+ else
62
+ Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
63
+ Bundler.settings.all.each do |setting|
64
+ Bundler.ui.confirm "#{setting}"
65
+ show_pretty_values_for(setting)
66
+ Bundler.ui.confirm ""
67
+ end
52
68
  end
53
69
  end
54
70
 
@@ -68,7 +84,9 @@ module Bundler
68
84
 
69
85
  def message
70
86
  locations = Bundler.settings.locations(name)
71
- if scope == "global"
87
+ if @options[:parseable]
88
+ "#{name}=#{new_value}" if new_value
89
+ elsif scope == "global"
72
90
  if locations[:local]
73
91
  "Your application has set #{name} to #{locations[:local].inspect}. " \
74
92
  "This will override the global value you are currently setting"