shopify-bundler 1.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +96 -0
- data/.rubocop_todo.yml +177 -0
- data/.travis.yml +104 -0
- data/CHANGELOG.md +2131 -0
- data/CODE_OF_CONDUCT.md +42 -0
- data/CONTRIBUTING.md +32 -0
- data/DEVELOPMENT.md +118 -0
- data/ISSUES.md +96 -0
- data/LICENSE.md +23 -0
- data/README.md +40 -0
- data/Rakefile +309 -0
- data/bin/rake +14 -0
- data/bin/rspec +10 -0
- data/bin/rubocop +11 -0
- data/bundler.gemspec +34 -0
- data/exe/bundle +21 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +21 -0
- data/lib/bundler.rb +499 -0
- data/lib/bundler/capistrano.rb +16 -0
- data/lib/bundler/cli.rb +435 -0
- data/lib/bundler/cli/binstubs.rb +37 -0
- data/lib/bundler/cli/cache.rb +34 -0
- data/lib/bundler/cli/check.rb +37 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +56 -0
- data/lib/bundler/cli/config.rb +88 -0
- data/lib/bundler/cli/console.rb +37 -0
- data/lib/bundler/cli/exec.rb +51 -0
- data/lib/bundler/cli/gem.rb +208 -0
- data/lib/bundler/cli/init.rb +32 -0
- data/lib/bundler/cli/inject.rb +32 -0
- data/lib/bundler/cli/install.rb +188 -0
- data/lib/bundler/cli/lock.rb +35 -0
- data/lib/bundler/cli/open.rb +22 -0
- data/lib/bundler/cli/outdated.rb +86 -0
- data/lib/bundler/cli/package.rb +45 -0
- data/lib/bundler/cli/platform.rb +42 -0
- data/lib/bundler/cli/show.rb +74 -0
- data/lib/bundler/cli/update.rb +72 -0
- data/lib/bundler/cli/viz.rb +26 -0
- data/lib/bundler/constants.rb +5 -0
- data/lib/bundler/current_ruby.rb +218 -0
- data/lib/bundler/definition.rb +675 -0
- data/lib/bundler/dep_proxy.rb +45 -0
- data/lib/bundler/dependency.rb +119 -0
- data/lib/bundler/deployment.rb +62 -0
- data/lib/bundler/deprecate.rb +17 -0
- data/lib/bundler/dsl.rb +478 -0
- data/lib/bundler/endpoint_specification.rb +100 -0
- data/lib/bundler/env.rb +82 -0
- data/lib/bundler/environment.rb +41 -0
- data/lib/bundler/fetcher.rb +288 -0
- data/lib/bundler/fetcher/base.rb +26 -0
- data/lib/bundler/fetcher/dependency.rb +88 -0
- data/lib/bundler/fetcher/downloader.rb +60 -0
- data/lib/bundler/fetcher/index.rb +32 -0
- data/lib/bundler/friendly_errors.rb +92 -0
- data/lib/bundler/gem_helper.rb +191 -0
- data/lib/bundler/gem_helpers.rb +26 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_path_manipulation.rb +8 -0
- data/lib/bundler/gem_tasks.rb +5 -0
- data/lib/bundler/graph.rb +173 -0
- data/lib/bundler/index.rb +199 -0
- data/lib/bundler/injector.rb +62 -0
- data/lib/bundler/inline.rb +58 -0
- data/lib/bundler/installer.rb +242 -0
- data/lib/bundler/installer/parallel_installer.rb +122 -0
- data/lib/bundler/installer/standalone.rb +48 -0
- data/lib/bundler/lazy_specification.rb +82 -0
- data/lib/bundler/lockfile_parser.rb +199 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +26 -0
- data/lib/bundler/remote_specification.rb +82 -0
- data/lib/bundler/resolver.rb +350 -0
- data/lib/bundler/retry.rb +60 -0
- data/lib/bundler/ruby_dsl.rb +11 -0
- data/lib/bundler/ruby_version.rb +116 -0
- data/lib/bundler/rubygems_ext.rb +175 -0
- data/lib/bundler/rubygems_integration.rb +674 -0
- data/lib/bundler/runtime.rb +285 -0
- data/lib/bundler/settings.rb +263 -0
- data/lib/bundler/setup.rb +26 -0
- data/lib/bundler/shared_helpers.rb +176 -0
- data/lib/bundler/similarity_detector.rb +61 -0
- data/lib/bundler/source.rb +35 -0
- data/lib/bundler/source/git.rb +286 -0
- data/lib/bundler/source/git/git_proxy.rb +190 -0
- data/lib/bundler/source/path.rb +224 -0
- data/lib/bundler/source/path/installer.rb +43 -0
- data/lib/bundler/source/rubygems.rb +436 -0
- data/lib/bundler/source/rubygems/remote.rb +38 -0
- data/lib/bundler/source_list.rb +101 -0
- data/lib/bundler/spec_set.rb +156 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +25 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +32 -0
- data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
- data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
- data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +20 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +64 -0
- data/lib/bundler/stub_specification.rb +23 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/.travis.yml.tt +4 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +22 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +41 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +16 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +43 -0
- data/lib/bundler/templates/newgem/rspec.tt +2 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
- data/lib/bundler/ui.rb +7 -0
- data/lib/bundler/ui/rg_proxy.rb +17 -0
- data/lib/bundler/ui/shell.rb +108 -0
- data/lib/bundler/ui/silent.rb +44 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +277 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +3 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +99 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +434 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +43 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +51 -0
- data/lib/bundler/vendor/net/http/faster.rb +26 -0
- data/lib/bundler/vendor/net/http/persistent.rb +1230 -0
- data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +484 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +73 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +267 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_molinillo.rb +2 -0
- data/lib/bundler/vendored_persistent.rb +11 -0
- data/lib/bundler/vendored_thor.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/lib/bundler/worker.rb +72 -0
- data/man/bundle-config.ronn +187 -0
- data/man/bundle-exec.ronn +136 -0
- data/man/bundle-gem.ronn +77 -0
- data/man/bundle-install.ronn +398 -0
- data/man/bundle-package.ronn +66 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-update.ronn +188 -0
- data/man/bundle.ronn +98 -0
- data/man/gemfile.5.ronn +495 -0
- data/man/index.txt +8 -0
- metadata +346 -0
@@ -0,0 +1,285 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Runtime < Environment
|
5
|
+
include SharedHelpers
|
6
|
+
|
7
|
+
def setup(*groups)
|
8
|
+
groups.map!(&:to_sym)
|
9
|
+
|
10
|
+
# Has to happen first
|
11
|
+
clean_load_path
|
12
|
+
|
13
|
+
specs = groups.any? ? @definition.specs_for(groups) : requested_specs
|
14
|
+
|
15
|
+
setup_environment
|
16
|
+
Bundler.rubygems.replace_entrypoints(specs)
|
17
|
+
|
18
|
+
# Activate the specs
|
19
|
+
specs.each do |spec|
|
20
|
+
unless spec.loaded_from
|
21
|
+
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
|
22
|
+
end
|
23
|
+
|
24
|
+
if activated_spec = Bundler.rubygems.loaded_specs(spec.name) and activated_spec.version != spec.version
|
25
|
+
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
26
|
+
"but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
|
27
|
+
"`bundle exec` to your command may solve this."
|
28
|
+
e.name = spec.name
|
29
|
+
if e.respond_to?(:requirement=)
|
30
|
+
e.requirement = Gem::Requirement.new(spec.version.to_s)
|
31
|
+
else
|
32
|
+
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
|
33
|
+
end
|
34
|
+
raise e
|
35
|
+
end
|
36
|
+
|
37
|
+
Bundler.rubygems.mark_loaded(spec)
|
38
|
+
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
|
39
|
+
$LOAD_PATH.unshift(*load_paths)
|
40
|
+
end
|
41
|
+
|
42
|
+
setup_manpath
|
43
|
+
|
44
|
+
lock(:preserve_bundled_with => true)
|
45
|
+
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
REQUIRE_ERRORS = [
|
50
|
+
/^no such file to load -- (.+)$/i,
|
51
|
+
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
|
52
|
+
/^Missing API definition file in (.+)$/i,
|
53
|
+
/^cannot load such file -- (.+)$/i,
|
54
|
+
/^dlopen\([^)]*\): Library not loaded: (.+)$/i,
|
55
|
+
]
|
56
|
+
|
57
|
+
def require(*groups)
|
58
|
+
groups.map!(&:to_sym)
|
59
|
+
groups = [:default] if groups.empty?
|
60
|
+
|
61
|
+
@definition.dependencies.each do |dep|
|
62
|
+
# Skip the dependency if it is not in any of the requested
|
63
|
+
# groups
|
64
|
+
next unless (dep.groups & groups).any? && dep.current_platform?
|
65
|
+
|
66
|
+
required_file = nil
|
67
|
+
|
68
|
+
begin
|
69
|
+
# Loop through all the specified autorequires for the
|
70
|
+
# dependency. If there are none, use the dependency's name
|
71
|
+
# as the autorequire.
|
72
|
+
Array(dep.autorequire || dep.name).each do |file|
|
73
|
+
# Allow `require: true` as an alias for `require: <name>`
|
74
|
+
file = dep.name if file == true
|
75
|
+
required_file = file
|
76
|
+
begin
|
77
|
+
Kernel.require file
|
78
|
+
rescue => e
|
79
|
+
raise e if e.is_a?(LoadError) # we handle this a little later
|
80
|
+
raise Bundler::GemRequireError.new e,
|
81
|
+
"There was an error while trying to load the gem '#{file}'."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
rescue LoadError => e
|
85
|
+
REQUIRE_ERRORS.find {|r| r =~ e.message }
|
86
|
+
raise if dep.autorequire || $1 != required_file
|
87
|
+
|
88
|
+
if dep.autorequire.nil? && dep.name.include?("-")
|
89
|
+
begin
|
90
|
+
namespaced_file = dep.name.tr("-", "/")
|
91
|
+
Kernel.require namespaced_file
|
92
|
+
rescue LoadError => e
|
93
|
+
REQUIRE_ERRORS.find {|r| r =~ e.message }
|
94
|
+
raise if $1 != namespaced_file
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def dependencies_for(*groups)
|
102
|
+
if groups.empty?
|
103
|
+
dependencies
|
104
|
+
else
|
105
|
+
dependencies.select {|d| (groups & d.groups).any? }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
alias_method :gems, :specs
|
110
|
+
|
111
|
+
def cache(custom_path = nil)
|
112
|
+
cache_path = Bundler.app_cache(custom_path)
|
113
|
+
SharedHelpers.filesystem_access(cache_path) do |p|
|
114
|
+
FileUtils.mkdir_p(p)
|
115
|
+
end unless File.exist?(cache_path)
|
116
|
+
|
117
|
+
Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
|
118
|
+
specs.each do |spec|
|
119
|
+
next if spec.name == "bundler"
|
120
|
+
spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
|
121
|
+
spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
|
122
|
+
end
|
123
|
+
|
124
|
+
Dir[cache_path.join("*/.git")].each do |git_dir|
|
125
|
+
FileUtils.rm_rf(git_dir)
|
126
|
+
FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
|
127
|
+
end
|
128
|
+
|
129
|
+
prune_cache(cache_path) unless Bundler.settings[:no_prune]
|
130
|
+
end
|
131
|
+
|
132
|
+
def prune_cache(cache_path)
|
133
|
+
SharedHelpers.filesystem_access(cache_path) do |p|
|
134
|
+
FileUtils.mkdir_p(p)
|
135
|
+
end unless File.exist?(cache_path)
|
136
|
+
resolve = @definition.resolve
|
137
|
+
prune_gem_cache(resolve, cache_path)
|
138
|
+
prune_git_and_path_cache(resolve, cache_path)
|
139
|
+
end
|
140
|
+
|
141
|
+
def clean(dry_run = false)
|
142
|
+
gem_bins = Dir["#{Gem.dir}/bin/*"]
|
143
|
+
git_dirs = Dir["#{Gem.dir}/bundler/gems/*"]
|
144
|
+
git_cache_dirs = Dir["#{Gem.dir}/cache/bundler/git/*"]
|
145
|
+
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
146
|
+
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
|
147
|
+
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
|
148
|
+
spec_gem_paths = []
|
149
|
+
# need to keep git sources around
|
150
|
+
spec_git_paths = @definition.spec_git_paths
|
151
|
+
spec_git_cache_dirs = []
|
152
|
+
spec_gem_executables = []
|
153
|
+
spec_cache_paths = []
|
154
|
+
spec_gemspec_paths = []
|
155
|
+
specs.each do |spec|
|
156
|
+
spec_gem_paths << spec.full_gem_path
|
157
|
+
# need to check here in case gems are nested like for the rails git repo
|
158
|
+
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
|
159
|
+
spec_git_paths << md[1] if md
|
160
|
+
spec_gem_executables << spec.executables.collect do |executable|
|
161
|
+
e = "#{Bundler.rubygems.gem_bindir}/#{executable}"
|
162
|
+
[e, "#{e}.bat"]
|
163
|
+
end
|
164
|
+
spec_cache_paths << spec.cache_file
|
165
|
+
spec_gemspec_paths << spec.spec_file
|
166
|
+
spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
|
167
|
+
end
|
168
|
+
spec_gem_paths.uniq!
|
169
|
+
spec_gem_executables.flatten!
|
170
|
+
|
171
|
+
stale_gem_bins = gem_bins - spec_gem_executables
|
172
|
+
stale_git_dirs = git_dirs - spec_git_paths - ["#{Gem.dir}/bundler/gems/extensions"]
|
173
|
+
stale_git_cache_dirs = git_cache_dirs - spec_git_cache_dirs
|
174
|
+
stale_gem_dirs = gem_dirs - spec_gem_paths
|
175
|
+
stale_gem_files = gem_files - spec_cache_paths
|
176
|
+
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
177
|
+
|
178
|
+
removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
179
|
+
removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
180
|
+
output = removed_stale_gem_dirs + removed_stale_git_dirs
|
181
|
+
|
182
|
+
unless dry_run
|
183
|
+
stale_files = stale_gem_bins + stale_gem_files + stale_gemspec_files
|
184
|
+
stale_files.each {|file| FileUtils.rm(file) if File.exist?(file) }
|
185
|
+
stale_git_cache_dirs.each {|dir| FileUtils.rm_rf(dir) if File.exist?(dir) }
|
186
|
+
end
|
187
|
+
|
188
|
+
output
|
189
|
+
end
|
190
|
+
|
191
|
+
def setup_environment
|
192
|
+
begin
|
193
|
+
ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
|
194
|
+
rescue Gem::GemNotFoundException
|
195
|
+
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Set BUNDLE_GEMFILE
|
199
|
+
ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s
|
200
|
+
|
201
|
+
SharedHelpers.set_bundle_environment
|
202
|
+
end
|
203
|
+
|
204
|
+
private
|
205
|
+
|
206
|
+
def prune_gem_cache(resolve, cache_path)
|
207
|
+
cached = Dir["#{cache_path}/*.gem"]
|
208
|
+
|
209
|
+
cached = cached.delete_if do |path|
|
210
|
+
spec = Bundler.rubygems.spec_from_gem path
|
211
|
+
|
212
|
+
resolve.any? do |s|
|
213
|
+
s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
if cached.any?
|
218
|
+
Bundler.ui.info "Removing outdated .gem files from #{Bundler.settings.app_cache_path}"
|
219
|
+
|
220
|
+
cached.each do |path|
|
221
|
+
Bundler.ui.info " * #{File.basename(path)}"
|
222
|
+
File.delete(path)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def prune_git_and_path_cache(resolve, cache_path)
|
228
|
+
cached = Dir["#{cache_path}/*/.bundlecache"]
|
229
|
+
|
230
|
+
cached = cached.delete_if do |path|
|
231
|
+
name = File.basename(File.dirname(path))
|
232
|
+
|
233
|
+
resolve.any? do |s|
|
234
|
+
source = s.source
|
235
|
+
source.respond_to?(:app_cache_dirname) && source.app_cache_dirname == name
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
if cached.any?
|
240
|
+
Bundler.ui.info "Removing outdated git and path gems from #{Bundler.settings.app_cache_path}"
|
241
|
+
|
242
|
+
cached.each do |path|
|
243
|
+
path = File.dirname(path)
|
244
|
+
Bundler.ui.info " * #{File.basename(path)}"
|
245
|
+
FileUtils.rm_rf(path)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def setup_manpath
|
251
|
+
# Store original MANPATH for restoration later in with_clean_env()
|
252
|
+
ENV["BUNDLE_ORIG_MANPATH"] = ENV["MANPATH"]
|
253
|
+
|
254
|
+
# Add man/ subdirectories from activated bundles to MANPATH for man(1)
|
255
|
+
manuals = $LOAD_PATH.map do |path|
|
256
|
+
man_subdir = path.sub(/lib$/, "man")
|
257
|
+
man_subdir unless Dir[man_subdir + "/man?/"].empty?
|
258
|
+
end.compact
|
259
|
+
|
260
|
+
unless manuals.empty?
|
261
|
+
ENV["MANPATH"] = manuals.concat(
|
262
|
+
ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
|
263
|
+
).uniq.join(File::PATH_SEPARATOR)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def remove_dir(dir, dry_run)
|
268
|
+
full_name = Pathname.new(dir).basename.to_s
|
269
|
+
|
270
|
+
parts = full_name.split("-")
|
271
|
+
name = parts[0..-2].join("-")
|
272
|
+
version = parts.last
|
273
|
+
output = "#{name} (#{version})"
|
274
|
+
|
275
|
+
if dry_run
|
276
|
+
Bundler.ui.info "Would have removed #{output}"
|
277
|
+
else
|
278
|
+
Bundler.ui.info "Removing #{output}"
|
279
|
+
FileUtils.rm_rf(dir)
|
280
|
+
end
|
281
|
+
|
282
|
+
output
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Settings
|
5
|
+
BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check ignore_messages gem.mit gem.coc).freeze
|
6
|
+
NUMBER_KEYS = %w(retry timeout redirect).freeze
|
7
|
+
DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }
|
8
|
+
|
9
|
+
def initialize(root = nil)
|
10
|
+
@root = root
|
11
|
+
@local_config = load_config(local_config_file)
|
12
|
+
@global_config = load_config(global_config_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](name)
|
16
|
+
key = key_for(name)
|
17
|
+
value = (@local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name])
|
18
|
+
|
19
|
+
case
|
20
|
+
when value.nil?
|
21
|
+
nil
|
22
|
+
when is_bool(name) || value == "false"
|
23
|
+
to_bool(value)
|
24
|
+
when is_num(name)
|
25
|
+
value.to_i
|
26
|
+
else
|
27
|
+
value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def []=(key, value)
|
32
|
+
local_config_file or raise GemfileNotFound, "Could not locate Gemfile"
|
33
|
+
set_key(key, value, @local_config, local_config_file)
|
34
|
+
end
|
35
|
+
|
36
|
+
alias_method :set_local, :[]=
|
37
|
+
|
38
|
+
def delete(key)
|
39
|
+
@local_config.delete(key_for(key))
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_global(key, value)
|
43
|
+
set_key(key, value, @global_config, global_config_file)
|
44
|
+
end
|
45
|
+
|
46
|
+
def all
|
47
|
+
env_keys = ENV.keys.select {|k| k =~ /BUNDLE_.*/ }
|
48
|
+
|
49
|
+
keys = @global_config.keys | @local_config.keys | env_keys
|
50
|
+
|
51
|
+
keys.map do |key|
|
52
|
+
key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def local_overrides
|
57
|
+
repos = {}
|
58
|
+
all.each do |k|
|
59
|
+
if k =~ /^local\./
|
60
|
+
repos[$'] = self[k]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
repos
|
64
|
+
end
|
65
|
+
|
66
|
+
def mirror_for(uri)
|
67
|
+
uri = URI(uri.to_s) unless uri.is_a?(URI)
|
68
|
+
|
69
|
+
# Settings keys are all downcased
|
70
|
+
normalized_key = normalize_uri(uri.to_s.downcase)
|
71
|
+
gem_mirrors[normalized_key] || uri
|
72
|
+
end
|
73
|
+
|
74
|
+
def credentials_for(uri)
|
75
|
+
self[uri.to_s] || self[uri.host]
|
76
|
+
end
|
77
|
+
|
78
|
+
def gem_mirrors
|
79
|
+
all.inject({}) do |h, k|
|
80
|
+
if k =~ /^mirror\./
|
81
|
+
uri = normalize_uri($')
|
82
|
+
h[uri] = normalize_uri(self[k])
|
83
|
+
end
|
84
|
+
h
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def locations(key)
|
89
|
+
key = key_for(key)
|
90
|
+
locations = {}
|
91
|
+
locations[:local] = @local_config[key] if @local_config.key?(key)
|
92
|
+
locations[:env] = ENV[key] if ENV[key]
|
93
|
+
locations[:global] = @global_config[key] if @global_config.key?(key)
|
94
|
+
locations[:default] = DEFAULT_CONFIG[key] if DEFAULT_CONFIG.key?(key)
|
95
|
+
locations
|
96
|
+
end
|
97
|
+
|
98
|
+
def pretty_values_for(exposed_key)
|
99
|
+
key = key_for(exposed_key)
|
100
|
+
|
101
|
+
locations = []
|
102
|
+
if @local_config.key?(key)
|
103
|
+
locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
|
104
|
+
end
|
105
|
+
|
106
|
+
if value = ENV[key]
|
107
|
+
locations << "Set via #{key}: #{value.inspect}"
|
108
|
+
end
|
109
|
+
|
110
|
+
if @global_config.key?(key)
|
111
|
+
locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
|
112
|
+
end
|
113
|
+
|
114
|
+
return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
|
115
|
+
locations
|
116
|
+
end
|
117
|
+
|
118
|
+
def without=(array)
|
119
|
+
set_array(:without, array)
|
120
|
+
end
|
121
|
+
|
122
|
+
def with=(array)
|
123
|
+
set_array(:with, array)
|
124
|
+
end
|
125
|
+
|
126
|
+
def without
|
127
|
+
get_array(:without)
|
128
|
+
end
|
129
|
+
|
130
|
+
def with
|
131
|
+
get_array(:with)
|
132
|
+
end
|
133
|
+
|
134
|
+
# @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
|
135
|
+
def path
|
136
|
+
key = key_for(:path)
|
137
|
+
path = ENV[key] || @global_config[key]
|
138
|
+
return path if path && !@local_config.key?(key)
|
139
|
+
|
140
|
+
if path = self[:path]
|
141
|
+
"#{path}/#{Bundler.ruby_scope}"
|
142
|
+
else
|
143
|
+
Bundler.rubygems.gem_dir
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def allow_sudo?
|
148
|
+
!@local_config.key?(key_for(:path))
|
149
|
+
end
|
150
|
+
|
151
|
+
def ignore_config?
|
152
|
+
ENV["BUNDLE_IGNORE_CONFIG"]
|
153
|
+
end
|
154
|
+
|
155
|
+
def app_cache_path
|
156
|
+
@app_cache_path ||= begin
|
157
|
+
path = self[:cache_path] || "vendor/cache"
|
158
|
+
raise InvalidOption, "Cache path must be relative to the bundle path" if path.start_with?("/")
|
159
|
+
path
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def key_for(key)
|
166
|
+
if key.is_a?(String) && /https?:/ =~ key
|
167
|
+
key = normalize_uri(key).to_s
|
168
|
+
end
|
169
|
+
key = key.to_s.gsub(".", "__").upcase
|
170
|
+
"BUNDLE_#{key}"
|
171
|
+
end
|
172
|
+
|
173
|
+
def parent_setting_for(name)
|
174
|
+
split_specfic_setting_for(name)[0]
|
175
|
+
end
|
176
|
+
|
177
|
+
def specfic_gem_for(name)
|
178
|
+
split_specfic_setting_for(name)[1]
|
179
|
+
end
|
180
|
+
|
181
|
+
def split_specfic_setting_for(name)
|
182
|
+
name.split(".")
|
183
|
+
end
|
184
|
+
|
185
|
+
def is_bool(name)
|
186
|
+
BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
|
187
|
+
end
|
188
|
+
|
189
|
+
def to_bool(value)
|
190
|
+
!(value.nil? || value == "" || value =~ /^(false|f|no|n|0)$/i || value == false)
|
191
|
+
end
|
192
|
+
|
193
|
+
def is_num(value)
|
194
|
+
NUMBER_KEYS.include?(value.to_s)
|
195
|
+
end
|
196
|
+
|
197
|
+
def get_array(key)
|
198
|
+
self[key] ? self[key].split(":").map(&:to_sym) : []
|
199
|
+
end
|
200
|
+
|
201
|
+
def set_array(key, array)
|
202
|
+
self[key] = (array.empty? ? nil : array.join(":")) if array
|
203
|
+
end
|
204
|
+
|
205
|
+
def set_key(key, value, hash, file)
|
206
|
+
key = key_for(key)
|
207
|
+
|
208
|
+
unless hash[key] == value
|
209
|
+
hash[key] = value
|
210
|
+
hash.delete(key) if value.nil?
|
211
|
+
SharedHelpers.filesystem_access(file) do |p|
|
212
|
+
FileUtils.mkdir_p(p.dirname)
|
213
|
+
require "bundler/psyched_yaml"
|
214
|
+
File.open(p, "w") {|f| f.puts YAML.dump(hash) }
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
value
|
219
|
+
end
|
220
|
+
|
221
|
+
def global_config_file
|
222
|
+
file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config")
|
223
|
+
Pathname.new(file)
|
224
|
+
end
|
225
|
+
|
226
|
+
def local_config_file
|
227
|
+
Pathname.new(@root).join("config") if @root
|
228
|
+
end
|
229
|
+
|
230
|
+
def load_config(config_file)
|
231
|
+
valid_file = config_file && config_file.exist? && !config_file.size.zero?
|
232
|
+
if !ignore_config? && valid_file
|
233
|
+
config_regex = /^(BUNDLE_.+): (['"]?)(.*(?:\n(?!BUNDLE).+)?)\2$/
|
234
|
+
raise PermissionError.new(config_file, :read) unless config_file.readable?
|
235
|
+
config_pairs = config_file.read.scan(config_regex).map do |m|
|
236
|
+
key, _, value = m
|
237
|
+
[convert_to_backward_compatible_key(key), value.gsub(/\s+/, " ").tr('"', "'")]
|
238
|
+
end
|
239
|
+
Hash[config_pairs]
|
240
|
+
else
|
241
|
+
{}
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def convert_to_backward_compatible_key(key)
|
246
|
+
key = "#{key}/" if key =~ /https?:/i && key !~ %r[/\Z]
|
247
|
+
key = key.gsub(".", "__") if key.include?(".")
|
248
|
+
key
|
249
|
+
end
|
250
|
+
|
251
|
+
# TODO: duplicates Rubygems#normalize_uri
|
252
|
+
# TODO: is this the correct place to validate mirror URIs?
|
253
|
+
def normalize_uri(uri)
|
254
|
+
uri = uri.to_s
|
255
|
+
uri = "#{uri}/" unless uri =~ %r[/\Z]
|
256
|
+
uri = URI(uri)
|
257
|
+
unless uri.absolute?
|
258
|
+
raise ArgumentError, "Gem sources must be absolute. You provided '#{uri}'."
|
259
|
+
end
|
260
|
+
uri
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|