toys-core 0.11.4 → 0.11.5
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 +4 -4
 - data/CHANGELOG.md +8 -2
 - data/lib/toys/core.rb +1 -1
 - data/lib/toys/standard_mixins/bundler.rb +5 -1
 - data/lib/toys/standard_mixins/exec.rb +10 -1
 - data/lib/toys/utils/exec.rb +8 -5
 - data/lib/toys/utils/gems.rb +15 -8
 - metadata +5 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ae396604e3a0005b460ad94f95187b603f36e8d10d1147da2a78b069232f7963
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 267209d6e7ab4575053219eee5fb1c6be47b9bd6ac6468b6da5c9abb9ed227c2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 527f51e0e679f93786ecd671ff14386615e2014e0dbd4995fd4bb6e58040cb00b27d83d3721c412eb8cc83fdc82fe7dff63c97e0e3d8bca8f8b8d7b04a5d9f41
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 07c617895710b6f5dd69c6fdb16613c2ed7474361a1cbd8617ae1d271eca647ffa457e77bec7e1b30915b1e01ad25173c74251f1728f261a5d5565ca29b80d68
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,16 +1,22 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Release History
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ### v0.11.5 / 2021-03-28
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * BREAKING CHANGE: The exit_on_nonzero_status option to exec now exits on signals and failures to spawn, in addition to error codes.
         
     | 
| 
      
 6 
     | 
    
         
            +
            * ADDED: Support retries in the bundler integration.
         
     | 
| 
      
 7 
     | 
    
         
            +
            * FIXED: Fix a bundler 2.2 integration issue that fails install in certain cases when an update is needed.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       3 
9 
     | 
    
         
             
            ### v0.11.4 / 2020-10-11
         
     | 
| 
       4 
10 
     | 
    
         | 
| 
       5 
11 
     | 
    
         
             
            * FIXED: Doesn't modify bundler lockfiles when adding Toys to a bundle
         
     | 
| 
       6 
12 
     | 
    
         | 
| 
       7 
13 
     | 
    
         
             
            ### v0.11.3 / 2020-09-13
         
     | 
| 
       8 
14 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            * FIXED: The Exec library recognizes the argv0 option, and logs it appropriately 
     | 
| 
      
 15 
     | 
    
         
            +
            * FIXED: The Exec library recognizes the argv0 option, and logs it appropriately
         
     | 
| 
       10 
16 
     | 
    
         | 
| 
       11 
17 
     | 
    
         
             
            ### v0.11.2 / 2020-09-06
         
     | 
| 
       12 
18 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            * FIXED: Fix a JRuby-specific race condition when capturing exec streams 
     | 
| 
      
 19 
     | 
    
         
            +
            * FIXED: Fix a JRuby-specific race condition when capturing exec streams
         
     | 
| 
       14 
20 
     | 
    
         | 
| 
       15 
21 
     | 
    
         
             
            ### v0.11.1 / 2020-08-24
         
     | 
| 
       16 
22 
     | 
    
         | 
    
        data/lib/toys/core.rb
    CHANGED
    
    
| 
         @@ -57,6 +57,9 @@ module Toys 
     | 
|
| 
       57 
57 
     | 
    
         
             
                #      *  `:ignore` - just silently proceed without bundling again.
         
     | 
| 
       58 
58 
     | 
    
         
             
                #      *  `:warn` - print a warning and proceed without bundling again.
         
     | 
| 
       59 
59 
     | 
    
         
             
                #
         
     | 
| 
      
 60 
     | 
    
         
            +
                #  *  `:retries` (Integer) Number of times to retry bundler operations
         
     | 
| 
      
 61 
     | 
    
         
            +
                #     (optional)
         
     | 
| 
      
 62 
     | 
    
         
            +
                #
         
     | 
| 
       60 
63 
     | 
    
         
             
                #  *  `:terminal` (Toys::Utils::Terminal) Terminal to use (optional)
         
     | 
| 
       61 
64 
     | 
    
         
             
                #  *  `:input` (IO) Input IO (optional, defaults to STDIN)
         
     | 
| 
       62 
65 
     | 
    
         
             
                #  *  `:output` (IO) Output IO (optional, defaults to STDOUT)
         
     | 
| 
         @@ -100,6 +103,7 @@ module Toys 
     | 
|
| 
       100 
103 
     | 
    
         
             
                                        groups: nil,
         
     | 
| 
       101 
104 
     | 
    
         
             
                                        on_missing: nil,
         
     | 
| 
       102 
105 
     | 
    
         
             
                                        on_conflict: nil,
         
     | 
| 
      
 106 
     | 
    
         
            +
                                        retries: nil,
         
     | 
| 
       103 
107 
     | 
    
         
             
                                        terminal: nil,
         
     | 
| 
       104 
108 
     | 
    
         
             
                                        input: nil,
         
     | 
| 
       105 
109 
     | 
    
         
             
                                        output: nil)
         
     | 
| 
         @@ -111,7 +115,7 @@ module Toys 
     | 
|
| 
       111 
115 
     | 
    
         
             
                    end
         
     | 
| 
       112 
116 
     | 
    
         
             
                    gems = ::Toys::Utils::Gems.new(on_missing: on_missing, on_conflict: on_conflict,
         
     | 
| 
       113 
117 
     | 
    
         
             
                                                   terminal: terminal, input: input, output: output)
         
     | 
| 
       114 
     | 
    
         
            -
                    gems.bundle(groups: groups, gemfile_path: gemfile_path)
         
     | 
| 
      
 118 
     | 
    
         
            +
                    gems.bundle(groups: groups, gemfile_path: gemfile_path, retries: retries)
         
     | 
| 
       115 
119 
     | 
    
         
             
                  end
         
     | 
| 
       116 
120 
     | 
    
         | 
| 
       117 
121 
     | 
    
         
             
                  # @private
         
     | 
| 
         @@ -708,7 +708,16 @@ module Toys 
     | 
|
| 
       708 
708 
     | 
    
         | 
| 
       709 
709 
     | 
    
         
             
                  ## @private
         
     | 
| 
       710 
710 
     | 
    
         
             
                  def self._interpret_e(value, context)
         
     | 
| 
       711 
     | 
    
         
            -
                     
     | 
| 
      
 711 
     | 
    
         
            +
                    return nil unless value
         
     | 
| 
      
 712 
     | 
    
         
            +
                    proc do |result|
         
     | 
| 
      
 713 
     | 
    
         
            +
                      if result.failed?
         
     | 
| 
      
 714 
     | 
    
         
            +
                        context.exit(127)
         
     | 
| 
      
 715 
     | 
    
         
            +
                      elsif result.signaled?
         
     | 
| 
      
 716 
     | 
    
         
            +
                        context.exit(result.signal_code + 128)
         
     | 
| 
      
 717 
     | 
    
         
            +
                      elsif result.error?
         
     | 
| 
      
 718 
     | 
    
         
            +
                        context.exit(result.exit_code)
         
     | 
| 
      
 719 
     | 
    
         
            +
                      end
         
     | 
| 
      
 720 
     | 
    
         
            +
                    end
         
     | 
| 
       712 
721 
     | 
    
         
             
                  end
         
     | 
| 
       713 
722 
     | 
    
         | 
| 
       714 
723 
     | 
    
         
             
                  ## @private
         
     | 
    
        data/lib/toys/utils/exec.rb
    CHANGED
    
    | 
         @@ -797,7 +797,7 @@ module Toys 
     | 
|
| 
       797 
797 
     | 
    
         
             
                  #     {Result#success?} or {Result#error?} will return true, and
         
     | 
| 
       798 
798 
     | 
    
         
             
                  #     {Result.exit_code} will return the numeric exit code.
         
     | 
| 
       799 
799 
     | 
    
         
             
                  #  *  The process executed but was terminated by an uncaught signal.
         
     | 
| 
       800 
     | 
    
         
            -
                  #     {Result#signaled?} will return true, and {Result# 
     | 
| 
      
 800 
     | 
    
         
            +
                  #     {Result#signaled?} will return true, and {Result#signal_code} will
         
     | 
| 
       801 
801 
     | 
    
         
             
                  #     return the numeric signal code.
         
     | 
| 
       802 
802 
     | 
    
         
             
                  #
         
     | 
| 
       803 
803 
     | 
    
         
             
                  class Result
         
     | 
| 
         @@ -849,6 +849,8 @@ module Toys 
     | 
|
| 
       849 
849 
     | 
    
         
             
                    # The exception raised if a process couldn't be started.
         
     | 
| 
       850 
850 
     | 
    
         
             
                    #
         
     | 
| 
       851 
851 
     | 
    
         
             
                    # Exactly one of {#exception} and {#status} will be non-nil.
         
     | 
| 
      
 852 
     | 
    
         
            +
                    # Exactly one of {#exception}, {#exit_code}, or {#signal_code} will be
         
     | 
| 
      
 853 
     | 
    
         
            +
                    # non-nil.
         
     | 
| 
       852 
854 
     | 
    
         
             
                    #
         
     | 
| 
       853 
855 
     | 
    
         
             
                    # @return [Exception] The exception raised from process start.
         
     | 
| 
       854 
856 
     | 
    
         
             
                    # @return [nil] if the process started successfully.
         
     | 
| 
         @@ -858,7 +860,7 @@ module Toys 
     | 
|
| 
       858 
860 
     | 
    
         
             
                    ##
         
     | 
| 
       859 
861 
     | 
    
         
             
                    # The numeric status code for a process that exited normally,
         
     | 
| 
       860 
862 
     | 
    
         
             
                    #
         
     | 
| 
       861 
     | 
    
         
            -
                    # Exactly one of {#exception}, {#exit_code},  
     | 
| 
      
 863 
     | 
    
         
            +
                    # Exactly one of {#exception}, {#exit_code}, or {#signal_code} will be
         
     | 
| 
       862 
864 
     | 
    
         
             
                    # non-nil.
         
     | 
| 
       863 
865 
     | 
    
         
             
                    #
         
     | 
| 
       864 
866 
     | 
    
         
             
                    # @return [Integer] the numeric status code, if the process started
         
     | 
| 
         @@ -873,16 +875,17 @@ module Toys 
     | 
|
| 
       873 
875 
     | 
    
         
             
                    ##
         
     | 
| 
       874 
876 
     | 
    
         
             
                    # The numeric signal code that caused process termination.
         
     | 
| 
       875 
877 
     | 
    
         
             
                    #
         
     | 
| 
       876 
     | 
    
         
            -
                    # Exactly one of {#exception}, {#exit_code},  
     | 
| 
      
 878 
     | 
    
         
            +
                    # Exactly one of {#exception}, {#exit_code}, or {#signal_code} will be
         
     | 
| 
       877 
879 
     | 
    
         
             
                    # non-nil.
         
     | 
| 
       878 
880 
     | 
    
         
             
                    #
         
     | 
| 
       879 
881 
     | 
    
         
             
                    # @return [Integer] The signal that caused the process to terminate.
         
     | 
| 
       880 
882 
     | 
    
         
             
                    # @return [nil] if the process did not start successfully, or executed
         
     | 
| 
       881 
883 
     | 
    
         
             
                    #     and exited with a normal exit code.
         
     | 
| 
       882 
884 
     | 
    
         
             
                    #
         
     | 
| 
       883 
     | 
    
         
            -
                    def  
     | 
| 
      
 885 
     | 
    
         
            +
                    def signal_code
         
     | 
| 
       884 
886 
     | 
    
         
             
                      status&.termsig
         
     | 
| 
       885 
887 
     | 
    
         
             
                    end
         
     | 
| 
      
 888 
     | 
    
         
            +
                    alias term_signal signal_code
         
     | 
| 
       886 
889 
     | 
    
         | 
| 
       887 
890 
     | 
    
         
             
                    ##
         
     | 
| 
       888 
891 
     | 
    
         
             
                    # Returns true if the subprocess failed to start, or false if the
         
     | 
| 
         @@ -901,7 +904,7 @@ module Toys 
     | 
|
| 
       901 
904 
     | 
    
         
             
                    # @return [Boolean]
         
     | 
| 
       902 
905 
     | 
    
         
             
                    #
         
     | 
| 
       903 
906 
     | 
    
         
             
                    def signaled?
         
     | 
| 
       904 
     | 
    
         
            -
                      ! 
     | 
| 
      
 907 
     | 
    
         
            +
                      !signal_code.nil?
         
     | 
| 
       905 
908 
     | 
    
         
             
                    end
         
     | 
| 
       906 
909 
     | 
    
         | 
| 
       907 
910 
     | 
    
         
             
                    ##
         
     | 
    
        data/lib/toys/utils/gems.rb
    CHANGED
    
    | 
         @@ -170,12 +170,16 @@ module Toys 
     | 
|
| 
       170 
170 
     | 
    
         
             
                  #     recognized as Gemfiles, when searching because gemfile_path is not
         
     | 
| 
       171 
171 
     | 
    
         
             
                  #     given. Defaults to {DEFAULT_GEMFILE_NAMES}.
         
     | 
| 
       172 
172 
     | 
    
         
             
                  #
         
     | 
| 
      
 173 
     | 
    
         
            +
                  # @param retries [Integer] Number of times to retry bundler operations.
         
     | 
| 
      
 174 
     | 
    
         
            +
                  #     Optional.
         
     | 
| 
      
 175 
     | 
    
         
            +
                  #
         
     | 
| 
       173 
176 
     | 
    
         
             
                  # @return [void]
         
     | 
| 
       174 
177 
     | 
    
         
             
                  #
         
     | 
| 
       175 
178 
     | 
    
         
             
                  def bundle(groups: nil,
         
     | 
| 
       176 
179 
     | 
    
         
             
                             gemfile_path: nil,
         
     | 
| 
       177 
180 
     | 
    
         
             
                             search_dirs: nil,
         
     | 
| 
       178 
     | 
    
         
            -
                             gemfile_names: nil 
     | 
| 
      
 181 
     | 
    
         
            +
                             gemfile_names: nil,
         
     | 
| 
      
 182 
     | 
    
         
            +
                             retries: nil)
         
     | 
| 
       179 
183 
     | 
    
         
             
                    Array(search_dirs).each do |dir|
         
     | 
| 
       180 
184 
     | 
    
         
             
                      break if gemfile_path
         
     | 
| 
       181 
185 
     | 
    
         
             
                      gemfile_path = Gems.find_gemfile(dir, gemfile_names: gemfile_names)
         
     | 
| 
         @@ -186,7 +190,7 @@ module Toys 
     | 
|
| 
       186 
190 
     | 
    
         
             
                        activate("bundler", "~> 2.1")
         
     | 
| 
       187 
191 
     | 
    
         
             
                        require "bundler"
         
     | 
| 
       188 
192 
     | 
    
         
             
                        lockfile_path = find_lockfile_path(gemfile_path)
         
     | 
| 
       189 
     | 
    
         
            -
                        setup_bundle(gemfile_path, lockfile_path, groups  
     | 
| 
      
 193 
     | 
    
         
            +
                        setup_bundle(gemfile_path, lockfile_path, groups: groups, retries: retries)
         
     | 
| 
       190 
194 
     | 
    
         
             
                      end
         
     | 
| 
       191 
195 
     | 
    
         
             
                    end
         
     | 
| 
       192 
196 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -296,14 +300,15 @@ module Toys 
     | 
|
| 
       296 
300 
     | 
    
         
             
                    end
         
     | 
| 
       297 
301 
     | 
    
         
             
                  end
         
     | 
| 
       298 
302 
     | 
    
         | 
| 
       299 
     | 
    
         
            -
                  def setup_bundle(gemfile_path, lockfile_path, groups)
         
     | 
| 
      
 303 
     | 
    
         
            +
                  def setup_bundle(gemfile_path, lockfile_path, groups: nil, retries: nil)
         
     | 
| 
      
 304 
     | 
    
         
            +
                    groups = Array(groups)
         
     | 
| 
       300 
305 
     | 
    
         
             
                    old_lockfile_contents = save_old_lockfile(lockfile_path)
         
     | 
| 
       301 
306 
     | 
    
         
             
                    begin
         
     | 
| 
       302 
307 
     | 
    
         
             
                      modify_bundle_definition(gemfile_path, lockfile_path)
         
     | 
| 
       303 
308 
     | 
    
         
             
                      ::Bundler.ui.silence { ::Bundler.setup(*groups) }
         
     | 
| 
       304 
309 
     | 
    
         
             
                    rescue ::Bundler::GemNotFound, ::Bundler::VersionConflict
         
     | 
| 
       305 
310 
     | 
    
         
             
                      restore_toys_libs
         
     | 
| 
       306 
     | 
    
         
            -
                      install_bundle(gemfile_path)
         
     | 
| 
      
 311 
     | 
    
         
            +
                      install_bundle(gemfile_path, retries: retries)
         
     | 
| 
       307 
312 
     | 
    
         
             
                      old_lockfile_contents = save_old_lockfile(lockfile_path)
         
     | 
| 
       308 
313 
     | 
    
         
             
                      ::Bundler.reset!
         
     | 
| 
       309 
314 
     | 
    
         
             
                      modify_bundle_definition(gemfile_path, lockfile_path)
         
     | 
| 
         @@ -383,19 +388,21 @@ module Toys 
     | 
|
| 
       383 
388 
     | 
    
         
             
                    end
         
     | 
| 
       384 
389 
     | 
    
         
             
                  end
         
     | 
| 
       385 
390 
     | 
    
         | 
| 
       386 
     | 
    
         
            -
                  def install_bundle(gemfile_path)
         
     | 
| 
      
 391 
     | 
    
         
            +
                  def install_bundle(gemfile_path, retries: nil)
         
     | 
| 
       387 
392 
     | 
    
         
             
                    gemfile_dir = ::File.dirname(gemfile_path)
         
     | 
| 
       388 
393 
     | 
    
         
             
                    unless permission_to_bundle?
         
     | 
| 
       389 
394 
     | 
    
         
             
                      raise BundleNotInstalledError,
         
     | 
| 
       390 
395 
     | 
    
         
             
                            "Your bundle is not installed. Consider running" \
         
     | 
| 
       391 
396 
     | 
    
         
             
                              " `cd #{gemfile_dir} && bundle install`"
         
     | 
| 
       392 
397 
     | 
    
         
             
                    end
         
     | 
| 
      
 398 
     | 
    
         
            +
                    retries = retries.to_i
         
     | 
| 
      
 399 
     | 
    
         
            +
                    args = retries.positive? ? ["--retry=#{retries}"] : []
         
     | 
| 
       393 
400 
     | 
    
         
             
                    require "bundler/cli"
         
     | 
| 
       394 
401 
     | 
    
         
             
                    begin
         
     | 
| 
       395 
     | 
    
         
            -
                      ::Bundler::CLI.start(["install"])
         
     | 
| 
       396 
     | 
    
         
            -
                    rescue ::Bundler::GemNotFound, ::Bundler::InstallError
         
     | 
| 
      
 402 
     | 
    
         
            +
                      ::Bundler::CLI.start(["install"] + args)
         
     | 
| 
      
 403 
     | 
    
         
            +
                    rescue ::Bundler::GemNotFound, ::Bundler::InstallError, ::Bundler::VersionConflict
         
     | 
| 
       397 
404 
     | 
    
         
             
                      terminal.puts("Failed to install. Trying update...")
         
     | 
| 
       398 
     | 
    
         
            -
                      ::Bundler::CLI.start(["update"])
         
     | 
| 
      
 405 
     | 
    
         
            +
                      ::Bundler::CLI.start(["update"] + args)
         
     | 
| 
       399 
406 
     | 
    
         
             
                    end
         
     | 
| 
       400 
407 
     | 
    
         
             
                  end
         
     | 
| 
       401 
408 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: toys-core
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.11. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.11.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Daniel Azuma
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-03-28 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: Toys-Core is the command line tool framework underlying Toys. It can
         
     | 
| 
       14 
14 
     | 
    
         
             
              be used to create command line executables using the Toys DSL and classes.
         
     | 
| 
         @@ -69,10 +69,10 @@ homepage: https://github.com/dazuma/toys 
     | 
|
| 
       69 
69 
     | 
    
         
             
            licenses:
         
     | 
| 
       70 
70 
     | 
    
         
             
            - MIT
         
     | 
| 
       71 
71 
     | 
    
         
             
            metadata:
         
     | 
| 
       72 
     | 
    
         
            -
              changelog_uri: https://dazuma.github.io/toys/gems/toys-core/v0.11. 
     | 
| 
       73 
     | 
    
         
            -
              source_code_uri: https://github.com/dazuma/toys
         
     | 
| 
      
 72 
     | 
    
         
            +
              changelog_uri: https://dazuma.github.io/toys/gems/toys-core/v0.11.5/file.CHANGELOG.html
         
     | 
| 
      
 73 
     | 
    
         
            +
              source_code_uri: https://github.com/dazuma/toys/tree/main/toys-core
         
     | 
| 
       74 
74 
     | 
    
         
             
              bug_tracker_uri: https://github.com/dazuma/toys/issues
         
     | 
| 
       75 
     | 
    
         
            -
              documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.11. 
     | 
| 
      
 75 
     | 
    
         
            +
              documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.11.5
         
     | 
| 
       76 
76 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       77 
77 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       78 
78 
     | 
    
         
             
            require_paths:
         
     |