squared 0.8.2 → 0.8.4
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 +111 -0
- data/README.md +10 -10
- data/lib/squared/common/base.rb +8 -0
- data/lib/squared/common/format.rb +2 -1
- data/lib/squared/common/host.rb +35 -0
- data/lib/squared/common/prompt.rb +11 -6
- data/lib/squared/common/shell.rb +13 -12
- data/lib/squared/common/utils.rb +7 -4
- data/lib/squared/common.rb +1 -0
- data/lib/squared/config.rb +1 -2
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +5 -27
- data/lib/squared/workspace/project/base.rb +59 -19
- data/lib/squared/workspace/project/docker.rb +180 -126
- data/lib/squared/workspace/project/git.rb +363 -174
- data/lib/squared/workspace/project/node.rb +53 -22
- data/lib/squared/workspace/project/python.rb +52 -35
- data/lib/squared/workspace/project/ruby.rb +24 -25
- data/lib/squared/workspace/project/support/optionpartition.rb +121 -57
- data/lib/squared/workspace/repo.rb +5 -7
- data/lib/squared/workspace/series.rb +2 -2
- metadata +3 -2
|
@@ -12,6 +12,7 @@ module Squared
|
|
|
12
12
|
include Enumerable
|
|
13
13
|
include Comparable
|
|
14
14
|
include Common::Format
|
|
15
|
+
include Host
|
|
15
16
|
include System
|
|
16
17
|
include Shell
|
|
17
18
|
include Prompt
|
|
@@ -338,6 +339,7 @@ module Squared
|
|
|
338
339
|
ext = flag == :ext ? param_guard(action, flag, args: args, key: :ext) : flag.to_s
|
|
339
340
|
tag = param_guard(action, flag, args: args, key: :tag)
|
|
340
341
|
dir = param_guard(action, flag, args: args, key: :dir)
|
|
342
|
+
digest = args.digest
|
|
341
343
|
unless tag.match?(URI_SCHEME)
|
|
342
344
|
tag = unpack_get tag, ext
|
|
343
345
|
tag ||= if @release
|
|
@@ -346,7 +348,7 @@ module Squared
|
|
|
346
348
|
raise ArgumentError, message('no base uri', tag, hint: ext)
|
|
347
349
|
end
|
|
348
350
|
end
|
|
349
|
-
force = case
|
|
351
|
+
force = case digest
|
|
350
352
|
when 'f', 'force'
|
|
351
353
|
digest = nil
|
|
352
354
|
true
|
|
@@ -362,7 +364,8 @@ module Squared
|
|
|
362
364
|
when :set
|
|
363
365
|
format_desc action, flag, 'version,dir?=u/home|p/arent'
|
|
364
366
|
task flag, [:version] do |_, args|
|
|
365
|
-
|
|
367
|
+
version = args.version
|
|
368
|
+
args = if version
|
|
366
369
|
args.extras
|
|
367
370
|
else
|
|
368
371
|
version, opts = choice_index('Select a version',
|
|
@@ -377,7 +380,9 @@ module Squared
|
|
|
377
380
|
asdf(flag, args, version: version)
|
|
378
381
|
end
|
|
379
382
|
else
|
|
380
|
-
format_desc(action, flag, case flag
|
|
383
|
+
format_desc(action, flag, case flag
|
|
384
|
+
when :exec, :env then 'command'
|
|
385
|
+
end)
|
|
381
386
|
task flag do |_, args|
|
|
382
387
|
args = args.to_a
|
|
383
388
|
if args.empty? && (flag == :exec || flag == :env)
|
|
@@ -533,7 +538,8 @@ module Squared
|
|
|
533
538
|
graph_deps.flatten(1).sort.each do |proj|
|
|
534
539
|
next if @@graph[:_].include?(proj)
|
|
535
540
|
|
|
536
|
-
|
|
541
|
+
val = ENV["PREREQS_#{proj.envname_get}"] || ENV["PREREQS_#{proj.ref.upcase}"]
|
|
542
|
+
if val
|
|
537
543
|
split_escape(val) do |meth|
|
|
538
544
|
if proj.has?(meth)
|
|
539
545
|
begin
|
|
@@ -581,7 +587,8 @@ module Squared
|
|
|
581
587
|
on :first, :clean unless pass
|
|
582
588
|
case @clean
|
|
583
589
|
when Struct
|
|
584
|
-
|
|
590
|
+
val = instance_eval(&@clean.block) || @clean.run
|
|
591
|
+
if val
|
|
585
592
|
cur = @clean
|
|
586
593
|
@clean = val
|
|
587
594
|
clean(*args, sync: sync, pass: true, **kwargs)
|
|
@@ -1175,6 +1182,18 @@ module Squared
|
|
|
1175
1182
|
ret
|
|
1176
1183
|
end
|
|
1177
1184
|
|
|
1185
|
+
def emptypath(val, create: true)
|
|
1186
|
+
ret = basepath(val).realdirpath
|
|
1187
|
+
if ret.exist?
|
|
1188
|
+
raise Errno::EEXIST, message(val, hint: 'not empty') unless ret.directory? && ret.empty?
|
|
1189
|
+
|
|
1190
|
+
ret.rmdir unless create
|
|
1191
|
+
elsif create
|
|
1192
|
+
ret.mkpath
|
|
1193
|
+
end
|
|
1194
|
+
ret
|
|
1195
|
+
end
|
|
1196
|
+
|
|
1178
1197
|
def localname
|
|
1179
1198
|
workspace.task_localname(name)
|
|
1180
1199
|
end
|
|
@@ -1354,9 +1373,8 @@ module Squared
|
|
|
1354
1373
|
def run_b(obj, **kwargs)
|
|
1355
1374
|
case obj
|
|
1356
1375
|
when Struct
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
end
|
|
1376
|
+
val = instance_eval(&obj.block) || obj.run
|
|
1377
|
+
run_b(val, **kwargs) if val
|
|
1360
1378
|
when Proc
|
|
1361
1379
|
instance_eval(&obj)
|
|
1362
1380
|
when Method
|
|
@@ -1556,7 +1574,7 @@ module Squared
|
|
|
1556
1574
|
def env(key, default = nil, suffix: nil, strict: false, ignore: nil, **kwargs, &blk)
|
|
1557
1575
|
name = "#{key}_#{envname_get}"
|
|
1558
1576
|
ret = if suffix
|
|
1559
|
-
ENV
|
|
1577
|
+
ENV["#{name}_#{suffix}"] || (ignore == false && ENV["#{key}_#{suffix}"]) || ''
|
|
1560
1578
|
elsif strict
|
|
1561
1579
|
ENV[name].to_s
|
|
1562
1580
|
else
|
|
@@ -1714,7 +1732,7 @@ module Squared
|
|
|
1714
1732
|
end
|
|
1715
1733
|
|
|
1716
1734
|
def print_success
|
|
1717
|
-
puts
|
|
1735
|
+
puts ARG[:SUCCESS]
|
|
1718
1736
|
end
|
|
1719
1737
|
|
|
1720
1738
|
def print_error(*args, loglevel: Logger::WARN, **kwargs)
|
|
@@ -1908,8 +1926,9 @@ module Squared
|
|
|
1908
1926
|
end
|
|
1909
1927
|
|
|
1910
1928
|
def append_hash(data, target: @session || [], build: false)
|
|
1911
|
-
if build && (type = env('BUILD', suffix: 'TYPE'
|
|
1912
|
-
|
|
1929
|
+
if build && (type = env('BUILD', suffix: 'TYPE', ignore: false))
|
|
1930
|
+
extra = data[type = "__#{type}__"] || data[type.to_sym]
|
|
1931
|
+
if extra.is_a?(Hash)
|
|
1913
1932
|
data = data.merge(extra)
|
|
1914
1933
|
else
|
|
1915
1934
|
extra = nil
|
|
@@ -2092,8 +2111,8 @@ module Squared
|
|
|
2092
2111
|
args
|
|
2093
2112
|
end
|
|
2094
2113
|
|
|
2095
|
-
def confirm_basic(msg, hint, accept = 'Y', style: :inline, target: @session, prefix:
|
|
2096
|
-
return true if
|
|
2114
|
+
def confirm_basic(msg, hint, accept = 'Y', style: :inline, target: @session, prefix: target&.first, **kwargs)
|
|
2115
|
+
return true if option('y', prefix: prefix)
|
|
2097
2116
|
|
|
2098
2117
|
confirm("#{msg} [#{sub_style(hint.to_s, style.is_a?(Symbol) ? theme[style] : style)}]", accept, **kwargs)
|
|
2099
2118
|
end
|
|
@@ -2127,7 +2146,10 @@ module Squared
|
|
|
2127
2146
|
if accept
|
|
2128
2147
|
hint = Array(ret).map { |val| sub_style(val.to_s, theme[:inline]) }.join(', ')
|
|
2129
2148
|
accept = Array(accept).map { |val| Array(val) }
|
|
2130
|
-
|
|
2149
|
+
if accept.any? { |val| val[1] == true }
|
|
2150
|
+
ret = [ret]
|
|
2151
|
+
multiple = -1
|
|
2152
|
+
end
|
|
2131
2153
|
begin
|
|
2132
2154
|
item = accept.shift
|
|
2133
2155
|
c = confirm("#{item[0]}#{" [#{hint}]" if hint}", item[2] ? 'Y' : 'N')
|
|
@@ -2140,7 +2162,7 @@ module Squared
|
|
|
2140
2162
|
end until accept.empty?
|
|
2141
2163
|
end
|
|
2142
2164
|
if values
|
|
2143
|
-
ret =
|
|
2165
|
+
ret = [ret] unless accept && multiple == -1
|
|
2144
2166
|
Array(values).each do |val|
|
|
2145
2167
|
if val.is_a?(Array)
|
|
2146
2168
|
val, force = val
|
|
@@ -2186,7 +2208,7 @@ module Squared
|
|
|
2186
2208
|
cmd.reverse! if File::NULL == 'NUL'
|
|
2187
2209
|
cmd.unshift('').join(' ')
|
|
2188
2210
|
end
|
|
2189
|
-
if
|
|
2211
|
+
if powershell?
|
|
2190
2212
|
"#{shell_bin('powershell.exe')} -Command \"& {#{args.join(' ; ')}}\"#{out}"
|
|
2191
2213
|
else
|
|
2192
2214
|
args.map { |val| "#{val}#{out}" }.join(' && ')
|
|
@@ -2323,7 +2345,7 @@ module Squared
|
|
|
2323
2345
|
end
|
|
2324
2346
|
|
|
2325
2347
|
def indexchar
|
|
2326
|
-
|
|
2348
|
+
windows? ? '=' : '^'
|
|
2327
2349
|
end
|
|
2328
2350
|
|
|
2329
2351
|
def shortname(*args, suffix: '?', delim: ',', pass: false)
|
|
@@ -2420,7 +2442,7 @@ module Squared
|
|
|
2420
2442
|
return if from == false
|
|
2421
2443
|
|
|
2422
2444
|
require 'timeout'
|
|
2423
|
-
unless (path.to_s == Dir.pwd || pass) && (
|
|
2445
|
+
unless (path.to_s == Dir.pwd || pass) && (mri? || !windows?)
|
|
2424
2446
|
pwd = Dir.pwd
|
|
2425
2447
|
Dir.chdir(path)
|
|
2426
2448
|
end
|
|
@@ -2715,6 +2737,10 @@ module Squared
|
|
|
2715
2737
|
end
|
|
2716
2738
|
end
|
|
2717
2739
|
|
|
2740
|
+
def dryrun?(target: @session, prefix: target&.first, **)
|
|
2741
|
+
Array(target).include?('--dry-run') || !option('dry-run', target: target, prefix: prefix).nil?
|
|
2742
|
+
end
|
|
2743
|
+
|
|
2718
2744
|
def pwd?
|
|
2719
2745
|
path == Pathname.pwd
|
|
2720
2746
|
end
|
|
@@ -2759,6 +2785,20 @@ module Squared
|
|
|
2759
2785
|
false
|
|
2760
2786
|
end
|
|
2761
2787
|
|
|
2788
|
+
def choice!(args, char: ':', first: true, empty: false, only: false)
|
|
2789
|
+
return true if (empty && args.empty?) || (only && args.size == 1 && args.first == char)
|
|
2790
|
+
|
|
2791
|
+
if first
|
|
2792
|
+
if args.first == char
|
|
2793
|
+
args.shift
|
|
2794
|
+
return true
|
|
2795
|
+
end
|
|
2796
|
+
elsif args.delete(char)
|
|
2797
|
+
return true
|
|
2798
|
+
end
|
|
2799
|
+
false
|
|
2800
|
+
end
|
|
2801
|
+
|
|
2762
2802
|
def variables
|
|
2763
2803
|
VAR_SET
|
|
2764
2804
|
end
|