rubygems-update 2.7.11 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +66 -0
- data/.travis.yml +22 -18
- data/CONTRIBUTING.md +141 -0
- data/History.txt +289 -19
- data/MAINTAINERS.txt +1 -0
- data/Manifest.txt +16 -11
- data/POLICIES.md +92 -0
- data/README.md +47 -26
- data/Rakefile +47 -207
- data/{UPGRADING.rdoc → UPGRADING.md} +31 -32
- data/appveyor.yml +20 -45
- data/bin/gem +1 -2
- data/bin/update_rubygems +2 -3
- data/bundler/CHANGELOG.md +54 -0
- data/bundler/bundler.gemspec +7 -1
- data/bundler/lib/bundler.rb +26 -8
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli.rb +63 -21
- data/bundler/lib/bundler/cli/add.rb +15 -5
- data/bundler/lib/bundler/cli/binstubs.rb +8 -2
- data/bundler/lib/bundler/cli/doctor.rb +47 -1
- data/bundler/lib/bundler/cli/install.rb +8 -5
- data/bundler/lib/bundler/cli/list.rb +41 -5
- data/bundler/lib/bundler/cli/outdated.rb +7 -1
- data/bundler/lib/bundler/cli/pristine.rb +4 -0
- data/bundler/lib/bundler/cli/remove.rb +18 -0
- data/bundler/lib/bundler/definition.rb +15 -16
- data/bundler/lib/bundler/dependency.rb +2 -2
- data/bundler/lib/bundler/dsl.rb +19 -3
- data/bundler/lib/bundler/feature_flag.rb +7 -0
- data/bundler/lib/bundler/gem_version_promoter.rb +4 -2
- data/bundler/lib/bundler/injector.rb +168 -9
- data/bundler/lib/bundler/installer.rb +29 -6
- data/bundler/lib/bundler/installer/parallel_installer.rb +5 -0
- data/bundler/lib/bundler/plugin.rb +10 -3
- data/bundler/lib/bundler/plugin/events.rb +61 -0
- data/bundler/lib/bundler/resolver.rb +2 -2
- data/bundler/lib/bundler/runtime.rb +8 -2
- data/bundler/lib/bundler/settings.rb +24 -3
- data/bundler/lib/bundler/settings/validator.rb +23 -0
- data/bundler/lib/bundler/shared_helpers.rb +19 -3
- data/bundler/lib/bundler/source.rb +9 -9
- data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/man/bundle-add.ronn +13 -2
- data/bundler/man/bundle-config.ronn +21 -0
- data/bundler/man/bundle-install.ronn +1 -1
- data/bundler/man/bundle-list.ronn +19 -1
- data/bundler/man/bundle-outdated.ronn +4 -0
- data/bundler/man/bundle-remove.ronn +23 -0
- data/bundler/man/bundle-update.ronn +1 -1
- data/lib/rubygems.rb +70 -96
- data/lib/rubygems/available_set.rb +1 -1
- data/lib/rubygems/basic_specification.rb +12 -12
- data/lib/rubygems/bundler_version_finder.rb +3 -3
- data/lib/rubygems/command.rb +22 -15
- data/lib/rubygems/command_manager.rb +20 -11
- data/lib/rubygems/commands/build_command.rb +27 -8
- data/lib/rubygems/commands/cert_command.rb +45 -24
- data/lib/rubygems/commands/check_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +14 -7
- data/lib/rubygems/commands/contents_command.rb +14 -15
- data/lib/rubygems/commands/dependency_command.rb +17 -17
- data/lib/rubygems/commands/environment_command.rb +20 -1
- data/lib/rubygems/commands/fetch_command.rb +2 -3
- data/lib/rubygems/commands/generate_index_command.rb +2 -3
- data/lib/rubygems/commands/help_command.rb +12 -13
- data/lib/rubygems/commands/info_command.rb +33 -0
- data/lib/rubygems/commands/install_command.rb +21 -17
- data/lib/rubygems/commands/list_command.rb +0 -1
- data/lib/rubygems/commands/lock_command.rb +3 -4
- data/lib/rubygems/commands/open_command.rb +16 -10
- data/lib/rubygems/commands/owner_command.rb +20 -11
- data/lib/rubygems/commands/pristine_command.rb +23 -16
- data/lib/rubygems/commands/push_command.rb +17 -8
- data/lib/rubygems/commands/query_command.rb +24 -24
- data/lib/rubygems/commands/rdoc_command.rb +3 -4
- data/lib/rubygems/commands/search_command.rb +0 -1
- data/lib/rubygems/commands/server_command.rb +1 -2
- data/lib/rubygems/commands/setup_command.rb +78 -38
- data/lib/rubygems/commands/signin_command.rb +2 -1
- data/lib/rubygems/commands/signout_command.rb +2 -2
- data/lib/rubygems/commands/sources_command.rb +11 -12
- data/lib/rubygems/commands/specification_command.rb +7 -7
- data/lib/rubygems/commands/uninstall_command.rb +41 -19
- data/lib/rubygems/commands/unpack_command.rb +16 -7
- data/lib/rubygems/commands/update_command.rb +28 -23
- data/lib/rubygems/commands/which_command.rb +4 -5
- data/lib/rubygems/commands/yank_command.rb +1 -2
- data/lib/rubygems/compatibility.rb +1 -21
- data/lib/rubygems/config_file.rb +36 -36
- data/lib/rubygems/core_ext/kernel_require.rb +6 -6
- data/lib/rubygems/core_ext/kernel_warn.rb +45 -0
- data/lib/rubygems/defaults.rb +31 -12
- data/lib/rubygems/dependency.rb +14 -14
- data/lib/rubygems/dependency_installer.rb +29 -31
- data/lib/rubygems/dependency_list.rb +8 -9
- data/lib/rubygems/deprecate.rb +2 -3
- data/lib/rubygems/doctor.rb +5 -6
- data/lib/rubygems/errors.rb +3 -3
- data/lib/rubygems/exceptions.rb +11 -4
- data/lib/rubygems/ext.rb +0 -1
- data/lib/rubygems/ext/build_error.rb +0 -1
- data/lib/rubygems/ext/builder.rb +50 -23
- data/lib/rubygems/ext/cmake_builder.rb +2 -2
- data/lib/rubygems/ext/configure_builder.rb +2 -3
- data/lib/rubygems/ext/ext_conf_builder.rb +8 -7
- data/lib/rubygems/ext/rake_builder.rb +16 -18
- data/lib/rubygems/gem_runner.rb +2 -2
- data/lib/rubygems/gemcutter_utilities.rb +40 -13
- data/lib/rubygems/indexer.rb +19 -12
- data/lib/rubygems/install_default_message.rb +0 -1
- data/lib/rubygems/install_message.rb +0 -1
- data/lib/rubygems/install_update_options.rb +2 -28
- data/lib/rubygems/installer.rb +95 -75
- data/lib/rubygems/installer_test_case.rb +0 -14
- data/lib/rubygems/local_remote_options.rb +5 -4
- data/lib/rubygems/mock_gem_ui.rb +3 -4
- data/lib/rubygems/name_tuple.rb +4 -4
- data/lib/rubygems/package.rb +90 -73
- data/lib/rubygems/package/digest_io.rb +3 -4
- data/lib/rubygems/package/file_source.rb +3 -4
- data/lib/rubygems/package/io_source.rb +1 -2
- data/lib/rubygems/package/old.rb +8 -16
- data/lib/rubygems/package/source.rb +0 -1
- data/lib/rubygems/package/tar_header.rb +2 -2
- data/lib/rubygems/package/tar_reader.rb +2 -4
- data/lib/rubygems/package/tar_reader/entry.rb +20 -4
- data/lib/rubygems/package/tar_test_case.rb +2 -8
- data/lib/rubygems/package/tar_writer.rb +13 -15
- data/lib/rubygems/package_task.rb +0 -1
- data/lib/rubygems/path_support.rb +16 -6
- data/lib/rubygems/platform.rb +4 -5
- data/lib/rubygems/psych_tree.rb +1 -1
- data/lib/rubygems/rdoc.rb +0 -311
- data/lib/rubygems/remote_fetcher.rb +34 -48
- data/lib/rubygems/request.rb +16 -15
- data/lib/rubygems/request/connection_pools.rb +24 -13
- data/lib/rubygems/request/http_pool.rb +3 -4
- data/lib/rubygems/request/https_pool.rb +1 -3
- data/lib/rubygems/request_set.rb +52 -25
- data/lib/rubygems/request_set/gem_dependency_api.rb +36 -40
- data/lib/rubygems/request_set/lockfile.rb +12 -12
- data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
- data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
- data/lib/rubygems/requirement.rb +16 -16
- data/lib/rubygems/resolver.rb +10 -15
- data/lib/rubygems/resolver/activation_request.rb +6 -6
- data/lib/rubygems/resolver/api_set.rb +5 -6
- data/lib/rubygems/resolver/api_specification.rb +2 -3
- data/lib/rubygems/resolver/best_set.rb +5 -6
- data/lib/rubygems/resolver/composed_set.rb +5 -6
- data/lib/rubygems/resolver/conflict.rb +5 -5
- data/lib/rubygems/resolver/current_set.rb +1 -2
- data/lib/rubygems/resolver/dependency_request.rb +4 -4
- data/lib/rubygems/resolver/git_set.rb +5 -6
- data/lib/rubygems/resolver/git_specification.rb +4 -5
- data/lib/rubygems/resolver/index_set.rb +5 -6
- data/lib/rubygems/resolver/index_specification.rb +3 -4
- data/lib/rubygems/resolver/installed_specification.rb +3 -4
- data/lib/rubygems/resolver/installer_set.rb +12 -12
- data/lib/rubygems/resolver/local_specification.rb +1 -2
- data/lib/rubygems/resolver/lock_set.rb +5 -6
- data/lib/rubygems/resolver/lock_specification.rb +7 -8
- data/lib/rubygems/resolver/requirement_list.rb +1 -1
- data/lib/rubygems/resolver/set.rb +2 -2
- data/lib/rubygems/resolver/source_set.rb +4 -5
- data/lib/rubygems/resolver/spec_specification.rb +1 -2
- data/lib/rubygems/resolver/specification.rb +10 -7
- data/lib/rubygems/resolver/stats.rb +1 -1
- data/lib/rubygems/resolver/vendor_set.rb +4 -5
- data/lib/rubygems/resolver/vendor_specification.rb +2 -3
- data/lib/rubygems/safe_yaml.rb +18 -10
- data/lib/rubygems/security.rb +21 -22
- data/lib/rubygems/security/policies.rb +1 -2
- data/lib/rubygems/security/policy.rb +25 -25
- data/lib/rubygems/security/signer.rb +72 -24
- data/lib/rubygems/security/trust_dir.rb +10 -10
- data/lib/rubygems/server.rb +21 -21
- data/lib/rubygems/source.rb +16 -25
- data/lib/rubygems/source/git.rb +9 -10
- data/lib/rubygems/source/installed.rb +3 -4
- data/lib/rubygems/source/local.rb +7 -7
- data/lib/rubygems/source/lock.rb +4 -4
- data/lib/rubygems/source/specific_file.rb +5 -5
- data/lib/rubygems/source/vendor.rb +2 -3
- data/lib/rubygems/source_list.rb +2 -2
- data/lib/rubygems/source_local.rb +0 -1
- data/lib/rubygems/spec_fetcher.rb +5 -6
- data/lib/rubygems/specification.rb +199 -536
- data/lib/rubygems/specification_policy.rb +407 -0
- data/lib/rubygems/ssl_certs/{rubygems.org → index.rubygems.org}/GlobalSignRootCA.pem +0 -0
- data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/rubygems/stub_specification.rb +11 -15
- data/lib/rubygems/test_case.rb +141 -66
- data/lib/rubygems/test_utilities.rb +20 -35
- data/lib/rubygems/text.rb +6 -6
- data/lib/rubygems/uninstaller.rb +37 -26
- data/lib/rubygems/uri_formatter.rb +1 -2
- data/lib/rubygems/user_interaction.rb +38 -93
- data/lib/rubygems/util.rb +20 -14
- data/lib/rubygems/util/licenses.rb +27 -1
- data/lib/rubygems/util/list.rb +1 -1
- data/lib/rubygems/validator.rb +4 -5
- data/lib/rubygems/version.rb +15 -15
- data/lib/rubygems/version_option.rb +2 -3
- data/rubygems-update.gemspec +43 -0
- data/setup.rb +2 -8
- data/test/rubygems/rubygems_plugin.rb +0 -1
- data/test/rubygems/simple_gem.rb +1 -1
- data/test/rubygems/test_bundled_ca.rb +4 -7
- data/test/rubygems/test_config.rb +7 -2
- data/test/rubygems/test_gem.rb +161 -130
- data/test/rubygems/test_gem_command.rb +0 -1
- data/test/rubygems/test_gem_command_manager.rb +8 -3
- data/test/rubygems/test_gem_commands_build_command.rb +219 -15
- data/test/rubygems/test_gem_commands_cert_command.rb +69 -8
- data/test/rubygems/test_gem_commands_check_command.rb +1 -1
- data/test/rubygems/test_gem_commands_cleanup_command.rb +27 -1
- data/test/rubygems/test_gem_commands_contents_command.rb +1 -2
- data/test/rubygems/test_gem_commands_dependency_command.rb +33 -34
- data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
- data/test/rubygems/test_gem_commands_fetch_command.rb +0 -1
- data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -1
- data/test/rubygems/test_gem_commands_help_command.rb +7 -4
- data/test/rubygems/test_gem_commands_info_command.rb +44 -0
- data/test/rubygems/test_gem_commands_install_command.rb +79 -12
- data/test/rubygems/test_gem_commands_lock_command.rb +0 -1
- data/test/rubygems/test_gem_commands_open_command.rb +29 -0
- data/test/rubygems/test_gem_commands_outdated_command.rb +0 -1
- data/test/rubygems/test_gem_commands_owner_command.rb +93 -57
- data/test/rubygems/test_gem_commands_pristine_command.rb +65 -30
- data/test/rubygems/test_gem_commands_push_command.rb +39 -0
- data/test/rubygems/test_gem_commands_query_command.rb +102 -100
- data/test/rubygems/test_gem_commands_search_command.rb +0 -1
- data/test/rubygems/test_gem_commands_server_command.rb +0 -1
- data/test/rubygems/test_gem_commands_setup_command.rb +39 -8
- data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
- data/test/rubygems/test_gem_commands_sources_command.rb +0 -1
- data/test/rubygems/test_gem_commands_specification_command.rb +2 -3
- data/test/rubygems/test_gem_commands_stale_command.rb +3 -2
- data/test/rubygems/test_gem_commands_uninstall_command.rb +81 -7
- data/test/rubygems/test_gem_commands_unpack_command.rb +17 -1
- data/test/rubygems/test_gem_commands_update_command.rb +19 -2
- data/test/rubygems/test_gem_commands_which_command.rb +0 -1
- data/test/rubygems/test_gem_commands_yank_command.rb +0 -1
- data/test/rubygems/test_gem_config_file.rb +4 -2
- data/test/rubygems/test_gem_dependency.rb +0 -1
- data/test/rubygems/test_gem_dependency_installer.rb +8 -5
- data/test/rubygems/test_gem_dependency_list.rb +6 -7
- data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -1
- data/test/rubygems/test_gem_doctor.rb +1 -2
- data/test/rubygems/test_gem_ext_builder.rb +10 -23
- data/test/rubygems/test_gem_ext_cmake_builder.rb +5 -4
- data/test/rubygems/test_gem_ext_configure_builder.rb +3 -3
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +8 -9
- data/test/rubygems/test_gem_ext_rake_builder.rb +20 -5
- data/test/rubygems/test_gem_gem_runner.rb +0 -1
- data/test/rubygems/test_gem_gemcutter_utilities.rb +32 -6
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -1
- data/test/rubygems/test_gem_indexer.rb +1 -2
- data/test/rubygems/test_gem_install_update_options.rb +1 -20
- data/test/rubygems/test_gem_installer.rb +69 -203
- data/test/rubygems/test_gem_local_remote_options.rb +3 -3
- data/test/rubygems/test_gem_name_tuple.rb +0 -1
- data/test/rubygems/test_gem_package.rb +59 -50
- data/test/rubygems/test_gem_package_old.rb +0 -1
- data/test/rubygems/test_gem_package_tar_header.rb +1 -2
- data/test/rubygems/test_gem_package_tar_reader.rb +0 -1
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +11 -0
- data/test/rubygems/test_gem_package_tar_writer.rb +40 -7
- data/test/rubygems/test_gem_package_task.rb +2 -2
- data/test/rubygems/test_gem_path_support.rb +28 -11
- data/test/rubygems/test_gem_platform.rb +4 -5
- data/test/rubygems/test_gem_rdoc.rb +1 -2
- data/test/rubygems/test_gem_remote_fetcher.rb +111 -130
- data/test/rubygems/test_gem_request.rb +5 -5
- data/test/rubygems/test_gem_request_connection_pools.rb +24 -3
- data/test/rubygems/test_gem_request_set.rb +5 -5
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +2 -7
- data/test/rubygems/test_gem_request_set_lockfile.rb +1 -2
- data/test/rubygems/test_gem_request_set_lockfile_parser.rb +4 -9
- data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
- data/test/rubygems/test_gem_requirement.rb +18 -4
- data/test/rubygems/test_gem_resolver.rb +13 -17
- data/test/rubygems/test_gem_resolver_activation_request.rb +0 -1
- data/test/rubygems/test_gem_resolver_api_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_api_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_best_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_composed_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_conflict.rb +0 -1
- data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -1
- data/test/rubygems/test_gem_resolver_git_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_git_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_index_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_index_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_installer_set.rb +2 -3
- data/test/rubygems/test_gem_resolver_local_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_lock_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -1
- data/test/rubygems/test_gem_resolver_specification.rb +1 -2
- data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -1
- data/test/rubygems/test_gem_security.rb +1 -3
- data/test/rubygems/test_gem_security_policy.rb +4 -5
- data/test/rubygems/test_gem_security_signer.rb +4 -3
- data/test/rubygems/test_gem_security_trust_dir.rb +1 -2
- data/test/rubygems/test_gem_server.rb +4 -4
- data/test/rubygems/test_gem_source.rb +0 -13
- data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
- data/test/rubygems/test_gem_source_git.rb +0 -1
- data/test/rubygems/test_gem_source_installed.rb +0 -1
- data/test/rubygems/test_gem_source_lock.rb +0 -1
- data/test/rubygems/test_gem_source_vendor.rb +0 -1
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -1
- data/test/rubygems/test_gem_specification.rb +334 -198
- data/test/rubygems/test_gem_stream_ui.rb +13 -30
- data/test/rubygems/test_gem_stub_specification.rb +0 -2
- data/test/rubygems/test_gem_text.rb +4 -5
- data/test/rubygems/test_gem_uninstaller.rb +21 -1
- data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -1
- data/test/rubygems/test_gem_uri_formatter.rb +0 -1
- data/test/rubygems/test_gem_util.rb +6 -11
- data/test/rubygems/test_gem_validator.rb +0 -1
- data/test/rubygems/test_gem_version.rb +11 -11
- data/test/rubygems/test_gem_version_option.rb +0 -1
- data/test/rubygems/test_remote_fetch_error.rb +0 -1
- data/test/rubygems/test_require.rb +67 -52
- data/util/CL2notes +1 -2
- data/util/ci +15 -12
- data/util/create_certs.rb +6 -7
- data/util/create_encrypted_key.rb +0 -1
- data/util/patch_with_prs.rb +1 -1
- data/util/rubocop +8 -0
- data/util/update_bundled_ca_certificates.rb +15 -14
- data/util/update_changelog.rb +1 -1
- metadata +67 -59
- data/.autotest +0 -71
- data/.document +0 -5
- data/CONTRIBUTING.rdoc +0 -130
- data/CVE-2013-4287.txt +0 -35
- data/CVE-2013-4363.txt +0 -45
- data/CVE-2015-3900.txt +0 -40
- data/POLICIES.rdoc +0 -74
- data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +0 -21
- data/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -2,13 +2,20 @@
|
|
2
2
|
|
3
3
|
module Bundler
|
4
4
|
class Injector
|
5
|
+
INJECTED_GEMS = "injected gems".freeze
|
6
|
+
|
5
7
|
def self.inject(new_deps, options = {})
|
6
8
|
injector = new(new_deps, options)
|
7
9
|
injector.inject(Bundler.default_gemfile, Bundler.default_lockfile)
|
8
10
|
end
|
9
11
|
|
10
|
-
def
|
11
|
-
|
12
|
+
def self.remove(gems, options = {})
|
13
|
+
injector = new(gems, options)
|
14
|
+
injector.remove(Bundler.default_gemfile, Bundler.default_lockfile)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(deps, options = {})
|
18
|
+
@deps = deps
|
12
19
|
@options = options
|
13
20
|
end
|
14
21
|
|
@@ -28,18 +35,19 @@ module Bundler
|
|
28
35
|
builder.eval_gemfile(gemfile_path)
|
29
36
|
|
30
37
|
# don't inject any gems that are already in the Gemfile
|
31
|
-
@
|
38
|
+
@deps -= builder.dependencies
|
32
39
|
|
33
40
|
# add new deps to the end of the in-memory Gemfile
|
34
|
-
# Set conservative versioning to false because
|
35
|
-
|
41
|
+
# Set conservative versioning to false because
|
42
|
+
# we want to let the resolver resolve the version first
|
43
|
+
builder.eval_gemfile(INJECTED_GEMS, build_gem_lines(false)) if @deps.any?
|
36
44
|
|
37
45
|
# resolve to see if the new deps broke anything
|
38
46
|
@definition = builder.to_definition(lockfile_path, {})
|
39
47
|
@definition.resolve_remotely!
|
40
48
|
|
41
49
|
# since nothing broke, we can add those gems to the gemfile
|
42
|
-
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @
|
50
|
+
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
|
43
51
|
|
44
52
|
# since we resolved successfully, write out the lockfile
|
45
53
|
@definition.lock(Bundler.default_lockfile)
|
@@ -48,7 +56,21 @@ module Bundler
|
|
48
56
|
Bundler.reset_paths!
|
49
57
|
|
50
58
|
# return an array of the deps that we added
|
51
|
-
@
|
59
|
+
@deps
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
|
64
|
+
# @param [Pathname] lockfile_path The lockfile from which to remove dependencies.
|
65
|
+
# @return [Array]
|
66
|
+
def remove(gemfile_path, lockfile_path)
|
67
|
+
# remove gems from each gemfiles we have
|
68
|
+
Bundler.definition.gemfiles.each do |path|
|
69
|
+
deps = remove_deps(path)
|
70
|
+
|
71
|
+
show_warning("No gems were removed from the gemfile.") if deps.empty?
|
72
|
+
|
73
|
+
deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep, false)} was removed." }
|
52
74
|
end
|
53
75
|
end
|
54
76
|
|
@@ -61,11 +83,21 @@ module Bundler
|
|
61
83
|
seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
|
62
84
|
|
63
85
|
prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
|
64
|
-
"
|
86
|
+
"#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def version_prefix
|
90
|
+
if @options[:strict]
|
91
|
+
"= "
|
92
|
+
elsif @options[:optimistic]
|
93
|
+
">= "
|
94
|
+
else
|
95
|
+
"~> "
|
96
|
+
end
|
65
97
|
end
|
66
98
|
|
67
99
|
def build_gem_lines(conservative_versioning)
|
68
|
-
@
|
100
|
+
@deps.map do |d|
|
69
101
|
name = d.name.dump
|
70
102
|
|
71
103
|
requirement = if conservative_versioning
|
@@ -90,5 +122,132 @@ module Bundler
|
|
90
122
|
f.puts new_gem_lines
|
91
123
|
end
|
92
124
|
end
|
125
|
+
|
126
|
+
# evalutes a gemfile to remove the specified gem
|
127
|
+
# from it.
|
128
|
+
def remove_deps(gemfile_path)
|
129
|
+
initial_gemfile = IO.readlines(gemfile_path)
|
130
|
+
|
131
|
+
Bundler.ui.info "Removing gems from #{gemfile_path}"
|
132
|
+
|
133
|
+
# evaluate the Gemfile we have
|
134
|
+
builder = Dsl.new
|
135
|
+
builder.eval_gemfile(gemfile_path)
|
136
|
+
|
137
|
+
removed_deps = remove_gems_from_dependencies(builder, @deps, gemfile_path)
|
138
|
+
|
139
|
+
# abort the opertion if no gems were removed
|
140
|
+
# no need to operate on gemfile furthur
|
141
|
+
return [] if removed_deps.empty?
|
142
|
+
|
143
|
+
cleaned_gemfile = remove_gems_from_gemfile(@deps, gemfile_path)
|
144
|
+
|
145
|
+
SharedHelpers.write_to_gemfile(gemfile_path, cleaned_gemfile)
|
146
|
+
|
147
|
+
# check for errors
|
148
|
+
# including extra gems being removed
|
149
|
+
# or some gems not being removed
|
150
|
+
# and return the actual removed deps
|
151
|
+
cross_check_for_errors(gemfile_path, builder.dependencies, removed_deps, initial_gemfile)
|
152
|
+
end
|
153
|
+
|
154
|
+
# @param [Dsl] builder Dsl object of current Gemfile.
|
155
|
+
# @param [Array] gems Array of names of gems to be removed.
|
156
|
+
# @param [Pathname] path of the Gemfile
|
157
|
+
# @return [Array] removed_deps Array of removed dependencies.
|
158
|
+
def remove_gems_from_dependencies(builder, gems, gemfile_path)
|
159
|
+
removed_deps = []
|
160
|
+
|
161
|
+
gems.each do |gem_name|
|
162
|
+
deleted_dep = builder.dependencies.find {|d| d.name == gem_name }
|
163
|
+
|
164
|
+
if deleted_dep.nil?
|
165
|
+
raise GemfileError, "`#{gem_name}` is not specified in #{gemfile_path} so it could not be removed."
|
166
|
+
end
|
167
|
+
|
168
|
+
builder.dependencies.delete(deleted_dep)
|
169
|
+
|
170
|
+
removed_deps << deleted_dep
|
171
|
+
end
|
172
|
+
|
173
|
+
removed_deps
|
174
|
+
end
|
175
|
+
|
176
|
+
# @param [Array] gems Array of names of gems to be removed.
|
177
|
+
# @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
|
178
|
+
def remove_gems_from_gemfile(gems, gemfile_path)
|
179
|
+
patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
|
180
|
+
|
181
|
+
# remove lines which match the regex
|
182
|
+
new_gemfile = IO.readlines(gemfile_path).reject {|line| line.match(patterns) }
|
183
|
+
|
184
|
+
# remove lone \n and append them with other strings
|
185
|
+
new_gemfile.each_with_index do |_line, index|
|
186
|
+
if new_gemfile[index + 1] == "\n"
|
187
|
+
new_gemfile[index] += new_gemfile[index + 1]
|
188
|
+
new_gemfile.delete_at(index + 1)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
%w[group source env install_if].each {|block| remove_nested_blocks(new_gemfile, block) }
|
193
|
+
|
194
|
+
new_gemfile.join.chomp
|
195
|
+
end
|
196
|
+
|
197
|
+
# @param [Array] gemfile Array of gemfile contents.
|
198
|
+
# @param [String] block_name Name of block name to look for.
|
199
|
+
def remove_nested_blocks(gemfile, block_name)
|
200
|
+
nested_blocks = 0
|
201
|
+
|
202
|
+
# count number of nested blocks
|
203
|
+
gemfile.each_with_index {|line, index| nested_blocks += 1 if !gemfile[index + 1].nil? && gemfile[index + 1].include?(block_name) && line.include?(block_name) }
|
204
|
+
|
205
|
+
while nested_blocks >= 0
|
206
|
+
nested_blocks -= 1
|
207
|
+
|
208
|
+
gemfile.each_with_index do |line, index|
|
209
|
+
next unless !line.nil? && line.include?(block_name)
|
210
|
+
if gemfile[index + 1] =~ /^\s*end\s*$/
|
211
|
+
gemfile[index] = nil
|
212
|
+
gemfile[index + 1] = nil
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
gemfile.compact!
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
# @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
|
221
|
+
# @param [Array] original_deps Array of original dependencies.
|
222
|
+
# @param [Array] removed_deps Array of removed dependencies.
|
223
|
+
# @param [Array] initial_gemfile Contents of original Gemfile before any operation.
|
224
|
+
def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)
|
225
|
+
# evalute the new gemfile to look for any failure cases
|
226
|
+
builder = Dsl.new
|
227
|
+
builder.eval_gemfile(gemfile_path)
|
228
|
+
|
229
|
+
# record gems which were removed but not requested
|
230
|
+
extra_removed_gems = original_deps - builder.dependencies
|
231
|
+
|
232
|
+
# if some extra gems were removed then raise error
|
233
|
+
# and revert Gemfile to original
|
234
|
+
unless extra_removed_gems.empty?
|
235
|
+
SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join)
|
236
|
+
|
237
|
+
raise InvalidOption, "Gems could not be removed. #{extra_removed_gems.join(", ")} would also have been removed. Bundler cannot continue."
|
238
|
+
end
|
239
|
+
|
240
|
+
# record gems which could not be removed due to some reasons
|
241
|
+
errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path }
|
242
|
+
|
243
|
+
show_warning "#{errored_deps.map(&:name).join(", ")} could not be removed." unless errored_deps.empty?
|
244
|
+
|
245
|
+
# return actual removed dependencies
|
246
|
+
removed_deps - errored_deps
|
247
|
+
end
|
248
|
+
|
249
|
+
def show_warning(message)
|
250
|
+
Bundler.ui.info Bundler.ui.add_color(message, :yellow)
|
251
|
+
end
|
93
252
|
end
|
94
253
|
end
|
@@ -21,8 +21,9 @@ module Bundler
|
|
21
21
|
# For more information see the #run method on this class.
|
22
22
|
def self.install(root, definition, options = {})
|
23
23
|
installer = new(root, definition)
|
24
|
-
Plugin.hook(
|
24
|
+
Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL_ALL, definition.dependencies)
|
25
25
|
installer.run(options)
|
26
|
+
Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL_ALL, definition.dependencies)
|
26
27
|
installer
|
27
28
|
end
|
28
29
|
|
@@ -192,14 +193,36 @@ module Bundler
|
|
192
193
|
# installation is SO MUCH FASTER. so we let people opt in.
|
193
194
|
def install(options)
|
194
195
|
force = options["force"]
|
195
|
-
jobs = options
|
196
|
-
|
197
|
-
|
196
|
+
jobs = installation_parallelization(options)
|
197
|
+
install_in_parallel jobs, options[:standalone], force
|
198
|
+
end
|
199
|
+
|
200
|
+
def installation_parallelization(options)
|
201
|
+
if jobs = options.delete(:jobs)
|
202
|
+
return jobs
|
203
|
+
end
|
204
|
+
|
205
|
+
return 1 unless can_install_in_parallel?
|
206
|
+
|
207
|
+
auto_config_jobs = Bundler.feature_flag.auto_config_jobs?
|
208
|
+
if jobs = Bundler.settings[:jobs]
|
209
|
+
if auto_config_jobs
|
210
|
+
jobs
|
198
211
|
else
|
199
|
-
1
|
212
|
+
[jobs.pred, 1].max
|
200
213
|
end
|
214
|
+
elsif auto_config_jobs
|
215
|
+
processor_count
|
216
|
+
else
|
217
|
+
1
|
201
218
|
end
|
202
|
-
|
219
|
+
end
|
220
|
+
|
221
|
+
def processor_count
|
222
|
+
require "etc"
|
223
|
+
Etc.nprocessors
|
224
|
+
rescue
|
225
|
+
1
|
203
226
|
end
|
204
227
|
|
205
228
|
def load_plugins
|
@@ -87,6 +87,7 @@ module Bundler
|
|
87
87
|
@force = force
|
88
88
|
@specs = all_specs.map {|s| SpecInstallation.new(s) }
|
89
89
|
@spec_set = all_specs
|
90
|
+
@rake = @specs.find {|s| s.name == "rake" }
|
90
91
|
end
|
91
92
|
|
92
93
|
def call
|
@@ -155,6 +156,7 @@ module Bundler
|
|
155
156
|
end
|
156
157
|
|
157
158
|
def do_install(spec_install, worker_num)
|
159
|
+
Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
|
158
160
|
gem_installer = Bundler::GemInstaller.new(
|
159
161
|
spec_install.spec, @installer, @standalone, worker_num, @force
|
160
162
|
)
|
@@ -170,6 +172,7 @@ module Bundler
|
|
170
172
|
spec_install.state = :failed
|
171
173
|
spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
|
172
174
|
end
|
175
|
+
Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL, spec_install)
|
173
176
|
spec_install
|
174
177
|
end
|
175
178
|
|
@@ -218,6 +221,8 @@ module Bundler
|
|
218
221
|
# are installed.
|
219
222
|
def enqueue_specs
|
220
223
|
@specs.select(&:ready_to_enqueue?).each do |spec|
|
224
|
+
next if @rake && !@rake.installed? && spec.name != @rake.name
|
225
|
+
|
221
226
|
if spec.dependencies_installed? @specs
|
222
227
|
spec.state = :enqueued
|
223
228
|
worker_pool.enq spec
|
@@ -5,6 +5,7 @@ require "bundler/plugin/api"
|
|
5
5
|
module Bundler
|
6
6
|
module Plugin
|
7
7
|
autoload :DSL, "bundler/plugin/dsl"
|
8
|
+
autoload :Events, "bundler/plugin/events"
|
8
9
|
autoload :Index, "bundler/plugin/index"
|
9
10
|
autoload :Installer, "bundler/plugin/installer"
|
10
11
|
autoload :SourceList, "bundler/plugin/source_list"
|
@@ -80,8 +81,8 @@ module Bundler
|
|
80
81
|
|
81
82
|
# The directory root for all plugin related data
|
82
83
|
#
|
83
|
-
#
|
84
|
-
# in user_bundle_path
|
84
|
+
# If run in an app, points to local root, in app_config_path
|
85
|
+
# Otherwise, points to global root, in Bundler.user_bundle_path("plugin")
|
85
86
|
def root
|
86
87
|
@root ||= if SharedHelpers.in_bundle?
|
87
88
|
local_root
|
@@ -96,7 +97,7 @@ module Bundler
|
|
96
97
|
|
97
98
|
# The global directory root for all plugin related data
|
98
99
|
def global_root
|
99
|
-
Bundler.user_bundle_path
|
100
|
+
Bundler.user_bundle_path("plugin")
|
100
101
|
end
|
101
102
|
|
102
103
|
# The cache directory for plugin stuffs
|
@@ -155,6 +156,9 @@ module Bundler
|
|
155
156
|
# To be called via the API to register a hooks and corresponding block that
|
156
157
|
# will be called to handle the hook
|
157
158
|
def add_hook(event, &block)
|
159
|
+
unless Events.defined_event?(event)
|
160
|
+
raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
|
161
|
+
end
|
158
162
|
@hooks_by_event[event.to_s] << block
|
159
163
|
end
|
160
164
|
|
@@ -166,6 +170,9 @@ module Bundler
|
|
166
170
|
# @param [String] event
|
167
171
|
def hook(event, *args, &arg_blk)
|
168
172
|
return unless Bundler.feature_flag.plugins?
|
173
|
+
unless Events.defined_event?(event)
|
174
|
+
raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
|
175
|
+
end
|
169
176
|
|
170
177
|
plugins = index.hook_plugins(event)
|
171
178
|
return unless plugins.any?
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module Plugin
|
5
|
+
module Events
|
6
|
+
def self.define(const, event)
|
7
|
+
const = const.to_sym.freeze
|
8
|
+
if const_defined?(const) && const_get(const) != event
|
9
|
+
raise ArgumentError, "Attempting to reassign #{const} to a different value"
|
10
|
+
end
|
11
|
+
const_set(const, event) unless const_defined?(const)
|
12
|
+
@events ||= {}
|
13
|
+
@events[event] = const
|
14
|
+
end
|
15
|
+
private_class_method :define
|
16
|
+
|
17
|
+
def self.reset
|
18
|
+
@events.each_value do |const|
|
19
|
+
remove_const(const)
|
20
|
+
end
|
21
|
+
@events = nil
|
22
|
+
end
|
23
|
+
private_class_method :reset
|
24
|
+
|
25
|
+
# Check if an event has been defined
|
26
|
+
# @param event [String] An event to check
|
27
|
+
# @return [Boolean] A boolean indicating if the event has been defined
|
28
|
+
def self.defined_event?(event)
|
29
|
+
@events ||= {}
|
30
|
+
@events.key?(event)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @!parse
|
34
|
+
# A hook called before each individual gem is installed
|
35
|
+
# Includes a Bundler::ParallelInstaller::SpecInstallation.
|
36
|
+
# No state, error, post_install_message will be present as nothing has installed yet
|
37
|
+
# GEM_BEFORE_INSTALL = "before-install"
|
38
|
+
define :GEM_BEFORE_INSTALL, "before-install"
|
39
|
+
|
40
|
+
# @!parse
|
41
|
+
# A hook called after each individual gem is installed
|
42
|
+
# Includes a Bundler::ParallelInstaller::SpecInstallation.
|
43
|
+
# - If state is failed, an error will be present.
|
44
|
+
# - If state is success, a post_install_message may be present.
|
45
|
+
# GEM_AFTER_INSTALL = "after-install"
|
46
|
+
define :GEM_AFTER_INSTALL, "after-install"
|
47
|
+
|
48
|
+
# @!parse
|
49
|
+
# A hook called before any gems install
|
50
|
+
# Includes an Array of Bundler::Dependency objects
|
51
|
+
# GEM_BEFORE_INSTALL_ALL = "before-install-all"
|
52
|
+
define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
|
53
|
+
|
54
|
+
# @!parse
|
55
|
+
# A hook called after any gems install
|
56
|
+
# Includes an Array of Bundler::Dependency objects
|
57
|
+
# GEM_AFTER_INSTALL_ALL = "after-install-all"
|
58
|
+
define :GEM_AFTER_INSTALL_ALL, "after-install-all"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -39,7 +39,7 @@ module Bundler
|
|
39
39
|
@gem_version_promoter = gem_version_promoter
|
40
40
|
@allow_bundler_dependency_conflicts = Bundler.feature_flag.allow_bundler_dependency_conflicts?
|
41
41
|
@lockfile_uses_separate_rubygems_sources = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
|
42
|
-
@use_gvp = !@gem_version_promoter.major?
|
42
|
+
@use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
|
43
43
|
end
|
44
44
|
|
45
45
|
def start(requirements)
|
@@ -137,7 +137,7 @@ module Bundler
|
|
137
137
|
end
|
138
138
|
# GVP handles major itself, but it's still a bit risky to trust it with it
|
139
139
|
# until we get it settled with new behavior. For 2.x it can take over all cases.
|
140
|
-
if
|
140
|
+
if !@use_gvp
|
141
141
|
spec_groups
|
142
142
|
else
|
143
143
|
@gem_version_promoter.sort_versions(dependency, spec_groups)
|
@@ -163,6 +163,7 @@ module Bundler
|
|
163
163
|
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
164
164
|
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
|
165
165
|
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
|
166
|
+
extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
|
166
167
|
spec_gem_paths = []
|
167
168
|
# need to keep git sources around
|
168
169
|
spec_git_paths = @definition.spec_git_paths
|
@@ -170,6 +171,7 @@ module Bundler
|
|
170
171
|
spec_gem_executables = []
|
171
172
|
spec_cache_paths = []
|
172
173
|
spec_gemspec_paths = []
|
174
|
+
spec_extension_paths = []
|
173
175
|
specs.each do |spec|
|
174
176
|
spec_gem_paths << spec.full_gem_path
|
175
177
|
# need to check here in case gems are nested like for the rails git repo
|
@@ -181,6 +183,7 @@ module Bundler
|
|
181
183
|
end
|
182
184
|
spec_cache_paths << spec.cache_file
|
183
185
|
spec_gemspec_paths << spec.spec_file
|
186
|
+
spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
|
184
187
|
spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
|
185
188
|
end
|
186
189
|
spec_gem_paths.uniq!
|
@@ -192,6 +195,7 @@ module Bundler
|
|
192
195
|
stale_gem_dirs = gem_dirs - spec_gem_paths
|
193
196
|
stale_gem_files = gem_files - spec_cache_paths
|
194
197
|
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
198
|
+
stale_extension_dirs = extension_dirs - spec_extension_paths
|
195
199
|
|
196
200
|
removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
197
201
|
removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
@@ -204,8 +208,10 @@ module Bundler
|
|
204
208
|
FileUtils.rm(file) if File.exist?(file)
|
205
209
|
end
|
206
210
|
end
|
207
|
-
|
208
|
-
|
211
|
+
|
212
|
+
stale_dirs = stale_git_cache_dirs + stale_extension_dirs
|
213
|
+
stale_dirs.each do |stale_dir|
|
214
|
+
SharedHelpers.filesystem_access(stale_dir) do |dir|
|
209
215
|
FileUtils.rm_rf(dir) if File.exist?(dir)
|
210
216
|
end
|
211
217
|
end
|