squared 0.4.14 → 0.4.16
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.ruby.md +4 -2
- data/lib/squared/common/prompt.rb +3 -3
- data/lib/squared/common/shell.rb +1 -2
- data/lib/squared/common/utils.rb +9 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +25 -19
- data/lib/squared/workspace/project/base.rb +173 -124
- data/lib/squared/workspace/project/docker.rb +21 -24
- data/lib/squared/workspace/project/git.rb +41 -41
- data/lib/squared/workspace/project/node.rb +67 -25
- data/lib/squared/workspace/project/python.rb +18 -11
- data/lib/squared/workspace/project/ruby.rb +95 -59
- data/lib/squared/workspace/project/support/class.rb +2 -4
- data/lib/squared/workspace/series.rb +8 -8
- data/lib/squared/workspace/support/base.rb +17 -0
- data/lib/squared/workspace/support.rb +1 -0
- data/squared.gemspec +2 -2
- metadata +3 -2
@@ -94,6 +94,7 @@ module Squared
|
|
94
94
|
subtasks({
|
95
95
|
'build' => %i[tag context bake].freeze,
|
96
96
|
'compose' => %i[build run exec up].freeze,
|
97
|
+
'bake' => %i[build check].freeze,
|
97
98
|
'image' => %i[list rm push tag save].freeze,
|
98
99
|
'container' => %i[run create exec update commit inspect diff start stop restart pause unpause top stats kill
|
99
100
|
rm].freeze,
|
@@ -128,12 +129,12 @@ module Squared
|
|
128
129
|
|
129
130
|
namespace name do
|
130
131
|
Docker.subtasks do |action, flags|
|
131
|
-
next if
|
132
|
+
next if task_pass?(action)
|
132
133
|
|
133
134
|
namespace action do
|
134
135
|
flags.each do |flag|
|
135
136
|
case action
|
136
|
-
when 'build'
|
137
|
+
when 'build', 'bake'
|
137
138
|
case flag
|
138
139
|
when :tag, :context
|
139
140
|
format_desc(action, flag, 'opts*', before: flag == :tag ? 'name' : 'dir')
|
@@ -141,16 +142,26 @@ module Squared
|
|
141
142
|
param = param_guard(action, flag, args: args, key: flag)
|
142
143
|
buildx(:build, args.extras, "#{flag}": param)
|
143
144
|
end
|
144
|
-
when :bake
|
145
|
+
when :bake, :build
|
146
|
+
next unless bake?
|
147
|
+
|
145
148
|
format_desc action, flag, ':?,opts*,target*,context?'
|
146
149
|
task flag do |_, args|
|
147
150
|
args = args.to_a
|
148
151
|
if args.first == ':'
|
149
152
|
choice_command :bake
|
150
153
|
else
|
151
|
-
buildx
|
154
|
+
buildx :bake, args
|
152
155
|
end
|
153
156
|
end
|
157
|
+
when :check
|
158
|
+
next unless bake?
|
159
|
+
|
160
|
+
format_desc action, flag, 'target'
|
161
|
+
task flag, [:target] do |_, args|
|
162
|
+
target = param_guard(action, flag, args: args, key: :target)
|
163
|
+
buildx :bake, ['allow=fs.read=*', 'call=check', target]
|
164
|
+
end
|
154
165
|
end
|
155
166
|
when 'compose'
|
156
167
|
case flag
|
@@ -265,7 +276,6 @@ module Squared
|
|
265
276
|
when Enumerable
|
266
277
|
ret.merge(opts.to_a)
|
267
278
|
end
|
268
|
-
|
269
279
|
[args, flags].each_with_index do |target, index|
|
270
280
|
if target.is_a?(String)
|
271
281
|
ret << target
|
@@ -308,7 +318,7 @@ module Squared
|
|
308
318
|
op.parse(OPT_DOCKER[:buildx][flag == :bake ? :bake : :build] + OPT_DOCKER[:buildx][:shared])
|
309
319
|
case flag
|
310
320
|
when :build, :context
|
311
|
-
append_tag(tag || option('tag', ignore: false) ||
|
321
|
+
append_tag(tag || option('tag', ignore: false) || self.tag)
|
312
322
|
append_context context
|
313
323
|
when :bake
|
314
324
|
unless op.empty?
|
@@ -318,7 +328,7 @@ module Squared
|
|
318
328
|
if projectpath?(val = args.pop)
|
319
329
|
context = val
|
320
330
|
else
|
321
|
-
op.
|
331
|
+
op.push(val)
|
322
332
|
end
|
323
333
|
end
|
324
334
|
op.append(args, escape: true)
|
@@ -574,12 +584,7 @@ module Squared
|
|
574
584
|
case flag
|
575
585
|
when :run
|
576
586
|
unless session_arg?('name', target: target)
|
577
|
-
target << basic_option('name', dnsname("#{name}_%s" %
|
578
|
-
require 'random/formatter'
|
579
|
-
Random.new.alphanumeric(6)
|
580
|
-
else
|
581
|
-
(0...6).map { rand(97..122).chr }.join
|
582
|
-
end))
|
587
|
+
target << basic_option('name', dnsname("#{name}_%s" % rand_s(6)))
|
583
588
|
end
|
584
589
|
when :exec
|
585
590
|
raise_error('no command args', hint: from) if list.empty?
|
@@ -680,11 +685,7 @@ module Squared
|
|
680
685
|
puts log_message(Logger::INFO, 'none detected', subject: "#{name}:#{from}", hint: hint) if found || y
|
681
686
|
end
|
682
687
|
rescue StandardError => e
|
683
|
-
|
684
|
-
ret = on(:error, from, e)
|
685
|
-
raise if exception && ret != true
|
686
|
-
|
687
|
-
warn log_message(Logger::WARN, e, pass: true) if warning?
|
688
|
+
on_error e, from
|
688
689
|
end
|
689
690
|
|
690
691
|
def confirm_command(*args, title: nil, target: nil, as: nil)
|
@@ -741,7 +742,7 @@ module Squared
|
|
741
742
|
cmd = docker_output ctx
|
742
743
|
case flag
|
743
744
|
when :tag
|
744
|
-
args = tagjoin @registry,
|
745
|
+
args = tagjoin @registry, tag
|
745
746
|
when :save
|
746
747
|
opts = "#{opts}.tar" unless opts.end_with?('.tar')
|
747
748
|
cmd << quote_option('output', File.expand_path(opts))
|
@@ -752,11 +753,7 @@ module Squared
|
|
752
753
|
else
|
753
754
|
cmd << opts << '--'
|
754
755
|
end
|
755
|
-
cmd.merge(
|
756
|
-
out.map! { |val| parse.call(val) }
|
757
|
-
else
|
758
|
-
[parse.call(out)]
|
759
|
-
end)
|
756
|
+
cmd.merge(Array(out).map! { |val| parse.call(val) })
|
760
757
|
cmd << args
|
761
758
|
print_success if success?(run(cmd)) && ctx.match?(/\A(?:network|tag|save)/)
|
762
759
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Squared
|
4
4
|
module Workspace
|
5
5
|
module Git
|
6
|
-
GIT_REPO =
|
6
|
+
GIT_REPO = Support.hashobj
|
7
7
|
GIT_PROTO = %r{^(?:https?|ssh|git|file)://}i.freeze
|
8
8
|
private_constant :GIT_REPO, :GIT_PROTO
|
9
9
|
|
@@ -58,8 +58,8 @@ module Squared
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
key = task_name key
|
61
|
-
|
62
|
-
|
61
|
+
GIT_REPO[main][key] = [uri.to_s, opts]
|
62
|
+
@kind[key] << Project::Git
|
63
63
|
end
|
64
64
|
if cache == true
|
65
65
|
revbuild
|
@@ -179,6 +179,9 @@ module Squared
|
|
179
179
|
}.freeze,
|
180
180
|
git: {
|
181
181
|
add: %w[N|intent-to-add refresh].freeze,
|
182
|
+
blame: %w[b c l s t w C=im? L=q M=im? S=p color-by-age color-lines first-parent incremental line-porcelain
|
183
|
+
p|porcelain root score-debug f|show-name e|show-email n|show-number show-stats abbrev=i
|
184
|
+
contents=p date=q encoding=b ignore-rev=b ignore-revs-file=p reverse=q].freeze,
|
182
185
|
clean: %w[d x X f|force n|dry-run i|interactive q|quiet e|exclude=q].freeze,
|
183
186
|
mv: %w[k f|force n|dry-run v|verbose].freeze,
|
184
187
|
revert: %w[e S=bm? abort continue n|no-commit quit reference skip cleanup=b gpg-sign=b? m|mainline=i
|
@@ -245,6 +248,7 @@ module Squared
|
|
245
248
|
tag: %w[n=im cleanup=b create-reflog i|ignore-case color=b? column=b contains=b? format=q merged=b?
|
246
249
|
no-contains=b? no-merged=b? points-at=q sort=q].freeze,
|
247
250
|
no: {
|
251
|
+
blame: %w[progress].freeze,
|
248
252
|
branch: %w[color color-moved column track].freeze,
|
249
253
|
checkout: %w[overwrite-ignore guess overlay progress recurse-submodules track].freeze,
|
250
254
|
fetch: {
|
@@ -330,7 +334,7 @@ module Squared
|
|
330
334
|
'diff' => %i[head branch files view between contain].freeze,
|
331
335
|
'fetch' => %i[origin remote].freeze,
|
332
336
|
'files' => %i[cached modified deleted others].freeze,
|
333
|
-
'git' => %i[add clean mv revert rm].freeze,
|
337
|
+
'git' => %i[add blame clean mv revert rm].freeze,
|
334
338
|
'log' => %i[view between contain].freeze,
|
335
339
|
'merge' => %i[commit no-commit send].freeze,
|
336
340
|
'pull' => %i[origin remote].freeze,
|
@@ -360,7 +364,7 @@ module Squared
|
|
360
364
|
|
361
365
|
namespace name do
|
362
366
|
Git.subtasks do |action, flags|
|
363
|
-
next if
|
367
|
+
next if task_pass?(action)
|
364
368
|
|
365
369
|
namespace action do
|
366
370
|
flags.each do |flag|
|
@@ -396,12 +400,12 @@ module Squared
|
|
396
400
|
if flag == :fixup
|
397
401
|
ref, squash, pick = choice_commit(accept: [['Auto squash?', true]], reflog: false,
|
398
402
|
values: ['Pick [amend|reword]'])
|
399
|
-
pick
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
403
|
+
pick &&= case pick.downcase
|
404
|
+
when 'a', 'amend'
|
405
|
+
'amend'
|
406
|
+
when 'r', 'reword'
|
407
|
+
'reword'
|
408
|
+
end
|
405
409
|
if squash
|
406
410
|
found = false
|
407
411
|
git_spawn(git_output('log --format=%h'), stdout: false).each do |val|
|
@@ -413,12 +417,14 @@ module Squared
|
|
413
417
|
end
|
414
418
|
end
|
415
419
|
end
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
420
|
+
opts = []
|
421
|
+
refs = []
|
422
|
+
unless pick == 'reword'
|
423
|
+
if flag == :add
|
424
|
+
opts = param_guard(action, flag, args: args.to_a)
|
425
|
+
elsif (refs = args.to_a).empty?
|
426
|
+
refs = readline('Enter file patterns', force: true).shellsplit
|
427
|
+
end
|
422
428
|
end
|
423
429
|
commit(flag, opts, refs: refs, ref: ref, squash: squash, pick: pick)
|
424
430
|
end
|
@@ -857,19 +863,14 @@ module Squared
|
|
857
863
|
args = args.to_a
|
858
864
|
if args.empty? || args.last == ':'
|
859
865
|
files = []
|
860
|
-
status_data.each
|
861
|
-
case (flag == :staged ? line[2] : line[1])
|
862
|
-
when /[AMDRTC]/
|
863
|
-
files << line[0]
|
864
|
-
end
|
865
|
-
end
|
866
|
+
status_data.each { |row| files << row[0] if row[flag == :staged ? 2 : 1].match?(/[AMDRTC]/) }
|
866
867
|
unless files.empty?
|
867
868
|
files = choice_index('Select a file', files, multiple: true, force: false,
|
868
869
|
accept: 'Restore?')
|
869
870
|
end
|
870
871
|
args.pop
|
871
872
|
args, glob = args.partition { |val| val.match?(/^(?:[a-z-]+=|[^*]+$)/) }
|
872
|
-
|
873
|
+
files.concat(glob)
|
873
874
|
next if args.empty? && files.empty?
|
874
875
|
end
|
875
876
|
restore(flag, args, files: files)
|
@@ -877,10 +878,11 @@ module Squared
|
|
877
878
|
end
|
878
879
|
when 'git'
|
879
880
|
before = case flag
|
881
|
+
when :blame then 'file'
|
880
882
|
when :mv then 'source+,destination'
|
881
883
|
when :revert then 'commit+' end
|
882
884
|
format_desc(action, flag, 'opts*', before: before, after: case flag
|
883
|
-
when :add then 'pathspec
|
885
|
+
when :add then 'pathspec*,:pattern:*'
|
884
886
|
when :clean, :rm then 'pathspec*' end)
|
885
887
|
task flag do |_, args|
|
886
888
|
git flag, args.to_a
|
@@ -1140,10 +1142,7 @@ module Squared
|
|
1140
1142
|
rescue StandardError => e
|
1141
1143
|
warn log_message(Logger::WARN, e, pass: true) if warning?
|
1142
1144
|
else
|
1143
|
-
|
1144
|
-
msg = sub_style('completed', styles: theme[:active])
|
1145
|
-
puts log_message(Logger::INFO, name, msg, subject: 'revbuild', hint: time_format(epochtime - start))
|
1146
|
-
end
|
1145
|
+
print_status(name, subject: 'revbuild', start: start, from: :completed)
|
1147
1146
|
workspace.rev_write(name, { 'revision' => sha, 'files' => status_digest(*args, **kwargs) },
|
1148
1147
|
sync: sync, utc: 'build')
|
1149
1148
|
end
|
@@ -1621,10 +1620,16 @@ module Squared
|
|
1621
1620
|
|
1622
1621
|
def git(flag, opts = [])
|
1623
1622
|
cmd, opts = git_session(flag, opts: opts)
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1623
|
+
op = OptionPartition.new(opts, OPT_GIT[:git].fetch(flag, []) + OPT_GIT.fetch(flag, []), cmd,
|
1624
|
+
project: self, no: OPT_GIT[:no][flag], first: case flag
|
1625
|
+
when :blame, :revert
|
1626
|
+
nil
|
1627
|
+
else matchpathspec end)
|
1627
1628
|
case flag
|
1629
|
+
when :blame
|
1630
|
+
raise_error 'no file found' unless (n = op.index { |s| (path + s).file? })
|
1631
|
+
op << '--' << shell_quote(path + op.delete_at(n))
|
1632
|
+
op.clear
|
1628
1633
|
when :revert
|
1629
1634
|
if VAL_GIT[:rebase][:send].any? { |val| op.arg?(val) }
|
1630
1635
|
op.clear
|
@@ -1635,14 +1640,13 @@ module Squared
|
|
1635
1640
|
end
|
1636
1641
|
when :add, :clean
|
1637
1642
|
if flag == :add && !op.arg?('pathspec-from-file')
|
1638
|
-
grep, list = op.
|
1639
|
-
|
1640
|
-
red = color(:red)
|
1643
|
+
grep, list = op.partition { |val| val.start_with?(':') && val.end_with?(':') }
|
1644
|
+
unless grep.empty? && !list.empty?
|
1641
1645
|
grep.map! { |val| Regexp.new(val[1..-2]) }
|
1642
1646
|
files = status_data.map! do |a, b|
|
1643
1647
|
next if b.strip.empty? || (!grep.empty? && grep.none? { |pat| pat.match?(a) })
|
1644
1648
|
|
1645
|
-
"#{sub_style(b, styles: red)} #{a}"
|
1649
|
+
"#{sub_style(b, styles: color(:red))} #{a}"
|
1646
1650
|
end
|
1647
1651
|
.compact
|
1648
1652
|
unless files.empty?
|
@@ -1739,11 +1743,7 @@ module Squared
|
|
1739
1743
|
end
|
1740
1744
|
end
|
1741
1745
|
rescue StandardError => e
|
1742
|
-
|
1743
|
-
ret = on(:error, from, e)
|
1744
|
-
raise if exception && ret != true
|
1745
|
-
|
1746
|
-
warn log_message(Logger::WARN, e, pass: true) if warning?
|
1746
|
+
on_error(e, from, pass: true)
|
1747
1747
|
nil
|
1748
1748
|
else
|
1749
1749
|
on :last, from
|
@@ -120,7 +120,7 @@ module Squared
|
|
120
120
|
|
121
121
|
namespace name do
|
122
122
|
Node.subtasks do |action, flags|
|
123
|
-
next if
|
123
|
+
next if task_pass?(action)
|
124
124
|
|
125
125
|
if flags.nil?
|
126
126
|
case action
|
@@ -257,6 +257,11 @@ module Squared
|
|
257
257
|
otp = args.first
|
258
258
|
else
|
259
259
|
tag, otp = param_guard(action, flag, args: args)
|
260
|
+
unless SEM_VER.match?(tag)
|
261
|
+
a = sub_style(project, styles: theme[:active])
|
262
|
+
b = sub_style(tag, styles: theme[:inline])
|
263
|
+
exit 1 unless confirm("Publish #{a}@#{b}? [y/N] ", 'N')
|
264
|
+
end
|
260
265
|
end
|
261
266
|
publish(flag, otp: otp, tag: tag, dryrun: dryrun, access: access)
|
262
267
|
end
|
@@ -268,7 +273,7 @@ module Squared
|
|
268
273
|
end
|
269
274
|
end
|
270
275
|
|
271
|
-
def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, workspace: false,
|
276
|
+
def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, files: nil, workspace: false,
|
272
277
|
link: false, force: false, override: false, sync: invoked_sync?('copy'), **kwargs)
|
273
278
|
glob = kwargs[:include]
|
274
279
|
pass = kwargs[:exclude]
|
@@ -277,6 +282,7 @@ module Squared
|
|
277
282
|
|
278
283
|
from = @copy[:from] if @copy.key?(:from)
|
279
284
|
into = @copy[:into] if @copy.key?(:into)
|
285
|
+
files = @copy[:files] if @copy.key?(:files)
|
280
286
|
workspace = @copy[:workspace] if @copy.key?(:workspace)
|
281
287
|
link = @copy[:link] if @copy.key?(:link)
|
282
288
|
force = @copy[:force] if @copy.key?(:force)
|
@@ -298,6 +304,7 @@ module Squared
|
|
298
304
|
|
299
305
|
on :first, :copy
|
300
306
|
print_item unless @output[0] || !verbose || task_invoked?(/^copy(?::#{Node.ref}|$)/)
|
307
|
+
packed = false
|
301
308
|
items.each do |dir|
|
302
309
|
case dir
|
303
310
|
when Pathname
|
@@ -335,9 +342,49 @@ module Squared
|
|
335
342
|
end
|
336
343
|
next unless from && dest&.directory?
|
337
344
|
|
338
|
-
from
|
345
|
+
if from == :npm
|
346
|
+
begin
|
347
|
+
unless packed
|
348
|
+
require 'open3'
|
349
|
+
files = pwd_set do
|
350
|
+
Open3.capture2e(session_output('npm', 'pack --dry-run --no-color', npmname).to_s)
|
351
|
+
.first
|
352
|
+
.scan(/^npm notice \d+(?:\.\d+)?[a-z]+ (.+)$/i)
|
353
|
+
.map { |item| Pathname.new(item.first) }
|
354
|
+
.select(&:exist?)
|
355
|
+
end
|
356
|
+
.concat(Array(files))
|
357
|
+
packed = true
|
358
|
+
end
|
359
|
+
to = dest.join(into, npmname)
|
360
|
+
to.mkpath
|
361
|
+
log.info "cp npm:#{npmname} #{to}"
|
362
|
+
subdir = []
|
363
|
+
errors = 0
|
364
|
+
files.each do |file|
|
365
|
+
s, d = file.is_a?(Array) ? file : [file, file]
|
366
|
+
dest = to + d
|
367
|
+
unless subdir.include?((target = dest.dirname).to_s)
|
368
|
+
target.mkpath
|
369
|
+
subdir << target.to_s
|
370
|
+
end
|
371
|
+
begin
|
372
|
+
FileUtils.cp(path + s, dest, verbose: verbose.is_a?(Numeric) && verbose > 0)
|
373
|
+
rescue StandardError => e
|
374
|
+
print_error e
|
375
|
+
errors += 1
|
376
|
+
end
|
377
|
+
end
|
378
|
+
rescue StandardError => e
|
379
|
+
on_error e, :copy
|
380
|
+
else
|
381
|
+
puts message(to, subdir.size, files.size - errors) if verbose
|
382
|
+
end
|
383
|
+
next
|
384
|
+
end
|
339
385
|
glob = Array(glob || '**/*')
|
340
386
|
target = []
|
387
|
+
from = path + from
|
341
388
|
if workspace
|
342
389
|
Dir.glob(from + '*').each do |path|
|
343
390
|
next unless (path = Pathname.new(path)).directory?
|
@@ -361,16 +408,14 @@ module Squared
|
|
361
408
|
end
|
362
409
|
end
|
363
410
|
else
|
364
|
-
target << [from, dest.join(into, scope ||
|
411
|
+
target << [from, dest.join(into, scope || npmname)]
|
365
412
|
end
|
366
413
|
target.each do |src, to|
|
367
414
|
glob.each { |val| log.info "cp #{from + val} #{to}" }
|
368
415
|
begin
|
369
416
|
copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbose)
|
370
417
|
rescue StandardError => e
|
371
|
-
|
372
|
-
ret = on(:error, :copy, e)
|
373
|
-
raise if exception && ret != true
|
418
|
+
on_error e, :copy
|
374
419
|
end
|
375
420
|
end
|
376
421
|
end
|
@@ -436,19 +481,14 @@ module Squared
|
|
436
481
|
log.info cmd.to_s
|
437
482
|
on :first, :outdated
|
438
483
|
end
|
439
|
-
banner = format_banner(cmd.temp(dryrun ? '
|
484
|
+
banner = format_banner(cmd.temp(dryrun ? '--dry-run' : nil))
|
440
485
|
print_item banner if sync
|
441
486
|
begin
|
442
487
|
data = pwd_set { `#{cmd.temp('--json', '--loglevel=error')}` }
|
443
488
|
doc = dependfile.read
|
444
489
|
json = JSON.parse(doc)
|
445
490
|
rescue StandardError => e
|
446
|
-
|
447
|
-
unless dryrun
|
448
|
-
ret = on(:error, :outdated, e)
|
449
|
-
raise if exception && ret != true
|
450
|
-
end
|
451
|
-
warn log_message(Logger::WARN, e) if warning?
|
491
|
+
on_error(e, :outdated, dryrun: dryrun)
|
452
492
|
return
|
453
493
|
else
|
454
494
|
dep1 = json['dependencies'] || {}
|
@@ -599,16 +639,16 @@ module Squared
|
|
599
639
|
package('update', from: :update)
|
600
640
|
end
|
601
641
|
|
602
|
-
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil,
|
642
|
+
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil)
|
603
643
|
if !version || read_packagemanager(:private)
|
604
644
|
warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: version ? 'private' : nil)
|
605
645
|
return
|
606
646
|
end
|
607
647
|
cmd = session 'npm', 'publish'
|
608
|
-
cmd << basic_option('otp', otp) if otp
|
609
|
-
cmd << basic_option('tag', tag) if tag
|
610
|
-
cmd << basic_option('access', access) if access
|
611
|
-
dryrun
|
648
|
+
cmd << basic_option('otp', otp) if otp &&= option('otp')
|
649
|
+
cmd << basic_option('tag', tag) if tag &&= option('tag')
|
650
|
+
cmd << basic_option('access', access) if access &&= option('access')
|
651
|
+
dryrun &&= dryrun?('npm')
|
612
652
|
if dryrun
|
613
653
|
cmd << '--dry-run'
|
614
654
|
else
|
@@ -616,7 +656,7 @@ module Squared
|
|
616
656
|
log.info cmd.to_s
|
617
657
|
end
|
618
658
|
if sync
|
619
|
-
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(
|
659
|
+
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
|
620
660
|
else
|
621
661
|
on :first, from
|
622
662
|
pwd_set(from: :publish, dryrun: dryrun) do
|
@@ -735,9 +775,7 @@ module Squared
|
|
735
775
|
raise_error('version not found', hint: dependfile)
|
736
776
|
end
|
737
777
|
rescue StandardError => e
|
738
|
-
|
739
|
-
ret = on(:error, :bump, e)
|
740
|
-
raise if exception && ret != true
|
778
|
+
on_error e, :bump
|
741
779
|
end
|
742
780
|
end
|
743
781
|
|
@@ -876,7 +914,7 @@ module Squared
|
|
876
914
|
end
|
877
915
|
|
878
916
|
def version
|
879
|
-
|
917
|
+
@version ||= read_packagemanager(:version)
|
880
918
|
end
|
881
919
|
|
882
920
|
def packagename
|
@@ -902,7 +940,7 @@ module Squared
|
|
902
940
|
else
|
903
941
|
if key
|
904
942
|
@pm[key]
|
905
|
-
elsif (ret = @pm[:_]) && !(version && ret[(ret.index('@') + 1)..-1]
|
943
|
+
elsif (ret = @pm[:_]) && !(version && semcmp(ret[(ret.index('@') + 1)..-1], version) == 1)
|
906
944
|
ret
|
907
945
|
end
|
908
946
|
end
|
@@ -967,6 +1005,10 @@ module Squared
|
|
967
1005
|
'package.json' if parent&.has?('outdated', Node.ref)
|
968
1006
|
end
|
969
1007
|
|
1008
|
+
def npmname
|
1009
|
+
packagename || project
|
1010
|
+
end
|
1011
|
+
|
970
1012
|
def npmnotice
|
971
1013
|
[
|
972
1014
|
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:cyan), index: 2 },
|
@@ -114,7 +114,7 @@ module Squared
|
|
114
114
|
|
115
115
|
namespace name do
|
116
116
|
Python.subtasks do |action, flags|
|
117
|
-
next if
|
117
|
+
next if task_pass?(action)
|
118
118
|
|
119
119
|
if flags.nil?
|
120
120
|
case action
|
@@ -183,7 +183,7 @@ module Squared
|
|
183
183
|
elsif i || args.empty?
|
184
184
|
readline('Enter command', force: true)
|
185
185
|
else
|
186
|
-
if (val = command_args(args, prefix: 'python'))
|
186
|
+
if (val = command_args(args, min: 1, prefix: 'python'))
|
187
187
|
args << val
|
188
188
|
end
|
189
189
|
args.join(' ')
|
@@ -280,7 +280,7 @@ module Squared
|
|
280
280
|
end
|
281
281
|
end
|
282
282
|
when 'outdated'
|
283
|
-
format_desc action, flag, 'eager?'
|
283
|
+
format_desc action, flag, 'eager?,user?'
|
284
284
|
task flag do |_, args|
|
285
285
|
outdated flag, args.to_a
|
286
286
|
end
|
@@ -366,7 +366,11 @@ module Squared
|
|
366
366
|
pwd_set(from: :outdated) do
|
367
367
|
buffer = []
|
368
368
|
out = ->(val) { sync ? puts(val) : buffer << val }
|
369
|
-
|
369
|
+
if workspace.windows?
|
370
|
+
(venv ? command(runenv, cmd) : `#{cmd}`).lines
|
371
|
+
else
|
372
|
+
IO.popen(runenv || {}, cmd)
|
373
|
+
end.each do |line|
|
370
374
|
next if line.match?(/^[ -]+$/)
|
371
375
|
|
372
376
|
if start > 0
|
@@ -431,7 +435,9 @@ module Squared
|
|
431
435
|
when :patch
|
432
436
|
patch
|
433
437
|
end
|
434
|
-
|
438
|
+
unless !pkg || pkg.empty?
|
439
|
+
install(:upgrade, pkg, strategy: opts.include?('eager') ? 'eager' : nil, user: opts.include?('user'))
|
440
|
+
end
|
435
441
|
elsif start == 0
|
436
442
|
puts 'No updates were found'
|
437
443
|
end
|
@@ -439,7 +445,7 @@ module Squared
|
|
439
445
|
on :last, :outdated
|
440
446
|
end
|
441
447
|
|
442
|
-
def install(flag, opts = [], strategy: nil)
|
448
|
+
def install(flag, opts = [], strategy: nil, user: nil)
|
443
449
|
cmd = pip_session 'install'
|
444
450
|
out = append_pip(flag, opts, from: :install)
|
445
451
|
case flag
|
@@ -449,6 +455,7 @@ module Squared
|
|
449
455
|
when :upgrade
|
450
456
|
raise_error('no packages listed', hint: flag) if out.empty?
|
451
457
|
cmd << '--upgrade'
|
458
|
+
cmd << '--user' if user
|
452
459
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
453
460
|
append_value out
|
454
461
|
end
|
@@ -485,7 +492,7 @@ module Squared
|
|
485
492
|
if srcdir
|
486
493
|
args = flag == :pdm ? ['d', 'dest'] : ['o', 'output']
|
487
494
|
if op.arg?(*args)
|
488
|
-
op.
|
495
|
+
op.push(srcdir)
|
489
496
|
else
|
490
497
|
op << quote_option(args.last, path + srcdir)
|
491
498
|
end
|
@@ -528,7 +535,7 @@ module Squared
|
|
528
535
|
case flag
|
529
536
|
when :hatch, :twine
|
530
537
|
if op.empty?
|
531
|
-
op.
|
538
|
+
op.push("#{dist.call}/*")
|
532
539
|
else
|
533
540
|
op.map! { |val| path + val }
|
534
541
|
end
|
@@ -648,7 +655,7 @@ module Squared
|
|
648
655
|
if edit
|
649
656
|
edit = path + edit unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
650
657
|
if flag == :editable
|
651
|
-
op.
|
658
|
+
op.push(edit)
|
652
659
|
else
|
653
660
|
target << quote_option('e', edit)
|
654
661
|
end
|
@@ -844,8 +851,8 @@ module Squared
|
|
844
851
|
return if !venv || (venvbin.directory? && !venvbin.empty?)
|
845
852
|
|
846
853
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'init')
|
847
|
-
|
848
|
-
venv_create(venv,
|
854
|
+
opts = @venvopts&.map { |val| OptionPartition.strip(val) }&.flatten
|
855
|
+
venv_create(venv, opts || ["prompt=#{name}", 'upgrade-deps'], env: false, banner: false)
|
849
856
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'created')
|
850
857
|
end
|
851
858
|
|