rubygems-update 3.2.33 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -4
- data/CONTRIBUTING.md +40 -10
- data/Manifest.txt +7 -5
- data/POLICIES.md +22 -8
- data/README.md +9 -7
- data/UPGRADING.md +5 -81
- data/bin/gem +1 -6
- data/bundler/CHANGELOG.md +47 -0
- data/bundler/exe/bundle +7 -8
- data/bundler/lib/bundler/.document +1 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/gem.rb +1 -1
- data/bundler/lib/bundler/cli/install.rb +2 -3
- data/bundler/lib/bundler/cli.rb +5 -0
- data/bundler/lib/bundler/definition.rb +14 -5
- data/bundler/lib/bundler/dependency.rb +5 -7
- data/bundler/lib/bundler/dsl.rb +0 -27
- data/bundler/lib/bundler/endpoint_specification.rb +0 -8
- data/bundler/lib/bundler/fetcher/compact_index.rb +9 -4
- data/bundler/lib/bundler/fetcher.rb +2 -5
- data/bundler/lib/bundler/injector.rb +10 -1
- data/bundler/lib/bundler/installer/gem_installer.rb +1 -6
- data/bundler/lib/bundler/installer.rb +1 -4
- data/bundler/lib/bundler/lockfile_parser.rb +10 -13
- data/bundler/lib/bundler/man/bundle-add.1 +9 -1
- data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
- data/bundler/lib/bundler/man/bundle-config.1 +2 -2
- data/bundler/lib/bundler/man/bundle-config.1.ronn +3 -3
- data/bundler/lib/bundler/man/bundle-install.1 +1 -1
- data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
- data/bundler/lib/bundler/man/bundle-update.1 +1 -1
- data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/bundler/lib/bundler/man/gemfile.5 +1 -1
- data/bundler/lib/bundler/man/gemfile.5.ronn +1 -1
- data/bundler/lib/bundler/plugin/installer.rb +1 -1
- data/bundler/lib/bundler/process_lock.rb +1 -1
- data/bundler/lib/bundler/psyched_yaml.rb +1 -13
- data/bundler/lib/bundler/resolver.rb +34 -29
- data/bundler/lib/bundler/rubygems_ext.rb +2 -0
- data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
- data/bundler/lib/bundler/rubygems_integration.rb +11 -48
- data/bundler/lib/bundler/self_manager.rb +76 -0
- data/bundler/lib/bundler/settings.rb +1 -0
- data/bundler/lib/bundler/shared_helpers.rb +2 -9
- data/bundler/lib/bundler/source/metadata.rb +1 -1
- data/bundler/lib/bundler/templates/Executable.bundler +1 -1
- data/bundler/lib/bundler/templates/Gemfile +0 -2
- data/bundler/lib/bundler/templates/gems.rb +0 -3
- data/bundler/lib/bundler/templates/newgem/Rakefile.tt +10 -1
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/bundler/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/bundler/lib/bundler/ui/shell.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +5 -3
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
- data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
- data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
- data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/lib/bundler.rb +9 -3
- data/hide_lib_for_update/note.txt +0 -4
- data/lib/rubygems/bundler_version_finder.rb +10 -42
- data/lib/rubygems/command_manager.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +5 -2
- data/lib/rubygems/commands/server_command.rb +14 -77
- data/lib/rubygems/commands/setup_command.rb +4 -16
- data/lib/rubygems/commands/update_command.rb +9 -4
- data/lib/rubygems/defaults.rb +2 -20
- data/lib/rubygems/dependency.rb +7 -7
- data/lib/rubygems/deprecate.rb +53 -6
- data/lib/rubygems/errors.rb +0 -3
- data/lib/rubygems/exceptions.rb +30 -1
- data/lib/rubygems/ext/builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +11 -2
- data/lib/rubygems/installer.rb +11 -1
- data/lib/rubygems/name_tuple.rb +2 -3
- data/lib/rubygems/path_support.rb +1 -6
- data/lib/rubygems/platform.rb +4 -0
- data/lib/rubygems/remote_fetcher.rb +1 -1
- data/lib/rubygems/requirement.rb +1 -1
- data/lib/rubygems/resolver/installer_set.rb +1 -1
- data/lib/rubygems/security/policy.rb +1 -3
- data/lib/rubygems/security.rb +14 -7
- data/lib/rubygems/source.rb +3 -1
- data/lib/rubygems/spec_fetcher.rb +1 -1
- data/lib/rubygems/specification.rb +12 -16
- data/lib/rubygems/stub_specification.rb +1 -1
- data/lib/rubygems/text.rb +21 -20
- data/lib/rubygems/uninstaller.rb +4 -1
- data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
- data/lib/rubygems/version.rb +2 -0
- data/lib/rubygems.rb +54 -55
- data/rubygems-update.gemspec +1 -1
- data/setup.rb +1 -6
- data/test/rubygems/helper.rb +20 -6
- data/test/rubygems/test_config.rb +2 -2
- data/test/rubygems/test_exit.rb +11 -0
- data/test/rubygems/test_gem.rb +46 -76
- data/test/rubygems/test_gem_bundler_version_finder.rb +22 -43
- data/test/rubygems/test_gem_command_manager.rb +16 -2
- data/test/rubygems/test_gem_commands_install_command.rb +33 -0
- data/test/rubygems/test_gem_commands_open_command.rb +1 -1
- data/test/rubygems/test_gem_commands_server_command.rb +4 -46
- data/test/rubygems/test_gem_commands_update_command.rb +2 -2
- data/test/rubygems/test_gem_dependency.rb +4 -8
- data/test/rubygems/test_gem_installer.rb +0 -27
- data/test/rubygems/test_gem_path_support.rb +2 -6
- data/test/rubygems/test_gem_remote_fetcher.rb +15 -0
- data/test/rubygems/test_gem_requirement.rb +0 -1
- data/test/rubygems/test_gem_security.rb +1 -1
- data/test/rubygems/test_gem_specification.rb +16 -25
- data/test/rubygems/test_gem_stream_ui.rb +1 -1
- data/test/rubygems/test_gem_text.rb +6 -0
- data/test/rubygems/test_kernel.rb +1 -13
- data/test/rubygems/test_project_sanity.rb +1 -1
- data/test/rubygems/test_require.rb +0 -32
- data/test/rubygems/test_rubygems.rb +23 -0
- metadata +10 -8
- data/bundler/lib/bundler/gemdeps.rb +0 -29
- data/lib/rubygems/server.rb +0 -882
- data/test/rubygems/bogussources.rb +0 -9
- data/test/rubygems/test_gem_server.rb +0 -608
@@ -12,25 +12,21 @@ module Bundler
|
|
12
12
|
EXT_LOCK = Monitor.new
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.version
|
16
|
-
@version ||= Gem::Version.new(Gem::VERSION)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.provides?(req_str)
|
20
|
-
Gem::Requirement.new(req_str).satisfied_by?(version)
|
21
|
-
end
|
22
|
-
|
23
15
|
def initialize
|
24
16
|
@replaced_methods = {}
|
25
17
|
backport_ext_builder_monitor
|
26
18
|
end
|
27
19
|
|
28
20
|
def version
|
29
|
-
|
21
|
+
@version ||= Gem.rubygems_version
|
30
22
|
end
|
31
23
|
|
32
24
|
def provides?(req_str)
|
33
|
-
|
25
|
+
Gem::Requirement.new(req_str).satisfied_by?(version)
|
26
|
+
end
|
27
|
+
|
28
|
+
def supports_bundler_trampolining?
|
29
|
+
provides?(">= 3.3.0.a")
|
34
30
|
end
|
35
31
|
|
36
32
|
def build_args
|
@@ -115,7 +111,7 @@ module Bundler
|
|
115
111
|
Bundler.ui.error "#{e.class}: #{e.message}"
|
116
112
|
Bundler.ui.trace e
|
117
113
|
raise
|
118
|
-
rescue
|
114
|
+
rescue ::Psych::SyntaxError => e
|
119
115
|
raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
|
120
116
|
"usually located in ~/.gemrc, contains invalid YAML syntax.")
|
121
117
|
end
|
@@ -142,19 +138,6 @@ module Bundler
|
|
142
138
|
end
|
143
139
|
end
|
144
140
|
|
145
|
-
def sources=(val)
|
146
|
-
# Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
|
147
|
-
# If that file exists, its settings (including sources) will overwrite the values we
|
148
|
-
# are about to set here. In order to avoid that, we force memoizing the config file now.
|
149
|
-
configuration
|
150
|
-
|
151
|
-
Gem.sources = val
|
152
|
-
end
|
153
|
-
|
154
|
-
def sources
|
155
|
-
Gem.sources
|
156
|
-
end
|
157
|
-
|
158
141
|
def gem_dir
|
159
142
|
Gem.dir
|
160
143
|
end
|
@@ -232,18 +215,6 @@ module Bundler
|
|
232
215
|
EXT_LOCK
|
233
216
|
end
|
234
217
|
|
235
|
-
def with_build_args(args)
|
236
|
-
ext_lock.synchronize do
|
237
|
-
old_args = build_args
|
238
|
-
begin
|
239
|
-
self.build_args = args
|
240
|
-
yield
|
241
|
-
ensure
|
242
|
-
self.build_args = old_args
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
218
|
def spec_from_gem(path, policy = nil)
|
248
219
|
require "rubygems/security"
|
249
220
|
require_relative "psyched_yaml"
|
@@ -571,10 +542,6 @@ module Bundler
|
|
571
542
|
Gem::REPOSITORY_SUBDIRECTORIES
|
572
543
|
end
|
573
544
|
|
574
|
-
def install_with_build_args(args)
|
575
|
-
yield
|
576
|
-
end
|
577
|
-
|
578
545
|
def path_separator
|
579
546
|
Gem.path_separator
|
580
547
|
end
|
@@ -604,6 +571,10 @@ module Bundler
|
|
604
571
|
end
|
605
572
|
end
|
606
573
|
|
574
|
+
def find_bundler(version)
|
575
|
+
find_name("bundler").find {|s| s.version.to_s == version }
|
576
|
+
end
|
577
|
+
|
607
578
|
def find_name(name)
|
608
579
|
Gem::Specification.stubs_for(name).map(&:to_spec)
|
609
580
|
end
|
@@ -617,14 +588,6 @@ module Bundler
|
|
617
588
|
Gem::Specification.send(:default_stubs, "*.gemspec")
|
618
589
|
end
|
619
590
|
end
|
620
|
-
|
621
|
-
def use_gemdeps(gemfile)
|
622
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
|
623
|
-
require_relative "gemdeps"
|
624
|
-
runtime = Bundler.setup
|
625
|
-
activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
|
626
|
-
[Gemdeps.new(runtime), activated_spec_names]
|
627
|
-
end
|
628
591
|
end
|
629
592
|
|
630
593
|
def self.rubygems
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
#
|
5
|
+
# This class handles installing and switching to the version of bundler needed
|
6
|
+
# by an application.
|
7
|
+
#
|
8
|
+
class SelfManager
|
9
|
+
def restart_with_locked_bundler_if_needed
|
10
|
+
return unless needs_switching? && installed?
|
11
|
+
|
12
|
+
restart_with_locked_bundler
|
13
|
+
end
|
14
|
+
|
15
|
+
def install_locked_bundler_and_restart_with_it_if_needed
|
16
|
+
return unless needs_switching?
|
17
|
+
|
18
|
+
Bundler.ui.info \
|
19
|
+
"Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
|
20
|
+
"Installing Bundler #{lockfile_version} and restarting using that version."
|
21
|
+
|
22
|
+
install_and_restart_with_locked_bundler
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def install_and_restart_with_locked_bundler
|
28
|
+
bundler_dep = Gem::Dependency.new("bundler", lockfile_version)
|
29
|
+
|
30
|
+
Gem.install(bundler_dep)
|
31
|
+
rescue StandardError => e
|
32
|
+
Bundler.ui.trace e
|
33
|
+
Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
|
34
|
+
else
|
35
|
+
restart_with_locked_bundler
|
36
|
+
end
|
37
|
+
|
38
|
+
def restart_with_locked_bundler
|
39
|
+
configured_gem_home = ENV["GEM_HOME"]
|
40
|
+
configured_gem_path = ENV["GEM_PATH"]
|
41
|
+
|
42
|
+
cmd = [$PROGRAM_NAME, *ARGV]
|
43
|
+
cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
|
44
|
+
|
45
|
+
Bundler.with_original_env do
|
46
|
+
Kernel.exec(
|
47
|
+
{ "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => lockfile_version },
|
48
|
+
*cmd
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def needs_switching?
|
54
|
+
ENV["BUNDLER_VERSION"].nil? &&
|
55
|
+
Bundler.rubygems.supports_bundler_trampolining? &&
|
56
|
+
SharedHelpers.in_bundle? &&
|
57
|
+
lockfile_version &&
|
58
|
+
!lockfile_version.end_with?(".dev") &&
|
59
|
+
lockfile_version != current_version
|
60
|
+
end
|
61
|
+
|
62
|
+
def installed?
|
63
|
+
Bundler.configure
|
64
|
+
|
65
|
+
Bundler.rubygems.find_bundler(lockfile_version)
|
66
|
+
end
|
67
|
+
|
68
|
+
def current_version
|
69
|
+
@current_version ||= Bundler::VERSION
|
70
|
+
end
|
71
|
+
|
72
|
+
def lockfile_version
|
73
|
+
@lockfile_version ||= Bundler::LockfileParser.bundled_with
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -219,6 +219,7 @@ module Bundler
|
|
219
219
|
def path
|
220
220
|
configs.each do |_level, settings|
|
221
221
|
path = value_for("path", settings)
|
222
|
+
path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
|
222
223
|
path_system = value_for("path.system", settings)
|
223
224
|
disabled_shared_gems = value_for("disable_shared_gems", settings)
|
224
225
|
next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
|
@@ -109,7 +109,7 @@ module Bundler
|
|
109
109
|
raise VirtualProtocolError.new
|
110
110
|
rescue Errno::ENOSPC
|
111
111
|
raise NoSpaceOnDeviceError.new(path, action)
|
112
|
-
rescue
|
112
|
+
rescue Errno::ENOTSUP
|
113
113
|
raise OperationNotSupportedError.new(path, action)
|
114
114
|
rescue Errno::EEXIST, Errno::ENOENT
|
115
115
|
raise
|
@@ -117,13 +117,6 @@ module Bundler
|
|
117
117
|
raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
|
118
118
|
end
|
119
119
|
|
120
|
-
def const_get_safely(constant_name, namespace)
|
121
|
-
const_in_namespace = namespace.constants.include?(constant_name.to_s) ||
|
122
|
-
namespace.constants.include?(constant_name.to_sym)
|
123
|
-
return nil unless const_in_namespace
|
124
|
-
namespace.const_get(constant_name)
|
125
|
-
end
|
126
|
-
|
127
120
|
def major_deprecation(major_version, message, print_caller_location: false)
|
128
121
|
if print_caller_location
|
129
122
|
caller_location = caller_locations(2, 2).first
|
@@ -246,7 +239,7 @@ module Bundler
|
|
246
239
|
current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
|
247
240
|
|
248
241
|
until !File.directory?(current) || current == previous
|
249
|
-
if ENV["
|
242
|
+
if ENV["BUNDLER_SPEC_RUN"]
|
250
243
|
# avoid stepping above the tmp directory when testing
|
251
244
|
gemspec = if ENV["GEM_COMMAND"]
|
252
245
|
# for Ruby Core
|
@@ -25,7 +25,7 @@ module Bundler
|
|
25
25
|
s.loaded_from = File.expand_path("..", __FILE__)
|
26
26
|
end
|
27
27
|
|
28
|
-
if local_spec = Bundler.rubygems.
|
28
|
+
if local_spec = Bundler.rubygems.find_bundler(VERSION)
|
29
29
|
idx << local_spec
|
30
30
|
end
|
31
31
|
|
@@ -73,7 +73,7 @@ m = Module.new do
|
|
73
73
|
|
74
74
|
requirement = bundler_gem_version.approximate_recommendation
|
75
75
|
|
76
|
-
return requirement unless Gem
|
76
|
+
return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
|
77
77
|
|
78
78
|
requirement += ".a" if bundler_gem_version.prerelease?
|
79
79
|
|
@@ -3,7 +3,16 @@
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
<% default_task_names = [config[:test_task]].compact -%>
|
5
5
|
<% case config[:test] -%>
|
6
|
-
<% when "minitest"
|
6
|
+
<% when "minitest" -%>
|
7
|
+
require "rake/testtask"
|
8
|
+
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << "test"
|
11
|
+
t.libs << "lib"
|
12
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
13
|
+
end
|
14
|
+
|
15
|
+
<% when "test-unit" -%>
|
7
16
|
require "rake/testtask"
|
8
17
|
|
9
18
|
Rake::TestTask.new(:test) do |t|
|
@@ -39,6 +39,6 @@ Gem::Specification.new do |spec|
|
|
39
39
|
# Uncomment to register a new dependency of your gem
|
40
40
|
# spec.add_dependency "example-gem", "~> 1.0"
|
41
41
|
|
42
|
-
# For more information and examples about making a new gem,
|
42
|
+
# For more information and examples about making a new gem, check out our
|
43
43
|
# guide at: https://bundler.io/guides/creating_gem.html
|
44
44
|
end
|
@@ -210,9 +210,9 @@ class Bundler::Thor
|
|
210
210
|
#
|
211
211
|
# ==== Examples
|
212
212
|
#
|
213
|
-
# inject_into_class "app/controllers/application_controller.rb", ApplicationController, " filter_parameter :password\n"
|
213
|
+
# inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " filter_parameter :password\n"
|
214
214
|
#
|
215
|
-
# inject_into_class "app/controllers/application_controller.rb", ApplicationController do
|
215
|
+
# inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
216
216
|
# " filter_parameter :password\n"
|
217
217
|
# end
|
218
218
|
#
|
@@ -233,9 +233,9 @@ class Bundler::Thor
|
|
233
233
|
#
|
234
234
|
# ==== Examples
|
235
235
|
#
|
236
|
-
# inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, " def help; 'help'; end\n"
|
236
|
+
# inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n"
|
237
237
|
#
|
238
|
-
# inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do
|
238
|
+
# inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do
|
239
239
|
# " def help; 'help'; end\n"
|
240
240
|
# end
|
241
241
|
#
|
@@ -252,7 +252,7 @@ class Bundler::Thor
|
|
252
252
|
# flag<Regexp|String>:: the regexp or string to be replaced
|
253
253
|
# replacement<String>:: the replacement, can be also given as a block
|
254
254
|
# config<Hash>:: give :verbose => false to not log the status, and
|
255
|
-
# :force => true, to force the replacement
|
255
|
+
# :force => true, to force the replacement regardles of runner behavior.
|
256
256
|
#
|
257
257
|
# ==== Example
|
258
258
|
#
|
@@ -331,7 +331,7 @@ class Bundler::Thor
|
|
331
331
|
path = File.expand_path(path, destination_root)
|
332
332
|
|
333
333
|
say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
|
334
|
-
if !options[:pretend] && File.exist?(path)
|
334
|
+
if !options[:pretend] && (File.exist?(path) || File.symlink?(path))
|
335
335
|
require "fileutils"
|
336
336
|
::FileUtils.rm_rf(path)
|
337
337
|
end
|
@@ -106,12 +106,14 @@ class Bundler::Thor
|
|
106
106
|
# Adds the content to the file.
|
107
107
|
#
|
108
108
|
def replace!(regexp, string, force)
|
109
|
-
return if pretend?
|
110
109
|
content = File.read(destination)
|
111
|
-
|
110
|
+
before, after = content.split(regexp, 2)
|
111
|
+
snippet = (behavior == :after ? after : before).to_s
|
112
|
+
|
113
|
+
if force || !snippet.include?(replacement)
|
112
114
|
success = content.gsub!(regexp, string)
|
113
115
|
|
114
|
-
File.open(destination, "wb") { |file| file.write(content) }
|
116
|
+
File.open(destination, "wb") { |file| file.write(content) } unless pretend?
|
115
117
|
success
|
116
118
|
end
|
117
119
|
end
|
@@ -161,6 +161,8 @@ class Bundler::Thor
|
|
161
161
|
# to the block you provide. The path is set back to the previous path when
|
162
162
|
# the method exits.
|
163
163
|
#
|
164
|
+
# Returns the value yielded by the block.
|
165
|
+
#
|
164
166
|
# ==== Parameters
|
165
167
|
# dir<String>:: the directory to move to.
|
166
168
|
# config<Hash>:: give :verbose => true to log and use padding.
|
@@ -179,16 +181,18 @@ class Bundler::Thor
|
|
179
181
|
FileUtils.mkdir_p(destination_root)
|
180
182
|
end
|
181
183
|
|
184
|
+
result = nil
|
182
185
|
if pretend
|
183
186
|
# In pretend mode, just yield down to the block
|
184
|
-
block.arity == 1 ? yield(destination_root) : yield
|
187
|
+
result = block.arity == 1 ? yield(destination_root) : yield
|
185
188
|
else
|
186
189
|
require "fileutils"
|
187
|
-
FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
|
190
|
+
FileUtils.cd(destination_root) { result = block.arity == 1 ? yield(destination_root) : yield }
|
188
191
|
end
|
189
192
|
|
190
193
|
@destination_stack.pop
|
191
194
|
shell.padding -= 1 if verbose
|
195
|
+
result
|
192
196
|
end
|
193
197
|
|
194
198
|
# Goes to the root and execute the given block.
|
@@ -102,9 +102,14 @@ class Bundler::Thor
|
|
102
102
|
end
|
103
103
|
|
104
104
|
if Correctable
|
105
|
-
DidYouMean
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
if DidYouMean.respond_to?(:correct_error)
|
106
|
+
DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
|
107
|
+
DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
|
108
|
+
else
|
109
|
+
DidYouMean::SPELL_CHECKERS.merge!(
|
110
|
+
'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
|
111
|
+
'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
|
112
|
+
)
|
113
|
+
end
|
109
114
|
end
|
110
115
|
end
|
@@ -45,6 +45,7 @@ class Bundler::Thor
|
|
45
45
|
@switches = {}
|
46
46
|
@extra = []
|
47
47
|
@stopped_parsing_after_extra_index = nil
|
48
|
+
@is_treated_as_value = false
|
48
49
|
|
49
50
|
options.each do |option|
|
50
51
|
@switches[option.switch_name] = option
|
@@ -74,8 +75,19 @@ class Bundler::Thor
|
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
78
|
+
def shift
|
79
|
+
@is_treated_as_value = false
|
80
|
+
super
|
81
|
+
end
|
82
|
+
|
83
|
+
def unshift(arg, is_value: false)
|
84
|
+
@is_treated_as_value = is_value
|
85
|
+
super(arg)
|
86
|
+
end
|
87
|
+
|
77
88
|
def parse(args) # rubocop:disable MethodLength
|
78
89
|
@pile = args.dup
|
90
|
+
@is_treated_as_value = false
|
79
91
|
@parsing_options = true
|
80
92
|
|
81
93
|
while peek
|
@@ -88,7 +100,10 @@ class Bundler::Thor
|
|
88
100
|
when SHORT_SQ_RE
|
89
101
|
unshift($1.split("").map { |f| "-#{f}" })
|
90
102
|
next
|
91
|
-
when EQ_RE
|
103
|
+
when EQ_RE
|
104
|
+
unshift($2, is_value: true)
|
105
|
+
switch = $1
|
106
|
+
when SHORT_NUM
|
92
107
|
unshift($2)
|
93
108
|
switch = $1
|
94
109
|
when LONG_RE, SHORT_RE
|
@@ -148,6 +163,7 @@ class Bundler::Thor
|
|
148
163
|
# Two booleans are returned. The first is true if the current value
|
149
164
|
# starts with a hyphen; the second is true if it is a registered switch.
|
150
165
|
def current_is_switch?
|
166
|
+
return [false, false] if @is_treated_as_value
|
151
167
|
case peek
|
152
168
|
when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
|
153
169
|
[true, switch?($1)]
|
@@ -159,6 +175,7 @@ class Bundler::Thor
|
|
159
175
|
end
|
160
176
|
|
161
177
|
def current_is_switch_formatted?
|
178
|
+
return false if @is_treated_as_value
|
162
179
|
case peek
|
163
180
|
when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
|
164
181
|
true
|
@@ -168,6 +185,7 @@ class Bundler::Thor
|
|
168
185
|
end
|
169
186
|
|
170
187
|
def current_is_value?
|
188
|
+
return true if @is_treated_as_value
|
171
189
|
peek && (!parsing_options? || super)
|
172
190
|
end
|
173
191
|
|
@@ -103,6 +103,23 @@ class Bundler::Thor
|
|
103
103
|
stdout.flush
|
104
104
|
end
|
105
105
|
|
106
|
+
# Say (print) an error to the user. If the sentence ends with a whitespace
|
107
|
+
# or tab character, a new line is not appended (print + flush). Otherwise
|
108
|
+
# are passed straight to puts (behavior got from Highline).
|
109
|
+
#
|
110
|
+
# ==== Example
|
111
|
+
# say_error("error: something went wrong")
|
112
|
+
#
|
113
|
+
def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
114
|
+
return if quiet?
|
115
|
+
|
116
|
+
buffer = prepare_message(message, *color)
|
117
|
+
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
|
118
|
+
|
119
|
+
stderr.print(buffer)
|
120
|
+
stderr.flush
|
121
|
+
end
|
122
|
+
|
106
123
|
# Say a status with the given color and appends the message. Since this
|
107
124
|
# method is used frequently by actions, it allows nil or false to be given
|
108
125
|
# in log_status, avoiding the message from being shown. If a Symbol is
|
@@ -111,13 +128,14 @@ class Bundler::Thor
|
|
111
128
|
def say_status(status, message, log_status = true)
|
112
129
|
return if quiet? || log_status == false
|
113
130
|
spaces = " " * (padding + 1)
|
114
|
-
color = log_status.is_a?(Symbol) ? log_status : :green
|
115
|
-
|
116
131
|
status = status.to_s.rjust(12)
|
132
|
+
margin = " " * status.length + spaces
|
133
|
+
|
134
|
+
color = log_status.is_a?(Symbol) ? log_status : :green
|
117
135
|
status = set_color status, color, true if color
|
118
136
|
|
119
|
-
|
120
|
-
buffer = "#{
|
137
|
+
message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
|
138
|
+
buffer = "#{status}#{spaces}#{message}\n"
|
121
139
|
|
122
140
|
stdout.print(buffer)
|
123
141
|
stdout.flush
|
@@ -21,7 +21,7 @@ class Bundler::Thor
|
|
21
21
|
end
|
22
22
|
|
23
23
|
module Shell
|
24
|
-
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
24
|
+
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_error, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
25
25
|
attr_writer :shell
|
26
26
|
|
27
27
|
autoload :Basic, File.expand_path("shell/basic", __dir__)
|
@@ -211,7 +211,7 @@ class Bundler::Thor
|
|
211
211
|
#
|
212
212
|
def globs_for(path)
|
213
213
|
path = escape_globs(path)
|
214
|
-
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks
|
214
|
+
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/**/*.thor"]
|
215
215
|
end
|
216
216
|
|
217
217
|
# Return the path to the ruby interpreter taking into account multiple
|