bundler-plus 4.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5670 -0
- data/LICENSE.md +22 -0
- data/README.md +58 -0
- data/bundler.gemspec +46 -0
- data/exe/bundle +29 -0
- data/exe/bundler +4 -0
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +44 -0
- data/lib/bundler/capistrano.rb +4 -0
- data/lib/bundler/checksum.rb +270 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +62 -0
- data/lib/bundler/cli/binstubs.rb +57 -0
- data/lib/bundler/cli/cache.rb +32 -0
- data/lib/bundler/cli/check.rb +40 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +161 -0
- data/lib/bundler/cli/config.rb +208 -0
- data/lib/bundler/cli/console.rb +47 -0
- data/lib/bundler/cli/doctor/diagnose.rb +167 -0
- data/lib/bundler/cli/doctor/ssl.rb +249 -0
- data/lib/bundler/cli/doctor.rb +33 -0
- data/lib/bundler/cli/exec.rb +114 -0
- data/lib/bundler/cli/fund.rb +36 -0
- data/lib/bundler/cli/gem.rb +493 -0
- data/lib/bundler/cli/info.rb +83 -0
- data/lib/bundler/cli/init.rb +51 -0
- data/lib/bundler/cli/install.rb +127 -0
- data/lib/bundler/cli/issue.rb +41 -0
- data/lib/bundler/cli/list.rb +97 -0
- data/lib/bundler/cli/lock.rb +94 -0
- data/lib/bundler/cli/open.rb +29 -0
- data/lib/bundler/cli/outdated.rb +337 -0
- data/lib/bundler/cli/platform.rb +48 -0
- data/lib/bundler/cli/plugin.rb +39 -0
- data/lib/bundler/cli/pristine.rb +64 -0
- data/lib/bundler/cli/remove.rb +17 -0
- data/lib/bundler/cli/show.rb +71 -0
- data/lib/bundler/cli/update.rb +125 -0
- data/lib/bundler/cli.rb +829 -0
- data/lib/bundler/compact_index_client/cache.rb +96 -0
- data/lib/bundler/compact_index_client/cache_file.rb +148 -0
- data/lib/bundler/compact_index_client/parser.rb +87 -0
- data/lib/bundler/compact_index_client/updater.rb +105 -0
- data/lib/bundler/compact_index_client.rb +92 -0
- data/lib/bundler/constants.rb +14 -0
- data/lib/bundler/current_ruby.rb +94 -0
- data/lib/bundler/definition.rb +1304 -0
- data/lib/bundler/dependency.rb +151 -0
- data/lib/bundler/deployment.rb +6 -0
- data/lib/bundler/deprecate.rb +44 -0
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +642 -0
- data/lib/bundler/endpoint_specification.rb +184 -0
- data/lib/bundler/env.rb +148 -0
- data/lib/bundler/environment_preserver.rb +69 -0
- data/lib/bundler/errors.rb +277 -0
- data/lib/bundler/feature_flag.rb +20 -0
- data/lib/bundler/fetcher/base.rb +55 -0
- data/lib/bundler/fetcher/compact_index.rb +133 -0
- data/lib/bundler/fetcher/dependency.rb +85 -0
- data/lib/bundler/fetcher/downloader.rb +116 -0
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +24 -0
- data/lib/bundler/fetcher/index.rb +25 -0
- data/lib/bundler/fetcher.rb +365 -0
- data/lib/bundler/force_platform.rb +16 -0
- data/lib/bundler/friendly_errors.rb +127 -0
- data/lib/bundler/gem_helper.rb +237 -0
- data/lib/bundler/gem_tasks.rb +7 -0
- data/lib/bundler/gem_version_promoter.rb +147 -0
- data/lib/bundler/index.rb +203 -0
- data/lib/bundler/injector.rb +284 -0
- data/lib/bundler/inline.rb +106 -0
- data/lib/bundler/installer/gem_installer.rb +88 -0
- data/lib/bundler/installer/parallel_installer.rb +280 -0
- data/lib/bundler/installer/standalone.rb +113 -0
- data/lib/bundler/installer.rb +241 -0
- data/lib/bundler/lazy_specification.rb +270 -0
- data/lib/bundler/lockfile_generator.rb +119 -0
- data/lib/bundler/lockfile_parser.rb +328 -0
- data/lib/bundler/man/.document +1 -0
- data/lib/bundler/man/bundle-add.1 +79 -0
- data/lib/bundler/man/bundle-add.1.ronn +92 -0
- data/lib/bundler/man/bundle-binstubs.1 +30 -0
- data/lib/bundler/man/bundle-binstubs.1.ronn +42 -0
- data/lib/bundler/man/bundle-cache.1 +56 -0
- data/lib/bundler/man/bundle-cache.1.ronn +95 -0
- data/lib/bundler/man/bundle-check.1 +21 -0
- data/lib/bundler/man/bundle-check.1.ronn +26 -0
- data/lib/bundler/man/bundle-clean.1 +17 -0
- data/lib/bundler/man/bundle-clean.1.ronn +18 -0
- data/lib/bundler/man/bundle-config.1 +339 -0
- data/lib/bundler/man/bundle-config.1.ronn +455 -0
- data/lib/bundler/man/bundle-console.1 +33 -0
- data/lib/bundler/man/bundle-console.1.ronn +39 -0
- data/lib/bundler/man/bundle-doctor.1 +69 -0
- data/lib/bundler/man/bundle-doctor.1.ronn +77 -0
- data/lib/bundler/man/bundle-env.1 +9 -0
- data/lib/bundler/man/bundle-env.1.ronn +10 -0
- data/lib/bundler/man/bundle-exec.1 +104 -0
- data/lib/bundler/man/bundle-exec.1.ronn +150 -0
- 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 +107 -0
- data/lib/bundler/man/bundle-gem.1.ronn +150 -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/lib/bundler/man/bundle-init.1 +20 -0
- data/lib/bundler/man/bundle-init.1.ronn +32 -0
- data/lib/bundler/man/bundle-install.1 +178 -0
- data/lib/bundler/man/bundle-install.1.ronn +314 -0
- 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/lib/bundler/man/bundle-list.1 +40 -0
- data/lib/bundler/man/bundle-list.1.ronn +41 -0
- data/lib/bundler/man/bundle-lock.1 +75 -0
- data/lib/bundler/man/bundle-lock.1.ronn +115 -0
- data/lib/bundler/man/bundle-open.1 +32 -0
- data/lib/bundler/man/bundle-open.1.ronn +28 -0
- data/lib/bundler/man/bundle-outdated.1 +106 -0
- data/lib/bundler/man/bundle-outdated.1.ronn +117 -0
- data/lib/bundler/man/bundle-platform.1 +49 -0
- data/lib/bundler/man/bundle-platform.1.ronn +49 -0
- data/lib/bundler/man/bundle-plugin.1 +76 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +84 -0
- data/lib/bundler/man/bundle-pristine.1 +23 -0
- data/lib/bundler/man/bundle-pristine.1.ronn +34 -0
- data/lib/bundler/man/bundle-remove.1 +15 -0
- data/lib/bundler/man/bundle-remove.1.ronn +16 -0
- data/lib/bundler/man/bundle-show.1 +16 -0
- data/lib/bundler/man/bundle-show.1.ronn +21 -0
- data/lib/bundler/man/bundle-update.1 +284 -0
- data/lib/bundler/man/bundle-update.1.ronn +367 -0
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/lib/bundler/man/bundle.1 +93 -0
- data/lib/bundler/man/bundle.1.ronn +107 -0
- data/lib/bundler/man/gemfile.5 +503 -0
- data/lib/bundler/man/gemfile.5.ronn +586 -0
- data/lib/bundler/man/index.txt +31 -0
- data/lib/bundler/match_metadata.rb +30 -0
- data/lib/bundler/match_platform.rb +42 -0
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/materialization.rb +59 -0
- data/lib/bundler/mirror.rb +221 -0
- data/lib/bundler/plugin/api/source.rb +330 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +85 -0
- data/lib/bundler/plugin/index.rb +203 -0
- data/lib/bundler/plugin/installer/git.rb +34 -0
- data/lib/bundler/plugin/installer/path.rb +26 -0
- data/lib/bundler/plugin/installer/rubygems.rb +19 -0
- data/lib/bundler/plugin/installer.rb +123 -0
- data/lib/bundler/plugin/source_list.rb +31 -0
- data/lib/bundler/plugin/unloaded_source.rb +25 -0
- data/lib/bundler/plugin.rb +387 -0
- data/lib/bundler/process_lock.rb +20 -0
- data/lib/bundler/remote_specification.rb +126 -0
- data/lib/bundler/resolver/base.rb +127 -0
- data/lib/bundler/resolver/candidate.rb +85 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +95 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +74 -0
- data/lib/bundler/resolver/strategy.rb +43 -0
- data/lib/bundler/resolver.rb +603 -0
- data/lib/bundler/retry.rb +92 -0
- data/lib/bundler/ruby_dsl.rb +67 -0
- data/lib/bundler/ruby_version.rb +135 -0
- data/lib/bundler/rubygems_ext.rb +503 -0
- data/lib/bundler/rubygems_gem_installer.rb +206 -0
- data/lib/bundler/rubygems_integration.rb +456 -0
- data/lib/bundler/runtime.rb +331 -0
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +197 -0
- data/lib/bundler/settings/validator.rb +86 -0
- data/lib/bundler/settings.rb +585 -0
- data/lib/bundler/setup.rb +39 -0
- data/lib/bundler/shared_helpers.rb +392 -0
- data/lib/bundler/source/gemspec.rb +19 -0
- data/lib/bundler/source/git/git_proxy.rb +509 -0
- data/lib/bundler/source/git.rb +451 -0
- data/lib/bundler/source/metadata.rb +67 -0
- data/lib/bundler/source/path/installer.rb +53 -0
- data/lib/bundler/source/path.rb +256 -0
- data/lib/bundler/source/rubygems/remote.rb +86 -0
- data/lib/bundler/source/rubygems.rb +606 -0
- data/lib/bundler/source/rubygems_aggregate.rb +71 -0
- data/lib/bundler/source.rb +120 -0
- data/lib/bundler/source_list.rb +240 -0
- data/lib/bundler/source_map.rb +72 -0
- data/lib/bundler/spec_set.rb +390 -0
- data/lib/bundler/stub_specification.rb +147 -0
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +14 -0
- data/lib/bundler/templates/Gemfile +5 -0
- data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +10 -0
- data/lib/bundler/templates/newgem/Cargo.toml.tt +13 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +24 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +49 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +72 -0
- data/lib/bundler/templates/newgem/bin/console.tt +11 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +37 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +22 -0
- data/lib/bundler/templates/newgem/ext/newgem/build.rs.tt +5 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +23 -0
- data/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt +69 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +48 -0
- data/lib/bundler/templates/newgem/gitignore.tt +23 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +27 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +15 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +58 -0
- data/lib/bundler/templates/newgem/rspec.tt +3 -0
- 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 +19 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -0
- 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/minitest/test_newgem.rb.tt +19 -0
- 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 +19 -0
- data/lib/bundler/ui/shell.rb +191 -0
- data/lib/bundler/ui/silent.rb +96 -0
- data/lib/bundler/ui.rb +9 -0
- data/lib/bundler/uri_credentials_filter.rb +43 -0
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +227 -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 +230 -0
- data/lib/bundler/vendor/fileutils/COPYING +56 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +2701 -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 +80 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1153 -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 +169 -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/strategy.rb +42 -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 +423 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +236 -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/COPYING +56 -0
- data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +105 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +61 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +108 -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 +407 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +130 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +340 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +825 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +151 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +107 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +106 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +292 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -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/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +86 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +195 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +178 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +294 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +72 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +335 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +384 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +112 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +81 -0
- 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 +81 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +285 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +674 -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/COPYING +56 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +922 -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 +1592 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +137 -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 +547 -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 +4 -0
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +11 -0
- data/lib/bundler/vendored_pub_grub.rb +4 -0
- data/lib/bundler/vendored_securerandom.rb +12 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- 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 +21 -0
- data/lib/bundler/vlad.rb +4 -0
- data/lib/bundler/worker.rb +125 -0
- data/lib/bundler/yaml_serializer.rb +98 -0
- data/lib/bundler.rb +691 -0
- metadata +409 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
require_relative "../thor"
|
|
2
|
+
require_relative "group"
|
|
3
|
+
|
|
4
|
+
require "digest/sha2"
|
|
5
|
+
require "pathname" unless defined?(Pathname)
|
|
6
|
+
|
|
7
|
+
class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
|
|
8
|
+
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|
|
9
|
+
|
|
10
|
+
def self.banner(command, all = false, subcommand = false)
|
|
11
|
+
"thor " + command.formatted_usage(self, all, subcommand)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.exit_on_failure?
|
|
15
|
+
true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Override Bundler::Thor#help so it can give information about any class and any method.
|
|
19
|
+
#
|
|
20
|
+
def help(meth = nil)
|
|
21
|
+
if meth && !respond_to?(meth)
|
|
22
|
+
initialize_thorfiles(meth)
|
|
23
|
+
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
|
|
24
|
+
self.class.handle_no_command_error(command, false) if klass.nil?
|
|
25
|
+
klass.start(["-h", command].compact, shell: shell)
|
|
26
|
+
else
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# If a command is not found on Bundler::Thor::Runner, method missing is invoked and
|
|
32
|
+
# Bundler::Thor::Runner is then responsible for finding the command in all classes.
|
|
33
|
+
#
|
|
34
|
+
def method_missing(meth, *args)
|
|
35
|
+
meth = meth.to_s
|
|
36
|
+
initialize_thorfiles(meth)
|
|
37
|
+
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
|
|
38
|
+
self.class.handle_no_command_error(command, false) if klass.nil?
|
|
39
|
+
args.unshift(command) if command
|
|
40
|
+
klass.start(args, shell: shell)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
|
|
44
|
+
method_options as: :string, relative: :boolean, force: :boolean
|
|
45
|
+
def install(name) # rubocop:disable Metrics/MethodLength
|
|
46
|
+
initialize_thorfiles
|
|
47
|
+
|
|
48
|
+
is_uri = name =~ %r{^https?\://}
|
|
49
|
+
|
|
50
|
+
if is_uri
|
|
51
|
+
base = name
|
|
52
|
+
package = :file
|
|
53
|
+
require "open-uri"
|
|
54
|
+
begin
|
|
55
|
+
contents = URI.open(name, &:read)
|
|
56
|
+
rescue OpenURI::HTTPError
|
|
57
|
+
raise Error, "Error opening URI '#{name}'"
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
# If a directory name is provided as the argument, look for a 'main.thor'
|
|
61
|
+
# command in said directory.
|
|
62
|
+
begin
|
|
63
|
+
if File.directory?(File.expand_path(name))
|
|
64
|
+
base = File.join(name, "main.thor")
|
|
65
|
+
package = :directory
|
|
66
|
+
contents = File.open(base, &:read)
|
|
67
|
+
else
|
|
68
|
+
base = name
|
|
69
|
+
package = :file
|
|
70
|
+
require "open-uri"
|
|
71
|
+
contents = URI.open(name, &:read)
|
|
72
|
+
end
|
|
73
|
+
rescue Errno::ENOENT
|
|
74
|
+
raise Error, "Error opening file '#{name}'"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
say "Your Thorfile contains:"
|
|
79
|
+
say contents
|
|
80
|
+
|
|
81
|
+
unless options["force"]
|
|
82
|
+
return false if no?("Do you wish to continue [y/N]?")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
as = options["as"] || begin
|
|
86
|
+
first_line = contents.split("\n")[0]
|
|
87
|
+
(match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
unless as
|
|
91
|
+
basename = File.basename(name)
|
|
92
|
+
as = ask("Please specify a name for #{name} in the system repository [#{basename}]:")
|
|
93
|
+
as = basename if as.empty?
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
location = if options[:relative] || is_uri
|
|
97
|
+
name
|
|
98
|
+
else
|
|
99
|
+
File.expand_path(name)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
thor_yaml[as] = {
|
|
103
|
+
filename: Digest::SHA256.hexdigest(name + as),
|
|
104
|
+
location: location,
|
|
105
|
+
namespaces: Bundler::Thor::Util.namespaces_in_content(contents, base)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
save_yaml(thor_yaml)
|
|
109
|
+
say "Storing thor file in your system repository"
|
|
110
|
+
destination = File.join(thor_root, thor_yaml[as][:filename])
|
|
111
|
+
|
|
112
|
+
if package == :file
|
|
113
|
+
File.open(destination, "w") { |f| f.puts contents }
|
|
114
|
+
else
|
|
115
|
+
require "fileutils"
|
|
116
|
+
FileUtils.cp_r(name, destination)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
thor_yaml[as][:filename] # Indicate success
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
desc "version", "Show Bundler::Thor version"
|
|
123
|
+
def version
|
|
124
|
+
require_relative "version"
|
|
125
|
+
say "Bundler::Thor #{Bundler::Thor::VERSION}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
desc "uninstall NAME", "Uninstall a named Bundler::Thor module"
|
|
129
|
+
def uninstall(name)
|
|
130
|
+
raise Error, "Can't find module '#{name}'" unless thor_yaml[name]
|
|
131
|
+
say "Uninstalling #{name}."
|
|
132
|
+
require "fileutils"
|
|
133
|
+
FileUtils.rm_rf(File.join(thor_root, (thor_yaml[name][:filename]).to_s))
|
|
134
|
+
|
|
135
|
+
thor_yaml.delete(name)
|
|
136
|
+
save_yaml(thor_yaml)
|
|
137
|
+
|
|
138
|
+
puts "Done."
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
desc "update NAME", "Update a Bundler::Thor file from its original location"
|
|
142
|
+
def update(name)
|
|
143
|
+
raise Error, "Can't find module '#{name}'" if !thor_yaml[name] || !thor_yaml[name][:location]
|
|
144
|
+
|
|
145
|
+
say "Updating '#{name}' from #{thor_yaml[name][:location]}"
|
|
146
|
+
|
|
147
|
+
old_filename = thor_yaml[name][:filename]
|
|
148
|
+
self.options = options.merge("as" => name)
|
|
149
|
+
|
|
150
|
+
if File.directory? File.expand_path(name)
|
|
151
|
+
require "fileutils"
|
|
152
|
+
FileUtils.rm_rf(File.join(thor_root, old_filename))
|
|
153
|
+
|
|
154
|
+
thor_yaml.delete(old_filename)
|
|
155
|
+
save_yaml(thor_yaml)
|
|
156
|
+
|
|
157
|
+
filename = install(name)
|
|
158
|
+
else
|
|
159
|
+
filename = install(thor_yaml[name][:location])
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
File.delete(File.join(thor_root, old_filename)) unless filename == old_filename
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
desc "installed", "List the installed Bundler::Thor modules and commands"
|
|
166
|
+
method_options internal: :boolean
|
|
167
|
+
def installed
|
|
168
|
+
initialize_thorfiles(nil, true)
|
|
169
|
+
display_klasses(true, options["internal"])
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
|
|
173
|
+
method_options substring: :boolean, group: :string, all: :boolean, debug: :boolean
|
|
174
|
+
def list(search = "")
|
|
175
|
+
initialize_thorfiles
|
|
176
|
+
|
|
177
|
+
search = ".*#{search}" if options["substring"]
|
|
178
|
+
search = /^#{search}.*/i
|
|
179
|
+
group = options[:group] || "standard"
|
|
180
|
+
|
|
181
|
+
klasses = Bundler::Thor::Base.subclasses.select do |k|
|
|
182
|
+
(options[:all] || k.group == group) && k.namespace =~ search
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
display_klasses(false, false, klasses)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
private
|
|
189
|
+
|
|
190
|
+
def thor_root
|
|
191
|
+
Bundler::Thor::Util.thor_root
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def thor_yaml
|
|
195
|
+
@thor_yaml ||= begin
|
|
196
|
+
yaml_file = File.join(thor_root, "thor.yml")
|
|
197
|
+
require "yaml"
|
|
198
|
+
yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)
|
|
199
|
+
yaml || {}
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Save the yaml file. If none exists in thor root, creates one.
|
|
204
|
+
#
|
|
205
|
+
def save_yaml(yaml)
|
|
206
|
+
yaml_file = File.join(thor_root, "thor.yml")
|
|
207
|
+
|
|
208
|
+
unless File.exist?(yaml_file)
|
|
209
|
+
require "fileutils"
|
|
210
|
+
FileUtils.mkdir_p(thor_root)
|
|
211
|
+
yaml_file = File.join(thor_root, "thor.yml")
|
|
212
|
+
FileUtils.touch(yaml_file)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Load the Thorfiles. If relevant_to is supplied, looks for specific files
|
|
219
|
+
# in the thor_root instead of loading them all.
|
|
220
|
+
#
|
|
221
|
+
# By default, it also traverses the current path until find Bundler::Thor files, as
|
|
222
|
+
# described in thorfiles. This look up can be skipped by supplying
|
|
223
|
+
# skip_lookup true.
|
|
224
|
+
#
|
|
225
|
+
def initialize_thorfiles(relevant_to = nil, skip_lookup = false)
|
|
226
|
+
thorfiles(relevant_to, skip_lookup).each do |f|
|
|
227
|
+
Bundler::Thor::Util.load_thorfile(f, nil, options[:debug]) unless Bundler::Thor::Base.subclass_files.keys.include?(File.expand_path(f))
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# Finds Thorfiles by traversing from your current directory down to the root
|
|
232
|
+
# directory of your system. If at any time we find a Bundler::Thor file, we stop.
|
|
233
|
+
#
|
|
234
|
+
# We also ensure that system-wide Thorfiles are loaded first, so local
|
|
235
|
+
# Thorfiles can override them.
|
|
236
|
+
#
|
|
237
|
+
# ==== Example
|
|
238
|
+
#
|
|
239
|
+
# If we start at /Users/wycats/dev/thor ...
|
|
240
|
+
#
|
|
241
|
+
# 1. /Users/wycats/dev/thor
|
|
242
|
+
# 2. /Users/wycats/dev
|
|
243
|
+
# 3. /Users/wycats <-- we find a Thorfile here, so we stop
|
|
244
|
+
#
|
|
245
|
+
# Suppose we start at c:\Documents and Settings\james\dev\thor ...
|
|
246
|
+
#
|
|
247
|
+
# 1. c:\Documents and Settings\james\dev\thor
|
|
248
|
+
# 2. c:\Documents and Settings\james\dev
|
|
249
|
+
# 3. c:\Documents and Settings\james
|
|
250
|
+
# 4. c:\Documents and Settings
|
|
251
|
+
# 5. c:\ <-- no Thorfiles found!
|
|
252
|
+
#
|
|
253
|
+
def thorfiles(relevant_to = nil, skip_lookup = false)
|
|
254
|
+
thorfiles = []
|
|
255
|
+
|
|
256
|
+
unless skip_lookup
|
|
257
|
+
Pathname.pwd.ascend do |path|
|
|
258
|
+
thorfiles = Bundler::Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten
|
|
259
|
+
break unless thorfiles.empty?
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Bundler::Thor::Util.thor_root_glob)
|
|
264
|
+
files += thorfiles
|
|
265
|
+
files -= ["#{thor_root}/thor.yml"]
|
|
266
|
+
|
|
267
|
+
files.map! do |file|
|
|
268
|
+
File.directory?(file) ? File.join(file, "main.thor") : file
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Load Thorfiles relevant to the given method. If you provide "foo:bar" it
|
|
273
|
+
# will load all thor files in the thor.yaml that has "foo" e "foo:bar"
|
|
274
|
+
# namespaces registered.
|
|
275
|
+
#
|
|
276
|
+
def thorfiles_relevant_to(meth)
|
|
277
|
+
lookup = [meth, meth.split(":")[0...-1].join(":")]
|
|
278
|
+
|
|
279
|
+
files = thor_yaml.select do |_, v|
|
|
280
|
+
v[:namespaces] && !(v[:namespaces] & lookup).empty?
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
files.map { |_, v| File.join(thor_root, (v[:filename]).to_s) }
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# Display information about the given klasses. If with_module is given,
|
|
287
|
+
# it shows a table with information extracted from the yaml file.
|
|
288
|
+
#
|
|
289
|
+
def display_klasses(with_modules = false, show_internal = false, klasses = Bundler::Thor::Base.subclasses)
|
|
290
|
+
klasses -= [Bundler::Thor, Bundler::Thor::Runner, Bundler::Thor::Group] unless show_internal
|
|
291
|
+
|
|
292
|
+
raise Error, "No Bundler::Thor commands available" if klasses.empty?
|
|
293
|
+
show_modules if with_modules && !thor_yaml.empty?
|
|
294
|
+
|
|
295
|
+
list = Hash.new { |h, k| h[k] = [] }
|
|
296
|
+
groups = klasses.select { |k| k.ancestors.include?(Bundler::Thor::Group) }
|
|
297
|
+
|
|
298
|
+
# Get classes which inherit from Bundler::Thor
|
|
299
|
+
(klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_commands(false) }
|
|
300
|
+
|
|
301
|
+
# Get classes which inherit from Bundler::Thor::Base
|
|
302
|
+
groups.map! { |k| k.printable_commands(false).first }
|
|
303
|
+
list["root"] = groups
|
|
304
|
+
|
|
305
|
+
# Order namespaces with default coming first
|
|
306
|
+
list = list.sort { |a, b| a[0].sub(/^default/, "") <=> b[0].sub(/^default/, "") }
|
|
307
|
+
list.each { |n, commands| display_commands(n, commands) unless commands.empty? }
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def display_commands(namespace, list) #:nodoc:
|
|
311
|
+
list.sort! { |a, b| a[0] <=> b[0] }
|
|
312
|
+
|
|
313
|
+
say shell.set_color(namespace, :blue, true)
|
|
314
|
+
say "-" * namespace.size
|
|
315
|
+
|
|
316
|
+
print_table(list, truncate: true)
|
|
317
|
+
say
|
|
318
|
+
end
|
|
319
|
+
alias_method :display_tasks, :display_commands
|
|
320
|
+
|
|
321
|
+
def show_modules #:nodoc:
|
|
322
|
+
info = []
|
|
323
|
+
labels = %w(Modules Namespaces)
|
|
324
|
+
|
|
325
|
+
info << labels
|
|
326
|
+
info << ["-" * labels[0].size, "-" * labels[1].size]
|
|
327
|
+
|
|
328
|
+
thor_yaml.each do |name, hash|
|
|
329
|
+
info << [name, hash[:namespaces].join(", ")]
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
print_table info
|
|
333
|
+
say ""
|
|
334
|
+
end
|
|
335
|
+
end
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
require_relative "column_printer"
|
|
2
|
+
require_relative "table_printer"
|
|
3
|
+
require_relative "wrapped_printer"
|
|
4
|
+
|
|
5
|
+
class Bundler::Thor
|
|
6
|
+
module Shell
|
|
7
|
+
class Basic
|
|
8
|
+
attr_accessor :base
|
|
9
|
+
attr_reader :padding
|
|
10
|
+
|
|
11
|
+
# Initialize base, mute and padding to nil.
|
|
12
|
+
#
|
|
13
|
+
def initialize #:nodoc:
|
|
14
|
+
@base = nil
|
|
15
|
+
@mute = false
|
|
16
|
+
@padding = 0
|
|
17
|
+
@always_force = false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Mute everything that's inside given block
|
|
21
|
+
#
|
|
22
|
+
def mute
|
|
23
|
+
@mute = true
|
|
24
|
+
yield
|
|
25
|
+
ensure
|
|
26
|
+
@mute = false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Check if base is muted
|
|
30
|
+
#
|
|
31
|
+
def mute?
|
|
32
|
+
@mute
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Sets the output padding, not allowing less than zero values.
|
|
36
|
+
#
|
|
37
|
+
def padding=(value)
|
|
38
|
+
@padding = [0, value].max
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Sets the output padding while executing a block and resets it.
|
|
42
|
+
#
|
|
43
|
+
def indent(count = 1)
|
|
44
|
+
orig_padding = padding
|
|
45
|
+
self.padding = padding + count
|
|
46
|
+
yield
|
|
47
|
+
self.padding = orig_padding
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Asks something to the user and receives a response.
|
|
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
|
+
#
|
|
56
|
+
# If asked to limit the correct responses, you can pass in an
|
|
57
|
+
# array of acceptable answers. If one of those is not supplied,
|
|
58
|
+
# they will be shown a message stating that one of those answers
|
|
59
|
+
# must be given and re-asked the question.
|
|
60
|
+
#
|
|
61
|
+
# If asking for sensitive information, the :echo option can be set
|
|
62
|
+
# to false to mask user input from $stdin.
|
|
63
|
+
#
|
|
64
|
+
# If the required input is a path, then set the path option to
|
|
65
|
+
# true. This will enable tab completion for file paths relative
|
|
66
|
+
# to the current working directory on systems that support
|
|
67
|
+
# Readline.
|
|
68
|
+
#
|
|
69
|
+
# ==== Example
|
|
70
|
+
# ask("What is your name?")
|
|
71
|
+
#
|
|
72
|
+
# ask("What is the planet furthest from the sun?", :default => "Neptune")
|
|
73
|
+
#
|
|
74
|
+
# ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
|
|
75
|
+
#
|
|
76
|
+
# ask("What is your password?", :echo => false)
|
|
77
|
+
#
|
|
78
|
+
# ask("Where should the file be saved?", :path => true)
|
|
79
|
+
#
|
|
80
|
+
def ask(statement, *args)
|
|
81
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
82
|
+
color = args.first
|
|
83
|
+
|
|
84
|
+
if options[:limited_to]
|
|
85
|
+
ask_filtered(statement, color, options)
|
|
86
|
+
else
|
|
87
|
+
ask_simply(statement, color, options)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Say (print) something to the user. If the sentence ends with a whitespace
|
|
92
|
+
# or tab character, a new line is not appended (print + flush). Otherwise
|
|
93
|
+
# are passed straight to puts (behavior got from Highline).
|
|
94
|
+
#
|
|
95
|
+
# ==== Example
|
|
96
|
+
# say("I know you knew that.")
|
|
97
|
+
#
|
|
98
|
+
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
|
99
|
+
return if quiet?
|
|
100
|
+
|
|
101
|
+
buffer = prepare_message(message, *color)
|
|
102
|
+
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
|
|
103
|
+
|
|
104
|
+
stdout.print(buffer)
|
|
105
|
+
stdout.flush
|
|
106
|
+
end
|
|
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
|
+
|
|
125
|
+
# Say a status with the given color and appends the message. Since this
|
|
126
|
+
# method is used frequently by actions, it allows nil or false to be given
|
|
127
|
+
# in log_status, avoiding the message from being shown. If a Symbol is
|
|
128
|
+
# given in log_status, it's used as the color.
|
|
129
|
+
#
|
|
130
|
+
def say_status(status, message, log_status = true)
|
|
131
|
+
return if quiet? || log_status == false
|
|
132
|
+
spaces = " " * (padding + 1)
|
|
133
|
+
status = status.to_s.rjust(12)
|
|
134
|
+
margin = " " * status.length + spaces
|
|
135
|
+
|
|
136
|
+
color = log_status.is_a?(Symbol) ? log_status : :green
|
|
137
|
+
status = set_color status, color, true if color
|
|
138
|
+
|
|
139
|
+
message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
|
|
140
|
+
buffer = "#{status}#{spaces}#{message}\n"
|
|
141
|
+
|
|
142
|
+
stdout.print(buffer)
|
|
143
|
+
stdout.flush
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Asks the user a question and returns true if the user replies "y" or
|
|
147
|
+
# "yes".
|
|
148
|
+
#
|
|
149
|
+
def yes?(statement, color = nil)
|
|
150
|
+
!!(ask(statement, color, add_to_history: false) =~ is?(:yes))
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Asks the user a question and returns true if the user replies "n" or
|
|
154
|
+
# "no".
|
|
155
|
+
#
|
|
156
|
+
def no?(statement, color = nil)
|
|
157
|
+
!!(ask(statement, color, add_to_history: false) =~ is?(:no))
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Prints values in columns
|
|
161
|
+
#
|
|
162
|
+
# ==== Parameters
|
|
163
|
+
# Array[String, String, ...]
|
|
164
|
+
#
|
|
165
|
+
def print_in_columns(array)
|
|
166
|
+
printer = ColumnPrinter.new(stdout)
|
|
167
|
+
printer.print(array)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Prints a table.
|
|
171
|
+
#
|
|
172
|
+
# ==== Parameters
|
|
173
|
+
# Array[Array[String, String, ...]]
|
|
174
|
+
#
|
|
175
|
+
# ==== Options
|
|
176
|
+
# indent<Integer>:: Indent the first column by indent value.
|
|
177
|
+
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
|
|
178
|
+
# borders<Boolean>:: Adds ascii borders.
|
|
179
|
+
#
|
|
180
|
+
def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
|
|
181
|
+
printer = TablePrinter.new(stdout, options)
|
|
182
|
+
printer.print(array)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Prints a long string, word-wrapping the text to the current width of the
|
|
186
|
+
# terminal display. Ideal for printing heredocs.
|
|
187
|
+
#
|
|
188
|
+
# ==== Parameters
|
|
189
|
+
# String
|
|
190
|
+
#
|
|
191
|
+
# ==== Options
|
|
192
|
+
# indent<Integer>:: Indent each line of the printed paragraph by indent value.
|
|
193
|
+
#
|
|
194
|
+
def print_wrapped(message, options = {})
|
|
195
|
+
printer = WrappedPrinter.new(stdout, options)
|
|
196
|
+
printer.print(message)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Deals with file collision and returns true if the file should be
|
|
200
|
+
# overwritten and false otherwise. If a block is given, it uses the block
|
|
201
|
+
# response as the content for the diff.
|
|
202
|
+
#
|
|
203
|
+
# ==== Parameters
|
|
204
|
+
# destination<String>:: the destination file to solve conflicts
|
|
205
|
+
# block<Proc>:: an optional block that returns the value to be used in diff and merge
|
|
206
|
+
#
|
|
207
|
+
def file_collision(destination)
|
|
208
|
+
return true if @always_force
|
|
209
|
+
options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"
|
|
210
|
+
|
|
211
|
+
loop do
|
|
212
|
+
answer = ask(
|
|
213
|
+
%[Overwrite #{destination}? (enter "h" for help) #{options}],
|
|
214
|
+
add_to_history: false
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
case answer
|
|
218
|
+
when nil
|
|
219
|
+
say ""
|
|
220
|
+
return true
|
|
221
|
+
when is?(:yes), is?(:force), ""
|
|
222
|
+
return true
|
|
223
|
+
when is?(:no), is?(:skip)
|
|
224
|
+
return false
|
|
225
|
+
when is?(:always)
|
|
226
|
+
return @always_force = true
|
|
227
|
+
when is?(:quit)
|
|
228
|
+
say "Aborting..."
|
|
229
|
+
raise SystemExit
|
|
230
|
+
when is?(:diff)
|
|
231
|
+
show_diff(destination, yield) if block_given?
|
|
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."
|
|
240
|
+
else
|
|
241
|
+
say file_collision_help(block_given?)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Called if something goes wrong during the execution. This is used by Bundler::Thor
|
|
247
|
+
# internally and should not be used inside your scripts. If something went
|
|
248
|
+
# wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
|
|
249
|
+
# will be rescued and wrapped in the method below.
|
|
250
|
+
#
|
|
251
|
+
def error(statement)
|
|
252
|
+
stderr.puts statement
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Apply color to the given string with optional bold. Disabled in the
|
|
256
|
+
# Bundler::Thor::Shell::Basic class.
|
|
257
|
+
#
|
|
258
|
+
def set_color(string, *) #:nodoc:
|
|
259
|
+
string
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
protected
|
|
263
|
+
|
|
264
|
+
def prepare_message(message, *color)
|
|
265
|
+
spaces = " " * padding
|
|
266
|
+
spaces + set_color(message.to_s, *color)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def can_display_colors?
|
|
270
|
+
false
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def lookup_color(color)
|
|
274
|
+
return color unless color.is_a?(Symbol)
|
|
275
|
+
self.class.const_get(color.to_s.upcase)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def stdout
|
|
279
|
+
$stdout
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def stderr
|
|
283
|
+
$stderr
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def is?(value) #:nodoc:
|
|
287
|
+
value = value.to_s
|
|
288
|
+
|
|
289
|
+
if value.size == 1
|
|
290
|
+
/\A#{value}\z/i
|
|
291
|
+
else
|
|
292
|
+
/\A(#{value}|#{value[0, 1]})\z/i
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def file_collision_help(block_given) #:nodoc:
|
|
297
|
+
help = <<-HELP
|
|
298
|
+
Y - yes, overwrite
|
|
299
|
+
n - no, do not overwrite
|
|
300
|
+
a - all, overwrite this and all others
|
|
301
|
+
q - quit, abort
|
|
302
|
+
h - help, show this help
|
|
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
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def show_diff(destination, content) #:nodoc:
|
|
314
|
+
diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
|
|
315
|
+
|
|
316
|
+
require "tempfile"
|
|
317
|
+
Tempfile.open(File.basename(destination), File.dirname(destination), binmode: true) do |temp|
|
|
318
|
+
temp.write content
|
|
319
|
+
temp.rewind
|
|
320
|
+
system %(#{diff_cmd} "#{destination}" "#{temp.path}")
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def quiet? #:nodoc:
|
|
325
|
+
mute? || (base && base.options[:quiet])
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def unix?
|
|
329
|
+
Terminal.unix?
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def ask_simply(statement, color, options)
|
|
333
|
+
default = options[:default]
|
|
334
|
+
message = [statement, ("(#{default})" if default), nil].uniq.join(" ")
|
|
335
|
+
message = prepare_message(message, *color)
|
|
336
|
+
result = Bundler::Thor::LineEditor.readline(message, options)
|
|
337
|
+
|
|
338
|
+
return unless result
|
|
339
|
+
|
|
340
|
+
result = result.strip
|
|
341
|
+
|
|
342
|
+
if default && result == ""
|
|
343
|
+
default
|
|
344
|
+
else
|
|
345
|
+
result
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
def ask_filtered(statement, color, options)
|
|
350
|
+
answer_set = options[:limited_to]
|
|
351
|
+
case_insensitive = options.fetch(:case_insensitive, false)
|
|
352
|
+
correct_answer = nil
|
|
353
|
+
until correct_answer
|
|
354
|
+
answers = answer_set.join(", ")
|
|
355
|
+
answer = ask_simply("#{statement} [#{answers}]", color, options)
|
|
356
|
+
correct_answer = answer_match(answer_set, answer, case_insensitive)
|
|
357
|
+
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
|
|
358
|
+
end
|
|
359
|
+
correct_answer
|
|
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 difftool --no-index"
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
end
|