squared 0.7.9 → 0.8.0
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 +44 -53
- data/README.md +38 -35
- data/lib/squared/common/base.rb +0 -1
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +25 -24
- data/lib/squared/common/shell.rb +11 -11
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +18 -22
- data/lib/squared/config.rb +3 -11
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -31
- data/lib/squared/workspace/project/base.rb +78 -81
- data/lib/squared/workspace/project/docker.rb +42 -41
- data/lib/squared/workspace/project/git.rb +164 -72
- data/lib/squared/workspace/project/node.rb +163 -121
- data/lib/squared/workspace/project/python.rb +26 -28
- data/lib/squared/workspace/project/ruby.rb +47 -41
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +7 -10
- data/lib/squared/workspace/project/support/utils.rb +15 -22
- data/lib/squared/workspace/repo.rb +7 -5
- data/lib/squared/workspace/series.rb +10 -2
- metadata +1 -1
|
@@ -56,15 +56,15 @@ module Squared
|
|
|
56
56
|
exec: %w[d|detach i|interactive privileged t|tty detach-keys=q e|env=qq env-file=p u|user=e
|
|
57
57
|
w|workdir=q].freeze,
|
|
58
58
|
commit: %w[no-pause a|author=q c|change=q m|message=q pause=b?].freeze,
|
|
59
|
-
inspect: %w[s|size f|format=q].freeze,
|
|
59
|
+
inspect: %w[s|size f|format=q type=b].freeze,
|
|
60
60
|
start: %w[a|attach i|interactive detach-keys=q].freeze,
|
|
61
61
|
stop: %w[s|signal=b t|timeout=i].freeze,
|
|
62
62
|
restart: %w[s|signal=b t|timeout=i].freeze,
|
|
63
63
|
kill: %w[s|signal=b].freeze,
|
|
64
|
-
stats: %w[a|all no-stream no-trunc format|q].freeze
|
|
64
|
+
stats: %w[a|all no-stream no-trunc format|q].freeze,
|
|
65
|
+
attach: %w[no-stdin detach-keys=q sig-proxy=!?].freeze
|
|
65
66
|
}.freeze,
|
|
66
67
|
image: {
|
|
67
|
-
inspect: %w[f|format platform=q].freeze,
|
|
68
68
|
ls: %w[a|all digests no-trunc q|quiet tree f|filter=q format=q].freeze,
|
|
69
69
|
pull: %w[a|all-tags platform=q q|quiet].freeze,
|
|
70
70
|
push: %w[a|all-tags platform=q q|quiet].freeze,
|
|
@@ -114,9 +114,9 @@ module Squared
|
|
|
114
114
|
'build' => %i[tag context].freeze,
|
|
115
115
|
'compose' => %i[build create publish run exec up down service].freeze,
|
|
116
116
|
'bake' => %i[build compose check].freeze,
|
|
117
|
-
'image' => %i[ls rm pull push tag save
|
|
118
|
-
'container' => %i[
|
|
119
|
-
|
|
117
|
+
'image' => %i[ls rm pull push tag save].freeze,
|
|
118
|
+
'container' => %i[attach commit create diff exec inspect kill pause restart rm run start stats stop top
|
|
119
|
+
unpause update].freeze,
|
|
120
120
|
'network' => %i[connect disconnect create].freeze,
|
|
121
121
|
'ls' => nil
|
|
122
122
|
})
|
|
@@ -166,7 +166,7 @@ module Squared
|
|
|
166
166
|
when 'compose'
|
|
167
167
|
'ps'
|
|
168
168
|
else
|
|
169
|
-
|
|
169
|
+
raise ArgumentError, message('unrecognized command', hint: command)
|
|
170
170
|
end
|
|
171
171
|
cmd << '-a' if has_value!(args, 'a', 'all') && command != 'network'
|
|
172
172
|
data = VAL_DOCKER[:ls][command.to_sym]
|
|
@@ -227,19 +227,20 @@ module Squared
|
|
|
227
227
|
format_desc action, flag, "service/:,command#{'?' unless flag == :exec}/::,args*,opts*"
|
|
228
228
|
task flag, [:service] do |_, args|
|
|
229
229
|
service = param_guard(action, flag, args: args, key: :service)
|
|
230
|
-
|
|
230
|
+
compose_(flag, args.extras, service: service)
|
|
231
231
|
end
|
|
232
232
|
when :service
|
|
233
233
|
cmds = %w[down kill pause restart rm start stop top unpause watch].freeze
|
|
234
234
|
format_desc(action, flag, cmds, arg: nil, after: 'name+|:')
|
|
235
235
|
task flag, [:command] do |_, args|
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
cmd = param_guard(action, flag, args: args, key: :command)
|
|
237
|
+
raise ArgumentError, message('unrecognized command', hint: cmd) unless cmds.include?(cmd)
|
|
238
|
+
|
|
238
239
|
service = args.extras
|
|
239
240
|
if service.first == ':'
|
|
240
|
-
choice_command flag,
|
|
241
|
+
choice_command flag, cmd
|
|
241
242
|
else
|
|
242
|
-
|
|
243
|
+
compose_(flag, [cmd], service: service.empty? || service)
|
|
243
244
|
end
|
|
244
245
|
end
|
|
245
246
|
when :publish
|
|
@@ -247,12 +248,12 @@ module Squared
|
|
|
247
248
|
|
|
248
249
|
format_desc action, flag, 'tag?,repository?,opts*'
|
|
249
250
|
task flag, [:tag] do |_, args|
|
|
250
|
-
|
|
251
|
+
compose_ flag, args.to_a
|
|
251
252
|
end
|
|
252
253
|
else
|
|
253
254
|
format_desc action, flag, 'opts*,service*|:'
|
|
254
255
|
task flag do |_, args|
|
|
255
|
-
|
|
256
|
+
compose_(flag, args.to_a, multiple: true)
|
|
256
257
|
end
|
|
257
258
|
end
|
|
258
259
|
when 'container'
|
|
@@ -277,7 +278,7 @@ module Squared
|
|
|
277
278
|
end
|
|
278
279
|
end
|
|
279
280
|
else
|
|
280
|
-
format_desc action, flag, "opts*,id/name#{flag == :update
|
|
281
|
+
format_desc action, flag, "opts*,id/name#{flag == :update ? '+' : '*'}"
|
|
281
282
|
task flag do |_, args|
|
|
282
283
|
container flag, args.to_a
|
|
283
284
|
end
|
|
@@ -288,7 +289,7 @@ module Squared
|
|
|
288
289
|
next unless @registry
|
|
289
290
|
|
|
290
291
|
format_desc action, flag, 'tag?,registry/username?,opts*'
|
|
291
|
-
task flag do |_, args|
|
|
292
|
+
task flag, [:tag] do |_, args|
|
|
292
293
|
image flag, args.to_a
|
|
293
294
|
end
|
|
294
295
|
when :pull
|
|
@@ -297,11 +298,6 @@ module Squared
|
|
|
297
298
|
id = param_guard(action, flag, args: args, key: :tag)
|
|
298
299
|
image(flag, args.extras, id: id)
|
|
299
300
|
end
|
|
300
|
-
when :inspect
|
|
301
|
-
format_desc action, flag, 'opts*,id+'
|
|
302
|
-
task flag do |_, args|
|
|
303
|
-
image flag, args.to_a
|
|
304
|
-
end
|
|
305
301
|
else
|
|
306
302
|
format_desc(action, flag, case flag
|
|
307
303
|
when :rm, :save then 'id,opts*'
|
|
@@ -440,7 +436,7 @@ module Squared
|
|
|
440
436
|
run(from: from || symjoin('buildx', flag))
|
|
441
437
|
end
|
|
442
438
|
|
|
443
|
-
def
|
|
439
|
+
def compose_(flag, opts = [], id: nil, service: nil, multiple: false)
|
|
444
440
|
from = symjoin 'compose', flag
|
|
445
441
|
if flag == :service
|
|
446
442
|
command = opts.first
|
|
@@ -477,14 +473,14 @@ module Squared
|
|
|
477
473
|
op.concat(service) if service
|
|
478
474
|
op.append(delim: true, escape: true, strip: /^:/)
|
|
479
475
|
else
|
|
480
|
-
|
|
476
|
+
raise ArgumentError, message('no service was selected', hint: flag) unless service
|
|
477
|
+
|
|
481
478
|
append_command(flag, service, op.extras, prompt: '::')
|
|
482
479
|
end
|
|
483
480
|
end
|
|
484
481
|
end
|
|
485
482
|
run(from: from)
|
|
486
483
|
end
|
|
487
|
-
alias compose_ compose!
|
|
488
484
|
|
|
489
485
|
def container(flag, opts = [], id: nil)
|
|
490
486
|
cmd, opts = docker_session('container', flag, opts: opts)
|
|
@@ -508,7 +504,7 @@ module Squared
|
|
|
508
504
|
when 'bind', 'volume', 'image', 'tmpfs'
|
|
509
505
|
type = v
|
|
510
506
|
else
|
|
511
|
-
|
|
507
|
+
raise TypeError, message('unknown', v || "''", hint: flag)
|
|
512
508
|
end
|
|
513
509
|
elsif all.include?(k)
|
|
514
510
|
unless type
|
|
@@ -524,7 +520,8 @@ module Squared
|
|
|
524
520
|
out << k
|
|
525
521
|
next
|
|
526
522
|
when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-path'
|
|
527
|
-
|
|
523
|
+
raise ArgumentError, message('no path value', k, hint: flag) unless v
|
|
524
|
+
|
|
528
525
|
v = basepath v
|
|
529
526
|
v = shell_quote(v, option: false, force: false) if q == ''
|
|
530
527
|
end
|
|
@@ -533,18 +530,20 @@ module Squared
|
|
|
533
530
|
log_message('unrecognized option', subject: from, hint: k)
|
|
534
531
|
end
|
|
535
532
|
end
|
|
536
|
-
|
|
533
|
+
raise TypeError, message('none specified', hint: flag) unless type
|
|
534
|
+
|
|
537
535
|
cmd << "--mount type=#{type},#{args.join(',')}"
|
|
538
536
|
end
|
|
539
537
|
end
|
|
540
538
|
append_command(flag, id || tagmain, op.extras)
|
|
541
539
|
when :update
|
|
542
|
-
|
|
540
|
+
raise ArgumentError, message('missing container', hint: flag) if op.empty?
|
|
541
|
+
|
|
543
542
|
op.append(escape: true, strip: /^:/)
|
|
544
543
|
when :commit
|
|
545
544
|
latest = op.shift || tagmain
|
|
546
545
|
cmd << id << latest
|
|
547
|
-
|
|
546
|
+
raise ArgumentError, message('unrecognized args', op.join(', '), hint: flag) unless op.empty?
|
|
548
547
|
return unless confirm_command(cmd.to_s, title: from, target: id, as: latest)
|
|
549
548
|
|
|
550
549
|
registry = option('registry') || @registry
|
|
@@ -565,7 +564,9 @@ module Squared
|
|
|
565
564
|
if op.empty?
|
|
566
565
|
ps, status, no = filter_ps flag, from
|
|
567
566
|
cmd << '--no-stream' if flag == :stats
|
|
568
|
-
list_image(flag, ps, no: no, hint: status,
|
|
567
|
+
list_image(flag, ps, no: no, hint: status, multiple: flag != :attach, from: from) do |img|
|
|
568
|
+
run(cmd.temp(img), from: from)
|
|
569
|
+
end
|
|
569
570
|
return
|
|
570
571
|
end
|
|
571
572
|
op.append(escape: true, strip: /^:/)
|
|
@@ -626,7 +627,7 @@ module Squared
|
|
|
626
627
|
break
|
|
627
628
|
end
|
|
628
629
|
end
|
|
629
|
-
|
|
630
|
+
raise ArgumentError, message('target not specified', hint: flag) unless found
|
|
630
631
|
when :pull
|
|
631
632
|
if !id
|
|
632
633
|
id = tagmain
|
|
@@ -642,7 +643,8 @@ module Squared
|
|
|
642
643
|
id ||= option('tag', ignore: false) || op.shift || tagmain
|
|
643
644
|
registry ||= option('registry') || op.shift || @registry
|
|
644
645
|
emptyargs op, flag
|
|
645
|
-
|
|
646
|
+
raise ArgumentError, message('username/registry not specified', hint: flag) unless registry
|
|
647
|
+
|
|
646
648
|
uri = shell_quote tagjoin(registry, id)
|
|
647
649
|
op << uri
|
|
648
650
|
img = docker_output 'image', 'tag', id, uri
|
|
@@ -652,9 +654,6 @@ module Squared
|
|
|
652
654
|
sync = false
|
|
653
655
|
exception ||= true
|
|
654
656
|
banner = false
|
|
655
|
-
when :inspect
|
|
656
|
-
raise_error ArgumentError, 'missing image', hint: flag if op.empty?
|
|
657
|
-
op.append(escape: true, strip: /^:/)
|
|
658
657
|
end
|
|
659
658
|
success?(run(sync: sync, exception: exception, banner: banner, from: from), flag == :tag || flag == :save)
|
|
660
659
|
end
|
|
@@ -748,7 +747,7 @@ module Squared
|
|
|
748
747
|
target << basic_option('name', dnsname("#{name}_%s" % rand_s(6)))
|
|
749
748
|
end
|
|
750
749
|
when :exec
|
|
751
|
-
|
|
750
|
+
raise ArgumentError, message('nothing to execute', hint: flag) if list.empty?
|
|
752
751
|
end
|
|
753
752
|
target << val << list.shift
|
|
754
753
|
target << list.join(' && ') unless list.empty?
|
|
@@ -802,7 +801,7 @@ module Squared
|
|
|
802
801
|
%w[running paused exited]
|
|
803
802
|
when :unpause
|
|
804
803
|
%w[paused]
|
|
805
|
-
when :top, :stats, :watch
|
|
804
|
+
when :top, :stats, :watch, :attach
|
|
806
805
|
%w[running]
|
|
807
806
|
when :kill
|
|
808
807
|
no = true
|
|
@@ -818,7 +817,8 @@ module Squared
|
|
|
818
817
|
[cmd, status, no]
|
|
819
818
|
end
|
|
820
819
|
|
|
821
|
-
def list_image(flag, cmd = docker_output('image ls -a'), filter: nil, hint: nil, no: true,
|
|
820
|
+
def list_image(flag, cmd = docker_output('image ls -a'), filter: nil, hint: nil, no: true, multiple: true,
|
|
821
|
+
from: nil)
|
|
822
822
|
pwd_set(from: from) do
|
|
823
823
|
index = 1
|
|
824
824
|
all = option('all', prefix: 'docker')
|
|
@@ -829,8 +829,8 @@ module Squared
|
|
|
829
829
|
elsif filter.match?(/[:_-]$/)
|
|
830
830
|
/\b#{Regexp.escape(filter)}/
|
|
831
831
|
else
|
|
832
|
-
filter = filter.empty? ? '(
|
|
833
|
-
/\b(
|
|
832
|
+
filter = filter.empty? ? '([:_-]|$)' : "[:_-]#{filter}"
|
|
833
|
+
/\b(#{dnsname(name)}|#{tagname(project)}|#{tagmain.split(':', 2).first})#{filter}/
|
|
834
834
|
end
|
|
835
835
|
IO.popen(cmd.temp('--format=json')).each do |line|
|
|
836
836
|
data = JSON.parse(line)
|
|
@@ -877,6 +877,7 @@ module Squared
|
|
|
877
877
|
puts if printfirst?
|
|
878
878
|
end
|
|
879
879
|
yield id
|
|
880
|
+
break unless multiple
|
|
880
881
|
end
|
|
881
882
|
list_empty(hint: hint || from) if index == 1 && !y
|
|
882
883
|
end
|
|
@@ -1010,7 +1011,7 @@ module Squared
|
|
|
1010
1011
|
end
|
|
1011
1012
|
|
|
1012
1013
|
def emptyargs(list, hint = nil)
|
|
1013
|
-
|
|
1014
|
+
raise ArgumentError, message('unrecognized args', list.join(', '), hint: hint) unless list.empty?
|
|
1014
1015
|
end
|
|
1015
1016
|
|
|
1016
1017
|
def anypath?(*args)
|