squared 0.4.17 → 0.4.18
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 +99 -58
- data/README.md +648 -1286
- data/lib/squared/common/base.rb +1 -1
- data/lib/squared/common/format.rb +5 -3
- data/lib/squared/common/prompt.rb +1 -1
- data/lib/squared/common/shell.rb +8 -2
- data/lib/squared/common/system.rb +1 -1
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +17 -7
- data/lib/squared/workspace/project/base.rb +24 -19
- data/lib/squared/workspace/project/docker.rb +2 -2
- data/lib/squared/workspace/project/git.rb +123 -109
- data/lib/squared/workspace/project/node.rb +22 -19
- data/lib/squared/workspace/project/python.rb +2 -2
- data/lib/squared/workspace/project/ruby.rb +50 -35
- data/lib/squared/workspace/project/support/class.rb +46 -3
- data/lib/squared/workspace/repo.rb +36 -13
- data/squared.gemspec +2 -2
- metadata +4 -5
- data/README.ruby.md +0 -725
data/lib/squared/common/base.rb
CHANGED
@@ -141,11 +141,11 @@ module Squared
|
|
141
141
|
def apply_style(data, key, args, empty: true)
|
142
142
|
return if data.is_a?(::Symbol) && (data = __get__(:theme)[data]).nil?
|
143
143
|
|
144
|
-
set = ->(k, v) { data[k] = check_style(v, empty: empty) }
|
144
|
+
set = ->(k, v) { data[k.to_sym] = check_style(v, empty: empty) }
|
145
145
|
if key.is_a?(::Hash)
|
146
146
|
key.each { |k, v| set.call(k, v || args) }
|
147
147
|
else
|
148
|
-
set.call(key
|
148
|
+
set.call(key, args)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -194,7 +194,7 @@ module Squared
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
def
|
197
|
+
def log_console(*args, pipe: 1)
|
198
198
|
return if args.first == false && args.size == 1
|
199
199
|
|
200
200
|
if pipe.is_a?(Pathname)
|
@@ -211,6 +211,8 @@ module Squared
|
|
211
211
|
(pipe == 2 ? $stderr : $stdout).puts(*args)
|
212
212
|
end
|
213
213
|
|
214
|
+
alias puts_oe log_console
|
215
|
+
|
214
216
|
module_function
|
215
217
|
|
216
218
|
def message(*args, hint: nil, empty: false, space: ARG[:SPACE])
|
data/lib/squared/common/shell.rb
CHANGED
@@ -92,10 +92,16 @@ module Squared
|
|
92
92
|
ret.join(join.is_a?(::String) ? join : ' ')
|
93
93
|
end
|
94
94
|
|
95
|
-
def
|
95
|
+
def shell_bin(name, env: true)
|
96
|
+
key = name.upcase
|
97
|
+
shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
|
98
|
+
option: false, force: false)
|
99
|
+
end
|
100
|
+
|
101
|
+
def fill_option(val, **kwargs)
|
96
102
|
return "-#{val}" if val.match?(/\A(?:[a-z]\d*|\d)\z/i)
|
97
103
|
|
98
|
-
shell_escape(val.start_with?('-') ? val : "--#{val}",
|
104
|
+
shell_escape(val.start_with?('-') ? val : "--#{val}", **kwargs)
|
99
105
|
end
|
100
106
|
|
101
107
|
def quote_option(flag, val, option: true, double: false, merge: false)
|
data/lib/squared/config.rb
CHANGED
@@ -94,10 +94,10 @@ module Squared
|
|
94
94
|
def build
|
95
95
|
return unless enabled?
|
96
96
|
|
97
|
-
namespace
|
97
|
+
namespace task_name(name) do |ns|
|
98
98
|
@mime.each do |type, items|
|
99
99
|
items.each do |command, file, opts|
|
100
|
-
next if Rake::Task.task_defined?("#{ns}:#{command}:#{type}")
|
100
|
+
next if Rake::Task.task_defined?("#{ns.scope.path}:#{command}:#{type}")
|
101
101
|
|
102
102
|
namespace command do
|
103
103
|
unless (data = @@mime_obj[type])
|
@@ -196,7 +196,7 @@ module Squared
|
|
196
196
|
private
|
197
197
|
|
198
198
|
def puts(*args)
|
199
|
-
|
199
|
+
log_console(*args, pipe: pipe)
|
200
200
|
end
|
201
201
|
|
202
202
|
def log
|
data/lib/squared/version.rb
CHANGED
@@ -95,9 +95,15 @@ module Squared
|
|
95
95
|
@kind = Support.hashlist
|
96
96
|
@extensions = []
|
97
97
|
@envname = env_key(@main).freeze
|
98
|
-
@pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
|
98
|
+
@pipe = $DEBUG ? 2 : env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
|
99
99
|
@exception = env_bool exception
|
100
|
-
@verbose =
|
100
|
+
@verbose = if $VERBOSE.nil?
|
101
|
+
false
|
102
|
+
elsif verbose.nil?
|
103
|
+
@pipe != 0
|
104
|
+
else
|
105
|
+
env_bool(verbose, verbose.is_a?(String) ? @pipe != 0 : verbose, index: true)
|
106
|
+
end
|
101
107
|
@warning = @verbose != false
|
102
108
|
@closed = false
|
103
109
|
if common
|
@@ -423,7 +429,7 @@ module Squared
|
|
423
429
|
ret << proj if proj
|
424
430
|
end
|
425
431
|
end
|
426
|
-
return (group || ref ? ret : ret
|
432
|
+
return (group || ref ? ret : ret.first) unless block_given?
|
427
433
|
|
428
434
|
ret.each(&blk)
|
429
435
|
self
|
@@ -678,6 +684,10 @@ module Squared
|
|
678
684
|
{ exception: exception, warning: warning }
|
679
685
|
end
|
680
686
|
|
687
|
+
def size
|
688
|
+
@project.size
|
689
|
+
end
|
690
|
+
|
681
691
|
def to_s
|
682
692
|
(home? ? home : root).to_s
|
683
693
|
end
|
@@ -800,8 +810,8 @@ module Squared
|
|
800
810
|
format_desc key
|
801
811
|
task key do
|
802
812
|
unless failed.empty? && group.empty?
|
803
|
-
puts
|
804
|
-
subject: 'failed placement', hint: false)
|
813
|
+
puts(log_message(Logger::ERROR, *(failed + group.map { |val| val.action }.flatten),
|
814
|
+
subject: 'failed placement', hint: false), pipe: 2)
|
805
815
|
end
|
806
816
|
cols = level.flatten(1).map(&:size).max
|
807
817
|
level.each_with_index do |grp, n|
|
@@ -817,8 +827,8 @@ module Squared
|
|
817
827
|
end
|
818
828
|
end
|
819
829
|
|
820
|
-
def puts(*args)
|
821
|
-
|
830
|
+
def puts(*args, **kwargs)
|
831
|
+
log_console(*args, pipe: kwargs[:pipe] || pipe)
|
822
832
|
end
|
823
833
|
|
824
834
|
def script_command(task, val, group, ref, on, &blk)
|
@@ -21,7 +21,7 @@ module Squared
|
|
21
21
|
VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
|
22
22
|
pass only exclude].freeze
|
23
23
|
BLK_SET = %i[run depend doc lint test copy clean].freeze
|
24
|
-
SEM_VER = /\b(\d+)(?:(\.)(\d+))?(?:(\.)(\d+))
|
24
|
+
SEM_VER = /\b(\d+)(?:(\.)(\d+))?(?:(\.)(\d+))?[-.]?(\S+)?\b/.freeze
|
25
25
|
URI_SCHEME = %r{\A([a-z][a-z\d+-.]*)://[^@:\[\]\\^<>|\s]}i.freeze
|
26
26
|
TASK_METADATA = Rake::TaskManager.record_task_metadata
|
27
27
|
private_constant :VAR_SET, :BLK_SET, :SEM_VER, :URI_SCHEME, :TASK_METADATA
|
@@ -313,7 +313,7 @@ module Squared
|
|
313
313
|
flags.each do |flag|
|
314
314
|
case action
|
315
315
|
when 'graph'
|
316
|
-
|
316
|
+
break unless graph?
|
317
317
|
|
318
318
|
format_desc action, flag, '(-)project*'
|
319
319
|
task flag do |_, args|
|
@@ -455,13 +455,13 @@ module Squared
|
|
455
455
|
if args.first.is_a?(Struct)
|
456
456
|
f, blk = args.first.to_a
|
457
457
|
args[0] = instance_eval(&blk) || f
|
458
|
-
return unless args
|
458
|
+
return unless args.first
|
459
459
|
end
|
460
460
|
if args.all? { |val| val.is_a?(Array) }
|
461
461
|
cmd = []
|
462
462
|
var = {}
|
463
463
|
args.each do |val|
|
464
|
-
next instance_exec(*val[1..-1], &val
|
464
|
+
next instance_exec(*val[1..-1], &val.first) if val.first.is_a?(Proc)
|
465
465
|
|
466
466
|
a, b, c, d, e = val
|
467
467
|
case b
|
@@ -948,7 +948,7 @@ module Squared
|
|
948
948
|
def log
|
949
949
|
return @log unless @log.is_a?(Array)
|
950
950
|
|
951
|
-
@log = Logger.new(enabled? ? @log
|
951
|
+
@log = Logger.new(enabled? ? @log.first : nil, **@log.last)
|
952
952
|
end
|
953
953
|
|
954
954
|
def allref
|
@@ -989,8 +989,8 @@ module Squared
|
|
989
989
|
|
990
990
|
private
|
991
991
|
|
992
|
-
def puts(*args)
|
993
|
-
|
992
|
+
def puts(*args, **kwargs)
|
993
|
+
log_console(*args, pipe: kwargs[:pipe] || pipe)
|
994
994
|
end
|
995
995
|
|
996
996
|
def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
|
@@ -999,10 +999,8 @@ module Squared
|
|
999
999
|
warn log_message(Logger::WARN, 'no command given', subject: project, hint: from || 'unknown', pass: true)
|
1000
1000
|
return
|
1001
1001
|
end
|
1002
|
-
i = interactive && !(@session && option('y'))
|
1003
1002
|
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
1004
|
-
|
1005
|
-
if i
|
1003
|
+
if interactive && (!@session || !option('y'))
|
1006
1004
|
title, y = case interactive
|
1007
1005
|
when Array
|
1008
1006
|
interactive
|
@@ -1011,10 +1009,10 @@ module Squared
|
|
1011
1009
|
else
|
1012
1010
|
['Run', 'Y']
|
1013
1011
|
end
|
1014
|
-
|
1015
|
-
|
1016
|
-
end
|
1012
|
+
yn = y == 'Y' ? 'Y/n' : 'y/N'
|
1013
|
+
exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
|
1017
1014
|
end
|
1015
|
+
cmd = session_done cmd
|
1018
1016
|
log&.info cmd
|
1019
1017
|
on :first, from
|
1020
1018
|
begin
|
@@ -1231,12 +1229,12 @@ module Squared
|
|
1231
1229
|
end
|
1232
1230
|
|
1233
1231
|
def session(*cmd, prefix: cmd.first, main: true, path: true, options: true)
|
1234
|
-
prefix = stripext
|
1235
|
-
if path && (val =
|
1232
|
+
prefix = stripext prefix.to_s
|
1233
|
+
if path && (val = shell_bin(prefix))
|
1236
1234
|
cmd[0] = shell_quote(val, force: false)
|
1237
1235
|
end
|
1238
1236
|
ret = JoinSet.new(cmd.flatten(1))
|
1239
|
-
if options && (val = env("#{prefix}_OPTIONS"))
|
1237
|
+
if options && (val = env("#{prefix.upcase}_OPTIONS"))
|
1240
1238
|
split_escape(val).each { |opt| ret.last(fill_option(opt), /\A(--?[^ =]+)[ =].+\z/m) }
|
1241
1239
|
end
|
1242
1240
|
main ? @session = ret : ret
|
@@ -1420,9 +1418,9 @@ module Squared
|
|
1420
1418
|
unless items.empty?
|
1421
1419
|
pad = items.size.to_s.size
|
1422
1420
|
items.each_with_index do |val, i|
|
1423
|
-
next unless matchany?(val
|
1421
|
+
next unless matchany?(val.first, reg)
|
1424
1422
|
|
1425
|
-
out << "#{i.succ.to_s.rjust(pad)}. #{each ? each.call(val) : val
|
1423
|
+
out << "#{i.succ.to_s.rjust(pad)}. #{each ? each.call(val) : val.first}"
|
1426
1424
|
end
|
1427
1425
|
end
|
1428
1426
|
sub = [headerstyle]
|
@@ -1779,7 +1777,14 @@ module Squared
|
|
1779
1777
|
return -1 if b.empty?
|
1780
1778
|
return 1 if a.empty?
|
1781
1779
|
|
1782
|
-
a, b = [a.first, b.first].map!
|
1780
|
+
a, b = [a.first, b.first].map! do |c|
|
1781
|
+
begin
|
1782
|
+
d = Integer(c[5]).to_s
|
1783
|
+
rescue StandardError
|
1784
|
+
d = c[5] ? '-1' : '0'
|
1785
|
+
end
|
1786
|
+
[c[0], c[2], c[4] || '0', d]
|
1787
|
+
end
|
1783
1788
|
a.each_with_index do |c, index|
|
1784
1789
|
next if c == (d = b[index])
|
1785
1790
|
|
@@ -147,7 +147,7 @@ module Squared
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
when 'bake'
|
150
|
-
|
150
|
+
break unless bake?
|
151
151
|
|
152
152
|
case flag
|
153
153
|
when :build
|
@@ -168,7 +168,7 @@ module Squared
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
when 'compose'
|
171
|
-
|
171
|
+
break unless compose?
|
172
172
|
|
173
173
|
case flag
|
174
174
|
when :build, :up
|