bundler 2.1.4 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2017 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +3 -0
  6. data/lib/bundler/build_metadata.rb +3 -11
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/binstubs.rb +6 -2
  9. data/lib/bundler/cli/cache.rb +3 -8
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/clean.rb +1 -1
  12. data/lib/bundler/cli/common.rb +29 -2
  13. data/lib/bundler/cli/console.rb +1 -1
  14. data/lib/bundler/cli/doctor.rb +16 -5
  15. data/lib/bundler/cli/exec.rb +5 -10
  16. data/lib/bundler/cli/fund.rb +36 -0
  17. data/lib/bundler/cli/gem.rb +209 -28
  18. data/lib/bundler/cli/info.rb +28 -5
  19. data/lib/bundler/cli/init.rb +2 -2
  20. data/lib/bundler/cli/inject.rb +1 -1
  21. data/lib/bundler/cli/install.rb +22 -34
  22. data/lib/bundler/cli/issue.rb +5 -4
  23. data/lib/bundler/cli/list.rb +19 -11
  24. data/lib/bundler/cli/lock.rb +5 -1
  25. data/lib/bundler/cli/open.rb +1 -2
  26. data/lib/bundler/cli/outdated.rb +95 -75
  27. data/lib/bundler/cli/plugin.rb +10 -0
  28. data/lib/bundler/cli/pristine.rb +5 -0
  29. data/lib/bundler/cli/remove.rb +1 -2
  30. data/lib/bundler/cli/show.rb +1 -1
  31. data/lib/bundler/cli/update.rb +14 -7
  32. data/lib/bundler/cli.rb +89 -66
  33. data/lib/bundler/compact_index_client/cache.rb +6 -14
  34. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  35. data/lib/bundler/compact_index_client/updater.rb +13 -22
  36. data/lib/bundler/compact_index_client.rb +3 -3
  37. data/lib/bundler/current_ruby.rb +5 -4
  38. data/lib/bundler/definition.rb +193 -363
  39. data/lib/bundler/dep_proxy.rb +16 -9
  40. data/lib/bundler/dependency.rb +3 -10
  41. data/lib/bundler/digest.rb +71 -0
  42. data/lib/bundler/dsl.rb +71 -47
  43. data/lib/bundler/endpoint_specification.rb +1 -1
  44. data/lib/bundler/env.rb +1 -1
  45. data/lib/bundler/environment_preserver.rb +29 -2
  46. data/lib/bundler/errors.rb +20 -3
  47. data/lib/bundler/feature_flag.rb +0 -8
  48. data/lib/bundler/fetcher/base.rb +1 -1
  49. data/lib/bundler/fetcher/compact_index.rb +2 -2
  50. data/lib/bundler/fetcher/downloader.rb +10 -7
  51. data/lib/bundler/fetcher/index.rb +3 -5
  52. data/lib/bundler/fetcher.rb +7 -5
  53. data/lib/bundler/friendly_errors.rb +25 -43
  54. data/lib/bundler/gem_helper.rb +53 -31
  55. data/lib/bundler/gem_helpers.rb +36 -25
  56. data/lib/bundler/gem_version_promoter.rb +4 -4
  57. data/lib/bundler/graph.rb +1 -1
  58. data/lib/bundler/index.rb +9 -9
  59. data/lib/bundler/injector.rb +23 -5
  60. data/lib/bundler/inline.rb +3 -2
  61. data/lib/bundler/installer/gem_installer.rb +6 -19
  62. data/lib/bundler/installer/parallel_installer.rb +46 -25
  63. data/lib/bundler/installer/standalone.rb +30 -10
  64. data/lib/bundler/installer.rb +36 -56
  65. data/lib/bundler/lazy_specification.rb +62 -26
  66. data/lib/bundler/lockfile_generator.rb +1 -1
  67. data/lib/bundler/lockfile_parser.rb +8 -34
  68. data/lib/bundler/man/.document +1 -0
  69. data/{man → lib/bundler/man}/bundle-add.1 +1 -1
  70. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
  71. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  72. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  73. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  74. data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  75. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  76. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  77. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  78. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  79. data/{man → lib/bundler/man}/bundle-config.1 +40 -41
  80. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +50 -53
  81. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  82. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  85. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  86. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  87. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  88. data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  89. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  90. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  91. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  92. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  93. data/{man → lib/bundler/man}/bundle-install.1 +30 -3
  94. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
  95. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  96. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  97. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  98. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  99. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  100. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  101. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  102. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
  103. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  104. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  105. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  106. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  107. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  108. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  109. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  110. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  111. data/{man → lib/bundler/man}/bundle-update.1 +4 -4
  112. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +3 -3
  113. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  114. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  115. data/{man → lib/bundler/man}/bundle.1 +1 -1
  116. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  117. data/{man → lib/bundler/man}/gemfile.5 +30 -4
  118. data/{man → lib/bundler/man}/gemfile.5.ronn +12 -4
  119. data/{man → lib/bundler/man}/index.txt +0 -0
  120. data/lib/bundler/mirror.rb +2 -2
  121. data/lib/bundler/plugin/api/source.rb +23 -1
  122. data/lib/bundler/plugin/dsl.rb +1 -1
  123. data/lib/bundler/plugin/index.rb +13 -1
  124. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  125. data/lib/bundler/plugin/installer.rb +11 -11
  126. data/lib/bundler/plugin/source_list.rb +5 -1
  127. data/lib/bundler/plugin.rb +56 -11
  128. data/lib/bundler/psyched_yaml.rb +0 -15
  129. data/lib/bundler/remote_specification.rb +5 -2
  130. data/lib/bundler/resolver/spec_group.rb +56 -53
  131. data/lib/bundler/resolver.rb +94 -128
  132. data/lib/bundler/retry.rb +2 -2
  133. data/lib/bundler/ruby_version.rb +1 -1
  134. data/lib/bundler/rubygems_ext.rb +96 -16
  135. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  136. data/lib/bundler/rubygems_integration.rb +57 -72
  137. data/lib/bundler/runtime.rb +22 -25
  138. data/lib/bundler/settings.rb +142 -64
  139. data/lib/bundler/setup.rb +2 -2
  140. data/lib/bundler/shared_helpers.rb +5 -13
  141. data/lib/bundler/similarity_detector.rb +1 -1
  142. data/lib/bundler/source/git/git_proxy.rb +88 -84
  143. data/lib/bundler/source/git.rb +43 -23
  144. data/lib/bundler/source/metadata.rb +0 -4
  145. data/lib/bundler/source/path/installer.rb +10 -10
  146. data/lib/bundler/source/path.rb +10 -4
  147. data/lib/bundler/source/rubygems/remote.rb +1 -1
  148. data/lib/bundler/source/rubygems.rb +126 -116
  149. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  150. data/lib/bundler/source.rb +22 -1
  151. data/lib/bundler/source_list.rb +101 -63
  152. data/lib/bundler/source_map.rb +58 -0
  153. data/lib/bundler/spec_set.rb +26 -41
  154. data/lib/bundler/stub_specification.rb +25 -7
  155. data/lib/bundler/templates/Executable.bundler +6 -6
  156. data/lib/bundler/templates/Gemfile +1 -1
  157. data/lib/bundler/templates/gems.rb +1 -1
  158. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  159. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  160. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  161. data/lib/bundler/templates/newgem/README.md.tt +6 -5
  162. data/lib/bundler/templates/newgem/Rakefile.tt +23 -5
  163. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  164. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  165. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  166. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  167. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  168. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  169. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  170. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  171. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  172. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  173. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  174. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  175. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  176. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  177. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  178. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  179. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  180. data/lib/bundler/ui/shell.rb +5 -5
  181. data/lib/bundler/uri_credentials_filter.rb +3 -1
  182. data/lib/bundler/vendor/.document +1 -0
  183. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  184. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  185. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  186. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  187. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  188. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  189. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  190. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  191. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  192. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  193. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +36 -4
  194. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
  195. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  196. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  197. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  198. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  199. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  200. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  201. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  202. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  203. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  204. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  206. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  207. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  208. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  209. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  210. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  211. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  212. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  213. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  214. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  215. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  216. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  217. data/lib/bundler/vendored_persistent.rb +0 -7
  218. data/lib/bundler/vendored_tmpdir.rb +4 -0
  219. data/lib/bundler/vendored_tsort.rb +4 -0
  220. data/lib/bundler/version.rb +1 -1
  221. data/lib/bundler/worker.rb +20 -5
  222. data/lib/bundler/yaml_serializer.rb +1 -1
  223. data/lib/bundler.rb +52 -37
  224. metadata +90 -89
  225. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  226. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  227. data/man/bundle-add.1.txt +0 -58
  228. data/man/bundle-binstubs.1.txt +0 -48
  229. data/man/bundle-cache.1.txt +0 -78
  230. data/man/bundle-check.1.txt +0 -33
  231. data/man/bundle-clean.1.txt +0 -26
  232. data/man/bundle-config.1.txt +0 -528
  233. data/man/bundle-doctor.1.txt +0 -44
  234. data/man/bundle-exec.1.txt +0 -178
  235. data/man/bundle-gem.1.txt +0 -91
  236. data/man/bundle-info.1.txt +0 -21
  237. data/man/bundle-init.1.txt +0 -34
  238. data/man/bundle-inject.1.txt +0 -32
  239. data/man/bundle-install.1.txt +0 -401
  240. data/man/bundle-list.1.txt +0 -43
  241. data/man/bundle-lock.1.txt +0 -93
  242. data/man/bundle-open.1.txt +0 -29
  243. data/man/bundle-outdated.1.txt +0 -131
  244. data/man/bundle-platform.1.txt +0 -57
  245. data/man/bundle-pristine.1.txt +0 -44
  246. data/man/bundle-remove.1.txt +0 -34
  247. data/man/bundle-show.1.txt +0 -27
  248. data/man/bundle-update.1.txt +0 -390
  249. data/man/bundle-viz.1.txt +0 -39
  250. data/man/bundle.1.txt +0 -116
  251. data/man/gemfile.5.txt +0 -649
@@ -12,6 +12,7 @@ module Bundler
12
12
  TEST_FRAMEWORK_VERSIONS = {
13
13
  "rspec" => "3.0",
14
14
  "minitest" => "5.0",
15
+ "test-unit" => "3.0",
15
16
  }.freeze
16
17
 
17
18
  attr_reader :options, :gem_name, :thor, :name, :target
@@ -38,11 +39,19 @@ module Bundler
38
39
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
39
40
  constant_array = constant_name.split("::")
40
41
 
41
- git_installed = Bundler.git_present?
42
+ use_git = Bundler.git_present? && options[:git]
42
43
 
43
- git_author_name = git_installed ? `git config user.name`.chomp : ""
44
- github_username = git_installed ? `git config github.user`.chomp : ""
45
- git_user_email = git_installed ? `git config user.email`.chomp : ""
44
+ git_author_name = use_git ? `git config user.name`.chomp : ""
45
+ git_username = use_git ? `git config github.user`.chomp : ""
46
+ git_user_email = use_git ? `git config user.email`.chomp : ""
47
+
48
+ github_username = if options[:github_username].nil?
49
+ git_username
50
+ elsif options[:github_username] == false
51
+ ""
52
+ else
53
+ options[:github_username]
54
+ end
46
55
 
47
56
  config = {
48
57
  :name => name,
@@ -57,14 +66,17 @@ module Bundler
57
66
  :ext => options[:ext],
58
67
  :exe => options[:exe],
59
68
  :bundler_version => bundler_dependency_version,
69
+ :git => use_git,
60
70
  :github_username => github_username.empty? ? "[USERNAME]" : github_username,
71
+ :required_ruby_version => required_ruby_version,
61
72
  }
62
73
  ensure_safe_gem_name(name, constant_array)
63
74
 
64
75
  templates = {
65
- "Gemfile.tt" => "Gemfile",
76
+ "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
66
77
  "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
67
78
  "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
79
+ "sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",
68
80
  "newgem.gemspec.tt" => "#{name}.gemspec",
69
81
  "Rakefile.tt" => "Rakefile",
70
82
  "README.md.tt" => "README.md",
@@ -77,14 +89,12 @@ module Bundler
77
89
  bin/setup
78
90
  ]
79
91
 
80
- templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present?
92
+ templates.merge!("gitignore.tt" => ".gitignore") if use_git
81
93
 
82
94
  if test_framework = ask_and_set_test_framework
83
95
  config[:test] = test_framework
84
96
  config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework]
85
97
 
86
- templates.merge!("travis.yml.tt" => ".travis.yml")
87
-
88
98
  case test_framework
89
99
  when "rspec"
90
100
  templates.merge!(
@@ -92,15 +102,33 @@ module Bundler
92
102
  "spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
93
103
  "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
94
104
  )
105
+ config[:test_task] = :spec
95
106
  when "minitest"
96
107
  templates.merge!(
97
- "test/test_helper.rb.tt" => "test/test_helper.rb",
98
- "test/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
108
+ "test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
109
+ "test/minitest/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
99
110
  )
111
+ config[:test_task] = :test
112
+ when "test-unit"
113
+ templates.merge!(
114
+ "test/test-unit/test_helper.rb.tt" => "test/test_helper.rb",
115
+ "test/test-unit/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
116
+ )
117
+ config[:test_task] = :test
100
118
  end
101
119
  end
102
120
 
103
- config[:test_task] = config[:test] == "minitest" ? "test" : "spec"
121
+ config[:ci] = ask_and_set_ci
122
+ case config[:ci]
123
+ when "github"
124
+ templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
125
+ when "travis"
126
+ templates.merge!("travis.yml.tt" => ".travis.yml")
127
+ when "gitlab"
128
+ templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
129
+ when "circle"
130
+ templates.merge!("circleci/config.yml.tt" => ".circleci/config.yml")
131
+ end
104
132
 
105
133
  if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
106
134
  "This means that any other developer or company will be legally allowed to use your code " \
@@ -124,6 +152,30 @@ module Bundler
124
152
  templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
125
153
  end
126
154
 
155
+ if ask_and_set(:changelog, "Do you want to include a changelog?",
156
+ "A changelog is a file which contains a curated, chronologically ordered list of notable " \
157
+ "changes for each version of a project. To make it easier for users and contributors to" \
158
+ " see precisely what notable changes have been made between each release (or version) of" \
159
+ " the project. Whether consumers or developers, the end users of software are" \
160
+ " human beings who care about what's in the software. When the software changes, people " \
161
+ "want to know why and how. see https://keepachangelog.com")
162
+ config[:changelog] = true
163
+ Bundler.ui.info "Changelog enabled in config"
164
+ templates.merge!("CHANGELOG.md.tt" => "CHANGELOG.md")
165
+ end
166
+
167
+ config[:linter] = ask_and_set_linter
168
+ case config[:linter]
169
+ when "rubocop"
170
+ config[:linter_version] = rubocop_version
171
+ Bundler.ui.info "RuboCop enabled in config"
172
+ templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
173
+ when "standard"
174
+ config[:linter_version] = standard_version
175
+ Bundler.ui.info "Standard enabled in config"
176
+ templates.merge!("standard.yml.tt" => ".standard.yml")
177
+ end
178
+
127
179
  templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
128
180
 
129
181
  if options[:ext]
@@ -134,24 +186,32 @@ module Bundler
134
186
  )
135
187
  end
136
188
 
189
+ if target.exist? && !target.directory?
190
+ Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
191
+ exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
192
+ end
193
+
194
+ if use_git
195
+ Bundler.ui.info "Initializing git repo in #{target}"
196
+ require "shellwords"
197
+ `git init #{target.to_s.shellescape}`
198
+
199
+ config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp
200
+ end
201
+
137
202
  templates.each do |src, dst|
138
203
  destination = target.join(dst)
139
- SharedHelpers.filesystem_access(destination) do
140
- thor.template("newgem/#{src}", destination, config)
141
- end
204
+ thor.template("newgem/#{src}", destination, config)
142
205
  end
143
206
 
144
207
  executables.each do |file|
145
- SharedHelpers.filesystem_access(target.join(file)) do |path|
146
- executable = (path.stat.mode | 0o111)
147
- path.chmod(executable)
148
- end
208
+ path = target.join(file)
209
+ executable = (path.stat.mode | 0o111)
210
+ path.chmod(executable)
149
211
  end
150
212
 
151
- if Bundler.git_present? && options[:git]
152
- Bundler.ui.info "Initializing git repo in #{target}"
213
+ if use_git
153
214
  Dir.chdir(target) do
154
- `git init`
155
215
  `git add .`
156
216
  end
157
217
  end
@@ -161,11 +221,9 @@ module Bundler
161
221
 
162
222
  Bundler.ui.info "Gem '#{name}' was successfully created. " \
163
223
  "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
164
- rescue Errno::EEXIST => e
165
- raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
166
224
  end
167
225
 
168
- private
226
+ private
169
227
 
170
228
  def resolve_name(name)
171
229
  SharedHelpers.pwd.join(name).basename.to_s
@@ -197,11 +255,12 @@ module Bundler
197
255
  def ask_and_set_test_framework
198
256
  test_framework = options[:test] || Bundler.settings["gem.test"]
199
257
 
200
- if test_framework.nil?
258
+ if test_framework.to_s.empty?
201
259
  Bundler.ui.confirm "Do you want to generate tests with your gem?"
202
- result = Bundler.ui.ask "Type 'rspec' or 'minitest' to generate those test files now and " \
203
- "in the future. rspec/minitest/(none):"
204
- if result =~ /rspec|minitest/
260
+ Bundler.ui.info hint_text("test")
261
+
262
+ result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):"
263
+ if result =~ /rspec|minitest|test-unit/
205
264
  test_framework = result
206
265
  else
207
266
  test_framework = false
@@ -212,9 +271,106 @@ module Bundler
212
271
  Bundler.settings.set_global("gem.test", test_framework)
213
272
  end
214
273
 
274
+ if options[:test] == Bundler.settings["gem.test"]
275
+ Bundler.ui.info "#{options[:test]} is already configured, ignoring --test flag."
276
+ end
277
+
215
278
  test_framework
216
279
  end
217
280
 
281
+ def hint_text(setting)
282
+ if Bundler.settings["gem.#{setting}"] == false
283
+ "Your choice will only be applied to this gem."
284
+ else
285
+ "Future `bundle gem` calls will use your choice. " \
286
+ "This setting can be changed anytime with `bundle config gem.#{setting}`."
287
+ end
288
+ end
289
+
290
+ def ask_and_set_ci
291
+ ci_template = options[:ci] || Bundler.settings["gem.ci"]
292
+
293
+ if ci_template.to_s.empty?
294
+ Bundler.ui.confirm "Do you want to set up continuous integration for your gem? " \
295
+ "Supported services:\n" \
296
+ "* CircleCI: https://circleci.com/\n" \
297
+ "* GitHub Actions: https://github.com/features/actions\n" \
298
+ "* GitLab CI: https://docs.gitlab.com/ee/ci/\n" \
299
+ "* Travis CI: https://travis-ci.org/\n" \
300
+ "\n"
301
+ Bundler.ui.info hint_text("ci")
302
+
303
+ result = Bundler.ui.ask "Enter a CI service. github/travis/gitlab/circle/(none):"
304
+ if result =~ /github|travis|gitlab|circle/
305
+ ci_template = result
306
+ else
307
+ ci_template = false
308
+ end
309
+ end
310
+
311
+ if Bundler.settings["gem.ci"].nil?
312
+ Bundler.settings.set_global("gem.ci", ci_template)
313
+ end
314
+
315
+ if options[:ci] == Bundler.settings["gem.ci"]
316
+ Bundler.ui.info "#{options[:ci]} is already configured, ignoring --ci flag."
317
+ end
318
+
319
+ ci_template
320
+ end
321
+
322
+ def ask_and_set_linter
323
+ linter_template = options[:linter] || Bundler.settings["gem.linter"]
324
+ linter_template = deprecated_rubocop_option if linter_template.nil?
325
+
326
+ if linter_template.to_s.empty?
327
+ Bundler.ui.confirm "Do you want to add a code linter and formatter to your gem? " \
328
+ "Supported Linters:\n" \
329
+ "* RuboCop: https://rubocop.org\n" \
330
+ "* Standard: https://github.com/testdouble/standard\n" \
331
+ "\n"
332
+ Bundler.ui.info hint_text("linter")
333
+
334
+ result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
335
+ if result =~ /rubocop|standard/
336
+ linter_template = result
337
+ else
338
+ linter_template = false
339
+ end
340
+ end
341
+
342
+ if Bundler.settings["gem.linter"].nil?
343
+ Bundler.settings.set_global("gem.linter", linter_template)
344
+ end
345
+
346
+ # Once gem.linter safely set, unset the deprecated gem.rubocop
347
+ unless Bundler.settings["gem.rubocop"].nil?
348
+ Bundler.settings.set_global("gem.rubocop", nil)
349
+ end
350
+
351
+ if options[:linter] == Bundler.settings["gem.linter"]
352
+ Bundler.ui.info "#{options[:linter]} is already configured, ignoring --linter flag."
353
+ end
354
+
355
+ linter_template
356
+ end
357
+
358
+ def deprecated_rubocop_option
359
+ if !options[:rubocop].nil?
360
+ if options[:rubocop]
361
+ Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop"
362
+ "rubocop"
363
+ else
364
+ Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter"
365
+ false
366
+ end
367
+ elsif !Bundler.settings["gem.rubocop"].nil?
368
+ Bundler::SharedHelpers.major_deprecation 2,
369
+ "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
370
+ Bundler.settings["gem.rubocop"] ? "rubocop" : false
371
+ end
372
+ end
373
+
218
374
  def bundler_dependency_version
219
375
  v = Gem::Version.new(Bundler::VERSION)
220
376
  req = v.segments[0..1]
@@ -248,5 +404,30 @@ module Bundler
248
404
  def open_editor(editor, file)
249
405
  thor.run(%(#{editor} "#{file}"))
250
406
  end
407
+
408
+ def required_ruby_version
409
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0"
410
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0"
411
+ elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0"
412
+ else
413
+ "2.6.0"
414
+ end
415
+ end
416
+
417
+ def rubocop_version
418
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0"
419
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12"
420
+ else
421
+ "1.21"
422
+ end
423
+ end
424
+
425
+ def standard_version
426
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.2.5"
427
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.0"
428
+ else
429
+ "1.3"
430
+ end
431
+ end
251
432
  end
252
433
  end
@@ -18,11 +18,12 @@ module Bundler
18
18
 
19
19
  if spec
20
20
  return print_gem_path(spec) if @options[:path]
21
+ return print_gem_version(spec) if @options[:version]
21
22
  print_gem_info(spec)
22
23
  end
23
24
  end
24
25
 
25
- private
26
+ private
26
27
 
27
28
  def spec_for_gem(gem_name)
28
29
  spec = Bundler.definition.specs.find {|s| s.name == gem_name }
@@ -39,23 +40,45 @@ module Bundler
39
40
  raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
40
41
  end
41
42
 
43
+ def print_gem_version(spec)
44
+ Bundler.ui.info spec.version.to_s
45
+ end
46
+
42
47
  def print_gem_path(spec)
43
- path = if spec.name == "bundler"
44
- File.expand_path("../../../..", __FILE__)
48
+ name = spec.name
49
+ if name == "bundler"
50
+ path = File.expand_path("../../../..", __FILE__)
45
51
  else
46
- spec.full_gem_path
52
+ path = spec.full_gem_path
53
+ if spec.deleted_gem?
54
+ return Bundler.ui.warn "The gem #{name} has been deleted. It was installed at: #{path}"
55
+ end
47
56
  end
48
57
 
49
58
  Bundler.ui.info path
50
59
  end
51
60
 
52
61
  def print_gem_info(spec)
62
+ metadata = spec.metadata
63
+ name = spec.name
53
64
  gem_info = String.new
54
- gem_info << " * #{spec.name} (#{spec.version}#{spec.git_version})\n"
65
+ gem_info << " * #{name} (#{spec.version}#{spec.git_version})\n"
55
66
  gem_info << "\tSummary: #{spec.summary}\n" if spec.summary
56
67
  gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage
68
+ gem_info << "\tDocumentation: #{metadata["documentation_uri"]}\n" if metadata.key?("documentation_uri")
69
+ gem_info << "\tSource Code: #{metadata["source_code_uri"]}\n" if metadata.key?("source_code_uri")
70
+ gem_info << "\tFunding: #{metadata["funding_uri"]}\n" if metadata.key?("funding_uri")
71
+ gem_info << "\tWiki: #{metadata["wiki_uri"]}\n" if metadata.key?("wiki_uri")
72
+ gem_info << "\tChangelog: #{metadata["changelog_uri"]}\n" if metadata.key?("changelog_uri")
73
+ gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri")
74
+ gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri")
57
75
  gem_info << "\tPath: #{spec.full_gem_path}\n"
58
76
  gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem?
77
+
78
+ if name != "bundler" && spec.deleted_gem?
79
+ return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}"
80
+ end
81
+
59
82
  Bundler.ui.info gem_info
60
83
  end
61
84
  end
@@ -38,10 +38,10 @@ module Bundler
38
38
  puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}"
39
39
  end
40
40
 
41
- private
41
+ private
42
42
 
43
43
  def gemfile
44
- @gemfile ||= Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
44
+ @gemfile ||= Bundler.preferred_gemfile_name
45
45
  end
46
46
  end
47
47
  end
@@ -44,7 +44,7 @@ module Bundler
44
44
  end
45
45
  end
46
46
 
47
- private
47
+ private
48
48
 
49
49
  def last_version_number
50
50
  definition = Bundler.definition(true)
@@ -8,12 +8,10 @@ module Bundler
8
8
  end
9
9
 
10
10
  def run
11
- Bundler.ui.level = "error" if options[:quiet]
11
+ Bundler.ui.level = "warn" if options[:quiet]
12
12
 
13
13
  warn_if_root
14
14
 
15
- normalize_groups
16
-
17
15
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
18
16
 
19
17
  # Disable color in deployment mode
@@ -35,12 +33,8 @@ module Bundler
35
33
 
36
34
  options[:local] = true if Bundler.app_cache.exist?
37
35
 
38
- if Bundler.feature_flag.deployment_means_frozen?
39
- Bundler.settings.set_command_option :deployment, true
40
- else
41
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
42
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
43
- end
36
+ Bundler.settings.set_command_option :deployment, true if options[:deployment]
37
+ Bundler.settings.set_command_option :frozen, true if options[:frozen]
44
38
  end
45
39
 
46
40
  # When install is called with --no-deployment, disable deployment mode
@@ -55,7 +49,7 @@ module Bundler
55
49
 
56
50
  if options["binstubs"]
57
51
  Bundler::SharedHelpers.major_deprecation 2,
58
- "The --binstubs option will be removed in favor of `bundle binstubs`"
52
+ "The --binstubs option will be removed in favor of `bundle binstubs --all`"
59
53
  end
60
54
 
61
55
  Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
@@ -64,7 +58,10 @@ module Bundler
64
58
  definition.validate_runtime!
65
59
 
66
60
  installer = Installer.install(Bundler.root, definition, options)
67
- Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
61
+
62
+ Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
63
+ Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
64
+ end
68
65
 
69
66
  Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
70
67
  Bundler::CLI::Common.output_without_groups_message(:install)
@@ -84,28 +81,17 @@ module Bundler
84
81
  require_relative "clean"
85
82
  Bundler::CLI::Clean.new(options).run
86
83
  end
87
- rescue GemNotFound, VersionConflict => e
88
- if options[:local] && Bundler.app_cache.exist?
89
- Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
90
- end
91
84
 
92
- unless Bundler.definition.has_rubygems_remotes?
93
- Bundler.ui.warn <<-WARN, :wrap => true
94
- Your Gemfile has no gem server sources. If you need gems that are \
95
- not already on your machine, add a line like this to your Gemfile:
96
- source 'https://rubygems.org'
97
- WARN
98
- end
99
- raise e
100
- rescue Gem::InvalidSpecificationException => e
85
+ Bundler::CLI::Common.output_fund_metadata_summary
86
+ rescue Gem::InvalidSpecificationException
101
87
  Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
102
- raise e
88
+ raise
103
89
  end
104
90
 
105
- private
91
+ private
106
92
 
107
93
  def warn_if_root
108
- return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !Process.uid.zero?
94
+ return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
109
95
  Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \
110
96
  "if it is needed, and installing your bundle as root will break this " \
111
97
  "application for all non-root users on this machine.", :wrap => true
@@ -165,6 +151,14 @@ module Bundler
165
151
 
166
152
  options[:with] = with
167
153
  options[:without] = without
154
+
155
+ unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
156
+ # need to nil them out first to get around validation for backwards compatibility
157
+ Bundler.settings.set_command_option :without, nil
158
+ Bundler.settings.set_command_option :with, nil
159
+ Bundler.settings.set_command_option :without, options[:without] - options[:with]
160
+ Bundler.settings.set_command_option :with, options[:with]
161
+ end
168
162
  end
169
163
 
170
164
  def normalize_settings
@@ -191,13 +185,7 @@ module Bundler
191
185
 
192
186
  Bundler.settings.set_command_option_if_given :clean, options["clean"]
193
187
 
194
- unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
195
- # need to nil them out first to get around validation for backwards compatibility
196
- Bundler.settings.set_command_option :without, nil
197
- Bundler.settings.set_command_option :with, nil
198
- Bundler.settings.set_command_option :without, options[:without] - options[:with]
199
- Bundler.settings.set_command_option :with, options[:with]
200
- end
188
+ normalize_groups
201
189
 
202
190
  options[:force] = options[:redownload]
203
191
  end
@@ -10,7 +10,7 @@ module Bundler
10
10
  be sure to check out these resources:
11
11
 
12
12
  1. Check out our troubleshooting guide for quick fixes to common issues:
13
- https://github.com/bundler/bundler/blob/master/doc/TROUBLESHOOTING.md
13
+ https://github.com/rubygems/rubygems/blob/master/bundler/doc/TROUBLESHOOTING.md
14
14
 
15
15
  2. Instructions for common Bundler uses can be found on the documentation
16
16
  site: https://bundler.io/
@@ -20,9 +20,10 @@ module Bundler
20
20
 
21
21
  Hopefully the troubleshooting steps above resolved your problem! If things
22
22
  still aren't working the way you expect them to, please let us know so
23
- that we can diagnose and help fix the problem you're having. Please
24
- view the Filing Issues guide for more information:
25
- https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md
23
+ that we can diagnose and help fix the problem you're having, by filling
24
+ in the new issue form located at
25
+ https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
26
+ and copy and pasting the information below.
26
27
 
27
28
  EOS
28
29
 
@@ -4,17 +4,25 @@ module Bundler
4
4
  class CLI::List
5
5
  def initialize(options)
6
6
  @options = options
7
+ @without_group = options["without-group"].map(&:to_sym)
8
+ @only_group = options["only-group"].map(&:to_sym)
7
9
  end
8
10
 
9
11
  def run
10
- raise InvalidOption, "The `--only-group` and `--without-group` options cannot be used together" if @options["only-group"] && @options["without-group"]
12
+ raise InvalidOption, "The `--only-group` and `--without-group` options cannot be used together" if @only_group.any? && @without_group.any?
11
13
 
12
14
  raise InvalidOption, "The `--name-only` and `--paths` options cannot be used together" if @options["name-only"] && @options[:paths]
13
15
 
14
- specs = if @options["only-group"] || @options["without-group"]
16
+ specs = if @only_group.any? || @without_group.any?
15
17
  filtered_specs_by_groups
16
18
  else
17
- Bundler.load.specs
19
+ begin
20
+ Bundler.load.specs
21
+ rescue GemNotFound => e
22
+ Bundler.ui.error e.message
23
+ Bundler.ui.warn "Install missing gems with `bundle install`."
24
+ exit 1
25
+ end
18
26
  end.reject {|s| s.name == "bundler" }.sort_by(&:name)
19
27
 
20
28
  return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
@@ -29,12 +37,12 @@ module Bundler
29
37
  Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
30
38
  end
31
39
 
32
- private
40
+ private
33
41
 
34
42
  def verify_group_exists(groups)
35
- raise InvalidOption, "`#{@options["without-group"]}` group could not be found." if @options["without-group"] && !groups.include?(@options["without-group"].to_sym)
36
-
37
- raise InvalidOption, "`#{@options["only-group"]}` group could not be found." if @options["only-group"] && !groups.include?(@options["only-group"].to_sym)
43
+ (@without_group + @only_group).each do |group|
44
+ raise InvalidOption, "`#{group}` group could not be found." unless groups.include?(group)
45
+ end
38
46
  end
39
47
 
40
48
  def filtered_specs_by_groups
@@ -44,10 +52,10 @@ module Bundler
44
52
  verify_group_exists(groups)
45
53
 
46
54
  show_groups =
47
- if @options["without-group"]
48
- groups.reject {|g| g == @options["without-group"].to_sym }
49
- elsif @options["only-group"]
50
- groups.select {|g| g == @options["only-group"].to_sym }
55
+ if @without_group.any?
56
+ groups.reject {|g| @without_group.include?(g) }
57
+ elsif @only_group.any?
58
+ groups.select {|g| @only_group.include?(g) }
51
59
  else
52
60
  groups
53
61
  end.map(&:to_sym)
@@ -21,9 +21,13 @@ module Bundler
21
21
  Bundler::Fetcher.disable_endpoint = options["full-index"]
22
22
 
23
23
  update = options[:update]
24
+ conservative = options[:conservative]
25
+
24
26
  if update.is_a?(Array) # unlocking specific gems
25
27
  Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
26
- update = { :gems => update, :lock_shared_dependencies => options[:conservative] }
28
+ update = { :gems => update, :conservative => conservative }
29
+ elsif update
30
+ update = { :conservative => conservative } if conservative
27
31
  end
28
32
  definition = Bundler.definition(update)
29
33
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class CLI::Open
7
5
  attr_reader :options, :name
@@ -19,6 +17,7 @@ module Bundler
19
17
  else
20
18
  path = spec.full_gem_path
21
19
  Dir.chdir(path) do
20
+ require "shellwords"
22
21
  command = Shellwords.split(editor) + [path]
23
22
  Bundler.with_original_env do
24
23
  system(*command)