squared 0.6.5 → 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 +64 -0
- data/README.md +80 -26
- data/lib/squared/common/format.rb +5 -1
- data/lib/squared/common/shell.rb +7 -2
- data/lib/squared/config.rb +12 -8
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +14 -20
- data/lib/squared/workspace/project/base.rb +39 -26
- data/lib/squared/workspace/project/docker.rb +37 -41
- data/lib/squared/workspace/project/git.rb +58 -44
- data/lib/squared/workspace/project/node.rb +42 -37
- data/lib/squared/workspace/project/python.rb +100 -77
- data/lib/squared/workspace/project/ruby.rb +149 -104
- 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
|
@@ -154,33 +154,34 @@ module Squared
|
|
|
154
154
|
task action, [:command] do |_, args|
|
|
155
155
|
command = param_guard(action, 'command', args: args, key: :command)
|
|
156
156
|
args = args.extras
|
|
157
|
-
cmd = docker_output
|
|
157
|
+
cmd = docker_output command, case command
|
|
158
158
|
when 'image', 'container', 'network'
|
|
159
159
|
'ls'
|
|
160
160
|
when 'compose'
|
|
161
161
|
'ps'
|
|
162
162
|
else
|
|
163
163
|
raise_error ArgumentError, 'unrecognized command', hint: command
|
|
164
|
-
end
|
|
164
|
+
end
|
|
165
165
|
cmd << '-a' if has_value!(args, 'a', 'all') && command != 'network'
|
|
166
166
|
data = VAL_DOCKER[:ls][command.to_sym]
|
|
167
|
-
if has_value!(args, 's', 'standard')
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
167
|
+
cols = if has_value!(args, 's', 'standard')
|
|
168
|
+
data.first(data.index('CreatedAt'))
|
|
169
|
+
else
|
|
170
|
+
[].tap do |out|
|
|
171
|
+
args.each do |val|
|
|
172
|
+
if val =~ /^(\d+)$/
|
|
173
|
+
out << data[$1.to_i.pred]
|
|
174
|
+
elsif val =~ /^(\d+)(-|\.{2,3})(\d+)$/
|
|
175
|
+
j = $1.to_i.pred
|
|
176
|
+
k = $3.to_i - ($2 == '..' ? 2 : 1)
|
|
177
|
+
out.concat(data[j..k]) if k > j
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
next unless out.empty?
|
|
181
|
+
|
|
182
|
+
out.replace(choice_index('Select a column', data, multiple: true, attempts: 1))
|
|
183
|
+
end
|
|
184
|
+
end
|
|
184
185
|
cmd << quote_option('format', "table #{cols.map! { |val| "{{.#{val}}}" }.join("\t")}")
|
|
185
186
|
run(cmd, banner: false, from: :ls)
|
|
186
187
|
end
|
|
@@ -417,7 +418,7 @@ module Squared
|
|
|
417
418
|
lines = IO.popen(cmd.temp('--services')).map(&:strip).reject(&:empty?)
|
|
418
419
|
return list_empty(hint: status) if lines.empty?
|
|
419
420
|
|
|
420
|
-
service = choice_index('Choose a service', lines, multiple: true,
|
|
421
|
+
service = choice_index('Choose a service', lines, multiple: true, attempts: 1)
|
|
421
422
|
end
|
|
422
423
|
docker_session('compose', command, '--', *service)
|
|
423
424
|
else
|
|
@@ -545,11 +546,12 @@ module Squared
|
|
|
545
546
|
if opts.size == op.size
|
|
546
547
|
index = 0
|
|
547
548
|
name = nil
|
|
548
|
-
opts.reverse_each do |
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
549
|
+
opts.reverse_each do |val|
|
|
550
|
+
next unless (arg = OptionPartition.parse_arg!('name', val))
|
|
551
|
+
|
|
552
|
+
name = arg[1]
|
|
553
|
+
opts.delete(val)
|
|
554
|
+
break
|
|
553
555
|
end
|
|
554
556
|
list_image(:run, from: from) do |val|
|
|
555
557
|
container(:run, if name
|
|
@@ -732,21 +734,17 @@ module Squared
|
|
|
732
734
|
end
|
|
733
735
|
|
|
734
736
|
def append_tag(val, target: @session)
|
|
737
|
+
ver = option('version', target: target, ignore: false)
|
|
735
738
|
case val
|
|
736
739
|
when String
|
|
737
740
|
split_escape val
|
|
738
|
-
when Array
|
|
739
|
-
val
|
|
740
741
|
else
|
|
741
|
-
|
|
742
|
-
end.
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
s = "#{s}:#{ver}" if ver && (!s.include?(':') || s.delete_suffix!(':latest'))
|
|
746
|
-
target << basic_option('tag', tagname(s))
|
|
747
|
-
end
|
|
748
|
-
target
|
|
742
|
+
Array(val)
|
|
743
|
+
end.each do |s|
|
|
744
|
+
s = "#{s}:#{ver}" if ver && (!s.include?(':') || s.delete_suffix!(':latest'))
|
|
745
|
+
target << basic_option('tag', tagname(s))
|
|
749
746
|
end
|
|
747
|
+
target
|
|
750
748
|
end
|
|
751
749
|
|
|
752
750
|
def filter_ps(flag, from = :'container:ps')
|
|
@@ -873,14 +871,12 @@ module Squared
|
|
|
873
871
|
"--format='table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.CreatedSince}}\t{{.Size}}'"]
|
|
874
872
|
end
|
|
875
873
|
lines = `#{docker_output(cmd)}`.lines
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
puts log_message('none found', subject: name, hint: "docker #{cmd.split(' ', 3)[0...2].join(' ')}")
|
|
874
|
+
if lines.size <= 1
|
|
875
|
+
puts log_message('none found', subject: name, hint: "docker #{cmd.split(' ', 3)[0, 2].join(' ')}")
|
|
879
876
|
return
|
|
880
877
|
end
|
|
881
|
-
puts " # #{
|
|
878
|
+
puts " # #{lines.shift}"
|
|
882
879
|
multiple = false
|
|
883
|
-
parse = ->(val) { val.split(/\s+/)[0] }
|
|
884
880
|
ctx = flag.to_s
|
|
885
881
|
case flag
|
|
886
882
|
when :run, :exec
|
|
@@ -915,7 +911,7 @@ module Squared
|
|
|
915
911
|
else
|
|
916
912
|
cmd << opts << '--'
|
|
917
913
|
end
|
|
918
|
-
cmd.merge(Array(out).map! { |val|
|
|
914
|
+
cmd.merge(Array(out).map! { |val| val.split(/\s+/, 2).first })
|
|
919
915
|
cmd << args
|
|
920
916
|
success?(run(cmd), ctx.start_with?(/network|tag|save/))
|
|
921
917
|
end
|
|
@@ -29,7 +29,7 @@ module Squared
|
|
|
29
29
|
base = name.to_s
|
|
30
30
|
each { |proj| repo << proj if !proj.parent && check.call(proj) }
|
|
31
31
|
else
|
|
32
|
-
warn
|
|
32
|
+
warn log_warn(name, subject: 'git', hint: 'invalid') if warning
|
|
33
33
|
return self
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -86,7 +86,7 @@ module Squared
|
|
|
86
86
|
@revdoc = JSON.parse(@revfile.read) if @revfile.exist?
|
|
87
87
|
rescue StandardError => e
|
|
88
88
|
@revfile = nil
|
|
89
|
-
warn
|
|
89
|
+
warn log_warn(e, pass: true)
|
|
90
90
|
self
|
|
91
91
|
else
|
|
92
92
|
@revdoc = {} unless @revdoc.is_a?(Hash)
|
|
@@ -142,7 +142,7 @@ module Squared
|
|
|
142
142
|
File.write(@revfile, JSON.pretty_generate(@revdoc))
|
|
143
143
|
rescue StandardError => e
|
|
144
144
|
log&.debug e
|
|
145
|
-
warn
|
|
145
|
+
warn log_warn(e, pass: true) if warning
|
|
146
146
|
ensure
|
|
147
147
|
@revlock = false
|
|
148
148
|
end
|
|
@@ -580,17 +580,17 @@ module Squared
|
|
|
580
580
|
when '--'
|
|
581
581
|
grep << '--' if grep.empty?
|
|
582
582
|
break
|
|
583
|
-
when
|
|
583
|
+
when /^a(ll-match)?$/
|
|
584
584
|
opts << 'all-match'
|
|
585
|
-
when
|
|
585
|
+
when /^in(vert-grep)?$/
|
|
586
586
|
opts << 'invert-grep'
|
|
587
587
|
when 'i', 'E', 'F', 'P'
|
|
588
588
|
opts << last
|
|
589
589
|
else
|
|
590
|
-
if last =~ /^(
|
|
590
|
+
if last =~ /^(f(-ormat)?)=(.+)$/
|
|
591
591
|
opts.shift
|
|
592
592
|
opts << "format=#{$1}"
|
|
593
|
-
elsif last =~ /^(
|
|
593
|
+
elsif last =~ /^(max(-count)?)=(\d+)$/
|
|
594
594
|
opts << "max-count=#{$1}"
|
|
595
595
|
else
|
|
596
596
|
grep << last
|
|
@@ -1167,7 +1167,7 @@ module Squared
|
|
|
1167
1167
|
end
|
|
1168
1168
|
end
|
|
1169
1169
|
out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
|
|
1170
|
-
values: values, column: /^[^@]+@\{(\d+)}
|
|
1170
|
+
values: values, column: /^[^@]+@\{(\d+)\}/)
|
|
1171
1171
|
if values
|
|
1172
1172
|
op.merge(out.reverse)
|
|
1173
1173
|
else
|
|
@@ -1276,9 +1276,7 @@ module Squared
|
|
|
1276
1276
|
files = status_digest(*args, **kwargs)
|
|
1277
1277
|
if cur['files'].size == files.size && cur['files'].find { |key, val| files[key] != val }.nil?
|
|
1278
1278
|
workspace.rev_timeutc(name, 'build') unless (since = workspace.rev_timesince(name, 'build'))
|
|
1279
|
-
if stdout?
|
|
1280
|
-
puts log_message(['revbuild', 'no changes'], subject: name, hint: ("#{since} ago" if since))
|
|
1281
|
-
end
|
|
1279
|
+
puts log_message(['revbuild', 'no changes'], subject: name, hint: ("#{since} ago" if since)) if stdout?
|
|
1282
1280
|
return
|
|
1283
1281
|
end
|
|
1284
1282
|
end
|
|
@@ -1513,13 +1511,14 @@ module Squared
|
|
|
1513
1511
|
append_pathspec op.extras
|
|
1514
1512
|
end
|
|
1515
1513
|
co = git_session('commit', options: false)
|
|
1516
|
-
pu = git_output 'push'
|
|
1514
|
+
pu = git_output 'push'
|
|
1515
|
+
co << '--amend' if amend
|
|
1516
|
+
pu << '--set-upstream' if upstream
|
|
1517
1517
|
if dryrun?
|
|
1518
|
-
op.
|
|
1518
|
+
op.adjoin('--dry-run')
|
|
1519
1519
|
co << '--dry-run'
|
|
1520
1520
|
pu << '--dry-run'
|
|
1521
1521
|
end
|
|
1522
|
-
co << '--amend' if amend
|
|
1523
1522
|
if message
|
|
1524
1523
|
append_message message
|
|
1525
1524
|
elsif flag == :'amend-orig' || option('edit', equals: '0')
|
|
@@ -1527,13 +1526,12 @@ module Squared
|
|
|
1527
1526
|
end
|
|
1528
1527
|
pu << '--force-with-lease' if amend
|
|
1529
1528
|
pu.merge(repotrack(origin, branch))
|
|
1530
|
-
puts if pass
|
|
1531
1529
|
adding = git_spawn 'diff --name-only --no-color'
|
|
1532
1530
|
source op
|
|
1533
1531
|
cached = git_spawn 'diff --cached --name-only --no-color'
|
|
1534
1532
|
if amend || !cached.empty? || dryrun?
|
|
1535
1533
|
if adding.empty? && !cached.empty? && banner?
|
|
1536
|
-
puts(cached.lines.map! { |val| "cached #{shell_quote(val
|
|
1534
|
+
puts(cached.lines(chomp: true).map! { |val| "cached #{shell_quote(val)}" })
|
|
1537
1535
|
end
|
|
1538
1536
|
source co
|
|
1539
1537
|
source pu
|
|
@@ -1553,7 +1551,8 @@ module Squared
|
|
|
1553
1551
|
case flag
|
|
1554
1552
|
when :commit, :'no-commit'
|
|
1555
1553
|
op = OptionPartition.new(opts, OPT_GIT[:merge], cmd, project: self, no: OPT_GIT[:no][:merge])
|
|
1556
|
-
op << "--#{flag}"
|
|
1554
|
+
op << "--#{flag}"
|
|
1555
|
+
op.delim
|
|
1557
1556
|
if branch
|
|
1558
1557
|
op << branch
|
|
1559
1558
|
op.clear(pass: false)
|
|
@@ -1643,13 +1642,15 @@ module Squared
|
|
|
1643
1642
|
git_spawn 'fetch --all --prune --quiet' if option('sync')
|
|
1644
1643
|
cmd << '-vv --no-abbrev --list'
|
|
1645
1644
|
out, banner, from = source(io: true)
|
|
1646
|
-
|
|
1645
|
+
first = workspace.size > 1
|
|
1646
|
+
grep = first ? [/^\*\s+#{Regexp.escape(head)}\s/] : []
|
|
1647
|
+
ret = write_lines(out, grep: grep, banner: banner, first: first) do |line, index|
|
|
1647
1648
|
next line if stdin?
|
|
1648
1649
|
|
|
1649
|
-
data = line.sub(
|
|
1650
|
-
a = sub_style
|
|
1651
|
-
b =
|
|
1652
|
-
r = /\A(?:\[((?~\]\s))\]\s)?(.+)\z/m.match(data[2
|
|
1650
|
+
data = line.sub(/^\*?\s+/, '').split(/\s+/, 3)
|
|
1651
|
+
a = sub_style(data[0], theme[:inline], styles: (:underline if !first && line.start_with?('*')))
|
|
1652
|
+
b = commitstyle data[1]
|
|
1653
|
+
r = /\A(?:\[((?~\]\s))\]\s)?(.+)\z/m.match(data[2])
|
|
1653
1654
|
if (r1 = r[1]) && r1 =~ /^(.+):(?: ([a-z]+) (\d+),)? ([a-z]+) (\d+)$/
|
|
1654
1655
|
write = ->(s1, s2) { "#{s1.capitalize.rjust(7)}: #{sub_style(s2, theme[:warn])}" }
|
|
1655
1656
|
r1 = $1
|
|
@@ -1657,7 +1658,7 @@ module Squared
|
|
|
1657
1658
|
r3 = write.call($4, $5)
|
|
1658
1659
|
end
|
|
1659
1660
|
r1 = nil if r1 == "origin/#{data[0]}"
|
|
1660
|
-
[" Branch: #{a.subhint(r1)}", r2, r3, " Commit: #{b}", "Message: #{r[2]}"]
|
|
1661
|
+
["#{"\n" unless index == 0} Branch: #{a.subhint(r1)}", r2, r3, " Commit: #{b}", "Message: #{r[2]}"]
|
|
1661
1662
|
.compact
|
|
1662
1663
|
.join("\n")
|
|
1663
1664
|
end
|
|
@@ -1690,7 +1691,7 @@ module Squared
|
|
|
1690
1691
|
basic_option 'track', track
|
|
1691
1692
|
end
|
|
1692
1693
|
when :detach
|
|
1693
|
-
cmd <<
|
|
1694
|
+
cmd << '--detach'
|
|
1694
1695
|
end
|
|
1695
1696
|
append_head commit
|
|
1696
1697
|
end
|
|
@@ -1738,7 +1739,7 @@ module Squared
|
|
|
1738
1739
|
case format
|
|
1739
1740
|
when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
|
|
1740
1741
|
cmd << basic_option('format', format)
|
|
1741
|
-
when
|
|
1742
|
+
when /^t?format:|%/
|
|
1742
1743
|
cmd << quote_option('pretty', format)
|
|
1743
1744
|
else
|
|
1744
1745
|
opts << format if format
|
|
@@ -1754,7 +1755,7 @@ module Squared
|
|
|
1754
1755
|
cmd, opts = git_session('rev-parse', opts: opts)
|
|
1755
1756
|
case flag
|
|
1756
1757
|
when :commit
|
|
1757
|
-
cmd << (
|
|
1758
|
+
cmd << (size.to_i.zero? ? '--verify' : basic_option('short', [size.to_i, 5].max))
|
|
1758
1759
|
append_commit(ref, head: true)
|
|
1759
1760
|
when :branch
|
|
1760
1761
|
cmd << '--abbrev-ref'
|
|
@@ -1823,15 +1824,14 @@ module Squared
|
|
|
1823
1824
|
grep, pathspec = op.partition { |val| OptionPartition.pattern?(val) }
|
|
1824
1825
|
unless grep.empty? && !pathspec.empty?
|
|
1825
1826
|
grep.map! { |val| Regexp.new(val[1..-2]) }
|
|
1826
|
-
files = []
|
|
1827
|
-
|
|
1828
|
-
|
|
1827
|
+
files = []
|
|
1828
|
+
status_data.each do |a, b|
|
|
1829
|
+
next if b.strip.empty? || (!grep.empty? && grep.none? { |pat| pat.match?(a) })
|
|
1829
1830
|
|
|
1830
|
-
|
|
1831
|
-
end
|
|
1831
|
+
files << "#{sub_style(b, color(:red))} #{a}"
|
|
1832
1832
|
end
|
|
1833
1833
|
unless files.empty?
|
|
1834
|
-
files = choice_index('Select files', files, multiple: true,
|
|
1834
|
+
files = choice_index('Select files', files, multiple: true, trim: /^\S+\s/,
|
|
1835
1835
|
accept: [accept_y('Add?')])
|
|
1836
1836
|
end
|
|
1837
1837
|
op.swap(pathspec + files)
|
|
@@ -1850,8 +1850,8 @@ module Squared
|
|
|
1850
1850
|
if op.include?('--')
|
|
1851
1851
|
op.add_path(val)
|
|
1852
1852
|
elsif op.exist?(val, glob: true)
|
|
1853
|
-
op
|
|
1854
|
-
|
|
1853
|
+
op.delim
|
|
1854
|
+
.add_path(val)
|
|
1855
1855
|
else
|
|
1856
1856
|
op.add_quote(val)
|
|
1857
1857
|
end
|
|
@@ -1951,7 +1951,7 @@ module Squared
|
|
|
1951
1951
|
out = []
|
|
1952
1952
|
data.each do |line|
|
|
1953
1953
|
next if grep&.none? { |pat| pat.match?(line) }
|
|
1954
|
-
next if block_given? && !(line = yield
|
|
1954
|
+
next if block_given? && !(line = yield(line, ret))
|
|
1955
1955
|
|
|
1956
1956
|
if loglevel
|
|
1957
1957
|
log&.add loglevel, line
|
|
@@ -1993,16 +1993,24 @@ module Squared
|
|
|
1993
1993
|
end
|
|
1994
1994
|
args = []
|
|
1995
1995
|
args << quote_option('sort', sort) if sort
|
|
1996
|
-
args <<
|
|
1996
|
+
args << basic_option('count', env('GIT_COUNT', ARG[:CHOICE])) if count
|
|
1997
1997
|
choice_index(msg, foreachref(type, *args, format: format), trim: trim, **kwargs)
|
|
1998
1998
|
end
|
|
1999
1999
|
|
|
2000
2000
|
def choice_commit(count: true, reflog: true, force: true, **kwargs)
|
|
2001
2001
|
kwargs[:attempts] ||= 1 unless force
|
|
2002
2002
|
cmd = git_output(reflog && env('GIT_REFLOG') ? 'reflog' : 'log')
|
|
2003
|
-
cmd << quote_option('format', '
|
|
2003
|
+
cmd << quote_option('format', "#{commitstyle('%h')} %s")
|
|
2004
2004
|
cmd << basic_option('max-count', env('GIT_COUNT', ARG[:CHOICE])) if count
|
|
2005
|
-
choice_index('Choose a commit', git_spawn(cmd, stdout: false), column:
|
|
2005
|
+
ret = choice_index('Choose a commit', git_spawn(cmd, stdout: false), column: /^(\S+)/, force: force, **kwargs)
|
|
2006
|
+
case ret
|
|
2007
|
+
when Array
|
|
2008
|
+
ret.map!(&:stripstyle)
|
|
2009
|
+
when String
|
|
2010
|
+
ret.stripstyle
|
|
2011
|
+
else
|
|
2012
|
+
ret
|
|
2013
|
+
end
|
|
2006
2014
|
end
|
|
2007
2015
|
|
|
2008
2016
|
def choice_remote(force: false, **kwargs)
|
|
@@ -2026,13 +2034,13 @@ module Squared
|
|
|
2026
2034
|
end
|
|
2027
2035
|
|
|
2028
2036
|
def status_data(*args)
|
|
2029
|
-
[]
|
|
2030
|
-
|
|
2031
|
-
|
|
2037
|
+
ret = []
|
|
2038
|
+
git_spawn('status -z -uall', *args).split("\x0").each do |line|
|
|
2039
|
+
next unless line =~ /^(.)(.) (.+)$/
|
|
2032
2040
|
|
|
2033
|
-
|
|
2034
|
-
end
|
|
2041
|
+
ret << [$3, $2, $1]
|
|
2035
2042
|
end
|
|
2043
|
+
ret
|
|
2036
2044
|
end
|
|
2037
2045
|
|
|
2038
2046
|
def append_pull(opts, list, flag:, from:, target: @session, no: nil, remote: nil)
|
|
@@ -2108,7 +2116,9 @@ module Squared
|
|
|
2108
2116
|
|
|
2109
2117
|
def append_message(val = nil, target: @session)
|
|
2110
2118
|
val = messageopt if val.to_s.empty?
|
|
2111
|
-
|
|
2119
|
+
return unless val
|
|
2120
|
+
|
|
2121
|
+
target << quote_option('message', val)
|
|
2112
2122
|
end
|
|
2113
2123
|
|
|
2114
2124
|
def append_head(val = nil, target: @session)
|
|
@@ -2205,6 +2215,10 @@ module Squared
|
|
|
2205
2215
|
s.start_with?(/\d/) ? "@~#{s}" : "@#{s}"
|
|
2206
2216
|
end
|
|
2207
2217
|
|
|
2218
|
+
def commitstyle(val)
|
|
2219
|
+
sub_style(val, theme[:extra] || color(:yellow))
|
|
2220
|
+
end
|
|
2221
|
+
|
|
2208
2222
|
def matchhead(val)
|
|
2209
2223
|
val =~ /^(?:(?:HEAD|@)([~^]\d*)?|H(\d+))$/ ? $2 || $1 || '' : nil
|
|
2210
2224
|
end
|
|
@@ -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?
|
|
@@ -710,7 +710,7 @@ module Squared
|
|
|
710
710
|
width = ->(a, i) { a.map { |aa| aa[i] }.max_by(&:size).size }
|
|
711
711
|
pad = ->(val, ord) { val.succ.to_s.rjust([ord.size.to_s.size, 2].max) }
|
|
712
712
|
footer = lambda do |val, size|
|
|
713
|
-
|
|
713
|
+
return unless verbose
|
|
714
714
|
|
|
715
715
|
msg, hint = if modified == -1
|
|
716
716
|
['Packages were updated', 'more possible']
|
|
@@ -814,6 +814,7 @@ module Squared
|
|
|
814
814
|
else
|
|
815
815
|
footer.call(0, found.size)
|
|
816
816
|
end
|
|
817
|
+
printsucc
|
|
817
818
|
commit(:add, [dependname], pass: true)
|
|
818
819
|
end
|
|
819
820
|
end
|
|
@@ -961,7 +962,7 @@ module Squared
|
|
|
961
962
|
case flag
|
|
962
963
|
when :install, :update
|
|
963
964
|
opts.unshift('package-lock=false', 'save=false') if nolockfile?('npm')
|
|
964
|
-
spec = 0
|
|
965
|
+
spec = flag == :install ? 0 : 2
|
|
965
966
|
when :add
|
|
966
967
|
spec = 1
|
|
967
968
|
flag = :install
|
|
@@ -1000,17 +1001,17 @@ module Squared
|
|
|
1000
1001
|
end
|
|
1001
1002
|
append_loglevel
|
|
1002
1003
|
case spec
|
|
1003
|
-
when
|
|
1004
|
+
when Numeric
|
|
1004
1005
|
op.each do |opt|
|
|
1005
1006
|
if opt =~ op.values
|
|
1006
1007
|
case $1
|
|
1007
1008
|
when 'w', 'workspace'
|
|
1008
1009
|
op << quotepath($1, $2)
|
|
1009
1010
|
end
|
|
1010
|
-
elsif opt.
|
|
1011
|
+
elsif opt.match?(/^-|=/)
|
|
1011
1012
|
op.errors << opt
|
|
1012
1013
|
else
|
|
1013
|
-
op.found << opt
|
|
1014
|
+
op.found << (spec == 2 && (n = opt.index('@')) ? opt[0, n] : opt)
|
|
1014
1015
|
end
|
|
1015
1016
|
end
|
|
1016
1017
|
op.swap
|
|
@@ -1112,7 +1113,7 @@ module Squared
|
|
|
1112
1113
|
print_run(cmd, banner, **kwargs)
|
|
1113
1114
|
session 'npx', cmd
|
|
1114
1115
|
start = time_epoch if kwargs.fetch(:verbose, verbose? && !stdin?)
|
|
1115
|
-
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|
|
|
1116
1117
|
next unless success?(ret, banner, start.nil?) && start
|
|
1117
1118
|
|
|
1118
1119
|
print_status(name, subject: 'tsc', start: start, from: :completed)
|
|
@@ -1326,7 +1327,7 @@ module Squared
|
|
|
1326
1327
|
|
|
1327
1328
|
def remove_modules(prefix = dependbin)
|
|
1328
1329
|
modules = basepath 'node_modules'
|
|
1329
|
-
return false unless modules.directory? && (option('
|
|
1330
|
+
return false unless modules.directory? && (option('y', prefix: prefix) || confirm_basic('Remove?', modules))
|
|
1330
1331
|
|
|
1331
1332
|
modules.rmtree
|
|
1332
1333
|
rescue Timeout::Error => e
|
|
@@ -1373,7 +1374,11 @@ module Squared
|
|
|
1373
1374
|
end
|
|
1374
1375
|
|
|
1375
1376
|
def append_platform(target: @session)
|
|
1376
|
-
%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
|
|
1377
1382
|
end
|
|
1378
1383
|
|
|
1379
1384
|
def quotepath(name, val)
|