squared 0.4.19 → 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 +62 -261
- data/README.md +1280 -647
- data/README.ruby.md +722 -0
- data/lib/squared/common/base.rb +8 -9
- data/lib/squared/common/format.rb +7 -16
- data/lib/squared/common/prompt.rb +38 -42
- data/lib/squared/common/shell.rb +10 -10
- data/lib/squared/common/system.rb +31 -35
- data/lib/squared/common/utils.rb +3 -28
- data/lib/squared/common.rb +2 -1
- data/lib/squared/config.rb +19 -19
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +55 -89
- data/lib/squared/workspace/project/base.rb +262 -403
- data/lib/squared/workspace/project/docker.rb +156 -183
- data/lib/squared/workspace/project/git.rb +337 -481
- data/lib/squared/workspace/project/node.rb +96 -141
- data/lib/squared/workspace/project/python.rb +73 -299
- data/lib/squared/workspace/project/ruby.rb +158 -238
- data/lib/squared/workspace/project/support/class.rb +79 -136
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +52 -93
- data/lib/squared/workspace/series.rb +16 -16
- data/lib/squared/workspace/support/data.rb +3 -2
- data/lib/squared/workspace/support.rb +0 -1
- data/lib/squared/workspace.rb +1 -1
- data/squared.gemspec +5 -5
- metadata +7 -8
- data/lib/squared/common/class.rb +0 -110
- data/lib/squared/workspace/support/base.rb +0 -17
@@ -10,22 +10,15 @@ module Squared
|
|
10
10
|
include Common::Shell
|
11
11
|
extend Forwardable
|
12
12
|
|
13
|
-
OPT_VALUE = /\A([^=]+)=(.+)\z/
|
14
|
-
private_constant :OPT_VALUE
|
15
|
-
|
16
13
|
class << self
|
17
14
|
include Common::Format
|
18
15
|
include Shell
|
19
16
|
include Prompt
|
20
17
|
|
21
|
-
def append(target, *args, delim: false, escape: false, quote: true,
|
18
|
+
def append(target, *args, delim: false, escape: false, quote: true, **)
|
22
19
|
return if (ret = args.flatten).empty?
|
23
20
|
|
24
21
|
target << '--' if delim && !target.include?('--')
|
25
|
-
if strip
|
26
|
-
pat, s = Array(strip)
|
27
|
-
ret.map! { |val| val.gsub(pat, s || '') }
|
28
|
-
end
|
29
22
|
ret.map! { |val| escape ? shell_escape(val, quote: quote) : shell_quote(val) } if escape || quote
|
30
23
|
if target.is_a?(Set)
|
31
24
|
target.merge(ret)
|
@@ -42,7 +35,9 @@ module Squared
|
|
42
35
|
kwargs[:hint] ||= 'unrecognized'
|
43
36
|
append(target, opts, delim: true) if kwargs.delete(:append)
|
44
37
|
warn log_message(Logger::WARN, opts.join(', '), pass: true, **kwargs)
|
45
|
-
|
38
|
+
return if pass || confirm("Run? [#{sub_style(target, styles: styles)}] [y/N] ", 'N')
|
39
|
+
|
40
|
+
raise_error 'user cancelled'
|
46
41
|
end
|
47
42
|
|
48
43
|
def strip(val)
|
@@ -52,38 +47,23 @@ module Squared
|
|
52
47
|
val.map { |s| s.sub(/\A-([a-z\d])(.+)\z/i, '\1=\2').sub(/\A--?/, '') }.reject(&:empty?)
|
53
48
|
end
|
54
49
|
|
55
|
-
def select(list, bare: true, no: true, single: false, double: false)
|
56
|
-
ret = bare ? list.grep_v(/=/) : list.grep(/=/).map! { |val| val.split('=', 2).first }
|
57
|
-
ret.map! { |val| val.split('|', 2).last }
|
58
|
-
ret = ret.grep_v(/^no-/) unless no
|
59
|
-
return ret if single == double
|
60
|
-
|
61
|
-
ret.select { |val| single ? val.size == 1 : val.size > 1 }
|
62
|
-
end
|
63
|
-
|
64
50
|
def arg?(target, *args, value: false, **)
|
65
51
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
66
52
|
unless s.empty?
|
67
53
|
s.map! { |val| Regexp.escape(val.start_with?('-') ? val : shell_option(val)) }
|
68
54
|
r << /\A(?:#{s.join('|')})#{value ? '[ =].' : '(?: |=|\z)'}/
|
69
55
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def pattern?(val)
|
74
|
-
val.match?(/(?:\A\^|\$\z)/) || val.match?(/(?:\.[*+]|\(\?:|\\[dsw]|\[.+\]|\{\d+,?\d*\})/)
|
56
|
+
s = target.to_a.compact
|
57
|
+
r.any? { |pat| s.any?(pat) }
|
75
58
|
end
|
76
59
|
end
|
77
60
|
|
78
61
|
attr_reader :target, :extras, :found, :errors, :values, :project, :path
|
79
62
|
|
80
63
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
81
|
-
:merge, :delete, :delete?, :delete_if, :grep, :
|
64
|
+
:merge, :delete, :delete?, :delete_if, :grep, :inspect, :to_a, :to_s
|
82
65
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
83
|
-
:pop, :push, :
|
84
|
-
|
85
|
-
def_delegator :@extras, :delete, :remove
|
86
|
-
def_delegator :@extras, :delete_if, :remove_if
|
66
|
+
:pop, :push, :join, :map, :map!, :select, :reject, :size
|
87
67
|
|
88
68
|
def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
|
89
69
|
@target = target.is_a?(Set) ? target : target.to_set
|
@@ -160,36 +140,35 @@ module Squared
|
|
160
140
|
numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && pat.match?(v) } }
|
161
141
|
skip = false
|
162
142
|
opts.each do |opt|
|
163
|
-
next
|
164
|
-
next push opt if skip
|
143
|
+
next @extras << opt if skip
|
165
144
|
|
166
145
|
if single&.match?(opt)
|
167
|
-
|
146
|
+
target << "-#{opt}"
|
168
147
|
elsif bare.include?(opt)
|
169
|
-
|
148
|
+
target << (opt.size == 1 ? "-#{opt}" : "--#{opt}")
|
170
149
|
elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
|
171
|
-
|
150
|
+
target << "--no-#{name}"
|
172
151
|
else
|
173
|
-
if opt =~
|
152
|
+
if opt =~ /\A([^=]+)=(.+)\z/
|
174
153
|
key = $1
|
175
154
|
val = $2
|
176
155
|
merge = m.include?(key)
|
177
156
|
if e.include?(key)
|
178
|
-
|
157
|
+
target << shell_option(key, val, merge: merge)
|
179
158
|
elsif q.include?(key)
|
180
|
-
|
159
|
+
target << quote_option(key, val, double: qq.include?(key), merge: merge)
|
181
160
|
elsif p.include?(key) && path
|
182
|
-
|
161
|
+
target << quote_option(key, path + val, merge: merge)
|
183
162
|
elsif b.include?(key) || numcheck.call(key, val)
|
184
|
-
|
163
|
+
target << basic_option(key, val, merge: merge)
|
185
164
|
elsif merge
|
186
|
-
|
165
|
+
target << basic_option(key, val, merge: true)
|
187
166
|
else
|
188
|
-
|
167
|
+
@extras << opt
|
189
168
|
end
|
190
169
|
opt = key
|
191
170
|
else
|
192
|
-
|
171
|
+
@extras << opt
|
193
172
|
skip = true if args
|
194
173
|
end
|
195
174
|
skip = true if first&.any? { |s| s.is_a?(Regexp) ? opt.match?(s) : !opt.include?(s) }
|
@@ -210,27 +189,10 @@ module Squared
|
|
210
189
|
end
|
211
190
|
|
212
191
|
def append(*args, **kwargs)
|
213
|
-
args
|
214
|
-
OptionPartition.append(target, *args, **kwargs)
|
192
|
+
OptionPartition.append(target, *(args.empty? ? extras : args), **kwargs)
|
215
193
|
self
|
216
194
|
end
|
217
195
|
|
218
|
-
def uniq(list)
|
219
|
-
items = map { |val| nameonly(val) }
|
220
|
-
list.reject do |val|
|
221
|
-
next true if items.include?(s = nameonly(val))
|
222
|
-
|
223
|
-
pat = /\A#{s = fill_option(s)}(?:#{s.start_with?('--') ? '[= ]' : '.*'}|\z)/
|
224
|
-
any? { |opt| opt.match?(pat) }
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
def uniq!(list)
|
229
|
-
n = size
|
230
|
-
concat uniq(list)
|
231
|
-
extras if size > n
|
232
|
-
end
|
233
|
-
|
234
196
|
def clear(opts = nil, errors: false, **kwargs)
|
235
197
|
styles = project.theme[:inline] if project
|
236
198
|
if !opts
|
@@ -244,101 +206,82 @@ module Squared
|
|
244
206
|
self
|
245
207
|
end
|
246
208
|
|
247
|
-
def
|
248
|
-
|
249
|
-
(items = to_a).each_with_index do |val, index|
|
250
|
-
if i == 0
|
251
|
-
next unless val.start_with?('-')
|
252
|
-
|
253
|
-
i = index
|
254
|
-
break
|
255
|
-
elsif index > 0 && !val.start_with?('-')
|
256
|
-
if start
|
257
|
-
i = index + (start.is_a?(Numeric) ? start : 1)
|
258
|
-
break
|
259
|
-
end
|
260
|
-
i = 0
|
261
|
-
end
|
262
|
-
end
|
263
|
-
if i > 0
|
264
|
-
if args.empty?
|
265
|
-
args = dup
|
266
|
-
reset
|
267
|
-
end
|
268
|
-
args = items[0...i] + args + items[i..-1]
|
269
|
-
target.clear
|
270
|
-
end
|
271
|
-
merge args
|
272
|
-
self
|
209
|
+
def arg?(*args, **kwargs)
|
210
|
+
OptionPartition.arg?(target, *args, **kwargs)
|
273
211
|
end
|
212
|
+
end
|
274
213
|
|
275
|
-
|
276
|
-
|
277
|
-
|
214
|
+
class JoinSet < Set
|
215
|
+
def self.to_s
|
216
|
+
super[/[^:]+\z/, 0]
|
278
217
|
end
|
279
218
|
|
280
|
-
|
281
|
-
|
282
|
-
|
219
|
+
attr_reader :delim
|
220
|
+
|
221
|
+
def initialize(data = [], delim: ' ')
|
222
|
+
super(data.compact)
|
223
|
+
@delim = delim
|
283
224
|
end
|
284
225
|
|
285
|
-
def
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
226
|
+
def last(val, pat)
|
227
|
+
(@last ||= []).append([val, pat, $1]) if val =~ pat
|
228
|
+
self << val
|
229
|
+
end
|
230
|
+
|
231
|
+
def pass(&blk)
|
232
|
+
ret = to_a.map!(&:to_s).reject(&:empty?)
|
233
|
+
@last&.each do |val, pat, key|
|
234
|
+
i = []
|
235
|
+
j = nil
|
236
|
+
ret.each_with_index do |opt, index|
|
237
|
+
if opt == val
|
238
|
+
j = index
|
239
|
+
elsif j && opt[pat, 1] == key
|
240
|
+
i << index
|
241
|
+
end
|
242
|
+
end
|
243
|
+
next unless j && !i.empty?
|
244
|
+
|
245
|
+
val = ret[j]
|
246
|
+
cur = j
|
247
|
+
i.each do |k|
|
248
|
+
ret[cur] = ret[k]
|
249
|
+
cur = k
|
305
250
|
end
|
251
|
+
ret[i.last] = val
|
306
252
|
end
|
307
|
-
|
253
|
+
block_given? ? ret.reject(&blk) : ret
|
308
254
|
end
|
309
255
|
|
310
|
-
def
|
311
|
-
|
312
|
-
|
313
|
-
self
|
256
|
+
def and(*args)
|
257
|
+
self << '&&'
|
258
|
+
merge args
|
314
259
|
end
|
315
260
|
|
316
|
-
def
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
return false unless val
|
261
|
+
def or(*args)
|
262
|
+
self << '||'
|
263
|
+
merge args
|
264
|
+
end
|
321
265
|
|
322
|
-
|
323
|
-
|
324
|
-
when :quote
|
325
|
-
quote_option(key, val)
|
326
|
-
when :basic
|
327
|
-
basic_option(key, val)
|
328
|
-
else
|
329
|
-
shell_option(key, val, **kwargs)
|
330
|
-
end
|
331
|
-
true
|
266
|
+
def with(*args, &blk)
|
267
|
+
temp('&&', *args, &blk)
|
332
268
|
end
|
333
269
|
|
334
|
-
def
|
335
|
-
|
270
|
+
def temp(*args, &blk)
|
271
|
+
args.compact!
|
272
|
+
ret = pass(&blk)
|
273
|
+
ret = Set.new(ret.concat(args)).to_a unless args.empty?
|
274
|
+
ret.join(@delim)
|
336
275
|
end
|
337
276
|
|
338
|
-
|
277
|
+
def done
|
278
|
+
ret = to_s
|
279
|
+
clear
|
280
|
+
ret
|
281
|
+
end
|
339
282
|
|
340
|
-
def
|
341
|
-
|
283
|
+
def to_s
|
284
|
+
pass.join(@delim)
|
342
285
|
end
|
343
286
|
end
|
344
287
|
end
|
@@ -3,16 +3,6 @@
|
|
3
3
|
module Squared
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
|
-
class << self
|
7
|
-
attr_accessor :line_width
|
8
|
-
|
9
|
-
def max_width(lines)
|
10
|
-
n = [lines.max_by(&:size).size, 80].max
|
11
|
-
[n, Rake.application.terminal_width].min
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
@line_width = ENV.fetch('LOG_COLUMNS', 80).to_i
|
16
6
|
end
|
17
7
|
end
|
18
8
|
end
|
@@ -57,10 +57,10 @@ module Squared
|
|
57
57
|
when 'verbose'
|
58
58
|
@verbose = 1
|
59
59
|
if script.is_a?(Array)
|
60
|
-
script[0] = task_join
|
60
|
+
script[0] = task_join script[0], 'verbose'
|
61
61
|
script
|
62
62
|
else
|
63
|
-
task_join
|
63
|
+
task_join script, 'verbose'
|
64
64
|
end
|
65
65
|
when 'silent'
|
66
66
|
@verbose = false
|
@@ -81,8 +81,8 @@ module Squared
|
|
81
81
|
data[:run] = run
|
82
82
|
end
|
83
83
|
data[:global] = true
|
84
|
-
data[:dev] = env_match
|
85
|
-
data[:prod] = env_match
|
84
|
+
data[:dev] = env_match 'REPO_DEV', dev
|
85
|
+
data[:prod] = env_match 'REPO_PROD', prod
|
86
86
|
if (val = env('REPO_GROUP'))
|
87
87
|
script_set(data, group: val.split(','))
|
88
88
|
found = true
|
@@ -113,39 +113,56 @@ module Squared
|
|
113
113
|
def __repo__(**kwargs)
|
114
114
|
kwargs.delete(:parallel) if env('REPO_SYNC', ignore: '0')
|
115
115
|
|
116
|
-
namespace task_name('repo') do |
|
117
|
-
path = ns.scope.path
|
116
|
+
namespace(name = task_name('repo')) do |repo|
|
118
117
|
branch = env('REPO_MANIFEST') || Repo.read_manifest(root)
|
119
118
|
target = branch || manifest
|
120
119
|
stage = nil
|
121
|
-
|
122
|
-
|
120
|
+
failfast = true
|
121
|
+
cmd = []
|
122
|
+
newline = ARGV.index { |val| val.start_with?('repo:') }.to_i > 0
|
123
|
+
parse_opts = lambda do |args|
|
124
|
+
args.to_a.each do |val|
|
125
|
+
case val
|
126
|
+
when 'no-fail'
|
127
|
+
failfast = false
|
128
|
+
when 'force'
|
129
|
+
cmd << '--force-checkout'
|
130
|
+
when 'rebase'
|
131
|
+
cmd << '--rebase'
|
132
|
+
when 'detach'
|
133
|
+
cmd << '--detach'
|
134
|
+
when 'gc'
|
135
|
+
cmd << '--auto-gc'
|
136
|
+
when 'no-update'
|
137
|
+
cmd << '--no-manifest-update'
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
123
141
|
desc = lambda do |val, alt = nil|
|
124
142
|
if (ver = branch || alt)
|
125
|
-
val = val.sub('{0}',
|
126
|
-
task_desc(
|
143
|
+
val = val.sub('{0}', 'opts*=force,rebase,detach,gc,no-update,no-fail')
|
144
|
+
task_desc(task_name('repo'), val, ver)
|
127
145
|
else
|
128
146
|
task_desc 'inactive'
|
129
147
|
end
|
130
148
|
end
|
131
149
|
|
132
150
|
desc.call('all[{0}]')
|
133
|
-
task 'all' do |_, args|
|
151
|
+
task 'all', [:opts] do |_, args|
|
152
|
+
parse_opts.call(args)
|
134
153
|
stage ||= 'all'
|
135
|
-
|
136
|
-
next if env('
|
154
|
+
repo['sync'].invoke
|
155
|
+
next if env('REPO_DRYRUN', equals: '2')
|
137
156
|
|
138
157
|
@project.select do |_, proj|
|
139
158
|
next unless proj.enabled?(proj.workspace.baseref)
|
140
159
|
|
141
160
|
proj.depend(sync: true) if proj.depend?
|
142
|
-
|
143
|
-
|
144
|
-
proj.build?
|
161
|
+
proj.build? unless env('REPO_DRYRUN', ignore: '0')
|
145
162
|
end
|
146
163
|
.each_value do |proj|
|
147
164
|
proj.build(sync: true)
|
148
|
-
next unless proj.dev? && proj.copy?
|
165
|
+
next unless proj.dev? && proj.copy?
|
149
166
|
|
150
167
|
if (ws = proj.workspace).task_defined?(target = task_join(proj.name, 'copy'))
|
151
168
|
task_invoke(target, **ws.invokeargs)
|
@@ -155,73 +172,39 @@ module Squared
|
|
155
172
|
end
|
156
173
|
end
|
157
174
|
|
158
|
-
desc.call("init[manifest?=#{target},
|
159
|
-
task 'init' do |_, args|
|
160
|
-
args
|
161
|
-
u = env('REPO_URL') || manifest_url
|
162
|
-
m = args.first && !opts.include?(args.first) ? args.shift : target
|
163
|
-
g = args.first && !opts.include?(args.first) ? args.shift : nil
|
164
|
-
g = case (val = env('REPO_GROUPS'))
|
165
|
-
when '', NilClass
|
166
|
-
g
|
167
|
-
when '0', 'false'
|
168
|
-
nil
|
169
|
-
else
|
170
|
-
val
|
171
|
-
end
|
175
|
+
desc.call("init[manifest?=#{target},{0}]", target)
|
176
|
+
task 'init', [:manifest, :opts] do |_, args|
|
177
|
+
parse_opts.call(args)
|
172
178
|
stage = 'init'
|
173
179
|
puts if newline
|
174
|
-
|
175
|
-
|
176
|
-
opts << '--submodules' if repo_submodules?(args.include?('submodules'))
|
177
|
-
repo_run "#{repo_bin} init #{opts.uniq.join(' ')}"
|
178
|
-
next if env('REPO_STAGE', equals: '0')
|
179
|
-
|
180
|
-
ns['all'].invoke(*args)
|
180
|
+
system("repo init -u #{env('REPO_URL') || manifest_url} -m #{args.manifest || target}.xml", chdir: root)
|
181
|
+
repo['all'].invoke
|
181
182
|
end
|
182
183
|
|
183
184
|
desc.call('sync[{0}]')
|
184
|
-
task 'sync' do |
|
185
|
-
|
186
|
-
|
187
|
-
else
|
188
|
-
raise_error 'repo not initialized' unless branch
|
189
|
-
repo_opts
|
190
|
-
end
|
191
|
-
args.to_a.each do |val|
|
192
|
-
case val
|
193
|
-
when 'force'
|
194
|
-
opts << '--force-checkout'
|
195
|
-
when 'rebase', 'detach'
|
196
|
-
opts << "--#{val}"
|
197
|
-
when 'submodules'
|
198
|
-
opts << '--fetch-submodules' if repo_submodules?(true)
|
199
|
-
when 'fail'
|
200
|
-
opts << '--fail-fast'
|
201
|
-
when 'no-update'
|
202
|
-
opts << '--no-manifest-update'
|
203
|
-
when 'gc'
|
204
|
-
opts << '--auto-gc'
|
205
|
-
end
|
185
|
+
task 'sync', [:opts] do |_, args|
|
186
|
+
unless branch || stage == 'init'
|
187
|
+
raise_error('repo not initialized', hint: task_name('repo:init'), kind: LoadError)
|
206
188
|
end
|
207
|
-
|
208
|
-
|
209
|
-
|
189
|
+
parse_opts.call(args)
|
190
|
+
cmd << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}"
|
191
|
+
cmd << '--fail-fast' if failfast
|
192
|
+
puts if newline && stage != 'init'
|
210
193
|
begin
|
211
|
-
|
194
|
+
Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
|
212
195
|
rescue Errno::ENOENT => e
|
213
196
|
emphasize(e, title: root)
|
214
197
|
raise
|
215
198
|
rescue StandardError => e
|
216
|
-
emphasize(e, title: "rake stash #{
|
199
|
+
emphasize(e, title: "rake stash #{task_name(task_join('repo', stage || 'sync'))}")
|
217
200
|
raise
|
218
201
|
end
|
219
202
|
end
|
220
203
|
|
221
|
-
series.sync.
|
222
|
-
task_join(
|
223
|
-
task_join(
|
224
|
-
task_join(
|
204
|
+
series.sync.append(
|
205
|
+
task_join(name, 'all'),
|
206
|
+
task_join(name, 'init'),
|
207
|
+
task_join(name, 'sync')
|
225
208
|
)
|
226
209
|
end
|
227
210
|
end
|
@@ -237,34 +220,10 @@ module Squared
|
|
237
220
|
)
|
238
221
|
end
|
239
222
|
|
240
|
-
def repo_run(cmd, exception: false)
|
241
|
-
puts log_message(Logger::INFO, cmd, subject: main, hint: root) if verbose
|
242
|
-
Common::System.shell(cmd, chdir: root, exception: exception)
|
243
|
-
end
|
244
|
-
|
245
|
-
def repo_bin
|
246
|
-
Common::Shell.shell_bin('repo')
|
247
|
-
end
|
248
|
-
|
249
|
-
def repo_opts(*args)
|
250
|
-
return args unless (n = ARGV.index('--'))
|
251
|
-
|
252
|
-
ARGV[(n + 1)..-1].concat(args)
|
253
|
-
end
|
254
|
-
|
255
223
|
def repo?
|
256
224
|
!manifest_url.nil? && (repo_install? || @repo_override == true)
|
257
225
|
end
|
258
226
|
|
259
|
-
def repo_submodules?(val = false)
|
260
|
-
case (s = env('REPO_SUBMODULES'))
|
261
|
-
when '0', 'false'
|
262
|
-
false
|
263
|
-
else
|
264
|
-
s ? true : val
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
227
|
def repo_install?(dir = root, parent: false)
|
269
228
|
return true if root?(dir, pass: ['.repo']) || dir.join('.repo').directory?
|
270
229
|
|
@@ -10,16 +10,16 @@ module Squared
|
|
10
10
|
|
11
11
|
TASK_BASE = []
|
12
12
|
TASK_BATCH = {}
|
13
|
-
TASK_EXTEND =
|
13
|
+
TASK_EXTEND = {}
|
14
14
|
TASK_KEYS = []
|
15
|
-
TASK_ALIAS =
|
15
|
+
TASK_ALIAS = {}
|
16
16
|
TASK_NAME = {}
|
17
17
|
private_constant :TASK_BASE, :TASK_BATCH, :TASK_EXTEND, :TASK_KEYS, :TASK_ALIAS, :TASK_NAME
|
18
18
|
|
19
19
|
class << self
|
20
20
|
def add(task, obj)
|
21
21
|
key_set task
|
22
|
-
TASK_EXTEND[task] << obj
|
22
|
+
(TASK_EXTEND[task] ||= []) << obj
|
23
23
|
end
|
24
24
|
|
25
25
|
def batch(*args, obj)
|
@@ -37,7 +37,7 @@ module Squared
|
|
37
37
|
|
38
38
|
def alias(ref, obj)
|
39
39
|
if obj.is_a?(Hash)
|
40
|
-
obj.each { |key, val| TASK_ALIAS[key][ref] = val }
|
40
|
+
obj.each { |key, val| (TASK_ALIAS[key] ||= {})[ref] = val }
|
41
41
|
else
|
42
42
|
TASK_ALIAS[obj]&.delete(ref)
|
43
43
|
end
|
@@ -68,7 +68,7 @@ module Squared
|
|
68
68
|
|
69
69
|
attr_reader :sync, :multiple, :parallel
|
70
70
|
|
71
|
-
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :
|
71
|
+
def_delegators :@data, :[], :each, :each_key, :keys, :key?, :fetch, :update, :merge!, :to_a, :to_s, :inspect
|
72
72
|
def_delegators :@workspace, :task_desc, :task_name, :task_namespace, :task_join, :format_desc
|
73
73
|
|
74
74
|
def initialize(workspace, exclude: [])
|
@@ -79,8 +79,8 @@ module Squared
|
|
79
79
|
@chain = {}
|
80
80
|
@exclude = exclude.freeze
|
81
81
|
@session = {
|
82
|
-
group:
|
83
|
-
parent:
|
82
|
+
group: {},
|
83
|
+
parent: {},
|
84
84
|
id: []
|
85
85
|
}
|
86
86
|
@data = {}
|
@@ -95,7 +95,7 @@ module Squared
|
|
95
95
|
|
96
96
|
if (g = proj.group)
|
97
97
|
id << g
|
98
|
-
group[:"#{key}:#{g}"].concat(tasks)
|
98
|
+
(group[:"#{key}:#{g}"] ||= []).concat(tasks)
|
99
99
|
else
|
100
100
|
items.concat(tasks)
|
101
101
|
end
|
@@ -106,35 +106,35 @@ module Squared
|
|
106
106
|
next unless (b = ws.find_base(proj)) && (n = b.ref.to_s) != g
|
107
107
|
|
108
108
|
id << n
|
109
|
-
parent[:"#{key}:#{n}"].concat(tasks)
|
109
|
+
(parent[:"#{key}:#{n}"] ||= []).concat(tasks)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
def build(parallel: [], pattern: [], **)
|
114
114
|
subcheck = ->(val) { (ns = task_namespace(val)) && parallel.include?(ns) }
|
115
|
-
@data.
|
116
|
-
@data.
|
115
|
+
@data.update(@session[:parent]) if @session[:id].uniq.size > 1
|
116
|
+
@data.update(@session[:group])
|
117
117
|
@data.each do |key, items|
|
118
118
|
next if exclude?(key, true) || @workspace.task_exclude?(t = name_get(key))
|
119
119
|
|
120
120
|
key = task_name t
|
121
|
-
|
121
|
+
title = format_desc(key, out: true)
|
122
122
|
if items.size > 1
|
123
123
|
@multiple << key
|
124
124
|
if parallel.include?(t) || pattern.any? { |pat| t.match?(pat) } || subcheck.call(t)
|
125
|
-
task_desc("#{
|
125
|
+
task_desc("#{title} (thread)", name: key) if title
|
126
126
|
multitask key => items
|
127
127
|
@parallel << key
|
128
128
|
|
129
|
-
s = task_join
|
130
|
-
task_desc("#{
|
129
|
+
s = task_join key, 'sync'
|
130
|
+
task_desc("#{title} (sync)", name: s) if title
|
131
131
|
task s => items
|
132
132
|
@sync << s
|
133
133
|
next
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
task_desc(
|
137
|
+
task_desc(title, name: key) if title
|
138
138
|
task key => items
|
139
139
|
end
|
140
140
|
@multiple.concat(sync)
|
@@ -3,8 +3,9 @@
|
|
3
3
|
module Squared
|
4
4
|
module Workspace
|
5
5
|
module Support
|
6
|
-
RunData = Struct.new(
|
7
|
-
ChainData = Struct.new(
|
6
|
+
RunData = Struct.new(:run, :block)
|
7
|
+
ChainData = Struct.new(:action, :step, :with, :before, :after, :sync)
|
8
|
+
BannerData = Struct.new(:command, :order, :styles, :border)
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|