squared 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +123 -63
- data/README.md +662 -1273
- data/lib/squared/common/base.rb +1 -1
- data/lib/squared/common/format.rb +5 -3
- data/lib/squared/common/prompt.rb +1 -1
- data/lib/squared/common/shell.rb +7 -2
- data/lib/squared/common/system.rb +1 -1
- data/lib/squared/config.rb +8 -8
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +26 -8
- data/lib/squared/workspace/project/base.rb +94 -19
- data/lib/squared/workspace/project/docker.rb +2 -2
- data/lib/squared/workspace/project/git.rb +140 -118
- data/lib/squared/workspace/project/node.rb +18 -19
- data/lib/squared/workspace/project/python.rb +36 -19
- data/lib/squared/workspace/project/ruby.rb +97 -53
- data/lib/squared/workspace/project/support/class.rb +46 -3
- data/lib/squared/workspace/repo.rb +36 -13
- data/squared.gemspec +2 -2
- metadata +5 -6
- data/README.ruby.md +0 -728
@@ -74,7 +74,7 @@ module Squared
|
|
74
74
|
@revdoc = JSON.parse(@revfile.read) if @revfile.exist?
|
75
75
|
rescue StandardError => e
|
76
76
|
@revfile = nil
|
77
|
-
warn log_message(Logger::WARN, e, pass: true)
|
77
|
+
warn log_message(Logger::WARN, e, pass: true)
|
78
78
|
self
|
79
79
|
else
|
80
80
|
@revdoc = {} unless @revdoc.is_a?(Hash)
|
@@ -304,9 +304,9 @@ module Squared
|
|
304
304
|
include Rake::DSL
|
305
305
|
|
306
306
|
def populate(ws, **)
|
307
|
-
return if ws.series.exclude?(:pull, true)
|
307
|
+
return if ws.series.exclude?(:pull, true) || ws.size == 1
|
308
308
|
|
309
|
-
namespace
|
309
|
+
namespace ws.task_name('git') do |ns|
|
310
310
|
ws.format_desc(all = ws.task_join(ns.scope.path, 'all'), 'stash|rebase|autostash?,depend?')
|
311
311
|
task 'all' do |_, args|
|
312
312
|
args = args.to_a
|
@@ -358,7 +358,7 @@ module Squared
|
|
358
358
|
'restore' => %i[source staged worktree].freeze,
|
359
359
|
'rev' => %i[commit build output].freeze,
|
360
360
|
'show' => %i[format oneline textconv].freeze,
|
361
|
-
'stash' => %i[push pop apply branch drop clear list].freeze,
|
361
|
+
'stash' => %i[push pop apply branch drop clear list all].freeze,
|
362
362
|
'submodule' => %i[status update branch url sync].freeze,
|
363
363
|
'switch' => %i[branch create detach].freeze,
|
364
364
|
'tag' => %i[add sign delete list].freeze
|
@@ -505,7 +505,7 @@ module Squared
|
|
505
505
|
format_desc(action, flag, 'opts*', after: case flag
|
506
506
|
when :push then 'pathspec*'
|
507
507
|
when :branch then 'name,stash?|:'
|
508
|
-
when :clear, :list then nil
|
508
|
+
when :clear, :list, :all then nil
|
509
509
|
else 'stash?|:' end)
|
510
510
|
task flag do |_, args|
|
511
511
|
stash flag, args.to_a
|
@@ -626,12 +626,12 @@ module Squared
|
|
626
626
|
format_desc action, flag, 'ref,opts*'
|
627
627
|
task flag, [:commit] do |_, args|
|
628
628
|
commit = commithead args.commit
|
629
|
-
if commit
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
629
|
+
args = if commit
|
630
|
+
args.extras
|
631
|
+
else
|
632
|
+
commit, opts = choice_commit(values: ['Options'])
|
633
|
+
OptionPartition.strip(opts)
|
634
|
+
end
|
635
635
|
checkout(flag, args, commit: commit)
|
636
636
|
end
|
637
637
|
when :detach
|
@@ -804,28 +804,28 @@ module Squared
|
|
804
804
|
when :branch
|
805
805
|
format_desc action, flag, 'upstream,branch?=HEAD,opts*'
|
806
806
|
task flag, [:upstream] do |_, args|
|
807
|
-
if (upstream = args.upstream)
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
807
|
+
args = if (upstream = args.upstream)
|
808
|
+
args.extras
|
809
|
+
else
|
810
|
+
upstream, opts = choice_refs('Choose upstream branch', values: ['Options'])
|
811
|
+
OptionPartition.strip(opts)
|
812
|
+
end
|
813
813
|
rebase(flag, args, upstream: upstream)
|
814
814
|
end
|
815
815
|
when :onto
|
816
816
|
format_desc action, flag, 'ref,upstream,branch?=HEAD'
|
817
817
|
task flag, [:commit, :upstream, :branch] do |_, args|
|
818
818
|
commit = commithead args.commit
|
819
|
-
if commit
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
819
|
+
args = if commit
|
820
|
+
upstream = param_guard(action, flag, args: args, key: :upstream)
|
821
|
+
branch = args.branch
|
822
|
+
[]
|
823
|
+
else
|
824
|
+
commit = choice_refs 'Choose "onto" branch'
|
825
|
+
target, opts = choice_commit(multiple: 2, values: ['Options'], reflog: false)
|
826
|
+
branch, upstream = target
|
827
|
+
OptionPartition.strip(opts)
|
828
|
+
end
|
829
829
|
rebase(flag, args, commit: commit, upstream: upstream, branch: branch)
|
830
830
|
end
|
831
831
|
when :commit, :'no-commit'
|
@@ -889,13 +889,13 @@ module Squared
|
|
889
889
|
format_desc action, flag, 'ref,opts*,pathspec*'
|
890
890
|
task flag, [:commit] do |_, args|
|
891
891
|
commit = commithead args.commit
|
892
|
-
if commit
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
892
|
+
args = if commit
|
893
|
+
args.extras
|
894
|
+
else
|
895
|
+
commit, opts, files = choice_commit(values: ['Options', ['Pathspec', true]])
|
896
|
+
files = files&.shellsplit
|
897
|
+
OptionPartition.strip(opts)
|
898
|
+
end
|
899
899
|
restore(flag, args, commit: commit, files: files)
|
900
900
|
end
|
901
901
|
when :staged, :worktree
|
@@ -956,43 +956,9 @@ module Squared
|
|
956
956
|
def pull(flag = nil, opts = [], sync: invoked_sync?('pull', flag), remote: nil, hint: nil)
|
957
957
|
cmd, opts = git_session('pull', opts: opts)
|
958
958
|
cmd << '--autostash' if option('autostash')
|
959
|
-
|
960
|
-
when :rebase
|
959
|
+
if flag == :rebase
|
961
960
|
cmd << '--rebase'
|
962
|
-
when :all
|
963
|
-
unless git_spawn('status -s -z --untracked-files=all').empty?
|
964
|
-
if confirm('Stash local changes?', 'Y')
|
965
|
-
git_spawn 'stash push --keep-index --quiet'
|
966
|
-
elsif !(force = confirm('Force checkout?', 'N'))
|
967
|
-
return
|
968
|
-
end
|
969
|
-
end
|
970
|
-
op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
|
971
|
-
reg = if op.empty?
|
972
|
-
[]
|
973
|
-
else
|
974
|
-
opts = opts.reject { |val| op.extras.include?(val) }
|
975
|
-
matchmap op
|
976
|
-
end
|
977
|
-
session_done op.target
|
978
|
-
heads = []
|
979
|
-
cur = nil
|
980
|
-
foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
|
981
|
-
line.chomp!
|
982
|
-
cur ||= line.delete_prefix!('* ')
|
983
|
-
heads << line if matchany?(line, reg)
|
984
|
-
end
|
985
|
-
raise_error('head not found', hint: 'for-each-ref') unless cur
|
986
|
-
opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
|
987
|
-
(heads.dup << cur).each_with_index do |branch, index|
|
988
|
-
next unless (index < heads.size && cur != branch) || index == heads.size
|
989
|
-
|
990
|
-
git_spawn 'switch --quiet', force && '--force', shell_quote(branch)
|
991
|
-
pull(nil, opts, sync: false, hint: branch) if heads.include?(branch)
|
992
|
-
end
|
993
|
-
return
|
994
961
|
else
|
995
|
-
cmd << '--autostash' if flag == :autostash
|
996
962
|
option('rebase', ignore: false) do |val|
|
997
963
|
cmd << case val
|
998
964
|
when '0', 'false'
|
@@ -1001,10 +967,46 @@ module Squared
|
|
1001
967
|
VAL_GIT[:rebase][:value].include?(val) ? basic_option('rebase', val) : '--rebase'
|
1002
968
|
end
|
1003
969
|
end
|
970
|
+
case flag
|
971
|
+
when :all
|
972
|
+
unless git_spawn('status -s -z --untracked-files=all').empty?
|
973
|
+
if confirm('Stash local changes?', 'Y')
|
974
|
+
git_spawn 'stash push --keep-index --quiet'
|
975
|
+
elsif !(force = confirm('Force checkout?', 'N'))
|
976
|
+
return
|
977
|
+
end
|
978
|
+
end
|
979
|
+
op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
|
980
|
+
reg = if op.empty?
|
981
|
+
[]
|
982
|
+
else
|
983
|
+
opts = op.uniq(opts)
|
984
|
+
matchmap op
|
985
|
+
end
|
986
|
+
session_done op.target
|
987
|
+
heads = []
|
988
|
+
cur = nil
|
989
|
+
foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
|
990
|
+
line.chomp!
|
991
|
+
cur ||= line.delete_prefix!('* ')
|
992
|
+
heads << line if matchany?(line, reg)
|
993
|
+
end
|
994
|
+
raise_error('head not found', hint: 'for-each-ref') unless cur
|
995
|
+
opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
|
996
|
+
(heads.dup << cur).each_with_index do |branch, index|
|
997
|
+
next unless (index < heads.size && cur != branch) || index == heads.size
|
998
|
+
|
999
|
+
git_spawn 'switch --quiet', force && '--force', shell_quote(branch)
|
1000
|
+
pull(nil, opts, sync: false, hint: branch) if heads.include?(branch)
|
1001
|
+
end
|
1002
|
+
return
|
1003
|
+
when :autostash
|
1004
|
+
cmd << '--autostash'
|
1005
|
+
end
|
1004
1006
|
end
|
1005
1007
|
append_pull(opts, OPT_GIT[:pull] + OPT_GIT[:fetch][:pull],
|
1006
1008
|
no: OPT_GIT[:no][:pull] + OPT_GIT[:no][:fetch][:pull], remote: remote, flag: flag, from: :pull)
|
1007
|
-
source(sync: sync, sub: if
|
1009
|
+
source(sync: sync, sub: if stdout?
|
1008
1010
|
[
|
1009
1011
|
{ pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: color(:red), index: 4 },
|
1010
1012
|
{ pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: color(:green), index: 3 }
|
@@ -1033,6 +1035,10 @@ module Squared
|
|
1033
1035
|
cmd << upstream
|
1034
1036
|
append_head branch
|
1035
1037
|
else
|
1038
|
+
unless gitpath('REBASE_HEAD').exist?
|
1039
|
+
puts log_message(Logger::INFO, name, 'no rebase in progress', hint: command) if stdout?
|
1040
|
+
return
|
1041
|
+
end
|
1036
1042
|
return unless VAL_GIT[:rebase][:send].include?(command)
|
1037
1043
|
|
1038
1044
|
cmd << "--#{command}"
|
@@ -1086,6 +1092,10 @@ module Squared
|
|
1086
1092
|
|
1087
1093
|
def stash(flag = nil, opts = [], sync: invoked_sync?('stash', flag))
|
1088
1094
|
if flag
|
1095
|
+
if flag == :all
|
1096
|
+
opts << 'include-untracked'
|
1097
|
+
flag = :push
|
1098
|
+
end
|
1089
1099
|
cmd, opts = git_session('stash', flag, opts: opts)
|
1090
1100
|
list = OPT_GIT[:stash][:common] + OPT_GIT[:stash].fetch(flag, [])
|
1091
1101
|
if flag == :list
|
@@ -1158,7 +1168,7 @@ module Squared
|
|
1158
1168
|
end
|
1159
1169
|
append_pathspec
|
1160
1170
|
end
|
1161
|
-
if
|
1171
|
+
if stdout?
|
1162
1172
|
r = color(:red)
|
1163
1173
|
g = color(:green)
|
1164
1174
|
sub = if session_arg?('short')
|
@@ -1211,7 +1221,7 @@ module Squared
|
|
1211
1221
|
if (cur = workspace.rev_entry(name)) && cur['revision'] == sha && !env('REVBUILD_FORCE')
|
1212
1222
|
files = status_digest(*args, **kwargs)
|
1213
1223
|
if cur['files'].size == files.size && cur['files'].find { |key, val| files[key] != val }.nil?
|
1214
|
-
if
|
1224
|
+
if stdout?
|
1215
1225
|
if (since = workspace.rev_timesince(name, 'build'))
|
1216
1226
|
puts log_message(Logger::INFO, name, 'no changes', subject: 'revbuild', hint: "#{since} ago")
|
1217
1227
|
else
|
@@ -1276,7 +1286,6 @@ module Squared
|
|
1276
1286
|
append_option('track', equals: true)
|
1277
1287
|
cmd << (create ? quote_option(create, branch) : branch) << commit
|
1278
1288
|
when :track
|
1279
|
-
|
1280
1289
|
cmd << quote_option(branch.delete_prefix!('^') ? 'B' : 'b', branch) if branch
|
1281
1290
|
cmd << '--track' << shell_quote(origin)
|
1282
1291
|
when :detach
|
@@ -1360,15 +1369,14 @@ module Squared
|
|
1360
1369
|
op << '--no-index'
|
1361
1370
|
append_pathspec(refs, parent: true)
|
1362
1371
|
else
|
1372
|
+
op << '--merge-base' if option('merge-base')
|
1363
1373
|
case flag
|
1364
1374
|
when :view
|
1365
|
-
op << '--merge-base' if option('merge-base')
|
1366
1375
|
op.merge(range)
|
1367
1376
|
when :between, :contain
|
1368
1377
|
op.delete('--merge-base')
|
1369
1378
|
op.add_quote(range.join(flag == :between ? '..' : '...'))
|
1370
1379
|
else
|
1371
|
-
op << '--merge-base' if option('merge-base')
|
1372
1380
|
op.add_quote(branch) if branch
|
1373
1381
|
if !index.empty?
|
1374
1382
|
if op.arg?('cached')
|
@@ -1415,7 +1423,6 @@ module Squared
|
|
1415
1423
|
cmd, opts = git_session('add', opts: opts)
|
1416
1424
|
op = OptionPartition.new(opts, OPT_GIT[:add], cmd, project: self, first: matchpathspec)
|
1417
1425
|
op << '--verbose' if verbose
|
1418
|
-
dryrun = dryrun?
|
1419
1426
|
format = '%(if)%(HEAD)%(then)%(refname:short)...%(upstream:short)...%(upstream:track)%(end)'
|
1420
1427
|
git_spawn 'fetch --no-tags --quiet'
|
1421
1428
|
foreachref('heads', format: format).each do |line|
|
@@ -1424,16 +1431,16 @@ module Squared
|
|
1424
1431
|
branch, origin, hint = line.split('...')
|
1425
1432
|
if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
|
1426
1433
|
raise_error('work tree is not usable', hint: hint[1..-2])
|
1427
|
-
elsif origin.empty?
|
1434
|
+
elsif !origin || origin.empty?
|
1428
1435
|
return nil if pass
|
1429
|
-
break if dryrun
|
1436
|
+
break if dryrun?
|
1430
1437
|
|
1431
1438
|
unless (origin = option('upstream', prefix: 'git', ignore: false))
|
1432
1439
|
if (origin = choice_refs('Choose an upstream', 'remotes', attempts: 1, force: false))
|
1433
1440
|
git_spawn 'branch', quote_option('set-upstream-to', origin)
|
1434
|
-
|
1435
|
-
origin = readline('Enter an upstream', force: true)
|
1441
|
+
break
|
1436
1442
|
end
|
1443
|
+
origin = readline('Enter an upstream', force: true)
|
1437
1444
|
end
|
1438
1445
|
raise_error('missing remote name', hint: origin) unless origin.include?('/')
|
1439
1446
|
upstream = true
|
@@ -1447,7 +1454,7 @@ module Squared
|
|
1447
1454
|
end
|
1448
1455
|
co = git_session('commit', options: false)
|
1449
1456
|
pu = git_output 'push', upstream && '--set-upstream'
|
1450
|
-
if dryrun
|
1457
|
+
if dryrun?
|
1451
1458
|
op.delete('--dry-run')
|
1452
1459
|
co << '--dry-run'
|
1453
1460
|
pu << '--dry-run'
|
@@ -1462,8 +1469,14 @@ module Squared
|
|
1462
1469
|
pu.merge(repotrack(origin, branch))
|
1463
1470
|
puts if pass
|
1464
1471
|
source op
|
1465
|
-
|
1466
|
-
|
1472
|
+
if amend || !git_spawn('diff --cached --name-only --no-color').empty? || dryrun?
|
1473
|
+
source co
|
1474
|
+
source pu
|
1475
|
+
elsif banner?
|
1476
|
+
puts 'Nothing to commit'
|
1477
|
+
elsif stdout?
|
1478
|
+
puts log_message(Logger::INFO, name, 'nothing to commit', hint: flag)
|
1479
|
+
end
|
1467
1480
|
end
|
1468
1481
|
|
1469
1482
|
def merge(flag, opts = [], command: nil, branch: nil)
|
@@ -1480,6 +1493,10 @@ module Squared
|
|
1480
1493
|
append_commit(*op.extras)
|
1481
1494
|
end
|
1482
1495
|
else
|
1496
|
+
unless gitpath('MERGE_HEAD').exist?
|
1497
|
+
puts log_message(Logger::INFO, name, 'no merge in progress', hint: command) if stdout?
|
1498
|
+
return
|
1499
|
+
end
|
1483
1500
|
return unless VAL_GIT[:merge][:send].include?(command)
|
1484
1501
|
|
1485
1502
|
cmd << "--#{command}"
|
@@ -1521,10 +1538,8 @@ module Squared
|
|
1521
1538
|
end
|
1522
1539
|
force, list = refs.partition { |val| val.start_with?(/[~^]/) }
|
1523
1540
|
force.each do |val|
|
1524
|
-
|
1525
|
-
|
1526
|
-
r = '-r' if dr.include?('~')
|
1527
|
-
source git_output('branch', d, r, shell_quote(val.sub(/^[~^]+/, '')))
|
1541
|
+
r = '-r' if val.delete!('~')
|
1542
|
+
source git_output('branch', val.delete!('^') ? '-D' : '-d', r, shell_quote(val))
|
1528
1543
|
end
|
1529
1544
|
return if list.empty?
|
1530
1545
|
|
@@ -1532,8 +1547,9 @@ module Squared
|
|
1532
1547
|
append_value list
|
1533
1548
|
remote = nil
|
1534
1549
|
when :move, :copy
|
1535
|
-
|
1536
|
-
|
1550
|
+
s = "-#{flag.to_s[0]}"
|
1551
|
+
s.upcase! if option('force', 'f')
|
1552
|
+
cmd << s
|
1537
1553
|
refs.compact.each { |val| cmd << shell_quote(val) }
|
1538
1554
|
stdout = true
|
1539
1555
|
when :current
|
@@ -1553,12 +1569,12 @@ module Squared
|
|
1553
1569
|
list_result(ret, 'branches', from: from)
|
1554
1570
|
return
|
1555
1571
|
else
|
1556
|
-
head = git_spawn('rev-parse --abbrev-ref HEAD').chomp
|
1557
|
-
if head.empty?
|
1572
|
+
if (head = git_spawn('rev-parse --abbrev-ref HEAD').chomp).empty?
|
1558
1573
|
ret = 0
|
1559
1574
|
else
|
1560
1575
|
git_spawn 'fetch --all --prune --quiet' if option('sync')
|
1561
|
-
|
1576
|
+
cmd << '-vv --no-abbrev --list'
|
1577
|
+
out, banner, from = source(io: true)
|
1562
1578
|
ret = write_lines(out, grep: [/^\*\s+#{Regexp.escape(head)}\s/], banner: banner, first: true) do |line|
|
1563
1579
|
next line if stdin?
|
1564
1580
|
|
@@ -1624,10 +1640,13 @@ module Squared
|
|
1624
1640
|
op = OptionPartition.new(opts, OPT_GIT[:submodule].fetch(flag, []), cmd, project: self)
|
1625
1641
|
case flag
|
1626
1642
|
when :branch, :url
|
1643
|
+
op.adjoin("set-#{flag}")
|
1627
1644
|
op << '--'
|
1628
1645
|
op.add_path(path) if path
|
1629
1646
|
op.add_quote(url) if url
|
1630
1647
|
else
|
1648
|
+
op.adjoin(flag)
|
1649
|
+
op << '--recursive' if option('recursive', 'r')
|
1631
1650
|
op.splice(path: true)
|
1632
1651
|
end
|
1633
1652
|
source
|
@@ -1652,19 +1671,15 @@ module Squared
|
|
1652
1671
|
source(banner: false)
|
1653
1672
|
return
|
1654
1673
|
when :oneline
|
1655
|
-
format =
|
1674
|
+
format = flag.to_s
|
1656
1675
|
end
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
else
|
1665
|
-
opts << format
|
1666
|
-
end
|
1667
|
-
end
|
1676
|
+
case format
|
1677
|
+
when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
|
1678
|
+
cmd << basic_option('format', format)
|
1679
|
+
when /(?:^t?format:|%)/
|
1680
|
+
cmd << quote_option('pretty', format)
|
1681
|
+
else
|
1682
|
+
opts << format if format
|
1668
1683
|
end
|
1669
1684
|
op = OptionPartition.new(opts, OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log][:diff], cmd,
|
1670
1685
|
project: self,
|
@@ -1784,7 +1799,7 @@ module Squared
|
|
1784
1799
|
private
|
1785
1800
|
|
1786
1801
|
def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
|
1787
|
-
multiple: false, hint: nil, from: nil, **kwargs)
|
1802
|
+
multiple: false, hint: nil, from: nil, send: :system, **kwargs)
|
1788
1803
|
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
1789
1804
|
if io && banner == false
|
1790
1805
|
from = nil
|
@@ -1795,7 +1810,7 @@ module Squared
|
|
1795
1810
|
if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z\-]*\z/) })
|
1796
1811
|
from = :"git:#{from}"
|
1797
1812
|
end
|
1798
|
-
banner &&= cmd.temp { |val| val.start_with?(
|
1813
|
+
banner &&= cmd.temp { |val| val.start_with?(/--(?:work-tree|git-dir)/) }
|
1799
1814
|
end
|
1800
1815
|
from = nil if from == false
|
1801
1816
|
end
|
@@ -1824,7 +1839,7 @@ module Squared
|
|
1824
1839
|
end
|
1825
1840
|
elsif !kwargs[:sub] && (sync || (!exception && !stderr))
|
1826
1841
|
print_item banner unless multiple
|
1827
|
-
ret = shell(cmd, exception: exception)
|
1842
|
+
ret = shell(cmd, name: send, exception: exception)
|
1828
1843
|
else
|
1829
1844
|
require 'open3'
|
1830
1845
|
if stderr
|
@@ -1882,7 +1897,7 @@ module Squared
|
|
1882
1897
|
def list_result(size, type, grep: [], action: 'found', from: nil)
|
1883
1898
|
if size == 0
|
1884
1899
|
puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
|
1885
|
-
elsif
|
1900
|
+
elsif stdout?
|
1886
1901
|
styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
|
1887
1902
|
styles << :bold if styles.size <= 1
|
1888
1903
|
puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
|
@@ -1957,11 +1972,9 @@ module Squared
|
|
1957
1972
|
when 'rebase'
|
1958
1973
|
op << basic_option($1, $2) if VAL_GIT[:rebase][:value].include?($2)
|
1959
1974
|
when 'shallow-since'
|
1960
|
-
|
1961
|
-
|
1962
|
-
op << quote_option($1, val.strftime('%F %T'))
|
1975
|
+
op.append?($1) { Date.parse($2)&.strftime('%F %T') }
|
1963
1976
|
when 'recurse-submodules'
|
1964
|
-
op
|
1977
|
+
op.append?($1, $2, type: :basic)
|
1965
1978
|
when 'refspec'
|
1966
1979
|
refspec << shell_escape($2, quote: true)
|
1967
1980
|
end
|
@@ -1971,7 +1984,7 @@ module Squared
|
|
1971
1984
|
op.errors << opt
|
1972
1985
|
end
|
1973
1986
|
end
|
1974
|
-
op << '--verbose' if (flag || from == :fetch) &&
|
1987
|
+
op << '--verbose' if (flag || from == :fetch) && stdout? && !op.arg?('quiet')
|
1975
1988
|
if remote
|
1976
1989
|
op.append(remote, delim: true)
|
1977
1990
|
if (val = option('refspec', target: target, strict: true))
|
@@ -1984,7 +1997,7 @@ module Squared
|
|
1984
1997
|
op.swap.merge(op.map! { |opt| shell_escape(opt, quote: true) })
|
1985
1998
|
return
|
1986
1999
|
elsif option('all')
|
1987
|
-
|
2000
|
+
op << '--all'
|
1988
2001
|
end
|
1989
2002
|
op.clear(errors: true, subject: flag.to_s) if flag
|
1990
2003
|
end
|
@@ -2072,8 +2085,17 @@ module Squared
|
|
2072
2085
|
git_session(*cmd, main: false, options: false, **kwargs)
|
2073
2086
|
end
|
2074
2087
|
|
2075
|
-
def git_spawn(*cmd, stdout: true)
|
2076
|
-
|
2088
|
+
def git_spawn(*cmd, exception: true, io: true, sync: true, stdout: true, banner: false, **kwargs)
|
2089
|
+
kwargs[:send] = if sync
|
2090
|
+
:system
|
2091
|
+
else
|
2092
|
+
exception = false
|
2093
|
+
io = false
|
2094
|
+
stdout = false
|
2095
|
+
:spawn
|
2096
|
+
end
|
2097
|
+
source(cmd.first.is_a?(Set) ? cmd.first : git_output(*cmd), exception: exception, io: io, sync: sync,
|
2098
|
+
stdout: stdout, banner: banner, **kwargs)
|
2077
2099
|
end
|
2078
2100
|
|
2079
2101
|
def dryrun?(*, target: @session, **)
|
@@ -2088,8 +2110,8 @@ module Squared
|
|
2088
2110
|
target.include?('--quiet') || (target.include?('-q') && stripext(target.first) == 'git')
|
2089
2111
|
end
|
2090
2112
|
|
2091
|
-
def gitpath
|
2092
|
-
path
|
2113
|
+
def gitpath(*args)
|
2114
|
+
path.join('.git', *args)
|
2093
2115
|
end
|
2094
2116
|
|
2095
2117
|
def repotrack(origin, branch, quote: true)
|
@@ -98,7 +98,7 @@ module Squared
|
|
98
98
|
'pack' => nil
|
99
99
|
})
|
100
100
|
|
101
|
-
def initialize(*, init: nil, **kwargs)
|
101
|
+
def initialize(*, init: nil, asdf: 'nodejs', **kwargs)
|
102
102
|
super
|
103
103
|
if @pass.include?(Node.ref)
|
104
104
|
initialize_ref Node.ref
|
@@ -141,12 +141,12 @@ module Squared
|
|
141
141
|
depend(:add, packages: packages, save: save, exact: exact)
|
142
142
|
end
|
143
143
|
when 'run'
|
144
|
-
next if
|
144
|
+
next if scripts.empty?
|
145
145
|
|
146
146
|
format_desc action, nil, "script,opts*|#{indexchar}index+|#,pattern*"
|
147
147
|
task action, [:script] do |_, args|
|
148
148
|
if args.script == '#'
|
149
|
-
format_list(
|
149
|
+
format_list(scripts.to_a, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile)
|
150
150
|
else
|
151
151
|
args = param_guard(action, 'script', args: args.to_a)
|
152
152
|
opts = []
|
@@ -782,15 +782,15 @@ module Squared
|
|
782
782
|
log.info "bump version #{cur} to #{val} (#{flag})"
|
783
783
|
on :first, :bump
|
784
784
|
end
|
785
|
-
if
|
785
|
+
if stdin?
|
786
|
+
puts val
|
787
|
+
elsif verbose
|
786
788
|
major = flag == :major
|
787
789
|
emphasize("version: #{val}", title: name, border: borderstyle, sub: [
|
788
790
|
headerstyle,
|
789
791
|
{ pat: /\A(version:)( )(\S+)(.*)\z/, styles: color(major ? :green : :yellow), index: 3 },
|
790
792
|
{ pat: /\A(version:)(.*)\z/, styles: theme[major ? :major : :active] }
|
791
793
|
])
|
792
|
-
elsif stdin?
|
793
|
-
puts val
|
794
794
|
end
|
795
795
|
on :last, :bump unless dryrun?
|
796
796
|
else
|
@@ -807,7 +807,7 @@ module Squared
|
|
807
807
|
cmd = session dependbin, 'pack'
|
808
808
|
if dependtype(:yarn) > 1
|
809
809
|
op = OptionPartition.new(opts, OPT_BERRY[:pack], cmd, project: self)
|
810
|
-
op
|
810
|
+
op.append?('out', Pathname.pwd + "#{project}-#{version}.tgz")
|
811
811
|
else
|
812
812
|
op = OptionPartition.new(opts, pnpm? ? OPT_PNPM[:pack] : OPT_NPM[:pack] + OPT_NPM[:common], cmd,
|
813
813
|
project: self)
|
@@ -822,7 +822,7 @@ module Squared
|
|
822
822
|
end
|
823
823
|
end
|
824
824
|
end
|
825
|
-
op
|
825
|
+
op.append?('pack-destination', Dir.pwd)
|
826
826
|
end
|
827
827
|
op.clear
|
828
828
|
run(from: :pack)
|
@@ -936,13 +936,17 @@ module Squared
|
|
936
936
|
end
|
937
937
|
|
938
938
|
def version
|
939
|
-
|
939
|
+
self.version ||= read_packagemanager(:version)
|
940
940
|
end
|
941
941
|
|
942
942
|
def packagename
|
943
943
|
read_packagemanager :name
|
944
944
|
end
|
945
945
|
|
946
|
+
def scripts
|
947
|
+
@scripts ||= read_packagemanager(:scripts).yield_self { |ret| ret.is_a?(Hash) ? ret : {} }
|
948
|
+
end
|
949
|
+
|
946
950
|
private
|
947
951
|
|
948
952
|
def read_packagemanager(key = nil, version: nil, update: false)
|
@@ -974,13 +978,8 @@ module Squared
|
|
974
978
|
ret
|
975
979
|
end
|
976
980
|
|
977
|
-
def read_scripts
|
978
|
-
ret = read_packagemanager(:scripts)
|
979
|
-
ret.is_a?(Hash) ? ret.to_a : []
|
980
|
-
end
|
981
|
-
|
982
981
|
def append_loglevel(target: @session)
|
983
|
-
level = env
|
982
|
+
level = env('NODE_LOGLEVEL')
|
984
983
|
silent = !verbose || level == 'silent'
|
985
984
|
return unless silent || level
|
986
985
|
|
@@ -1011,10 +1010,6 @@ module Squared
|
|
1011
1010
|
end
|
1012
1011
|
end
|
1013
1012
|
|
1014
|
-
def dryrun?(prefix = dependbin, **)
|
1015
|
-
super || !option('dry-run', prefix: prefix).nil?
|
1016
|
-
end
|
1017
|
-
|
1018
1013
|
def dependbin
|
1019
1014
|
if yarn?
|
1020
1015
|
'yarn'
|
@@ -1039,6 +1034,10 @@ module Squared
|
|
1039
1034
|
{ pat: /^(npm )(.+)$/, styles: :bold }
|
1040
1035
|
]
|
1041
1036
|
end
|
1037
|
+
|
1038
|
+
def dryrun?(prefix = dependbin, **)
|
1039
|
+
super || !option('dry-run', prefix: prefix).nil?
|
1040
|
+
end
|
1042
1041
|
end
|
1043
1042
|
|
1044
1043
|
Application.implement Node
|