squared 0.4.14 → 0.5.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 +14 -58
- data/README.md +4 -4
- data/README.ruby.md +15 -12
- data/lib/squared/common/base.rb +7 -8
- data/lib/squared/common/format.rb +3 -9
- data/lib/squared/common/prompt.rb +36 -40
- data/lib/squared/common/shell.rb +13 -8
- data/lib/squared/common/system.rb +45 -48
- data/lib/squared/common/utils.rb +3 -19
- data/lib/squared/common.rb +2 -1
- data/lib/squared/config.rb +16 -16
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +27 -40
- data/lib/squared/workspace/project/base.rb +128 -196
- data/lib/squared/workspace/project/docker.rb +37 -38
- data/lib/squared/workspace/project/git.rb +113 -139
- data/lib/squared/workspace/project/node.rb +64 -49
- data/lib/squared/workspace/project/python.rb +57 -251
- data/lib/squared/workspace/project/ruby.rb +119 -139
- data/lib/squared/workspace/project/support/class.rb +73 -34
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +6 -7
- data/lib/squared/workspace/series.rb +8 -8
- data/lib/squared/workspace/support/data.rb +3 -2
- data/lib/squared/workspace.rb +1 -1
- data/squared.gemspec +1 -1
- metadata +2 -3
- data/lib/squared/common/class.rb +0 -110
@@ -21,8 +21,7 @@ module Squared
|
|
21
21
|
compose: {
|
22
22
|
common: %w[all-resources compatibility dry-run ansi|b env-file=p f|file=p parallel=b profile=b progress=b
|
23
23
|
project-directory=p p|project-name=e].freeze,
|
24
|
-
build: %w[
|
25
|
-
ssh=qq].freeze,
|
24
|
+
build: %w[no-cache pull push with-dependencies q|quiet build-arg=qq builder=b m|memory=b ssh=qq].freeze,
|
26
25
|
exec: %w[dry-run privileged d|detach e|env=qq index=i T|no-TTY=b? user=e w|workdir=q].freeze,
|
27
26
|
run: %w[build dry-run no-deps quiet-pull remove-orphans rm P|service-ports use-aliases cap-add=b cap-drop=b
|
28
27
|
d|detach entrypoint=q e|env=qq i|interactive=b? l|label=q name=b T|no-TTY=b? p|publish=e pull=b
|
@@ -112,6 +111,7 @@ module Squared
|
|
112
111
|
@mounts = mounts
|
113
112
|
@secrets = secrets
|
114
113
|
@registry = tagjoin registry, kwargs[:username]
|
114
|
+
@file = nil
|
115
115
|
initialize_ref Docker.ref
|
116
116
|
initialize_logger(**kwargs)
|
117
117
|
initialize_env(**kwargs)
|
@@ -160,7 +160,7 @@ module Squared
|
|
160
160
|
compose! flag, args.to_a
|
161
161
|
end
|
162
162
|
when :exec, :run
|
163
|
-
format_desc action, flag, "service,command#{flag == :exec ? '' : '?'}
|
163
|
+
format_desc action, flag, "service,command#{flag == :exec ? '' : '?'},args*,opts*"
|
164
164
|
task flag, [:service] do |_, args|
|
165
165
|
service = param_guard(action, flag, args: args, key: :service)
|
166
166
|
compose!(flag, args.extras, service: service)
|
@@ -198,8 +198,8 @@ module Squared
|
|
198
198
|
when :push
|
199
199
|
format_desc action, flag, 'tag,registry/username?,opts*'
|
200
200
|
task flag, [:tag] do |_, args|
|
201
|
-
|
202
|
-
image(flag, args.extras, id:
|
201
|
+
id = param_guard(action, flag, args: args, key: :tag)
|
202
|
+
image(flag, args.extras, id: id)
|
203
203
|
end
|
204
204
|
else
|
205
205
|
format_desc(action, flag, case flag
|
@@ -267,10 +267,8 @@ module Squared
|
|
267
267
|
end
|
268
268
|
|
269
269
|
[args, flags].each_with_index do |target, index|
|
270
|
-
if target
|
271
|
-
ret
|
272
|
-
elsif (target = append_any(target, target: []))
|
273
|
-
ret.merge(target.map { |arg| index == 0 ? fill_option(arg) : quote_option('build-arg', arg) })
|
270
|
+
if (data = append_any(target, target: []))
|
271
|
+
ret.merge(data.map { |arg| index == 0 ? fill_option(arg) : quote_option('build-arg', arg) })
|
274
272
|
end
|
275
273
|
end
|
276
274
|
case from
|
@@ -280,12 +278,12 @@ module Squared
|
|
280
278
|
ret << quote_option('secret', @secrets, double: true)
|
281
279
|
when Hash
|
282
280
|
append = lambda do |type|
|
283
|
-
|
281
|
+
as_a(@secrets[type]).each { |arg| ret << quote_option('secret', "type=#{type},#{arg}", double: true) }
|
284
282
|
end
|
285
283
|
append.call(:file)
|
286
284
|
append.call(:env)
|
287
285
|
else
|
288
|
-
|
286
|
+
as_a(@secrets).each { |arg| ret << quote_option('secret', arg) }
|
289
287
|
end
|
290
288
|
if (val = option('tag', ignore: false))
|
291
289
|
append_tag val
|
@@ -294,8 +292,8 @@ module Squared
|
|
294
292
|
end
|
295
293
|
append_context
|
296
294
|
when :bake, :compose
|
297
|
-
|
298
|
-
ret.merge(split_escape(
|
295
|
+
option(from == :bake ? 'target' : 'service', ignore: false) do |a|
|
296
|
+
ret.merge(split_escape(a).map! { |b| shell_escape(b) })
|
299
297
|
end
|
300
298
|
end
|
301
299
|
ret
|
@@ -313,7 +311,7 @@ module Squared
|
|
313
311
|
when :bake
|
314
312
|
unless op.empty?
|
315
313
|
args = op.dup
|
316
|
-
op.
|
314
|
+
op.extras.clear
|
317
315
|
if Dir.exist?(args.last)
|
318
316
|
if projectpath?(val = args.pop)
|
319
317
|
context = val
|
@@ -360,11 +358,11 @@ module Squared
|
|
360
358
|
both = run[:bind] + run[:tmpfs]
|
361
359
|
diff = run[:bind].reject { |val| run[:tmpfs].include?(val) }
|
362
360
|
delim = Regexp.new(",\\s*(?=#{both.join('|')})")
|
363
|
-
|
361
|
+
as_a(@mounts).each do |val|
|
364
362
|
args = []
|
365
363
|
tmpfs = true
|
366
364
|
val.split(delim).each do |opt|
|
367
|
-
k, v, q = split_option
|
365
|
+
k, v, q = split_option opt
|
368
366
|
next unless both.include?(k)
|
369
367
|
|
370
368
|
if k == 'type'
|
@@ -504,7 +502,7 @@ module Squared
|
|
504
502
|
raise_error(id ? "unknown args: #{op.join(', ')}" : 'no id/tag given', hint: from) unless id && op.empty?
|
505
503
|
raise_error('username/registry not provided', hint: from) unless registry
|
506
504
|
registry.chomp!('/')
|
507
|
-
uri = shell_quote
|
505
|
+
uri = shell_quote "#{registry}/#{id}"
|
508
506
|
op << uri
|
509
507
|
img = docker_output 'image', 'tag', id, uri
|
510
508
|
return unless confirm_command(img.to_s, cmd.to_s, target: id, as: registry, title: from)
|
@@ -566,9 +564,7 @@ module Squared
|
|
566
564
|
end
|
567
565
|
|
568
566
|
def append_command(flag, val, list, target: @session, from: nil)
|
569
|
-
if
|
570
|
-
list << readline('Enter command [args]', force: true)
|
571
|
-
elsif (args = env('DOCKER_ARGS'))
|
567
|
+
if (args = env('DOCKER_ARGS'))
|
572
568
|
list << args
|
573
569
|
end
|
574
570
|
case flag
|
@@ -591,7 +587,7 @@ module Squared
|
|
591
587
|
def append_file(type, target: @session)
|
592
588
|
return unless type == 2 || type == 4 || @file.is_a?(Array)
|
593
589
|
|
594
|
-
files =
|
590
|
+
files = as_a(@file).map { |val| quote_option('file', path + val) }
|
595
591
|
if target.is_a?(Set)
|
596
592
|
target.merge(files)
|
597
593
|
else
|
@@ -607,18 +603,20 @@ module Squared
|
|
607
603
|
end
|
608
604
|
|
609
605
|
def append_tag(val, target: @session)
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
606
|
+
case val
|
607
|
+
when String
|
608
|
+
val.split(',')
|
609
|
+
when Array
|
610
|
+
val
|
611
|
+
else
|
612
|
+
[]
|
613
|
+
end.yield_self do |list|
|
614
|
+
ver = option('version', target: target, ignore: false)
|
615
|
+
list.each do |s|
|
616
|
+
s = "#{s}:#{ver}" if ver && (!s.include?(':') || s.delete_suffix!(':latest'))
|
617
|
+
target << basic_option('tag', tagname(s))
|
618
|
+
end
|
619
|
+
target
|
622
620
|
end
|
623
621
|
end
|
624
622
|
|
@@ -665,7 +663,7 @@ module Squared
|
|
665
663
|
cols.each do |key|
|
666
664
|
next if (key == 'Tag' && !dd) || (key == 'Size' && data[key] == '0B')
|
667
665
|
|
668
|
-
puts "#{g + f} #{key}: #{
|
666
|
+
puts "#{g + f} #{key}: #{as_a(data[key]).join(', ')}" unless data[key].to_s.empty?
|
669
667
|
end
|
670
668
|
w = 9 + flag.to_s.size + 4 + ee.size
|
671
669
|
puts g + sub_style(ARG[:BORDER][6] + (ARG[:BORDER][1] * w), styles: theme[:inline])
|
@@ -758,7 +756,7 @@ module Squared
|
|
758
756
|
[parse.call(out)]
|
759
757
|
end)
|
760
758
|
cmd << args
|
761
|
-
print_success if success?(run(cmd)) && ctx.
|
759
|
+
print_success if success?(run(cmd)) && ctx.start_with?(/(?:network|tag|save)/)
|
762
760
|
end
|
763
761
|
end
|
764
762
|
|
@@ -788,9 +786,10 @@ module Squared
|
|
788
786
|
|
789
787
|
def tagname(val)
|
790
788
|
val = val.split(':').map! { |s| charname(s.sub(/^\W+/, '')) }
|
791
|
-
|
792
|
-
|
793
|
-
|
789
|
+
val.join(':').yield_self do |s|
|
790
|
+
s = val.first if val.size > 1 && s.size > 128
|
791
|
+
s[0..127]
|
792
|
+
end
|
794
793
|
end
|
795
794
|
|
796
795
|
def dnsname(val)
|