squared 0.4.7 → 0.4.8
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 +30 -0
- data/README.ruby.md +16 -0
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/class.rb +19 -1
- data/lib/squared/common/format.rb +25 -21
- data/lib/squared/common/prompt.rb +39 -1
- data/lib/squared/common/shell.rb +12 -8
- data/lib/squared/common/system.rb +1 -1
- data/lib/squared/common/utils.rb +11 -10
- data/lib/squared/config.rb +1 -2
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +36 -20
- data/lib/squared/workspace/project/base.rb +125 -48
- data/lib/squared/workspace/project/docker.rb +64 -23
- data/lib/squared/workspace/project/git.rb +111 -65
- data/lib/squared/workspace/project/node.rb +22 -37
- data/lib/squared/workspace/project/python.rb +7 -7
- data/lib/squared/workspace/project/ruby.rb +227 -39
- data/lib/squared/workspace/project/support/class.rb +11 -9
- data/lib/squared/workspace/repo.rb +6 -8
- data/lib/squared/workspace/series.rb +6 -5
- data/lib/squared/workspace.rb +1 -8
- metadata +2 -2
@@ -14,14 +14,14 @@ module Squared
|
|
14
14
|
check = ->(proj) { proj.is_a?(Project::Git) && !proj.exclude?(Project::Git.ref) && git_clone?(proj.path) }
|
15
15
|
if uri.is_a?(Array)
|
16
16
|
base = name
|
17
|
-
uri.each { |val| repo << proj if (proj = @project[val.to_s]) && check.(proj) }
|
17
|
+
uri.each { |val| repo << proj if (proj = @project[val.to_s]) && check.call(proj) }
|
18
18
|
elsif uri
|
19
19
|
data[name.to_s] = uri
|
20
20
|
elsif name.is_a?(Enumerable)
|
21
21
|
data = name.to_h
|
22
22
|
elsif name.is_a?(String) && name.match?(GIT_PROTO)
|
23
23
|
base = name
|
24
|
-
@project.each_value { |proj| repo << proj if !proj.parent && check.(proj) }
|
24
|
+
@project.each_value { |proj| repo << proj if !proj.parent && check.call(proj) }
|
25
25
|
else
|
26
26
|
warn log_message(Logger::WARN, name, subject: 'git', hint: 'invalid', pass: true) if warning
|
27
27
|
return self
|
@@ -297,7 +297,7 @@ module Squared
|
|
297
297
|
end
|
298
298
|
|
299
299
|
def tasks
|
300
|
-
%i[pull rebase fetch clone stash status branch revbuild].freeze
|
300
|
+
%i[pull rebase autostash fetch clone stash status branch revbuild].freeze
|
301
301
|
end
|
302
302
|
|
303
303
|
def config?(val)
|
@@ -342,7 +342,7 @@ module Squared
|
|
342
342
|
return unless ref?(Git.ref)
|
343
343
|
|
344
344
|
namespace name do
|
345
|
-
|
345
|
+
Git.subtasks do |action, flags|
|
346
346
|
next if @pass.include?(action)
|
347
347
|
|
348
348
|
namespace action do
|
@@ -383,9 +383,11 @@ module Squared
|
|
383
383
|
tag flag, args.to_a
|
384
384
|
end
|
385
385
|
when :delete
|
386
|
-
format_desc action, flag, 'name
|
386
|
+
format_desc action, flag, 'name+?'
|
387
387
|
task flag do |_, args|
|
388
|
-
refs =
|
388
|
+
if (refs = args.to_a).empty?
|
389
|
+
refs = choice_refs('Choose a tag', 'tags', multiple: true, accept: 'Delete?')
|
390
|
+
end
|
389
391
|
tag(flag, refs: refs)
|
390
392
|
end
|
391
393
|
when :add, :sign
|
@@ -408,7 +410,7 @@ module Squared
|
|
408
410
|
case flag
|
409
411
|
when :view, :between, :contain
|
410
412
|
if flag == :view && action == 'log'
|
411
|
-
format_desc action, flag, '(^)commit/H0*,pathspec
|
413
|
+
format_desc action, flag, '(^)commit/H0*,opts*,pathspec*'
|
412
414
|
task flag do |_, args|
|
413
415
|
index = []
|
414
416
|
args.to_a.each do |val|
|
@@ -416,18 +418,18 @@ module Squared
|
|
416
418
|
index << "HEAD~#{$1}"
|
417
419
|
elsif (sha = commithash(val))
|
418
420
|
index << sha
|
419
|
-
elsif val.start_with?('^')
|
421
|
+
elsif val.start_with?('^')
|
420
422
|
index << shell_quote(val)
|
421
423
|
end
|
422
424
|
end
|
423
|
-
|
425
|
+
log!(flag, args.to_a.drop(index.size), index: index)
|
424
426
|
end
|
425
427
|
else
|
426
|
-
format_desc action, flag, 'commit1,commit2,pathspec
|
428
|
+
format_desc action, flag, 'commit1,commit2,opts*,pathspec*'
|
427
429
|
task flag, [:commit1, :commit2] do |_, args|
|
428
430
|
commit1 = param_guard(action, flag, args: args, key: :commit1)
|
429
431
|
commit2 = param_guard(action, flag, args: args, key: :commit2)
|
430
|
-
__send__(action == 'log' ? :
|
432
|
+
__send__(action == 'log' ? :log! : :diff, flag, args.extras, range: [commit1, commit2])
|
431
433
|
end
|
432
434
|
end
|
433
435
|
when :head
|
@@ -458,33 +460,41 @@ module Squared
|
|
458
460
|
when 'checkout'
|
459
461
|
case flag
|
460
462
|
when :branch
|
461
|
-
format_desc action, flag, 'name
|
463
|
+
format_desc action, flag, 'name?,create?=[bB],commit?,detach?=d'
|
462
464
|
task flag, [:name, :create, :commit, :detach] do |_, args|
|
463
|
-
branch =
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
create
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
465
|
+
if (branch = args.name)
|
466
|
+
branch = param_guard(action, flag, args: args, key: :name)
|
467
|
+
create = args.create
|
468
|
+
if args.commit == 'd'
|
469
|
+
detach = 'd'
|
470
|
+
commit = nil
|
471
|
+
elsif create == 'd'
|
472
|
+
create = nil
|
473
|
+
commit = nil
|
474
|
+
detach = 'd'
|
475
|
+
elsif create && create.size > 1
|
476
|
+
commit = create
|
477
|
+
create = nil
|
478
|
+
detach = args.commit
|
479
|
+
else
|
480
|
+
detach = args.detach
|
481
|
+
commit = args.commit
|
482
|
+
end
|
483
|
+
param_guard(action, flag, args: { create: create }, key: :create, pat: /\Ab\z/i) if create
|
476
484
|
else
|
477
|
-
|
478
|
-
commit = args.commit
|
485
|
+
branch = choice_refs 'Choose a branch to switch', 'heads'
|
479
486
|
end
|
480
|
-
param_guard(action, flag, args: { create: create }, key: :create, pat: /\Ab\z/i) if create
|
481
487
|
checkout(flag, branch: branch, create: create, commit: commit, detach: detach)
|
482
488
|
end
|
483
489
|
when :track
|
484
|
-
format_desc action, flag, 'origin
|
490
|
+
format_desc action, flag, 'origin?,(^)name?'
|
485
491
|
task flag, [:origin, :name] do |_, args|
|
486
|
-
origin =
|
487
|
-
|
492
|
+
if (origin = args.origin)
|
493
|
+
branch = args.name
|
494
|
+
else
|
495
|
+
origin, branch = choice_refs('Choose a remote', 'remotes', values: ['Enter branch name'])
|
496
|
+
end
|
497
|
+
checkout(flag, branch: branch, origin: origin)
|
488
498
|
end
|
489
499
|
when :commit
|
490
500
|
format_desc action, flag, 'branch/commit,opts*'
|
@@ -512,15 +522,21 @@ module Squared
|
|
512
522
|
branch(flag, target: target, ref: args.ref)
|
513
523
|
end
|
514
524
|
when :set
|
515
|
-
format_desc(action, flag, '(^)upstream
|
525
|
+
format_desc(action, flag, '(^)upstream?,name?')
|
516
526
|
task flag, [:upstream, :name] do |_, args|
|
517
|
-
|
518
|
-
|
527
|
+
if (ref = args.upstream)
|
528
|
+
target = args.name
|
529
|
+
else
|
530
|
+
ref, target = choice_refs('Choose a remote', 'remotes', values: ['Enter branch name'])
|
531
|
+
end
|
532
|
+
branch(flag, target: target, ref: ref)
|
519
533
|
end
|
520
534
|
when :delete
|
521
|
-
format_desc action, flag, '(^~)name
|
535
|
+
format_desc action, flag, '(^~)name+?'
|
522
536
|
task flag do |_, args|
|
523
|
-
refs =
|
537
|
+
if (refs = args.to_a).empty?
|
538
|
+
refs = choice_refs('Choose a branch', 'heads', multiple: true, accept: 'Delete?')
|
539
|
+
end
|
524
540
|
branch(flag, refs: refs)
|
525
541
|
end
|
526
542
|
when :edit
|
@@ -699,15 +715,18 @@ module Squared
|
|
699
715
|
cmd, opts = git_session('pull', opts: opts)
|
700
716
|
if flag == :rebase
|
701
717
|
cmd << '--rebase'
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
718
|
+
cmd << '--autostash' if option('autostash')
|
719
|
+
else
|
720
|
+
cmd << '--autostash' if flag == :autostash
|
721
|
+
if (val = option('rebase', ignore: false))
|
722
|
+
cmd << case val
|
723
|
+
when '0', 'false'
|
724
|
+
'--no-rebase'
|
725
|
+
else
|
726
|
+
VAL_GIT[:rebase][:value].include?(val) ? basic_option('rebase', val) : '--rebase'
|
727
|
+
end
|
728
|
+
end
|
709
729
|
end
|
710
|
-
cmd << '--autostash' if option('autostash')
|
711
730
|
append_pull(opts, OPT_GIT[:pull] + OPT_GIT[:fetch][:pull],
|
712
731
|
no: OPT_GIT[:no][:pull] + OPT_GIT[:no][:fetch][:pull], remote: remote, flag: flag)
|
713
732
|
source(sync: sync, sub: if verbose
|
@@ -750,10 +769,14 @@ module Squared
|
|
750
769
|
source
|
751
770
|
end
|
752
771
|
|
772
|
+
def autostash(*, sync: invoked_sync?('autostash'), **)
|
773
|
+
pull(:autostash, sync: sync)
|
774
|
+
end
|
775
|
+
|
753
776
|
def fetch(flag = nil, opts = [], sync: invoked_sync?('fetch', flag), remote: nil)
|
754
777
|
cmd, opts = git_session('fetch', opts: opts)
|
755
|
-
append_pull(opts, collect_hash(OPT_GIT[:fetch]),
|
756
|
-
|
778
|
+
append_pull(opts, collect_hash(OPT_GIT[:fetch]),
|
779
|
+
no: collect_hash(OPT_GIT[:no][:fetch]), remote: remote, flag: flag)
|
757
780
|
cmd << '--all' if !remote && !session_arg?('multiple') && option('all')
|
758
781
|
cmd << '--verbose' if verbose && !session_arg?('quiet')
|
759
782
|
source(sync: sync, **threadargs)
|
@@ -853,16 +876,16 @@ module Squared
|
|
853
876
|
end
|
854
877
|
unless workspace.closed
|
855
878
|
if @revbuild
|
856
|
-
statusargs.
|
879
|
+
statusargs.call.each { |key, val| @revbuild[key] += val }
|
857
880
|
else
|
858
|
-
@revbuild = statusargs.
|
881
|
+
@revbuild = statusargs.call
|
859
882
|
end
|
860
883
|
return
|
861
884
|
end
|
862
|
-
sha = git_spawn('rev-parse --verify HEAD').
|
885
|
+
sha = git_spawn('rev-parse --verify HEAD').chomp
|
863
886
|
return if sha.empty?
|
864
887
|
|
865
|
-
kwargs = kwargs.key?(:include) || kwargs.key?(:exclude) ? statusargs.
|
888
|
+
kwargs = kwargs.key?(:include) || kwargs.key?(:exclude) ? statusargs.call : @revbuild || {}
|
866
889
|
case flag
|
867
890
|
when :build
|
868
891
|
op = OptionPartition.new(opts, OPT_GIT[:status], project: self)
|
@@ -937,16 +960,16 @@ module Squared
|
|
937
960
|
when :branch
|
938
961
|
cmd << '--detach' if detach == 'd' || option('detach')
|
939
962
|
append_option('track', equals: true)
|
940
|
-
cmd << (create ?
|
963
|
+
cmd << (create ? quote_option(create, branch) : branch) << commit
|
941
964
|
when :track
|
942
965
|
if branch
|
943
966
|
if branch.start_with?('^')
|
944
967
|
opt = 'B'
|
945
968
|
branch = branch[1..-1]
|
946
969
|
end
|
947
|
-
cmd <<
|
970
|
+
cmd << quote_option(opt || 'b', branch)
|
948
971
|
end
|
949
|
-
cmd << '--track' << origin
|
972
|
+
cmd << '--track' << shell_quote(origin)
|
950
973
|
when :detach
|
951
974
|
cmd << '--detach' << commit
|
952
975
|
else
|
@@ -995,7 +1018,7 @@ module Squared
|
|
995
1018
|
source
|
996
1019
|
end
|
997
1020
|
|
998
|
-
def
|
1021
|
+
def log!(flag, opts = [], range: [], index: [])
|
999
1022
|
cmd, opts = git_session('log', opts: opts)
|
1000
1023
|
op = OptionPartition.new(opts, collect_hash(OPT_GIT[:log]), cmd,
|
1001
1024
|
project: self, no: collect_hash(OPT_GIT[:no][:log]))
|
@@ -1068,7 +1091,7 @@ module Squared
|
|
1068
1091
|
branch = nil
|
1069
1092
|
upstream = nil
|
1070
1093
|
git_spawn 'fetch --no-tags --quiet'
|
1071
|
-
git_spawn('branch -vv --list', stdout: false).
|
1094
|
+
git_spawn('branch -vv --list', stdout: false).each do |val|
|
1072
1095
|
next unless (r = /^\*\s(\S+)\s+(\h+)(?:\s\[(.+?)(?=\]\s)\])?\s/.match(val))
|
1073
1096
|
|
1074
1097
|
branch = r[1]
|
@@ -1076,7 +1099,7 @@ module Squared
|
|
1076
1099
|
origin = r[3][%r{^(.+)/#{Regexp.escape(branch)}$}, 1]
|
1077
1100
|
else
|
1078
1101
|
unless (origin = option('repository', prefix: 'git', ignore: false))
|
1079
|
-
out = git_spawn
|
1102
|
+
out = git_spawn 'log -n1 --format=%h%d'
|
1080
1103
|
if out =~ /^#{r[2]} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)$/
|
1081
1104
|
split_escape($1).each do |s|
|
1082
1105
|
next unless s.end_with?("/#{branch}")
|
@@ -1161,17 +1184,17 @@ module Squared
|
|
1161
1184
|
end
|
1162
1185
|
ref = nil
|
1163
1186
|
when :delete
|
1164
|
-
force, list = refs.partition { |val| val.match?(/^[
|
1187
|
+
force, list = refs.partition { |val| val.match?(/^[~^]/) }
|
1165
1188
|
force.each do |val|
|
1166
1189
|
dr = val[0, 3]
|
1167
1190
|
d = dr.include?('^') ? '-D' : '-d'
|
1168
|
-
r = dr.include?('~')
|
1191
|
+
r = '-r' if dr.include?('~')
|
1169
1192
|
source git_output('branch', d, r, shell_quote(val.sub(/^[\^~]+/, '')))
|
1170
1193
|
end
|
1171
1194
|
return if list.empty?
|
1172
1195
|
|
1173
1196
|
cmd << '-d'
|
1174
|
-
list
|
1197
|
+
append_value list
|
1175
1198
|
when :move, :copy
|
1176
1199
|
flag = "-#{flag.to_s[0]}"
|
1177
1200
|
cmd << (option('force') ? flag.upcase : flag)
|
@@ -1196,7 +1219,7 @@ module Squared
|
|
1196
1219
|
list_result(ret, 'branches', from: from)
|
1197
1220
|
return
|
1198
1221
|
else
|
1199
|
-
head = git_spawn('rev-parse --abbrev-ref HEAD').
|
1222
|
+
head = git_spawn('rev-parse --abbrev-ref HEAD').chomp
|
1200
1223
|
if head.empty?
|
1201
1224
|
ret = 0
|
1202
1225
|
else
|
@@ -1212,8 +1235,8 @@ module Squared
|
|
1212
1235
|
if (r1 = r[1]) && r1 =~ /^(.+):(?: ([a-z]+) (\d+),)? ([a-z]+) (\d+)$/
|
1213
1236
|
write = ->(s1, s2) { "#{s1.capitalize.rjust(7)}: #{sub_style(s2, styles: theme[:warn])}" }
|
1214
1237
|
r1 = $1
|
1215
|
-
r2 = $2 && write.($2, $3)
|
1216
|
-
r3 = write.($4, $5)
|
1238
|
+
r2 = $2 && write.call($2, $3)
|
1239
|
+
r3 = write.call($4, $5)
|
1217
1240
|
end
|
1218
1241
|
r1 = nil if r1 == "origin/#{data[0]}"
|
1219
1242
|
[" Branch: #{a + (r1 ? " (#{r1})" : '')}", r2, r3, " Commit: #{b}", "Message: #{r[2]}"]
|
@@ -1381,8 +1404,11 @@ module Squared
|
|
1381
1404
|
format_banner((banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), ''), banner: true)
|
1382
1405
|
end
|
1383
1406
|
begin
|
1384
|
-
|
1407
|
+
if io
|
1408
|
+
return `#{cmd}` if stdout
|
1385
1409
|
|
1410
|
+
return banner ? [IO.popen(cmd), banner, from] : IO.popen(cmd)
|
1411
|
+
end
|
1386
1412
|
if stdin? ? sync : stdout
|
1387
1413
|
print_item banner unless multiple
|
1388
1414
|
ret = `#{cmd}`
|
@@ -1471,11 +1497,29 @@ module Squared
|
|
1471
1497
|
on :last, from
|
1472
1498
|
end
|
1473
1499
|
|
1474
|
-
def
|
1500
|
+
def choice_refs(msg, type, format: nil, sort: '-creatordate', count: ARG[:CHOICE], short: true, **kwargs)
|
1501
|
+
unless format
|
1502
|
+
format = +"%(refname#{short ? ':short' : ''})"
|
1503
|
+
case type
|
1504
|
+
when 'heads', 'tags'
|
1505
|
+
format += '%(if)%(HEAD)%(then) *%(end)'
|
1506
|
+
trim = /\s+\*\z/
|
1507
|
+
end
|
1508
|
+
end
|
1509
|
+
cmd = git_output 'for-each-ref', quote_option('format', format)
|
1510
|
+
cmd << quote_option('sort', sort) if sort
|
1511
|
+
cmd << shell_option('count', count) if count
|
1512
|
+
cmd << "refs/#{type}"
|
1513
|
+
choice_index(msg, source(cmd, io: true, banner: false), trim: trim, **kwargs)
|
1514
|
+
end
|
1515
|
+
|
1516
|
+
def status_digest(*args, algorithm: nil, **kwargs)
|
1517
|
+
require 'digest'
|
1518
|
+
algorithm ||= Digest::SHA256
|
1475
1519
|
glob = kwargs.fetch(:include, [])
|
1476
1520
|
pass = kwargs.fetch(:exclude, [])
|
1477
1521
|
ret = {}
|
1478
|
-
git_spawn('status -s --porcelain', *args, stdout: false).
|
1522
|
+
git_spawn('status -s --porcelain', *args, stdout: false).each do |line|
|
1479
1523
|
next unless (file = line[/^[A-Z ?!]{3}"?(.+?)"?$/, 1])
|
1480
1524
|
next if !glob.empty? && glob.none? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
|
1481
1525
|
next if !pass.empty? && pass.any? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
|
@@ -1492,6 +1536,8 @@ module Squared
|
|
1492
1536
|
def append_pull(opts, list, target: @session, flag: nil, no: nil, remote: nil)
|
1493
1537
|
target << '--force' if option('force', target: target)
|
1494
1538
|
append_submodules(target: target)
|
1539
|
+
return if !remote && opts.empty?
|
1540
|
+
|
1495
1541
|
refspec = []
|
1496
1542
|
op = OptionPartition.new(opts, remote ? list + ['refspec=v'] : list, target, project: self, no: no)
|
1497
1543
|
op.each do |opt|
|
@@ -112,7 +112,7 @@ module Squared
|
|
112
112
|
return unless outdated? && ref?(Node.ref)
|
113
113
|
|
114
114
|
namespace name do
|
115
|
-
|
115
|
+
Node.subtasks do |action, flags|
|
116
116
|
next if @pass.include?(action)
|
117
117
|
|
118
118
|
if flags.nil?
|
@@ -201,11 +201,11 @@ module Squared
|
|
201
201
|
tag, otp, dryrun = args
|
202
202
|
end
|
203
203
|
check = ->(val) { val == 'dry-run' || val == 'true' }
|
204
|
-
if check.(otp)
|
204
|
+
if check.call(otp)
|
205
205
|
dryrun = true
|
206
206
|
otp = nil
|
207
207
|
elsif dryrun
|
208
|
-
dryrun = check.(dryrun)
|
208
|
+
dryrun = check.call(dryrun)
|
209
209
|
end
|
210
210
|
publish(flag, otp: otp, tag: tag, dryrun: dryrun)
|
211
211
|
end
|
@@ -445,14 +445,13 @@ module Squared
|
|
445
445
|
if upgrade && !w[5]
|
446
446
|
next if file == want
|
447
447
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
found << [key, file, want, index, major, f, w]
|
448
|
+
found << [key, file, want, if a != c
|
449
|
+
1
|
450
|
+
elsif b != d
|
451
|
+
3
|
452
|
+
else
|
453
|
+
5
|
454
|
+
end, major, f, w]
|
456
455
|
elsif !major
|
457
456
|
avail << [key, file, latest, latest != current]
|
458
457
|
end
|
@@ -478,11 +477,12 @@ module Squared
|
|
478
477
|
end
|
479
478
|
print_item banner unless sync
|
480
479
|
if !found.empty?
|
481
|
-
col1 = size_col.(found, 0) + 4
|
482
|
-
col2 = size_col.(found, 1) + 4
|
480
|
+
col1 = size_col.call(found, 0) + 4
|
481
|
+
col2 = size_col.call(found, 1) + 4
|
483
482
|
found.each_with_index do |item, i|
|
484
483
|
a, b, c, d, e = item
|
485
|
-
|
484
|
+
inter &&= rev != :major || e || semmajor?(item[5], item[6])
|
485
|
+
if inter && !confirm_outdated(a, c, (d / 2.0).ceil, lock: e)
|
486
486
|
cur = -1
|
487
487
|
else
|
488
488
|
cur = modified
|
@@ -510,22 +510,22 @@ module Squared
|
|
510
510
|
else
|
511
511
|
sub_style(c, pat: SEM_VER, styles: color(:green), index: d)
|
512
512
|
end
|
513
|
-
puts "#{pad_ord.(i, found)}. #{a + b + c}"
|
513
|
+
puts "#{pad_ord.call(i, found)}. #{a + b + c}"
|
514
514
|
end
|
515
515
|
pending = avail.reduce(pending) { |a, b| a + (b[3] ? 0 : 1) }
|
516
516
|
if dryrun || (modified == 0 && pending > 0)
|
517
|
-
footer.(modified, found.size)
|
517
|
+
footer.call(modified, found.size)
|
518
518
|
elsif modified > 0
|
519
519
|
modified = -1
|
520
|
-
footer.(0, found.size)
|
520
|
+
footer.call(0, found.size)
|
521
521
|
File.write(dependfile, doc)
|
522
522
|
commit(:add, refs: ['package.json'], pass: true)
|
523
523
|
install if opts.include?('prune')
|
524
524
|
end
|
525
525
|
elsif !avail.empty?
|
526
|
-
col1 = size_col.(avail, 0) + 4
|
527
|
-
col2 = size_col.(avail, 1)
|
528
|
-
col3 = size_col.(avail, 2) + 4
|
526
|
+
col1 = size_col.call(avail, 0) + 4
|
527
|
+
col2 = size_col.call(avail, 1)
|
528
|
+
col3 = size_col.call(avail, 2) + 4
|
529
529
|
avail.each_with_index do |item, i|
|
530
530
|
a, b, c, d = item
|
531
531
|
a = a.ljust(col1)
|
@@ -536,9 +536,9 @@ module Squared
|
|
536
536
|
c = sub_style(c, styles: color(:green))
|
537
537
|
pending += 1
|
538
538
|
end
|
539
|
-
puts "#{pad_ord.(i, avail)}. #{a + c + b} (#{d ? 'locked' : 'latest'})"
|
539
|
+
puts "#{pad_ord.call(i, avail)}. #{a + c + b} (#{d ? 'locked' : 'latest'})"
|
540
540
|
end
|
541
|
-
footer.(0, avail.size)
|
541
|
+
footer.call(0, avail.size)
|
542
542
|
else
|
543
543
|
puts 'No updates were found'
|
544
544
|
end
|
@@ -902,21 +902,6 @@ module Squared
|
|
902
902
|
end
|
903
903
|
end
|
904
904
|
|
905
|
-
def confirm_outdated(pkg, ver, rev, lock)
|
906
|
-
a = sub_style(case rev
|
907
|
-
when 1
|
908
|
-
'MAJOR'
|
909
|
-
when 3
|
910
|
-
'MINOR'
|
911
|
-
else
|
912
|
-
'PATCH'
|
913
|
-
end, styles: theme[:header])
|
914
|
-
b = sub_style("#{pkg} #{ver}", styles: theme[:inline])
|
915
|
-
c, d = rev == 1 || lock ? ['y/N', 'N'] : ['Y/n', 'Y']
|
916
|
-
e = lock ? " #{sub_style('(locked)', styles: color(:red))}" : ''
|
917
|
-
confirm("Upgrade to #{a}? #{b + e} [#{c}] ", d, timeout: 60)
|
918
|
-
end
|
919
|
-
|
920
905
|
def dryrun?(prefix = dependbin, **)
|
921
906
|
super || !option('dry-run', prefix: prefix).nil?
|
922
907
|
end
|
@@ -55,7 +55,7 @@ module Squared
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def bannerargs
|
58
|
-
[
|
58
|
+
%i[dependfile venv].freeze
|
59
59
|
end
|
60
60
|
|
61
61
|
def venv?
|
@@ -109,7 +109,7 @@ module Squared
|
|
109
109
|
return unless outdated? && ref?(Python.ref)
|
110
110
|
|
111
111
|
namespace name do
|
112
|
-
|
112
|
+
Python.subtasks do |action, flags|
|
113
113
|
next if @pass.include?(action)
|
114
114
|
|
115
115
|
namespace action do
|
@@ -211,7 +211,7 @@ module Squared
|
|
211
211
|
'location?'
|
212
212
|
end)
|
213
213
|
task flag do |_, args|
|
214
|
-
|
214
|
+
build! flag, args.to_a
|
215
215
|
end
|
216
216
|
when 'publish'
|
217
217
|
format_desc(action, flag, 'opts*', after: case flag
|
@@ -311,12 +311,12 @@ module Squared
|
|
311
311
|
line = sub_style(line, pat: /^(.+)(#{Regexp.escape(latest)})(.+)$/, styles: styles, index: 2)
|
312
312
|
found += 1
|
313
313
|
end
|
314
|
-
out.("#{start.to_s.rjust(2)}. #{line}")
|
314
|
+
out.call("#{start.to_s.rjust(2)}. #{line}")
|
315
315
|
start += 1
|
316
316
|
elsif line.start_with?('Package')
|
317
317
|
unless stdin?
|
318
318
|
sub = { pat: /^(.*)(?<!\dm)(Package|Latest)(.+)$/, styles: theme[:header], index: 2 }
|
319
|
-
out.(print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub]))
|
319
|
+
out.call(print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub]))
|
320
320
|
end
|
321
321
|
start += 1
|
322
322
|
end
|
@@ -350,7 +350,7 @@ module Squared
|
|
350
350
|
run(from: :install)
|
351
351
|
end
|
352
352
|
|
353
|
-
def
|
353
|
+
def build!(flag, opts = [])
|
354
354
|
case flag
|
355
355
|
when :python
|
356
356
|
cmd, opts = python_session('-m build', opts: opts)
|
@@ -577,7 +577,7 @@ module Squared
|
|
577
577
|
def preopts(quiet: true)
|
578
578
|
ret = []
|
579
579
|
case verbose
|
580
|
-
when
|
580
|
+
when FalseClass
|
581
581
|
ret << '--quiet' if quiet
|
582
582
|
when Numeric
|
583
583
|
ret << "-#{'v' * verbose}" if verbose > 0
|