squared 0.7.13 → 0.8.0
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 +44 -176
- data/README.md +38 -35
- data/lib/squared/common/base.rb +0 -9
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +30 -32
- data/lib/squared/common/shell.rb +11 -11
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +19 -23
- data/lib/squared/config.rb +5 -12
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -31
- data/lib/squared/workspace/project/base.rb +84 -94
- data/lib/squared/workspace/project/docker.rb +85 -117
- data/lib/squared/workspace/project/git.rb +187 -94
- data/lib/squared/workspace/project/node.rb +184 -177
- data/lib/squared/workspace/project/python.rb +52 -51
- data/lib/squared/workspace/project/ruby.rb +54 -46
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +17 -42
- data/lib/squared/workspace/project/support/utils.rb +15 -22
- data/lib/squared/workspace/repo.rb +10 -7
- data/lib/squared/workspace/series.rb +12 -5
- metadata +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
|
-
require 'logger'
|
|
5
4
|
|
|
6
5
|
require_relative 'support/class'
|
|
7
6
|
require_relative 'support/utils'
|
|
@@ -10,6 +9,7 @@ module Squared
|
|
|
10
9
|
module Workspace
|
|
11
10
|
module Project
|
|
12
11
|
class Base
|
|
12
|
+
include Enumerable
|
|
13
13
|
include Comparable
|
|
14
14
|
include Common::Format
|
|
15
15
|
include System
|
|
@@ -343,7 +343,7 @@ module Squared
|
|
|
343
343
|
tag ||= if @release
|
|
344
344
|
"%s.#{ext}" % [@release.include?('??') ? @release.sub('??', tag) : @release + tag]
|
|
345
345
|
else
|
|
346
|
-
|
|
346
|
+
raise ArgumentError, message('no base uri', tag, hint: ext)
|
|
347
347
|
end
|
|
348
348
|
end
|
|
349
349
|
force = case (digest = args.digest)
|
|
@@ -471,10 +471,10 @@ module Squared
|
|
|
471
471
|
cmd = args.each_with_object([]) do |val, out|
|
|
472
472
|
case val.first
|
|
473
473
|
when Proc
|
|
474
|
-
instance_exec(*val
|
|
474
|
+
instance_exec(*val.drop(1), &val.first)
|
|
475
475
|
next
|
|
476
476
|
when Method
|
|
477
|
-
val.first.call(*val
|
|
477
|
+
val.first.call(*val.drop(1))
|
|
478
478
|
next
|
|
479
479
|
end
|
|
480
480
|
a, b, c, d, e = val
|
|
@@ -542,7 +542,7 @@ module Squared
|
|
|
542
542
|
on_error(e, exception: true)
|
|
543
543
|
end
|
|
544
544
|
else
|
|
545
|
-
print_error('prereqs',
|
|
545
|
+
print_error('prereqs', 'method', meth, subject: name, hint: 'undefined')
|
|
546
546
|
end
|
|
547
547
|
end
|
|
548
548
|
elsif proj.build?
|
|
@@ -582,10 +582,10 @@ module Squared
|
|
|
582
582
|
case @clean
|
|
583
583
|
when Struct
|
|
584
584
|
if (val = instance_eval(&@clean.block) || @clean.run)
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
585
|
+
cur = @clean
|
|
586
|
+
@clean = val
|
|
587
|
+
clean(*args, sync: sync, pass: true, **kwargs)
|
|
588
|
+
@clean = cur
|
|
589
589
|
end
|
|
590
590
|
when String
|
|
591
591
|
run_s(@clean, sync: sync)
|
|
@@ -661,9 +661,10 @@ module Squared
|
|
|
661
661
|
if !target.exist?
|
|
662
662
|
target.mkpath
|
|
663
663
|
elsif !target.directory?
|
|
664
|
-
|
|
664
|
+
raise Errno::EEXIST, message(target, hint: uri)
|
|
665
665
|
elsif !file && !target.empty?
|
|
666
|
-
|
|
666
|
+
raise Errno::EEXIST, message(target, hint: uri) unless force || env('UNPACK_FORCE')
|
|
667
|
+
|
|
667
668
|
create = true
|
|
668
669
|
end
|
|
669
670
|
if digest
|
|
@@ -683,7 +684,7 @@ module Squared
|
|
|
683
684
|
when 128, 'sha512'
|
|
684
685
|
Digest::SHA512
|
|
685
686
|
else
|
|
686
|
-
|
|
687
|
+
raise message('invalid checksum', digest, hint: uri)
|
|
687
688
|
end
|
|
688
689
|
end
|
|
689
690
|
env('HEADERS') do |val|
|
|
@@ -701,14 +702,14 @@ module Squared
|
|
|
701
702
|
data = f.read
|
|
702
703
|
if algo && algo.hexdigest(data) != digest
|
|
703
704
|
data = nil
|
|
704
|
-
|
|
705
|
+
raise message('invalid checksum', digest, hint: url) if i == uri.size.pred
|
|
705
706
|
end
|
|
706
707
|
next if ext && i == 0
|
|
707
708
|
|
|
708
709
|
case f.content_type
|
|
709
710
|
when 'application/zip'
|
|
710
711
|
ext = 'zip'
|
|
711
|
-
when %r{application/(
|
|
712
|
+
when %r{application/(x-)?gzip}
|
|
712
713
|
ext = 'tgz'
|
|
713
714
|
when 'application/x-xz'
|
|
714
715
|
ext = 'txz'
|
|
@@ -719,7 +720,7 @@ module Squared
|
|
|
719
720
|
break uri = url if data
|
|
720
721
|
end
|
|
721
722
|
unless data && (ext ||= URI.decode_www_form_component(URI.parse(uri).path[/\.([\w%]+)(?:\?|\z)/, 1]))
|
|
722
|
-
|
|
723
|
+
raise(data ? TypeError : RuntimeError, message("no content#{' type' if data}", hint: uri))
|
|
723
724
|
end
|
|
724
725
|
end
|
|
725
726
|
ext = ext.downcase
|
|
@@ -748,7 +749,7 @@ module Squared
|
|
|
748
749
|
case ext
|
|
749
750
|
when 'zip', 'aar'
|
|
750
751
|
session 'unzip', shell_quote(file), quote_option('d', target)
|
|
751
|
-
when 'tar', /\A(
|
|
752
|
+
when 'tar', /\A(t|tar\.)?[gx]z\z/
|
|
752
753
|
flags = +(silent? ? '' : 'v')
|
|
753
754
|
if ext.end_with?('gz')
|
|
754
755
|
flags += 'z'
|
|
@@ -764,7 +765,7 @@ module Squared
|
|
|
764
765
|
session 'gem', 'unpack', shell_quote(file), quote_option('target', target)
|
|
765
766
|
depth = 0 unless val
|
|
766
767
|
else
|
|
767
|
-
|
|
768
|
+
raise message('unsupported format', ext, hint: uri || file)
|
|
768
769
|
end
|
|
769
770
|
run(sync: sync, banner: verbose, from: from)
|
|
770
771
|
while depth > 0 && target.children.size == 1
|
|
@@ -1018,13 +1019,13 @@ module Squared
|
|
|
1018
1019
|
|
|
1019
1020
|
alias apply variable_set
|
|
1020
1021
|
|
|
1021
|
-
def enabled?(ref
|
|
1022
|
+
def enabled?(ref: nil, **)
|
|
1022
1023
|
return false if ref && Array(ref).none? { |val| ref?(val) }
|
|
1023
1024
|
|
|
1024
1025
|
(path.directory? && !path.empty?) || archive?
|
|
1025
1026
|
end
|
|
1026
1027
|
|
|
1027
|
-
def has?(meth, ref
|
|
1028
|
+
def has?(meth, ref: nil, all: false, missing: false)
|
|
1028
1029
|
return false if ref && !ref?(ref)
|
|
1029
1030
|
|
|
1030
1031
|
pred = :"#{meth}?"
|
|
@@ -1105,8 +1106,8 @@ module Squared
|
|
|
1105
1106
|
!@exclude.empty? && has_value?(@exclude, *refs)
|
|
1106
1107
|
end
|
|
1107
1108
|
|
|
1108
|
-
def task_include?(key, ref
|
|
1109
|
-
workspace.task_include?(self, key, ref) && !@pass.include?(key.to_s)
|
|
1109
|
+
def task_include?(key, ref: nil)
|
|
1110
|
+
workspace.task_include?(self, key, ref: ref) && !@pass.include?(key.to_s)
|
|
1110
1111
|
end
|
|
1111
1112
|
|
|
1112
1113
|
def version(*)
|
|
@@ -1189,6 +1190,20 @@ module Squared
|
|
|
1189
1190
|
keys.empty? ? ret : ret.dig(*keys)
|
|
1190
1191
|
end
|
|
1191
1192
|
|
|
1193
|
+
def each(from: :run, ref: nil, accept: nil, &blk)
|
|
1194
|
+
from = from.to_s.split(':').last if from.is_a?(Symbol)
|
|
1195
|
+
items = ref ? children.select { |proj| proj.ref?(ref) } : children
|
|
1196
|
+
if items.empty?
|
|
1197
|
+
print_error("nothing to #{from}", subject: name)
|
|
1198
|
+
elsif accept && !confirm_basic("#{from.capitalize} workspace?", items.map(&:name).join(', '), accept,
|
|
1199
|
+
prefix: 'npm')
|
|
1200
|
+
items.clear
|
|
1201
|
+
end
|
|
1202
|
+
return items.to_enum unless block_given?
|
|
1203
|
+
|
|
1204
|
+
items.each(&blk)
|
|
1205
|
+
end
|
|
1206
|
+
|
|
1192
1207
|
def inspect
|
|
1193
1208
|
"#<#{self.class}: #{name} => #{self}>"
|
|
1194
1209
|
end
|
|
@@ -1389,7 +1404,7 @@ module Squared
|
|
|
1389
1404
|
elsif ws.task_defined?(val = task_join(name, meth)) || (meth.include?(':') && ws.task_defined?(val = meth))
|
|
1390
1405
|
run(val, var, sync: sync, banner: banner, **kwargs)
|
|
1391
1406
|
elsif from
|
|
1392
|
-
print_error(from,
|
|
1407
|
+
print_error(from, 'method', meth, subject: name, hint: 'undefined')
|
|
1393
1408
|
end
|
|
1394
1409
|
end
|
|
1395
1410
|
end
|
|
@@ -1422,11 +1437,7 @@ module Squared
|
|
|
1422
1437
|
when 0
|
|
1423
1438
|
f
|
|
1424
1439
|
when 1
|
|
1425
|
-
|
|
1426
|
-
"#{d}#{b * 4} #{f}"
|
|
1427
|
-
else
|
|
1428
|
-
"#{last ? d : c}#{b * 3}#{e} #{f}"
|
|
1429
|
-
end
|
|
1440
|
+
items.empty? ? "#{d}#{b * 4} #{f}" : "#{last ? d : c}#{b * 3}#{e} #{f}"
|
|
1430
1441
|
else
|
|
1431
1442
|
"#{single ? ' ' : a}#{' ' * depth.pred}#{last ? d : c}#{b * 3}#{items.empty? ? b : e} #{f}"
|
|
1432
1443
|
end
|
|
@@ -1490,7 +1501,7 @@ module Squared
|
|
|
1490
1501
|
end
|
|
1491
1502
|
run(cmd, sync: false, banner: false)
|
|
1492
1503
|
ENV.delete(key) if key
|
|
1493
|
-
elsif proj.has?(meth, tasks || graph
|
|
1504
|
+
elsif proj.has?(meth, ref: (workspace.baseref unless tasks || graph))
|
|
1494
1505
|
proj.__send__(meth, sync: sync)
|
|
1495
1506
|
end
|
|
1496
1507
|
end
|
|
@@ -1545,7 +1556,7 @@ module Squared
|
|
|
1545
1556
|
def env(key, default = nil, suffix: nil, strict: false, ignore: nil, **kwargs, &blk)
|
|
1546
1557
|
name = "#{key}_#{envname_get}"
|
|
1547
1558
|
ret = if suffix
|
|
1548
|
-
ENV
|
|
1559
|
+
ENV.fetch("#{name}_#{suffix}", '')
|
|
1549
1560
|
elsif strict
|
|
1550
1561
|
ENV[name].to_s
|
|
1551
1562
|
else
|
|
@@ -1572,7 +1583,7 @@ module Squared
|
|
|
1572
1583
|
end
|
|
1573
1584
|
cache = @timeout[:_]
|
|
1574
1585
|
cache[1] ||= workspace.timeout_get(*@ref, group: group)
|
|
1575
|
-
cache[0][ret] = if cmd
|
|
1586
|
+
cache[0][ret] = if cmd.drop(1).find { |val| val =~ /\A([A-Za-z][\w-]*)(?<![-_])(?: |\z)/ }
|
|
1576
1587
|
command = :"#{prefix}_#{$1}"
|
|
1577
1588
|
cache[1][command] || @timeout[command]
|
|
1578
1589
|
end || cache[1][prefix.to_sym] || @timeout[prefix.to_sym]
|
|
@@ -1638,8 +1649,8 @@ module Squared
|
|
|
1638
1649
|
|
|
1639
1650
|
def session_done(cmd)
|
|
1640
1651
|
return cmd.to_s unless cmd.respond_to?(:done)
|
|
1652
|
+
raise message('no command added', hint: cmd.first) unless cmd.size > 1
|
|
1641
1653
|
|
|
1642
|
-
raise_error 'no command added', hint: cmd.first unless cmd.size > 1
|
|
1643
1654
|
@session = nil if cmd.equal?(@session)
|
|
1644
1655
|
cmd.done
|
|
1645
1656
|
end
|
|
@@ -1672,7 +1683,7 @@ module Squared
|
|
|
1672
1683
|
end
|
|
1673
1684
|
|
|
1674
1685
|
def write_lines(data, grep: [], prefix: nil, sub: nil, banner: nil, loglevel: nil, pass: false, first: false)
|
|
1675
|
-
grep = (matchmap(grep, prefix) unless grep.empty?)
|
|
1686
|
+
grep = (matchmap(grep, prefix: prefix) unless grep.empty?)
|
|
1676
1687
|
sub = (as_a(sub) unless stdin?)
|
|
1677
1688
|
ret = 0
|
|
1678
1689
|
lines = data.each_with_object([]) do |line, out|
|
|
@@ -1692,18 +1703,12 @@ module Squared
|
|
|
1692
1703
|
ret += 1
|
|
1693
1704
|
break out if first
|
|
1694
1705
|
end
|
|
1695
|
-
if banner && (ret > 0 || (!pass && !first))
|
|
1696
|
-
if banner.empty?
|
|
1697
|
-
print_item(*lines)
|
|
1698
|
-
else
|
|
1699
|
-
print_item(banner, *lines)
|
|
1700
|
-
end
|
|
1701
|
-
end
|
|
1706
|
+
print_item banner, lines if banner && (ret > 0 || (!pass && !first))
|
|
1702
1707
|
ret
|
|
1703
1708
|
end
|
|
1704
1709
|
|
|
1705
1710
|
def print_success
|
|
1706
|
-
puts
|
|
1711
|
+
puts 'Success'
|
|
1707
1712
|
end
|
|
1708
1713
|
|
|
1709
1714
|
def print_error(*args, loglevel: Logger::WARN, **kwargs)
|
|
@@ -1724,7 +1729,7 @@ module Squared
|
|
|
1724
1729
|
end
|
|
1725
1730
|
|
|
1726
1731
|
def print_run(cmd, banner = true, verbose: nil, **)
|
|
1727
|
-
return if banner || !stdout? || verbose == false || env('BANNER', equals:
|
|
1732
|
+
return if banner || !stdout? || verbose == false || env('BANNER', equals: '0')
|
|
1728
1733
|
|
|
1729
1734
|
puts "\n> #{cmd}"
|
|
1730
1735
|
printsucc
|
|
@@ -1733,7 +1738,7 @@ module Squared
|
|
|
1733
1738
|
def print_item(*val, series: false)
|
|
1734
1739
|
puts unless printfirst?
|
|
1735
1740
|
printsucc unless series
|
|
1736
|
-
puts val unless val.empty? || (val.size == 1 &&
|
|
1741
|
+
puts val unless val.empty? || (val.size == 1 && !val.first)
|
|
1737
1742
|
end
|
|
1738
1743
|
|
|
1739
1744
|
def print_banner(*lines, client: false, styles: theme[:banner], border: borderstyle)
|
|
@@ -1814,13 +1819,13 @@ module Squared
|
|
|
1814
1819
|
out = []
|
|
1815
1820
|
if data.command
|
|
1816
1821
|
if command
|
|
1817
|
-
if cmd =~ /\A(?:"((?:[^"]|(?<=\\)")+)"|'((?:[^']|(?<=\\)')+)'|(\S+))( |\z)/
|
|
1822
|
+
if cmd =~ /\A(?:"((?:[^"]|(?<=\\)")+)"|'((?:[^']|(?<=\\)')+)'|(\S+))(?: |\z)/
|
|
1818
1823
|
arg = $3 || $2 || $1
|
|
1819
1824
|
cmd = cmd.sub(arg, data.command == 0 ? arg.stripext : arg.stripext.upcase)
|
|
1820
1825
|
end
|
|
1821
1826
|
if strip || (strip.nil? && data.order.include?(:path))
|
|
1822
|
-
|
|
1823
|
-
|
|
1827
|
+
s = Regexp.escape(File.join(path, ''))
|
|
1828
|
+
cmd = cmd.gsub(/(#{s}?(?=["'])|#{s})/, '').gsub(/( -[^ ])? (""|'')/, '')
|
|
1824
1829
|
end
|
|
1825
1830
|
cmd = cmd.gsub(/(?<= )(["'])([\w.-]+)\1(?= |\z)/, '\2') unless quote
|
|
1826
1831
|
end
|
|
@@ -1897,7 +1902,7 @@ module Squared
|
|
|
1897
1902
|
end
|
|
1898
1903
|
|
|
1899
1904
|
def append_hash(data, target: @session || [], build: false)
|
|
1900
|
-
if build && (type = env('BUILD', suffix: 'TYPE'
|
|
1905
|
+
if build && (type = env('BUILD', suffix: 'TYPE') || ENV['BUILD_TYPE'])
|
|
1901
1906
|
if (extra = data[type = "__#{type}__"] || data[type.to_sym]).is_a?(Hash)
|
|
1902
1907
|
data = data.merge(extra)
|
|
1903
1908
|
else
|
|
@@ -2044,11 +2049,6 @@ module Squared
|
|
|
2044
2049
|
end
|
|
2045
2050
|
end
|
|
2046
2051
|
|
|
2047
|
-
def collect_hash(data, pass: [])
|
|
2048
|
-
data = data.reject { |key,| pass.include?(key) } unless pass.empty?
|
|
2049
|
-
data.values.flatten
|
|
2050
|
-
end
|
|
2051
|
-
|
|
2052
2052
|
def replace_bin(val)
|
|
2053
2053
|
a, b = val.split(' ', 2)
|
|
2054
2054
|
return val if val.start_with?(/["']/) || a.include?(File::Separator)
|
|
@@ -2058,7 +2058,7 @@ module Squared
|
|
|
2058
2058
|
|
|
2059
2059
|
def parse_json(val, kind: Hash, key: nil, hint: nil, &blk)
|
|
2060
2060
|
ret = JSON.parse(val)
|
|
2061
|
-
|
|
2061
|
+
raise message('invalid JSON', kind.name, hint: hint) if kind && !ret.is_a?(kind)
|
|
2062
2062
|
return ret unless key
|
|
2063
2063
|
|
|
2064
2064
|
block_given? ? ret.fetch(key, &blk) : ret[key]
|
|
@@ -2078,18 +2078,18 @@ module Squared
|
|
|
2078
2078
|
return val unless val.nil? || (pat && !val.match?(pat)) || (values && !values.include?(val))
|
|
2079
2079
|
|
|
2080
2080
|
@session = nil
|
|
2081
|
-
|
|
2081
|
+
raise message(action, "#{flag}[#{key}]", hint: val.nil? ? 'missing' : 'invalid')
|
|
2082
2082
|
elsif args.is_a?(Array) && args.empty?
|
|
2083
2083
|
@session = nil
|
|
2084
|
-
|
|
2084
|
+
raise message(action, "#{flag}+", hint: 'empty')
|
|
2085
2085
|
end
|
|
2086
2086
|
args
|
|
2087
2087
|
end
|
|
2088
2088
|
|
|
2089
|
-
def confirm_basic(msg, hint,
|
|
2090
|
-
return true if option('y', prefix: prefix)
|
|
2089
|
+
def confirm_basic(msg, hint, accept = 'Y', style: :inline, target: @session, prefix: nil, **kwargs)
|
|
2090
|
+
return true if prefix ? option('y', prefix: prefix) : target && option('y', target: target)
|
|
2091
2091
|
|
|
2092
|
-
confirm("#{msg} [#{sub_style(hint.to_s, style.is_a?(Symbol) ? theme[style] : style)}]",
|
|
2092
|
+
confirm("#{msg} [#{sub_style(hint.to_s, style.is_a?(Symbol) ? theme[style] : style)}]", accept, **kwargs)
|
|
2093
2093
|
end
|
|
2094
2094
|
|
|
2095
2095
|
def confirm_semver(msg, type, style: (type == 1 && theme[:major]) || :inline, timeout: 0, **kwargs)
|
|
@@ -2121,10 +2121,7 @@ module Squared
|
|
|
2121
2121
|
if accept
|
|
2122
2122
|
hint = Array(ret).map { |val| sub_style(val.to_s, theme[:inline]) }.join(', ')
|
|
2123
2123
|
accept = Array(accept).map { |val| Array(val) }
|
|
2124
|
-
if accept.any? { |val| val[1] == true }
|
|
2125
|
-
ret = [ret]
|
|
2126
|
-
multiple = -1
|
|
2127
|
-
end
|
|
2124
|
+
ret = Array(ret) if accept.any? { |val| val[1] == true }
|
|
2128
2125
|
begin
|
|
2129
2126
|
item = accept.shift
|
|
2130
2127
|
c = confirm("#{item[0]}#{" [#{hint}]" if hint}", item[2] ? 'Y' : 'N')
|
|
@@ -2137,7 +2134,7 @@ module Squared
|
|
|
2137
2134
|
end until accept.empty?
|
|
2138
2135
|
end
|
|
2139
2136
|
if values
|
|
2140
|
-
ret =
|
|
2137
|
+
ret = Array(ret)
|
|
2141
2138
|
Array(values).each do |val|
|
|
2142
2139
|
if val.is_a?(Array)
|
|
2143
2140
|
val, force = val
|
|
@@ -2152,12 +2149,8 @@ module Squared
|
|
|
2152
2149
|
ret
|
|
2153
2150
|
end
|
|
2154
2151
|
|
|
2155
|
-
def accept_b(val, yes
|
|
2156
|
-
[val,
|
|
2157
|
-
end
|
|
2158
|
-
|
|
2159
|
-
def accept_y(val, bool = false)
|
|
2160
|
-
[val, bool, true]
|
|
2152
|
+
def accept_b(val, ret: true, yes: false)
|
|
2153
|
+
[val, ret, yes]
|
|
2161
2154
|
end
|
|
2162
2155
|
|
|
2163
2156
|
def command_args(args, min: 0, force: false, **kwargs)
|
|
@@ -2218,10 +2211,6 @@ module Squared
|
|
|
2218
2211
|
end
|
|
2219
2212
|
end
|
|
2220
2213
|
|
|
2221
|
-
def symjoin(*args, char: ':')
|
|
2222
|
-
args.join(char).to_sym
|
|
2223
|
-
end
|
|
2224
|
-
|
|
2225
2214
|
def semver(val)
|
|
2226
2215
|
return val if val[3]
|
|
2227
2216
|
|
|
@@ -2263,7 +2252,7 @@ module Squared
|
|
|
2263
2252
|
def sembump(val, flag = :patch, join: true)
|
|
2264
2253
|
ret = semscan(val, fill: false)
|
|
2265
2254
|
case flag
|
|
2266
|
-
when :major
|
|
2255
|
+
when :major, :premajor
|
|
2267
2256
|
ret[2] = if ret[0] != '0' || ret[2].nil?
|
|
2268
2257
|
ret[0] = ret[0].succ
|
|
2269
2258
|
'0'
|
|
@@ -2271,16 +2260,29 @@ module Squared
|
|
|
2271
2260
|
ret[2].succ
|
|
2272
2261
|
end
|
|
2273
2262
|
ret[4] = '0'
|
|
2274
|
-
when :minor
|
|
2263
|
+
when :minor, :preminor
|
|
2275
2264
|
if ret[0] == '0'
|
|
2276
2265
|
ret[4] &&= ret[4].succ
|
|
2277
2266
|
else
|
|
2278
2267
|
ret[2] = ret[2].succ
|
|
2279
2268
|
ret[4] &&= '0'
|
|
2280
2269
|
end
|
|
2281
|
-
when :patch
|
|
2270
|
+
when :patch, :prepatch
|
|
2282
2271
|
ret[4] &&= ret[4].succ
|
|
2283
2272
|
end
|
|
2273
|
+
case flag
|
|
2274
|
+
when :premajor, :preminor, :prepatch
|
|
2275
|
+
ret[5] ||= '-'
|
|
2276
|
+
ret[6] = '0'
|
|
2277
|
+
when :prerelease
|
|
2278
|
+
if !ret[6]
|
|
2279
|
+
ret[5] = '-'
|
|
2280
|
+
ret[6] = '0'
|
|
2281
|
+
elsif ret[6].match?(/^\d+$/)
|
|
2282
|
+
ret[5] ||= '-'
|
|
2283
|
+
ret[6] = ret[6].succ
|
|
2284
|
+
end
|
|
2285
|
+
end
|
|
2284
2286
|
join ? ret.join : ret
|
|
2285
2287
|
end
|
|
2286
2288
|
|
|
@@ -2307,7 +2309,7 @@ module Squared
|
|
|
2307
2309
|
end
|
|
2308
2310
|
|
|
2309
2311
|
def indexerror(val, list = nil)
|
|
2310
|
-
|
|
2312
|
+
raise IndexError, message("requested index #{val}", hint: ("of #{list.size}" if list))
|
|
2311
2313
|
end
|
|
2312
2314
|
|
|
2313
2315
|
def indexchar
|
|
@@ -2695,16 +2697,7 @@ module Squared
|
|
|
2695
2697
|
end
|
|
2696
2698
|
|
|
2697
2699
|
def banner?
|
|
2698
|
-
|
|
2699
|
-
when '0', 'false'
|
|
2700
|
-
false
|
|
2701
|
-
else
|
|
2702
|
-
!val.nil? || ARG[:BANNER]
|
|
2703
|
-
end
|
|
2704
|
-
end
|
|
2705
|
-
|
|
2706
|
-
def dryrun?(*, target: @session, prefix: target&.first)
|
|
2707
|
-
Array(target).include?('--dry-run') || !option('dry-run', target: target, prefix: prefix).nil?
|
|
2700
|
+
ARG[:BANNER] && env('BANNER', notequals: '0')
|
|
2708
2701
|
end
|
|
2709
2702
|
|
|
2710
2703
|
def pwd?
|
|
@@ -2732,17 +2725,14 @@ module Squared
|
|
|
2732
2725
|
end
|
|
2733
2726
|
|
|
2734
2727
|
def exception?(*level)
|
|
2735
|
-
|
|
2736
|
-
|
|
2728
|
+
ret = exception
|
|
2729
|
+
return ret unless ret.is_a?(Numeric)
|
|
2730
|
+
|
|
2731
|
+
level.empty? ? ret != Logger::INFO : level.include?(ret)
|
|
2737
2732
|
end
|
|
2738
2733
|
|
|
2739
2734
|
def strict?
|
|
2740
|
-
|
|
2741
|
-
when '0', 'false'
|
|
2742
|
-
false
|
|
2743
|
-
else
|
|
2744
|
-
!val.nil? || ARG[:STRICT] || exception?(Logger::FATAL)
|
|
2745
|
-
end
|
|
2735
|
+
(ARG[:STRICT] || exception?(Logger::FATAL)) && env('STRICT', notequals: '0')
|
|
2746
2736
|
end
|
|
2747
2737
|
|
|
2748
2738
|
def serve?
|