squared 0.6.4 → 0.6.6
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 +80 -0
- data/README.md +81 -27
- data/lib/squared/common/format.rb +8 -5
- data/lib/squared/common/shell.rb +7 -2
- data/lib/squared/config.rb +14 -12
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +16 -22
- data/lib/squared/workspace/project/base.rb +131 -83
- data/lib/squared/workspace/project/docker.rb +40 -44
- data/lib/squared/workspace/project/git.rb +64 -50
- data/lib/squared/workspace/project/node.rb +123 -105
- data/lib/squared/workspace/project/python.rb +119 -86
- data/lib/squared/workspace/project/ruby.rb +225 -113
- data/lib/squared/workspace/project/support/class.rb +26 -8
- data/lib/squared/workspace/project/support/optionpartition.rb +93 -42
- data/lib/squared/workspace/series.rb +3 -1
- data/lib/squared/workspace.rb +4 -3
- metadata +1 -1
|
@@ -159,7 +159,7 @@ module Squared
|
|
|
159
159
|
end
|
|
160
160
|
@dependname = 'package.json'
|
|
161
161
|
dependfile_set [@dependname]
|
|
162
|
-
@tsfile = basepath
|
|
162
|
+
@tsfile = basepath! ts
|
|
163
163
|
@pm = { __: init }
|
|
164
164
|
end
|
|
165
165
|
|
|
@@ -246,11 +246,11 @@ module Squared
|
|
|
246
246
|
if op.empty?
|
|
247
247
|
op << package
|
|
248
248
|
if (args = readline('Enter arguments', force: false))
|
|
249
|
-
op
|
|
249
|
+
op.delim unless pnpm?
|
|
250
250
|
op << args
|
|
251
251
|
end
|
|
252
252
|
else
|
|
253
|
-
op
|
|
253
|
+
op.delim unless pnpm?
|
|
254
254
|
op << package << op.join(' ')
|
|
255
255
|
end
|
|
256
256
|
else
|
|
@@ -426,7 +426,7 @@ module Squared
|
|
|
426
426
|
Open3.capture2e(session_output('npm', 'pack --dry-run --no-color', npmname).to_s)
|
|
427
427
|
.first
|
|
428
428
|
.scan(/^npm notice \d+(?:\.\d+)?[a-z]+ (.+)$/i)
|
|
429
|
-
.map { |item| Pathname.new(item.first) }
|
|
429
|
+
.map! { |item| Pathname.new(item.first) }
|
|
430
430
|
.select(&:exist?)
|
|
431
431
|
end.concat(Array(files))
|
|
432
432
|
packed = true
|
|
@@ -507,22 +507,23 @@ module Squared
|
|
|
507
507
|
end
|
|
508
508
|
save, exact, omit = save if save.is_a?(Array)
|
|
509
509
|
ws = env('NODE_WORKSPACES', equals: '0')
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
'
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
510
|
+
om = lambda do |cmd|
|
|
511
|
+
if omit
|
|
512
|
+
save = case save
|
|
513
|
+
when 'peer'
|
|
514
|
+
'optional'
|
|
515
|
+
when 'optional'
|
|
516
|
+
'dev'
|
|
517
|
+
when 'dev'
|
|
518
|
+
'prod'
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
return unless save && save != 'bundle'
|
|
522
|
+
|
|
523
|
+
cmd << "--#{save}"
|
|
523
524
|
end
|
|
524
525
|
rm = lambda do |target|
|
|
525
|
-
|
|
526
|
+
return if remove.empty?
|
|
526
527
|
|
|
527
528
|
run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '), from: :remove, sync: sync)
|
|
528
529
|
end
|
|
@@ -531,15 +532,15 @@ module Squared
|
|
|
531
532
|
append_loglevel
|
|
532
533
|
if yarn == 1
|
|
533
534
|
cmd << '--ignore-engines' unless option('ignore-engines', equals: '0')
|
|
534
|
-
cmd << '--ignore-scripts' if
|
|
535
|
+
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
535
536
|
cmd << '--force' if option('force')
|
|
536
537
|
else
|
|
537
|
-
cmd << '--mode=skip-build' if
|
|
538
|
+
cmd << '--mode=skip-build' if option('ignore-scripts')
|
|
538
539
|
cmd << '--check-cache' if !flag && option('force')
|
|
539
540
|
end
|
|
540
541
|
if nolockfile?('yarn')
|
|
541
542
|
cmd << '--no-lockfile'
|
|
542
|
-
elsif ci
|
|
543
|
+
elsif option('ci')
|
|
543
544
|
if yarn == 1
|
|
544
545
|
cmd << '--frozen-lockfile'
|
|
545
546
|
elsif !flag
|
|
@@ -549,8 +550,7 @@ module Squared
|
|
|
549
550
|
if add
|
|
550
551
|
cmd << '-W' if yarn == 1 && !option('w', 'ignore-workspace-root-check', equals: '0')
|
|
551
552
|
rm.call(cmd)
|
|
552
|
-
om.call
|
|
553
|
-
cmd << "--#{save}" if save && save != 'bundle'
|
|
553
|
+
om.call(cmd)
|
|
554
554
|
cmd << '--exact' if exact
|
|
555
555
|
end
|
|
556
556
|
elsif pnpm?
|
|
@@ -558,8 +558,7 @@ module Squared
|
|
|
558
558
|
append_nocolor
|
|
559
559
|
append_loglevel
|
|
560
560
|
if add
|
|
561
|
-
om.call
|
|
562
|
-
cmd << "--save-#{save}" if save && save != 'bundle'
|
|
561
|
+
om.call(cmd)
|
|
563
562
|
rm.call(cmd)
|
|
564
563
|
cmd << '--save-exact' if exact
|
|
565
564
|
option('allow-build') { |val| cmd << quote_option('allow-build', val) }
|
|
@@ -574,17 +573,18 @@ module Squared
|
|
|
574
573
|
'--force'
|
|
575
574
|
elsif nolockfile?('pnpm')
|
|
576
575
|
'--no-lockfile'
|
|
577
|
-
elsif ci
|
|
576
|
+
elsif option('ci')
|
|
578
577
|
'--frozen-lockfile'
|
|
579
578
|
end
|
|
580
|
-
cmd << '--ignore-scripts' if
|
|
579
|
+
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
581
580
|
else
|
|
582
|
-
cmd = session
|
|
581
|
+
cmd = session 'npm'
|
|
582
|
+
cmd << (ci = option('ci') ? 'ci' : 'install')
|
|
583
583
|
cmd << '--workspaces=false' if ws
|
|
584
584
|
append_nocolor
|
|
585
585
|
append_loglevel
|
|
586
586
|
if omit
|
|
587
|
-
cmd << "--omit=#{save}"
|
|
587
|
+
cmd << "--omit=#{save || omit}"
|
|
588
588
|
save = nil
|
|
589
589
|
end
|
|
590
590
|
unless ci
|
|
@@ -597,7 +597,7 @@ module Squared
|
|
|
597
597
|
end
|
|
598
598
|
end
|
|
599
599
|
cmd << '--package-lock=false' << 'save=false' if nolockfile?('npm')
|
|
600
|
-
cmd << '--ignore-scripts' if
|
|
600
|
+
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
601
601
|
end
|
|
602
602
|
if add
|
|
603
603
|
return if packages.empty?
|
|
@@ -630,13 +630,20 @@ module Squared
|
|
|
630
630
|
end
|
|
631
631
|
found = []
|
|
632
632
|
avail = []
|
|
633
|
-
|
|
633
|
+
flag ||= case (up = option('u', 'update'))
|
|
634
|
+
when 'major', 'minor'
|
|
635
|
+
up.to_sym
|
|
636
|
+
else
|
|
637
|
+
prod? ? :patch : :minor
|
|
638
|
+
end
|
|
634
639
|
if sync && !stdin?
|
|
635
|
-
if has_value?(opts, 's', 'select')
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
+
items = if has_value?(opts, 's', 'select')
|
|
641
|
+
se = true
|
|
642
|
+
[]
|
|
643
|
+
elsif has_value?(opts, 'i', 'interactive')
|
|
644
|
+
ia = true
|
|
645
|
+
[]
|
|
646
|
+
end
|
|
640
647
|
end
|
|
641
648
|
unless data.empty?
|
|
642
649
|
JSON.parse(data).each_pair do |key, val|
|
|
@@ -647,7 +654,7 @@ module Squared
|
|
|
647
654
|
ch = file[0]
|
|
648
655
|
if ch.match?(/[~^]/)
|
|
649
656
|
file = file[1..-1]
|
|
650
|
-
elsif ia &&
|
|
657
|
+
elsif ia && flag == :major
|
|
651
658
|
major = true
|
|
652
659
|
else
|
|
653
660
|
avail << [key, file, latest, true]
|
|
@@ -656,7 +663,7 @@ module Squared
|
|
|
656
663
|
current = val['current'] || file
|
|
657
664
|
want = val['wanted']
|
|
658
665
|
unless latest[SEM_VER, 6]
|
|
659
|
-
case
|
|
666
|
+
case flag
|
|
660
667
|
when :major
|
|
661
668
|
want = latest
|
|
662
669
|
when :minor
|
|
@@ -675,7 +682,7 @@ module Squared
|
|
|
675
682
|
b = f[2]
|
|
676
683
|
c = w[0]
|
|
677
684
|
d = w[2]
|
|
678
|
-
upgrade = case
|
|
685
|
+
upgrade = case flag
|
|
679
686
|
when :major
|
|
680
687
|
a == '0' ? c == '0' || c == '1' : true
|
|
681
688
|
when :minor
|
|
@@ -703,7 +710,7 @@ module Squared
|
|
|
703
710
|
width = ->(a, i) { a.map { |aa| aa[i] }.max_by(&:size).size }
|
|
704
711
|
pad = ->(val, ord) { val.succ.to_s.rjust([ord.size.to_s.size, 2].max) }
|
|
705
712
|
footer = lambda do |val, size|
|
|
706
|
-
|
|
713
|
+
return unless verbose
|
|
707
714
|
|
|
708
715
|
msg, hint = if modified == -1
|
|
709
716
|
['Packages were updated', 'more possible']
|
|
@@ -717,6 +724,7 @@ module Squared
|
|
|
717
724
|
if !found.empty?
|
|
718
725
|
col1 = width.call(found, 0) + 4
|
|
719
726
|
col2 = width.call(found, 1) + 4
|
|
727
|
+
col3 = pad.call(found.size, found).size + 2 + col1 + col2 + width.call(found, 2)
|
|
720
728
|
packages = []
|
|
721
729
|
pat = ->(a) { /("#{Regexp.escape(a[0])}"\s*:\s*)"([~^])#{'?' if a[4]}#{Regexp.escape(a[1])}"/ }
|
|
722
730
|
edit = lambda do |a, pkg, mod|
|
|
@@ -724,60 +732,57 @@ module Squared
|
|
|
724
732
|
modified += 1
|
|
725
733
|
"#{pkg}\"#{mod || (a[3] == 1 && a[4] ? '^' : '')}#{a[2]}\""
|
|
726
734
|
end
|
|
727
|
-
kwargs = { col1: col1, col2: col2, col3: width.call(found, 2), timeout: 0 }
|
|
728
735
|
found.each_with_index do |item, i|
|
|
729
736
|
a, b, c, d, e = item
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
cur = -1
|
|
739
|
-
pending += 1
|
|
740
|
-
capture
|
|
741
|
-
else
|
|
742
|
-
edit.call(item, $1, $2)
|
|
743
|
-
end
|
|
737
|
+
cur = modified
|
|
738
|
+
doc.send(items ? :sub : :sub!, pat.call(item)) do |capture|
|
|
739
|
+
if $2 == '~' && flag != :patch
|
|
740
|
+
cur = -1
|
|
741
|
+
pending += 1
|
|
742
|
+
capture
|
|
743
|
+
else
|
|
744
|
+
edit.call(item, $1, $2)
|
|
744
745
|
end
|
|
745
746
|
end
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
747
|
+
a = a.ljust(col1)
|
|
748
|
+
b = b.ljust(col2)
|
|
749
|
+
sub_style! b, theme[:current] if theme[:current] && !stdin?
|
|
750
|
+
if cur == -1
|
|
751
|
+
c = 'SKIP'
|
|
752
|
+
elsif modified == cur
|
|
753
|
+
c = 'FAIL'
|
|
754
|
+
elsif !stdin?
|
|
755
|
+
if d == 1
|
|
756
|
+
sub_style! a, theme[:major]
|
|
757
|
+
sub_style! c, :bold, color(:green)
|
|
758
|
+
else
|
|
759
|
+
sub_style!(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
|
|
760
|
+
end
|
|
761
|
+
g = item
|
|
753
762
|
end
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
elsif modified == cur
|
|
757
|
-
'FAIL'
|
|
758
|
-
elsif stdin?
|
|
759
|
-
c
|
|
760
|
-
else
|
|
761
|
-
g = item
|
|
762
|
-
if d == 1
|
|
763
|
-
sub_style! a, theme[:major]
|
|
764
|
-
sub_style c, :bold, color(:green)
|
|
765
|
-
else
|
|
766
|
-
sub_style(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
|
|
767
|
-
end
|
|
768
|
-
end
|
|
769
|
-
s = a + b + c
|
|
770
|
-
if !items
|
|
771
|
-
puts "#{f ? ' ' * col0.size : col0}#{s}"
|
|
772
|
-
elsif g
|
|
763
|
+
s = "#{pad.call(i, found)}. #{a}#{b}#{c}"
|
|
764
|
+
if se
|
|
773
765
|
items << [s, g]
|
|
766
|
+
next
|
|
767
|
+
elsif ia && g
|
|
768
|
+
items << [g]
|
|
769
|
+
if flag != :major || e || semmajor?(item[5], item[6])
|
|
770
|
+
items.pop unless confirm_semver(s.ljust(col3 + s.size - s.stripstyle.size), (d / 2.0).ceil)
|
|
771
|
+
next
|
|
772
|
+
end
|
|
774
773
|
end
|
|
774
|
+
puts s
|
|
775
775
|
end
|
|
776
776
|
pending = avail.reduce(pending) { |a, b| a + (b[3] ? 0 : 1) }
|
|
777
|
-
if dryrun || (modified == 0 && (pending > 0 || (items && pending == 0)))
|
|
777
|
+
if (dryrun && Array(items).empty?) || (modified == 0 && (pending > 0 || (items && pending == 0)))
|
|
778
778
|
n = if items
|
|
779
|
-
|
|
780
|
-
|
|
779
|
+
if items.empty?
|
|
780
|
+
puts 'No updates were selected'
|
|
781
|
+
0
|
|
782
|
+
else
|
|
783
|
+
puts items.map(&:first) if se
|
|
784
|
+
items.size
|
|
785
|
+
end
|
|
781
786
|
else
|
|
782
787
|
found.size
|
|
783
788
|
end
|
|
@@ -785,24 +790,33 @@ module Squared
|
|
|
785
790
|
elsif modified > 0
|
|
786
791
|
if items
|
|
787
792
|
packages.clear
|
|
788
|
-
|
|
789
|
-
.
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
+
if ia
|
|
794
|
+
(1..items.size)
|
|
795
|
+
else
|
|
796
|
+
choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
|
|
797
|
+
border: true)
|
|
798
|
+
end.each do |n|
|
|
799
|
+
item = items[n.pred].last
|
|
800
|
+
doc.sub!(pat.call(item)) { edit.call(item, $1, $2) }
|
|
801
|
+
end
|
|
793
802
|
end
|
|
794
803
|
unless packages.empty?
|
|
795
|
-
|
|
796
|
-
if
|
|
797
|
-
run(git_output('diff', shell_quote(dependfile)), banner: false)
|
|
798
|
-
end
|
|
799
|
-
if has_value?(opts, 'u', 'update') || option('update')
|
|
800
|
-
package(:update, packages: packages, from: :'outdated:update')
|
|
801
|
-
else
|
|
802
|
-
modified = -1
|
|
804
|
+
modified = -1
|
|
805
|
+
if dryrun
|
|
803
806
|
footer.call(0, found.size)
|
|
807
|
+
else
|
|
808
|
+
File.write(dependfile, doc)
|
|
809
|
+
if sync && (opts.include?('diff') || option('diff'))
|
|
810
|
+
run(git_output('diff', shell_quote(dependfile)), banner: false)
|
|
811
|
+
end
|
|
812
|
+
if has_value?(opts, 'u', 'update') || up
|
|
813
|
+
package(:update, packages: packages, from: :'outdated:update')
|
|
814
|
+
else
|
|
815
|
+
footer.call(0, found.size)
|
|
816
|
+
end
|
|
817
|
+
printsucc
|
|
818
|
+
commit(:add, [dependname], pass: true)
|
|
804
819
|
end
|
|
805
|
-
commit(:add, [dependname], pass: true)
|
|
806
820
|
end
|
|
807
821
|
end
|
|
808
822
|
elsif !avail.empty?
|
|
@@ -948,7 +962,7 @@ module Squared
|
|
|
948
962
|
case flag
|
|
949
963
|
when :install, :update
|
|
950
964
|
opts.unshift('package-lock=false', 'save=false') if nolockfile?('npm')
|
|
951
|
-
spec = 0
|
|
965
|
+
spec = flag == :install ? 0 : 2
|
|
952
966
|
when :add
|
|
953
967
|
spec = 1
|
|
954
968
|
flag = :install
|
|
@@ -987,17 +1001,17 @@ module Squared
|
|
|
987
1001
|
end
|
|
988
1002
|
append_loglevel
|
|
989
1003
|
case spec
|
|
990
|
-
when
|
|
1004
|
+
when Numeric
|
|
991
1005
|
op.each do |opt|
|
|
992
1006
|
if opt =~ op.values
|
|
993
1007
|
case $1
|
|
994
1008
|
when 'w', 'workspace'
|
|
995
1009
|
op << quotepath($1, $2)
|
|
996
1010
|
end
|
|
997
|
-
elsif opt.
|
|
1011
|
+
elsif opt.match?(/^-|=/)
|
|
998
1012
|
op.errors << opt
|
|
999
1013
|
else
|
|
1000
|
-
op.found << opt
|
|
1014
|
+
op.found << (spec == 2 && (n = opt.index('@')) ? opt[0, n] : opt)
|
|
1001
1015
|
end
|
|
1002
1016
|
end
|
|
1003
1017
|
op.swap
|
|
@@ -1099,7 +1113,7 @@ module Squared
|
|
|
1099
1113
|
print_run(cmd, banner, **kwargs)
|
|
1100
1114
|
session 'npx', cmd
|
|
1101
1115
|
start = time_epoch if kwargs.fetch(:verbose, verbose? && !stdin?)
|
|
1102
|
-
run(sync: sync, banner: banner, from: from).tap do |ret|
|
|
1116
|
+
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: from).tap do |ret|
|
|
1103
1117
|
next unless success?(ret, banner, start.nil?) && start
|
|
1104
1118
|
|
|
1105
1119
|
print_status(name, subject: 'tsc', start: start, from: :completed)
|
|
@@ -1313,7 +1327,7 @@ module Squared
|
|
|
1313
1327
|
|
|
1314
1328
|
def remove_modules(prefix = dependbin)
|
|
1315
1329
|
modules = basepath 'node_modules'
|
|
1316
|
-
return false unless modules.directory? && (option('
|
|
1330
|
+
return false unless modules.directory? && (option('y', prefix: prefix) || confirm_basic('Remove?', modules))
|
|
1317
1331
|
|
|
1318
1332
|
modules.rmtree
|
|
1319
1333
|
rescue Timeout::Error => e
|
|
@@ -1360,7 +1374,11 @@ module Squared
|
|
|
1360
1374
|
end
|
|
1361
1375
|
|
|
1362
1376
|
def append_platform(target: @session)
|
|
1363
|
-
%w[cpu os libc].each
|
|
1377
|
+
%w[cpu os libc].each do |name|
|
|
1378
|
+
next unless (val = option(name))
|
|
1379
|
+
|
|
1380
|
+
target << basic_option(name, val)
|
|
1381
|
+
end
|
|
1364
1382
|
end
|
|
1365
1383
|
|
|
1366
1384
|
def quotepath(name, val)
|