squared 0.8.3 → 0.8.4
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 +68 -4
- data/README.md +6 -8
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/format.rb +2 -1
- data/lib/squared/common/host.rb +35 -0
- data/lib/squared/common/prompt.rb +3 -2
- data/lib/squared/common/shell.rb +13 -12
- data/lib/squared/common/utils.rb +7 -4
- data/lib/squared/common.rb +1 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +5 -27
- data/lib/squared/workspace/project/base.rb +39 -15
- data/lib/squared/workspace/project/docker.rb +147 -107
- data/lib/squared/workspace/project/git.rb +109 -97
- data/lib/squared/workspace/project/node.rb +50 -18
- data/lib/squared/workspace/project/python.rb +13 -9
- data/lib/squared/workspace/project/ruby.rb +8 -7
- data/lib/squared/workspace/project/support/optionpartition.rb +104 -55
- data/lib/squared/workspace/repo.rb +2 -1
- data/lib/squared/workspace/series.rb +2 -2
- metadata +3 -2
|
@@ -225,7 +225,7 @@ module Squared
|
|
|
225
225
|
graph ita-invisible-in-index minimal name-only name-status no-color-moved-ws no-prefix no-renames
|
|
226
226
|
numstat patch-with-raw patch-with-stat patience pickaxe-all pickaxe-regex raw shortstat summary
|
|
227
227
|
a|text abbrev=i? anchored=q break-rewrites=b? color=b color-moved=b color-moved-ws=b color-words=q?
|
|
228
|
-
diff-algorithm=b diff-filter=
|
|
228
|
+
diff-algorithm=b diff-filter=q? X|dirstat=b? dirstat-by-file=b? dst-prefix=q find-copies=i?
|
|
229
229
|
find-object=b find-renames=b? ignore-matching-lines=q ignore-submodules=b? line-prefix=q
|
|
230
230
|
max-depth=n output=p output-indicator-context=q output-indicator-new=q output-indicator-old=q
|
|
231
231
|
relative=p rotate-to=p skip-to=p src-prefix=q stat=b? stat-count=i stat-width=i stat-name-width=i
|
|
@@ -413,7 +413,8 @@ module Squared
|
|
|
413
413
|
if flag == :remote
|
|
414
414
|
format_desc action, flag, 'remote?,opts*'
|
|
415
415
|
task flag, [:remote] do |_, args|
|
|
416
|
-
|
|
416
|
+
remote = args.remote
|
|
417
|
+
args = if remote && !git_grep('remote', remote).empty?
|
|
417
418
|
args.extras
|
|
418
419
|
else
|
|
419
420
|
remote = choice_remote
|
|
@@ -449,19 +450,21 @@ module Squared
|
|
|
449
450
|
task flag, [:commit] do |_, args|
|
|
450
451
|
ref = args.commit
|
|
451
452
|
if !ref || ref == ':'
|
|
452
|
-
ref = choice_commit('@{u}..',
|
|
453
|
+
ref = choice_commit(range: '@{u}..',
|
|
454
|
+
empty: log_message('No pending commits', hint: remotetrack))
|
|
453
455
|
end
|
|
454
456
|
push(flag, args.extras, ref: ref)
|
|
455
457
|
end
|
|
456
458
|
else
|
|
457
459
|
format_desc(action, flag, 'origin?,opts*', after: ('refs*' unless flag == :all))
|
|
458
|
-
task flag do |_, args|
|
|
459
|
-
|
|
460
|
-
if
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
460
|
+
task flag, [:origin] do |_, args|
|
|
461
|
+
origin = args.origin
|
|
462
|
+
args = if origin && !git_grep('remote', origin).empty?
|
|
463
|
+
args.extras
|
|
464
|
+
else
|
|
465
|
+
origin = nil
|
|
466
|
+
args.to_a
|
|
467
|
+
end
|
|
465
468
|
push(flag, args, origin: origin)
|
|
466
469
|
end
|
|
467
470
|
end
|
|
@@ -555,7 +558,8 @@ module Squared
|
|
|
555
558
|
when :add, :sign
|
|
556
559
|
format_desc action, flag, 'name,message?,commit?,remote?'
|
|
557
560
|
task flag, [:name, :message, :commit, :remote] do |_, args|
|
|
558
|
-
|
|
561
|
+
name = args.name
|
|
562
|
+
if name
|
|
559
563
|
message = args.message
|
|
560
564
|
commit = commithead args.commit
|
|
561
565
|
remote = args.remote
|
|
@@ -594,9 +598,10 @@ module Squared
|
|
|
594
598
|
format_desc action, flag, '(^)commit*|:,opts*,pathspec*'
|
|
595
599
|
task flag do |_, args|
|
|
596
600
|
args = args.to_a
|
|
597
|
-
if args
|
|
598
|
-
|
|
599
|
-
|
|
601
|
+
if choice!(args, empty: true)
|
|
602
|
+
index = choice_commit('Choose revision range', multiple: true, series: true)
|
|
603
|
+
exclude = choice_commit('With exclusions', multiple: true, force: false)
|
|
604
|
+
index.concat(exclude.map { |val| "^#{val}" }) if exclude
|
|
600
605
|
else
|
|
601
606
|
index = args.each_with_object([]) do |val, out|
|
|
602
607
|
if matchhead(val)
|
|
@@ -613,33 +618,32 @@ module Squared
|
|
|
613
618
|
end
|
|
614
619
|
log_(flag, args, index: index)
|
|
615
620
|
end
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
621
|
+
else
|
|
622
|
+
format_desc action, flag, 'commit1,commit2,opts*,pathspec*'
|
|
623
|
+
task flag, [:commit1, :commit2] do |_, args|
|
|
624
|
+
commit1 = commithead args.commit1
|
|
625
|
+
if commit1
|
|
626
|
+
range = [commit1, commithead(param_guard(action, flag, args: args, key: :commit2))]
|
|
627
|
+
opts = args.extras
|
|
628
|
+
else
|
|
629
|
+
range, opts, refs = choice_commit(multiple: flag == :view ? true : 2,
|
|
630
|
+
values: %w[Options Pathspec])
|
|
631
|
+
range.reverse!
|
|
632
|
+
opts = OptionPartition.strip(opts)
|
|
633
|
+
opts.concat(refs.shellsplit) if refs
|
|
634
|
+
end
|
|
635
|
+
if action == 'log'
|
|
636
|
+
log_(flag, opts, range: range)
|
|
637
|
+
else
|
|
638
|
+
diff(flag, opts, range: range, from: action.to_sym)
|
|
639
|
+
end
|
|
635
640
|
end
|
|
636
641
|
end
|
|
637
642
|
when :head
|
|
638
643
|
format_desc action, flag, 'commit*|:,opts*,pathspec*'
|
|
639
644
|
task flag do |_, args|
|
|
640
645
|
args = args.to_a
|
|
641
|
-
if args
|
|
642
|
-
args.shift
|
|
646
|
+
if choice!(args, empty: true)
|
|
643
647
|
index = choice_commit(multiple: true)
|
|
644
648
|
else
|
|
645
649
|
index = args.each_with_object([]) do |val, out|
|
|
@@ -681,10 +685,10 @@ module Squared
|
|
|
681
685
|
when 'i', 'E', 'F', 'P'
|
|
682
686
|
opts << last
|
|
683
687
|
else
|
|
684
|
-
if last =~ /^
|
|
688
|
+
if last =~ /^f(?:-ormat)?=(.+)$/
|
|
685
689
|
opts.shift
|
|
686
690
|
opts << "format=#{$1}"
|
|
687
|
-
elsif last =~ /^
|
|
691
|
+
elsif last =~ /^max(?:-count)?=(\d+)$/
|
|
688
692
|
opts << "max-count=#{$1}"
|
|
689
693
|
else
|
|
690
694
|
grep << last
|
|
@@ -699,9 +703,10 @@ module Squared
|
|
|
699
703
|
when 'checkout'
|
|
700
704
|
case flag
|
|
701
705
|
when :branch
|
|
702
|
-
format_desc action, flag, '
|
|
703
|
-
task flag, [:
|
|
704
|
-
|
|
706
|
+
format_desc action, flag, 'branch,create?=[bB],commit?,d/etach?'
|
|
707
|
+
task flag, [:branch, :create, :commit, :detach] do |_, args|
|
|
708
|
+
branch = args.branch
|
|
709
|
+
if branch
|
|
705
710
|
create = args.create
|
|
706
711
|
detach = if args.commit == 'd'
|
|
707
712
|
commit = nil
|
|
@@ -725,9 +730,10 @@ module Squared
|
|
|
725
730
|
checkout(flag, branch: branch, create: create, commit: commit, detach: detach)
|
|
726
731
|
end
|
|
727
732
|
when :track
|
|
728
|
-
format_desc action, flag, '
|
|
729
|
-
task flag, [:
|
|
730
|
-
|
|
733
|
+
format_desc action, flag, 'remote,(^)name?'
|
|
734
|
+
task flag, [:remote, :name] do |_, args|
|
|
735
|
+
origin = args.remote
|
|
736
|
+
if origin
|
|
731
737
|
branch = args.name
|
|
732
738
|
else
|
|
733
739
|
origin, branch = choice_refs('Choose a remote', 'remotes', values: 'Enter branch name')
|
|
@@ -778,7 +784,8 @@ module Squared
|
|
|
778
784
|
when :track
|
|
779
785
|
format_desc action, flag, '(^~)upstream?,name?'
|
|
780
786
|
task flag, [:upstream, :name] do |_, args|
|
|
781
|
-
|
|
787
|
+
ref = args.upstream
|
|
788
|
+
if ref
|
|
782
789
|
target = args.name
|
|
783
790
|
remote = true if ref.delete_prefix!('~')
|
|
784
791
|
else
|
|
@@ -791,12 +798,12 @@ module Squared
|
|
|
791
798
|
format_desc action, flag, '[^~]name*,:?'
|
|
792
799
|
task flag do |_, args|
|
|
793
800
|
refs = args.to_a
|
|
794
|
-
if refs.empty? || (
|
|
801
|
+
if refs.empty? || (ia = refs.last == ':')
|
|
795
802
|
accept = ['Delete?']
|
|
796
|
-
accept << accept_b('Force?') unless
|
|
797
|
-
remote = choice_refs('Choose a branch',
|
|
798
|
-
|
|
799
|
-
if
|
|
803
|
+
accept << accept_b('Force?') unless ia
|
|
804
|
+
remote = choice_refs('Choose a branch', ia ? 'remotes' : 'heads', multiple: true,
|
|
805
|
+
accept: accept)
|
|
806
|
+
if ia
|
|
800
807
|
refs.pop
|
|
801
808
|
else
|
|
802
809
|
refs = remote.first
|
|
@@ -814,7 +821,8 @@ module Squared
|
|
|
814
821
|
when :move, :copy
|
|
815
822
|
format_desc action, flag, 'branch,oldbranch?'
|
|
816
823
|
task flag, [:branch, :oldbranch] do |_, args|
|
|
817
|
-
|
|
824
|
+
branch = args.branch
|
|
825
|
+
if branch
|
|
818
826
|
oldbranch = args.oldbranch
|
|
819
827
|
else
|
|
820
828
|
oldbranch, branch = choice_refs("Choose a branch to #{flag}",
|
|
@@ -831,18 +839,19 @@ module Squared
|
|
|
831
839
|
when 'clone'
|
|
832
840
|
format_desc(action, flag, flag == :tag ? 'dir,tag/:' : 'dir,branch/:', after: 'opts*')
|
|
833
841
|
task flag, [:dir, :ref] do |_, args|
|
|
834
|
-
dir =
|
|
835
|
-
|
|
842
|
+
dir = param_guard(action, flag, args: args, key: :dir)
|
|
843
|
+
ref = args.ref
|
|
844
|
+
if !ref || ref == ':'
|
|
836
845
|
ref = flag == :tag ? choice_refs('Choose a tag', 'tags') : choice_refs('Choose a branch')
|
|
837
846
|
end
|
|
838
|
-
clone(flag, args.extras, dir: dir, ref: ref)
|
|
847
|
+
clone(flag, args.extras, dir: emptypath(dir, create: false), ref: ref)
|
|
839
848
|
end
|
|
840
849
|
when 'switch'
|
|
841
850
|
case flag
|
|
842
851
|
when :create
|
|
843
|
-
format_desc action, flag, '(^)
|
|
844
|
-
task flag, [:
|
|
845
|
-
branch = param_guard(action, flag, args: args, key: :
|
|
852
|
+
format_desc action, flag, '(^)branch,commit?|:'
|
|
853
|
+
task flag, [:branch, :commit] do |_, args|
|
|
854
|
+
branch = param_guard(action, flag, args: args, key: :branch)
|
|
846
855
|
commit = commithead args.commit
|
|
847
856
|
commit, track = choice_commit(force: false, values: 'Track? [Y/n]') if commit == ':'
|
|
848
857
|
switch(flag, branch: branch, commit: commit, track: track)
|
|
@@ -855,15 +864,11 @@ module Squared
|
|
|
855
864
|
switch(flag, commit: commit)
|
|
856
865
|
end
|
|
857
866
|
when :branch
|
|
858
|
-
format_desc action, flag, '
|
|
859
|
-
task flag, [:
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
else
|
|
864
|
-
[]
|
|
865
|
-
end
|
|
866
|
-
switch(flag, args, branch: branch || choice_refs('Choose a branch'))
|
|
867
|
+
format_desc action, flag, 'branch/:,opts*'
|
|
868
|
+
task flag, [:branch] do |_, args|
|
|
869
|
+
branch = args.branch
|
|
870
|
+
branch = nil if branch == ':'
|
|
871
|
+
switch(flag, args.extras, branch: branch || choice_refs('Choose a branch'))
|
|
867
872
|
end
|
|
868
873
|
end
|
|
869
874
|
when 'reset'
|
|
@@ -872,17 +877,16 @@ module Squared
|
|
|
872
877
|
format_desc action, flag, 'commit?|:,opts*'
|
|
873
878
|
task flag, [:commit] do |_, args|
|
|
874
879
|
commit = commithead args.commit
|
|
875
|
-
args =
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
end
|
|
880
|
+
args = args.extras
|
|
881
|
+
if !commit || commit == ':'
|
|
882
|
+
commit, mode = choice_commit(values: ['Mode [mixed|soft|hard|N]'])
|
|
883
|
+
args.concat(case mode&.downcase
|
|
884
|
+
when 'h', 'hard' then ['hard']
|
|
885
|
+
when 's', 'soft' then ['soft']
|
|
886
|
+
when 'n', 'N' then %w[mixed N]
|
|
887
|
+
else ['mixed']
|
|
888
|
+
end)
|
|
889
|
+
end
|
|
886
890
|
success?(reset(flag, args, commit: commit))
|
|
887
891
|
end
|
|
888
892
|
when :index
|
|
@@ -931,9 +935,11 @@ module Squared
|
|
|
931
935
|
when 'rebase', 'merge'
|
|
932
936
|
case flag
|
|
933
937
|
when :branch
|
|
934
|
-
format_desc action, flag, 'upstream
|
|
938
|
+
format_desc action, flag, 'upstream?|:,opts*'
|
|
935
939
|
task flag, [:upstream] do |_, args|
|
|
936
|
-
|
|
940
|
+
upstream = args.upstream
|
|
941
|
+
args = if upstream
|
|
942
|
+
upstream = choice_refs 'Choose upstream branch' if upstream == ':'
|
|
937
943
|
args.extras
|
|
938
944
|
else
|
|
939
945
|
upstream, opts = choice_refs('Choose upstream branch', values: 'Options')
|
|
@@ -961,8 +967,9 @@ module Squared
|
|
|
961
967
|
when :commit, :'no-commit'
|
|
962
968
|
format_desc action, flag, 'branch|:,ours|theirs?,opts*'
|
|
963
969
|
task flag, [:branch] do |_, args|
|
|
964
|
-
|
|
965
|
-
|
|
970
|
+
branch = args.branch
|
|
971
|
+
current = git_spawn('branch --show-current').chomp
|
|
972
|
+
if branch
|
|
966
973
|
branch = choice_refs('Choose a branch', accept: "#{action.capitalize}?") if branch == ':'
|
|
967
974
|
opts = args.extras
|
|
968
975
|
if has_value!(opts, 'ours')
|
|
@@ -975,9 +982,11 @@ module Squared
|
|
|
975
982
|
accept: "Merge with #{current}?")
|
|
976
983
|
opts = OptionPartition.strip(opts)
|
|
977
984
|
end
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
985
|
+
if current == branch
|
|
986
|
+
puts log_message('nothing to merge', subject: name, hint: branch)
|
|
987
|
+
else
|
|
988
|
+
merge(flag, opts, branch: branch)
|
|
989
|
+
end
|
|
981
990
|
end
|
|
982
991
|
when :send
|
|
983
992
|
format_desc(action, flag, VAL_GIT[action.to_sym][:send], arg: nil)
|
|
@@ -994,7 +1003,7 @@ module Squared
|
|
|
994
1003
|
task flag, [:ref, :size] do |_, args|
|
|
995
1004
|
ref = commithead args.ref
|
|
996
1005
|
size = args.size
|
|
997
|
-
if !size && ref.to_i.between?(
|
|
1006
|
+
if !size && ref.to_i.between?(4, 40)
|
|
998
1007
|
size = ref
|
|
999
1008
|
ref = nil
|
|
1000
1009
|
end
|
|
@@ -1023,7 +1032,8 @@ module Squared
|
|
|
1023
1032
|
if flag == :remote
|
|
1024
1033
|
format_desc action, flag, 'remote?|:,opts*,pattern*'
|
|
1025
1034
|
task flag, [:remote] do |_, args|
|
|
1026
|
-
|
|
1035
|
+
remote = args.remote
|
|
1036
|
+
args = if remote && (remote == ':' || !git_grep('remote', remote).empty?)
|
|
1027
1037
|
remote = choice_remote(force: true) if remote == ':'
|
|
1028
1038
|
args.extras
|
|
1029
1039
|
else
|
|
@@ -1568,7 +1578,7 @@ module Squared
|
|
|
1568
1578
|
unless force
|
|
1569
1579
|
i = -1
|
|
1570
1580
|
op.each do |val|
|
|
1571
|
-
if !val.include?(':') && repofetch(origin, branch: val, sync: (i += 1)
|
|
1581
|
+
if !val.include?(':') && repofetch(origin, branch: val, sync: (i += 1) == 0).first.nil?
|
|
1572
1582
|
op.errors << val
|
|
1573
1583
|
else
|
|
1574
1584
|
op.found << val
|
|
@@ -1624,7 +1634,7 @@ module Squared
|
|
|
1624
1634
|
append_option 'f', 'force', 'merge'
|
|
1625
1635
|
case flag
|
|
1626
1636
|
when :branch
|
|
1627
|
-
cmd << '--detach' if detach == 'd' || option('detach')
|
|
1637
|
+
cmd << '--detach' if detach == 'd' || option('d', 'detach')
|
|
1628
1638
|
append_option('track', equals: true)
|
|
1629
1639
|
cmd << (create ? quote_option(create, branch) : branch) << commit
|
|
1630
1640
|
when :track
|
|
@@ -1652,7 +1662,7 @@ module Squared
|
|
|
1652
1662
|
cmd, opts = git_session('tag', opts: opts)
|
|
1653
1663
|
case flag
|
|
1654
1664
|
when :add, :sign
|
|
1655
|
-
if flag == :sign
|
|
1665
|
+
if flag == :sign
|
|
1656
1666
|
cmd << '--sign'
|
|
1657
1667
|
elsif !session_arg?('s', 'sign', 'u', 'local-user')
|
|
1658
1668
|
cmd << '--annotate'
|
|
@@ -1812,8 +1822,10 @@ module Squared
|
|
|
1812
1822
|
return if pass
|
|
1813
1823
|
|
|
1814
1824
|
upstream = true
|
|
1815
|
-
|
|
1816
|
-
|
|
1825
|
+
origin = option('origin', 'upstream', prefix: 'git', ignore: false)
|
|
1826
|
+
unless origin
|
|
1827
|
+
origin = choice_refs('Choose an upstream', 'remotes', attempts: 1, force: false)
|
|
1828
|
+
if origin
|
|
1817
1829
|
git_spawn 'branch', quote_option('set-upstream-to', origin)
|
|
1818
1830
|
upstream = false
|
|
1819
1831
|
else
|
|
@@ -1963,7 +1975,7 @@ module Squared
|
|
|
1963
1975
|
out, banner, from = source(io: true)
|
|
1964
1976
|
first = from_base?('branch')
|
|
1965
1977
|
grep = first ? [/^\*\s+#{Regexp.escape(head)}\s/] : []
|
|
1966
|
-
ret = write_lines(out, grep: grep, banner: banner, first: first) do |line,
|
|
1978
|
+
ret = write_lines(out, grep: grep, banner: banner, first: first) do |line, i|
|
|
1967
1979
|
next line if stdin?
|
|
1968
1980
|
|
|
1969
1981
|
data = line.sub(/^\*?\s+/, '').split(/\s+/, 3)
|
|
@@ -1977,7 +1989,7 @@ module Squared
|
|
|
1977
1989
|
r3 = write.call($4, $5)
|
|
1978
1990
|
end
|
|
1979
1991
|
r1 = nil if r1 == "origin/#{data[0]}"
|
|
1980
|
-
["#{"\n" unless
|
|
1992
|
+
["#{"\n" unless i == 0} Branch: #{a.subhint(r1)}", r2, r3, " Commit: #{b}", "Message: #{md[2]}"]
|
|
1981
1993
|
.compact
|
|
1982
1994
|
.join("\n")
|
|
1983
1995
|
end
|
|
@@ -2073,7 +2085,7 @@ module Squared
|
|
|
2073
2085
|
cmd, opts = git_session('rev-parse', opts: opts)
|
|
2074
2086
|
case flag
|
|
2075
2087
|
when :commit
|
|
2076
|
-
cmd << (size.to_i
|
|
2088
|
+
cmd << (size.to_i == 0 ? '--verify' : basic_option('short', [size.to_i, 5].max))
|
|
2077
2089
|
append_commit(ref, head: true)
|
|
2078
2090
|
when :branch
|
|
2079
2091
|
cmd << '--abbrev-ref' << '--symbolic-full-name' << shell_quote(case ref
|
|
@@ -2329,12 +2341,12 @@ module Squared
|
|
|
2329
2341
|
choice_index(msg, foreachref(type, *args, format: format), trim: trim, **kwargs)
|
|
2330
2342
|
end
|
|
2331
2343
|
|
|
2332
|
-
def choice_commit(
|
|
2344
|
+
def choice_commit(msg = 'Choose a commit', range: nil, count: true, reflog: true, force: true, **kwargs)
|
|
2333
2345
|
kwargs[:attempts] ||= 1 unless force
|
|
2334
2346
|
cmd = git_output(reflog && env('GIT_REFLOG') ? 'reflog' : 'log', range)
|
|
2335
2347
|
cmd << quote_option('format', "#{commitstyle('%h')} %s")
|
|
2336
2348
|
cmd << basic_option('max-count', env('GIT_COUNT', ARG[:CHOICE])) if count
|
|
2337
|
-
ret = choice_index(
|
|
2349
|
+
ret = choice_index(msg, git_spawn(cmd, stdout: false), column: /^(\S+)/, force: force, **kwargs)
|
|
2338
2350
|
case ret
|
|
2339
2351
|
when Array
|
|
2340
2352
|
ret.map { |val| val&.stripstyle }
|
|
@@ -2480,7 +2492,7 @@ module Squared
|
|
|
2480
2492
|
def foreachref(path, *args, format: nil, chomp: true)
|
|
2481
2493
|
format &&= quote_option('format', format)
|
|
2482
2494
|
ret = git_spawn('for-each-ref', format, *args.concat(Array(path).map { |val| "refs/#{val}" }),
|
|
2483
|
-
stdout:
|
|
2495
|
+
stdout: windows?)
|
|
2484
2496
|
if ret.is_a?(String)
|
|
2485
2497
|
ret.lines(chomp: chomp)
|
|
2486
2498
|
elsif chomp
|
|
@@ -2565,7 +2577,7 @@ module Squared
|
|
|
2565
2577
|
end
|
|
2566
2578
|
|
|
2567
2579
|
def remotetrack
|
|
2568
|
-
git_spawn('rev-parse --abbrev-ref @{u}').split('/'
|
|
2580
|
+
git_spawn('rev-parse --abbrev-ref @{u}').split('/').first
|
|
2569
2581
|
end
|
|
2570
2582
|
|
|
2571
2583
|
def commithash(val)
|
|
@@ -18,6 +18,7 @@ module Squared
|
|
|
18
18
|
pack: %w[ignore-scripts=!? json=!? pack-destination=p].freeze,
|
|
19
19
|
rebuild: %w[bin-links=! foreground-scripts=!? global=!? ignore-scripts=!? install-links=!?].freeze,
|
|
20
20
|
'approve-scripts': %w[a|all allow-scripts-pending allow-scripts-pin=!? no-allow-scripts-pin json].freeze,
|
|
21
|
+
'deny-scripts': %w[a|all json].freeze,
|
|
21
22
|
no: {
|
|
22
23
|
install: %w[audit bin-links fund package-lock].freeze
|
|
23
24
|
}.freeze
|
|
@@ -254,7 +255,8 @@ module Squared
|
|
|
254
255
|
when 'exec'
|
|
255
256
|
format_desc action, nil, 'pkg/cmd,opts*,args*'
|
|
256
257
|
task action, [:package] do |_, args|
|
|
257
|
-
|
|
258
|
+
package = args.package
|
|
259
|
+
if package
|
|
258
260
|
args = args.extras
|
|
259
261
|
cmd = if pnpm?
|
|
260
262
|
pre = ->(ch) { "-#{ch}" if args.delete(ch) }
|
|
@@ -267,9 +269,10 @@ module Squared
|
|
|
267
269
|
op = OptionPartition.new(args, list, cmd, project: self, strict: strict?)
|
|
268
270
|
if op.empty?
|
|
269
271
|
op << package
|
|
270
|
-
|
|
272
|
+
s = readline('Enter arguments', force: false)
|
|
273
|
+
if s
|
|
271
274
|
op.delim unless pnpm?
|
|
272
|
-
op <<
|
|
275
|
+
op << s
|
|
273
276
|
end
|
|
274
277
|
else
|
|
275
278
|
op.delim unless pnpm?
|
|
@@ -281,20 +284,21 @@ module Squared
|
|
|
281
284
|
run(from: :exec)
|
|
282
285
|
end
|
|
283
286
|
when 'nvm'
|
|
284
|
-
next unless ENV['NVM_DIR'] && !
|
|
287
|
+
next unless ENV['NVM_DIR'] && !windows?
|
|
285
288
|
|
|
286
289
|
format_desc action, nil, 'version?,args*'
|
|
287
290
|
task action, [:version] do |_, args|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
version = args.version
|
|
292
|
+
args = args.extras
|
|
293
|
+
append = ->(s) { shell_quote(File.join(ENV['NVM_DIR'], s)) }
|
|
294
|
+
unless version
|
|
295
|
+
cmd = ". #{append.call('nvm.sh')} && nvm list --no-colors --no-alias"
|
|
291
296
|
version = pwd_set(from: :nvm) do
|
|
292
297
|
choice_index('Select a version', IO.popen(cmd).map { |line| line[/\s(v\S+)/, 1] }, series: true)
|
|
293
298
|
end
|
|
294
299
|
end
|
|
295
|
-
args = args.extras
|
|
296
300
|
args << readline('Enter command', force: true) if args.empty?
|
|
297
|
-
args.unshift(
|
|
301
|
+
args.unshift(append.call('nvm-exec'))
|
|
298
302
|
run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
|
|
299
303
|
end
|
|
300
304
|
when 'bump'
|
|
@@ -325,20 +329,48 @@ module Squared
|
|
|
325
329
|
outdated flag, args.to_a
|
|
326
330
|
end
|
|
327
331
|
when 'package'
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
332
|
+
case flag
|
|
333
|
+
when :approve, :deny
|
|
334
|
+
format_desc action, flag, 'name*|:,opts*'
|
|
335
|
+
task flag do |_, args|
|
|
336
|
+
args = args.to_a
|
|
337
|
+
if choice!(args)
|
|
338
|
+
pwd_set do
|
|
339
|
+
pad = 0
|
|
340
|
+
list = IO.popen(npm_output('approve-scripts --allow-scripts-pending').to_s)
|
|
341
|
+
.each_with_object([]) do |line, out|
|
|
342
|
+
next unless line =~ /^\s+([a-z\d@][^@]*)@(\S+)/
|
|
343
|
+
|
|
344
|
+
pad = [pad, $1.size].max
|
|
345
|
+
out << [$1, $2]
|
|
346
|
+
end
|
|
347
|
+
.map { |name, ver| name.ljust(pad + 4) + ver }
|
|
348
|
+
if list.empty?
|
|
349
|
+
puts log_message('no packages to review', subject: name, hint: "#{flag}-scripts")
|
|
350
|
+
exit 0
|
|
351
|
+
end
|
|
352
|
+
args.concat(choice_index('Select packages', list, multiple: true, column: /^(\S+)/))
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
package flag, args
|
|
356
|
+
end
|
|
357
|
+
else
|
|
358
|
+
format_desc(action, flag, 'opts*', before: case flag
|
|
359
|
+
when :dedupe, :rebuild then nil
|
|
360
|
+
when :reinstall then 'f/orce?'
|
|
361
|
+
else 'name*'
|
|
362
|
+
end)
|
|
363
|
+
task flag do |_, args|
|
|
364
|
+
package flag, args.to_a
|
|
365
|
+
end
|
|
335
366
|
end
|
|
336
367
|
when 'publish'
|
|
337
368
|
if flag == :verify
|
|
338
369
|
format_desc action, flag, 'version?,ext*'
|
|
339
370
|
task flag, [:version] do |_, args|
|
|
371
|
+
version = args.version
|
|
340
372
|
ext = args.extras
|
|
341
|
-
if
|
|
373
|
+
if version&.match?(/^\.?[a-z]+$/i)
|
|
342
374
|
ext.unshift(version)
|
|
343
375
|
version = nil
|
|
344
376
|
end
|
|
@@ -1639,7 +1671,7 @@ module Squared
|
|
|
1639
1671
|
end
|
|
1640
1672
|
|
|
1641
1673
|
def quotepath(name, val)
|
|
1642
|
-
if $2.include?(File::SEPARATOR) || (
|
|
1674
|
+
if $2.include?(File::SEPARATOR) || (windows? && val.match?(%r{[\\/]}))
|
|
1643
1675
|
quote_option name, basepath(val)
|
|
1644
1676
|
else
|
|
1645
1677
|
shell_option name, val
|
|
@@ -236,7 +236,7 @@ module Squared
|
|
|
236
236
|
format_desc action, nil, 'command|:,args*'
|
|
237
237
|
task action do |_, args|
|
|
238
238
|
args = args.to_a
|
|
239
|
-
cmd = if (i = args.delete(':')) && !
|
|
239
|
+
cmd = if (i = args.delete(':')) && !windows?
|
|
240
240
|
readline('Enter script', force: true, multiline: %w[## ;])
|
|
241
241
|
elsif i || args.empty?
|
|
242
242
|
readline('Enter command', force: true)
|
|
@@ -502,7 +502,7 @@ module Squared
|
|
|
502
502
|
patch = []
|
|
503
503
|
buffer = []
|
|
504
504
|
out = ->(val) { sync ? puts(val) : buffer << val }
|
|
505
|
-
if
|
|
505
|
+
if windows?
|
|
506
506
|
(venv ? command(runenv, cmd) : `#{cmd}`).lines(chomp: true)
|
|
507
507
|
else
|
|
508
508
|
IO.popen(runenv || {}, cmd).readlines(chomp: true)
|
|
@@ -617,7 +617,7 @@ module Squared
|
|
|
617
617
|
|
|
618
618
|
op << "--#{flag}"
|
|
619
619
|
op.append
|
|
620
|
-
python_session('-m pip', *op.to_a.drop(1)) if
|
|
620
|
+
python_session('-m pip', *op.to_a.drop(1)) if windows?
|
|
621
621
|
end
|
|
622
622
|
end
|
|
623
623
|
run(banner: banner, from: :install)
|
|
@@ -1009,7 +1009,7 @@ module Squared
|
|
|
1009
1009
|
@build_backend ||= read_pyproject('build-system', 'build-backend') || ''
|
|
1010
1010
|
end
|
|
1011
1011
|
|
|
1012
|
-
def read_pyproject(table,
|
|
1012
|
+
def read_pyproject(table, *keys)
|
|
1013
1013
|
return [] unless (file = pyprojectfile)
|
|
1014
1014
|
|
|
1015
1015
|
ret = (@pyproject ||= {})[table]
|
|
@@ -1074,7 +1074,11 @@ module Squared
|
|
|
1074
1074
|
end
|
|
1075
1075
|
@pyproject[table] = ret
|
|
1076
1076
|
end
|
|
1077
|
-
|
|
1077
|
+
unless keys.empty?
|
|
1078
|
+
ret.select! { |key,| keys.include?(key) }
|
|
1079
|
+
return ret.first&.last if keys.size == 1
|
|
1080
|
+
end
|
|
1081
|
+
ret
|
|
1078
1082
|
end
|
|
1079
1083
|
|
|
1080
1084
|
def pyprojectfile
|
|
@@ -1132,15 +1136,15 @@ module Squared
|
|
|
1132
1136
|
def runenv
|
|
1133
1137
|
return unless venv
|
|
1134
1138
|
|
|
1135
|
-
if
|
|
1136
|
-
shell_quote(venvbin.join(
|
|
1139
|
+
if windows?
|
|
1140
|
+
shell_quote(venvbin.join(powershell? ? 'Activate.ps1' : 'activate.bat'), option: false)
|
|
1137
1141
|
else
|
|
1138
1142
|
{ 'VIRTUAL_ENV' => venv.to_s, 'PATH' => "#{venvbin}:#{ENV['PATH']}" }
|
|
1139
1143
|
end
|
|
1140
1144
|
end
|
|
1141
1145
|
|
|
1142
1146
|
def venvbin
|
|
1143
|
-
@venv&.join(
|
|
1147
|
+
@venv&.join(windows? ? 'Scripts' : 'bin')
|
|
1144
1148
|
end
|
|
1145
1149
|
|
|
1146
1150
|
def editable_set(val)
|
|
@@ -1215,7 +1219,7 @@ module Squared
|
|
|
1215
1219
|
success?(ret, banner, !status) do |out|
|
|
1216
1220
|
if out && dir.directory?
|
|
1217
1221
|
if poetry?
|
|
1218
|
-
dir += (
|
|
1222
|
+
dir += (windows? ? 'Scripts/python.exe' : 'bin/python')
|
|
1219
1223
|
cmd = poetry_session 'env use'
|
|
1220
1224
|
else
|
|
1221
1225
|
puts "Success: #{dir}"
|