squared 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ruby.md +30 -8
- data/lib/squared/common/base.rb +14 -8
- data/lib/squared/common/class.rb +5 -1
- data/lib/squared/common/format.rb +48 -45
- data/lib/squared/common/shell.rb +3 -3
- data/lib/squared/common/system.rb +35 -3
- data/lib/squared/common/task.rb +1 -9
- data/lib/squared/config.rb +3 -4
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +79 -83
- data/lib/squared/workspace/project/base.rb +100 -57
- data/lib/squared/workspace/project/git.rb +21 -21
- data/lib/squared/workspace/project/node.rb +62 -52
- data/lib/squared/workspace/project/python.rb +9 -16
- data/lib/squared/workspace/project/ruby.rb +211 -63
- data/lib/squared/workspace/project.rb +4 -0
- data/lib/squared/workspace/repo.rb +20 -16
- data/lib/squared/workspace/series.rb +14 -12
- data/lib/squared/workspace.rb +3 -1
- metadata +2 -2
@@ -4,11 +4,11 @@ module Squared
|
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
6
|
class Ruby < Git
|
7
|
-
REF = :ruby
|
8
7
|
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
|
9
|
-
OPT_INSTALL = %w[no-cache force
|
10
|
-
OPT_UPDATE = %w[redownload local strict conservative group=s
|
11
|
-
|
8
|
+
OPT_INSTALL = %w[no-cache force].freeze
|
9
|
+
OPT_UPDATE = %w[redownload local strict conservative group=s].freeze
|
10
|
+
OPT_OUTDATED = %w[local strict pre only-explicit group=s].freeze
|
11
|
+
private_constant :GEMFILE, :OPT_INSTALL, :OPT_UPDATE, :OPT_OUTDATED
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def populate(*); end
|
@@ -26,32 +26,34 @@ module Squared
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
@@tasks[
|
30
|
-
install: %i[redownload local prefer-local with
|
29
|
+
@@tasks[ref] = {
|
30
|
+
install: %i[redownload local prefer-local gem with without],
|
31
31
|
update: %i[all patch minor major],
|
32
|
-
|
32
|
+
outdated: %i[patch minor major],
|
33
|
+
pristine: %i[gem all version],
|
34
|
+
exec: nil,
|
35
|
+
config: nil,
|
33
36
|
rake: nil
|
34
37
|
}.freeze
|
35
38
|
|
36
39
|
attr_reader :gemfile
|
37
40
|
|
38
|
-
def initialize(
|
41
|
+
def initialize(*, version: nil, autodetect: false, **kwargs)
|
39
42
|
super
|
40
|
-
initialize_build(
|
41
|
-
@version = env('BUILD', suffix: 'VERSION', strict: true)
|
43
|
+
initialize_build(Ruby.ref, **kwargs)
|
44
|
+
@version = env('BUILD', version, suffix: 'VERSION', strict: true)
|
42
45
|
@autodetect = autodetect
|
43
46
|
index = GEMFILE.index { |file| base_path(file).exist? } || 0
|
44
47
|
@gemfile = base_path(GEMFILE[index])
|
45
48
|
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || (file = rakefile).nil?
|
46
49
|
|
47
50
|
begin
|
48
|
-
pat = %r{\brequire\s+(["'])bundler/gem_tasks\1}
|
49
51
|
File.foreach(file) do |line|
|
50
|
-
next unless line =~
|
52
|
+
next unless line =~ %r{\brequire\s+(["'])bundler/gem_tasks\1}
|
51
53
|
|
52
54
|
@output[0] = 'bundle exec rake build'
|
53
55
|
@copy = 'bundle exec rake install'
|
54
|
-
@clean
|
56
|
+
@clean = 'bundle exec rake clean' if @clean.nil?
|
55
57
|
break
|
56
58
|
end
|
57
59
|
rescue StandardError => e
|
@@ -61,18 +63,23 @@ module Squared
|
|
61
63
|
|
62
64
|
def populate(*)
|
63
65
|
super
|
64
|
-
return unless outdated?
|
66
|
+
return unless outdated? && !@exclude.include?(Ruby.ref)
|
65
67
|
|
66
68
|
namespace name do
|
67
|
-
@@tasks[
|
69
|
+
@@tasks[Ruby.ref].each do |action, flags|
|
68
70
|
if flags.nil?
|
69
71
|
case action
|
72
|
+
when :exec, :config
|
73
|
+
desc format_desc(action, nil, 'command+')
|
74
|
+
task action, [:command] do |_, args|
|
75
|
+
bundle(action, args.to_a)
|
76
|
+
end
|
70
77
|
when :rake
|
71
78
|
next unless rakefile
|
72
79
|
|
73
80
|
desc format_desc(action, nil, 'command*')
|
74
81
|
task action, [:command] do |_, args|
|
75
|
-
rake
|
82
|
+
rake args.to_a
|
76
83
|
end
|
77
84
|
end
|
78
85
|
else
|
@@ -81,26 +88,51 @@ module Squared
|
|
81
88
|
case action
|
82
89
|
when :install
|
83
90
|
case flag
|
84
|
-
when :
|
91
|
+
when :gem
|
92
|
+
desc format_desc(action, flag, 'name+')
|
93
|
+
task flag, [:name] do |_, args|
|
94
|
+
name = args.to_a
|
95
|
+
guard_params(action, flag, args: name)
|
96
|
+
depend(flag, opts: name, override: true)
|
97
|
+
end
|
98
|
+
when :with, :without
|
85
99
|
desc format_desc(action, flag, 'group+')
|
86
100
|
task flag, [:group] do |_, args|
|
87
|
-
|
101
|
+
group = args.to_a
|
102
|
+
guard_params(action, flag, args: group)
|
103
|
+
depend(flag, opts: group, override: true)
|
88
104
|
end
|
89
105
|
else
|
90
106
|
desc format_desc(action, flag, OPT_INSTALL)
|
91
107
|
task flag, [:opts] do |_, args|
|
92
|
-
depend(flag, opts:
|
108
|
+
depend(flag, opts: args.to_a, override: true)
|
93
109
|
end
|
94
110
|
end
|
95
|
-
when :update
|
96
|
-
desc format_desc(action, flag, OPT_UPDATE)
|
111
|
+
when :update, :outdated
|
112
|
+
desc format_desc(action, flag, action == :update ? OPT_UPDATE : OPT_OUTDATED)
|
97
113
|
task flag, [:opts] do |_, args|
|
98
|
-
|
114
|
+
__send__(action, flag, opts: args.to_a)
|
99
115
|
end
|
100
116
|
when :pristine
|
101
|
-
|
102
|
-
|
103
|
-
|
117
|
+
case flag
|
118
|
+
when :gem
|
119
|
+
desc format_desc(action, flag, 'name+')
|
120
|
+
task flag, [:name] do |_, args|
|
121
|
+
name = args.to_a
|
122
|
+
guard_params(action, flag, args: name)
|
123
|
+
pristine(flag, opts: name)
|
124
|
+
end
|
125
|
+
when :all
|
126
|
+
desc format_desc(action, flag, 'skip*')
|
127
|
+
task flag, [:skip] do |_, args|
|
128
|
+
pristine(flag, opts: args.to_a)
|
129
|
+
end
|
130
|
+
when :version
|
131
|
+
desc format_desc(action, flag, 'version?')
|
132
|
+
task flag, [:version] do |_, args|
|
133
|
+
guard_params(action, flag, args: args, key: :version)
|
134
|
+
pristine(flag, version: args.version)
|
135
|
+
end
|
104
136
|
end
|
105
137
|
end
|
106
138
|
end
|
@@ -110,7 +142,7 @@ module Squared
|
|
110
142
|
end
|
111
143
|
end
|
112
144
|
|
113
|
-
def depend(flag = nil, opts: [],
|
145
|
+
def depend(flag = nil, opts: [], override: false)
|
114
146
|
if @depend && !override
|
115
147
|
super
|
116
148
|
elsif outdated?
|
@@ -134,16 +166,17 @@ module Squared
|
|
134
166
|
end}"
|
135
167
|
end
|
136
168
|
append_bundle opts, OPT_INSTALL
|
137
|
-
when :
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
169
|
+
when :gem
|
170
|
+
gem_session 'install'
|
171
|
+
append_value opts
|
172
|
+
when :with, :without
|
173
|
+
gem_session 'install'
|
174
|
+
append_repeat flag, opts
|
142
175
|
else
|
143
|
-
|
176
|
+
bundle_session 'install'
|
144
177
|
append_bundle
|
145
178
|
end
|
146
|
-
|
179
|
+
run_rb
|
147
180
|
end
|
148
181
|
end
|
149
182
|
|
@@ -169,28 +202,136 @@ module Squared
|
|
169
202
|
end
|
170
203
|
end
|
171
204
|
|
172
|
-
def outdated(
|
205
|
+
def outdated(rev = nil, opts: [])
|
206
|
+
cmd = bundle_session 'outdated', rev && "--#{rev}"
|
207
|
+
append_bundle opts, OPT_OUTDATED
|
208
|
+
cmd = cmd.done
|
209
|
+
log.info cmd
|
210
|
+
print_item format_banner(cmd) if store_pwd || invoked_sync?("outdated#{rev ? ":#{rev}" : ''}")
|
211
|
+
start = 0
|
212
|
+
found = 0
|
213
|
+
major = 0
|
214
|
+
IO.popen("#{cmd} --no-color").each do |line|
|
215
|
+
if start > 0
|
216
|
+
unless pipe?
|
217
|
+
data = line.scan(SEM_VER)
|
218
|
+
cur = data.shift
|
219
|
+
lat = data.shift
|
220
|
+
if cur && lat
|
221
|
+
semver(cur)
|
222
|
+
semver(lat)
|
223
|
+
c = cur.join
|
224
|
+
l = lat.join
|
225
|
+
styles = []
|
226
|
+
data.each do |val|
|
227
|
+
break unless styles && (req = /(>?=|~>|!=|<=?) (#{Regexp.escape(val.join)})/.match(line))
|
228
|
+
|
229
|
+
v = semver(val).join
|
230
|
+
case req[1]
|
231
|
+
when '>', '>='
|
232
|
+
if c == l
|
233
|
+
styles = nil
|
234
|
+
elsif l < v
|
235
|
+
styles = %i[red underline]
|
236
|
+
break
|
237
|
+
elsif semmajor(cur, lat)
|
238
|
+
styles = %i[green underline]
|
239
|
+
major += 1
|
240
|
+
elsif cur[3] != lat[3]
|
241
|
+
styles = %i[green bold]
|
242
|
+
else
|
243
|
+
styles[0] = :green
|
244
|
+
end
|
245
|
+
when '<', '<='
|
246
|
+
if c <= v
|
247
|
+
if semmajor(cur, lat)
|
248
|
+
styles = %i[green underline]
|
249
|
+
major += 1
|
250
|
+
else
|
251
|
+
styles[0] = :yellow
|
252
|
+
end
|
253
|
+
elsif l >= v
|
254
|
+
styles = nil
|
255
|
+
end
|
256
|
+
when '!='
|
257
|
+
if c == v
|
258
|
+
styles = %i[red underline]
|
259
|
+
break
|
260
|
+
elsif l == v
|
261
|
+
styles = nil
|
262
|
+
else
|
263
|
+
styles[1] = :bold
|
264
|
+
end
|
265
|
+
when '~>'
|
266
|
+
if c < v && cur[0] == val[0] && !semmajor(cur, val)
|
267
|
+
styles[0] = :yellow
|
268
|
+
elsif semmajor(lat, val)
|
269
|
+
styles = nil
|
270
|
+
else
|
271
|
+
styles[1] = :bold
|
272
|
+
end
|
273
|
+
when '='
|
274
|
+
if c == v
|
275
|
+
styles[1] = :underline
|
276
|
+
else
|
277
|
+
styles[0] = :red
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
next unless styles && !styles.empty?
|
173
282
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
283
|
+
case styles[0]
|
284
|
+
when :yellow, :green
|
285
|
+
line = sub_style(line, pat: /^(\S+)(.+)$/, styles: theme[:active])
|
286
|
+
found += 1
|
287
|
+
end
|
288
|
+
line = sub_style(line, pat: /^((?:\S+\s+){2})(#{Regexp.escape(l)})(.+)$/,
|
289
|
+
styles: styles.compact, index: 2)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
puts "#{start.to_s.rjust(2)}. #{line}"
|
293
|
+
start += 1
|
294
|
+
elsif line =~ /^Gem /
|
295
|
+
unless pipe?
|
296
|
+
puts print_footer(" # #{line.chomp}", reverse: true, sub: [
|
297
|
+
{ pat: /^(.+)(Gem)(.+)$/, styles: theme[:header], index: 2 },
|
298
|
+
{ pat: /^(.+)(Latest)(.+)$/, styles: theme[:header], index: 2 }
|
299
|
+
])
|
300
|
+
end
|
301
|
+
start += 1
|
302
|
+
end
|
303
|
+
end
|
304
|
+
if found > 0
|
305
|
+
puts print_footer(empty_status('Updates are available', 'major', major, always: true))
|
306
|
+
elsif start == 0
|
307
|
+
puts 'No updates were found'
|
179
308
|
end
|
309
|
+
store_pwd true
|
310
|
+
end
|
311
|
+
|
312
|
+
def update(flag, opts: [])
|
313
|
+
bundle_session 'update', "--#{flag}"
|
180
314
|
append_bundle opts, OPT_UPDATE
|
181
|
-
|
315
|
+
run_rb
|
182
316
|
end
|
183
317
|
|
184
|
-
def pristine(flag, version: nil)
|
185
|
-
cmd = gem_session 'pristine'
|
318
|
+
def pristine(flag, version: nil, opts: [])
|
319
|
+
cmd = gem_session 'pristine'
|
186
320
|
case flag
|
187
|
-
when :
|
188
|
-
|
321
|
+
when :gem
|
322
|
+
append_value opts
|
323
|
+
when :all
|
324
|
+
cmd << '--all'
|
325
|
+
append_repeat 'skip', opts
|
189
326
|
when :version
|
190
|
-
|
327
|
+
cmd << project << "--version=#{shell_escape(version)}"
|
191
328
|
end
|
192
|
-
|
193
|
-
|
329
|
+
run_rb
|
330
|
+
end
|
331
|
+
|
332
|
+
def bundle(flag, cmd)
|
333
|
+
guard_params('bundle', flag, args: cmd)
|
334
|
+
run_s "bundle #{flag} #{cmd.join(' ')}"
|
194
335
|
end
|
195
336
|
|
196
337
|
def rake(cmd)
|
@@ -210,9 +351,8 @@ module Squared
|
|
210
351
|
return true if @copy.is_a?(::String) || @copy&.fetch(:gemdir, nil)
|
211
352
|
return gemdir? if @gemdir
|
212
353
|
|
213
|
-
gempath = -> { "gems#{::File::SEPARATOR}#{project}-#{@version}" }
|
214
354
|
if @version && (val = ENV['GEM_HOME'])
|
215
|
-
@gemdir = Pathname.new(val).join(gempath
|
355
|
+
@gemdir = Pathname.new(val).join(gempath)
|
216
356
|
return true if gemdir?
|
217
357
|
end
|
218
358
|
return false unless @autodetect
|
@@ -236,7 +376,7 @@ module Squared
|
|
236
376
|
break
|
237
377
|
end
|
238
378
|
unsafe.('path') unless data
|
239
|
-
@gemdir = Pathname.new(data[1].strip).join(gempath
|
379
|
+
@gemdir = Pathname.new(data[1].strip).join(gempath)
|
240
380
|
rescue StandardError => e
|
241
381
|
log.error e
|
242
382
|
@version = nil
|
@@ -247,38 +387,46 @@ module Squared
|
|
247
387
|
end
|
248
388
|
end
|
249
389
|
|
250
|
-
def depend?
|
251
|
-
outdated? || !!@depend
|
252
|
-
end
|
253
|
-
|
254
390
|
def outdated?
|
255
391
|
gemfile.exist?
|
256
392
|
end
|
257
393
|
|
258
|
-
def dev?
|
259
|
-
@dev
|
260
|
-
end
|
261
|
-
|
262
394
|
private
|
263
395
|
|
396
|
+
def run_rb
|
397
|
+
run(banner: !@session.include?('--quiet'))
|
398
|
+
end
|
399
|
+
|
264
400
|
def append_bundle(opts = nil, list = nil)
|
265
401
|
if (val = env('BUNDLE_JOBS')).to_i > 0
|
266
402
|
@session << "-j#{val}"
|
267
403
|
end
|
268
|
-
@session << '--norc' if env('BUNDLE_NORC')
|
269
404
|
return unless opts && list
|
270
405
|
|
271
406
|
opts.each do |opt|
|
272
407
|
if list.include?(opt)
|
273
408
|
@session << "--#{opt}"
|
274
409
|
elsif opt.match(/^g(?:roup)?=(.+)$/)
|
275
|
-
@session << "--group=#{shell_escape($1
|
410
|
+
@session << "--group=#{shell_escape($1)}"
|
276
411
|
end
|
277
412
|
end
|
278
413
|
end
|
279
414
|
|
415
|
+
def append_repeat(flag, opts)
|
416
|
+
opts.each { |val| @session << "--#{flag}=#{shell_escape(val)}" }
|
417
|
+
end
|
418
|
+
|
419
|
+
def append_value(opts)
|
420
|
+
opts.each { |val| @session << val }
|
421
|
+
end
|
422
|
+
|
280
423
|
def gem_session(*cmd)
|
281
|
-
session('gem', *cmd)
|
424
|
+
ret = session('gem', *cmd)
|
425
|
+
if (val = env('GEM_CONFIG_FILE'))
|
426
|
+
ret << "--config-file=#{shell_escape(base_path(val).to_s, quote: true)}"
|
427
|
+
end
|
428
|
+
ret << '--norc' if env('GEM_NORC')
|
429
|
+
ret
|
282
430
|
end
|
283
431
|
|
284
432
|
def bundle_session(*cmd)
|
@@ -286,8 +434,8 @@ module Squared
|
|
286
434
|
append_nocolor
|
287
435
|
end
|
288
436
|
|
289
|
-
def
|
290
|
-
|
437
|
+
def gempath
|
438
|
+
File.join('gems', "#{project}-#{@version}")
|
291
439
|
end
|
292
440
|
|
293
441
|
def gemdir?
|
@@ -6,14 +6,13 @@ module Squared
|
|
6
6
|
include Common
|
7
7
|
include Format
|
8
8
|
include System
|
9
|
-
include Task
|
10
9
|
|
11
10
|
attr_accessor :warning
|
12
11
|
|
13
|
-
def repo(url, manifest = 'latest', run: nil, dev: nil, prod: nil)
|
12
|
+
def repo(url, manifest = 'latest', run: nil, dev: nil, prod: nil, ref: @ref, group: @group)
|
14
13
|
@home = if (val = env('REPO_HOME'))
|
15
14
|
home = Pathname.new(val)
|
16
|
-
if
|
15
|
+
if main == home.basename.to_s
|
17
16
|
@root = home.parent
|
18
17
|
if home.exist?
|
19
18
|
@root = nil unless home.directory?
|
@@ -33,9 +32,9 @@ module Squared
|
|
33
32
|
elsif !install?
|
34
33
|
raise_error('REPO_ROOT', val, hint: 'exist') unless confirm_install
|
35
34
|
end
|
36
|
-
@root.join(
|
35
|
+
@root.join(main).realdirpath
|
37
36
|
else
|
38
|
-
install?(pwd = Pathname.pwd) ? pwd.join(
|
37
|
+
install?(pwd = Pathname.pwd) ? pwd.join(main) : pwd
|
39
38
|
end
|
40
39
|
@root = @home.parent
|
41
40
|
@manifest_url = url
|
@@ -44,7 +43,7 @@ module Squared
|
|
44
43
|
@script[:build] = case (val = env('REPO_BUILD'))
|
45
44
|
when 'verbose'
|
46
45
|
@verbose = true
|
47
|
-
"#{run}:verbose"
|
46
|
+
run.is_a?(String) ? "#{run}:verbose" : run
|
48
47
|
when 'silent'
|
49
48
|
@verbose = false
|
50
49
|
@warning = false
|
@@ -54,19 +53,23 @@ module Squared
|
|
54
53
|
end
|
55
54
|
@script[:dev] = bool_match(env('REPO_DEV'), dev)
|
56
55
|
@script[:prod] = bool_match(env('REPO_PROD'), prod)
|
56
|
+
@script[:ref][:_] = env('REPO_REF', ref)
|
57
|
+
@script[:group][:_] = env('REPO_GROUP', group)
|
57
58
|
@warning = case env('REPO_WARN')
|
58
59
|
when '0'
|
59
60
|
false
|
60
61
|
when '1'
|
61
62
|
true
|
62
63
|
else
|
63
|
-
!empty?(@root)
|
64
|
+
@warning && !empty?(@root)
|
64
65
|
end
|
65
66
|
@extensions << :__repo__
|
66
67
|
else
|
67
68
|
@script[:build] = run
|
68
69
|
@script[:dev] = dev
|
69
70
|
@script[:prod] = prod
|
71
|
+
@script[:ref][:_] = ref
|
72
|
+
@script[:group][:_] = group
|
70
73
|
end
|
71
74
|
self
|
72
75
|
end
|
@@ -93,7 +96,7 @@ module Squared
|
|
93
96
|
cmd = []
|
94
97
|
newline = ARGV.index { |val| val.start_with?('repo:') }.to_i > 0
|
95
98
|
parse_opts = lambda do |args|
|
96
|
-
|
99
|
+
args.to_a.each do |val|
|
97
100
|
case val
|
98
101
|
when 'no-fail'
|
99
102
|
failfast = false
|
@@ -122,10 +125,10 @@ module Squared
|
|
122
125
|
stage ||= 'all'
|
123
126
|
repo['sync'].invoke
|
124
127
|
@project.select do |_, proj|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
128
|
+
next unless proj.enabled?
|
129
|
+
|
130
|
+
proj.depend if proj.depend?
|
131
|
+
proj.build?
|
129
132
|
end
|
130
133
|
.each_value { |proj| proj.has?(:dev) ? proj.refresh : proj.build }
|
131
134
|
end
|
@@ -166,12 +169,13 @@ module Squared
|
|
166
169
|
end
|
167
170
|
|
168
171
|
def confirm_install
|
169
|
-
return false unless
|
172
|
+
return false unless root.directory?
|
170
173
|
|
174
|
+
path = sub_style(root, styles: theme[:inline])
|
171
175
|
@override = confirm(
|
172
|
-
"#{log_title(:warn)} \"#{
|
176
|
+
"#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation? [y/N] ",
|
173
177
|
default: 'N',
|
174
|
-
timeout: env('REPO_TIMEOUT', ignore: '0'
|
178
|
+
timeout: env('REPO_TIMEOUT', 15, ignore: '0')
|
175
179
|
)
|
176
180
|
end
|
177
181
|
|
@@ -188,7 +192,7 @@ module Squared
|
|
188
192
|
end
|
189
193
|
end
|
190
194
|
|
191
|
-
def install?(dir =
|
195
|
+
def install?(dir = root)
|
192
196
|
return true if empty?(dir) || dir.join('.repo').directory?
|
193
197
|
return false unless dir == root && env('REPO_HOME').nil? && !env('REPO_ROOT').nil?
|
194
198
|
|
@@ -8,18 +8,17 @@ module Squared
|
|
8
8
|
include ::Rake::DSL
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
attr_reader :
|
11
|
+
attr_reader :sync, :multiple, :parallel
|
12
12
|
|
13
|
-
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :to_a, :to_s, :inspect, :merge!, :key
|
13
|
+
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :to_a, :to_s, :inspect, :merge!, :key?
|
14
14
|
|
15
|
-
def initialize(tasks,
|
15
|
+
def initialize(tasks, keys: Workspace::Application::WORKSPACE_KEYS)
|
16
16
|
if tasks.is_a?(Array)
|
17
17
|
@data = {}
|
18
18
|
tasks.each { |key| __set__ key }
|
19
19
|
else
|
20
20
|
@data = tasks.dup
|
21
21
|
end
|
22
|
-
@workspace = workspace
|
23
22
|
@keys = keys
|
24
23
|
@sync = []
|
25
24
|
@multiple = []
|
@@ -39,6 +38,7 @@ module Squared
|
|
39
38
|
return unless @session
|
40
39
|
|
41
40
|
group, parent, id = @session.values
|
41
|
+
workspace = proj.workspace
|
42
42
|
each do |key, items|
|
43
43
|
target = "#{proj.name}:#{key}"
|
44
44
|
if @keys.include?(key)
|
@@ -46,25 +46,23 @@ module Squared
|
|
46
46
|
else
|
47
47
|
next unless workspace.task_include?(proj, key)
|
48
48
|
end
|
49
|
+
next unless workspace.task_defined?(target)
|
50
|
+
|
49
51
|
if (g = proj.group)
|
50
52
|
id << g
|
51
53
|
(group[:"#{key}:#{g}"] ||= []).push(target)
|
52
54
|
else
|
53
55
|
items << target
|
54
56
|
end
|
55
|
-
next unless (b = find_base(proj)) && (name = b.
|
57
|
+
next unless (b = find_base(proj)) && (name = b.ref.to_s) != g
|
56
58
|
|
57
59
|
id << name
|
58
60
|
(parent[:"#{key}:#{name}"] ||= []).push(target)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
|
-
def
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def finalize!(thread = [])
|
67
|
-
thread.map!(&:to_s)
|
64
|
+
def build(**kwargs)
|
65
|
+
thread = kwargs.fetch(:parallel, []).map(&:to_s)
|
68
66
|
group, parent, id = @session.values
|
69
67
|
merge!(parent) if id.uniq.size > 1
|
70
68
|
merge!(group)
|
@@ -93,6 +91,10 @@ module Squared
|
|
93
91
|
@session = nil
|
94
92
|
end
|
95
93
|
|
94
|
+
def method_missing(key, *)
|
95
|
+
self[key]
|
96
|
+
end
|
97
|
+
|
96
98
|
def has?(key)
|
97
99
|
!key.nil? && key?(key = key.to_sym) && !self[key].empty?
|
98
100
|
end
|
@@ -116,7 +118,7 @@ module Squared
|
|
116
118
|
private
|
117
119
|
|
118
120
|
def already_invoked?(list, val)
|
119
|
-
return list.include?(val) && invoked?(val) if val
|
121
|
+
return list.include?(val) && Common::Task.invoked?(val) if val
|
120
122
|
|
121
123
|
::Rake::Task.tasks.any? { |item| item.already_invoked && list.include?(item.name) }
|
122
124
|
end
|
data/lib/squared/workspace.rb
CHANGED
@@ -5,6 +5,8 @@ require_relative 'common'
|
|
5
5
|
module Squared
|
6
6
|
module Workspace
|
7
7
|
class << self
|
8
|
+
include Common
|
9
|
+
|
8
10
|
def resolve(*args)
|
9
11
|
ret = args.map do |id|
|
10
12
|
if id.is_a?(::Symbol)
|
@@ -21,7 +23,7 @@ module Squared
|
|
21
23
|
ret = project(name)
|
22
24
|
return ret if ret&.path&.directory?
|
23
25
|
|
24
|
-
raise NoMethodError,
|
26
|
+
raise NoMethodError, message('project is not initialized', hint: name)
|
25
27
|
end
|
26
28
|
|
27
29
|
def project?(name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|