bundler 2.0.2

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 (303) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3111 -0
  3. data/LICENSE.md +23 -0
  4. data/README.md +63 -0
  5. data/bundler.gemspec +65 -0
  6. data/exe/bundle +31 -0
  7. data/exe/bundle_ruby +60 -0
  8. data/exe/bundler +4 -0
  9. data/lib/bundler.rb +567 -0
  10. data/lib/bundler/build_metadata.rb +53 -0
  11. data/lib/bundler/capistrano.rb +22 -0
  12. data/lib/bundler/cli.rb +792 -0
  13. data/lib/bundler/cli/add.rb +35 -0
  14. data/lib/bundler/cli/binstubs.rb +49 -0
  15. data/lib/bundler/cli/cache.rb +36 -0
  16. data/lib/bundler/cli/check.rb +38 -0
  17. data/lib/bundler/cli/clean.rb +25 -0
  18. data/lib/bundler/cli/common.rb +102 -0
  19. data/lib/bundler/cli/config.rb +119 -0
  20. data/lib/bundler/cli/console.rb +43 -0
  21. data/lib/bundler/cli/doctor.rb +140 -0
  22. data/lib/bundler/cli/exec.rb +105 -0
  23. data/lib/bundler/cli/gem.rb +252 -0
  24. data/lib/bundler/cli/info.rb +50 -0
  25. data/lib/bundler/cli/init.rb +47 -0
  26. data/lib/bundler/cli/inject.rb +60 -0
  27. data/lib/bundler/cli/install.rb +218 -0
  28. data/lib/bundler/cli/issue.rb +40 -0
  29. data/lib/bundler/cli/list.rb +58 -0
  30. data/lib/bundler/cli/lock.rb +63 -0
  31. data/lib/bundler/cli/open.rb +26 -0
  32. data/lib/bundler/cli/outdated.rb +266 -0
  33. data/lib/bundler/cli/package.rb +49 -0
  34. data/lib/bundler/cli/platform.rb +46 -0
  35. data/lib/bundler/cli/plugin.rb +24 -0
  36. data/lib/bundler/cli/pristine.rb +47 -0
  37. data/lib/bundler/cli/remove.rb +18 -0
  38. data/lib/bundler/cli/show.rb +75 -0
  39. data/lib/bundler/cli/update.rb +91 -0
  40. data/lib/bundler/cli/viz.rb +31 -0
  41. data/lib/bundler/compact_index_client.rb +109 -0
  42. data/lib/bundler/compact_index_client/cache.rb +118 -0
  43. data/lib/bundler/compact_index_client/updater.rb +116 -0
  44. data/lib/bundler/compatibility_guard.rb +13 -0
  45. data/lib/bundler/constants.rb +7 -0
  46. data/lib/bundler/current_ruby.rb +94 -0
  47. data/lib/bundler/definition.rb +995 -0
  48. data/lib/bundler/dep_proxy.rb +48 -0
  49. data/lib/bundler/dependency.rb +139 -0
  50. data/lib/bundler/deployment.rb +69 -0
  51. data/lib/bundler/deprecate.rb +44 -0
  52. data/lib/bundler/dsl.rb +615 -0
  53. data/lib/bundler/endpoint_specification.rb +141 -0
  54. data/lib/bundler/env.rb +149 -0
  55. data/lib/bundler/environment_preserver.rb +59 -0
  56. data/lib/bundler/errors.rb +158 -0
  57. data/lib/bundler/feature_flag.rb +75 -0
  58. data/lib/bundler/fetcher.rb +312 -0
  59. data/lib/bundler/fetcher/base.rb +52 -0
  60. data/lib/bundler/fetcher/compact_index.rb +126 -0
  61. data/lib/bundler/fetcher/dependency.rb +82 -0
  62. data/lib/bundler/fetcher/downloader.rb +84 -0
  63. data/lib/bundler/fetcher/index.rb +52 -0
  64. data/lib/bundler/friendly_errors.rb +131 -0
  65. data/lib/bundler/gem_helper.rb +217 -0
  66. data/lib/bundler/gem_helpers.rb +101 -0
  67. data/lib/bundler/gem_remote_fetcher.rb +43 -0
  68. data/lib/bundler/gem_tasks.rb +7 -0
  69. data/lib/bundler/gem_version_promoter.rb +190 -0
  70. data/lib/bundler/gemdeps.rb +29 -0
  71. data/lib/bundler/graph.rb +152 -0
  72. data/lib/bundler/index.rb +213 -0
  73. data/lib/bundler/injector.rb +253 -0
  74. data/lib/bundler/inline.rb +74 -0
  75. data/lib/bundler/installer.rb +318 -0
  76. data/lib/bundler/installer/gem_installer.rb +85 -0
  77. data/lib/bundler/installer/parallel_installer.rb +229 -0
  78. data/lib/bundler/installer/standalone.rb +53 -0
  79. data/lib/bundler/lazy_specification.rb +123 -0
  80. data/lib/bundler/lockfile_generator.rb +95 -0
  81. data/lib/bundler/lockfile_parser.rb +256 -0
  82. data/lib/bundler/match_platform.rb +24 -0
  83. data/lib/bundler/mirror.rb +223 -0
  84. data/lib/bundler/plugin.rb +294 -0
  85. data/lib/bundler/plugin/api.rb +81 -0
  86. data/lib/bundler/plugin/api/source.rb +306 -0
  87. data/lib/bundler/plugin/dsl.rb +53 -0
  88. data/lib/bundler/plugin/events.rb +61 -0
  89. data/lib/bundler/plugin/index.rb +165 -0
  90. data/lib/bundler/plugin/installer.rb +96 -0
  91. data/lib/bundler/plugin/installer/git.rb +38 -0
  92. data/lib/bundler/plugin/installer/rubygems.rb +27 -0
  93. data/lib/bundler/plugin/source_list.rb +27 -0
  94. data/lib/bundler/process_lock.rb +24 -0
  95. data/lib/bundler/psyched_yaml.rb +37 -0
  96. data/lib/bundler/remote_specification.rb +114 -0
  97. data/lib/bundler/resolver.rb +373 -0
  98. data/lib/bundler/resolver/spec_group.rb +106 -0
  99. data/lib/bundler/retry.rb +66 -0
  100. data/lib/bundler/ruby_dsl.rb +18 -0
  101. data/lib/bundler/ruby_version.rb +152 -0
  102. data/lib/bundler/rubygems_ext.rb +209 -0
  103. data/lib/bundler/rubygems_gem_installer.rb +99 -0
  104. data/lib/bundler/rubygems_integration.rb +915 -0
  105. data/lib/bundler/runtime.rb +322 -0
  106. data/lib/bundler/settings.rb +464 -0
  107. data/lib/bundler/settings/validator.rb +102 -0
  108. data/lib/bundler/setup.rb +28 -0
  109. data/lib/bundler/shared_helpers.rb +386 -0
  110. data/lib/bundler/similarity_detector.rb +63 -0
  111. data/lib/bundler/source.rb +94 -0
  112. data/lib/bundler/source/gemspec.rb +18 -0
  113. data/lib/bundler/source/git.rb +329 -0
  114. data/lib/bundler/source/git/git_proxy.rb +262 -0
  115. data/lib/bundler/source/metadata.rb +62 -0
  116. data/lib/bundler/source/path.rb +249 -0
  117. data/lib/bundler/source/path/installer.rb +74 -0
  118. data/lib/bundler/source/rubygems.rb +539 -0
  119. data/lib/bundler/source/rubygems/remote.rb +69 -0
  120. data/lib/bundler/source_list.rb +186 -0
  121. data/lib/bundler/spec_set.rb +208 -0
  122. data/lib/bundler/ssl_certs/.document +1 -0
  123. data/lib/bundler/ssl_certs/certificate_manager.rb +66 -0
  124. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  125. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  126. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  127. data/lib/bundler/stub_specification.rb +108 -0
  128. data/lib/bundler/templates/.document +1 -0
  129. data/lib/bundler/templates/Executable +29 -0
  130. data/lib/bundler/templates/Executable.bundler +105 -0
  131. data/lib/bundler/templates/Executable.standalone +14 -0
  132. data/lib/bundler/templates/Gemfile +7 -0
  133. data/lib/bundler/templates/gems.rb +8 -0
  134. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
  135. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  136. data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  137. data/lib/bundler/templates/newgem/README.md.tt +47 -0
  138. data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
  139. data/lib/bundler/templates/newgem/bin/console.tt +14 -0
  140. data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  141. data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  142. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  143. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  144. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  145. data/lib/bundler/templates/newgem/gitignore.tt +20 -0
  146. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +13 -0
  147. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  148. data/lib/bundler/templates/newgem/newgem.gemspec.tt +50 -0
  149. data/lib/bundler/templates/newgem/rspec.tt +3 -0
  150. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +9 -0
  151. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -0
  152. data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
  153. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +8 -0
  154. data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
  155. data/lib/bundler/ui.rb +9 -0
  156. data/lib/bundler/ui/rg_proxy.rb +19 -0
  157. data/lib/bundler/ui/shell.rb +146 -0
  158. data/lib/bundler/ui/silent.rb +69 -0
  159. data/lib/bundler/uri_credentials_filter.rb +37 -0
  160. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1741 -0
  161. data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
  162. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
  163. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  164. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  165. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
  166. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +223 -0
  167. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
  168. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
  169. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
  170. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
  171. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
  172. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
  173. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
  174. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
  175. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +136 -0
  176. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
  177. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
  178. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +101 -0
  179. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +67 -0
  180. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
  181. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +46 -0
  182. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
  183. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +27 -0
  184. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1233 -0
  185. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +129 -0
  186. data/lib/bundler/vendor/thor/lib/thor.rb +509 -0
  187. data/lib/bundler/vendor/thor/lib/thor/actions.rb +331 -0
  188. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +104 -0
  189. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +60 -0
  190. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
  191. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
  192. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
  193. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
  194. data/lib/bundler/vendor/thor/lib/thor/base.rb +678 -0
  195. data/lib/bundler/vendor/thor/lib/thor/command.rb +135 -0
  196. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
  197. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  198. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
  199. data/lib/bundler/vendor/thor/lib/thor/error.rb +114 -0
  200. data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
  201. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +177 -0
  202. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  203. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
  204. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  205. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  206. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +70 -0
  207. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  208. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +146 -0
  209. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +226 -0
  210. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
  211. data/lib/bundler/vendor/thor/lib/thor/runner.rb +324 -0
  212. data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  213. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +482 -0
  214. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
  215. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
  216. data/lib/bundler/vendor/thor/lib/thor/util.rb +268 -0
  217. data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  218. data/lib/bundler/vendored_fileutils.rb +9 -0
  219. data/lib/bundler/vendored_molinillo.rb +4 -0
  220. data/lib/bundler/vendored_persistent.rb +52 -0
  221. data/lib/bundler/vendored_thor.rb +8 -0
  222. data/lib/bundler/version.rb +28 -0
  223. data/lib/bundler/version_ranges.rb +76 -0
  224. data/lib/bundler/vlad.rb +17 -0
  225. data/lib/bundler/worker.rb +106 -0
  226. data/lib/bundler/yaml_serializer.rb +90 -0
  227. data/man/bundle-add.1 +58 -0
  228. data/man/bundle-add.1.txt +52 -0
  229. data/man/bundle-add.ronn +40 -0
  230. data/man/bundle-binstubs.1 +40 -0
  231. data/man/bundle-binstubs.1.txt +48 -0
  232. data/man/bundle-binstubs.ronn +43 -0
  233. data/man/bundle-check.1 +31 -0
  234. data/man/bundle-check.1.txt +33 -0
  235. data/man/bundle-check.ronn +26 -0
  236. data/man/bundle-clean.1 +24 -0
  237. data/man/bundle-clean.1.txt +26 -0
  238. data/man/bundle-clean.ronn +18 -0
  239. data/man/bundle-config.1 +497 -0
  240. data/man/bundle-config.1.txt +529 -0
  241. data/man/bundle-config.ronn +397 -0
  242. data/man/bundle-doctor.1 +44 -0
  243. data/man/bundle-doctor.1.txt +44 -0
  244. data/man/bundle-doctor.ronn +33 -0
  245. data/man/bundle-exec.1 +165 -0
  246. data/man/bundle-exec.1.txt +178 -0
  247. data/man/bundle-exec.ronn +152 -0
  248. data/man/bundle-gem.1 +80 -0
  249. data/man/bundle-gem.1.txt +91 -0
  250. data/man/bundle-gem.ronn +78 -0
  251. data/man/bundle-info.1 +20 -0
  252. data/man/bundle-info.1.txt +21 -0
  253. data/man/bundle-info.ronn +17 -0
  254. data/man/bundle-init.1 +25 -0
  255. data/man/bundle-init.1.txt +34 -0
  256. data/man/bundle-init.ronn +29 -0
  257. data/man/bundle-inject.1 +33 -0
  258. data/man/bundle-inject.1.txt +32 -0
  259. data/man/bundle-inject.ronn +22 -0
  260. data/man/bundle-install.1 +308 -0
  261. data/man/bundle-install.1.txt +396 -0
  262. data/man/bundle-install.ronn +378 -0
  263. data/man/bundle-list.1 +50 -0
  264. data/man/bundle-list.1.txt +43 -0
  265. data/man/bundle-list.ronn +33 -0
  266. data/man/bundle-lock.1 +84 -0
  267. data/man/bundle-lock.1.txt +93 -0
  268. data/man/bundle-lock.ronn +94 -0
  269. data/man/bundle-open.1 +32 -0
  270. data/man/bundle-open.1.txt +29 -0
  271. data/man/bundle-open.ronn +19 -0
  272. data/man/bundle-outdated.1 +155 -0
  273. data/man/bundle-outdated.1.txt +131 -0
  274. data/man/bundle-outdated.ronn +111 -0
  275. data/man/bundle-package.1 +55 -0
  276. data/man/bundle-package.1.txt +79 -0
  277. data/man/bundle-package.ronn +72 -0
  278. data/man/bundle-platform.1 +61 -0
  279. data/man/bundle-platform.1.txt +57 -0
  280. data/man/bundle-platform.ronn +42 -0
  281. data/man/bundle-pristine.1 +34 -0
  282. data/man/bundle-pristine.1.txt +44 -0
  283. data/man/bundle-pristine.ronn +34 -0
  284. data/man/bundle-remove.1 +31 -0
  285. data/man/bundle-remove.1.txt +34 -0
  286. data/man/bundle-remove.ronn +23 -0
  287. data/man/bundle-show.1 +23 -0
  288. data/man/bundle-show.1.txt +27 -0
  289. data/man/bundle-show.ronn +21 -0
  290. data/man/bundle-update.1 +394 -0
  291. data/man/bundle-update.1.txt +391 -0
  292. data/man/bundle-update.ronn +350 -0
  293. data/man/bundle-viz.1 +39 -0
  294. data/man/bundle-viz.1.txt +39 -0
  295. data/man/bundle-viz.ronn +30 -0
  296. data/man/bundle.1 +136 -0
  297. data/man/bundle.1.txt +116 -0
  298. data/man/bundle.ronn +111 -0
  299. data/man/gemfile.5 +689 -0
  300. data/man/gemfile.5.ronn +521 -0
  301. data/man/gemfile.5.txt +653 -0
  302. data/man/index.txt +25 -0
  303. metadata +463 -0
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ # Represents metadata from when the Bundler gem was built.
5
+ module BuildMetadata
6
+ # begin ivars
7
+ @built_at = "2019-06-13".freeze
8
+ @git_commit_sha = "496bca538".freeze
9
+ @release = true
10
+ # end ivars
11
+
12
+ # A hash representation of the build metadata.
13
+ def self.to_h
14
+ {
15
+ "Built At" => built_at,
16
+ "Git SHA" => git_commit_sha,
17
+ "Released Version" => release?,
18
+ }
19
+ end
20
+
21
+ # A string representing the date the bundler gem was built.
22
+ def self.built_at
23
+ @built_at ||= Time.now.utc.strftime("%Y-%m-%d").freeze
24
+ end
25
+
26
+ # The SHA for the git commit the bundler gem was built from.
27
+ def self.git_commit_sha
28
+ return @git_commit_sha if @git_commit_sha
29
+
30
+ # If Bundler has been installed without its .git directory and without a
31
+ # commit instance variable then we can't determine its commits SHA.
32
+ git_dir = File.join(File.expand_path("../../..", __FILE__), ".git")
33
+ if File.directory?(git_dir)
34
+ return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
35
+ end
36
+
37
+ # If Bundler is a submodule in RubyGems, get the submodule commit
38
+ git_sub_dir = File.join(File.expand_path("../../../..", __FILE__), ".git")
39
+ if File.directory?(git_sub_dir)
40
+ return @git_commit_sha = Dir.chdir(git_sub_dir) do
41
+ `git ls-tree --abbrev=8 HEAD bundler`.split(/\s/).fetch(2, "").strip.freeze
42
+ end
43
+ end
44
+
45
+ @git_commit_sha ||= "unknown"
46
+ end
47
+
48
+ # Whether this is an official release build of Bundler.
49
+ def self.release?
50
+ @release
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/shared_helpers"
4
+ Bundler::SharedHelpers.major_deprecation 3,
5
+ "The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler"
6
+
7
+ # Capistrano task for Bundler.
8
+ #
9
+ # Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
10
+ # Bundler will be activated after each new deployment.
11
+ require "bundler/deployment"
12
+ require "capistrano/version"
13
+
14
+ if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
15
+ raise "For Capistrano 3.x integration, please use http://github.com/capistrano/bundler"
16
+ end
17
+
18
+ Capistrano::Configuration.instance(:must_exist).load do
19
+ before "deploy:finalize_update", "bundle:install"
20
+ Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
21
+ set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
22
+ end
@@ -0,0 +1,792 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler"
4
+ require "bundler/vendored_thor"
5
+
6
+ module Bundler
7
+ class CLI < Thor
8
+ require "bundler/cli/common"
9
+
10
+ package_name "Bundler"
11
+
12
+ AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
13
+ PARSEABLE_COMMANDS = %w[
14
+ check config help exec platform show version
15
+ ].freeze
16
+
17
+ def self.start(*)
18
+ super
19
+ rescue Exception => e
20
+ Bundler.ui = UI::Shell.new
21
+ raise e
22
+ ensure
23
+ Bundler::SharedHelpers.print_major_deprecations!
24
+ end
25
+
26
+ def self.dispatch(*)
27
+ super do |i|
28
+ i.send(:print_command)
29
+ i.send(:warn_on_outdated_bundler)
30
+ end
31
+ end
32
+
33
+ def initialize(*args)
34
+ super
35
+
36
+ custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
37
+ if custom_gemfile && !custom_gemfile.empty?
38
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile)
39
+ Bundler.reset_paths!
40
+ end
41
+
42
+ Bundler.settings.set_command_option_if_given :retry, options[:retry]
43
+
44
+ current_cmd = args.last[:current_command].name
45
+ auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
46
+ rescue UnknownArgumentError => e
47
+ raise InvalidOption, e.message
48
+ ensure
49
+ self.options ||= {}
50
+ unprinted_warnings = Bundler.ui.unprinted_warnings
51
+ Bundler.ui = UI::Shell.new(options)
52
+ Bundler.ui.level = "debug" if options["verbose"]
53
+ unprinted_warnings.each {|w| Bundler.ui.warn(w) }
54
+
55
+ if ENV["RUBYGEMS_GEMDEPS"] && !ENV["RUBYGEMS_GEMDEPS"].empty?
56
+ Bundler.ui.warn(
57
+ "The RUBYGEMS_GEMDEPS environment variable is set. This enables RubyGems' " \
58
+ "experimental Gemfile mode, which may conflict with Bundler and cause unexpected errors. " \
59
+ "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true
60
+ )
61
+ end
62
+ end
63
+
64
+ def self.deprecated_option(*args, &blk)
65
+ return if Bundler.feature_flag.forget_cli_options?
66
+ method_option(*args, &blk)
67
+ end
68
+
69
+ check_unknown_options!(:except => [:config, :exec])
70
+ stop_on_unknown_option! :exec
71
+
72
+ desc "cli_help", "Prints a summary of bundler commands", :hide => true
73
+ def cli_help
74
+ version
75
+ Bundler.ui.info "\n"
76
+
77
+ primary_commands = ["install", "update",
78
+ Bundler.feature_flag.cache_command_is_package? ? "cache" : "package",
79
+ "exec", "config", "help"]
80
+
81
+ list = self.class.printable_commands(true)
82
+ by_name = list.group_by {|name, _message| name.match(/^bundle (\w+)/)[1] }
83
+ utilities = by_name.keys.sort - primary_commands
84
+ primary_commands.map! {|name| (by_name[name] || raise("no primary command #{name}")).first }
85
+ utilities.map! {|name| by_name[name].first }
86
+
87
+ shell.say "Bundler commands:\n\n"
88
+
89
+ shell.say " Primary commands:\n"
90
+ shell.print_table(primary_commands, :indent => 4, :truncate => true)
91
+ shell.say
92
+ shell.say " Utilities:\n"
93
+ shell.print_table(utilities, :indent => 4, :truncate => true)
94
+ shell.say
95
+ self.class.send(:class_options_help, shell)
96
+ end
97
+ default_task(Bundler.feature_flag.default_cli_command)
98
+
99
+ class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
100
+ class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
101
+ :desc => "Specify the number of times you wish to attempt network commands"
102
+ class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
103
+
104
+ def help(cli = nil)
105
+ case cli
106
+ when "gemfile" then command = "gemfile"
107
+ when nil then command = "bundle"
108
+ else command = "bundle-#{cli}"
109
+ end
110
+
111
+ man_path = File.expand_path("../../../man", __FILE__)
112
+ man_pages = Hash[Dir.glob(File.join(man_path, "*")).grep(/.*\.\d*\Z/).collect do |f|
113
+ [File.basename(f, ".*"), f]
114
+ end]
115
+
116
+ if man_pages.include?(command)
117
+ if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
118
+ Kernel.exec "man #{man_pages[command]}"
119
+ else
120
+ puts File.read("#{man_path}/#{File.basename(man_pages[command])}.txt")
121
+ end
122
+ elsif command_path = Bundler.which("bundler-#{cli}")
123
+ Kernel.exec(command_path, "--help")
124
+ else
125
+ super
126
+ end
127
+ end
128
+
129
+ def self.handle_no_command_error(command, has_namespace = $thor_runner)
130
+ if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
131
+ return Bundler::Plugin.exec_command(command, ARGV[1..-1])
132
+ end
133
+
134
+ return super unless command_path = Bundler.which("bundler-#{command}")
135
+
136
+ Kernel.exec(command_path, *ARGV[1..-1])
137
+ end
138
+
139
+ desc "init [OPTIONS]", "Generates a Gemfile into the current working directory"
140
+ long_desc <<-D
141
+ Init generates a default Gemfile in the current working directory. When adding a
142
+ Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
143
+ dependency listed in the gemspec file to the newly created Gemfile.
144
+ D
145
+ deprecated_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
146
+ def init
147
+ require "bundler/cli/init"
148
+ Init.new(options.dup).run
149
+ end
150
+
151
+ desc "check [OPTIONS]", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
152
+ long_desc <<-D
153
+ Check searches the local machine for each of the gems requested in the Gemfile. If
154
+ all gems are found, Bundler prints a success message and exits with a status of 0.
155
+ If not, the first missing gem is listed and Bundler exits status 1.
156
+ D
157
+ method_option "dry-run", :type => :boolean, :default => false, :banner =>
158
+ "Lock the Gemfile"
159
+ method_option "gemfile", :type => :string, :banner =>
160
+ "Use the specified gemfile instead of Gemfile"
161
+ method_option "path", :type => :string, :banner =>
162
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
163
+ map "c" => "check"
164
+ def check
165
+ require "bundler/cli/check"
166
+ Check.new(options).run
167
+ end
168
+
169
+ desc "remove [GEM [GEM ...]]", "Removes gems from the Gemfile"
170
+ long_desc <<-D
171
+ Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
172
+ D
173
+ method_option "install", :type => :boolean, :banner =>
174
+ "Runs 'bundle install' after removing the gems from the Gemfile"
175
+ def remove(*gems)
176
+ require "bundler/cli/remove"
177
+ Remove.new(gems, options).run
178
+ end
179
+
180
+ desc "install [OPTIONS]", "Install the current environment to the system"
181
+ long_desc <<-D
182
+ Install will install all of the gems in the current bundle, making them available
183
+ for use. In a freshly checked out repository, this command will give you the same
184
+ gem versions as the last person who updated the Gemfile and ran `bundle update`.
185
+
186
+ Passing [DIR] to install (e.g. vendor) will cause the unpacked gems to be installed
187
+ into the [DIR] directory rather than into system gems.
188
+
189
+ If the bundle has already been installed, bundler will tell you so and then exit.
190
+ D
191
+ deprecated_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
192
+ "Generate bin stubs for bundled gems to ./bin"
193
+ deprecated_option "clean", :type => :boolean, :banner =>
194
+ "Run bundle clean automatically after install"
195
+ deprecated_option "deployment", :type => :boolean, :banner =>
196
+ "Install using defaults tuned for deployment environments"
197
+ deprecated_option "frozen", :type => :boolean, :banner =>
198
+ "Do not allow the Gemfile.lock to be updated after this install"
199
+ method_option "full-index", :type => :boolean, :banner =>
200
+ "Fall back to using the single-file index of all gems"
201
+ method_option "gemfile", :type => :string, :banner =>
202
+ "Use the specified gemfile instead of Gemfile"
203
+ method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
204
+ "Specify the number of jobs to run in parallel"
205
+ method_option "local", :type => :boolean, :banner =>
206
+ "Do not attempt to fetch gems remotely and use the gem cache instead"
207
+ deprecated_option "no-cache", :type => :boolean, :banner =>
208
+ "Don't update the existing gem cache."
209
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
210
+ "Force downloading every gem."
211
+ deprecated_option "no-prune", :type => :boolean, :banner =>
212
+ "Don't remove stale gems from the cache."
213
+ deprecated_option "path", :type => :string, :banner =>
214
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
215
+ method_option "quiet", :type => :boolean, :banner =>
216
+ "Only output warnings and errors."
217
+ deprecated_option "shebang", :type => :string, :banner =>
218
+ "Specify a different shebang executable name than the default (usually 'ruby')"
219
+ method_option "standalone", :type => :array, :lazy_default => [], :banner =>
220
+ "Make a bundle that can work without the Bundler runtime"
221
+ deprecated_option "system", :type => :boolean, :banner =>
222
+ "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
223
+ method_option "trust-policy", :alias => "P", :type => :string, :banner =>
224
+ "Gem trust policy (like gem install -P). Must be one of " +
225
+ Bundler.rubygems.security_policy_keys.join("|")
226
+ deprecated_option "without", :type => :array, :banner =>
227
+ "Exclude gems that are part of the specified named group."
228
+ deprecated_option "with", :type => :array, :banner =>
229
+ "Include gems that are part of the specified named group."
230
+ map "i" => "install"
231
+ def install
232
+ SharedHelpers.major_deprecation(3, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
233
+ require "bundler/cli/install"
234
+ Bundler.settings.temporary(:no_install => false) do
235
+ Install.new(options.dup).run
236
+ end
237
+ end
238
+
239
+ desc "update [OPTIONS]", "Update the current environment"
240
+ long_desc <<-D
241
+ Update will install the newest versions of the gems listed in the Gemfile. Use
242
+ update when you have changed the Gemfile, or if you want to get the newest
243
+ possible versions of the gems in the bundle.
244
+ D
245
+ method_option "full-index", :type => :boolean, :banner =>
246
+ "Fall back to using the single-file index of all gems"
247
+ method_option "gemfile", :type => :string, :banner =>
248
+ "Use the specified gemfile instead of Gemfile"
249
+ method_option "group", :aliases => "-g", :type => :array, :banner =>
250
+ "Update a specific group"
251
+ method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
252
+ "Specify the number of jobs to run in parallel"
253
+ method_option "local", :type => :boolean, :banner =>
254
+ "Do not attempt to fetch gems remotely and use the gem cache instead"
255
+ method_option "quiet", :type => :boolean, :banner =>
256
+ "Only output warnings and errors."
257
+ method_option "source", :type => :array, :banner =>
258
+ "Update a specific source (and all gems associated with it)"
259
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
260
+ "Force downloading every gem."
261
+ method_option "ruby", :type => :boolean, :banner =>
262
+ "Update ruby specified in Gemfile.lock"
263
+ method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
264
+ "Update the locked version of bundler"
265
+ method_option "patch", :type => :boolean, :banner =>
266
+ "Prefer updating only to next patch version"
267
+ method_option "minor", :type => :boolean, :banner =>
268
+ "Prefer updating only to next minor version"
269
+ method_option "major", :type => :boolean, :banner =>
270
+ "Prefer updating to next major version (default)"
271
+ method_option "strict", :type => :boolean, :banner =>
272
+ "Do not allow any gem to be updated past latest --patch | --minor | --major"
273
+ method_option "conservative", :type => :boolean, :banner =>
274
+ "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
275
+ method_option "all", :type => :boolean, :banner =>
276
+ "Update everything."
277
+ def update(*gems)
278
+ SharedHelpers.major_deprecation(3, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
279
+ require "bundler/cli/update"
280
+ Bundler.settings.temporary(:no_install => false) do
281
+ Update.new(options, gems).run
282
+ end
283
+ end
284
+
285
+ desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
286
+ long_desc <<-D
287
+ Show lists the names and versions of all gems that are required by your Gemfile.
288
+ Calling show with [GEM] will list the exact location of that gem on your machine.
289
+ D
290
+ method_option "paths", :type => :boolean,
291
+ :banner => "List the paths of all gems that are required by your Gemfile."
292
+ method_option "outdated", :type => :boolean,
293
+ :banner => "Show verbose output including whether gems are outdated."
294
+ def show(gem_name = nil)
295
+ if ARGV[0] == "show"
296
+ rest = ARGV[1..-1]
297
+
298
+ new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list"
299
+
300
+ new_arguments = rest.map do |arg|
301
+ next arg if arg != "--paths"
302
+ next "--path" if new_command == "info"
303
+ end
304
+
305
+ old_argv = ARGV.join(" ")
306
+ new_argv = [new_command, *new_arguments.compact].join(" ")
307
+
308
+ Bundler::SharedHelpers.major_deprecation(3, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
309
+ end
310
+ require "bundler/cli/show"
311
+ Show.new(options, gem_name).run
312
+ end
313
+ # TODO: 2.0 remove `bundle show`
314
+
315
+ if Bundler.feature_flag.list_command?
316
+ desc "list", "List all gems in the bundle"
317
+ method_option "name-only", :type => :boolean, :banner => "print only the gem names"
318
+ method_option "only-group", :type => :string, :banner => "print gems from a particular group"
319
+ method_option "without-group", :type => :string, :banner => "print all gems expect from a group"
320
+ method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
321
+ def list
322
+ require "bundler/cli/list"
323
+ List.new(options).run
324
+ end
325
+
326
+ map %w[ls] => "list"
327
+ else
328
+ map %w[list] => "show"
329
+ end
330
+
331
+ desc "info GEM [OPTIONS]", "Show information for the given gem"
332
+ method_option "path", :type => :boolean, :banner => "Print full path to gem"
333
+ def info(gem_name)
334
+ require "bundler/cli/info"
335
+ Info.new(options, gem_name).run
336
+ end
337
+
338
+ desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem"
339
+ long_desc <<-D
340
+ Generate binstubs for executables in [GEM]. Binstubs are put into bin,
341
+ or the --binstubs directory if one has been set. Calling binstubs with [GEM [GEM]]
342
+ will create binstubs for all given gems.
343
+ D
344
+ method_option "force", :type => :boolean, :default => false, :banner =>
345
+ "Overwrite existing binstubs if they exist"
346
+ method_option "path", :type => :string, :lazy_default => "bin", :banner =>
347
+ "Binstub destination directory (default bin)"
348
+ method_option "shebang", :type => :string, :banner =>
349
+ "Specify a different shebang executable name than the default (usually 'ruby')"
350
+ method_option "standalone", :type => :boolean, :banner =>
351
+ "Make binstubs that can work without the Bundler runtime"
352
+ method_option "all", :type => :boolean, :banner =>
353
+ "Install binstubs for all gems"
354
+ def binstubs(*gems)
355
+ require "bundler/cli/binstubs"
356
+ Binstubs.new(options, gems).run
357
+ end
358
+
359
+ desc "add GEM VERSION", "Add gem to Gemfile and run bundle install"
360
+ long_desc <<-D
361
+ Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step.
362
+ D
363
+ method_option "version", :aliases => "-v", :type => :string
364
+ method_option "group", :aliases => "-g", :type => :string
365
+ method_option "source", :aliases => "-s", :type => :string
366
+ method_option "skip-install", :type => :boolean, :banner =>
367
+ "Adds gem to the Gemfile but does not install it"
368
+ method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
369
+ method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
370
+ def add(*gems)
371
+ require "bundler/cli/add"
372
+ Add.new(options.dup, gems).run
373
+ end
374
+
375
+ desc "outdated GEM [OPTIONS]", "List installed gems with newer versions available"
376
+ long_desc <<-D
377
+ Outdated lists the names and versions of gems that have a newer version available
378
+ in the given source. Calling outdated with [GEM [GEM]] will only check for newer
379
+ versions of the given gems. Prerelease gems are ignored by default. If your gems
380
+ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
381
+
382
+ For more information on patch level options (--major, --minor, --patch,
383
+ --update-strict) see documentation on the same options on the update command.
384
+ D
385
+ method_option "group", :type => :string, :banner => "List gems from a specific group"
386
+ method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
387
+ method_option "local", :type => :boolean, :banner =>
388
+ "Do not attempt to fetch gems remotely and use the gem cache instead"
389
+ method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
390
+ method_option "source", :type => :array, :banner => "Check against a specific source"
391
+ method_option "strict", :type => :boolean, :banner =>
392
+ "Only list newer versions allowed by your Gemfile requirements"
393
+ method_option "update-strict", :type => :boolean, :banner =>
394
+ "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
395
+ method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
396
+ method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
397
+ method_option "patch", :type => :boolean, :banner => "Prefer updating only to next patch version"
398
+ method_option "filter-major", :type => :boolean, :banner => "Only list major newer versions"
399
+ method_option "filter-minor", :type => :boolean, :banner => "Only list minor newer versions"
400
+ method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
401
+ method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
402
+ "Use minimal formatting for more parseable output"
403
+ method_option "only-explicit", :type => :boolean, :banner =>
404
+ "Only list gems specified in your Gemfile, not their dependencies"
405
+ def outdated(*gems)
406
+ require "bundler/cli/outdated"
407
+ Outdated.new(options, gems).run
408
+ end
409
+
410
+ if Bundler.feature_flag.cache_command_is_package?
411
+ map %w[cache] => :package
412
+ else
413
+ desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true
414
+ unless Bundler.feature_flag.cache_command_is_package?
415
+ method_option "all", :type => :boolean,
416
+ :banner => "Include all sources (including path and git)."
417
+ end
418
+ method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
419
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
420
+ def cache
421
+ require "bundler/cli/cache"
422
+ Cache.new(options).run
423
+ end
424
+ end
425
+
426
+ desc "#{Bundler.feature_flag.cache_command_is_package? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
427
+ unless Bundler.feature_flag.cache_command_is_package?
428
+ method_option "all", :type => :boolean,
429
+ :banner => "Include all sources (including path and git)."
430
+ end
431
+ method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
432
+ method_option "cache-path", :type => :string, :banner =>
433
+ "Specify a different cache path than the default (vendor/cache)."
434
+ method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
435
+ method_option "no-install", :type => :boolean, :banner => "Don't install the gems, only the package."
436
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
437
+ method_option "path", :type => :string, :banner =>
438
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
439
+ method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
440
+ method_option "frozen", :type => :boolean, :banner =>
441
+ "Do not allow the Gemfile.lock to be updated after this package operation's install"
442
+ long_desc <<-D
443
+ The package command will copy the .gem files for every gem in the bundle into the
444
+ directory ./vendor/cache. If you then check that directory into your source
445
+ control repository, others who check out your source will be able to install the
446
+ bundle without having to download any additional gems.
447
+ D
448
+ def package
449
+ require "bundler/cli/package"
450
+ Package.new(options).run
451
+ end
452
+ map %w[pack] => :package
453
+
454
+ desc "exec [OPTIONS]", "Run the command in context of the bundle"
455
+ method_option :keep_file_descriptors, :type => :boolean, :default => false
456
+ method_option :gemfile, :type => :string, :required => false
457
+ long_desc <<-D
458
+ Exec runs a command, providing it access to the gems in the bundle. While using
459
+ bundle exec you can require and call the bundled gems as if they were installed
460
+ into the system wide RubyGems repository.
461
+ D
462
+ map "e" => "exec"
463
+ def exec(*args)
464
+ require "bundler/cli/exec"
465
+ Exec.new(options, args).run
466
+ end
467
+
468
+ desc "config NAME [VALUE]", "Retrieve or set a configuration value"
469
+ long_desc <<-D
470
+ Retrieves or sets a configuration value. If only one parameter is provided, retrieve the value. If two parameters are provided, replace the
471
+ existing value with the newly provided one.
472
+
473
+ By default, setting a configuration value sets it for all projects
474
+ on the machine.
475
+
476
+ If a global setting is superceded by local configuration, this command
477
+ will show the current value, as well as any superceded values and
478
+ where they were specified.
479
+ D
480
+ method_option "parseable", :type => :boolean, :banner => "Use minimal formatting for more parseable output"
481
+ def config(*args)
482
+ require "bundler/cli/config"
483
+ Config.new(options, args, self).run
484
+ end
485
+
486
+ desc "open GEM", "Opens the source directory of the given bundled gem"
487
+ def open(name)
488
+ require "bundler/cli/open"
489
+ Open.new(options, name).run
490
+ end
491
+
492
+ if Bundler.feature_flag.console_command?
493
+ desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
494
+ def console(group = nil)
495
+ require "bundler/cli/console"
496
+ Console.new(options, group).run
497
+ end
498
+ end
499
+
500
+ desc "version", "Prints the bundler's version information"
501
+ def version
502
+ cli_help = current_command.name == "cli_help"
503
+ if cli_help || ARGV.include?("version")
504
+ build_info = " (#{BuildMetadata.built_at} commit #{BuildMetadata.git_commit_sha})"
505
+ end
506
+
507
+ if !cli_help && Bundler.feature_flag.print_only_version_number?
508
+ Bundler.ui.info "#{Bundler::VERSION}#{build_info}"
509
+ else
510
+ Bundler.ui.info "Bundler version #{Bundler::VERSION}#{build_info}"
511
+ end
512
+ end
513
+ map %w[-v --version] => :version
514
+
515
+ desc "licenses", "Prints the license of all gems in the bundle"
516
+ def licenses
517
+ Bundler.load.specs.sort_by {|s| s.license.to_s }.reverse_each do |s|
518
+ gem_name = s.name
519
+ license = s.license || s.licenses
520
+
521
+ if license.empty?
522
+ Bundler.ui.warn "#{gem_name}: Unknown"
523
+ else
524
+ Bundler.ui.info "#{gem_name}: #{license}"
525
+ end
526
+ end
527
+ end
528
+
529
+ if Bundler.feature_flag.viz_command?
530
+ desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
531
+ long_desc <<-D
532
+ Viz generates a PNG file of the current Gemfile as a dependency graph.
533
+ Viz requires the ruby-graphviz gem (and its dependencies).
534
+ The associated gems must also be installed via 'bundle install'.
535
+ D
536
+ method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
537
+ method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
538
+ method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
539
+ method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
540
+ method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
541
+ def viz
542
+ SharedHelpers.major_deprecation 3, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
543
+ require "bundler/cli/viz"
544
+ Viz.new(options.dup).run
545
+ end
546
+ end
547
+
548
+ old_gem = instance_method(:gem)
549
+
550
+ desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
551
+ method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
552
+ method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config gem.coc true`."
553
+ method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
554
+ :lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
555
+ :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
556
+ method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
557
+ method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config gem.mit true`."
558
+ method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec",
559
+ :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config gem.test rspec`."
560
+ def gem(name)
561
+ end
562
+
563
+ commands["gem"].tap do |gem_command|
564
+ def gem_command.run(instance, args = [])
565
+ arity = 1 # name
566
+
567
+ require "bundler/cli/gem"
568
+ cmd_args = args + [instance]
569
+ cmd_args.unshift(instance.options)
570
+
571
+ cmd = begin
572
+ Gem.new(*cmd_args)
573
+ rescue ArgumentError => e
574
+ instance.class.handle_argument_error(self, e, args, arity)
575
+ end
576
+
577
+ cmd.run
578
+ end
579
+ end
580
+
581
+ undef_method(:gem)
582
+ define_method(:gem, old_gem)
583
+ private :gem
584
+
585
+ def self.source_root
586
+ File.expand_path(File.join(File.dirname(__FILE__), "templates"))
587
+ end
588
+
589
+ desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
590
+ method_option "dry-run", :type => :boolean, :default => false, :banner =>
591
+ "Only print out changes, do not clean gems"
592
+ method_option "force", :type => :boolean, :default => false, :banner =>
593
+ "Forces clean even if --path is not set"
594
+ def clean
595
+ require "bundler/cli/clean"
596
+ Clean.new(options.dup).run
597
+ end
598
+
599
+ desc "platform [OPTIONS]", "Displays platform compatibility information"
600
+ method_option "ruby", :type => :boolean, :default => false, :banner =>
601
+ "only display ruby related platform information"
602
+ def platform
603
+ require "bundler/cli/platform"
604
+ Platform.new(options).run
605
+ end
606
+
607
+ desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", :hide => true
608
+ method_option "source", :type => :string, :banner =>
609
+ "Install gem from the given source"
610
+ method_option "group", :type => :string, :banner =>
611
+ "Install gem into a bundler group"
612
+ def inject(name, version)
613
+ SharedHelpers.major_deprecation 3, "The `inject` command has been replaced by the `add` command"
614
+ require "bundler/cli/inject"
615
+ Inject.new(options.dup, name, version).run
616
+ end
617
+
618
+ desc "lock", "Creates a lockfile without installing"
619
+ method_option "update", :type => :array, :lazy_default => true, :banner =>
620
+ "ignore the existing lockfile, update all gems by default, or update list of given gems"
621
+ method_option "local", :type => :boolean, :default => false, :banner =>
622
+ "do not attempt to fetch remote gemspecs and use the local gem cache only"
623
+ method_option "print", :type => :boolean, :default => false, :banner =>
624
+ "print the lockfile to STDOUT instead of writing to the file system"
625
+ method_option "lockfile", :type => :string, :default => nil, :banner =>
626
+ "the path the lockfile should be written to"
627
+ method_option "full-index", :type => :boolean, :default => false, :banner =>
628
+ "Fall back to using the single-file index of all gems"
629
+ method_option "add-platform", :type => :array, :default => [], :banner =>
630
+ "Add a new platform to the lockfile"
631
+ method_option "remove-platform", :type => :array, :default => [], :banner =>
632
+ "Remove a platform from the lockfile"
633
+ method_option "patch", :type => :boolean, :banner =>
634
+ "If updating, prefer updating only to next patch version"
635
+ method_option "minor", :type => :boolean, :banner =>
636
+ "If updating, prefer updating only to next minor version"
637
+ method_option "major", :type => :boolean, :banner =>
638
+ "If updating, prefer updating to next major version (default)"
639
+ method_option "strict", :type => :boolean, :banner =>
640
+ "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
641
+ method_option "conservative", :type => :boolean, :banner =>
642
+ "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
643
+ def lock
644
+ require "bundler/cli/lock"
645
+ Lock.new(options).run
646
+ end
647
+
648
+ desc "env", "Print information about the environment Bundler is running under"
649
+ def env
650
+ Env.write($stdout)
651
+ end
652
+
653
+ desc "doctor [OPTIONS]", "Checks the bundle for common problems"
654
+ long_desc <<-D
655
+ Doctor scans the OS dependencies of each of the gems requested in the Gemfile. If
656
+ missing dependencies are detected, Bundler prints them and exits status 1.
657
+ Otherwise, Bundler prints a success message and exits with a status of 0.
658
+ D
659
+ method_option "gemfile", :type => :string, :banner =>
660
+ "Use the specified gemfile instead of Gemfile"
661
+ method_option "quiet", :type => :boolean, :banner =>
662
+ "Only output warnings and errors."
663
+ def doctor
664
+ require "bundler/cli/doctor"
665
+ Doctor.new(options).run
666
+ end
667
+
668
+ desc "issue", "Learn how to report an issue in Bundler"
669
+ def issue
670
+ require "bundler/cli/issue"
671
+ Issue.new.run
672
+ end
673
+
674
+ desc "pristine [GEMS...]", "Restores installed gems to pristine condition"
675
+ long_desc <<-D
676
+ Restores installed gems to pristine condition from files located in the
677
+ gem cache. Gems installed from a git repository will be issued `git
678
+ checkout --force`.
679
+ D
680
+ def pristine(*gems)
681
+ require "bundler/cli/pristine"
682
+ Pristine.new(gems).run
683
+ end
684
+
685
+ if Bundler.feature_flag.plugins?
686
+ require "bundler/cli/plugin"
687
+ desc "plugin", "Manage the bundler plugins"
688
+ subcommand "plugin", Plugin
689
+ end
690
+
691
+ # Reformat the arguments passed to bundle that include a --help flag
692
+ # into the corresponding `bundle help #{command}` call
693
+ def self.reformatted_help_args(args)
694
+ bundler_commands = all_commands.keys
695
+ help_flags = %w[--help -h]
696
+ exec_commands = %w[e ex exe exec]
697
+ help_used = args.index {|a| help_flags.include? a }
698
+ exec_used = args.index {|a| exec_commands.include? a }
699
+ command = args.find {|a| bundler_commands.include? a }
700
+ if exec_used && help_used
701
+ if exec_used + help_used == 1
702
+ %w[help exec]
703
+ else
704
+ args
705
+ end
706
+ elsif help_used
707
+ args = args.dup
708
+ args.delete_at(help_used)
709
+ ["help", command || args].flatten.compact
710
+ else
711
+ args
712
+ end
713
+ end
714
+
715
+ private
716
+
717
+ # Automatically invoke `bundle install` and resume if
718
+ # Bundler.settings[:auto_install] exists. This is set through config cmd
719
+ # `bundle config auto_install 1`.
720
+ #
721
+ # Note that this method `nil`s out the global Definition object, so it
722
+ # should be called first, before you instantiate anything like an
723
+ # `Installer` that'll keep a reference to the old one instead.
724
+ def auto_install
725
+ return unless Bundler.settings[:auto_install]
726
+
727
+ begin
728
+ Bundler.definition.specs
729
+ rescue GemNotFound
730
+ Bundler.ui.info "Automatically installing missing gems."
731
+ Bundler.reset!
732
+ invoke :install, []
733
+ Bundler.reset!
734
+ end
735
+ end
736
+
737
+ def current_command
738
+ _, _, config = @_initializer
739
+ config[:current_command]
740
+ end
741
+
742
+ def print_command
743
+ return unless Bundler.ui.debug?
744
+ cmd = current_command
745
+ command_name = cmd.name
746
+ return if PARSEABLE_COMMANDS.include?(command_name)
747
+ command = ["bundle", command_name] + args
748
+ options_to_print = options.dup
749
+ options_to_print.delete_if do |k, v|
750
+ next unless o = cmd.options[k]
751
+ o.default == v
752
+ end
753
+ command << Thor::Options.to_switches(options_to_print.sort_by(&:first)).strip
754
+ command.reject!(&:empty?)
755
+ Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
756
+ end
757
+
758
+ def warn_on_outdated_bundler
759
+ return if Bundler.settings[:disable_version_check]
760
+
761
+ command_name = current_command.name
762
+ return if PARSEABLE_COMMANDS.include?(command_name)
763
+
764
+ return unless SharedHelpers.md5_available?
765
+
766
+ latest = Fetcher::CompactIndex.
767
+ new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil).
768
+ send(:compact_index_client).
769
+ instance_variable_get(:@cache).
770
+ dependencies("bundler").
771
+ map {|d| Gem::Version.new(d.first) }.
772
+ max
773
+ return unless latest
774
+
775
+ current = Gem::Version.new(VERSION)
776
+ return if current >= latest
777
+ latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
778
+
779
+ installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
780
+ if latest_installed && latest_installed > current
781
+ suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
782
+ suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
783
+ else
784
+ suggestion = installation
785
+ end
786
+
787
+ Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
788
+ rescue RuntimeError
789
+ nil
790
+ end
791
+ end
792
+ end