squared 0.2.2 → 0.2.4
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 +17 -1
- data/README.ruby.md +6 -6
- data/lib/squared/common/format.rb +1 -1
- data/lib/squared/common/shell.rb +6 -1
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/project/base.rb +4 -8
- data/lib/squared/workspace/project/git.rb +7 -6
- data/lib/squared/workspace/project/python.rb +33 -44
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a1aedaf9ac684379d28ad4e69449ada34e1e04a1b5241607e29c1142b8ad759d
         | 
| 4 | 
            +
              data.tar.gz: 3d13f6d09a48cf2e394ec4497e5c838d69f4eb7cde83df4811059c0e743e029c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 16928495ed31d6e0ea9876ff0ce6aef9366e98324a96bceffe99e3d7b60ee0eabc863b8846443947342164166047476d68eab992102dc7143ace991fad3b7575
         | 
| 7 | 
            +
              data.tar.gz: 151c60e043f2129f0d84bf04a36531d9131e5a2abcec244311d22e03b23b2b4810b1d24e14663724acf3b25d2a5f3bd166577a294f419a427a0602db9bddabe1
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,19 @@ | |
| 1 1 | 
             
            # Changelog
         | 
| 2 2 |  | 
| 3 | 
            +
            ## [0.2.4] - 2025-02-12
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ### Fixed
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            - Git status did not show ignored or untracked files.
         | 
| 8 | 
            +
            - Caller locations were not compatible with Ruby 2.4.
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ## [0.2.3] - 2025-02-05
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ### Fixed
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             - Project hash options duplicated dash prefix.
         | 
| 15 | 
            +
             - Pip upgrade did not append package names.
         | 
| 16 | 
            +
             | 
| 3 17 | 
             
            ## [0.2.2] - 2025-01-19
         | 
| 4 18 |  | 
| 5 19 | 
             
            ### Fixed
         | 
| @@ -55,7 +69,7 @@ | |
| 55 69 | 
             
            - Gem install and update non-deprecated options are fully complete.
         | 
| 56 70 | 
             
            - Pip install options are fully complete.
         | 
| 57 71 | 
             
            - Node command bump action version was implemented.
         | 
| 58 | 
            -
            - Node command add was implemented. | 
| 72 | 
            +
            - Node command add was implemented.
         | 
| 59 73 | 
             
            - Python command install can use single character options.
         | 
| 60 74 | 
             
            - Gem install and pristine options are fully complete.
         | 
| 61 75 | 
             
            - Gem command outdated was implemented.
         | 
| @@ -169,6 +183,8 @@ | |
| 169 183 |  | 
| 170 184 | 
             
            - Changelog was created.
         | 
| 171 185 |  | 
| 186 | 
            +
            [0.2.4]: https://github.com/anpham6/squared/releases/tag/v0.2.4-ruby
         | 
| 187 | 
            +
            [0.2.3]: https://github.com/anpham6/squared/releases/tag/v0.2.3-ruby
         | 
| 172 188 | 
             
            [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
         | 
| 173 189 | 
             
            [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
         | 
| 174 190 | 
             
            [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
         | 
    
        data/README.ruby.md
    CHANGED
    
    | @@ -335,16 +335,16 @@ Common::PATH.merge!({ | |
| 335 335 | 
             
            # :env                                         :run           :opts
         | 
| 336 336 | 
             
            # LD_LIBRARY_PATH="path/to/lib" CFLAGS="-Wall" gcc a.c -o a.o -c
         | 
| 337 337 | 
             
            BUILD_${NAME}      # gcc a.c -o a.o
         | 
| 338 | 
            -
             | 
| 339 | 
            -
             | 
| 338 | 
            +
            BUILD_${NAME}_OPTS # -c
         | 
| 339 | 
            +
            BUILD_${NAME}_ENV  # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
         | 
| 340 340 |  | 
| 341 341 | 
             
            # :env                                       :opts                               :script
         | 
| 342 342 | 
             
            # NODE_ENV="production" NO_COLOR="1" npm run --loglevel=error --workspaces=false build:dev
         | 
| 343 343 | 
             
            BUILD_${NAME}      # build:dev
         | 
| 344 | 
            -
             | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 344 | 
            +
            BUILD_${NAME}_OPTS # --loglevel=error --workspaces=false
         | 
| 345 | 
            +
            BUILD_${NAME}_ENV  # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
         | 
| 346 | 
            +
            BUILD_${NAME}_DEV  # pattern,0,1 (:dev)
         | 
| 347 | 
            +
            BUILD_${NAME}_PROD # pattern,0,1 (:prod)
         | 
| 348 348 |  | 
| 349 349 | 
             
            BUILD_${NAME}=0    # skip project
         | 
| 350 350 | 
             
            ```
         | 
| @@ -279,7 +279,7 @@ module Squared | |
| 279 279 | 
             
                  end
         | 
| 280 280 |  | 
| 281 281 | 
             
                  def raise_error(*args, hint: nil, kind: ArgumentError)
         | 
| 282 | 
            -
                    raise kind, message(*args, hint: hint, empty: true), caller_locations(1)
         | 
| 282 | 
            +
                    raise kind, message(*args, hint: hint, empty: true), caller_locations(1).map(&:to_s)
         | 
| 283 283 | 
             
                  end
         | 
| 284 284 | 
             
                end
         | 
| 285 285 | 
             
              end
         | 
    
        data/lib/squared/common/shell.rb
    CHANGED
    
    | @@ -40,7 +40,12 @@ module Squared | |
| 40 40 | 
             
                  end
         | 
| 41 41 |  | 
| 42 42 | 
             
                  def shell_option(flag, val = nil, escape: true, quote: true)
         | 
| 43 | 
            -
                     | 
| 43 | 
            +
                    flag = flag.to_s
         | 
| 44 | 
            +
                    if flag[0] == '-'
         | 
| 45 | 
            +
                      b = flag[1] == '-' ? '=' : ' '
         | 
| 46 | 
            +
                    else
         | 
| 47 | 
            +
                      a, b = flag.size == 1 ? ['-', ' '] : ['--', '=']
         | 
| 48 | 
            +
                    end
         | 
| 44 49 | 
             
                    "#{a}#{flag}#{if val
         | 
| 45 50 | 
             
                                    "#{b}#{if escape
         | 
| 46 51 | 
             
                                             shell_escape(val, quote: quote)
         | 
    
        data/lib/squared/version.rb
    CHANGED
    
    
| @@ -992,21 +992,17 @@ module Squared | |
| 992 992 | 
             
                    def append_hash(opts, target: @session)
         | 
| 993 993 | 
             
                      out = target.to_s
         | 
| 994 994 | 
             
                      opts.each do |key, val|
         | 
| 995 | 
            -
                         | 
| 996 | 
            -
                        key = shell_option(key) unless key[0] == '-'
         | 
| 997 | 
            -
                        next if out =~ Regexp.new(" #{key}(?: |=|$)")
         | 
| 995 | 
            +
                        next if out =~ / #{Regexp.escape(shell_option(key))}(?: |=|$)/
         | 
| 998 996 |  | 
| 999 997 | 
             
                        case val
         | 
| 1000 | 
            -
                        when String
         | 
| 1001 | 
            -
                          append_repeat(key, [val], target: target)
         | 
| 1002 998 | 
             
                        when Array
         | 
| 1003 999 | 
             
                          append_repeat(key, val, target: target)
         | 
| 1004 1000 | 
             
                        when Numeric
         | 
| 1005 | 
            -
                          target << (key  | 
| 1001 | 
            +
                          target << basic_option(key, val)
         | 
| 1006 1002 | 
             
                        when false
         | 
| 1007 | 
            -
                          target << key.sub(/^--(?!no-)/, '--no-')
         | 
| 1003 | 
            +
                          target << shell_option(key).sub(/^--(?!no-)/, '--no-')
         | 
| 1008 1004 | 
             
                        else
         | 
| 1009 | 
            -
                          target << key
         | 
| 1005 | 
            +
                          target << shell_option(key, val.is_a?(String) ? val : nil)
         | 
| 1010 1006 | 
             
                        end
         | 
| 1011 1007 | 
             
                      end
         | 
| 1012 1008 | 
             
                    end
         | 
| @@ -538,7 +538,8 @@ module Squared | |
| 538 538 | 
             
                    end
         | 
| 539 539 |  | 
| 540 540 | 
             
                    def status(*, sync: invoked_sync?('status'), **)
         | 
| 541 | 
            -
                      cmd = git_session 'status' | 
| 541 | 
            +
                      cmd = git_session 'status'
         | 
| 542 | 
            +
                      cmd << (option('long') ? '--long' : '--short')
         | 
| 542 543 | 
             
                      if (val = option('ignore-submodules', ignore: false))
         | 
| 543 544 | 
             
                        cmd << basic_option('ignore-submodules', case val
         | 
| 544 545 | 
             
                                                                 when '0', 'none'
         | 
| @@ -559,8 +560,8 @@ module Squared | |
| 559 560 | 
             
                      end
         | 
| 560 561 | 
             
                      ret = write_lines(out, banner: banner, sub: if verbose
         | 
| 561 562 | 
             
                                                                    [
         | 
| 562 | 
            -
                                                                      { pat: /^(.)([A-Z])(.+)$/, styles: :red, index: 2 },
         | 
| 563 | 
            -
                                                                      { pat: /^([A-Z])(.+)$/, styles: :green },
         | 
| 563 | 
            +
                                                                      { pat: /^(.)([A-Z?!])(.+)$/, styles: :red, index: 2 },
         | 
| 564 | 
            +
                                                                      { pat: /^([A-Z?!])(.+)$/, styles: :green },
         | 
| 564 565 | 
             
                                                                      { pat: /^(\?\?)(.+)$/, styles: :red },
         | 
| 565 566 | 
             
                                                                      { pat: /^(## )(.+)(\.{3})(.+)$/,
         | 
| 566 567 | 
             
                                                                        styles: [nil, :green, nil, :red], index: -1 }
         | 
| @@ -721,15 +722,15 @@ module Squared | |
| 721 722 | 
             
                      origin = nil
         | 
| 722 723 | 
             
                      branch = nil
         | 
| 723 724 | 
             
                      upstream = nil
         | 
| 724 | 
            -
                      source(git_output('fetch | 
| 725 | 
            -
                      source(git_output('branch | 
| 725 | 
            +
                      source(git_output('fetch --no-tags --quiet'), io: true, banner: false)
         | 
| 726 | 
            +
                      source(git_output('branch -vv --list'), io: true, banner: false).first.each do |val|
         | 
| 726 727 | 
             
                        next unless (data = /^\*\s(\S+)\s+(\h+)(?:\s\[(.+?)(?=\]\s)\])?\s/.match(val))
         | 
| 727 728 |  | 
| 728 729 | 
             
                        branch = data[1]
         | 
| 729 730 | 
             
                        sha = data[2]
         | 
| 730 731 | 
             
                        if !data[3]
         | 
| 731 732 | 
             
                          unless (origin = option('repository', prefix: 'git', ignore: false))
         | 
| 732 | 
            -
                            out = source(git_output('log | 
| 733 | 
            +
                            out = source(git_output('log -n1 --format=%h%d'), io: true, stdout: true, banner: false).first
         | 
| 733 734 | 
             
                            if (data = /^#{sha} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)$/.match(out))
         | 
| 734 735 | 
             
                              split_escape(data[1]).each do |val|
         | 
| 735 736 | 
             
                                next unless val.end_with?("/#{branch}")
         | 
| @@ -4,11 +4,11 @@ module Squared | |
| 4 4 | 
             
              module Workspace
         | 
| 5 5 | 
             
                module Project
         | 
| 6 6 | 
             
                  class Python < Git
         | 
| 7 | 
            -
                    REQUIREMENTS = %w[requirements.txt pyproject.toml | 
| 7 | 
            +
                    REQUIREMENTS = %w[requirements.txt pyproject.toml].freeze
         | 
| 8 8 | 
             
                    OPT_INSTALL = %w[I U break-system-packages check-build-dependencies compile dry-run force-reinstall
         | 
| 9 9 | 
             
                                     ignore-installed ignore-requires-python no-build-isolation no-clean no-compile no-deps
         | 
| 10 10 | 
             
                                     no-index no-warn-conflicts no-warn-script-location pre prefer-binary require-hashes upgrade
         | 
| 11 | 
            -
                                     use-pep517 user abi=s config-settings=s c=s constraint=s e=s editable=s extra-index-url=s
         | 
| 11 | 
            +
                                     use-pep517 user abi=s config-settings=s c=s constraint=s e=s? editable=s? extra-index-url=s
         | 
| 12 12 | 
             
                                     f=s find-links=s global-option=s implementation=s i=s index-url=s no-binary=s only-binary=s
         | 
| 13 13 | 
             
                                     platform=s prefix=s progress-bar=s python-version=s report=s r=s requirement=s
         | 
| 14 14 | 
             
                                     root-user-action=s root=s src=s t=s target=s upgrade-strategy=s].freeze
         | 
| @@ -37,7 +37,7 @@ module Squared | |
| 37 37 | 
             
                      def config?(val)
         | 
| 38 38 | 
             
                        return false unless (val = as_path(val))
         | 
| 39 39 |  | 
| 40 | 
            -
                        REQUIREMENTS.any? { |file| val.join(file).exist? }
         | 
| 40 | 
            +
                        (REQUIREMENTS + ['setup.py']).any? { |file| val.join(file).exist? }
         | 
| 41 41 | 
             
                      end
         | 
| 42 42 | 
             
                    end
         | 
| 43 43 |  | 
| @@ -79,7 +79,7 @@ module Squared | |
| 79 79 | 
             
                                                                                               when :target
         | 
| 80 80 | 
             
                                                                                                 'dir'
         | 
| 81 81 | 
             
                                                                                               when :upgrade
         | 
| 82 | 
            -
                                                                                                 'strategy'
         | 
| 82 | 
            +
                                                                                                 'strategy?,packages+'
         | 
| 83 83 | 
             
                                                                                               end)
         | 
| 84 84 | 
             
                                end
         | 
| 85 85 | 
             
                                case flag
         | 
| @@ -104,47 +104,32 @@ module Squared | |
| 104 104 | 
             
                      if @depend && !flag
         | 
| 105 105 | 
             
                        super
         | 
| 106 106 | 
             
                      elsif outdated?
         | 
| 107 | 
            -
                         | 
| 108 | 
            -
                         | 
| 109 | 
            -
             | 
| 110 | 
            -
                           | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                           | 
| 114 | 
            -
             | 
| 115 | 
            -
                             | 
| 116 | 
            -
                            when 'eager', 'only-if-needed'
         | 
| 117 | 
            -
                              cmd << basic_option('upgrade-strategy', param)
         | 
| 118 | 
            -
                            else
         | 
| 119 | 
            -
                              opts << param
         | 
| 120 | 
            -
                            end
         | 
| 121 | 
            -
                          when :force
         | 
| 122 | 
            -
                            cmd << '--force-reinstall'
         | 
| 123 | 
            -
                          when :target
         | 
| 124 | 
            -
                            cmd << quote_option('target', basepath(param))
         | 
| 107 | 
            +
                        cmd = pip_session 'install'
         | 
| 108 | 
            +
                        case flag
         | 
| 109 | 
            +
                        when :user
         | 
| 110 | 
            +
                          cmd << '--user'
         | 
| 111 | 
            +
                        when :upgrade
         | 
| 112 | 
            +
                          cmd << '--upgrade'
         | 
| 113 | 
            +
                          case param
         | 
| 114 | 
            +
                          when 'eager', 'only-if-needed'
         | 
| 115 | 
            +
                            cmd << basic_option('upgrade-strategy', param)
         | 
| 125 116 | 
             
                          else
         | 
| 126 | 
            -
                             | 
| 117 | 
            +
                            opts << param
         | 
| 127 118 | 
             
                          end
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                           | 
| 119 | 
            +
                        when :force
         | 
| 120 | 
            +
                          cmd << '--force-reinstall'
         | 
| 121 | 
            +
                        when :target
         | 
| 122 | 
            +
                          cmd << quote_option('target', basepath(param))
         | 
| 123 | 
            +
                        else
         | 
| 124 | 
            +
                          append_global
         | 
| 125 | 
            +
                        end
         | 
| 126 | 
            +
                        append_pip flag, opts if flag
         | 
| 127 | 
            +
                        unless flag == :upgrade
         | 
| 128 | 
            +
                          if dependtype == 2 || cmd.find { |val| val =~ /^(?:-e|--editable)$/ }
         | 
| 130 129 | 
             
                            cmd << '.'
         | 
| 131 | 
            -
                          elsif !cmd.find { |val| val =~ /^(?:-r|--requirement)/ }
         | 
| 130 | 
            +
                          elsif !cmd.find { |val| val =~ /^(?:-r|--requirement|-e|--editable)/ }
         | 
| 132 131 | 
             
                            cmd << '-r requirements.txt'
         | 
| 133 132 | 
             
                          end
         | 
| 134 | 
            -
                        when 3
         | 
| 135 | 
            -
                          cmd = python_session 'setup.py', 'install'
         | 
| 136 | 
            -
                          case flag
         | 
| 137 | 
            -
                          when :user
         | 
| 138 | 
            -
                            cmd << '--user'
         | 
| 139 | 
            -
                          when :target
         | 
| 140 | 
            -
                            cmd << quote_option('build-base', basepath(dir))
         | 
| 141 | 
            -
                          end
         | 
| 142 | 
            -
                          if option('user')
         | 
| 143 | 
            -
                            cmd << '--user'
         | 
| 144 | 
            -
                          else
         | 
| 145 | 
            -
                            append_first(%w[home prefix], equals: true, escape: false, quote: true, ignore: false)
         | 
| 146 | 
            -
                          end
         | 
| 147 | 
            -
                          cmd.delete('--user') if workspace.windows?
         | 
| 148 133 | 
             
                        end
         | 
| 149 134 | 
             
                        run(from: :depend, sync: sync)
         | 
| 150 135 | 
             
                      end
         | 
| @@ -256,12 +241,12 @@ module Squared | |
| 256 241 | 
             
                      session('python', *cmd)
         | 
| 257 242 | 
             
                    end
         | 
| 258 243 |  | 
| 259 | 
            -
                    def append_pip( | 
| 244 | 
            +
                    def append_pip(flag, opts, target: @session)
         | 
| 260 245 | 
             
                      append_nocolor(target: target)
         | 
| 261 246 | 
             
                      return if opts.empty?
         | 
| 262 247 |  | 
| 263 248 | 
             
                      out = []
         | 
| 264 | 
            -
                      opts, pat = option_partition(opts,  | 
| 249 | 
            +
                      opts, pat = option_partition(opts, OPT_INSTALL + OPT_GENERAL, target: target)
         | 
| 265 250 | 
             
                      opts.each do |opt|
         | 
| 266 251 | 
             
                        if opt =~ /^(v+|q+)$/
         | 
| 267 252 | 
             
                          cmd << "-#{$1}"
         | 
| @@ -272,7 +257,7 @@ module Squared | |
| 272 257 | 
             
                            target << quote_option($1, basepath($2))
         | 
| 273 258 | 
             
                          when 'e', 'editable'
         | 
| 274 259 | 
             
                            val = $2
         | 
| 275 | 
            -
                            target << quote_option($1, val =~ %r{^[a-z] | 
| 260 | 
            +
                            target << quote_option($1, val =~ %r{^[a-z]+(?:\+[a-z]+)?://}i ? val : basepath(val))
         | 
| 276 261 | 
             
                          when 'proxy', 'config-settings', 'global-option', 'extra-index-url',
         | 
| 277 262 | 
             
                               'f', 'find-links', 'i', 'index-url'
         | 
| 278 263 | 
             
                            target << quote_option($1, $2)
         | 
| @@ -285,7 +270,11 @@ module Squared | |
| 285 270 | 
             
                          out << opt
         | 
| 286 271 | 
             
                        end
         | 
| 287 272 | 
             
                      end
         | 
| 288 | 
            -
                       | 
| 273 | 
            +
                      if flag == :upgrade
         | 
| 274 | 
            +
                        append_value(out, delim: true)
         | 
| 275 | 
            +
                      else
         | 
| 276 | 
            +
                        option_clear(out, target: target)
         | 
| 277 | 
            +
                      end
         | 
| 289 278 | 
             
                    end
         | 
| 290 279 |  | 
| 291 280 | 
             
                    def append_global
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: squared
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - An Pham
         | 
| 8 8 | 
             
            bindir: exe
         | 
| 9 9 | 
             
            cert_chain: []
         | 
| 10 | 
            -
            date: 2025- | 
| 10 | 
            +
            date: 2025-02-13 00:00:00.000000000 Z
         | 
| 11 11 | 
             
            dependencies:
         | 
| 12 12 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 13 13 | 
             
              name: rake
         |