bundler 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3111 -0
- data/LICENSE.md +23 -0
- data/README.md +63 -0
- data/bundler.gemspec +65 -0
- data/exe/bundle +31 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +4 -0
- data/lib/bundler.rb +567 -0
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +22 -0
- data/lib/bundler/cli.rb +792 -0
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +49 -0
- data/lib/bundler/cli/cache.rb +36 -0
- data/lib/bundler/cli/check.rb +38 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +102 -0
- data/lib/bundler/cli/config.rb +119 -0
- data/lib/bundler/cli/console.rb +43 -0
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +105 -0
- data/lib/bundler/cli/gem.rb +252 -0
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +47 -0
- data/lib/bundler/cli/inject.rb +60 -0
- data/lib/bundler/cli/install.rb +218 -0
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +63 -0
- data/lib/bundler/cli/open.rb +26 -0
- data/lib/bundler/cli/outdated.rb +266 -0
- data/lib/bundler/cli/package.rb +49 -0
- data/lib/bundler/cli/platform.rb +46 -0
- data/lib/bundler/cli/plugin.rb +24 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +75 -0
- data/lib/bundler/cli/update.rb +91 -0
- data/lib/bundler/cli/viz.rb +31 -0
- data/lib/bundler/compact_index_client.rb +109 -0
- data/lib/bundler/compact_index_client/cache.rb +118 -0
- data/lib/bundler/compact_index_client/updater.rb +116 -0
- data/lib/bundler/compatibility_guard.rb +13 -0
- data/lib/bundler/constants.rb +7 -0
- data/lib/bundler/current_ruby.rb +94 -0
- data/lib/bundler/definition.rb +995 -0
- data/lib/bundler/dep_proxy.rb +48 -0
- data/lib/bundler/dependency.rb +139 -0
- data/lib/bundler/deployment.rb +69 -0
- data/lib/bundler/deprecate.rb +44 -0
- data/lib/bundler/dsl.rb +615 -0
- data/lib/bundler/endpoint_specification.rb +141 -0
- data/lib/bundler/env.rb +149 -0
- data/lib/bundler/environment_preserver.rb +59 -0
- data/lib/bundler/errors.rb +158 -0
- data/lib/bundler/feature_flag.rb +75 -0
- data/lib/bundler/fetcher.rb +312 -0
- data/lib/bundler/fetcher/base.rb +52 -0
- data/lib/bundler/fetcher/compact_index.rb +126 -0
- data/lib/bundler/fetcher/dependency.rb +82 -0
- data/lib/bundler/fetcher/downloader.rb +84 -0
- data/lib/bundler/fetcher/index.rb +52 -0
- data/lib/bundler/friendly_errors.rb +131 -0
- data/lib/bundler/gem_helper.rb +217 -0
- data/lib/bundler/gem_helpers.rb +101 -0
- data/lib/bundler/gem_remote_fetcher.rb +43 -0
- data/lib/bundler/gem_tasks.rb +7 -0
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +152 -0
- data/lib/bundler/index.rb +213 -0
- data/lib/bundler/injector.rb +253 -0
- data/lib/bundler/inline.rb +74 -0
- data/lib/bundler/installer.rb +318 -0
- data/lib/bundler/installer/gem_installer.rb +85 -0
- data/lib/bundler/installer/parallel_installer.rb +229 -0
- data/lib/bundler/installer/standalone.rb +53 -0
- data/lib/bundler/lazy_specification.rb +123 -0
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +256 -0
- data/lib/bundler/match_platform.rb +24 -0
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +294 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +306 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +165 -0
- data/lib/bundler/plugin/installer.rb +96 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +27 -0
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +37 -0
- data/lib/bundler/remote_specification.rb +114 -0
- data/lib/bundler/resolver.rb +373 -0
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +66 -0
- data/lib/bundler/ruby_dsl.rb +18 -0
- data/lib/bundler/ruby_version.rb +152 -0
- data/lib/bundler/rubygems_ext.rb +209 -0
- data/lib/bundler/rubygems_gem_installer.rb +99 -0
- data/lib/bundler/rubygems_integration.rb +915 -0
- data/lib/bundler/runtime.rb +322 -0
- data/lib/bundler/settings.rb +464 -0
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +28 -0
- data/lib/bundler/shared_helpers.rb +386 -0
- data/lib/bundler/similarity_detector.rb +63 -0
- data/lib/bundler/source.rb +94 -0
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +329 -0
- data/lib/bundler/source/git/git_proxy.rb +262 -0
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +249 -0
- data/lib/bundler/source/path/installer.rb +74 -0
- data/lib/bundler/source/rubygems.rb +539 -0
- data/lib/bundler/source/rubygems/remote.rb +69 -0
- data/lib/bundler/source_list.rb +186 -0
- data/lib/bundler/spec_set.rb +208 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +66 -0
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/bundler/stub_specification.rb +108 -0
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +29 -0
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +14 -0
- data/lib/bundler/templates/Gemfile +7 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -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 +47 -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 +20 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +13 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +50 -0
- data/lib/bundler/templates/newgem/rspec.tt +3 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +9 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +8 -0
- data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
- data/lib/bundler/ui.rb +9 -0
- data/lib/bundler/ui/rg_proxy.rb +19 -0
- data/lib/bundler/ui/shell.rb +146 -0
- data/lib/bundler/ui/silent.rb +69 -0
- data/lib/bundler/uri_credentials_filter.rb +37 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1741 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +223 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +136 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +101 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +67 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1233 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +509 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +331 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +104 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +678 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +114 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +177 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -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 +70 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +146 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +226 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +324 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +482 -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 +268 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +4 -0
- data/lib/bundler/vendored_persistent.rb +52 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- data/lib/bundler/version.rb +28 -0
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +17 -0
- data/lib/bundler/worker.rb +106 -0
- data/lib/bundler/yaml_serializer.rb +90 -0
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/man/bundle-binstubs.1 +40 -0
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +43 -0
- data/man/bundle-check.1 +31 -0
- data/man/bundle-check.1.txt +33 -0
- data/man/bundle-check.ronn +26 -0
- data/man/bundle-clean.1 +24 -0
- data/man/bundle-clean.1.txt +26 -0
- data/man/bundle-clean.ronn +18 -0
- data/man/bundle-config.1 +497 -0
- data/man/bundle-config.1.txt +529 -0
- data/man/bundle-config.ronn +397 -0
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/man/bundle-exec.1 +165 -0
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +152 -0
- data/man/bundle-gem.1 +80 -0
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +78 -0
- data/man/bundle-info.1 +20 -0
- data/man/bundle-info.1.txt +21 -0
- data/man/bundle-info.ronn +17 -0
- data/man/bundle-init.1 +25 -0
- data/man/bundle-init.1.txt +34 -0
- data/man/bundle-init.ronn +29 -0
- data/man/bundle-inject.1 +33 -0
- data/man/bundle-inject.1.txt +32 -0
- data/man/bundle-inject.ronn +22 -0
- data/man/bundle-install.1 +308 -0
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +378 -0
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/man/bundle-lock.1 +84 -0
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +94 -0
- data/man/bundle-open.1 +32 -0
- data/man/bundle-open.1.txt +29 -0
- data/man/bundle-open.ronn +19 -0
- data/man/bundle-outdated.1 +155 -0
- data/man/bundle-outdated.1.txt +131 -0
- data/man/bundle-outdated.ronn +111 -0
- data/man/bundle-package.1 +55 -0
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +72 -0
- data/man/bundle-platform.1 +61 -0
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-pristine.1 +34 -0
- data/man/bundle-pristine.1.txt +44 -0
- data/man/bundle-pristine.ronn +34 -0
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +23 -0
- data/man/bundle-show.1.txt +27 -0
- data/man/bundle-show.ronn +21 -0
- data/man/bundle-update.1 +394 -0
- data/man/bundle-update.1.txt +391 -0
- data/man/bundle-update.ronn +350 -0
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/man/bundle.1 +136 -0
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +111 -0
- data/man/gemfile.5 +689 -0
- data/man/gemfile.5.ronn +521 -0
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -0
- metadata +463 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class DepProxy
|
5
|
+
attr_reader :__platform, :dep
|
6
|
+
|
7
|
+
def initialize(dep, platform)
|
8
|
+
@dep = dep
|
9
|
+
@__platform = platform
|
10
|
+
end
|
11
|
+
|
12
|
+
def hash
|
13
|
+
@hash ||= [dep, __platform].hash
|
14
|
+
end
|
15
|
+
|
16
|
+
def ==(other)
|
17
|
+
return false if other.class != self.class
|
18
|
+
dep == other.dep && __platform == other.__platform
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :eql?, :==
|
22
|
+
|
23
|
+
def type
|
24
|
+
@dep.type
|
25
|
+
end
|
26
|
+
|
27
|
+
def name
|
28
|
+
@dep.name
|
29
|
+
end
|
30
|
+
|
31
|
+
def requirement
|
32
|
+
@dep.requirement
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
s = name.dup
|
37
|
+
s << " (#{requirement})" unless requirement == Gem::Requirement.default
|
38
|
+
s << " #{__platform}" unless __platform == Gem::Platform::RUBY
|
39
|
+
s
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def method_missing(*args, &blk)
|
45
|
+
@dep.send(*args, &blk)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubygems/dependency"
|
4
|
+
require "bundler/shared_helpers"
|
5
|
+
require "bundler/rubygems_ext"
|
6
|
+
|
7
|
+
module Bundler
|
8
|
+
class Dependency < Gem::Dependency
|
9
|
+
attr_reader :autorequire
|
10
|
+
attr_reader :groups, :platforms, :gemfile
|
11
|
+
|
12
|
+
PLATFORM_MAP = {
|
13
|
+
:ruby => Gem::Platform::RUBY,
|
14
|
+
:ruby_18 => Gem::Platform::RUBY,
|
15
|
+
:ruby_19 => Gem::Platform::RUBY,
|
16
|
+
:ruby_20 => Gem::Platform::RUBY,
|
17
|
+
:ruby_21 => Gem::Platform::RUBY,
|
18
|
+
:ruby_22 => Gem::Platform::RUBY,
|
19
|
+
:ruby_23 => Gem::Platform::RUBY,
|
20
|
+
:ruby_24 => Gem::Platform::RUBY,
|
21
|
+
:ruby_25 => Gem::Platform::RUBY,
|
22
|
+
:mri => Gem::Platform::RUBY,
|
23
|
+
:mri_18 => Gem::Platform::RUBY,
|
24
|
+
:mri_19 => Gem::Platform::RUBY,
|
25
|
+
:mri_20 => Gem::Platform::RUBY,
|
26
|
+
:mri_21 => Gem::Platform::RUBY,
|
27
|
+
:mri_22 => Gem::Platform::RUBY,
|
28
|
+
:mri_23 => Gem::Platform::RUBY,
|
29
|
+
:mri_24 => Gem::Platform::RUBY,
|
30
|
+
:mri_25 => Gem::Platform::RUBY,
|
31
|
+
:rbx => Gem::Platform::RUBY,
|
32
|
+
:truffleruby => Gem::Platform::RUBY,
|
33
|
+
:jruby => Gem::Platform::JAVA,
|
34
|
+
:jruby_18 => Gem::Platform::JAVA,
|
35
|
+
:jruby_19 => Gem::Platform::JAVA,
|
36
|
+
:mswin => Gem::Platform::MSWIN,
|
37
|
+
:mswin_18 => Gem::Platform::MSWIN,
|
38
|
+
:mswin_19 => Gem::Platform::MSWIN,
|
39
|
+
:mswin_20 => Gem::Platform::MSWIN,
|
40
|
+
:mswin_21 => Gem::Platform::MSWIN,
|
41
|
+
:mswin_22 => Gem::Platform::MSWIN,
|
42
|
+
:mswin_23 => Gem::Platform::MSWIN,
|
43
|
+
:mswin_24 => Gem::Platform::MSWIN,
|
44
|
+
:mswin_25 => Gem::Platform::MSWIN,
|
45
|
+
:mswin64 => Gem::Platform::MSWIN64,
|
46
|
+
:mswin64_19 => Gem::Platform::MSWIN64,
|
47
|
+
:mswin64_20 => Gem::Platform::MSWIN64,
|
48
|
+
:mswin64_21 => Gem::Platform::MSWIN64,
|
49
|
+
:mswin64_22 => Gem::Platform::MSWIN64,
|
50
|
+
:mswin64_23 => Gem::Platform::MSWIN64,
|
51
|
+
:mswin64_24 => Gem::Platform::MSWIN64,
|
52
|
+
:mswin64_25 => Gem::Platform::MSWIN64,
|
53
|
+
:mingw => Gem::Platform::MINGW,
|
54
|
+
:mingw_18 => Gem::Platform::MINGW,
|
55
|
+
:mingw_19 => Gem::Platform::MINGW,
|
56
|
+
:mingw_20 => Gem::Platform::MINGW,
|
57
|
+
:mingw_21 => Gem::Platform::MINGW,
|
58
|
+
:mingw_22 => Gem::Platform::MINGW,
|
59
|
+
:mingw_23 => Gem::Platform::MINGW,
|
60
|
+
:mingw_24 => Gem::Platform::MINGW,
|
61
|
+
:mingw_25 => Gem::Platform::MINGW,
|
62
|
+
:x64_mingw => Gem::Platform::X64_MINGW,
|
63
|
+
:x64_mingw_20 => Gem::Platform::X64_MINGW,
|
64
|
+
:x64_mingw_21 => Gem::Platform::X64_MINGW,
|
65
|
+
:x64_mingw_22 => Gem::Platform::X64_MINGW,
|
66
|
+
:x64_mingw_23 => Gem::Platform::X64_MINGW,
|
67
|
+
:x64_mingw_24 => Gem::Platform::X64_MINGW,
|
68
|
+
:x64_mingw_25 => Gem::Platform::X64_MINGW,
|
69
|
+
}.freeze
|
70
|
+
|
71
|
+
REVERSE_PLATFORM_MAP = {}.tap do |reverse_platform_map|
|
72
|
+
PLATFORM_MAP.each do |key, value|
|
73
|
+
reverse_platform_map[value] ||= []
|
74
|
+
reverse_platform_map[value] << key
|
75
|
+
end
|
76
|
+
|
77
|
+
reverse_platform_map.each {|_, platforms| platforms.freeze }
|
78
|
+
end.freeze
|
79
|
+
|
80
|
+
def initialize(name, version, options = {}, &blk)
|
81
|
+
type = options["type"] || :runtime
|
82
|
+
super(name, version, type)
|
83
|
+
|
84
|
+
@autorequire = nil
|
85
|
+
@groups = Array(options["group"] || :default).map(&:to_sym)
|
86
|
+
@source = options["source"]
|
87
|
+
@platforms = Array(options["platforms"])
|
88
|
+
@env = options["env"]
|
89
|
+
@should_include = options.fetch("should_include", true)
|
90
|
+
@gemfile = options["gemfile"]
|
91
|
+
|
92
|
+
@autorequire = Array(options["require"] || []) if options.key?("require")
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns the platforms this dependency is valid for, in the same order as
|
96
|
+
# passed in the `valid_platforms` parameter
|
97
|
+
def gem_platforms(valid_platforms)
|
98
|
+
return valid_platforms if @platforms.empty?
|
99
|
+
|
100
|
+
@gem_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
|
101
|
+
|
102
|
+
valid_platforms & @gem_platforms
|
103
|
+
end
|
104
|
+
|
105
|
+
def should_include?
|
106
|
+
@should_include && current_env? && current_platform?
|
107
|
+
end
|
108
|
+
|
109
|
+
def current_env?
|
110
|
+
return true unless @env
|
111
|
+
if @env.is_a?(Hash)
|
112
|
+
@env.all? do |key, val|
|
113
|
+
ENV[key.to_s] && (val.is_a?(String) ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
|
114
|
+
end
|
115
|
+
else
|
116
|
+
ENV[@env.to_s]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def current_platform?
|
121
|
+
return true if @platforms.empty?
|
122
|
+
@platforms.any? do |p|
|
123
|
+
Bundler.current_ruby.send("#{p}?")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def to_lock
|
128
|
+
out = super
|
129
|
+
out << "!" if source
|
130
|
+
out << "\n"
|
131
|
+
end
|
132
|
+
|
133
|
+
def specific?
|
134
|
+
super
|
135
|
+
rescue NoMethodError
|
136
|
+
requirement != ">= 0"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/shared_helpers"
|
4
|
+
Bundler::SharedHelpers.major_deprecation 3, "Bundler no longer integrates with " \
|
5
|
+
"Capistrano, but Capistrano provides its own integration with " \
|
6
|
+
"Bundler via the capistrano-bundler gem. Use it instead."
|
7
|
+
|
8
|
+
module Bundler
|
9
|
+
class Deployment
|
10
|
+
def self.define_task(context, task_method = :task, opts = {})
|
11
|
+
if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
|
12
|
+
context_name = "capistrano"
|
13
|
+
role_default = "{:except => {:no_release => true}}"
|
14
|
+
error_type = ::Capistrano::CommandError
|
15
|
+
else
|
16
|
+
context_name = "vlad"
|
17
|
+
role_default = "[:app]"
|
18
|
+
error_type = ::Rake::CommandFailedError
|
19
|
+
end
|
20
|
+
|
21
|
+
roles = context.fetch(:bundle_roles, false)
|
22
|
+
opts[:roles] = roles if roles
|
23
|
+
|
24
|
+
context.send :namespace, :bundle do
|
25
|
+
send :desc, <<-DESC
|
26
|
+
Install the current Bundler environment. By default, gems will be \
|
27
|
+
installed to the shared/bundle path. Gems in the development and \
|
28
|
+
test group will not be installed. The install command is executed \
|
29
|
+
with the --deployment and --quiet flags. If the bundle cmd cannot \
|
30
|
+
be found then you can override the bundle_cmd variable to specify \
|
31
|
+
which one it should use. The base path to the app is fetched from \
|
32
|
+
the :latest_release variable. Set it for custom deploy layouts.
|
33
|
+
|
34
|
+
You can override any of these defaults by setting the variables shown below.
|
35
|
+
|
36
|
+
N.B. bundle_roles must be defined before you require 'bundler/#{context_name}' \
|
37
|
+
in your deploy.rb file.
|
38
|
+
|
39
|
+
set :bundle_gemfile, "Gemfile"
|
40
|
+
set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
|
41
|
+
set :bundle_flags, "--deployment --quiet"
|
42
|
+
set :bundle_without, [:development, :test]
|
43
|
+
set :bundle_with, [:mysql]
|
44
|
+
set :bundle_cmd, "bundle" # e.g. "/opt/ruby/bin/bundle"
|
45
|
+
set :bundle_roles, #{role_default} # e.g. [:app, :batch]
|
46
|
+
DESC
|
47
|
+
send task_method, :install, opts do
|
48
|
+
bundle_cmd = context.fetch(:bundle_cmd, "bundle")
|
49
|
+
bundle_flags = context.fetch(:bundle_flags, "--deployment --quiet")
|
50
|
+
bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), "bundle"))
|
51
|
+
bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
|
52
|
+
bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact
|
53
|
+
bundle_with = [*context.fetch(:bundle_with, [])].compact
|
54
|
+
app_path = context.fetch(:latest_release)
|
55
|
+
if app_path.to_s.empty?
|
56
|
+
raise error_type.new("Cannot detect current release path - make sure you have deployed at least once.")
|
57
|
+
end
|
58
|
+
args = ["--gemfile #{File.join(app_path, bundle_gemfile)}"]
|
59
|
+
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
|
60
|
+
args << bundle_flags.to_s
|
61
|
+
args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
|
62
|
+
args << "--with #{bundle_with.join(" ")}" unless bundle_with.empty?
|
63
|
+
|
64
|
+
run "cd #{app_path} && #{bundle_cmd} install #{args.join(" ")}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "rubygems/deprecate"
|
5
|
+
rescue LoadError
|
6
|
+
# it's fine if it doesn't exist on the current RubyGems...
|
7
|
+
nil
|
8
|
+
end
|
9
|
+
|
10
|
+
module Bundler
|
11
|
+
# If Bundler::Deprecate is an autoload constant, we need to define it
|
12
|
+
if defined?(Bundler::Deprecate) && !autoload?(:Deprecate)
|
13
|
+
# nothing to do!
|
14
|
+
elsif defined? ::Deprecate
|
15
|
+
Deprecate = ::Deprecate
|
16
|
+
elsif defined? Gem::Deprecate
|
17
|
+
Deprecate = Gem::Deprecate
|
18
|
+
else
|
19
|
+
class Deprecate
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
unless Deprecate.respond_to?(:skip_during)
|
24
|
+
def Deprecate.skip_during
|
25
|
+
original = skip
|
26
|
+
self.skip = true
|
27
|
+
yield
|
28
|
+
ensure
|
29
|
+
self.skip = original
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
unless Deprecate.respond_to?(:skip)
|
34
|
+
def Deprecate.skip
|
35
|
+
@skip ||= false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
unless Deprecate.respond_to?(:skip=)
|
40
|
+
def Deprecate.skip=(skip)
|
41
|
+
@skip = skip
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/bundler/dsl.rb
ADDED
@@ -0,0 +1,615 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/dependency"
|
4
|
+
require "bundler/ruby_dsl"
|
5
|
+
|
6
|
+
module Bundler
|
7
|
+
class Dsl
|
8
|
+
include RubyDsl
|
9
|
+
|
10
|
+
def self.evaluate(gemfile, lockfile, unlock)
|
11
|
+
builder = new
|
12
|
+
builder.eval_gemfile(gemfile)
|
13
|
+
builder.to_definition(lockfile, unlock)
|
14
|
+
end
|
15
|
+
|
16
|
+
VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
|
17
|
+
|
18
|
+
VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
|
19
|
+
platform platforms type source install_if gemfile].freeze
|
20
|
+
|
21
|
+
attr_reader :gemspecs
|
22
|
+
attr_accessor :dependencies
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
@source = nil
|
26
|
+
@sources = SourceList.new
|
27
|
+
@git_sources = {}
|
28
|
+
@dependencies = []
|
29
|
+
@groups = []
|
30
|
+
@install_conditionals = []
|
31
|
+
@optional_groups = []
|
32
|
+
@platforms = []
|
33
|
+
@env = nil
|
34
|
+
@ruby_version = nil
|
35
|
+
@gemspecs = []
|
36
|
+
@gemfile = nil
|
37
|
+
@gemfiles = []
|
38
|
+
add_git_sources
|
39
|
+
end
|
40
|
+
|
41
|
+
def eval_gemfile(gemfile, contents = nil)
|
42
|
+
expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile && @gemfile.parent)
|
43
|
+
original_gemfile = @gemfile
|
44
|
+
@gemfile = expanded_gemfile_path
|
45
|
+
@gemfiles << expanded_gemfile_path
|
46
|
+
contents ||= Bundler.read_file(@gemfile.to_s)
|
47
|
+
instance_eval(contents.dup.untaint, gemfile.to_s, 1)
|
48
|
+
rescue Exception => e
|
49
|
+
message = "There was an error " \
|
50
|
+
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
|
51
|
+
"`#{File.basename gemfile.to_s}`: #{e.message}"
|
52
|
+
|
53
|
+
raise DSLError.new(message, gemfile, e.backtrace, contents)
|
54
|
+
ensure
|
55
|
+
@gemfile = original_gemfile
|
56
|
+
end
|
57
|
+
|
58
|
+
def gemspec(opts = nil)
|
59
|
+
opts ||= {}
|
60
|
+
path = opts[:path] || "."
|
61
|
+
glob = opts[:glob]
|
62
|
+
name = opts[:name]
|
63
|
+
development_group = opts[:development_group] || :development
|
64
|
+
expanded_path = gemfile_root.join(path)
|
65
|
+
|
66
|
+
gemspecs = Dir[File.join(expanded_path, "{,*}.gemspec")].map {|g| Bundler.load_gemspec(g) }.compact
|
67
|
+
gemspecs.reject! {|s| s.name != name } if name
|
68
|
+
Index.sort_specs(gemspecs)
|
69
|
+
specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
|
70
|
+
|
71
|
+
case specs_by_name_and_version.size
|
72
|
+
when 1
|
73
|
+
specs = specs_by_name_and_version.values.first
|
74
|
+
spec = specs.find {|s| s.match_platform(Bundler.local_platform) } || specs.first
|
75
|
+
|
76
|
+
@gemspecs << spec
|
77
|
+
|
78
|
+
gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
|
79
|
+
gem spec.name, :name => spec.name, :path => path, :glob => glob, :platforms => gem_platforms
|
80
|
+
|
81
|
+
group(development_group) do
|
82
|
+
spec.development_dependencies.each do |dep|
|
83
|
+
gem dep.name, *(dep.requirement.as_list + [:type => :development])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
when 0
|
87
|
+
raise InvalidOption, "There are no gemspecs at #{expanded_path}"
|
88
|
+
else
|
89
|
+
raise InvalidOption, "There are multiple gemspecs at #{expanded_path}. " \
|
90
|
+
"Please use the :name option to specify which one should be used"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def gem(name, *args)
|
95
|
+
options = args.last.is_a?(Hash) ? args.pop.dup : {}
|
96
|
+
options["gemfile"] = @gemfile
|
97
|
+
version = args || [">= 0"]
|
98
|
+
|
99
|
+
normalize_options(name, version, options)
|
100
|
+
|
101
|
+
dep = Dependency.new(name, version, options)
|
102
|
+
|
103
|
+
# if there's already a dependency with this name we try to prefer one
|
104
|
+
if current = @dependencies.find {|d| d.name == dep.name }
|
105
|
+
deleted_dep = @dependencies.delete(current) if current.type == :development
|
106
|
+
|
107
|
+
if current.requirement != dep.requirement
|
108
|
+
unless deleted_dep
|
109
|
+
return if dep.type == :development
|
110
|
+
|
111
|
+
update_prompt = ""
|
112
|
+
|
113
|
+
if File.basename(@gemfile) == Injector::INJECTED_GEMS
|
114
|
+
if dep.requirements_list.include?(">= 0") && !current.requirements_list.include?(">= 0")
|
115
|
+
update_prompt = ". Gem already added"
|
116
|
+
else
|
117
|
+
update_prompt = ". If you want to update the gem version, run `bundle update #{current.name}`"
|
118
|
+
|
119
|
+
update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current.requirements_list.include?(">= 0")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
|
124
|
+
"You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
|
125
|
+
"#{update_prompt}"
|
126
|
+
end
|
127
|
+
|
128
|
+
else
|
129
|
+
Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
|
130
|
+
"You should probably keep only one of them.\n" \
|
131
|
+
"Remove any duplicate entries and specify the gem only once (per group).\n" \
|
132
|
+
"While it's not a problem now, it could cause errors if you change the version of one of them later."
|
133
|
+
end
|
134
|
+
|
135
|
+
if current.source != dep.source
|
136
|
+
unless deleted_dep
|
137
|
+
return if dep.type == :development
|
138
|
+
raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
|
139
|
+
"You specified that #{dep.name} (#{dep.requirement}) should come from " \
|
140
|
+
"#{current.source || "an unspecified source"} and #{dep.source}\n"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
@dependencies << dep
|
146
|
+
end
|
147
|
+
|
148
|
+
def source(source, *args, &blk)
|
149
|
+
options = args.last.is_a?(Hash) ? args.pop.dup : {}
|
150
|
+
options = normalize_hash(options)
|
151
|
+
source = normalize_source(source)
|
152
|
+
|
153
|
+
if options.key?("type")
|
154
|
+
options["type"] = options["type"].to_s
|
155
|
+
unless Plugin.source?(options["type"])
|
156
|
+
raise InvalidOption, "No plugin sources available for #{options["type"]}"
|
157
|
+
end
|
158
|
+
|
159
|
+
unless block_given?
|
160
|
+
raise InvalidOption, "You need to pass a block to #source with :type option"
|
161
|
+
end
|
162
|
+
|
163
|
+
source_opts = options.merge("uri" => source)
|
164
|
+
with_source(@sources.add_plugin_source(options["type"], source_opts), &blk)
|
165
|
+
elsif block_given?
|
166
|
+
with_source(@sources.add_rubygems_source("remotes" => source), &blk)
|
167
|
+
else
|
168
|
+
check_primary_source_safety(@sources)
|
169
|
+
@sources.global_rubygems_source = source
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def git_source(name, &block)
|
174
|
+
unless block_given?
|
175
|
+
raise InvalidOption, "You need to pass a block to #git_source"
|
176
|
+
end
|
177
|
+
|
178
|
+
if valid_keys.include?(name.to_s)
|
179
|
+
raise InvalidOption, "You cannot use #{name} as a git source. It " \
|
180
|
+
"is a reserved key. Reserved keys are: #{valid_keys.join(", ")}"
|
181
|
+
end
|
182
|
+
|
183
|
+
@git_sources[name.to_s] = block
|
184
|
+
end
|
185
|
+
|
186
|
+
def path(path, options = {}, &blk)
|
187
|
+
unless block_given?
|
188
|
+
msg = "You can no longer specify a path source by itself. Instead, \n" \
|
189
|
+
"either use the :path option on a gem, or specify the gems that \n" \
|
190
|
+
"bundler should find in the path source by passing a block to \n" \
|
191
|
+
"the path method, like: \n\n" \
|
192
|
+
" path 'dir/containing/rails' do\n" \
|
193
|
+
" gem 'rails'\n" \
|
194
|
+
" end\n\n"
|
195
|
+
|
196
|
+
raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
|
197
|
+
SharedHelpers.major_deprecation(3, msg.strip)
|
198
|
+
end
|
199
|
+
|
200
|
+
source_options = normalize_hash(options).merge(
|
201
|
+
"path" => Pathname.new(path),
|
202
|
+
"root_path" => gemfile_root,
|
203
|
+
"gemspec" => gemspecs.find {|g| g.name == options["name"] }
|
204
|
+
)
|
205
|
+
source = @sources.add_path_source(source_options)
|
206
|
+
with_source(source, &blk)
|
207
|
+
end
|
208
|
+
|
209
|
+
def git(uri, options = {}, &blk)
|
210
|
+
unless block_given?
|
211
|
+
msg = "You can no longer specify a git source by itself. Instead, \n" \
|
212
|
+
"either use the :git option on a gem, or specify the gems that \n" \
|
213
|
+
"bundler should find in the git source by passing a block to \n" \
|
214
|
+
"the git method, like: \n\n" \
|
215
|
+
" git 'git://github.com/rails/rails.git' do\n" \
|
216
|
+
" gem 'rails'\n" \
|
217
|
+
" end"
|
218
|
+
raise DeprecatedError, msg
|
219
|
+
end
|
220
|
+
|
221
|
+
with_source(@sources.add_git_source(normalize_hash(options).merge("uri" => uri)), &blk)
|
222
|
+
end
|
223
|
+
|
224
|
+
def github(repo, options = {})
|
225
|
+
raise ArgumentError, "GitHub sources require a block" unless block_given?
|
226
|
+
raise DeprecatedError, "The #github method has been removed" if Bundler.feature_flag.skip_default_git_sources?
|
227
|
+
github_uri = @git_sources["github"].call(repo)
|
228
|
+
git_options = normalize_hash(options).merge("uri" => github_uri)
|
229
|
+
git_source = @sources.add_git_source(git_options)
|
230
|
+
with_source(git_source) { yield }
|
231
|
+
end
|
232
|
+
|
233
|
+
def to_definition(lockfile, unlock)
|
234
|
+
Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles)
|
235
|
+
end
|
236
|
+
|
237
|
+
def group(*args, &blk)
|
238
|
+
options = args.last.is_a?(Hash) ? args.pop.dup : {}
|
239
|
+
normalize_group_options(options, args)
|
240
|
+
|
241
|
+
@groups.concat args
|
242
|
+
|
243
|
+
if options["optional"]
|
244
|
+
optional_groups = args - @optional_groups
|
245
|
+
@optional_groups.concat optional_groups
|
246
|
+
end
|
247
|
+
|
248
|
+
yield
|
249
|
+
ensure
|
250
|
+
args.each { @groups.pop }
|
251
|
+
end
|
252
|
+
|
253
|
+
def install_if(*args)
|
254
|
+
@install_conditionals.concat args
|
255
|
+
yield
|
256
|
+
ensure
|
257
|
+
args.each { @install_conditionals.pop }
|
258
|
+
end
|
259
|
+
|
260
|
+
def platforms(*platforms)
|
261
|
+
@platforms.concat platforms
|
262
|
+
yield
|
263
|
+
ensure
|
264
|
+
platforms.each { @platforms.pop }
|
265
|
+
end
|
266
|
+
alias_method :platform, :platforms
|
267
|
+
|
268
|
+
def env(name)
|
269
|
+
old = @env
|
270
|
+
@env = name
|
271
|
+
yield
|
272
|
+
ensure
|
273
|
+
@env = old
|
274
|
+
end
|
275
|
+
|
276
|
+
def plugin(*args)
|
277
|
+
# Pass on
|
278
|
+
end
|
279
|
+
|
280
|
+
def method_missing(name, *args)
|
281
|
+
raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
|
282
|
+
end
|
283
|
+
|
284
|
+
private
|
285
|
+
|
286
|
+
def add_git_sources
|
287
|
+
return if Bundler.feature_flag.skip_default_git_sources?
|
288
|
+
|
289
|
+
git_source(:github) do |repo_name|
|
290
|
+
warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".')
|
291
|
+
"https://github.com/#{repo_name}.git"
|
292
|
+
RUBY
|
293
|
+
# It would be better to use https instead of the git protocol, but this
|
294
|
+
# can break deployment of existing locked bundles when switching between
|
295
|
+
# different versions of Bundler. The change will be made in 2.0, which
|
296
|
+
# does not guarantee compatibility with the 1.x series.
|
297
|
+
#
|
298
|
+
# See https://github.com/bundler/bundler/pull/2569 for discussion
|
299
|
+
#
|
300
|
+
# This can be overridden by adding this code to your Gemfiles:
|
301
|
+
#
|
302
|
+
# git_source(:github) do |repo_name|
|
303
|
+
# repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
304
|
+
# "https://github.com/#{repo_name}.git"
|
305
|
+
# end
|
306
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
307
|
+
# TODO: 2.0 upgrade this setting to the default
|
308
|
+
if Bundler.feature_flag.github_https?
|
309
|
+
Bundler::SharedHelpers.major_deprecation 3, "The `github.https` setting will be removed"
|
310
|
+
"https://github.com/#{repo_name}.git"
|
311
|
+
else
|
312
|
+
"git://github.com/#{repo_name}.git"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
# TODO: 2.0 remove this deprecated git source
|
317
|
+
git_source(:gist) do |repo_name|
|
318
|
+
warn_deprecated_git_source(:gist, '"https://gist.github.com/#{repo_name}.git"')
|
319
|
+
|
320
|
+
"https://gist.github.com/#{repo_name}.git"
|
321
|
+
end
|
322
|
+
|
323
|
+
# TODO: 2.0 remove this deprecated git source
|
324
|
+
git_source(:bitbucket) do |repo_name|
|
325
|
+
warn_deprecated_git_source(:bitbucket, <<-'RUBY'.strip)
|
326
|
+
user_name, repo_name = repo_name.split("/")
|
327
|
+
repo_name ||= user_name
|
328
|
+
"https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
|
329
|
+
RUBY
|
330
|
+
|
331
|
+
user_name, repo_name = repo_name.split("/")
|
332
|
+
repo_name ||= user_name
|
333
|
+
"https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def with_source(source)
|
338
|
+
old_source = @source
|
339
|
+
if block_given?
|
340
|
+
@source = source
|
341
|
+
yield
|
342
|
+
end
|
343
|
+
source
|
344
|
+
ensure
|
345
|
+
@source = old_source
|
346
|
+
end
|
347
|
+
|
348
|
+
def normalize_hash(opts)
|
349
|
+
opts.keys.each do |k|
|
350
|
+
opts[k.to_s] = opts.delete(k) unless k.is_a?(String)
|
351
|
+
end
|
352
|
+
opts
|
353
|
+
end
|
354
|
+
|
355
|
+
def valid_keys
|
356
|
+
@valid_keys ||= VALID_KEYS
|
357
|
+
end
|
358
|
+
|
359
|
+
def normalize_options(name, version, opts)
|
360
|
+
if name.is_a?(Symbol)
|
361
|
+
raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead)
|
362
|
+
end
|
363
|
+
if name =~ /\s/
|
364
|
+
raise GemfileError, %('#{name}' is not a valid gem name because it contains whitespace)
|
365
|
+
end
|
366
|
+
if name.empty?
|
367
|
+
raise GemfileError, %(an empty gem name is not valid)
|
368
|
+
end
|
369
|
+
|
370
|
+
normalize_hash(opts)
|
371
|
+
|
372
|
+
git_names = @git_sources.keys.map(&:to_s)
|
373
|
+
validate_keys("gem '#{name}'", opts, valid_keys + git_names)
|
374
|
+
|
375
|
+
groups = @groups.dup
|
376
|
+
opts["group"] = opts.delete("groups") || opts["group"]
|
377
|
+
groups.concat Array(opts.delete("group"))
|
378
|
+
groups = [:default] if groups.empty?
|
379
|
+
|
380
|
+
install_if = @install_conditionals.dup
|
381
|
+
install_if.concat Array(opts.delete("install_if"))
|
382
|
+
install_if = install_if.reduce(true) do |memo, val|
|
383
|
+
memo && (val.respond_to?(:call) ? val.call : val)
|
384
|
+
end
|
385
|
+
|
386
|
+
platforms = @platforms.dup
|
387
|
+
opts["platforms"] = opts["platform"] || opts["platforms"]
|
388
|
+
platforms.concat Array(opts.delete("platforms"))
|
389
|
+
platforms.map!(&:to_sym)
|
390
|
+
platforms.each do |p|
|
391
|
+
next if VALID_PLATFORMS.include?(p)
|
392
|
+
raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
|
393
|
+
end
|
394
|
+
|
395
|
+
# Save sources passed in a key
|
396
|
+
if opts.key?("source")
|
397
|
+
source = normalize_source(opts["source"])
|
398
|
+
opts["source"] = @sources.add_rubygems_source("remotes" => source)
|
399
|
+
end
|
400
|
+
|
401
|
+
git_name = (git_names & opts.keys).last
|
402
|
+
if @git_sources[git_name]
|
403
|
+
opts["git"] = @git_sources[git_name].call(opts[git_name])
|
404
|
+
end
|
405
|
+
|
406
|
+
%w[git path].each do |type|
|
407
|
+
next unless param = opts[type]
|
408
|
+
if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
|
409
|
+
options = opts.merge("name" => name, "version" => $1)
|
410
|
+
else
|
411
|
+
options = opts.dup
|
412
|
+
end
|
413
|
+
source = send(type, param, options) {}
|
414
|
+
opts["source"] = source
|
415
|
+
end
|
416
|
+
|
417
|
+
opts["source"] ||= @source
|
418
|
+
opts["env"] ||= @env
|
419
|
+
opts["platforms"] = platforms.dup
|
420
|
+
opts["group"] = groups
|
421
|
+
opts["should_include"] = install_if
|
422
|
+
end
|
423
|
+
|
424
|
+
def normalize_group_options(opts, groups)
|
425
|
+
normalize_hash(opts)
|
426
|
+
|
427
|
+
groups = groups.map {|group| ":#{group}" }.join(", ")
|
428
|
+
validate_keys("group #{groups}", opts, %w[optional])
|
429
|
+
|
430
|
+
opts["optional"] ||= false
|
431
|
+
end
|
432
|
+
|
433
|
+
def validate_keys(command, opts, valid_keys)
|
434
|
+
invalid_keys = opts.keys - valid_keys
|
435
|
+
|
436
|
+
git_source = opts.keys & @git_sources.keys.map(&:to_s)
|
437
|
+
if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
|
438
|
+
raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
|
439
|
+
end
|
440
|
+
|
441
|
+
return true unless invalid_keys.any?
|
442
|
+
|
443
|
+
message = String.new
|
444
|
+
message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} "
|
445
|
+
message << if invalid_keys.size > 1
|
446
|
+
"as options for #{command}, but they are invalid."
|
447
|
+
else
|
448
|
+
"as an option for #{command}, but it is invalid."
|
449
|
+
end
|
450
|
+
|
451
|
+
message << " Valid options are: #{valid_keys.join(", ")}."
|
452
|
+
message << " You may be able to resolve this by upgrading Bundler to the newest version."
|
453
|
+
raise InvalidOption, message
|
454
|
+
end
|
455
|
+
|
456
|
+
def normalize_source(source)
|
457
|
+
case source
|
458
|
+
when :gemcutter, :rubygems, :rubyforge
|
459
|
+
Bundler::SharedHelpers.major_deprecation 3, "The source :#{source} is deprecated because HTTP " \
|
460
|
+
"requests are insecure.\nPlease change your source to 'https://" \
|
461
|
+
"rubygems.org' if possible, or 'http://rubygems.org' if not."
|
462
|
+
"http://rubygems.org"
|
463
|
+
when String
|
464
|
+
source
|
465
|
+
else
|
466
|
+
raise GemfileError, "Unknown source '#{source}'"
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
def check_primary_source_safety(source_list)
|
471
|
+
return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
|
472
|
+
|
473
|
+
if Bundler.feature_flag.disable_multisource?
|
474
|
+
msg = "This Gemfile contains multiple primary sources. " \
|
475
|
+
"Each source after the first must include a block to indicate which gems " \
|
476
|
+
"should come from that source"
|
477
|
+
unless Bundler.feature_flag.bundler_3_mode?
|
478
|
+
msg += ". To downgrade this error to a warning, run " \
|
479
|
+
"`bundle config --delete disable_multisource`"
|
480
|
+
end
|
481
|
+
raise GemfileEvalError, msg
|
482
|
+
else
|
483
|
+
Bundler::SharedHelpers.major_deprecation 3, "Your Gemfile contains multiple primary sources. " \
|
484
|
+
"Using `source` more than once without a block is a security risk, and " \
|
485
|
+
"may result in installing unexpected gems. To resolve this warning, use " \
|
486
|
+
"a block to indicate which gems should come from the secondary source. " \
|
487
|
+
"To upgrade this warning to an error, run `bundle config " \
|
488
|
+
"disable_multisource true`."
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
def warn_deprecated_git_source(name, replacement, additional_message = nil)
|
493
|
+
# TODO: 2.0 remove deprecation
|
494
|
+
additional_message &&= " #{additional_message}"
|
495
|
+
replacement = if replacement.count("\n").zero?
|
496
|
+
"{|repo_name| #{replacement} }"
|
497
|
+
else
|
498
|
+
"do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end"
|
499
|
+
end
|
500
|
+
|
501
|
+
Bundler::SharedHelpers.major_deprecation 3, <<-EOS
|
502
|
+
The :#{name} git source is deprecated, and will be removed in Bundler 3.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work:
|
503
|
+
|
504
|
+
git_source(:#{name}) #{replacement}
|
505
|
+
|
506
|
+
EOS
|
507
|
+
end
|
508
|
+
|
509
|
+
class DSLError < GemfileError
|
510
|
+
# @return [String] the description that should be presented to the user.
|
511
|
+
#
|
512
|
+
attr_reader :description
|
513
|
+
|
514
|
+
# @return [String] the path of the dsl file that raised the exception.
|
515
|
+
#
|
516
|
+
attr_reader :dsl_path
|
517
|
+
|
518
|
+
# @return [Exception] the backtrace of the exception raised by the
|
519
|
+
# evaluation of the dsl file.
|
520
|
+
#
|
521
|
+
attr_reader :backtrace
|
522
|
+
|
523
|
+
# @param [Exception] backtrace @see backtrace
|
524
|
+
# @param [String] dsl_path @see dsl_path
|
525
|
+
#
|
526
|
+
def initialize(description, dsl_path, backtrace, contents = nil)
|
527
|
+
@status_code = $!.respond_to?(:status_code) && $!.status_code
|
528
|
+
|
529
|
+
@description = description
|
530
|
+
@dsl_path = dsl_path
|
531
|
+
@backtrace = backtrace
|
532
|
+
@contents = contents
|
533
|
+
end
|
534
|
+
|
535
|
+
def status_code
|
536
|
+
@status_code || super
|
537
|
+
end
|
538
|
+
|
539
|
+
# @return [String] the contents of the DSL that cause the exception to
|
540
|
+
# be raised.
|
541
|
+
#
|
542
|
+
def contents
|
543
|
+
@contents ||= begin
|
544
|
+
dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
# The message of the exception reports the content of podspec for the
|
549
|
+
# line that generated the original exception.
|
550
|
+
#
|
551
|
+
# @example Output
|
552
|
+
#
|
553
|
+
# Invalid podspec at `RestKit.podspec` - undefined method
|
554
|
+
# `exclude_header_search_paths=' for #<Pod::Specification for
|
555
|
+
# `RestKit/Network (0.9.3)`>
|
556
|
+
#
|
557
|
+
# from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36
|
558
|
+
# -------------------------------------------
|
559
|
+
# # because it would break: #import <CoreData/CoreData.h>
|
560
|
+
# > ns.exclude_header_search_paths = 'Code/RestKit.h'
|
561
|
+
# end
|
562
|
+
# -------------------------------------------
|
563
|
+
#
|
564
|
+
# @return [String] the message of the exception.
|
565
|
+
#
|
566
|
+
def to_s
|
567
|
+
@to_s ||= begin
|
568
|
+
trace_line, description = parse_line_number_from_description
|
569
|
+
|
570
|
+
m = String.new("\n[!] ")
|
571
|
+
m << description
|
572
|
+
m << ". Bundler cannot continue.\n"
|
573
|
+
|
574
|
+
return m unless backtrace && dsl_path && contents
|
575
|
+
|
576
|
+
trace_line = backtrace.find {|l| l.include?(dsl_path.to_s) } || trace_line
|
577
|
+
return m unless trace_line
|
578
|
+
line_numer = trace_line.split(":")[1].to_i - 1
|
579
|
+
return m unless line_numer
|
580
|
+
|
581
|
+
lines = contents.lines.to_a
|
582
|
+
indent = " # "
|
583
|
+
indicator = indent.tr("#", ">")
|
584
|
+
first_line = line_numer.zero?
|
585
|
+
last_line = (line_numer == (lines.count - 1))
|
586
|
+
|
587
|
+
m << "\n"
|
588
|
+
m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n"
|
589
|
+
m << "#{indent}-------------------------------------------\n"
|
590
|
+
m << "#{indent}#{lines[line_numer - 1]}" unless first_line
|
591
|
+
m << "#{indicator}#{lines[line_numer]}"
|
592
|
+
m << "#{indent}#{lines[line_numer + 1]}" unless last_line
|
593
|
+
m << "\n" unless m.end_with?("\n")
|
594
|
+
m << "#{indent}-------------------------------------------\n"
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
private
|
599
|
+
|
600
|
+
def parse_line_number_from_description
|
601
|
+
description = self.description
|
602
|
+
if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
|
603
|
+
trace_line = Regexp.last_match[1]
|
604
|
+
description = description.sub(/#{Regexp.quote trace_line}:\s*/, "").sub("\n", " - ")
|
605
|
+
end
|
606
|
+
[trace_line, description]
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
def gemfile_root
|
611
|
+
@gemfile ||= Bundler.default_gemfile
|
612
|
+
@gemfile.dirname
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|