bundler 1.11.1 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2125 -840
- data/LICENSE.md +18 -19
- data/README.md +33 -11
- data/bundler.gemspec +34 -21
- data/exe/bundle +36 -6
- data/exe/bundler +2 -18
- data/lib/bundler.rb +435 -160
- data/lib/bundler/build_metadata.rb +45 -0
- data/lib/bundler/capistrano.rb +9 -3
- data/lib/bundler/cli.rb +550 -130
- data/lib/bundler/cli/add.rb +47 -0
- data/lib/bundler/cli/binstubs.rb +26 -10
- data/lib/bundler/cli/cache.rb +25 -17
- data/lib/bundler/cli/check.rb +8 -7
- data/lib/bundler/cli/clean.rb +8 -8
- data/lib/bundler/cli/common.rb +69 -9
- data/lib/bundler/cli/config.rb +170 -76
- data/lib/bundler/cli/console.rb +6 -1
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +63 -21
- data/lib/bundler/cli/fund.rb +36 -0
- data/lib/bundler/cli/gem.rb +158 -42
- data/lib/bundler/cli/info.rb +73 -0
- data/lib/bundler/cli/init.rb +22 -7
- data/lib/bundler/cli/inject.rb +38 -10
- data/lib/bundler/cli/install.rb +139 -104
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +60 -0
- data/lib/bundler/cli/lock.rb +27 -5
- data/lib/bundler/cli/open.rb +13 -5
- data/lib/bundler/cli/outdated.rb +251 -46
- data/lib/bundler/cli/platform.rb +6 -2
- data/lib/bundler/cli/plugin.rb +41 -0
- data/lib/bundler/cli/pristine.rb +52 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +5 -4
- data/lib/bundler/cli/update.rb +67 -26
- data/lib/bundler/cli/viz.rb +11 -6
- data/lib/bundler/compact_index_client.rb +125 -0
- data/lib/bundler/compact_index_client/cache.rb +110 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
- data/lib/bundler/compact_index_client/updater.rb +104 -0
- data/lib/bundler/constants.rb +2 -0
- data/lib/bundler/current_ruby.rb +51 -174
- data/lib/bundler/definition.rb +533 -216
- data/lib/bundler/dep_proxy.rb +18 -8
- data/lib/bundler/dependency.rb +39 -12
- data/lib/bundler/deployment.rb +7 -0
- data/lib/bundler/deprecate.rb +31 -2
- data/lib/bundler/dsl.rb +188 -91
- data/lib/bundler/endpoint_specification.rb +51 -10
- data/lib/bundler/env.rb +116 -48
- data/lib/bundler/environment_preserver.rb +82 -0
- data/lib/bundler/errors.rb +108 -31
- data/lib/bundler/feature_flag.rb +60 -0
- data/lib/bundler/fetcher.rb +81 -52
- data/lib/bundler/fetcher/base.rb +15 -3
- data/lib/bundler/fetcher/compact_index.rb +140 -0
- data/lib/bundler/fetcher/dependency.rb +36 -42
- data/lib/bundler/fetcher/downloader.rb +39 -12
- data/lib/bundler/fetcher/index.rb +34 -9
- data/lib/bundler/friendly_errors.rb +132 -88
- data/lib/bundler/gem_helper.rb +92 -50
- data/lib/bundler/gem_helpers.rb +90 -5
- data/lib/bundler/gem_tasks.rb +3 -1
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +20 -41
- data/lib/bundler/index.rb +74 -57
- data/lib/bundler/injector.rb +242 -31
- data/lib/bundler/inline.rb +49 -23
- data/lib/bundler/installer.rb +190 -74
- data/lib/bundler/installer/gem_installer.rb +33 -20
- data/lib/bundler/installer/parallel_installer.rb +201 -97
- data/lib/bundler/installer/standalone.rb +10 -6
- data/lib/bundler/lazy_specification.rb +74 -10
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +126 -74
- data/lib/bundler/{ssl_certs → man}/.document +0 -0
- data/lib/bundler/man/bundle-add.1 +66 -0
- data/lib/bundler/man/bundle-add.1.ronn +46 -0
- data/lib/bundler/man/bundle-binstubs.1 +42 -0
- data/lib/bundler/man/bundle-binstubs.1.ronn +41 -0
- data/lib/bundler/man/bundle-cache.1 +55 -0
- data/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +22 -16
- data/lib/bundler/man/bundle-check.1 +31 -0
- data/lib/bundler/man/bundle-check.1.ronn +26 -0
- data/lib/bundler/man/bundle-clean.1 +24 -0
- data/lib/bundler/man/bundle-clean.1.ronn +18 -0
- data/lib/bundler/man/bundle-config.1 +488 -0
- data/lib/bundler/man/bundle-config.1.ronn +388 -0
- data/lib/bundler/man/bundle-doctor.1 +44 -0
- data/lib/bundler/man/bundle-doctor.1.ronn +33 -0
- data/lib/bundler/man/bundle-exec.1 +165 -0
- data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +20 -4
- data/lib/bundler/man/bundle-gem.1 +102 -0
- data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +37 -13
- data/lib/bundler/man/bundle-info.1 +20 -0
- data/lib/bundler/man/bundle-info.1.ronn +17 -0
- data/lib/bundler/man/bundle-init.1 +25 -0
- data/lib/bundler/man/bundle-init.1.ronn +29 -0
- data/lib/bundler/man/bundle-inject.1 +33 -0
- data/lib/bundler/man/bundle-inject.1.ronn +22 -0
- data/lib/bundler/man/bundle-install.1 +338 -0
- data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +82 -76
- data/lib/bundler/man/bundle-list.1 +50 -0
- data/lib/bundler/man/bundle-list.1.ronn +33 -0
- data/lib/bundler/man/bundle-lock.1 +84 -0
- data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +47 -0
- data/lib/bundler/man/bundle-open.1 +32 -0
- data/lib/bundler/man/bundle-open.1.ronn +19 -0
- data/lib/bundler/man/bundle-outdated.1 +155 -0
- data/lib/bundler/man/bundle-outdated.1.ronn +111 -0
- data/lib/bundler/man/bundle-platform.1 +61 -0
- data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +1 -1
- data/lib/bundler/man/bundle-pristine.1 +34 -0
- data/lib/bundler/man/bundle-pristine.1.ronn +34 -0
- data/lib/bundler/man/bundle-remove.1 +31 -0
- data/lib/bundler/man/bundle-remove.1.ronn +23 -0
- data/lib/bundler/man/bundle-show.1 +23 -0
- data/lib/bundler/man/bundle-show.1.ronn +21 -0
- data/lib/bundler/man/bundle-update.1 +394 -0
- data/lib/bundler/man/bundle-update.1.ronn +350 -0
- data/lib/bundler/man/bundle-viz.1 +39 -0
- data/lib/bundler/man/bundle-viz.1.ronn +30 -0
- data/lib/bundler/man/bundle.1 +136 -0
- data/lib/bundler/man/bundle.1.ronn +111 -0
- data/lib/bundler/man/gemfile.5 +686 -0
- data/{man → lib/bundler/man}/gemfile.5.ronn +117 -95
- data/lib/bundler/man/index.txt +25 -0
- data/lib/bundler/match_platform.rb +15 -4
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +330 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +304 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +182 -0
- data/lib/bundler/plugin/installer.rb +109 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +27 -0
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +2 -6
- data/lib/bundler/remote_specification.rb +42 -9
- data/lib/bundler/resolver.rb +312 -225
- data/lib/bundler/resolver/spec_group.rb +122 -0
- data/lib/bundler/retry.rb +11 -5
- data/lib/bundler/ruby_dsl.rb +9 -2
- data/lib/bundler/ruby_version.rb +84 -61
- data/lib/bundler/rubygems_ext.rb +92 -53
- data/lib/bundler/rubygems_gem_installer.rb +84 -0
- data/lib/bundler/rubygems_integration.rb +320 -395
- data/lib/bundler/runtime.rb +87 -75
- data/lib/bundler/settings.rb +297 -119
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +13 -12
- data/lib/bundler/shared_helpers.rb +234 -53
- data/lib/bundler/similarity_detector.rb +5 -3
- data/lib/bundler/source.rb +63 -4
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +97 -50
- data/lib/bundler/source/git/git_proxy.rb +138 -65
- data/lib/bundler/source/metadata.rb +67 -0
- data/lib/bundler/source/path.rb +83 -47
- data/lib/bundler/source/path/installer.rb +42 -11
- data/lib/bundler/source/rubygems.rb +231 -116
- data/lib/bundler/source/rubygems/remote.rb +30 -1
- data/lib/bundler/source_list.rb +103 -21
- data/lib/bundler/spec_set.rb +96 -51
- data/lib/bundler/stub_specification.rb +87 -4
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +14 -1
- data/lib/bundler/templates/Executable.bundler +114 -0
- data/lib/bundler/templates/Executable.standalone +6 -4
- data/lib/bundler/templates/Gemfile +4 -1
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +79 -44
- data/lib/bundler/templates/newgem/Gemfile.tt +18 -2
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
- data/lib/bundler/templates/newgem/README.md.tt +16 -10
- data/lib/bundler/templates/newgem/Rakefile.tt +22 -8
- data/lib/bundler/templates/newgem/bin/console.tt +2 -1
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +18 -0
- data/lib/bundler/templates/newgem/gitignore.tt +5 -1
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -6
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +6 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -28
- data/lib/bundler/templates/newgem/rspec.tt +1 -0
- data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +4 -4
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -2
- data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +3 -1
- data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -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/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
- data/lib/bundler/ui.rb +5 -3
- data/lib/bundler/ui/rg_proxy.rb +3 -1
- data/lib/bundler/ui/shell.rb +54 -21
- data/lib/bundler/ui/silent.rb +26 -1
- data/lib/bundler/uri_credentials_filter.rb +43 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1764 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +11 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +113 -134
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +158 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +82 -8
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +4 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +2 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +6 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +555 -150
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +6 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +19 -12
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +310 -467
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +58 -25
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +50 -33
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +5 -3
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +9 -19
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +79 -22
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +33 -20
- data/lib/bundler/vendor/thor/lib/thor/base.rb +110 -67
- data/lib/bundler/vendor/thor/lib/thor/command.rb +33 -24
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
- data/lib/bundler/vendor/thor/lib/thor/error.rb +81 -3
- data/lib/bundler/vendor/thor/lib/thor/group.rb +16 -16
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +5 -5
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +18 -18
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +60 -26
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +31 -13
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +42 -39
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +109 -39
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +7 -3
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +5 -5
- 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/tmpdir/lib/tmpdir.rb +154 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
- data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -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 +21 -0
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
- data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/bundler/vendored_fileutils.rb +4 -0
- data/lib/bundler/vendored_molinillo.rb +3 -1
- data/lib/bundler/vendored_persistent.rb +45 -9
- data/lib/bundler/vendored_thor.rb +8 -3
- data/lib/bundler/vendored_tmpdir.rb +4 -0
- data/lib/bundler/vendored_uri.rb +4 -0
- data/lib/bundler/version.rb +7 -4
- data/lib/bundler/version_ranges.rb +122 -0
- data/lib/bundler/vlad.rb +8 -2
- data/lib/bundler/worker.rb +38 -6
- data/lib/bundler/yaml_serializer.rb +89 -0
- metadata +164 -158
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -105
- data/.rubocop_todo.yml +0 -120
- data/.travis.yml +0 -97
- data/CODE_OF_CONDUCT.md +0 -42
- data/CONTRIBUTING.md +0 -32
- data/DEVELOPMENT.md +0 -118
- data/ISSUES.md +0 -96
- data/Rakefile +0 -309
- data/bin/rake +0 -14
- data/bin/rspec +0 -10
- data/bin/rubocop +0 -11
- data/exe/bundle_ruby +0 -60
- data/lib/bundler/cli/package.rb +0 -45
- data/lib/bundler/environment.rb +0 -41
- data/lib/bundler/gem_path_manipulation.rb +0 -8
- data/lib/bundler/gem_remote_fetcher.rb +0 -41
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +0 -32
- data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
- data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
- data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +0 -20
- data/lib/bundler/ssl_certs/certificate_manager.rb +0 -64
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
- data/lib/bundler/vendor/net/http/faster.rb +0 -26
- data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +0 -128
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -10
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -98
- data/man/bundle-config.ronn +0 -187
- data/man/bundle-update.ronn +0 -188
- data/man/bundle.ronn +0 -98
- data/man/index.txt +0 -8
@@ -1,27 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
require_relative "command"
|
2
|
+
require_relative "core_ext/hash_with_indifferent_access"
|
3
|
+
require_relative "error"
|
4
|
+
require_relative "invocation"
|
5
|
+
require_relative "nested_context"
|
6
|
+
require_relative "parser"
|
7
|
+
require_relative "shell"
|
8
|
+
require_relative "line_editor"
|
9
|
+
require_relative "util"
|
10
10
|
|
11
11
|
class Bundler::Thor
|
12
|
-
autoload :Actions, "
|
13
|
-
autoload :RakeCompat, "
|
14
|
-
autoload :Group, "
|
12
|
+
autoload :Actions, File.expand_path("actions", __dir__)
|
13
|
+
autoload :RakeCompat, File.expand_path("rake_compat", __dir__)
|
14
|
+
autoload :Group, File.expand_path("group", __dir__)
|
15
15
|
|
16
16
|
# Shortcuts for help.
|
17
|
-
HELP_MAPPINGS = %w
|
17
|
+
HELP_MAPPINGS = %w(-h -? --help -D)
|
18
18
|
|
19
19
|
# Bundler::Thor methods that should not be overwritten by the user.
|
20
|
-
THOR_RESERVED_WORDS = %w
|
21
|
-
action add_file create_file in_root inside run run_ruby_script
|
20
|
+
THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
|
21
|
+
action add_file create_file in_root inside run run_ruby_script)
|
22
22
|
|
23
23
|
TEMPLATE_EXTNAME = ".tt"
|
24
24
|
|
25
|
+
class << self
|
26
|
+
def deprecation_warning(message) #:nodoc:
|
27
|
+
unless ENV['THOR_SILENCE_DEPRECATION']
|
28
|
+
warn "Deprecation warning: #{message}\n" +
|
29
|
+
'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
module Base
|
26
35
|
attr_accessor :options, :parent_options, :args
|
27
36
|
|
@@ -41,7 +50,7 @@ class Bundler::Thor
|
|
41
50
|
#
|
42
51
|
# config<Hash>:: Configuration for this Bundler::Thor class.
|
43
52
|
#
|
44
|
-
def initialize(args = [], local_options = {}, config = {})
|
53
|
+
def initialize(args = [], local_options = {}, config = {})
|
45
54
|
parse_options = self.class.class_options
|
46
55
|
|
47
56
|
# The start method splits inbound arguments at the first argument
|
@@ -52,18 +61,21 @@ class Bundler::Thor
|
|
52
61
|
command_options = config.delete(:command_options) # hook for start
|
53
62
|
parse_options = parse_options.merge(command_options) if command_options
|
54
63
|
if local_options.is_a?(Array)
|
55
|
-
array_options
|
64
|
+
array_options = local_options
|
65
|
+
hash_options = {}
|
56
66
|
else
|
57
67
|
# Handle the case where the class was explicitly instantiated
|
58
68
|
# with pre-parsed options.
|
59
|
-
array_options
|
69
|
+
array_options = []
|
70
|
+
hash_options = local_options
|
60
71
|
end
|
61
72
|
|
62
73
|
# Let Bundler::Thor::Options parse the options first, so it can remove
|
63
74
|
# declared options from the array. This will leave us with
|
64
75
|
# a list of arguments that weren't declared.
|
65
76
|
stop_on_unknown = self.class.stop_on_unknown_option? config[:current_command]
|
66
|
-
|
77
|
+
disable_required_check = self.class.disable_required_check? config[:current_command]
|
78
|
+
opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check)
|
67
79
|
self.options = opts.parse(array_options)
|
68
80
|
self.options = config[:class_options].merge(options) if config[:class_options]
|
69
81
|
|
@@ -86,6 +98,7 @@ class Bundler::Thor
|
|
86
98
|
|
87
99
|
class << self
|
88
100
|
def included(base) #:nodoc:
|
101
|
+
super(base)
|
89
102
|
base.extend ClassMethods
|
90
103
|
base.send :include, Invocation
|
91
104
|
base.send :include, Shell
|
@@ -110,7 +123,7 @@ class Bundler::Thor
|
|
110
123
|
end
|
111
124
|
|
112
125
|
# Whenever a class inherits from Bundler::Thor or Bundler::Thor::Group, we should track the
|
113
|
-
# class and the file on Bundler::Thor::Base. This is the method
|
126
|
+
# class and the file on Bundler::Thor::Base. This is the method responsible for it.
|
114
127
|
#
|
115
128
|
def register_klass_file(klass) #:nodoc:
|
116
129
|
file = caller[1].match(/(.*):\d+/)[1]
|
@@ -148,6 +161,24 @@ class Bundler::Thor
|
|
148
161
|
!!check_unknown_options
|
149
162
|
end
|
150
163
|
|
164
|
+
# If you want to raise an error when the default value of an option does not match
|
165
|
+
# the type call check_default_type!
|
166
|
+
# This will be the default; for compatibility a deprecation warning is issued if necessary.
|
167
|
+
def check_default_type!
|
168
|
+
@check_default_type = true
|
169
|
+
end
|
170
|
+
|
171
|
+
# If you want to use defaults that don't match the type of an option,
|
172
|
+
# either specify `check_default_type: false` or call `allow_incompatible_default_type!`
|
173
|
+
def allow_incompatible_default_type!
|
174
|
+
@check_default_type = false
|
175
|
+
end
|
176
|
+
|
177
|
+
def check_default_type #:nodoc:
|
178
|
+
@check_default_type = from_superclass(:check_default_type, nil) unless defined?(@check_default_type)
|
179
|
+
@check_default_type
|
180
|
+
end
|
181
|
+
|
151
182
|
# If true, option parsing is suspended as soon as an unknown option or a
|
152
183
|
# regular argument is encountered. All remaining arguments are passed to
|
153
184
|
# the command as regular arguments.
|
@@ -155,6 +186,12 @@ class Bundler::Thor
|
|
155
186
|
false
|
156
187
|
end
|
157
188
|
|
189
|
+
# If true, option set will not suspend the execution of the command when
|
190
|
+
# a required option is not provided.
|
191
|
+
def disable_required_check?(command_name) #:nodoc:
|
192
|
+
false
|
193
|
+
end
|
194
|
+
|
158
195
|
# If you want only strict string args (useful when cascading thor classes),
|
159
196
|
# call strict_args_position! This is disabled by default to allow dynamic
|
160
197
|
# invocations.
|
@@ -205,7 +242,7 @@ class Bundler::Thor
|
|
205
242
|
# ==== Errors
|
206
243
|
# ArgumentError:: Raised if you supply a required argument after a non required one.
|
207
244
|
#
|
208
|
-
def argument(name, options = {})
|
245
|
+
def argument(name, options = {})
|
209
246
|
is_thor_reserved_word?(name, :argument)
|
210
247
|
no_commands { attr_accessor name }
|
211
248
|
|
@@ -219,11 +256,13 @@ class Bundler::Thor
|
|
219
256
|
|
220
257
|
remove_argument name
|
221
258
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
259
|
+
if required
|
260
|
+
arguments.each do |argument|
|
261
|
+
next if argument.required?
|
262
|
+
raise ArgumentError, "You cannot have #{name.to_s.inspect} as required argument after " \
|
263
|
+
"the non-required argument #{argument.human_name.inspect}."
|
264
|
+
end
|
265
|
+
end
|
227
266
|
|
228
267
|
options[:required] = required
|
229
268
|
|
@@ -327,23 +366,23 @@ class Bundler::Thor
|
|
327
366
|
# Returns the commands for this Bundler::Thor class.
|
328
367
|
#
|
329
368
|
# ==== Returns
|
330
|
-
#
|
331
|
-
#
|
369
|
+
# Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
|
370
|
+
# objects as values.
|
332
371
|
#
|
333
372
|
def commands
|
334
|
-
@commands ||=
|
373
|
+
@commands ||= Hash.new
|
335
374
|
end
|
336
375
|
alias_method :tasks, :commands
|
337
376
|
|
338
377
|
# Returns the commands for this Bundler::Thor class and all subclasses.
|
339
378
|
#
|
340
379
|
# ==== Returns
|
341
|
-
#
|
342
|
-
#
|
380
|
+
# Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
|
381
|
+
# objects as values.
|
343
382
|
#
|
344
383
|
def all_commands
|
345
|
-
@all_commands ||= from_superclass(:all_commands,
|
346
|
-
@all_commands.merge(commands)
|
384
|
+
@all_commands ||= from_superclass(:all_commands, Hash.new)
|
385
|
+
@all_commands.merge!(commands)
|
347
386
|
end
|
348
387
|
alias_method :all_tasks, :all_commands
|
349
388
|
|
@@ -389,14 +428,20 @@ class Bundler::Thor
|
|
389
428
|
# remove_command :this_is_not_a_command
|
390
429
|
# end
|
391
430
|
#
|
392
|
-
def no_commands
|
393
|
-
|
394
|
-
yield
|
395
|
-
ensure
|
396
|
-
@no_commands = false
|
431
|
+
def no_commands(&block)
|
432
|
+
no_commands_context.enter(&block)
|
397
433
|
end
|
434
|
+
|
398
435
|
alias_method :no_tasks, :no_commands
|
399
436
|
|
437
|
+
def no_commands_context
|
438
|
+
@no_commands_context ||= NestedContext.new
|
439
|
+
end
|
440
|
+
|
441
|
+
def no_commands?
|
442
|
+
no_commands_context.entered?
|
443
|
+
end
|
444
|
+
|
400
445
|
# Sets the namespace for the Bundler::Thor or Bundler::Thor::Group class. By default the
|
401
446
|
# namespace is retrieved from the class name. If your Bundler::Thor class is named
|
402
447
|
# Scripts::MyScript, the help method, for example, will be called as:
|
@@ -440,13 +485,13 @@ class Bundler::Thor
|
|
440
485
|
dispatch(nil, given_args.dup, nil, config)
|
441
486
|
rescue Bundler::Thor::Error => e
|
442
487
|
config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message)
|
443
|
-
exit(
|
488
|
+
exit(false) if exit_on_failure?
|
444
489
|
rescue Errno::EPIPE
|
445
490
|
# This happens if a thor command is piped to something like `head`,
|
446
491
|
# which closes the pipe when it's done reading. This will also
|
447
492
|
# mean that if the pipe is closed, further unnecessary
|
448
493
|
# computation will not occur.
|
449
|
-
exit(
|
494
|
+
exit(true)
|
450
495
|
end
|
451
496
|
|
452
497
|
# Allows to use private methods from parent in child classes as commands.
|
@@ -467,20 +512,23 @@ class Bundler::Thor
|
|
467
512
|
alias_method :public_task, :public_command
|
468
513
|
|
469
514
|
def handle_no_command_error(command, has_namespace = $thor_runner) #:nodoc:
|
470
|
-
if has_namespace
|
471
|
-
fail UndefinedCommandError, "Could not find command #{command.inspect} in #{namespace.inspect} namespace."
|
472
|
-
else
|
473
|
-
fail UndefinedCommandError, "Could not find command #{command.inspect}."
|
474
|
-
end
|
515
|
+
raise UndefinedCommandError.new(command, all_commands.keys, (namespace if has_namespace))
|
475
516
|
end
|
476
517
|
alias_method :handle_no_task_error, :handle_no_command_error
|
477
518
|
|
478
519
|
def handle_argument_error(command, error, args, arity) #:nodoc:
|
479
|
-
|
520
|
+
name = [command.ancestor_name, command.name].compact.join(" ")
|
521
|
+
msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
|
480
522
|
msg << "no arguments" if args.empty?
|
481
523
|
msg << "arguments " << args.inspect unless args.empty?
|
482
|
-
msg << "\nUsage: #{banner(command).
|
483
|
-
|
524
|
+
msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\""
|
525
|
+
raise InvocationError, msg
|
526
|
+
end
|
527
|
+
|
528
|
+
# A flag that makes the process exit with status 1 if any error happens.
|
529
|
+
def exit_on_failure?
|
530
|
+
Bundler::Thor.deprecation_warning "Bundler::Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `#{self.name}`"
|
531
|
+
false
|
484
532
|
end
|
485
533
|
|
486
534
|
protected
|
@@ -513,14 +561,13 @@ class Bundler::Thor
|
|
513
561
|
padding = options.map { |o| o.aliases.size }.max.to_i * 4
|
514
562
|
|
515
563
|
options.each do |option|
|
516
|
-
|
517
|
-
|
518
|
-
|
564
|
+
next if option.hide
|
565
|
+
item = [option.usage(padding)]
|
566
|
+
item.push(option.description ? "# #{option.description}" : "")
|
519
567
|
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
end
|
568
|
+
list << item
|
569
|
+
list << ["", "# Default: #{option.default}"] if option.show_default?
|
570
|
+
list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum
|
524
571
|
end
|
525
572
|
|
526
573
|
shell.say(group_name ? "#{group_name} options:" : "Options:")
|
@@ -531,7 +578,7 @@ class Bundler::Thor
|
|
531
578
|
# Raises an error if the word given is a Bundler::Thor reserved word.
|
532
579
|
def is_thor_reserved_word?(word, type) #:nodoc:
|
533
580
|
return false unless THOR_RESERVED_WORDS.include?(word.to_s)
|
534
|
-
|
581
|
+
raise "#{word.inspect} is a Bundler::Thor reserved word and cannot be defined as #{type}"
|
535
582
|
end
|
536
583
|
|
537
584
|
# Build an option and adds it to the given scope.
|
@@ -541,7 +588,7 @@ class Bundler::Thor
|
|
541
588
|
# options<Hash>:: Described in both class_option and method_option.
|
542
589
|
# scope<Hash>:: Options hash that is being built up
|
543
590
|
def build_option(name, options, scope) #:nodoc:
|
544
|
-
scope[name] = Bundler::Thor::Option.new(name, options)
|
591
|
+
scope[name] = Bundler::Thor::Option.new(name, {:check_default_type => check_default_type}.merge!(options))
|
545
592
|
end
|
546
593
|
|
547
594
|
# Receives a hash of options, parse them and add to the scope. This is a
|
@@ -566,7 +613,7 @@ class Bundler::Thor
|
|
566
613
|
elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
|
567
614
|
commands[name.to_s] = command.clone
|
568
615
|
else
|
569
|
-
|
616
|
+
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
|
570
617
|
end
|
571
618
|
end
|
572
619
|
alias_method :find_and_refresh_task, :find_and_refresh_command
|
@@ -574,13 +621,15 @@ class Bundler::Thor
|
|
574
621
|
# Everytime someone inherits from a Bundler::Thor class, register the klass
|
575
622
|
# and file into baseclass.
|
576
623
|
def inherited(klass)
|
624
|
+
super(klass)
|
577
625
|
Bundler::Thor::Base.register_klass_file(klass)
|
578
|
-
klass.instance_variable_set(:@no_commands,
|
626
|
+
klass.instance_variable_set(:@no_commands, 0)
|
579
627
|
end
|
580
628
|
|
581
629
|
# Fire this callback whenever a method is added. Added methods are
|
582
630
|
# tracked as commands by invoking the create_command method.
|
583
631
|
def method_added(meth)
|
632
|
+
super(meth)
|
584
633
|
meth = meth.to_s
|
585
634
|
|
586
635
|
if meth == "initialize"
|
@@ -591,8 +640,7 @@ class Bundler::Thor
|
|
591
640
|
# Return if it's not a public instance method
|
592
641
|
return unless public_method_defined?(meth.to_sym)
|
593
642
|
|
594
|
-
|
595
|
-
return if @no_commands || !create_command(meth)
|
643
|
+
return if no_commands? || !create_command(meth)
|
596
644
|
|
597
645
|
is_thor_reserved_word?(meth, :command)
|
598
646
|
Bundler::Thor::Base.register_klass_file(self)
|
@@ -619,11 +667,6 @@ class Bundler::Thor
|
|
619
667
|
end
|
620
668
|
end
|
621
669
|
|
622
|
-
# A flag that makes the process exit with status 1 if any error happens.
|
623
|
-
def exit_on_failure?
|
624
|
-
false
|
625
|
-
end
|
626
|
-
|
627
670
|
#
|
628
671
|
# The basename of the program invoking the thor class.
|
629
672
|
#
|
@@ -649,7 +692,7 @@ class Bundler::Thor
|
|
649
692
|
|
650
693
|
# SIGNATURE: The hook invoked by start.
|
651
694
|
def dispatch(command, given_args, given_opts, config) #:nodoc:
|
652
|
-
|
695
|
+
raise NotImplementedError
|
653
696
|
end
|
654
697
|
end
|
655
698
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Bundler::Thor
|
2
|
-
class Command < Struct.new(:name, :description, :long_description, :usage, :options)
|
2
|
+
class Command < Struct.new(:name, :description, :long_description, :usage, :options, :ancestor_name)
|
3
3
|
FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
|
4
4
|
|
5
5
|
def initialize(name, description, long_description, usage, options = nil)
|
@@ -33,38 +33,48 @@ class Bundler::Thor
|
|
33
33
|
rescue ArgumentError => e
|
34
34
|
handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)
|
35
35
|
rescue NoMethodError => e
|
36
|
-
handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (
|
36
|
+
handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (raise e)
|
37
37
|
end
|
38
38
|
|
39
39
|
# Returns the formatted usage by injecting given required arguments
|
40
40
|
# and required options into the given usage.
|
41
41
|
def formatted_usage(klass, namespace = true, subcommand = false)
|
42
|
-
if
|
42
|
+
if ancestor_name
|
43
|
+
formatted = "#{ancestor_name} ".dup # add space
|
44
|
+
elsif namespace
|
43
45
|
namespace = klass.namespace
|
44
|
-
formatted = "#{namespace.gsub(/^(default)/, '')}:"
|
46
|
+
formatted = "#{namespace.gsub(/^(default)/, '')}:".dup
|
45
47
|
end
|
46
|
-
formatted
|
48
|
+
formatted ||= "#{klass.namespace.split(':').last} ".dup if subcommand
|
47
49
|
|
48
|
-
formatted ||= ""
|
50
|
+
formatted ||= "".dup
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
usage.to_s.gsub(/^#{name}/) do |match|
|
53
|
-
match << " " << klass.arguments.map { |a| a.usage }.compact.join(" ")
|
54
|
-
end
|
55
|
-
else
|
56
|
-
usage.to_s
|
57
|
-
end
|
52
|
+
Array(usage).map do |specific_usage|
|
53
|
+
formatted_specific_usage = formatted
|
58
54
|
|
59
|
-
|
60
|
-
formatted << " #{required_options}"
|
55
|
+
formatted_specific_usage += required_arguments_for(klass, specific_usage)
|
61
56
|
|
62
|
-
|
63
|
-
|
57
|
+
# Add required options
|
58
|
+
formatted_specific_usage += " #{required_options}"
|
59
|
+
|
60
|
+
# Strip and go!
|
61
|
+
formatted_specific_usage.strip
|
62
|
+
end.join("\n")
|
64
63
|
end
|
65
64
|
|
66
65
|
protected
|
67
66
|
|
67
|
+
# Add usage with required arguments
|
68
|
+
def required_arguments_for(klass, usage)
|
69
|
+
if klass && !klass.arguments.empty?
|
70
|
+
usage.to_s.gsub(/^#{name}/) do |match|
|
71
|
+
match << " " << klass.arguments.map(&:usage).compact.join(" ")
|
72
|
+
end
|
73
|
+
else
|
74
|
+
usage.to_s
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
68
78
|
def not_debugging?(instance)
|
69
79
|
!(instance.class.respond_to?(:debugging) && instance.class.debugging)
|
70
80
|
end
|
@@ -88,15 +98,14 @@ class Bundler::Thor
|
|
88
98
|
end
|
89
99
|
|
90
100
|
def sans_backtrace(backtrace, caller) #:nodoc:
|
91
|
-
saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) || (frame =~
|
101
|
+
saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) || (frame =~ %r{^kernel/} && RUBY_ENGINE =~ /rbx/) }
|
92
102
|
saned - caller
|
93
103
|
end
|
94
104
|
|
95
105
|
def handle_argument_error?(instance, error, caller)
|
96
106
|
not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
|
97
107
|
saned = sans_backtrace(error.backtrace, caller)
|
98
|
-
|
99
|
-
saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
|
108
|
+
saned.empty? || saned.size == 1
|
100
109
|
end
|
101
110
|
end
|
102
111
|
|
@@ -105,7 +114,7 @@ class Bundler::Thor
|
|
105
114
|
error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
|
106
115
|
end
|
107
116
|
end
|
108
|
-
Task = Command
|
117
|
+
Task = Command
|
109
118
|
|
110
119
|
# A command that is hidden in help messages but still invocable.
|
111
120
|
class HiddenCommand < Command
|
@@ -113,7 +122,7 @@ class Bundler::Thor
|
|
113
122
|
true
|
114
123
|
end
|
115
124
|
end
|
116
|
-
HiddenTask = HiddenCommand
|
125
|
+
HiddenTask = HiddenCommand
|
117
126
|
|
118
127
|
# A dynamic command that handles method missing scenarios.
|
119
128
|
class DynamicCommand < Command
|
@@ -129,5 +138,5 @@ class Bundler::Thor
|
|
129
138
|
end
|
130
139
|
end
|
131
140
|
end
|
132
|
-
DynamicTask = DynamicCommand
|
141
|
+
DynamicTask = DynamicCommand
|
133
142
|
end
|