squared 0.4.7 → 0.4.8
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 +30 -0
- data/README.ruby.md +16 -0
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/class.rb +19 -1
- data/lib/squared/common/format.rb +25 -21
- data/lib/squared/common/prompt.rb +39 -1
- data/lib/squared/common/shell.rb +12 -8
- data/lib/squared/common/system.rb +1 -1
- data/lib/squared/common/utils.rb +11 -10
- data/lib/squared/config.rb +1 -2
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +36 -20
- data/lib/squared/workspace/project/base.rb +125 -48
- data/lib/squared/workspace/project/docker.rb +64 -23
- data/lib/squared/workspace/project/git.rb +111 -65
- data/lib/squared/workspace/project/node.rb +22 -37
- data/lib/squared/workspace/project/python.rb +7 -7
- data/lib/squared/workspace/project/ruby.rb +227 -39
- data/lib/squared/workspace/project/support/class.rb +11 -9
- data/lib/squared/workspace/repo.rb +6 -8
- data/lib/squared/workspace/series.rb +6 -5
- data/lib/squared/workspace.rb +1 -8
- metadata +2 -2
@@ -7,6 +7,9 @@ module Squared
|
|
7
7
|
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
|
8
8
|
DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
|
9
9
|
OPT_RUBY = {
|
10
|
+
ruby: %w[a c l n p s S w d|debug jit rjit v|verbose y|yydebug 0=im? backtrace-limit=i crash-report=q
|
11
|
+
disable=q dump=q e=q enable=q encoding=b external-encoding=b Eex=m? F=qm i=m? internal-encoding=b
|
12
|
+
I=pm parser=b r=bm W=bm? x=pm?].freeze,
|
10
13
|
rake: %w[A|all B|build-all comments n|dry-run p|execute-print=q m|multitask P|prereqs q|quiet
|
11
14
|
X|no-deprecation-warnings N|no-search G|no-system nosearch nosystem rules s|silent g|system
|
12
15
|
v|verbose backtrace=b? D|describe=q? e|execute=q E|execute-continue=q I|libdir=p job-stats=b?
|
@@ -78,6 +81,7 @@ module Squared
|
|
78
81
|
'update' => %i[patch minor major all].freeze,
|
79
82
|
'outdated' => %i[patch minor major].freeze,
|
80
83
|
'gem' => %i[install uninstall update pristine outdated push build exec].freeze,
|
84
|
+
'ruby' => %i[file script version].freeze,
|
81
85
|
'exec' => nil,
|
82
86
|
'cache' => nil,
|
83
87
|
'config' => nil,
|
@@ -124,7 +128,7 @@ module Squared
|
|
124
128
|
return unless outdated? && ref?(Ruby.ref)
|
125
129
|
|
126
130
|
namespace name do
|
127
|
-
|
131
|
+
Ruby.subtasks do |action, flags|
|
128
132
|
next if @pass.include?(action)
|
129
133
|
|
130
134
|
if flags.nil?
|
@@ -182,16 +186,54 @@ module Squared
|
|
182
186
|
end
|
183
187
|
when 'gem'
|
184
188
|
case flag
|
185
|
-
when :outdated
|
189
|
+
when :outdated
|
190
|
+
format_desc action, flag, 'major|minor|patch|(i)nteractive?,opts*'
|
191
|
+
task flag, [:semver] do |_, args|
|
192
|
+
case (filter = args.semver)
|
193
|
+
when 'major', 'minor', 'patch', 'interactive', 'i'
|
194
|
+
filter = 'interactive' if filter == 'i'
|
195
|
+
args = args.to_a.drop(1)
|
196
|
+
else
|
197
|
+
filter = nil
|
198
|
+
args = args.to_a
|
199
|
+
end
|
200
|
+
gem!(flag, args, filter: filter)
|
201
|
+
end
|
202
|
+
when :build, :push, :exec
|
186
203
|
format_desc(action, flag, 'opts*', before: flag == :exec ? 'command+' : nil)
|
187
204
|
task flag do |_, args|
|
188
|
-
|
205
|
+
gem! flag, args.to_a
|
189
206
|
end
|
190
207
|
else
|
191
208
|
format_desc action, flag, "opts*,name+#{flag == :pristine ? '|name?@version' : ''}"
|
192
209
|
task flag do |_, args|
|
193
210
|
opts = param_guard(action, flag, args: args.to_a)
|
194
|
-
|
211
|
+
gem! flag, opts
|
212
|
+
end
|
213
|
+
end
|
214
|
+
when 'ruby'
|
215
|
+
case flag
|
216
|
+
when :file
|
217
|
+
format_desc action, flag, 'path,opts*,args*'
|
218
|
+
task flag, [:rb] do |_, args|
|
219
|
+
file = param_guard(action, flag, args: args, key: :rb)
|
220
|
+
ruby(flag, args.to_a.drop(1), file: file)
|
221
|
+
end
|
222
|
+
when :script
|
223
|
+
format_desc action, flag, 'command|RUBY_E,opts*,args*'
|
224
|
+
task flag, [:e] do |_, args|
|
225
|
+
if (command = ENV['RUBY_E'])
|
226
|
+
opts = args.to_a
|
227
|
+
else
|
228
|
+
command = param_guard(action, flag, args: args, key: :e)
|
229
|
+
opts = args.to_a.drop(1)
|
230
|
+
end
|
231
|
+
ruby(flag, opts, command: command)
|
232
|
+
end
|
233
|
+
when :version
|
234
|
+
format_desc action, flag
|
235
|
+
task flag do
|
236
|
+
ruby flag
|
195
237
|
end
|
196
238
|
end
|
197
239
|
end
|
@@ -279,7 +321,7 @@ module Squared
|
|
279
321
|
end
|
280
322
|
minor_set = -> { styles[0] = cur[2] == lat[2] ? :yellow : :green }
|
281
323
|
if data.empty?
|
282
|
-
semmajor?(cur, lat) ? major_set.
|
324
|
+
semmajor?(cur, lat) ? major_set.call : minor_set.call
|
283
325
|
else
|
284
326
|
data.each do |val|
|
285
327
|
break unless line =~ /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/
|
@@ -287,11 +329,11 @@ module Squared
|
|
287
329
|
v = semver(val).join
|
288
330
|
case $1
|
289
331
|
when '>', '>='
|
290
|
-
semmajor?(cur, lat) ? major_set.
|
332
|
+
semmajor?(cur, lat) ? major_set.call : minor_set.call
|
291
333
|
when '<', '<='
|
292
334
|
if c <= v
|
293
335
|
if semmajor?(cur, lat)
|
294
|
-
major_set.
|
336
|
+
major_set.call
|
295
337
|
else
|
296
338
|
styles[0] = :yellow
|
297
339
|
end
|
@@ -329,11 +371,11 @@ module Squared
|
|
329
371
|
index: 2)
|
330
372
|
end
|
331
373
|
end
|
332
|
-
out.("#{start.to_s.rjust(2)}. #{line}")
|
374
|
+
out.call("#{start.to_s.rjust(2)}. #{line}")
|
333
375
|
elsif line.start_with?('Gem')
|
334
376
|
unless stdin?
|
335
377
|
sub = { pat: /^(.+)(?<!\dm)(Gem|Latest)(.+)$/, styles: theme[:header], index: 2 }
|
336
|
-
out.(print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub]))
|
378
|
+
out.call(print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub]))
|
337
379
|
end
|
338
380
|
else
|
339
381
|
next
|
@@ -376,7 +418,96 @@ module Squared
|
|
376
418
|
run_rb(from: :update)
|
377
419
|
end
|
378
420
|
|
379
|
-
def
|
421
|
+
def ruby(flag, opts = [], file: nil, command: nil)
|
422
|
+
case flag
|
423
|
+
when :file, :script
|
424
|
+
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
425
|
+
if file
|
426
|
+
op.extras.unshift(shell_quote(basepath(file)))
|
427
|
+
elsif command
|
428
|
+
op << quote_option('e', command, option: false)
|
429
|
+
end
|
430
|
+
if (args = ENV['RUBY_ARGS'])
|
431
|
+
op.extras << args
|
432
|
+
end
|
433
|
+
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
434
|
+
when :version
|
435
|
+
pwd_set do
|
436
|
+
out = []
|
437
|
+
[
|
438
|
+
'$HOME/.rvm/bin/rvm',
|
439
|
+
'/usr/local/rvm/bin/rvm',
|
440
|
+
'/usr/share/rvm/bin/rvm',
|
441
|
+
"#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
|
442
|
+
'/usr/bin/rbenv',
|
443
|
+
'/usr/local/share/chruby/chruby.sh',
|
444
|
+
"#{ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf')}/plugins/ruby/bin/install",
|
445
|
+
''
|
446
|
+
].each do |val|
|
447
|
+
next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
|
448
|
+
|
449
|
+
trim = ->(s) { s[/^\D+\d+\.\d+(?:\.\S+)?/, 0].sub(/^([a-z]+)-/i, '\1 ') }
|
450
|
+
ver = '.ruby-version'
|
451
|
+
out << trim.call(case (cmd = File.basename(val))
|
452
|
+
when 'rvm'
|
453
|
+
`rvm current`[/^\S+/, 0]
|
454
|
+
when 'rbenv'
|
455
|
+
name = `rbenv version-name`
|
456
|
+
name =~ SEM_VER ? "ruby #{name}" : name
|
457
|
+
when 'chruby.sh'
|
458
|
+
chruby = session_output 'source', val
|
459
|
+
`#{chruby.with('ruby --version')}`
|
460
|
+
when 'install'
|
461
|
+
ver = '.tool-versions'
|
462
|
+
`asdf current ruby`[/ruby\s+\S+/, 0].sub(/\s+/, ' ')
|
463
|
+
else
|
464
|
+
ver = nil
|
465
|
+
`ruby --version`
|
466
|
+
end)
|
467
|
+
unless val.empty?
|
468
|
+
out << trim.call(case cmd
|
469
|
+
when 'chruby.sh'
|
470
|
+
`#{chruby.with('chruby --version')}`.sub(':', '')
|
471
|
+
when 'install'
|
472
|
+
"asdf #{`asdf version`.sub(/^v/, '')}"
|
473
|
+
else
|
474
|
+
`#{cmd} --version`
|
475
|
+
end)
|
476
|
+
end
|
477
|
+
begin
|
478
|
+
out << ('which %s' % case cmd
|
479
|
+
when 'rbenv'
|
480
|
+
`rbenv which ruby`
|
481
|
+
when 'chruby.sh'
|
482
|
+
`#{chruby.with('which ruby')}`
|
483
|
+
when 'install'
|
484
|
+
`asdf which ruby`
|
485
|
+
else
|
486
|
+
`which ruby`
|
487
|
+
end)
|
488
|
+
rescue StandardError => e
|
489
|
+
log.debug e
|
490
|
+
end
|
491
|
+
if ver
|
492
|
+
path.ascend do |ent|
|
493
|
+
next unless (ent = ent.join(ver)).exist?
|
494
|
+
|
495
|
+
hint = File.read(ent).lines(chomp: true).reject(&:empty?).join(', ') rescue nil
|
496
|
+
out << message("found #{ent}", hint: hint)
|
497
|
+
end
|
498
|
+
end
|
499
|
+
break
|
500
|
+
end
|
501
|
+
out.map!(&:split)
|
502
|
+
pad = out.map(&:first).map!(&:size).max
|
503
|
+
puts(out.map! { |line| "#{line.first.rjust(pad)} #{line[1..-1].join(' ')}" })
|
504
|
+
end
|
505
|
+
return
|
506
|
+
end
|
507
|
+
run_rb(banner: op.arg?('v'), from: :"ruby:#{flag}")
|
508
|
+
end
|
509
|
+
|
510
|
+
def gem!(flag, opts = [], filter: nil)
|
380
511
|
cmd = gem_session
|
381
512
|
case flag
|
382
513
|
when :outdated
|
@@ -420,6 +551,10 @@ module Squared
|
|
420
551
|
op.clear
|
421
552
|
on :first, from
|
422
553
|
print_item format_banner(cmd.to_s)
|
554
|
+
major = 0
|
555
|
+
minor = 0
|
556
|
+
patch = 0
|
557
|
+
update = []
|
423
558
|
pwd_set(pass: !pwd.nil?, from: from) do
|
424
559
|
items = [[%w[Gem Current Latest], nil]]
|
425
560
|
IO.popen(cmd.done).each do |line|
|
@@ -427,9 +562,9 @@ module Squared
|
|
427
562
|
cur = semscan($2)
|
428
563
|
lat = semscan($3)
|
429
564
|
items << [$~.to_a.drop(1), if semmajor?(cur, lat)
|
430
|
-
|
565
|
+
1
|
431
566
|
else
|
432
|
-
cur[2] == lat[2] ?
|
567
|
+
cur[2] == lat[2] ? 3 : 2
|
433
568
|
end]
|
434
569
|
else
|
435
570
|
puts line
|
@@ -448,9 +583,7 @@ module Squared
|
|
448
583
|
e = b.size if b.size > e
|
449
584
|
f = c.size if c.size > f
|
450
585
|
end
|
451
|
-
|
452
|
-
minor = 0
|
453
|
-
patch = 0
|
586
|
+
j = 0
|
454
587
|
items.each_with_index do |item, i|
|
455
588
|
next if i == 0 && stdin?
|
456
589
|
|
@@ -464,33 +597,80 @@ module Squared
|
|
464
597
|
puts line
|
465
598
|
puts sub_style(ARG[:BORDER][1] * n, styles: borderstyle)
|
466
599
|
else
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
600
|
+
g = a.ljust(d)
|
601
|
+
pat = [/\A([^.]+\.)([^.]+\..+)\z/, /\A([^.]+\.[^.]+\.)(.+)\z/]
|
602
|
+
pre = b.start_with?('0.')
|
603
|
+
latest = [theme[:current]]
|
604
|
+
case item.last
|
605
|
+
when 1
|
606
|
+
case filter
|
607
|
+
when 'major'
|
608
|
+
update << a
|
609
|
+
when 'minor', 'patch'
|
610
|
+
next
|
611
|
+
end
|
612
|
+
g = sub_style(g, styles: theme[:major])
|
613
|
+
major += 1
|
614
|
+
styles = %i[green bold]
|
615
|
+
pat = pre ? pat.first : nil
|
616
|
+
latest << :bold
|
617
|
+
when 2
|
618
|
+
case filter
|
619
|
+
when 'major', 'minor'
|
620
|
+
update << a
|
621
|
+
when 'patch'
|
622
|
+
next
|
623
|
+
end
|
624
|
+
g = sub_style(g, styles: theme[:active])
|
625
|
+
minor += 1
|
626
|
+
styles = %i[green]
|
627
|
+
pat = pre ? pat.last : pat.first
|
477
628
|
else
|
629
|
+
case filter
|
630
|
+
when 'major', 'minor', 'patch'
|
631
|
+
update << a
|
632
|
+
end
|
478
633
|
patch += 1
|
634
|
+
styles = %i[yellow]
|
635
|
+
pat = pat.last
|
479
636
|
end
|
480
637
|
b = b.rjust(e)
|
481
|
-
b = sub_style(b, styles
|
482
|
-
|
483
|
-
|
638
|
+
b = sub_style(b, *colormap(styles), pat: pat, index: 2)
|
639
|
+
h = sub_style(c.rjust(f), styles: latest.flatten.compact, pat: pat, index: 2)
|
640
|
+
j += 1
|
641
|
+
puts "#{"#{j}.".rjust(pad)} #{g} #{b} #{h}"
|
642
|
+
update << a if filter == 'interactive' && confirm_outdated(a, c, item.last)
|
484
643
|
end
|
485
644
|
end
|
486
|
-
unless stdin?
|
487
|
-
status = print_footer("major #{major} / minor #{minor} / patch #{patch}", right: true).split("\n")
|
488
|
-
status[1] = sub_style(status[1], pat: /^( +major )(\d+)(.+)$/, styles: theme[:major], index: 2)
|
489
|
-
status[1] = sub_style(status[1], pat: /^(.+)(minor )(\d+)(.+)$/, styles: theme[:active], index: 3)
|
490
|
-
puts status
|
491
|
-
end
|
492
645
|
end
|
493
646
|
end
|
647
|
+
unless update.empty?
|
648
|
+
cmd = gem_output 'update', '-f'
|
649
|
+
if (val = option('document', prefix: 'gem', ignore: false))
|
650
|
+
cmd << case val
|
651
|
+
when '0', 'false'
|
652
|
+
'--no-document'
|
653
|
+
else
|
654
|
+
basic_option('document', val)
|
655
|
+
end
|
656
|
+
end
|
657
|
+
if (val = option('user-install', prefix: 'gem', ignore: false))
|
658
|
+
cmd << case val
|
659
|
+
when '0', 'false'
|
660
|
+
'--no-user-install'
|
661
|
+
else
|
662
|
+
'--user-install'
|
663
|
+
end
|
664
|
+
end
|
665
|
+
cmd.merge(update)
|
666
|
+
run(cmd, banner: false, from: :'gem:update')
|
667
|
+
end
|
668
|
+
unless stdin?
|
669
|
+
status = print_footer("major #{major} / minor #{minor} / patch #{patch}", right: true).split("\n")
|
670
|
+
status[1] = sub_style(status[1], pat: /^( +major )(\d+)(.+)$/, styles: theme[:major], index: 2)
|
671
|
+
status[1] = sub_style(status[1], pat: /^(.+)(minor )(\d+)(.+)$/, styles: theme[:active], index: 3)
|
672
|
+
puts status
|
673
|
+
end
|
494
674
|
on :last, from
|
495
675
|
return
|
496
676
|
when :build, :push
|
@@ -502,7 +682,7 @@ module Squared
|
|
502
682
|
end
|
503
683
|
elsif flag == :build
|
504
684
|
spec = [basepath("#{project}.gemspec"), basepath("#{name}.gemspec"), *Dir.glob(basepath('*.gemspec'))]
|
505
|
-
op << File.basename(spec) if (spec = spec.find { |
|
685
|
+
op << File.basename(spec) if (spec = spec.find { |file| File.exist?(file) })
|
506
686
|
end
|
507
687
|
when :exec
|
508
688
|
raise_error('missing command', hint: flag) if op.empty?
|
@@ -600,7 +780,7 @@ module Squared
|
|
600
780
|
ver.each do |val|
|
601
781
|
next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
|
602
782
|
|
603
|
-
set.(val, $1)
|
783
|
+
set.call(val, $1)
|
604
784
|
break
|
605
785
|
end
|
606
786
|
end
|
@@ -612,14 +792,14 @@ module Squared
|
|
612
792
|
|
613
793
|
lib = Regexp.new(['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
|
614
794
|
if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
|
615
|
-
set.(ver, val)
|
795
|
+
set.call(ver, val)
|
616
796
|
end
|
617
797
|
end
|
618
798
|
if RUBY_VERSION >= '2.6'
|
619
799
|
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
620
|
-
parse.(target.resolve_feature_path(project)&.last)
|
800
|
+
parse.call(target.resolve_feature_path(project)&.last)
|
621
801
|
end
|
622
|
-
pwd_set { parse.(`#{bundle_output('show', project)}`) } unless @gemdir
|
802
|
+
pwd_set { parse.call(`#{bundle_output('show', project)}`) } unless @gemdir
|
623
803
|
end
|
624
804
|
raise_error('parse failed', hint: @version || 'path') unless @gemdir
|
625
805
|
rescue StandardError => e
|
@@ -660,6 +840,10 @@ module Squared
|
|
660
840
|
end
|
661
841
|
end
|
662
842
|
|
843
|
+
def ruby_session(*cmd, **kwargs)
|
844
|
+
session('ruby', *preopts, *cmd, **kwargs)
|
845
|
+
end
|
846
|
+
|
663
847
|
def gem_session(*cmd, **kwargs)
|
664
848
|
ret = session('gem', *cmd, **kwargs)
|
665
849
|
return ret if cmd.empty?
|
@@ -683,6 +867,10 @@ module Squared
|
|
683
867
|
session_output('gem', *cmd, **kwargs)
|
684
868
|
end
|
685
869
|
|
870
|
+
def ruby_output(*cmd, **kwargs)
|
871
|
+
session_output('ruby', *cmd, **kwargs)
|
872
|
+
end
|
873
|
+
|
686
874
|
def bundle_output(*cmd, **kwargs)
|
687
875
|
session_output('bundle', *cmd, **kwargs)
|
688
876
|
end
|
@@ -16,10 +16,10 @@ module Squared
|
|
16
16
|
include Prompt
|
17
17
|
|
18
18
|
def append(target, *args, delim: false, escape: false, quote: true)
|
19
|
-
return if args.empty?
|
19
|
+
return if (ret = args.flatten).empty?
|
20
20
|
|
21
21
|
target << '--' if delim && !target.include?('--')
|
22
|
-
ret
|
22
|
+
ret.map! { |val| escape ? shell_escape(val, quote: quote) : shell_quote(val) } if escape || quote
|
23
23
|
if target.is_a?(Set)
|
24
24
|
target.merge(ret)
|
25
25
|
else
|
@@ -117,6 +117,7 @@ module Squared
|
|
117
117
|
else
|
118
118
|
next
|
119
119
|
end
|
120
|
+
m << flag if val[n + 2] == 'm'
|
120
121
|
bare << flag if val.end_with?('?')
|
121
122
|
else
|
122
123
|
bare << val
|
@@ -138,17 +139,18 @@ module Squared
|
|
138
139
|
if opt =~ /\A([^=]+)=(.+)\z/
|
139
140
|
key = $1
|
140
141
|
val = $2
|
141
|
-
|
142
|
+
merge = m.include?(key)
|
143
|
+
r = ->(flag, pat) { flag.include?(key) && pat.match?(val) }
|
142
144
|
if e.include?(key)
|
143
|
-
target << shell_option(key, val)
|
145
|
+
target << shell_option(key, val, merge: merge)
|
144
146
|
elsif q.include?(key)
|
145
|
-
target << quote_option(key, val, double: qq.include?(key))
|
147
|
+
target << quote_option(key, val, double: qq.include?(key), merge: merge)
|
146
148
|
elsif p.include?(key) && path
|
147
|
-
target << quote_option(key, path.join(val))
|
148
|
-
elsif
|
149
|
+
target << quote_option(key, path.join(val), merge: merge)
|
150
|
+
elsif b.include?(key) || r.call(i, /^\d+$/) || r.call(f, /^\d*(?:\.\d+)?$/) || r.call(si, /^-?\d+$/)
|
151
|
+
target << basic_option(key, val, merge: merge)
|
152
|
+
elsif merge
|
149
153
|
target << basic_option(key, val, merge: true)
|
150
|
-
elsif b.include?(key) || match.(i, /^\d+$/) || match.(f, /^\d*(?:\.\d+)?$/) || match.(si, /^-?\d+$/)
|
151
|
-
target << basic_option(key, val)
|
152
154
|
else
|
153
155
|
@extras << opt
|
154
156
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module Squared
|
4
4
|
module Workspace
|
5
5
|
module Repo
|
6
|
-
include Common::Format
|
7
|
-
|
8
6
|
class << self
|
9
7
|
def read_manifest(path)
|
10
8
|
require 'rexml/document'
|
@@ -149,9 +147,9 @@ module Squared
|
|
149
147
|
end
|
150
148
|
end
|
151
149
|
|
152
|
-
desc.('all[{0}]')
|
150
|
+
desc.call('all[{0}]')
|
153
151
|
task 'all', [:opts] do |_, args|
|
154
|
-
parse_opts.(args)
|
152
|
+
parse_opts.call(args)
|
155
153
|
stage ||= 'all'
|
156
154
|
repo['sync'].invoke
|
157
155
|
next if env('REPO_DRYRUN', equals: '2')
|
@@ -174,21 +172,21 @@ module Squared
|
|
174
172
|
end
|
175
173
|
end
|
176
174
|
|
177
|
-
desc.("init[manifest?=#{target},{0}]", target)
|
175
|
+
desc.call("init[manifest?=#{target},{0}]", target)
|
178
176
|
task 'init', [:manifest, :opts] do |_, args|
|
179
|
-
parse_opts.(args)
|
177
|
+
parse_opts.call(args)
|
180
178
|
stage = 'init'
|
181
179
|
puts if newline
|
182
180
|
system("repo init -u #{env('REPO_URL') || manifest_url} -m #{args.manifest || target}.xml", chdir: root)
|
183
181
|
repo['all'].invoke
|
184
182
|
end
|
185
183
|
|
186
|
-
desc.('sync[{0}]')
|
184
|
+
desc.call('sync[{0}]')
|
187
185
|
task 'sync', [:opts] do |_, args|
|
188
186
|
unless branch || stage == 'init'
|
189
187
|
raise_error('repo not initialized', hint: task_name('repo:init'), kind: LoadError)
|
190
188
|
end
|
191
|
-
parse_opts.(args)
|
189
|
+
parse_opts.call(args)
|
192
190
|
cmd << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}"
|
193
191
|
cmd << '--fail-fast' if failfast
|
194
192
|
puts if newline && stage != 'init'
|
@@ -66,16 +66,17 @@ module Squared
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
attr_reader :sync, :multiple, :parallel
|
69
|
+
attr_reader :exclude, :sync, :multiple, :parallel
|
70
70
|
|
71
71
|
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :to_a, :to_s, :inspect, :merge!, :key?
|
72
72
|
def_delegators :@workspace, :task_desc, :task_name, :task_namespace, :task_join, :format_desc
|
73
73
|
|
74
|
-
def initialize(workspace)
|
74
|
+
def initialize(workspace, exclude: [])
|
75
75
|
@workspace = workspace
|
76
76
|
@sync = []
|
77
77
|
@multiple = []
|
78
78
|
@parallel = []
|
79
|
+
@exclude = exclude.freeze
|
79
80
|
@session = {
|
80
81
|
group: {},
|
81
82
|
parent: {},
|
@@ -89,7 +90,7 @@ module Squared
|
|
89
90
|
group, parent, id = @session.values
|
90
91
|
ws = proj.workspace
|
91
92
|
@data.each do |key, items|
|
92
|
-
next if (tasks = ws.task_resolve(proj, key)).empty?
|
93
|
+
next if exclude.include?(key) || (tasks = ws.task_resolve(proj, key)).empty?
|
93
94
|
|
94
95
|
if (g = proj.group)
|
95
96
|
id << g
|
@@ -113,13 +114,13 @@ module Squared
|
|
113
114
|
@data.merge!(@session[:parent]) if @session[:id].uniq.size > 1
|
114
115
|
@data.merge!(@session[:group])
|
115
116
|
@data.each do |key, items|
|
116
|
-
next if items.empty? || @workspace.task_exclude?(t = name_get(key))
|
117
|
+
next if items.empty? || exclude.include?(key) || @workspace.task_exclude?(t = name_get(key))
|
117
118
|
|
118
119
|
key = task_name(t)
|
119
120
|
val = format_desc(key, out: true)
|
120
121
|
if items.size > 1
|
121
122
|
@multiple << key
|
122
|
-
if parallel.include?(t) || pattern.any? { |pat| t.match?(pat) } || subcheck.(t)
|
123
|
+
if parallel.include?(t) || pattern.any? { |pat| t.match?(pat) } || subcheck.call(t)
|
123
124
|
task_desc("#{val} (thread)", name: key)
|
124
125
|
multitask key => items
|
125
126
|
@parallel << key
|
data/lib/squared/workspace.rb
CHANGED
@@ -10,8 +10,7 @@ module Squared
|
|
10
10
|
if id.is_a?(Symbol)
|
11
11
|
project id
|
12
12
|
else
|
13
|
-
|
14
|
-
__get__(:project).find { |_, val| val.path.to_s == id.to_s }
|
13
|
+
__get__(:project).find { |_, val| File.expand_path(val.path) == File.expand_path(id) }
|
15
14
|
end
|
16
15
|
end
|
17
16
|
ret.size == 1 ? ret.first : ret
|
@@ -33,12 +32,6 @@ module Squared
|
|
33
32
|
def project(name)
|
34
33
|
__get__(:project)[name.to_s]
|
35
34
|
end
|
36
|
-
|
37
|
-
def dirpath(val, absolute: true)
|
38
|
-
Pathname.new(val).realdirpath
|
39
|
-
rescue StandardError
|
40
|
-
absolute ? Pathname.pwd.join(val) : Pathname.new(val)
|
41
|
-
end
|
42
35
|
end
|
43
36
|
end
|
44
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.6.
|
126
|
+
rubygems_version: 3.6.7
|
127
127
|
specification_version: 4
|
128
128
|
summary: Rake task generator for managing multi-language workspaces.
|
129
129
|
test_files: []
|