squared 0.7.9 → 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 -53
- data/README.md +38 -35
- data/lib/squared/common/base.rb +0 -1
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +25 -24
- data/lib/squared/common/shell.rb +11 -11
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +18 -22
- data/lib/squared/config.rb +3 -11
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -31
- data/lib/squared/workspace/project/base.rb +78 -81
- data/lib/squared/workspace/project/docker.rb +42 -41
- data/lib/squared/workspace/project/git.rb +164 -72
- data/lib/squared/workspace/project/node.rb +163 -121
- data/lib/squared/workspace/project/python.rb +26 -28
- data/lib/squared/workspace/project/ruby.rb +47 -41
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +7 -10
- data/lib/squared/workspace/project/support/utils.rb +15 -22
- data/lib/squared/workspace/repo.rb +7 -5
- data/lib/squared/workspace/series.rb +10 -2
- metadata +1 -1
|
@@ -105,7 +105,7 @@ module Squared
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
def bannerargs
|
|
108
|
-
%i[version dependfile venv].freeze
|
|
108
|
+
%i[version dependfile venv editable].freeze
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def venv?
|
|
@@ -216,7 +216,7 @@ module Squared
|
|
|
216
216
|
found |= 1
|
|
217
217
|
run(pdm_session('run', val), from: :run)
|
|
218
218
|
else
|
|
219
|
-
raise
|
|
219
|
+
raise message('script', val) if exception?
|
|
220
220
|
|
|
221
221
|
found |= 2
|
|
222
222
|
log.warn "run script \"#{val}\"".subhint('not indexed')
|
|
@@ -265,10 +265,10 @@ module Squared
|
|
|
265
265
|
|
|
266
266
|
format_desc action, flag, 'c/reate?,d/epend?,opts*'
|
|
267
267
|
task flag do |_, args|
|
|
268
|
-
|
|
269
|
-
rm_rf(venv, verbose:
|
|
270
|
-
venv_init if has_value!(
|
|
271
|
-
depend :force,
|
|
268
|
+
opts = args.to_a
|
|
269
|
+
rm_rf(venv, verbose: !silent?)
|
|
270
|
+
venv_init if has_value!(opts, 'c', 'create')
|
|
271
|
+
depend :force, opts if has_value!(opts, 'd', 'depend')
|
|
272
272
|
end
|
|
273
273
|
when :exec
|
|
274
274
|
format_desc action, flag, 'command,args*'
|
|
@@ -391,7 +391,7 @@ module Squared
|
|
|
391
391
|
else 'outdir?,srcdir?'
|
|
392
392
|
end)
|
|
393
393
|
task flag do |_, args|
|
|
394
|
-
|
|
394
|
+
build_ flag, args.to_a
|
|
395
395
|
end
|
|
396
396
|
break if be
|
|
397
397
|
when 'publish'
|
|
@@ -438,9 +438,9 @@ module Squared
|
|
|
438
438
|
if flag
|
|
439
439
|
cmd << case flag
|
|
440
440
|
when :requirement, :target
|
|
441
|
-
quote_option
|
|
441
|
+
quote_option flag, basepath(target)
|
|
442
442
|
else
|
|
443
|
-
shell_option
|
|
443
|
+
shell_option flag
|
|
444
444
|
end
|
|
445
445
|
op = append_pip flag, opts, pipopts(:install)
|
|
446
446
|
op.clear
|
|
@@ -614,7 +614,8 @@ module Squared
|
|
|
614
614
|
op.clear
|
|
615
615
|
when :user, :upgrade
|
|
616
616
|
op.concat(packages)
|
|
617
|
-
|
|
617
|
+
raise ArgumentError, message('no packages listed', hint: flag) if op.empty?
|
|
618
|
+
|
|
618
619
|
op << "--#{flag}"
|
|
619
620
|
op.append
|
|
620
621
|
python_session('-m pip', *op.to_a.drop(1)) if workspace.windows?
|
|
@@ -622,7 +623,7 @@ module Squared
|
|
|
622
623
|
run(banner: banner, from: :install)
|
|
623
624
|
end
|
|
624
625
|
|
|
625
|
-
def
|
|
626
|
+
def build_(flag, opts = [], outdir: nil, srcdir: nil)
|
|
626
627
|
list = case flag
|
|
627
628
|
when :poetry
|
|
628
629
|
cmd = poetry_session 'build'
|
|
@@ -685,7 +686,6 @@ module Squared
|
|
|
685
686
|
run(from: from)
|
|
686
687
|
end
|
|
687
688
|
end
|
|
688
|
-
alias build_ build!
|
|
689
689
|
|
|
690
690
|
def publish(flag, opts = [], test: false)
|
|
691
691
|
list = case flag
|
|
@@ -706,12 +706,9 @@ module Squared
|
|
|
706
706
|
dist = lambda do
|
|
707
707
|
dir = basepath 'dist'
|
|
708
708
|
return dir if dir.directory? && !dir.empty?
|
|
709
|
+
raise message('no source to publish', hint: dir) if dir.exist?
|
|
709
710
|
|
|
710
|
-
|
|
711
|
-
raise_error 'no source to publish', hint: dir
|
|
712
|
-
else
|
|
713
|
-
raise_error Errno::ENOENT, dir, hint: 'publish'
|
|
714
|
-
end
|
|
711
|
+
raise Errno::ENOENT, message(dir, hint: 'publish')
|
|
715
712
|
end
|
|
716
713
|
if test
|
|
717
714
|
if op.arg?('r', flag == :hatch ? 'repo' : 'repository')
|
|
@@ -772,7 +769,7 @@ module Squared
|
|
|
772
769
|
when :install, :uninstall
|
|
773
770
|
op << '.' if installable? && !op.arg?('r', 'requirement')
|
|
774
771
|
else
|
|
775
|
-
|
|
772
|
+
raise ArgumentError, message('no packages listed', hint: flag)
|
|
776
773
|
end
|
|
777
774
|
elsif flag == :install
|
|
778
775
|
op.append_any
|
|
@@ -795,7 +792,8 @@ module Squared
|
|
|
795
792
|
.clear
|
|
796
793
|
when :cache
|
|
797
794
|
op.concat(args)
|
|
798
|
-
|
|
795
|
+
raise message('no subcommand', hint: flag) if op.empty?
|
|
796
|
+
|
|
799
797
|
op << (action = op.shift)
|
|
800
798
|
case action
|
|
801
799
|
when 'dir', 'info', 'purge'
|
|
@@ -803,13 +801,15 @@ module Squared
|
|
|
803
801
|
when 'list', 'remove'
|
|
804
802
|
op.add_first(quote: true)
|
|
805
803
|
else
|
|
806
|
-
|
|
804
|
+
raise ArgumentError, message('unrecognized args', action, hint: flag)
|
|
807
805
|
end
|
|
808
806
|
op.clear
|
|
809
807
|
when :config
|
|
810
808
|
op.concat(args)
|
|
811
|
-
|
|
812
|
-
|
|
809
|
+
raise message('no subcommand', hint: flag) if op.empty?
|
|
810
|
+
|
|
811
|
+
action = op.shift
|
|
812
|
+
op << action
|
|
813
813
|
case action
|
|
814
814
|
when 'list', 'edit', 'debug'
|
|
815
815
|
nil
|
|
@@ -817,7 +817,7 @@ module Squared
|
|
|
817
817
|
op.add_first
|
|
818
818
|
op.add_first(quote: true, expect: true) if action == 'set'
|
|
819
819
|
else
|
|
820
|
-
|
|
820
|
+
raise ArgumentError, message('unrecognized args', action, hint: flag)
|
|
821
821
|
end
|
|
822
822
|
op.clear
|
|
823
823
|
when :hash
|
|
@@ -854,7 +854,7 @@ module Squared
|
|
|
854
854
|
def variable_set(key, *args, **, &blk)
|
|
855
855
|
if block_given?
|
|
856
856
|
case key
|
|
857
|
-
when :dependfile, :
|
|
857
|
+
when :dependfile, :venv
|
|
858
858
|
args = block_args args, &blk
|
|
859
859
|
end
|
|
860
860
|
end
|
|
@@ -871,8 +871,6 @@ module Squared
|
|
|
871
871
|
log.warn "variable_set: @dependfile=#{val}".subhint('not supported')
|
|
872
872
|
end
|
|
873
873
|
end
|
|
874
|
-
when :editable
|
|
875
|
-
editable_set args.first
|
|
876
874
|
when :venv
|
|
877
875
|
@venv = (basepath(*args) unless args.empty? || args.first.nil?)
|
|
878
876
|
else
|
|
@@ -1026,7 +1024,7 @@ module Squared
|
|
|
1026
1024
|
|
|
1027
1025
|
if found
|
|
1028
1026
|
line.chomp!($1) if line =~ /(?<=[\d"'{}\[\]]|true|false)(\s*#.*)$/
|
|
1029
|
-
break if line.match?(/^\s*\[(
|
|
1027
|
+
break if line.match?(/^\s*\[([\w.\-"' ]+|".+"|'.+')\]\s*$/)
|
|
1030
1028
|
|
|
1031
1029
|
if ch
|
|
1032
1030
|
val = line.rstrip
|
|
@@ -1130,7 +1128,7 @@ module Squared
|
|
|
1130
1128
|
end
|
|
1131
1129
|
|
|
1132
1130
|
def variables
|
|
1133
|
-
(super + %i[venv
|
|
1131
|
+
(super + %i[venv]).freeze
|
|
1134
1132
|
end
|
|
1135
1133
|
|
|
1136
1134
|
def runenv
|
|
@@ -382,7 +382,7 @@ module Squared
|
|
|
382
382
|
if val.include?('*')
|
|
383
383
|
out.concat(Dir.glob(val, base: path))
|
|
384
384
|
elsif !(file = basepath!(val))
|
|
385
|
-
print_error(
|
|
385
|
+
print_error('file not found', hint: val)
|
|
386
386
|
elsif file.directory?
|
|
387
387
|
out.concat(file.glob('**/*.rb'))
|
|
388
388
|
else
|
|
@@ -438,17 +438,18 @@ module Squared
|
|
|
438
438
|
when 'gem'
|
|
439
439
|
case flag
|
|
440
440
|
when :outdated
|
|
441
|
-
format_desc action, flag, "semver?=major|minor|patch,#{shortname('i', 's', 'u', 'd')},opts*"
|
|
441
|
+
format_desc action, flag, "semver?=(=)major|minor|patch,#{shortname('i', 's', 'u', 'd')},opts*"
|
|
442
442
|
task flag, [:semver] do |_, args|
|
|
443
|
-
opts =
|
|
444
|
-
|
|
443
|
+
opts = if args.semver =~ /^(=)?(major|minor|patch)$/i
|
|
444
|
+
equals = !$1.nil?
|
|
445
|
+
semver = $2.downcase
|
|
445
446
|
args.extras
|
|
446
447
|
else
|
|
447
|
-
semver = nil
|
|
448
448
|
args.to_a
|
|
449
449
|
end
|
|
450
450
|
gem(flag, opts: opts, banner: true, filter: {
|
|
451
451
|
semver: semver,
|
|
452
|
+
equals: equals,
|
|
452
453
|
update: has_value!(opts, 'u', 'update'),
|
|
453
454
|
interactive: has_value!(opts, 'i', 'interactive'),
|
|
454
455
|
select: has_value!(opts, 's', 'select'),
|
|
@@ -506,23 +507,16 @@ module Squared
|
|
|
506
507
|
format_desc action, flag, 'f/orce?,l/ocal?,opts*'
|
|
507
508
|
task flag do |_, args|
|
|
508
509
|
opts = args.to_a
|
|
509
|
-
opts << 'local' if has_value!(opts, 'l'
|
|
510
|
+
opts << 'local' if has_value!(opts, 'l')
|
|
510
511
|
opts << 'redownload' if has_value!(opts, 'f', 'force')
|
|
511
512
|
if (lock = basepath!('Gemfile.lock'))
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
print_error(
|
|
513
|
+
config = basepath '.bundle', 'config'
|
|
514
|
+
if config.exist? && config.read.match?(/\bBUNDLE_FROZEN:\s+"true"/)
|
|
515
|
+
if opts.include?('redownload')
|
|
516
|
+
run(bundle_output('config unset frozen'), banner: false)
|
|
517
|
+
else
|
|
518
|
+
print_error('Gemfile.lock is frozen', subject: name, hint: flag)
|
|
518
519
|
lock = nil
|
|
519
|
-
elsif basepath!('.bundle', 'config')&.read&.match?(/\bBUNDLE_FROZEN:\s+"true"/)
|
|
520
|
-
if opts.include?('redownload')
|
|
521
|
-
run(bundle_output('config unset frozen'), banner: false)
|
|
522
|
-
else
|
|
523
|
-
print_error('Gemfile.lock is frozen', subject: name, hint: flag)
|
|
524
|
-
lock = nil
|
|
525
|
-
end
|
|
526
520
|
end
|
|
527
521
|
end
|
|
528
522
|
lock&.delete
|
|
@@ -569,7 +563,7 @@ module Squared
|
|
|
569
563
|
else
|
|
570
564
|
%w[## ;]
|
|
571
565
|
end
|
|
572
|
-
msg = if
|
|
566
|
+
msg = if Prompt.reline.respond_to?(:readmultiline)
|
|
573
567
|
'ruby>'
|
|
574
568
|
else
|
|
575
569
|
multiline = Array(multiline)
|
|
@@ -698,9 +692,9 @@ module Squared
|
|
|
698
692
|
.lines
|
|
699
693
|
.map { |line| line.sub(/#.*$/, '').strip }
|
|
700
694
|
.reject(&:empty?)
|
|
701
|
-
.yield_self do |
|
|
702
|
-
target =
|
|
703
|
-
target ? [target] :
|
|
695
|
+
.yield_self do |lines|
|
|
696
|
+
target = lines.find { |line| line.include?(tool) }
|
|
697
|
+
target ? [target] : lines
|
|
704
698
|
end
|
|
705
699
|
.join(', ')
|
|
706
700
|
end
|
|
@@ -734,7 +728,7 @@ module Squared
|
|
|
734
728
|
out.map!(&:split)
|
|
735
729
|
pad = as_a(out, :first, :size).max
|
|
736
730
|
print_item
|
|
737
|
-
puts(out.map { |line| '%*s %s' % [pad, line.first, line
|
|
731
|
+
puts(out.map { |line| '%*s %s' % [pad, line.first, line.drop(1).join(' ')] })
|
|
738
732
|
end
|
|
739
733
|
end
|
|
740
734
|
when :reshim
|
|
@@ -1074,6 +1068,7 @@ module Squared
|
|
|
1074
1068
|
buffer = []
|
|
1075
1069
|
filter = kwargs.fetch(:filter, {})
|
|
1076
1070
|
semver = filter[:semver]
|
|
1071
|
+
equals = filter[:equals]
|
|
1077
1072
|
update = if sync && filter[:select]
|
|
1078
1073
|
semver ||= 'major'
|
|
1079
1074
|
items = []
|
|
@@ -1150,6 +1145,8 @@ module Squared
|
|
|
1150
1145
|
when 2
|
|
1151
1146
|
case semver
|
|
1152
1147
|
when 'major', 'minor'
|
|
1148
|
+
next if equals && semver == 'major'
|
|
1149
|
+
|
|
1153
1150
|
update&.push(a)
|
|
1154
1151
|
when 'patch'
|
|
1155
1152
|
next
|
|
@@ -1163,6 +1160,8 @@ module Squared
|
|
|
1163
1160
|
else
|
|
1164
1161
|
case semver
|
|
1165
1162
|
when 'major', 'minor', 'patch'
|
|
1163
|
+
next if equals && semver != 'patch'
|
|
1164
|
+
|
|
1166
1165
|
update&.push(a)
|
|
1167
1166
|
end
|
|
1168
1167
|
unless stdin?
|
|
@@ -1261,26 +1260,36 @@ module Squared
|
|
|
1261
1260
|
case flag
|
|
1262
1261
|
when :build
|
|
1263
1262
|
if op.empty?
|
|
1264
|
-
|
|
1263
|
+
raise Errno::ENOENT, message('gemspec', hint: project) unless gemfile
|
|
1264
|
+
|
|
1265
1265
|
op.add_path(gemfile)
|
|
1266
1266
|
else
|
|
1267
|
-
op.add_first(path: true)
|
|
1267
|
+
op.add_first(path: !op.first.include?('*'), quote: true)
|
|
1268
1268
|
.clear(pass: false)
|
|
1269
1269
|
end
|
|
1270
1270
|
when :push
|
|
1271
|
+
target = gemname
|
|
1271
1272
|
if op.empty? || (n = op.index(':'))
|
|
1272
1273
|
file = basepath(if !n && (spec = gemspec)
|
|
1273
1274
|
"#{spec.name}-#{spec.version}.gem"
|
|
1274
1275
|
else
|
|
1275
1276
|
choice_index 'Select a file', Dir.glob('*.gem', base: path)
|
|
1276
1277
|
end)
|
|
1278
|
+
op.add_path(file)
|
|
1279
|
+
elsif (file = op.shift).include?('*')
|
|
1280
|
+
file = '*.gem' if file == '*'
|
|
1281
|
+
target = Dir.glob(file, base: path).join(', ')
|
|
1282
|
+
raise Errno::ENOENT, message(file, hint: flag) if target.empty?
|
|
1283
|
+
|
|
1284
|
+
op.add_quote(file)
|
|
1277
1285
|
else
|
|
1278
|
-
file = basepath(
|
|
1279
|
-
|
|
1280
|
-
|
|
1286
|
+
file = basepath(file.include?('.') ? file : "#{file}.gem")
|
|
1287
|
+
raise Errno::ENOENT, message(file, hint: flag) unless file.exist?
|
|
1288
|
+
raise ArgumentError, message('unrecognized args', op.join(', '), hint: flag) unless op.empty?
|
|
1289
|
+
|
|
1290
|
+
op.add_path(file)
|
|
1281
1291
|
end
|
|
1282
|
-
|
|
1283
|
-
return run(from: from, interactive: ['Push', 'N', gemname]) unless with || !banner
|
|
1292
|
+
return run(from: from, interactive: ['Push', 'N', target]) unless with || !banner
|
|
1284
1293
|
when :exec
|
|
1285
1294
|
min = if op.arg?('g', 'gem')
|
|
1286
1295
|
1
|
|
@@ -1336,7 +1345,8 @@ module Squared
|
|
|
1336
1345
|
op.unshift(name)
|
|
1337
1346
|
end
|
|
1338
1347
|
end
|
|
1339
|
-
|
|
1348
|
+
raise ArgumentError, message('missing gem name', hint: flag) if op.empty?
|
|
1349
|
+
|
|
1340
1350
|
if op.arg?('all')
|
|
1341
1351
|
if flag == :pristine
|
|
1342
1352
|
append_repeat 'skip', op.extras
|
|
@@ -1376,7 +1386,7 @@ module Squared
|
|
|
1376
1386
|
op << action
|
|
1377
1387
|
op.clear
|
|
1378
1388
|
else
|
|
1379
|
-
|
|
1389
|
+
raise ArgumentError, message('unrecognized command', action, hint: flag)
|
|
1380
1390
|
end
|
|
1381
1391
|
end
|
|
1382
1392
|
when :open, :owner, :unpack, :yank
|
|
@@ -1413,7 +1423,7 @@ module Squared
|
|
|
1413
1423
|
end
|
|
1414
1424
|
end
|
|
1415
1425
|
opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
|
|
1416
|
-
invalid = ->(a) {
|
|
1426
|
+
invalid = ->(a) { raise ArgumentError, message('unrecognized args', a.join(', '), hint: flag) }
|
|
1417
1427
|
cmd = bundle_session flag
|
|
1418
1428
|
case flag
|
|
1419
1429
|
when :cache, :check, :clean, :init, :install, :lock, :pack, :package, :platform
|
|
@@ -1738,7 +1748,7 @@ module Squared
|
|
|
1738
1748
|
def project
|
|
1739
1749
|
return @project unless @project.frozen?
|
|
1740
1750
|
|
|
1741
|
-
@project = (
|
|
1751
|
+
@project = (gemspec&.name || @project).dup
|
|
1742
1752
|
end
|
|
1743
1753
|
|
|
1744
1754
|
def depend?
|
|
@@ -1833,8 +1843,8 @@ module Squared
|
|
|
1833
1843
|
private
|
|
1834
1844
|
|
|
1835
1845
|
def run_repl(*args, opts:, banner:, from:, delim: true, **kwargs)
|
|
1836
|
-
op = OptionPartition.new(opts, OPT_RUBY[from], session(*bundle_args(from)),
|
|
1837
|
-
|
|
1846
|
+
op = OptionPartition.new(opts, OPT_RUBY[from], session(*bundle_args(from)), project: self, strict: strict?,
|
|
1847
|
+
first: [/\.rb$/])
|
|
1838
1848
|
r = []
|
|
1839
1849
|
r << 'bundler/setup' if !op.arg?('r') && bundle_load
|
|
1840
1850
|
r.concat(Array(kwargs[:name])) if kwargs[:name]
|
|
@@ -1955,10 +1965,6 @@ module Squared
|
|
|
1955
1965
|
verbose? ? ['--verbose'] : []
|
|
1956
1966
|
end
|
|
1957
1967
|
|
|
1958
|
-
def variables
|
|
1959
|
-
(super + %i[autodetect]).freeze
|
|
1960
|
-
end
|
|
1961
|
-
|
|
1962
1968
|
def rakefile
|
|
1963
1969
|
if @rakefile.nil?
|
|
1964
1970
|
file = Rake::Application::DEFAULT_RAKEFILES.find { |val| exist?(val) }
|
|
@@ -20,8 +20,8 @@ module Squared
|
|
|
20
20
|
include Shell
|
|
21
21
|
include Prompt
|
|
22
22
|
|
|
23
|
-
def append(target, *args, delim: false, escape: false, quote: true, strip: nil,
|
|
24
|
-
|
|
23
|
+
def append(target, *args, delim: false, escape: false, quote: true, strip: nil, double: false, filter: nil,
|
|
24
|
+
pass: nil, **kwargs)
|
|
25
25
|
return if (ret = args.flatten(1)).empty?
|
|
26
26
|
|
|
27
27
|
target << '--' if delim && !target.include?('--')
|
|
@@ -52,7 +52,7 @@ module Squared
|
|
|
52
52
|
if !(pa = val.is_a?(Pathname)) && escape
|
|
53
53
|
shell_escape(val, quote: quote, double: double)
|
|
54
54
|
elsif quote || pa
|
|
55
|
-
shell_quote(val,
|
|
55
|
+
shell_quote(val, double: double, **kwargs)
|
|
56
56
|
else
|
|
57
57
|
val
|
|
58
58
|
end
|
|
@@ -135,7 +135,7 @@ module Squared
|
|
|
135
135
|
[name, $3, $2 || (name.size == 1 && $1.empty? ? true : '')]
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
def arg?(target, *args, value: false
|
|
138
|
+
def arg?(target, *args, value: false)
|
|
139
139
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
|
140
140
|
r << matchopts(s, value) unless s.empty?
|
|
141
141
|
a = target.to_a
|
|
@@ -315,7 +315,7 @@ module Squared
|
|
|
315
315
|
end
|
|
316
316
|
numtype = [
|
|
317
317
|
[i, /\A\d+\z/],
|
|
318
|
-
[f, /\A\d*(
|
|
318
|
+
[f, /\A\d*(\.\d+)?\z/],
|
|
319
319
|
[si, /\A-?\d+\z/]
|
|
320
320
|
].freeze
|
|
321
321
|
numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && v.match?(pat) } }
|
|
@@ -609,7 +609,7 @@ module Squared
|
|
|
609
609
|
val = OptionPartition.send(:matchopts, val) unless val.is_a?(Regexp)
|
|
610
610
|
blk = proc { |s| s&.match?(val) }
|
|
611
611
|
else
|
|
612
|
-
raise TypeError,
|
|
612
|
+
raise TypeError, Common::Format.message('unknown', val, hint: target.first)
|
|
613
613
|
end
|
|
614
614
|
end
|
|
615
615
|
ret = find_all(&blk)
|
|
@@ -658,10 +658,7 @@ module Squared
|
|
|
658
658
|
|
|
659
659
|
def readline(msg, fallback = nil, option: nil, quote: false, force: true, double: false)
|
|
660
660
|
begin
|
|
661
|
-
|
|
662
|
-
ret = Readline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
|
|
663
|
-
rescue LoadError
|
|
664
|
-
raise unless (ret = fallback) || !force
|
|
661
|
+
ret = Common::Prompt.reline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
|
|
665
662
|
rescue Interrupt
|
|
666
663
|
exit(force ? 1 : 0)
|
|
667
664
|
else
|
|
@@ -7,6 +7,15 @@ module Squared
|
|
|
7
7
|
module Utils
|
|
8
8
|
private
|
|
9
9
|
|
|
10
|
+
def symjoin(*args, char: ':')
|
|
11
|
+
args.flatten.join(char).to_sym
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def collect_hash(data, pass: [])
|
|
15
|
+
data = data.reject { |key,| pass.include?(key) } unless pass.empty?
|
|
16
|
+
data.values.flatten
|
|
17
|
+
end
|
|
18
|
+
|
|
10
19
|
def rand_s(size)
|
|
11
20
|
require 'random/formatter'
|
|
12
21
|
Random.new.alphanumeric(size)
|
|
@@ -26,29 +35,13 @@ module Squared
|
|
|
26
35
|
end
|
|
27
36
|
end
|
|
28
37
|
|
|
29
|
-
def matchmap(list, prefix
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if prefix
|
|
36
|
-
a = nil
|
|
37
|
-
val.sub!(/\A(\^|\\A)/) do |s|
|
|
38
|
-
a = s
|
|
39
|
-
nil
|
|
40
|
-
end
|
|
41
|
-
val = ".*#{val}" unless a
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
pat = Regexp.new("#{a}#{prefix}#{val == '*' ? '.+' : val}")
|
|
45
|
-
if negate
|
|
46
|
-
ret[n || 0] << pat
|
|
47
|
-
else
|
|
48
|
-
ret << pat
|
|
49
|
-
end
|
|
38
|
+
def matchmap(list, prefix: nil)
|
|
39
|
+
list.map do |val|
|
|
40
|
+
next val if val.is_a?(Regexp)
|
|
41
|
+
|
|
42
|
+
val = ".*#{val}" if prefix && !val.sub!(/\A(\^|\\A)/, '')
|
|
43
|
+
Regexp.new("#{prefix}#{val == '*' ? '.+' : val}")
|
|
50
44
|
end
|
|
51
|
-
ret
|
|
52
45
|
end
|
|
53
46
|
|
|
54
47
|
def matchany?(list, *args, empty: true)
|
|
@@ -20,7 +20,7 @@ module Squared
|
|
|
20
20
|
elsif !repo_install? && !repo_confirm
|
|
21
21
|
@root = nil
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
raise Errno::EEXIST, message(path.cleanpath, hint: 'REPO_HOME') unless @root
|
|
24
24
|
end
|
|
25
25
|
path.realdirpath
|
|
26
26
|
elsif (val = env('REPO_ROOT'))
|
|
@@ -28,7 +28,7 @@ module Squared
|
|
|
28
28
|
if !@root.exist?
|
|
29
29
|
@root.mkpath
|
|
30
30
|
elsif !repo_install?(parent: true) && !repo_confirm
|
|
31
|
-
|
|
31
|
+
raise Errno::EEXIST, message(@root, hint: 'REPO_ROOT')
|
|
32
32
|
end
|
|
33
33
|
@root.join(main).realdirpath
|
|
34
34
|
elsif repo_install?(parent: true) && (!home.exist? || @root + main == home)
|
|
@@ -157,6 +157,8 @@ module Squared
|
|
|
157
157
|
[proj, proj.build? && (script || run), doc && proj.doc?, lint && proj.lint?, test && proj.test?]
|
|
158
158
|
end
|
|
159
159
|
.select do |proj, run, doc, lint, test|
|
|
160
|
+
next unless proj
|
|
161
|
+
|
|
160
162
|
proj.doc(sync: true) if doc
|
|
161
163
|
proj.build(sync: true) if run
|
|
162
164
|
next if n.anybits?(4)
|
|
@@ -275,7 +277,7 @@ module Squared
|
|
|
275
277
|
end
|
|
276
278
|
end
|
|
277
279
|
|
|
278
|
-
def repo_run(cmd, opts = [], exception:
|
|
280
|
+
def repo_run(cmd, opts = [], exception: exception?, options: true, **kwargs)
|
|
279
281
|
cmd = [repo_bin, cmd]
|
|
280
282
|
cmd << opts.uniq.join(' ') unless opts.empty?
|
|
281
283
|
env('REPO_OPTIONS', **kwargs) { |val| cmd << val } if options
|
|
@@ -308,7 +310,7 @@ module Squared
|
|
|
308
310
|
r = r.keys
|
|
309
311
|
pass = g.empty? && r.empty?
|
|
310
312
|
select do |proj|
|
|
311
|
-
next unless proj.enabled?(baseref)
|
|
313
|
+
next unless proj.enabled?(ref: baseref)
|
|
312
314
|
|
|
313
315
|
proj.global_set(name)
|
|
314
316
|
i = -1
|
|
@@ -339,7 +341,7 @@ module Squared
|
|
|
339
341
|
task_invoke(name, **proj.workspace.invokeargs)
|
|
340
342
|
end
|
|
341
343
|
rescue => e
|
|
342
|
-
raise if exception
|
|
344
|
+
raise if exception?
|
|
343
345
|
|
|
344
346
|
warn log_warn(e, pass: true) if warning
|
|
345
347
|
end
|
|
@@ -38,10 +38,18 @@ module Squared
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
if (args = obj.batchargs)
|
|
41
|
-
|
|
41
|
+
if args.first.is_a?(Hash)
|
|
42
|
+
batch_set(obj.ref, *args)
|
|
43
|
+
else
|
|
44
|
+
batch_set(*args)
|
|
45
|
+
end
|
|
42
46
|
end
|
|
43
47
|
if (args = obj.aliasargs)
|
|
44
|
-
|
|
48
|
+
if args.first.is_a?(Hash)
|
|
49
|
+
alias_set(obj.ref, *args)
|
|
50
|
+
else
|
|
51
|
+
alias_set(*args)
|
|
52
|
+
end
|
|
45
53
|
end
|
|
46
54
|
end
|
|
47
55
|
workspace.config_get(:batch)&.each { |args| batch_set(*args) }
|