bundler 1.17.3 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3354 -1258
- data/LICENSE.md +18 -19
- data/README.md +10 -15
- data/bundler.gemspec +15 -33
- data/exe/bundle +8 -10
- data/exe/bundler +1 -1
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +5 -13
- data/lib/bundler/capistrano.rb +5 -5
- data/lib/bundler/checksum.rb +254 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +29 -15
- data/lib/bundler/cli/binstubs.rb +13 -5
- data/lib/bundler/cli/cache.rb +24 -17
- data/lib/bundler/cli/check.rb +7 -5
- data/lib/bundler/cli/clean.rb +1 -1
- data/lib/bundler/cli/common.rb +50 -14
- data/lib/bundler/cli/config.rb +171 -86
- data/lib/bundler/cli/console.rb +3 -6
- data/lib/bundler/cli/doctor.rb +29 -12
- data/lib/bundler/cli/exec.rb +9 -25
- data/lib/bundler/cli/fund.rb +36 -0
- data/lib/bundler/cli/gem.rb +268 -53
- data/lib/bundler/cli/info.rb +51 -18
- data/lib/bundler/cli/init.rb +7 -3
- data/lib/bundler/cli/inject.rb +2 -2
- data/lib/bundler/cli/install.rb +55 -73
- data/lib/bundler/cli/issue.rb +9 -8
- data/lib/bundler/cli/list.rb +19 -11
- data/lib/bundler/cli/lock.rb +56 -26
- data/lib/bundler/cli/open.rb +10 -7
- data/lib/bundler/cli/outdated.rb +159 -128
- data/lib/bundler/cli/platform.rb +8 -6
- data/lib/bundler/cli/plugin.rb +23 -12
- data/lib/bundler/cli/pristine.rb +39 -26
- data/lib/bundler/cli/remove.rb +1 -2
- data/lib/bundler/cli/show.rb +7 -7
- data/lib/bundler/cli/update.rb +51 -19
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +399 -390
- data/lib/bundler/compact_index_client/cache.rb +55 -77
- data/lib/bundler/compact_index_client/cache_file.rb +148 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +32 -0
- data/lib/bundler/compact_index_client/parser.rb +84 -0
- data/lib/bundler/compact_index_client/updater.rb +72 -84
- data/lib/bundler/compact_index_client.rb +61 -73
- data/lib/bundler/constants.rb +9 -2
- data/lib/bundler/current_ruby.rb +20 -21
- data/lib/bundler/definition.rb +663 -505
- data/lib/bundler/dependency.rb +38 -71
- data/lib/bundler/deployment.rb +1 -1
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +171 -152
- data/lib/bundler/endpoint_specification.rb +43 -17
- data/lib/bundler/env.rb +11 -18
- data/lib/bundler/environment_preserver.rb +17 -8
- data/lib/bundler/errors.rb +115 -14
- data/lib/bundler/feature_flag.rb +15 -39
- data/lib/bundler/fetcher/base.rb +12 -12
- data/lib/bundler/fetcher/compact_index.rb +41 -47
- data/lib/bundler/fetcher/dependency.rb +4 -8
- data/lib/bundler/fetcher/downloader.rb +27 -20
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/lib/bundler/fetcher/index.rb +6 -33
- data/lib/bundler/fetcher.rb +109 -90
- data/lib/bundler/force_platform.rb +16 -0
- data/lib/bundler/friendly_errors.rb +50 -55
- data/lib/bundler/gem_helper.rb +81 -46
- data/lib/bundler/gem_helpers.rb +78 -29
- data/lib/bundler/gem_tasks.rb +1 -1
- data/lib/bundler/gem_version_promoter.rb +68 -109
- data/lib/bundler/graph.rb +11 -11
- data/lib/bundler/index.rb +74 -82
- data/lib/bundler/injector.rb +58 -26
- data/lib/bundler/inline.rb +59 -35
- data/lib/bundler/installer/gem_installer.rb +29 -29
- data/lib/bundler/installer/parallel_installer.rb +38 -68
- data/lib/bundler/installer/standalone.rb +76 -16
- data/lib/bundler/installer.rb +60 -135
- data/lib/bundler/lazy_specification.rb +161 -63
- data/lib/bundler/lockfile_generator.rb +14 -5
- data/lib/bundler/lockfile_parser.rb +150 -109
- data/lib/bundler/man/bundle-add.1 +76 -0
- data/lib/bundler/man/bundle-add.1.ronn +87 -0
- data/{man → lib/bundler/man}/bundle-binstubs.1 +15 -22
- data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +8 -7
- data/lib/bundler/man/bundle-cache.1 +68 -0
- data/lib/bundler/man/bundle-cache.1.ronn +108 -0
- data/{man → lib/bundler/man}/bundle-check.1 +7 -14
- data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +7 -2
- data/{man → lib/bundler/man}/bundle-clean.1 +4 -11
- data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
- data/{man → lib/bundler/man}/bundle-config.1 +80 -260
- data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +104 -98
- data/lib/bundler/man/bundle-console.1 +33 -0
- data/lib/bundler/man/bundle-console.1.ronn +39 -0
- data/{man → lib/bundler/man}/bundle-doctor.1 +5 -19
- data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +1 -1
- data/lib/bundler/man/bundle-env.1 +9 -0
- data/lib/bundler/man/bundle-env.1.ronn +10 -0
- data/{man → lib/bundler/man}/bundle-exec.1 +20 -78
- data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +12 -10
- data/lib/bundler/man/bundle-fund.1 +22 -0
- data/lib/bundler/man/bundle-fund.1.ronn +25 -0
- data/lib/bundler/man/bundle-gem.1 +87 -0
- data/lib/bundler/man/bundle-gem.1.ronn +149 -0
- data/lib/bundler/man/bundle-help.1 +9 -0
- data/lib/bundler/man/bundle-help.1.ronn +12 -0
- data/lib/bundler/man/bundle-info.1 +17 -0
- data/lib/bundler/man/bundle-info.1.ronn +21 -0
- data/{man → lib/bundler/man}/bundle-init.1 +8 -13
- data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +5 -2
- data/lib/bundler/man/bundle-inject.1 +31 -0
- data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +12 -2
- data/{man → lib/bundler/man}/bundle-install.1 +65 -155
- data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +66 -57
- data/lib/bundler/man/bundle-issue.1 +45 -0
- data/lib/bundler/man/bundle-issue.1.ronn +37 -0
- data/lib/bundler/man/bundle-licenses.1 +9 -0
- data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
- data/{man → lib/bundler/man}/bundle-list.1 +9 -24
- data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +10 -7
- data/{man → lib/bundler/man}/bundle-lock.1 +25 -34
- data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +25 -4
- data/lib/bundler/man/bundle-open.1 +32 -0
- data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +10 -1
- data/{man → lib/bundler/man}/bundle-outdated.1 +23 -75
- data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +21 -22
- data/lib/bundler/man/bundle-platform.1 +49 -0
- data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
- data/lib/bundler/man/bundle-plugin.1 +58 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
- data/{man → lib/bundler/man}/bundle-pristine.1 +5 -16
- data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +1 -1
- data/{man → lib/bundler/man}/bundle-remove.1 +4 -14
- data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +1 -1
- data/{man → lib/bundler/man}/bundle-show.1 +7 -11
- data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +4 -0
- data/{man → lib/bundler/man}/bundle-update.1 +35 -148
- data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +21 -12
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/{man → lib/bundler/man}/bundle-viz.1 +9 -18
- data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +9 -3
- data/{man → lib/bundler/man}/bundle.1 +19 -53
- data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
- data/{man → lib/bundler/man}/gemfile.5 +139 -356
- data/{man → lib/bundler/man}/gemfile.5.ronn +134 -97
- data/{man → lib/bundler/man}/index.txt +9 -1
- data/lib/bundler/match_metadata.rb +17 -0
- data/lib/bundler/match_platform.rb +2 -3
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/materialization.rb +59 -0
- data/lib/bundler/mirror.rb +10 -12
- data/lib/bundler/plugin/api/source.rb +34 -18
- data/lib/bundler/plugin/api.rb +1 -1
- data/lib/bundler/plugin/dsl.rb +1 -1
- data/lib/bundler/plugin/events.rb +24 -0
- data/lib/bundler/plugin/index.rb +44 -9
- data/lib/bundler/plugin/installer/git.rb +0 -4
- data/lib/bundler/plugin/installer/path.rb +18 -0
- data/lib/bundler/plugin/installer/rubygems.rb +1 -9
- data/lib/bundler/plugin/installer.rb +63 -27
- data/lib/bundler/plugin/source_list.rb +5 -1
- data/lib/bundler/plugin.rb +131 -45
- data/lib/bundler/process_lock.rb +10 -14
- data/lib/bundler/remote_specification.rb +22 -10
- data/lib/bundler/resolver/base.rb +118 -0
- data/lib/bundler/resolver/candidate.rb +82 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +90 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +60 -68
- data/lib/bundler/resolver.rb +454 -303
- data/lib/bundler/retry.rb +6 -6
- data/lib/bundler/ruby_dsl.rb +51 -7
- data/lib/bundler/ruby_version.rb +23 -38
- data/lib/bundler/rubygems_ext.rb +357 -98
- data/lib/bundler/rubygems_gem_installer.rb +131 -65
- data/lib/bundler/rubygems_integration.rb +149 -591
- data/lib/bundler/runtime.rb +51 -51
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +206 -0
- data/lib/bundler/settings.rb +271 -135
- data/lib/bundler/setup.rb +23 -12
- data/lib/bundler/shared_helpers.rb +127 -117
- data/lib/bundler/similarity_detector.rb +3 -3
- data/lib/bundler/source/git/git_proxy.rb +326 -127
- data/lib/bundler/source/git.rb +207 -88
- data/lib/bundler/source/metadata.rb +19 -18
- data/lib/bundler/source/path/installer.rb +11 -32
- data/lib/bundler/source/path.rb +39 -38
- data/lib/bundler/source/rubygems/remote.rb +3 -4
- data/lib/bundler/source/rubygems.rb +223 -255
- data/lib/bundler/source/rubygems_aggregate.rb +68 -0
- data/lib/bundler/source.rb +33 -11
- data/lib/bundler/source_list.rb +131 -66
- data/lib/bundler/source_map.rb +71 -0
- data/lib/bundler/spec_set.rb +239 -94
- data/lib/bundler/stub_specification.rb +77 -39
- data/lib/bundler/templates/Executable +3 -5
- data/lib/bundler/templates/Executable.bundler +23 -19
- data/lib/bundler/templates/Executable.standalone +4 -4
- data/lib/bundler/templates/Gemfile +0 -2
- data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +104 -46
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +19 -2
- data/lib/bundler/templates/newgem/README.md.tt +18 -16
- data/lib/bundler/templates/newgem/Rakefile.tt +44 -6
- data/lib/bundler/templates/newgem/bin/console.tt +1 -4
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +37 -40
- data/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
- data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
- data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
- data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
- data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
- data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
- data/lib/bundler/ui/rg_proxy.rb +2 -2
- data/lib/bundler/ui/shell.rb +64 -23
- data/lib/bundler/ui/silent.rb +33 -6
- data/lib/bundler/ui.rb +3 -3
- data/lib/bundler/uri_credentials_filter.rb +11 -5
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +175 -0
- data/lib/bundler/vendor/fileutils/.document +1 -0
- data/lib/bundler/vendor/fileutils/COPYING +56 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1490 -432
- data/lib/bundler/vendor/net-http-persistent/.document +1 -0
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +362 -484
- data/lib/bundler/vendor/pub_grub/.document +1 -0
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/securerandom/.document +1 -0
- data/lib/bundler/vendor/securerandom/COPYING +56 -0
- data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
- data/lib/bundler/vendor/thor/.document +1 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +4 -3
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +8 -18
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +27 -20
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +34 -13
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +47 -28
- data/lib/bundler/vendor/thor/lib/thor/base.rb +200 -54
- data/lib/bundler/vendor/thor/lib/thor/command.rb +34 -18
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +74 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +15 -4
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +35 -15
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +45 -13
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +86 -13
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +51 -40
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +99 -148
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -43
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -49
- data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +6 -6
- data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +182 -17
- data/lib/bundler/vendor/tsort/.document +1 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
- data/lib/bundler/vendor/uri/.document +1 -0
- data/lib/bundler/vendor/uri/COPYING +56 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +876 -0
- data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +1578 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
- data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
- data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/lib/bundler/vendored_fileutils.rb +1 -6
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +1 -42
- data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/vendored_securerandom.rb +12 -0
- data/lib/bundler/vendored_thor.rb +2 -2
- data/lib/bundler/vendored_timeout.rb +12 -0
- data/lib/bundler/vendored_tsort.rb +4 -0
- data/lib/bundler/vendored_uri.rb +21 -0
- data/lib/bundler/version.rb +5 -20
- data/lib/bundler/vlad.rb +3 -3
- data/lib/bundler/worker.rb +26 -15
- data/lib/bundler/yaml_serializer.rb +21 -13
- data/lib/bundler.rb +364 -230
- metadata +186 -218
- data/exe/bundle_ruby +0 -60
- data/lib/bundler/cli/package.rb +0 -49
- data/lib/bundler/compatibility_guard.rb +0 -14
- data/lib/bundler/dep_proxy.rb +0 -48
- data/lib/bundler/gem_remote_fetcher.rb +0 -43
- data/lib/bundler/gemdeps.rb +0 -29
- data/lib/bundler/psyched_yaml.rb +0 -37
- data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
- data/lib/bundler/templates/gems.rb +0 -8
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -7
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
- data/lib/bundler/version_ranges.rb +0 -76
- data/man/bundle-add.1 +0 -58
- data/man/bundle-add.1.txt +0 -52
- data/man/bundle-add.ronn +0 -40
- data/man/bundle-binstubs.1.txt +0 -48
- data/man/bundle-check.1.txt +0 -33
- data/man/bundle-clean.1.txt +0 -26
- data/man/bundle-config.1.txt +0 -529
- data/man/bundle-doctor.1.txt +0 -44
- data/man/bundle-exec.1.txt +0 -178
- data/man/bundle-gem.1 +0 -80
- data/man/bundle-gem.1.txt +0 -91
- data/man/bundle-gem.ronn +0 -78
- data/man/bundle-info.1 +0 -20
- data/man/bundle-info.1.txt +0 -21
- data/man/bundle-info.ronn +0 -17
- data/man/bundle-init.1.txt +0 -34
- data/man/bundle-inject.1 +0 -33
- data/man/bundle-inject.1.txt +0 -32
- data/man/bundle-install.1.txt +0 -396
- data/man/bundle-list.1.txt +0 -43
- data/man/bundle-lock.1.txt +0 -93
- data/man/bundle-open.1 +0 -32
- data/man/bundle-open.1.txt +0 -29
- data/man/bundle-outdated.1.txt +0 -131
- data/man/bundle-package.1 +0 -55
- data/man/bundle-package.1.txt +0 -79
- data/man/bundle-package.ronn +0 -72
- data/man/bundle-platform.1 +0 -61
- data/man/bundle-platform.1.txt +0 -57
- data/man/bundle-pristine.1.txt +0 -44
- data/man/bundle-remove.1.txt +0 -34
- data/man/bundle-show.1.txt +0 -27
- data/man/bundle-update.1.txt +0 -391
- data/man/bundle-viz.1.txt +0 -39
- data/man/bundle.1.txt +0 -116
- data/man/gemfile.5.txt +0 -653
- /data/lib/bundler/{ssl_certs → man}/.document +0 -0
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
|
1
|
+
require_relative "../thor"
|
2
|
+
require_relative "group"
|
4
3
|
|
5
4
|
require "yaml"
|
6
|
-
require "digest"
|
5
|
+
require "digest/sha2"
|
7
6
|
require "pathname"
|
8
7
|
|
9
|
-
class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
|
8
|
+
class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
|
10
9
|
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|
11
10
|
|
12
11
|
def self.banner(command, all = false, subcommand = false)
|
@@ -24,7 +23,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
24
23
|
initialize_thorfiles(meth)
|
25
24
|
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
|
26
25
|
self.class.handle_no_command_error(command, false) if klass.nil?
|
27
|
-
klass.start(["-h", command].compact, :
|
26
|
+
klass.start(["-h", command].compact, shell: shell)
|
28
27
|
else
|
29
28
|
super
|
30
29
|
end
|
@@ -39,33 +38,45 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
39
38
|
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
|
40
39
|
self.class.handle_no_command_error(command, false) if klass.nil?
|
41
40
|
args.unshift(command) if command
|
42
|
-
klass.start(args, :
|
41
|
+
klass.start(args, shell: shell)
|
43
42
|
end
|
44
43
|
|
45
44
|
desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
|
46
|
-
method_options :
|
47
|
-
def install(name) # rubocop:disable MethodLength
|
45
|
+
method_options as: :string, relative: :boolean, force: :boolean
|
46
|
+
def install(name) # rubocop:disable Metrics/MethodLength
|
48
47
|
initialize_thorfiles
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
49
|
+
is_uri = name =~ %r{^https?\://}
|
50
|
+
|
51
|
+
if is_uri
|
52
|
+
base = name
|
53
|
+
package = :file
|
54
|
+
require "open-uri"
|
55
|
+
begin
|
56
|
+
contents = URI.open(name, &:read)
|
57
|
+
rescue OpenURI::HTTPError
|
58
|
+
raise Error, "Error opening URI '#{name}'"
|
59
|
+
end
|
60
|
+
else
|
61
|
+
# If a directory name is provided as the argument, look for a 'main.thor'
|
62
|
+
# command in said directory.
|
63
|
+
begin
|
64
|
+
if File.directory?(File.expand_path(name))
|
65
|
+
base = File.join(name, "main.thor")
|
66
|
+
package = :directory
|
67
|
+
contents = File.open(base, &:read)
|
68
|
+
else
|
69
|
+
base = name
|
70
|
+
package = :file
|
71
|
+
require "open-uri"
|
72
|
+
contents = URI.open(name, &:read)
|
73
|
+
end
|
74
|
+
rescue Errno::ENOENT
|
75
|
+
raise Error, "Error opening file '#{name}'"
|
61
76
|
end
|
62
|
-
rescue OpenURI::HTTPError
|
63
|
-
raise Error, "Error opening URI '#{name}'"
|
64
|
-
rescue Errno::ENOENT
|
65
|
-
raise Error, "Error opening file '#{name}'"
|
66
77
|
end
|
67
78
|
|
68
|
-
say "Your
|
79
|
+
say "Your Thorfile contains:"
|
69
80
|
say contents
|
70
81
|
|
71
82
|
unless options["force"]
|
@@ -83,16 +94,16 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
83
94
|
as = basename if as.empty?
|
84
95
|
end
|
85
96
|
|
86
|
-
location = if options[:relative] ||
|
97
|
+
location = if options[:relative] || is_uri
|
87
98
|
name
|
88
99
|
else
|
89
100
|
File.expand_path(name)
|
90
101
|
end
|
91
102
|
|
92
103
|
thor_yaml[as] = {
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
104
|
+
filename: Digest::SHA256.hexdigest(name + as),
|
105
|
+
location: location,
|
106
|
+
namespaces: Bundler::Thor::Util.namespaces_in_content(contents, base)
|
96
107
|
}
|
97
108
|
|
98
109
|
save_yaml(thor_yaml)
|
@@ -111,7 +122,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
111
122
|
|
112
123
|
desc "version", "Show Bundler::Thor version"
|
113
124
|
def version
|
114
|
-
|
125
|
+
require_relative "version"
|
115
126
|
say "Bundler::Thor #{Bundler::Thor::VERSION}"
|
116
127
|
end
|
117
128
|
|
@@ -153,14 +164,14 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
153
164
|
end
|
154
165
|
|
155
166
|
desc "installed", "List the installed Bundler::Thor modules and commands"
|
156
|
-
method_options :
|
167
|
+
method_options internal: :boolean
|
157
168
|
def installed
|
158
169
|
initialize_thorfiles(nil, true)
|
159
170
|
display_klasses(true, options["internal"])
|
160
171
|
end
|
161
172
|
|
162
173
|
desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
|
163
|
-
method_options :
|
174
|
+
method_options substring: :boolean, group: :string, all: :boolean, debug: :boolean
|
164
175
|
def list(search = "")
|
165
176
|
initialize_thorfiles
|
166
177
|
|
@@ -204,7 +215,7 @@ private
|
|
204
215
|
File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
|
205
216
|
end
|
206
217
|
|
207
|
-
# Load the
|
218
|
+
# Load the Thorfiles. If relevant_to is supplied, looks for specific files
|
208
219
|
# in the thor_root instead of loading them all.
|
209
220
|
#
|
210
221
|
# By default, it also traverses the current path until find Bundler::Thor files, as
|
@@ -217,11 +228,11 @@ private
|
|
217
228
|
end
|
218
229
|
end
|
219
230
|
|
220
|
-
# Finds
|
231
|
+
# Finds Thorfiles by traversing from your current directory down to the root
|
221
232
|
# directory of your system. If at any time we find a Bundler::Thor file, we stop.
|
222
233
|
#
|
223
|
-
# We also ensure that system-wide
|
224
|
-
#
|
234
|
+
# We also ensure that system-wide Thorfiles are loaded first, so local
|
235
|
+
# Thorfiles can override them.
|
225
236
|
#
|
226
237
|
# ==== Example
|
227
238
|
#
|
@@ -229,7 +240,7 @@ private
|
|
229
240
|
#
|
230
241
|
# 1. /Users/wycats/dev/thor
|
231
242
|
# 2. /Users/wycats/dev
|
232
|
-
# 3. /Users/wycats <-- we find a
|
243
|
+
# 3. /Users/wycats <-- we find a Thorfile here, so we stop
|
233
244
|
#
|
234
245
|
# Suppose we start at c:\Documents and Settings\james\dev\thor ...
|
235
246
|
#
|
@@ -237,7 +248,7 @@ private
|
|
237
248
|
# 2. c:\Documents and Settings\james\dev
|
238
249
|
# 3. c:\Documents and Settings\james
|
239
250
|
# 4. c:\Documents and Settings
|
240
|
-
# 5. c:\ <-- no
|
251
|
+
# 5. c:\ <-- no Thorfiles found!
|
241
252
|
#
|
242
253
|
def thorfiles(relevant_to = nil, skip_lookup = false)
|
243
254
|
thorfiles = []
|
@@ -258,7 +269,7 @@ private
|
|
258
269
|
end
|
259
270
|
end
|
260
271
|
|
261
|
-
# Load
|
272
|
+
# Load Thorfiles relevant to the given method. If you provide "foo:bar" it
|
262
273
|
# will load all thor files in the thor.yaml that has "foo" e "foo:bar"
|
263
274
|
# namespaces registered.
|
264
275
|
#
|
@@ -302,7 +313,7 @@ private
|
|
302
313
|
say shell.set_color(namespace, :blue, true)
|
303
314
|
say "-" * namespace.size
|
304
315
|
|
305
|
-
print_table(list, :
|
316
|
+
print_table(list, truncate: true)
|
306
317
|
say
|
307
318
|
end
|
308
319
|
alias_method :display_tasks, :display_commands
|
@@ -1,3 +1,7 @@
|
|
1
|
+
require_relative "column_printer"
|
2
|
+
require_relative "table_printer"
|
3
|
+
require_relative "wrapped_printer"
|
4
|
+
|
1
5
|
class Bundler::Thor
|
2
6
|
module Shell
|
3
7
|
class Basic
|
@@ -45,6 +49,10 @@ class Bundler::Thor
|
|
45
49
|
|
46
50
|
# Asks something to the user and receives a response.
|
47
51
|
#
|
52
|
+
# If a default value is specified it will be presented to the user
|
53
|
+
# and allows them to select that value with an empty response. This
|
54
|
+
# option is ignored when limited answers are supplied.
|
55
|
+
#
|
48
56
|
# If asked to limit the correct responses, you can pass in an
|
49
57
|
# array of acceptable answers. If one of those is not supplied,
|
50
58
|
# they will be shown a message stating that one of those answers
|
@@ -59,13 +67,15 @@ class Bundler::Thor
|
|
59
67
|
# Readline.
|
60
68
|
#
|
61
69
|
# ==== Example
|
62
|
-
#
|
70
|
+
# ask("What is your name?")
|
71
|
+
#
|
72
|
+
# ask("What is the planet furthest from the sun?", :default => "Neptune")
|
63
73
|
#
|
64
|
-
#
|
74
|
+
# ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
|
65
75
|
#
|
66
|
-
#
|
76
|
+
# ask("What is your password?", :echo => false)
|
67
77
|
#
|
68
|
-
#
|
78
|
+
# ask("Where should the file be saved?", :path => true)
|
69
79
|
#
|
70
80
|
def ask(statement, *args)
|
71
81
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -83,9 +93,11 @@ class Bundler::Thor
|
|
83
93
|
# are passed straight to puts (behavior got from Highline).
|
84
94
|
#
|
85
95
|
# ==== Example
|
86
|
-
#
|
96
|
+
# say("I know you knew that.")
|
87
97
|
#
|
88
98
|
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
99
|
+
return if quiet?
|
100
|
+
|
89
101
|
buffer = prepare_message(message, *color)
|
90
102
|
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
|
91
103
|
|
@@ -93,6 +105,23 @@ class Bundler::Thor
|
|
93
105
|
stdout.flush
|
94
106
|
end
|
95
107
|
|
108
|
+
# Say (print) an error to the user. If the sentence ends with a whitespace
|
109
|
+
# or tab character, a new line is not appended (print + flush). Otherwise
|
110
|
+
# are passed straight to puts (behavior got from Highline).
|
111
|
+
#
|
112
|
+
# ==== Example
|
113
|
+
# say_error("error: something went wrong")
|
114
|
+
#
|
115
|
+
def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
116
|
+
return if quiet?
|
117
|
+
|
118
|
+
buffer = prepare_message(message, *color)
|
119
|
+
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
|
120
|
+
|
121
|
+
stderr.print(buffer)
|
122
|
+
stderr.flush
|
123
|
+
end
|
124
|
+
|
96
125
|
# Say a status with the given color and appends the message. Since this
|
97
126
|
# method is used frequently by actions, it allows nil or false to be given
|
98
127
|
# in log_status, avoiding the message from being shown. If a Symbol is
|
@@ -101,30 +130,31 @@ class Bundler::Thor
|
|
101
130
|
def say_status(status, message, log_status = true)
|
102
131
|
return if quiet? || log_status == false
|
103
132
|
spaces = " " * (padding + 1)
|
104
|
-
color = log_status.is_a?(Symbol) ? log_status : :green
|
105
|
-
|
106
133
|
status = status.to_s.rjust(12)
|
134
|
+
margin = " " * status.length + spaces
|
135
|
+
|
136
|
+
color = log_status.is_a?(Symbol) ? log_status : :green
|
107
137
|
status = set_color status, color, true if color
|
108
138
|
|
109
|
-
|
110
|
-
buffer = "#{
|
139
|
+
message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
|
140
|
+
buffer = "#{status}#{spaces}#{message}\n"
|
111
141
|
|
112
142
|
stdout.print(buffer)
|
113
143
|
stdout.flush
|
114
144
|
end
|
115
145
|
|
116
|
-
#
|
146
|
+
# Asks the user a question and returns true if the user replies "y" or
|
117
147
|
# "yes".
|
118
148
|
#
|
119
149
|
def yes?(statement, color = nil)
|
120
|
-
!!(ask(statement, color, :
|
150
|
+
!!(ask(statement, color, add_to_history: false) =~ is?(:yes))
|
121
151
|
end
|
122
152
|
|
123
|
-
#
|
153
|
+
# Asks the user a question and returns true if the user replies "n" or
|
124
154
|
# "no".
|
125
155
|
#
|
126
156
|
def no?(statement, color = nil)
|
127
|
-
!!(ask(statement, color, :
|
157
|
+
!!(ask(statement, color, add_to_history: false) =~ is?(:no))
|
128
158
|
end
|
129
159
|
|
130
160
|
# Prints values in columns
|
@@ -133,16 +163,8 @@ class Bundler::Thor
|
|
133
163
|
# Array[String, String, ...]
|
134
164
|
#
|
135
165
|
def print_in_columns(array)
|
136
|
-
|
137
|
-
|
138
|
-
array.each_with_index do |value, index|
|
139
|
-
# Don't output trailing spaces when printing the last column
|
140
|
-
if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
|
141
|
-
stdout.puts value
|
142
|
-
else
|
143
|
-
stdout.printf("%-#{colwidth}s", value)
|
144
|
-
end
|
145
|
-
end
|
166
|
+
printer = ColumnPrinter.new(stdout)
|
167
|
+
printer.print(array)
|
146
168
|
end
|
147
169
|
|
148
170
|
# Prints a table.
|
@@ -153,58 +175,11 @@ class Bundler::Thor
|
|
153
175
|
# ==== Options
|
154
176
|
# indent<Integer>:: Indent the first column by indent value.
|
155
177
|
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
|
178
|
+
# borders<Boolean>:: Adds ascii borders.
|
156
179
|
#
|
157
|
-
def print_table(array, options = {}) # rubocop:disable MethodLength
|
158
|
-
|
159
|
-
|
160
|
-
formats = []
|
161
|
-
indent = options[:indent].to_i
|
162
|
-
colwidth = options[:colwidth]
|
163
|
-
options[:truncate] = terminal_width if options[:truncate] == true
|
164
|
-
|
165
|
-
formats << "%-#{colwidth + 2}s".dup if colwidth
|
166
|
-
start = colwidth ? 1 : 0
|
167
|
-
|
168
|
-
colcount = array.max { |a, b| a.size <=> b.size }.size
|
169
|
-
|
170
|
-
maximas = []
|
171
|
-
|
172
|
-
start.upto(colcount - 1) do |index|
|
173
|
-
maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
|
174
|
-
maximas << maxima
|
175
|
-
formats << if index == colcount - 1
|
176
|
-
# Don't output 2 trailing spaces when printing the last column
|
177
|
-
"%-s".dup
|
178
|
-
else
|
179
|
-
"%-#{maxima + 2}s".dup
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
formats[0] = formats[0].insert(0, " " * indent)
|
184
|
-
formats << "%s"
|
185
|
-
|
186
|
-
array.each do |row|
|
187
|
-
sentence = "".dup
|
188
|
-
|
189
|
-
row.each_with_index do |column, index|
|
190
|
-
maxima = maximas[index]
|
191
|
-
|
192
|
-
f = if column.is_a?(Numeric)
|
193
|
-
if index == row.size - 1
|
194
|
-
# Don't output 2 trailing spaces when printing the last column
|
195
|
-
"%#{maxima}s"
|
196
|
-
else
|
197
|
-
"%#{maxima}s "
|
198
|
-
end
|
199
|
-
else
|
200
|
-
formats[index]
|
201
|
-
end
|
202
|
-
sentence << f % column.to_s
|
203
|
-
end
|
204
|
-
|
205
|
-
sentence = truncate(sentence, options[:truncate]) if options[:truncate]
|
206
|
-
stdout.puts sentence
|
207
|
-
end
|
180
|
+
def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
|
181
|
+
printer = TablePrinter.new(stdout, options)
|
182
|
+
printer.print(array)
|
208
183
|
end
|
209
184
|
|
210
185
|
# Prints a long string, word-wrapping the text to the current width of the
|
@@ -217,20 +192,8 @@ class Bundler::Thor
|
|
217
192
|
# indent<Integer>:: Indent each line of the printed paragraph by indent value.
|
218
193
|
#
|
219
194
|
def print_wrapped(message, options = {})
|
220
|
-
|
221
|
-
|
222
|
-
paras = message.split("\n\n")
|
223
|
-
|
224
|
-
paras.map! do |unwrapped|
|
225
|
-
unwrapped.strip.tr("\n", " ").squeeze(" ").gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
|
226
|
-
end
|
227
|
-
|
228
|
-
paras.each do |para|
|
229
|
-
para.split("\n").each do |line|
|
230
|
-
stdout.puts line.insert(0, " " * indent)
|
231
|
-
end
|
232
|
-
stdout.puts unless para == paras.last
|
233
|
-
end
|
195
|
+
printer = WrappedPrinter.new(stdout, options)
|
196
|
+
printer.print(message)
|
234
197
|
end
|
235
198
|
|
236
199
|
# Deals with file collision and returns true if the file should be
|
@@ -239,16 +202,16 @@ class Bundler::Thor
|
|
239
202
|
#
|
240
203
|
# ==== Parameters
|
241
204
|
# destination<String>:: the destination file to solve conflicts
|
242
|
-
# block<Proc>:: an optional block that returns the value to be used in diff
|
205
|
+
# block<Proc>:: an optional block that returns the value to be used in diff and merge
|
243
206
|
#
|
244
207
|
def file_collision(destination)
|
245
208
|
return true if @always_force
|
246
|
-
options = block_given? ? "[
|
209
|
+
options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"
|
247
210
|
|
248
211
|
loop do
|
249
212
|
answer = ask(
|
250
213
|
%[Overwrite #{destination}? (enter "h" for help) #{options}],
|
251
|
-
:
|
214
|
+
add_to_history: false
|
252
215
|
)
|
253
216
|
|
254
217
|
case answer
|
@@ -267,25 +230,19 @@ class Bundler::Thor
|
|
267
230
|
when is?(:diff)
|
268
231
|
show_diff(destination, yield) if block_given?
|
269
232
|
say "Retrying..."
|
233
|
+
when is?(:merge)
|
234
|
+
if block_given? && !merge_tool.empty?
|
235
|
+
merge(destination, yield)
|
236
|
+
return nil
|
237
|
+
end
|
238
|
+
|
239
|
+
say "Please specify merge tool to `THOR_MERGE` env."
|
270
240
|
else
|
271
|
-
say file_collision_help
|
241
|
+
say file_collision_help(block_given?)
|
272
242
|
end
|
273
243
|
end
|
274
244
|
end
|
275
245
|
|
276
|
-
# This code was copied from Rake, available under MIT-LICENSE
|
277
|
-
# Copyright (c) 2003, 2004 Jim Weirich
|
278
|
-
def terminal_width
|
279
|
-
result = if ENV["THOR_COLUMNS"]
|
280
|
-
ENV["THOR_COLUMNS"].to_i
|
281
|
-
else
|
282
|
-
unix? ? dynamic_width : 80
|
283
|
-
end
|
284
|
-
result < 10 ? 80 : result
|
285
|
-
rescue
|
286
|
-
80
|
287
|
-
end
|
288
|
-
|
289
246
|
# Called if something goes wrong during the execution. This is used by Bundler::Thor
|
290
247
|
# internally and should not be used inside your scripts. If something went
|
291
248
|
# wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
|
@@ -336,15 +293,21 @@ class Bundler::Thor
|
|
336
293
|
end
|
337
294
|
end
|
338
295
|
|
339
|
-
def file_collision_help #:nodoc:
|
340
|
-
<<-HELP
|
296
|
+
def file_collision_help(block_given) #:nodoc:
|
297
|
+
help = <<-HELP
|
341
298
|
Y - yes, overwrite
|
342
299
|
n - no, do not overwrite
|
343
300
|
a - all, overwrite this and all others
|
344
301
|
q - quit, abort
|
345
|
-
d - diff, show the differences between the old and the new
|
346
302
|
h - help, show this help
|
347
303
|
HELP
|
304
|
+
if block_given
|
305
|
+
help << <<-HELP
|
306
|
+
d - diff, show the differences between the old and the new
|
307
|
+
m - merge, run merge tool
|
308
|
+
HELP
|
309
|
+
end
|
310
|
+
help
|
348
311
|
end
|
349
312
|
|
350
313
|
def show_diff(destination, content) #:nodoc:
|
@@ -362,46 +325,8 @@ class Bundler::Thor
|
|
362
325
|
mute? || (base && base.options[:quiet])
|
363
326
|
end
|
364
327
|
|
365
|
-
# Calculate the dynamic width of the terminal
|
366
|
-
def dynamic_width
|
367
|
-
@dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
|
368
|
-
end
|
369
|
-
|
370
|
-
def dynamic_width_stty
|
371
|
-
`stty size 2>/dev/null`.split[1].to_i
|
372
|
-
end
|
373
|
-
|
374
|
-
def dynamic_width_tput
|
375
|
-
`tput cols 2>/dev/null`.to_i
|
376
|
-
end
|
377
|
-
|
378
328
|
def unix?
|
379
|
-
|
380
|
-
end
|
381
|
-
|
382
|
-
def truncate(string, width)
|
383
|
-
as_unicode do
|
384
|
-
chars = string.chars.to_a
|
385
|
-
if chars.length <= width
|
386
|
-
chars.join
|
387
|
-
else
|
388
|
-
chars[0, width - 3].join + "..."
|
389
|
-
end
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
if "".respond_to?(:encode)
|
394
|
-
def as_unicode
|
395
|
-
yield
|
396
|
-
end
|
397
|
-
else
|
398
|
-
def as_unicode
|
399
|
-
old = $KCODE
|
400
|
-
$KCODE = "U"
|
401
|
-
yield
|
402
|
-
ensure
|
403
|
-
$KCODE = old
|
404
|
-
end
|
329
|
+
Terminal.unix?
|
405
330
|
end
|
406
331
|
|
407
332
|
def ask_simply(statement, color, options)
|
@@ -423,15 +348,41 @@ class Bundler::Thor
|
|
423
348
|
|
424
349
|
def ask_filtered(statement, color, options)
|
425
350
|
answer_set = options[:limited_to]
|
351
|
+
case_insensitive = options.fetch(:case_insensitive, false)
|
426
352
|
correct_answer = nil
|
427
353
|
until correct_answer
|
428
354
|
answers = answer_set.join(", ")
|
429
355
|
answer = ask_simply("#{statement} [#{answers}]", color, options)
|
430
|
-
correct_answer = answer_set
|
356
|
+
correct_answer = answer_match(answer_set, answer, case_insensitive)
|
431
357
|
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
|
432
358
|
end
|
433
359
|
correct_answer
|
434
360
|
end
|
361
|
+
|
362
|
+
def answer_match(possibilities, answer, case_insensitive)
|
363
|
+
if case_insensitive
|
364
|
+
possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
|
365
|
+
else
|
366
|
+
possibilities.detect{ |possibility| possibility == answer }
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
def merge(destination, content) #:nodoc:
|
371
|
+
require "tempfile"
|
372
|
+
Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
|
373
|
+
temp.write content
|
374
|
+
temp.rewind
|
375
|
+
system %(#{merge_tool} "#{temp.path}" "#{destination}")
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def merge_tool #:nodoc:
|
380
|
+
@merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
|
381
|
+
end
|
382
|
+
|
383
|
+
def git_merge_tool #:nodoc:
|
384
|
+
`git config merge.tool`.rstrip rescue ""
|
385
|
+
end
|
435
386
|
end
|
436
387
|
end
|
437
388
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "basic"
|
2
2
|
|
3
3
|
class Bundler::Thor
|
4
4
|
module Shell
|
@@ -97,52 +97,15 @@ class Bundler::Thor
|
|
97
97
|
protected
|
98
98
|
|
99
99
|
def can_display_colors?
|
100
|
-
|
100
|
+
are_colors_supported? && !are_colors_disabled?
|
101
101
|
end
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
#
|
106
|
-
def show_diff(destination, content) #:nodoc:
|
107
|
-
if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
|
108
|
-
actual = File.binread(destination).to_s.split("\n")
|
109
|
-
content = content.to_s.split("\n")
|
110
|
-
|
111
|
-
Diff::LCS.sdiff(actual, content).each do |diff|
|
112
|
-
output_diff_line(diff)
|
113
|
-
end
|
114
|
-
else
|
115
|
-
super
|
116
|
-
end
|
103
|
+
def are_colors_supported?
|
104
|
+
stdout.tty? && ENV["TERM"] != "dumb"
|
117
105
|
end
|
118
106
|
|
119
|
-
def
|
120
|
-
|
121
|
-
when "-"
|
122
|
-
say "- #{diff.old_element.chomp}", :red, true
|
123
|
-
when "+"
|
124
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
125
|
-
when "!"
|
126
|
-
say "- #{diff.old_element.chomp}", :red, true
|
127
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
128
|
-
else
|
129
|
-
say " #{diff.old_element.chomp}", nil, true
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# Check if Diff::LCS is loaded. If it is, use it to create pretty output
|
134
|
-
# for diff.
|
135
|
-
#
|
136
|
-
def diff_lcs_loaded? #:nodoc:
|
137
|
-
return true if defined?(Diff::LCS)
|
138
|
-
return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
|
139
|
-
|
140
|
-
@diff_lcs_loaded = begin
|
141
|
-
require "diff/lcs"
|
142
|
-
true
|
143
|
-
rescue LoadError
|
144
|
-
false
|
145
|
-
end
|
107
|
+
def are_colors_disabled?
|
108
|
+
!ENV["NO_COLOR"].nil? && !ENV["NO_COLOR"].empty?
|
146
109
|
end
|
147
110
|
end
|
148
111
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "terminal"
|
2
|
+
|
3
|
+
class Bundler::Thor
|
4
|
+
module Shell
|
5
|
+
class ColumnPrinter
|
6
|
+
attr_reader :stdout, :options
|
7
|
+
|
8
|
+
def initialize(stdout, options = {})
|
9
|
+
@stdout = stdout
|
10
|
+
@options = options
|
11
|
+
@indent = options[:indent].to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def print(array)
|
15
|
+
return if array.empty?
|
16
|
+
colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
|
17
|
+
array.each_with_index do |value, index|
|
18
|
+
# Don't output trailing spaces when printing the last column
|
19
|
+
if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
|
20
|
+
stdout.puts value
|
21
|
+
else
|
22
|
+
stdout.printf("%-#{colwidth}s", value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|