squared 0.8.7 → 0.9.0.pre1
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 +34 -55
- data/README.md +158 -126
- data/exe/sqd +224 -0
- data/lib/squared/common/base.rb +7 -3
- data/lib/squared/common/format.rb +8 -3
- data/lib/squared/common/prompt.rb +65 -33
- data/lib/squared/common/shell.rb +3 -1
- data/lib/squared/common/system.rb +2 -9
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +33 -44
- data/lib/squared/workspace/project/base.rb +105 -62
- data/lib/squared/workspace/project/docker.rb +94 -45
- data/lib/squared/workspace/project/git.rb +66 -97
- data/lib/squared/workspace/project/node.rb +31 -39
- data/lib/squared/workspace/project/python.rb +127 -95
- data/lib/squared/workspace/project/ruby.rb +68 -71
- data/lib/squared/workspace/project/support/class.rb +1 -1
- data/lib/squared/workspace/project/support/optionpartition.rb +29 -39
- data/lib/squared/workspace/repo.rb +5 -5
- data/lib/squared/workspace/series.rb +4 -2
- data/squared.gemspec +7 -5
- metadata +21 -5
|
@@ -21,25 +21,24 @@ module Squared
|
|
|
21
21
|
nomultiline noprompt noscript nosingleline noverbose regexp-completor sample-book-mode script
|
|
22
22
|
simple-prompt single-irb singleline tracer truncate-echo-on-assignment type-completor verbose
|
|
23
23
|
back-trace-limit=i context-mode=i prompt=b prompt-mode=b].freeze,
|
|
24
|
-
rdbg: %w[
|
|
24
|
+
rdbg: %w[no-color no-rc no-sigint-hook c|command n|nonstop stop-at-load cookie=q e=q host=q x|init-script=p
|
|
25
25
|
O|open=q? port=i port-range=b session-name=q sock-path=q util=q].freeze,
|
|
26
26
|
rbs: %w[I=pm r=bm no-collection no-stdlib collection=p log-level=b log-output=p repo=p].freeze,
|
|
27
|
-
rubocop: %w[D P r=bm auto-gen-config a|autocorrect A|autocorrect-all d|debug
|
|
28
|
-
|
|
29
|
-
display-only-safe-correctable S|display-style-guide display-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
only-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
s|stdin=p].freeze,
|
|
27
|
+
rubocop: %w[D P r=bm auto-gen-config a|autocorrect A|autocorrect-all d|debug disable-pending-cops
|
|
28
|
+
display-only-correctable display-only-fail-level-offenses display-only-failed
|
|
29
|
+
display-only-safe-correctable S|display-style-guide display-time disable-uncorrectable editor-mode
|
|
30
|
+
enable-pending-cops E|extra-details F|fail-fast force-default-config force-exclusion x|fix-layout
|
|
31
|
+
ignore-disable-comments ignore-parent-exclusion ignore-unrecognized-cops init l|lint
|
|
32
|
+
list-enabled-cops-for=p L|list-target-files lsp memory no-detach only-guide-cops
|
|
33
|
+
only-recognized-file-types no-exclude-limit profile raise-cop-error regenerate-todo
|
|
34
|
+
restart-server safe server-status start-server stderr stop-server C|cache=b cache-root=p config=p
|
|
35
|
+
exclude-limit=i fail-level=b f|format=b except=q only=q o|out=p plugin=p require=p show-cops=q
|
|
36
|
+
show-docs-url=q s|stdin=p].freeze,
|
|
38
37
|
pry: %w[f e=q I=pm no-color no-history no-multiline no-pager no-plugins simple-prompt c|context=q
|
|
39
38
|
d|disable-plugin=q gem=b r|require=bm s|select-plugin=q].freeze,
|
|
40
39
|
no: {
|
|
41
40
|
rubocop: %w[auto-gen-enforced-style auto-gen-only-exclude auto-gen-timestamp color display-cop-names
|
|
42
|
-
offense-counts parallel
|
|
41
|
+
offense-counts parallel server].freeze
|
|
43
42
|
}
|
|
44
43
|
}.freeze
|
|
45
44
|
OPT_BUNDLE = {
|
|
@@ -227,10 +226,9 @@ module Squared
|
|
|
227
226
|
serve_set kwargs[:serve]
|
|
228
227
|
gemfile_set kwargs[:gemspec]
|
|
229
228
|
self.autodetect = autodetect
|
|
230
|
-
@bundle = { exec: exec }
|
|
229
|
+
@bundle = { exec: exec.is_a?(String) ? basepath!(exec) : false }
|
|
231
230
|
@steepfile = basepath! steep if steep
|
|
232
|
-
|
|
233
|
-
@rubocopfile = basepath! rubocop if rubocop
|
|
231
|
+
@rubocopfile = Pathname.new(rubocop).realpath rescue basepath!(Dir.home, '.rubocop.yml') if rubocop
|
|
234
232
|
@rubygems = kwargs.fetch(:rubygems, 0)
|
|
235
233
|
return unless rakefile && @output[0].nil? && @copy.nil? && !version && !self.autodetect
|
|
236
234
|
|
|
@@ -238,10 +236,10 @@ module Squared
|
|
|
238
236
|
File.foreach(rakefile) do |line|
|
|
239
237
|
next unless line.match?(%r{\brequire\s+(["'])bundler/gem_tasks\1})
|
|
240
238
|
|
|
241
|
-
cmd = bundle_output('exec rake')
|
|
242
|
-
@output[0] =
|
|
243
|
-
@copy =
|
|
244
|
-
@clean =
|
|
239
|
+
cmd = "#{bundle_output('exec rake')} %s"
|
|
240
|
+
@output[0] = cmd % 'build'
|
|
241
|
+
@copy = cmd % 'install'
|
|
242
|
+
@clean = cmd % 'clean' if @clean.nil?
|
|
245
243
|
break
|
|
246
244
|
end
|
|
247
245
|
rescue => e
|
|
@@ -331,7 +329,7 @@ module Squared
|
|
|
331
329
|
opts = args.to_a
|
|
332
330
|
cmd = opts.delete('::')
|
|
333
331
|
if (n = opts.index('c'))
|
|
334
|
-
args = opts.slice!(n.succ
|
|
332
|
+
args = opts.slice!(n.succ..)
|
|
335
333
|
else
|
|
336
334
|
file = opts.shift
|
|
337
335
|
args = []
|
|
@@ -461,11 +459,13 @@ module Squared
|
|
|
461
459
|
when :build, :push, :exec, :update
|
|
462
460
|
format_desc(action, flag, 'opts*', after: case flag
|
|
463
461
|
when :exec then 'command,args*'
|
|
464
|
-
when :push then 'file
|
|
462
|
+
when :push then 'file/:,d/dry-run?'
|
|
465
463
|
when :update then 'name*'
|
|
466
464
|
end)
|
|
467
465
|
task flag do |_, args|
|
|
468
|
-
|
|
466
|
+
opts = args.to_a
|
|
467
|
+
filter = { dryrun: true } if flag == :push && has_value!(opts, 'd', 'dry-run')
|
|
468
|
+
gem(flag, opts: opts, banner: true, filter: filter)
|
|
469
469
|
end
|
|
470
470
|
when :install, :uninstall, :pristine
|
|
471
471
|
format_desc(action, flag, 'opts*', after: flag == :pristine ? 'name*|name?@version' : 'name*')
|
|
@@ -572,13 +572,18 @@ module Squared
|
|
|
572
572
|
else
|
|
573
573
|
%w[## ;]
|
|
574
574
|
end
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
575
|
+
unless (command = ENV['RUBY_E'])
|
|
576
|
+
command = if Prompt.reline.respond_to?(:readmultiline)
|
|
577
|
+
require 'ripper'
|
|
578
|
+
readline('ruby>', force: true, multiline: multiline) do |code|
|
|
579
|
+
next if code.strip.empty? || !Ripper.sexp(code)
|
|
580
|
+
|
|
581
|
+
Array(multiline).any? { |s| code.split.last.match?(/(?<!#{s[-1]})#{s}$/) }
|
|
582
|
+
end
|
|
583
|
+
else
|
|
584
|
+
readline('Enter script', force: true, multiline: Array(multiline))
|
|
585
|
+
end
|
|
586
|
+
end
|
|
582
587
|
ruby(flag, opts: args.to_a, command: command)
|
|
583
588
|
end
|
|
584
589
|
when :version
|
|
@@ -701,7 +706,7 @@ module Squared
|
|
|
701
706
|
.lines
|
|
702
707
|
.map { |line| line.sub(/#.*$/, '').strip }
|
|
703
708
|
.reject(&:empty?)
|
|
704
|
-
.
|
|
709
|
+
.then do |lines|
|
|
705
710
|
target = lines.find { |line| line.include?(tool) }
|
|
706
711
|
target ? [target] : lines
|
|
707
712
|
end
|
|
@@ -788,7 +793,7 @@ module Squared
|
|
|
788
793
|
when '1', 'true' then nil
|
|
789
794
|
else
|
|
790
795
|
if val.start_with?('~')
|
|
791
|
-
val = File.join(Dir.home, val == '~' ? '.bundle' : val[1
|
|
796
|
+
val = File.join(Dir.home, val == '~' ? '.bundle' : val[1..])
|
|
792
797
|
if prod?
|
|
793
798
|
config_set('binstubs', shell_quote(val), global: true)
|
|
794
799
|
val = nil
|
|
@@ -978,8 +983,9 @@ module Squared
|
|
|
978
983
|
if found > 0
|
|
979
984
|
unless Array(items).empty?
|
|
980
985
|
gems = if se
|
|
981
|
-
choice('Select a package', items.map(&:first),
|
|
982
|
-
|
|
986
|
+
choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
|
|
987
|
+
border: true, **parse_select)
|
|
988
|
+
.map { |n| items[n.pred].last }
|
|
983
989
|
else
|
|
984
990
|
items.map(&:last)
|
|
985
991
|
end
|
|
@@ -1041,7 +1047,7 @@ module Squared
|
|
|
1041
1047
|
end
|
|
1042
1048
|
end
|
|
1043
1049
|
print_run(op, banner, **kwargs) unless flag
|
|
1044
|
-
run(sync: sync, banner: banner, exception: exception?
|
|
1050
|
+
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception?), from: from || :ruby)
|
|
1045
1051
|
end
|
|
1046
1052
|
|
|
1047
1053
|
def gem(flag, *args, sync: true, banner: verbose?, with: nil, pass: nil, **kwargs)
|
|
@@ -1213,8 +1219,9 @@ module Squared
|
|
|
1213
1219
|
puts 'No updates were found'
|
|
1214
1220
|
else
|
|
1215
1221
|
if items
|
|
1216
|
-
update = choice('Select a package', items.map(&:first),
|
|
1217
|
-
|
|
1222
|
+
update = choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
|
|
1223
|
+
border: true, **parse_select)
|
|
1224
|
+
.map { |n| items[n.pred].last }
|
|
1218
1225
|
end
|
|
1219
1226
|
unless Array(update).empty?
|
|
1220
1227
|
opts = ['f']
|
|
@@ -1298,7 +1305,12 @@ module Squared
|
|
|
1298
1305
|
|
|
1299
1306
|
op.add_path(file)
|
|
1300
1307
|
end
|
|
1301
|
-
|
|
1308
|
+
if dryrun? || kwargs[:filter]&.fetch(:dryrun, nil)
|
|
1309
|
+
print_item "> #{op}"
|
|
1310
|
+
exit 0
|
|
1311
|
+
elsif !with && banner
|
|
1312
|
+
return run(from: from, interactive: ['Push', 'N', target || gemname])
|
|
1313
|
+
end
|
|
1302
1314
|
when :exec
|
|
1303
1315
|
min = if op.arg?('g', 'gem')
|
|
1304
1316
|
1
|
|
@@ -1367,9 +1379,9 @@ module Squared
|
|
|
1367
1379
|
name = op.remove_at(n)
|
|
1368
1380
|
n = name.index('@')
|
|
1369
1381
|
pre, ver = if n == 0
|
|
1370
|
-
[gemname, name[1
|
|
1382
|
+
[gemname, name[1..]]
|
|
1371
1383
|
else
|
|
1372
|
-
[name[0, n], name[n.succ
|
|
1384
|
+
[name[0, n], name[n.succ..]]
|
|
1373
1385
|
end
|
|
1374
1386
|
op.adjoin(pre, quote_option('version', ver))
|
|
1375
1387
|
.clear
|
|
@@ -1418,7 +1430,7 @@ module Squared
|
|
|
1418
1430
|
op.clear(errors: true) if gems
|
|
1419
1431
|
print_run(op, banner, **kwargs)
|
|
1420
1432
|
run(banner: banner && %w[q silent quiet no-verbose].none? { |s| op.include?(shell_option(s)) },
|
|
1421
|
-
exception: exception?
|
|
1433
|
+
exception: kwargs.fetch(:exception, exception?), from: from)
|
|
1422
1434
|
end
|
|
1423
1435
|
|
|
1424
1436
|
def bundle(flag, *args, sync: true, banner: verbose?, with: nil, pass: nil, **kwargs)
|
|
@@ -1555,7 +1567,7 @@ module Squared
|
|
|
1555
1567
|
op.clear
|
|
1556
1568
|
end
|
|
1557
1569
|
print_run(op, banner, **kwargs)
|
|
1558
|
-
ret = run(sync: sync, banner: banner, exception: exception?
|
|
1570
|
+
ret = run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception?),
|
|
1559
1571
|
from: symjoin('bundle', flag))
|
|
1560
1572
|
success?(ret, banner, output)
|
|
1561
1573
|
end
|
|
@@ -1568,7 +1580,7 @@ module Squared
|
|
|
1568
1580
|
op.append(escape: true)
|
|
1569
1581
|
print_run(op, banner, **kwargs)
|
|
1570
1582
|
var = { 'BANNER' => '0' } unless banner
|
|
1571
|
-
run(op, var, sync: sync, banner: false, exception: exception?
|
|
1583
|
+
run(op, var, sync: sync, banner: false, exception: kwargs.fetch(:exception, exception?), from: :rake)
|
|
1572
1584
|
end
|
|
1573
1585
|
|
|
1574
1586
|
def irb(*args, banner: verbose?, with: nil, pass: PASS_RUBY[:irb], **kwargs)
|
|
@@ -1583,7 +1595,7 @@ module Squared
|
|
|
1583
1595
|
|
|
1584
1596
|
def rdbg(*args, banner: verbose?, with: nil, pass: PASS_RUBY[:rdbg], **kwargs)
|
|
1585
1597
|
opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
|
|
1586
|
-
cmd = session
|
|
1598
|
+
cmd = session 'rdbg'
|
|
1587
1599
|
args.each_with_index do |val, i|
|
|
1588
1600
|
break if val == '--'
|
|
1589
1601
|
next unless exist?(val, type: 'f')
|
|
@@ -1596,7 +1608,7 @@ module Squared
|
|
|
1596
1608
|
op.concat(args)
|
|
1597
1609
|
op.append(quote: false, delim: true)
|
|
1598
1610
|
print_run(op, banner, **kwargs)
|
|
1599
|
-
run(banner: false, exception: exception?
|
|
1611
|
+
run(banner: false, exception: kwargs.fetch(:exception, exception?), from: :rdbg)
|
|
1600
1612
|
end
|
|
1601
1613
|
|
|
1602
1614
|
def rbs(flag, *args, banner: verbose?, with: nil, pass: nil, **kwargs)
|
|
@@ -1645,7 +1657,7 @@ module Squared
|
|
|
1645
1657
|
op.clear
|
|
1646
1658
|
.append(*args)
|
|
1647
1659
|
print_run(op, banner, **kwargs)
|
|
1648
|
-
run(banner: false, exception: exception?
|
|
1660
|
+
run(banner: false, exception: kwargs.fetch(:exception, exception?), from: symjoin('rbs', flag))
|
|
1649
1661
|
end
|
|
1650
1662
|
end
|
|
1651
1663
|
|
|
@@ -1668,7 +1680,7 @@ module Squared
|
|
|
1668
1680
|
op.append(delim: true)
|
|
1669
1681
|
.clear(errors: true)
|
|
1670
1682
|
print_run(op, banner, **kwargs)
|
|
1671
|
-
run(sync: sync, banner: banner, exception: exception?
|
|
1683
|
+
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception?), from: :rubocop)
|
|
1672
1684
|
end
|
|
1673
1685
|
|
|
1674
1686
|
def serve(root, *, bind: nil, port: 3000, **kwargs)
|
|
@@ -1828,10 +1840,7 @@ module Squared
|
|
|
1828
1840
|
set.call(ver, val)
|
|
1829
1841
|
end
|
|
1830
1842
|
end
|
|
1831
|
-
|
|
1832
|
-
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
|
1833
|
-
parse.call(target.resolve_feature_path(gemname)&.last)
|
|
1834
|
-
end
|
|
1843
|
+
parse.call($LOAD_PATH.resolve_feature_path(gemname)&.last)
|
|
1835
1844
|
unless gemdir || pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
|
|
1836
1845
|
raise Errno::ENOENT, 'gems home'
|
|
1837
1846
|
end
|
|
@@ -1862,11 +1871,11 @@ module Squared
|
|
|
1862
1871
|
op.concat(args)
|
|
1863
1872
|
op.append(delim: delim)
|
|
1864
1873
|
print_run(op, banner, **kwargs)
|
|
1865
|
-
run(banner: false, exception: exception?
|
|
1874
|
+
run(banner: false, exception: kwargs.fetch(:exception, exception?), from: from)
|
|
1866
1875
|
end
|
|
1867
1876
|
|
|
1868
1877
|
def ruby_session(*cmd, **kwargs)
|
|
1869
|
-
session(
|
|
1878
|
+
session('ruby', *preopts, *cmd, **kwargs)
|
|
1870
1879
|
end
|
|
1871
1880
|
|
|
1872
1881
|
def gem_session(*cmd, **kwargs)
|
|
@@ -1884,10 +1893,11 @@ module Squared
|
|
|
1884
1893
|
end
|
|
1885
1894
|
|
|
1886
1895
|
def rbs_session(*cmd, opts: nil)
|
|
1887
|
-
|
|
1896
|
+
args = bundle_args 'rbs'
|
|
1897
|
+
return session(*args, *cmd) unless opts
|
|
1888
1898
|
|
|
1889
1899
|
op = OptionPartition.new(opts, OPT_RUBY[:rbs], project: self, strict: strict?)
|
|
1890
|
-
[session(*
|
|
1900
|
+
[session(*args, *op.to_a, *cmd), op.extras]
|
|
1891
1901
|
end
|
|
1892
1902
|
|
|
1893
1903
|
def gem_output(*cmd, **kwargs)
|
|
@@ -1895,7 +1905,7 @@ module Squared
|
|
|
1895
1905
|
end
|
|
1896
1906
|
|
|
1897
1907
|
def ruby_output(*cmd, **kwargs)
|
|
1898
|
-
session_output(
|
|
1908
|
+
session_output('ruby', *cmd, **kwargs)
|
|
1899
1909
|
end
|
|
1900
1910
|
|
|
1901
1911
|
def bundle_output(*cmd, **kwargs)
|
|
@@ -1908,20 +1918,7 @@ module Squared
|
|
|
1908
1918
|
|
|
1909
1919
|
def bundle_args(*args)
|
|
1910
1920
|
if (val = @bundle[:exec])
|
|
1911
|
-
|
|
1912
|
-
if val.is_a?(Hash)
|
|
1913
|
-
env = val[app.to_s] || val[app.to_sym]
|
|
1914
|
-
return args unless env
|
|
1915
|
-
|
|
1916
|
-
val = env.is_a?(String) ? basepath!(env) : true
|
|
1917
|
-
elsif app == 'ruby'
|
|
1918
|
-
return args
|
|
1919
|
-
end
|
|
1920
|
-
if val.is_a?(String)
|
|
1921
|
-
return args unless (val = basepath!(val))
|
|
1922
|
-
|
|
1923
|
-
args.unshift("--gemfile=#{shell_escape(val.relative_path_from(path), quote: true)}")
|
|
1924
|
-
end
|
|
1921
|
+
args.unshift(quote_option('gemfile', val)) unless val == true
|
|
1925
1922
|
args.unshift('bundle', 'exec')
|
|
1926
1923
|
end
|
|
1927
1924
|
args
|
|
@@ -2071,7 +2068,7 @@ module Squared
|
|
|
2071
2068
|
end
|
|
2072
2069
|
|
|
2073
2070
|
def gemlib
|
|
2074
|
-
@gemlib ||= Set.new(['lib']).
|
|
2071
|
+
@gemlib ||= Set.new(['lib']).then do |lib|
|
|
2075
2072
|
if (spec = gemspec)
|
|
2076
2073
|
lib.merge(spec.require_paths || [])
|
|
2077
2074
|
end
|
|
@@ -19,7 +19,6 @@ module Squared
|
|
|
19
19
|
class << self
|
|
20
20
|
include Common::Format
|
|
21
21
|
include Shell
|
|
22
|
-
include Prompt
|
|
23
22
|
|
|
24
23
|
def append(target, *args, delim: false, escape: false, quote: true, strip: nil, double: false, filter: nil,
|
|
25
24
|
pass: nil, **kwargs)
|
|
@@ -82,7 +81,7 @@ module Squared
|
|
|
82
81
|
kwargs[:hint] ||= 'unrecognized'
|
|
83
82
|
append(target, opts, delim: true) if kwargs.delete(:append)
|
|
84
83
|
warn log_warn(opts.join(', '), pass: true, **kwargs)
|
|
85
|
-
exit 1 unless !strict && (pass || confirm("Run? [#{sub_style(target, styles)}]", 'N'))
|
|
84
|
+
exit 1 unless !strict && (pass || Common::Prompt.confirm("Run? [#{sub_style(target, styles)}]", 'N'))
|
|
86
85
|
end
|
|
87
86
|
|
|
88
87
|
def delete_key(target, *args, value: false, reverse: false, count: -1)
|
|
@@ -104,7 +103,7 @@ module Squared
|
|
|
104
103
|
next if s.empty? || pass == i
|
|
105
104
|
|
|
106
105
|
if s == '--'
|
|
107
|
-
ret << s << args[i.succ
|
|
106
|
+
ret << s << args[i.succ..].join(' ')
|
|
108
107
|
break
|
|
109
108
|
end
|
|
110
109
|
next ret << s unless s.start_with?('-')
|
|
@@ -139,7 +138,7 @@ module Squared
|
|
|
139
138
|
j = val =~ OPT_VALUE ? $1 : val
|
|
140
139
|
(out[j] ||= []) << i unless pass.include?(j)
|
|
141
140
|
end
|
|
142
|
-
.map { |item| item[1].size > 1 ? item[1][
|
|
141
|
+
.map { |item| item[1].size > 1 ? item[1][..-2] : [] }
|
|
143
142
|
.reject(&:empty?)
|
|
144
143
|
return if data.empty?
|
|
145
144
|
|
|
@@ -152,12 +151,12 @@ module Squared
|
|
|
152
151
|
val = val.strip
|
|
153
152
|
return [val, nil, ''] unless (i = val.index('='))
|
|
154
153
|
|
|
155
|
-
last = val[i.succ
|
|
154
|
+
last = val[i.succ..].strip
|
|
156
155
|
if last =~ /\A(["'])(.*)\1\z/m
|
|
157
156
|
last = $2
|
|
158
157
|
quote = $1
|
|
159
158
|
end
|
|
160
|
-
[val[
|
|
159
|
+
[val[...i], last, quote || '']
|
|
161
160
|
end
|
|
162
161
|
|
|
163
162
|
def parse_arg!(name, val)
|
|
@@ -174,7 +173,7 @@ module Squared
|
|
|
174
173
|
r << matchopts(s, value) unless s.empty?
|
|
175
174
|
a = target.to_a
|
|
176
175
|
if (n = a.index('--'))
|
|
177
|
-
a = a[
|
|
176
|
+
a = a[..n]
|
|
178
177
|
end
|
|
179
178
|
r.any? { |pat| a.any?(pat) }
|
|
180
179
|
end
|
|
@@ -193,6 +192,8 @@ module Squared
|
|
|
193
192
|
false
|
|
194
193
|
end
|
|
195
194
|
|
|
195
|
+
alias filter select
|
|
196
|
+
|
|
196
197
|
private
|
|
197
198
|
|
|
198
199
|
def matchopt(val, value = false)
|
|
@@ -219,13 +220,12 @@ module Squared
|
|
|
219
220
|
end
|
|
220
221
|
|
|
221
222
|
attr_reader :target, :extras, :found, :errors, :values, :project, :path, :sep
|
|
222
|
-
attr_accessor :stdout
|
|
223
223
|
|
|
224
224
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
|
225
225
|
:merge, :compact, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
|
226
226
|
def_delegators :@extras, :empty?, :member?, :each, :each_with_index, :each_with_object, :partition, :dup,
|
|
227
227
|
:first, :shift, :unshift, :pop, :push, :concat, :index, :join, :detect, :map, :map!, :select,
|
|
228
|
-
:select!, :reject, :slice, :slice!, :size
|
|
228
|
+
:select!, :filter, :filter!, :reject, :slice, :slice!, :size
|
|
229
229
|
|
|
230
230
|
def_delegator :@extras, :delete, :remove
|
|
231
231
|
def_delegator :@extras, :delete_at, :remove_at
|
|
@@ -242,16 +242,14 @@ module Squared
|
|
|
242
242
|
@sep = sep
|
|
243
243
|
@errors = []
|
|
244
244
|
@found = []
|
|
245
|
-
@stdout = false
|
|
246
245
|
parse(list, opts, **kwargs, &blk)
|
|
247
246
|
end
|
|
248
247
|
|
|
249
248
|
def parse(list, opts = extras, no: nil, single: nil, args: false, multiple: nil, first: nil, underscore: nil,
|
|
250
|
-
explicit: false, bool: %w[true false],
|
|
249
|
+
explicit: false, bool: %w[true false], stdin: false, &blk)
|
|
251
250
|
@extras = []
|
|
252
251
|
@values = []
|
|
253
252
|
bare = []
|
|
254
|
-
auto = auto.flat_map { |val| val.split('|', 2) }
|
|
255
253
|
e = []
|
|
256
254
|
b = []
|
|
257
255
|
m = []
|
|
@@ -264,13 +262,15 @@ module Squared
|
|
|
264
262
|
bl = []
|
|
265
263
|
ex = []
|
|
266
264
|
ml = []
|
|
265
|
+
re = {}
|
|
266
|
+
ar = {}
|
|
267
267
|
sw = {}
|
|
268
268
|
se = {}
|
|
269
269
|
list.flat_map do |val|
|
|
270
270
|
x, y = val.split('|', 2)
|
|
271
271
|
if y
|
|
272
272
|
if (n = val.index('='))
|
|
273
|
-
x += val[n
|
|
273
|
+
x += val[n..]
|
|
274
274
|
end
|
|
275
275
|
[x, y]
|
|
276
276
|
else
|
|
@@ -285,10 +285,10 @@ module Squared
|
|
|
285
285
|
end
|
|
286
286
|
if (n = val.index('='))
|
|
287
287
|
flag = val[0, n]
|
|
288
|
-
|
|
289
|
-
mod = if
|
|
290
|
-
pre =
|
|
291
|
-
|
|
288
|
+
enum = flag.split(':')
|
|
289
|
+
mod = if enum.size > 1
|
|
290
|
+
pre = enum.shift
|
|
291
|
+
enum.map { |s| "#{pre}:#{s}" }
|
|
292
292
|
else
|
|
293
293
|
[flag]
|
|
294
294
|
end
|
|
@@ -319,18 +319,18 @@ module Squared
|
|
|
319
319
|
bare.concat(mod)
|
|
320
320
|
when '/'
|
|
321
321
|
begin
|
|
322
|
-
val = val[n.succ
|
|
322
|
+
val = val[n.succ..]
|
|
323
323
|
pat = eval(val)
|
|
324
324
|
raise SyntaxError unless pat.is_a?(Regexp)
|
|
325
325
|
|
|
326
|
-
mod.each { |key|
|
|
326
|
+
mod.each { |key| re[key] = pat }
|
|
327
327
|
rescue SyntaxError
|
|
328
328
|
warn "#{self.class}: invalid pattern (#{val})"
|
|
329
329
|
end
|
|
330
330
|
when '{'
|
|
331
|
-
group = val[(n + 2)
|
|
331
|
+
group = val[(n + 2)..].chomp!('}')&.split(',')
|
|
332
332
|
if group
|
|
333
|
-
mod.each { |key|
|
|
333
|
+
mod.each { |key| ar[key] = group }
|
|
334
334
|
else
|
|
335
335
|
warn "#{self.class}: invalid group (#{val})"
|
|
336
336
|
end
|
|
@@ -351,7 +351,6 @@ module Squared
|
|
|
351
351
|
tr = ->(a) { a.map { |val| val.tr('-', '_') } }
|
|
352
352
|
@values.concat(tr.call(@values))
|
|
353
353
|
bare.concat(tr.call(bare))
|
|
354
|
-
auto.concat(tr.call(auto))
|
|
355
354
|
e.concat(tr.call(e))
|
|
356
355
|
b.concat(tr.call(b))
|
|
357
356
|
m.concat(tr.call(m))
|
|
@@ -365,7 +364,6 @@ module Squared
|
|
|
365
364
|
ml.concat(tr.call(ml))
|
|
366
365
|
no.concat(tr.call(no))
|
|
367
366
|
end
|
|
368
|
-
bare.concat(auto)
|
|
369
367
|
if target.is_a?(JoinSet)
|
|
370
368
|
target.multiple = multiple if multiple
|
|
371
369
|
target.multiple = ml.map { |val| val.size == 1 ? "-#{val}" : "--#{val}" }
|
|
@@ -398,12 +396,8 @@ module Squared
|
|
|
398
396
|
add "#{sw[opt]}#{opt}"
|
|
399
397
|
else
|
|
400
398
|
add(opt.size == 1 ? "-#{opt}" : "--#{opt}")
|
|
401
|
-
if auto.include?(opt)
|
|
402
|
-
@stdout = true
|
|
403
|
-
break
|
|
404
|
-
end
|
|
405
399
|
end
|
|
406
|
-
elsif opt.start_with?(/no[-_]/) && no.include?(s = opt[3
|
|
400
|
+
elsif opt.start_with?(/no[-_]/) && no.include?(s = opt[3..])
|
|
407
401
|
add "--no-#{s}"
|
|
408
402
|
else
|
|
409
403
|
has = lambda do |list, key|
|
|
@@ -437,8 +431,8 @@ module Squared
|
|
|
437
431
|
else
|
|
438
432
|
push opt
|
|
439
433
|
end
|
|
440
|
-
elsif !
|
|
441
|
-
group = get.call(
|
|
434
|
+
elsif !ar.empty? && has.call(ar.keys, key)
|
|
435
|
+
group = get.call(ar)
|
|
442
436
|
if group.include?(val)
|
|
443
437
|
add shell_option(key, val, force: false, **kwargs)
|
|
444
438
|
elsif @strict
|
|
@@ -446,10 +440,10 @@ module Squared
|
|
|
446
440
|
else
|
|
447
441
|
push opt
|
|
448
442
|
end
|
|
449
|
-
elsif !
|
|
450
|
-
pat = get.call(
|
|
443
|
+
elsif !re.empty? && has.call(re.keys, key)
|
|
444
|
+
pat = get.call(re)
|
|
451
445
|
if val.match?(pat)
|
|
452
|
-
add
|
|
446
|
+
add quote_option(key, val, **kwargs)
|
|
453
447
|
elsif @strict
|
|
454
448
|
clear([opt], hint: "match != /#{pat.source}/")
|
|
455
449
|
else
|
|
@@ -461,7 +455,7 @@ module Squared
|
|
|
461
455
|
push opt
|
|
462
456
|
end
|
|
463
457
|
opt = key unless opt == last
|
|
464
|
-
elsif has.call(m, key = opt[0]) && opt[1
|
|
458
|
+
elsif has.call(m, key = opt[0]) && opt[1..] =~ QUOTE_VALUE
|
|
465
459
|
add basic_option(key, $2, double: $1 == '"' || has.call(qq, key), **kwargs, merge: true)
|
|
466
460
|
opt = key
|
|
467
461
|
else
|
|
@@ -619,7 +613,7 @@ module Squared
|
|
|
619
613
|
else
|
|
620
614
|
args.each { |val| remove val }
|
|
621
615
|
end
|
|
622
|
-
args = temp[0, index] + args + temp[index
|
|
616
|
+
args = temp[0, index] + args + temp[index..]
|
|
623
617
|
target.clear
|
|
624
618
|
end
|
|
625
619
|
merge args
|
|
@@ -828,10 +822,6 @@ module Squared
|
|
|
828
822
|
end
|
|
829
823
|
end
|
|
830
824
|
|
|
831
|
-
def style?(*args)
|
|
832
|
-
!stdout && args.none?(&:!)
|
|
833
|
-
end
|
|
834
|
-
|
|
835
825
|
def uniq!(list)
|
|
836
826
|
list = uniq list
|
|
837
827
|
return if list.empty?
|
|
@@ -215,8 +215,8 @@ module Squared
|
|
|
215
215
|
opts << '--force-checkout'
|
|
216
216
|
when 'rebase', 'detach'
|
|
217
217
|
opts << "--#{val}"
|
|
218
|
-
when /^(
|
|
219
|
-
opts << '--
|
|
218
|
+
when /^(recurse-)?submodules$/
|
|
219
|
+
opts << '--recurse-submodules' if repo_submodules?(true, **envargs)
|
|
220
220
|
when /^(fail-)?fast$/
|
|
221
221
|
opts << '--fail-fast'
|
|
222
222
|
when /^no-(manifest-)?update$/
|
|
@@ -228,7 +228,7 @@ module Squared
|
|
|
228
228
|
if (jobs = ENV['REPO_JOBS']) || opts.none?(/^--?j(obs)?$/)
|
|
229
229
|
opts << "-j#{jobs || Rake::CpuCounter.count}"
|
|
230
230
|
end
|
|
231
|
-
opts << '--
|
|
231
|
+
opts << '--recurse-submodules' if repo_submodules?(**envargs)
|
|
232
232
|
begin
|
|
233
233
|
repo_run('sync', opts, exception: opts.include?('--fail-fast'), options: stage != 'init')
|
|
234
234
|
rescue Errno::ENOENT => e
|
|
@@ -262,7 +262,7 @@ module Squared
|
|
|
262
262
|
return false unless root.directory?
|
|
263
263
|
|
|
264
264
|
path = sub_style root, theme[:inline]
|
|
265
|
-
@repo_override = case env('REPO_Y')
|
|
265
|
+
@repo_override = case __arg__('YES', 'REPO') || env('REPO_Y')
|
|
266
266
|
when '0', 'false'
|
|
267
267
|
false
|
|
268
268
|
when '1', 'true'
|
|
@@ -345,7 +345,7 @@ module Squared
|
|
|
345
345
|
def repo_opts(*args)
|
|
346
346
|
return args unless (n = ARGV.index('--'))
|
|
347
347
|
|
|
348
|
-
ARGV[n.succ
|
|
348
|
+
ARGV[n.succ..].concat(args)
|
|
349
349
|
end
|
|
350
350
|
|
|
351
351
|
def repo_submodules?(val = false, **kwargs)
|
|
@@ -9,6 +9,7 @@ module Squared
|
|
|
9
9
|
extend Forwardable
|
|
10
10
|
|
|
11
11
|
attr_reader :sync, :multiple, :parallel
|
|
12
|
+
attr_writer :ref_min
|
|
12
13
|
|
|
13
14
|
def_delegators :@data, :[], :each, :each_key, :keys, :key?, :include?, :fetch, :update, :merge!, :any?, :none?,
|
|
14
15
|
:delete, :delete_if, :find, :find_all, :to_a, :to_s, :inspect
|
|
@@ -19,6 +20,7 @@ module Squared
|
|
|
19
20
|
@sync = []
|
|
20
21
|
@multiple = []
|
|
21
22
|
@parallel = []
|
|
23
|
+
@ref_min = 2
|
|
22
24
|
@chain = {}
|
|
23
25
|
@exclude = exclude.freeze
|
|
24
26
|
@task = Struct::SeriesData.new(workspace.config_get(:rename))
|
|
@@ -56,7 +58,7 @@ module Squared
|
|
|
56
58
|
@session = {
|
|
57
59
|
group: Support.hashlist,
|
|
58
60
|
parent: Support.hashlist,
|
|
59
|
-
id:
|
|
61
|
+
id: Set.new
|
|
60
62
|
}.freeze
|
|
61
63
|
end
|
|
62
64
|
|
|
@@ -85,7 +87,7 @@ module Squared
|
|
|
85
87
|
|
|
86
88
|
def build(parallel: [], pattern: [], **)
|
|
87
89
|
subcheck = ->(val) { (ns = task_namespace(val)) && parallel.include?(ns) }
|
|
88
|
-
update @session[:parent] if @session[:id].
|
|
90
|
+
update @session[:parent] if @session[:id].size >= @ref_min
|
|
89
91
|
update @session[:group]
|
|
90
92
|
each do |key, items|
|
|
91
93
|
next if exclude?(key, empty: true) || @workspace.task_exclude?(t = name_get(key))
|