squared 0.4.13 → 0.4.14
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 +70 -0
- data/README.ruby.md +1 -1
- data/lib/squared/common/base.rb +5 -2
- data/lib/squared/common/format.rb +8 -2
- data/lib/squared/common/prompt.rb +1 -1
- data/lib/squared/common/system.rb +21 -14
- data/lib/squared/common/utils.rb +7 -3
- data/lib/squared/config.rb +6 -5
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +20 -12
- data/lib/squared/workspace/project/base.rb +99 -60
- data/lib/squared/workspace/project/docker.rb +12 -9
- data/lib/squared/workspace/project/git.rb +71 -42
- data/lib/squared/workspace/project/node.rb +37 -41
- data/lib/squared/workspace/project/python.rb +244 -46
- data/lib/squared/workspace/project/ruby.rb +119 -92
- data/lib/squared/workspace/project/support/class.rb +37 -1
- data/lib/squared/workspace/repo.rb +2 -1
- data/lib/squared/workspace/support/data.rb +2 -2
- metadata +1 -1
@@ -27,7 +27,7 @@ module Squared
|
|
27
27
|
base = name
|
28
28
|
@project.each_value { |proj| repo << proj if !proj.parent && check.call(proj) }
|
29
29
|
else
|
30
|
-
warn log_message(Logger::WARN, name, subject: 'git', hint: 'invalid'
|
30
|
+
warn log_message(Logger::WARN, name, subject: 'git', hint: 'invalid') if warning
|
31
31
|
return self
|
32
32
|
end
|
33
33
|
if base
|
@@ -340,7 +340,7 @@ module Squared
|
|
340
340
|
'restore' => %i[source staged worktree].freeze,
|
341
341
|
'rev' => %i[commit build output].freeze,
|
342
342
|
'show' => %i[format oneline textconv].freeze,
|
343
|
-
'stash' => %i[push pop apply drop clear list].freeze,
|
343
|
+
'stash' => %i[push pop apply branch drop clear list].freeze,
|
344
344
|
'switch' => %i[create detach merge].freeze,
|
345
345
|
'tag' => %i[add sign delete list].freeze
|
346
346
|
})
|
@@ -367,13 +367,13 @@ module Squared
|
|
367
367
|
case action
|
368
368
|
when 'pull', 'fetch'
|
369
369
|
if flag == :remote
|
370
|
-
format_desc action, flag, 'remote
|
370
|
+
format_desc action, flag, 'remote?,opts*'
|
371
371
|
task flag, [:remote] do |_, args|
|
372
372
|
if (remote = args.remote)
|
373
373
|
args = args.extras
|
374
374
|
else
|
375
375
|
remote = choice_remote
|
376
|
-
args = args.to_a
|
376
|
+
args = args.to_a
|
377
377
|
end
|
378
378
|
__send__(action, flag, args, remote: remote)
|
379
379
|
end
|
@@ -459,6 +459,7 @@ module Squared
|
|
459
459
|
when 'stash'
|
460
460
|
format_desc(action, flag, 'opts*', after: case flag
|
461
461
|
when :push then 'pathspec*'
|
462
|
+
when :branch then 'name,stash?|:'
|
462
463
|
when :clear, :list then nil
|
463
464
|
else 'stash?|:' end)
|
464
465
|
task flag do |_, args|
|
@@ -927,7 +928,7 @@ module Squared
|
|
927
928
|
source(sync: sync, sub: if verbose
|
928
929
|
[
|
929
930
|
{ pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: color(:red), index: 4 },
|
930
|
-
{ pat: /^(.+)(\|\s+\d+\s+)(\++)(
|
931
|
+
{ pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: color(:green), index: 3 }
|
931
932
|
]
|
932
933
|
end, **threadargs)
|
933
934
|
end
|
@@ -942,7 +943,7 @@ module Squared
|
|
942
943
|
return unless upstream
|
943
944
|
|
944
945
|
op = OptionPartition.new(opts, OPT_GIT[:rebase], cmd, project: self, no: OPT_GIT[:no][:rebase])
|
945
|
-
cmd <<
|
946
|
+
cmd << upstream
|
946
947
|
append_head op.shift
|
947
948
|
op.clear(pass: false)
|
948
949
|
when :onto
|
@@ -950,7 +951,7 @@ module Squared
|
|
950
951
|
|
951
952
|
cmd << '--interactive' if option('interactive', 'i')
|
952
953
|
cmd << shell_option('onto', commit) if commit
|
953
|
-
cmd <<
|
954
|
+
cmd << upstream
|
954
955
|
append_head branch
|
955
956
|
else
|
956
957
|
return unless VAL_GIT[:rebase][:send].include?(command)
|
@@ -1012,12 +1013,26 @@ module Squared
|
|
1012
1013
|
case flag
|
1013
1014
|
when :push
|
1014
1015
|
append_pathspec op.extras
|
1015
|
-
when :pop, :apply, :drop
|
1016
|
+
when :pop, :apply, :drop, :branch
|
1016
1017
|
if op.extras.delete(':')
|
1017
|
-
|
1018
|
-
|
1018
|
+
if flag == :branch
|
1019
|
+
if op.empty?
|
1020
|
+
values = [['Branch name', true]]
|
1021
|
+
else
|
1022
|
+
op << op.pop
|
1023
|
+
end
|
1024
|
+
end
|
1025
|
+
out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
|
1026
|
+
values: values, column: /^[^@]+@\{(\d+)\}/, force: true)
|
1027
|
+
if values
|
1028
|
+
op.merge(out.reverse)
|
1029
|
+
else
|
1030
|
+
op << out
|
1031
|
+
end
|
1019
1032
|
elsif !op.empty?
|
1020
|
-
op <<
|
1033
|
+
op << op.pop
|
1034
|
+
elsif flag == :branch
|
1035
|
+
raise_error 'no branch name'
|
1021
1036
|
end
|
1022
1037
|
op.clear
|
1023
1038
|
when :clear
|
@@ -1079,8 +1094,8 @@ module Squared
|
|
1079
1094
|
def revbuild(flag = nil, opts = [], sync: nil, **kwargs)
|
1080
1095
|
statusargs = lambda do
|
1081
1096
|
{
|
1082
|
-
include: relativepath(
|
1083
|
-
exclude: relativepath(
|
1097
|
+
include: relativepath(Array(kwargs[:include]), all: true),
|
1098
|
+
exclude: relativepath(Array(kwargs[:exclude]), all: true)
|
1084
1099
|
}
|
1085
1100
|
end
|
1086
1101
|
unless workspace.closed
|
@@ -1189,13 +1204,14 @@ module Squared
|
|
1189
1204
|
else
|
1190
1205
|
op = OptionPartition.new(opts, OPT_GIT[:checkout], cmd, project: self, no: OPT_GIT[:no][:checkout],
|
1191
1206
|
first: flag == :path ? matchpathspec : nil)
|
1192
|
-
if flag == :
|
1193
|
-
op.append(commit)
|
1194
|
-
.clear(pass: false)
|
1195
|
-
else
|
1207
|
+
if flag == :path
|
1196
1208
|
append_head
|
1197
1209
|
append_pathspec(op.extras, pass: false)
|
1210
|
+
print_success if success?(source)
|
1211
|
+
return
|
1198
1212
|
end
|
1213
|
+
op.append(commit)
|
1214
|
+
.clear(pass: false)
|
1199
1215
|
end
|
1200
1216
|
source
|
1201
1217
|
end
|
@@ -1235,9 +1251,9 @@ module Squared
|
|
1235
1251
|
|
1236
1252
|
def log!(flag, opts = [], range: [], index: [])
|
1237
1253
|
cmd, opts = git_session('log', opts: opts)
|
1238
|
-
op = OptionPartition.new(opts, collect_hash(OPT_GIT[:log]), cmd,
|
1239
|
-
|
1240
|
-
|
1254
|
+
op = OptionPartition.new(opts, collect_hash(OPT_GIT[:log]), cmd, project: self,
|
1255
|
+
no: collect_hash(OPT_GIT[:no][:log]),
|
1256
|
+
first: matchpathspec)
|
1241
1257
|
case flag
|
1242
1258
|
when :between, :contain
|
1243
1259
|
op << shell_quote(range.join(flag == :between ? '..' : '...'))
|
@@ -1624,19 +1640,20 @@ module Squared
|
|
1624
1640
|
red = color(:red)
|
1625
1641
|
grep.map! { |val| Regexp.new(val[1..-2]) }
|
1626
1642
|
files = status_data.map! do |a, b|
|
1627
|
-
next
|
1643
|
+
next if b.strip.empty? || (!grep.empty? && grep.none? { |pat| pat.match?(a) })
|
1628
1644
|
|
1629
1645
|
"#{sub_style(b, styles: red)} #{a}"
|
1630
1646
|
end
|
1631
1647
|
.compact
|
1632
1648
|
unless files.empty?
|
1633
1649
|
files = choice_index('Select files', files, multiple: true, force: true, trim: /^\S+\s/,
|
1634
|
-
accept: 'Add?')
|
1650
|
+
accept: [['Add?', false, true]])
|
1635
1651
|
end
|
1636
1652
|
op.swap(list + files)
|
1637
1653
|
end
|
1638
1654
|
end
|
1639
|
-
append_pathspec(op.extras)
|
1655
|
+
return source(git_session('status', '-s'), banner: false) unless append_pathspec(op.extras)
|
1656
|
+
|
1640
1657
|
verbose = flag == :add && !op.arg?('verbose')
|
1641
1658
|
print_success if success?(source) && verbose
|
1642
1659
|
return
|
@@ -1665,30 +1682,36 @@ module Squared
|
|
1665
1682
|
private
|
1666
1683
|
|
1667
1684
|
def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
|
1668
|
-
multiple: false, **kwargs)
|
1685
|
+
multiple: false, from: nil, **kwargs)
|
1669
1686
|
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1687
|
+
if io && banner == false
|
1688
|
+
from = nil
|
1689
|
+
banner = nil
|
1690
|
+
else
|
1691
|
+
banner = nil if banner && (multiple || !banner?)
|
1692
|
+
if cmd.respond_to?(:done)
|
1693
|
+
if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z\-]*\z/) })
|
1694
|
+
from = :"git:#{from}"
|
1695
|
+
end
|
1696
|
+
banner &&= cmd.temp { |val| val.start_with?('--work-tree') || val.start_with?('--git-dir') }
|
1676
1697
|
end
|
1677
|
-
|
1698
|
+
from = nil if from == false
|
1678
1699
|
end
|
1679
1700
|
cmd = session_done cmd
|
1680
1701
|
log&.info cmd
|
1681
|
-
on :first, from
|
1682
1702
|
banner = if banner
|
1683
1703
|
format_banner((banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), ''), banner: true)
|
1684
1704
|
end
|
1705
|
+
on :first, from
|
1685
1706
|
begin
|
1686
1707
|
if io
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1708
|
+
ret = if stdout
|
1709
|
+
`#{cmd}`
|
1710
|
+
else
|
1711
|
+
banner ? [IO.popen(cmd), banner, from] : IO.popen(cmd)
|
1712
|
+
end
|
1713
|
+
return ret
|
1714
|
+
elsif stdin? ? sync : stdout
|
1692
1715
|
print_item banner unless multiple
|
1693
1716
|
ret = `#{cmd}`
|
1694
1717
|
if !ret.empty?
|
@@ -1696,7 +1719,7 @@ module Squared
|
|
1696
1719
|
elsif success?(!banner.nil?)
|
1697
1720
|
print_success
|
1698
1721
|
end
|
1699
|
-
elsif sync || (!exception && !stderr)
|
1722
|
+
elsif !kwargs[:sub] && (sync || (!exception && !stderr))
|
1700
1723
|
print_item banner unless multiple
|
1701
1724
|
ret = shell(cmd, exception: exception)
|
1702
1725
|
else
|
@@ -1889,6 +1912,7 @@ module Squared
|
|
1889
1912
|
def append_pathspec(files = [], target: @session, expect: false, parent: false, pass: true)
|
1890
1913
|
if session_arg?('pathspec-from-file', target: target)
|
1891
1914
|
option_clear files
|
1915
|
+
true
|
1892
1916
|
else
|
1893
1917
|
if files.empty? && (val = option('pathspec', target: target))
|
1894
1918
|
files = split_escape val
|
@@ -1896,8 +1920,11 @@ module Squared
|
|
1896
1920
|
files = projectmap(files, parent: parent, pass: pass)
|
1897
1921
|
if !files.empty?
|
1898
1922
|
target << '--' << files.join(' ')
|
1923
|
+
true
|
1899
1924
|
elsif expect
|
1900
1925
|
raise_error(parent ? 'pathspec not present' : 'pathspec not within worktree')
|
1926
|
+
else
|
1927
|
+
false
|
1901
1928
|
end
|
1902
1929
|
end
|
1903
1930
|
end
|
@@ -1940,8 +1967,10 @@ module Squared
|
|
1940
1967
|
end
|
1941
1968
|
|
1942
1969
|
def foreachref(path, *args, format: nil)
|
1943
|
-
path =
|
1944
|
-
|
1970
|
+
path = Array(path).map! { |val| "refs/#{val}" }
|
1971
|
+
format &&= quote_option('format', format)
|
1972
|
+
ret = git_spawn('for-each-ref', format, *args, *path, stdout: workspace.windows?)
|
1973
|
+
ret.is_a?(String) ? ret.lines : ret
|
1945
1974
|
end
|
1946
1975
|
|
1947
1976
|
def git_session(*cmd, opts: nil, worktree: true, **kwargs)
|
@@ -1979,8 +2008,8 @@ module Squared
|
|
1979
2008
|
|
1980
2009
|
def repotrack(origin, branch, quote: true)
|
1981
2010
|
i = origin.index('/')
|
1982
|
-
branch = "#{branch}:#{origin[i + 1..-1]}" unless origin.end_with?("/#{branch}")
|
1983
|
-
ret = [origin[0..i - 1], branch]
|
2011
|
+
branch = "#{branch}:#{origin[(i + 1)..-1]}" unless origin.end_with?("/#{branch}")
|
2012
|
+
ret = [origin[0..(i - 1)], branch]
|
1984
2013
|
quote ? ret.map! { |val| shell_quote(val) } : ret
|
1985
2014
|
end
|
1986
2015
|
|
@@ -134,7 +134,7 @@ module Squared
|
|
134
134
|
end
|
135
135
|
case save
|
136
136
|
when 'prod', 'dev', 'optional', 'peer'
|
137
|
-
packages = args.
|
137
|
+
packages = args.extras
|
138
138
|
else
|
139
139
|
save = 'prod'
|
140
140
|
packages = args.to_a
|
@@ -145,10 +145,10 @@ module Squared
|
|
145
145
|
when 'run'
|
146
146
|
next if (list = read_scripts).empty?
|
147
147
|
|
148
|
-
format_desc action, nil,
|
148
|
+
format_desc action, nil, "script,opts*|#{indexchar}index+|#,pattern*"
|
149
149
|
task action, [:script] do |_, args|
|
150
150
|
if args.script == '#'
|
151
|
-
format_list(list,
|
151
|
+
format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile)
|
152
152
|
else
|
153
153
|
args = param_guard(action, 'script', args: args.to_a)
|
154
154
|
opts = []
|
@@ -185,7 +185,7 @@ module Squared
|
|
185
185
|
format_desc action, nil, 'pkg/cmd,opts*,args*'
|
186
186
|
task action, [:package] do |_, args|
|
187
187
|
if (package = args.package)
|
188
|
-
args = args.
|
188
|
+
args = args.extras
|
189
189
|
if pnpm?
|
190
190
|
pre = ->(ch) { "-#{ch}" if (ch = args.delete(ch)) }
|
191
191
|
cmd = session 'pnpm', pre.call('r'), pre.call('c'), 'exec'
|
@@ -226,7 +226,7 @@ module Squared
|
|
226
226
|
outdated flag, args.to_a
|
227
227
|
end
|
228
228
|
when 'package'
|
229
|
-
format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : '
|
229
|
+
format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : 'name*')
|
230
230
|
task flag do |_, args|
|
231
231
|
package flag, args.to_a
|
232
232
|
end
|
@@ -336,7 +336,7 @@ module Squared
|
|
336
336
|
next unless from && dest&.directory?
|
337
337
|
|
338
338
|
from = path + from
|
339
|
-
glob =
|
339
|
+
glob = Array(glob || '**/*')
|
340
340
|
target = []
|
341
341
|
if workspace
|
342
342
|
Dir.glob(from + '*').each do |path|
|
@@ -448,7 +448,7 @@ module Squared
|
|
448
448
|
ret = on(:error, :outdated, e)
|
449
449
|
raise if exception && ret != true
|
450
450
|
end
|
451
|
-
warn log_message(Logger::WARN, e
|
451
|
+
warn log_message(Logger::WARN, e) if warning?
|
452
452
|
return
|
453
453
|
else
|
454
454
|
dep1 = json['dependencies'] || {}
|
@@ -596,50 +596,43 @@ module Squared
|
|
596
596
|
end
|
597
597
|
|
598
598
|
def update(*)
|
599
|
-
package
|
599
|
+
package('update', from: :update)
|
600
600
|
end
|
601
601
|
|
602
602
|
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, dryrun: nil, access: nil)
|
603
|
-
if read_packagemanager(:private)
|
604
|
-
|
605
|
-
warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: 'private', pass: true)
|
606
|
-
end
|
603
|
+
if !version || read_packagemanager(:private)
|
604
|
+
warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: version ? 'private' : nil)
|
607
605
|
return
|
608
606
|
end
|
609
|
-
return unless version
|
610
|
-
|
611
607
|
cmd = session 'npm', 'publish'
|
612
|
-
dryrun = dryrun?('npm') if dryrun.nil?
|
613
608
|
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
614
609
|
cmd << basic_option('tag', tag) if tag ||= option('tag')
|
615
610
|
cmd << basic_option('access', access) if access ||= option('access')
|
616
|
-
if
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
611
|
+
dryrun = dryrun?('npm') if dryrun.nil?
|
612
|
+
if dryrun
|
613
|
+
cmd << '--dry-run'
|
614
|
+
else
|
615
|
+
from = :publish
|
616
|
+
log.info cmd.to_s
|
617
|
+
end
|
618
|
+
if sync
|
619
|
+
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(project, styles: theme[:active])}")
|
620
|
+
else
|
621
|
+
on :first, from
|
622
|
+
pwd_set(from: :publish, dryrun: dryrun) do
|
623
|
+
require 'open3'
|
624
|
+
banner = format_banner(cmd.to_s)
|
625
|
+
Open3.popen2e(cmd.done) do |_, out|
|
626
|
+
write_lines(out, banner: banner, sub: npmnotice + [
|
627
|
+
{ pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2 }
|
628
|
+
])
|
632
629
|
end
|
633
|
-
on :last, :publish unless dryrun
|
634
|
-
return
|
635
630
|
end
|
636
|
-
|
637
|
-
return
|
631
|
+
on :last, from
|
638
632
|
end
|
639
|
-
run(from: :publish, sync: sync)
|
640
633
|
end
|
641
634
|
|
642
|
-
def package(flag, opts = [])
|
635
|
+
def package(flag, opts = [], from: nil)
|
643
636
|
workspace.rev_clear(name)
|
644
637
|
if (yarn = dependtype(:yarn)) > 0
|
645
638
|
cmd = session 'yarn', if flag == :update
|
@@ -665,6 +658,7 @@ module Squared
|
|
665
658
|
list = OPT_NPM[:install_base] + OPT_NPM.fetch(flag, []) + OPT_NPM[:common]
|
666
659
|
list.concat(OPT_NPM[:install_as]) unless flag == :dedupe
|
667
660
|
no = OPT_NPM[:install_no]
|
661
|
+
cmd << '--save=true' if option('save')
|
668
662
|
end
|
669
663
|
op = OptionPartition.new(opts, list, cmd, no: no, project: self)
|
670
664
|
op.each do |opt|
|
@@ -689,7 +683,7 @@ module Squared
|
|
689
683
|
end
|
690
684
|
op.clear(errors: true)
|
691
685
|
end
|
692
|
-
run(from: :"package:#{flag}")
|
686
|
+
run(from: from || :"package:#{flag}")
|
693
687
|
end
|
694
688
|
|
695
689
|
def bump(flag, val = nil)
|
@@ -906,9 +900,11 @@ module Squared
|
|
906
900
|
@pm[:_] = false
|
907
901
|
nil
|
908
902
|
else
|
909
|
-
|
910
|
-
|
911
|
-
|
903
|
+
if key
|
904
|
+
@pm[key]
|
905
|
+
elsif (ret = @pm[:_]) && !(version && ret[(ret.index('@') + 1)..-1] < version)
|
906
|
+
ret
|
907
|
+
end
|
912
908
|
end
|
913
909
|
|
914
910
|
def read_install
|