bundler 1.13.6 → 1.17.3

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