squared 0.4.16 → 0.4.17
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 +31 -0
- data/README.md +10 -5
- data/README.ruby.md +17 -13
- data/lib/squared/common/system.rb +17 -16
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +10 -5
- data/lib/squared/workspace/project/base.rb +42 -23
- data/lib/squared/workspace/project/docker.rb +69 -53
- data/lib/squared/workspace/project/git.rb +212 -115
- data/lib/squared/workspace/project/node.rb +21 -6
- data/lib/squared/workspace/project/python.rb +36 -11
- data/lib/squared/workspace/project/ruby.rb +27 -19
- data/lib/squared/workspace/project/support/class.rb +64 -13
- data/lib/squared/workspace/repo.rb +46 -42
- metadata +1 -1
@@ -97,7 +97,7 @@ module Squared
|
|
97
97
|
'pack' => nil
|
98
98
|
})
|
99
99
|
|
100
|
-
def initialize(*, **kwargs)
|
100
|
+
def initialize(*, init: nil, **kwargs)
|
101
101
|
super
|
102
102
|
if @pass.include?(Node.ref)
|
103
103
|
initialize_ref Node.ref
|
@@ -107,7 +107,7 @@ module Squared
|
|
107
107
|
initialize_env(**kwargs)
|
108
108
|
end
|
109
109
|
@dependfile = @path + 'package.json'
|
110
|
-
@pm = {}
|
110
|
+
@pm = { __: init }
|
111
111
|
end
|
112
112
|
|
113
113
|
def ref
|
@@ -116,7 +116,7 @@ module Squared
|
|
116
116
|
|
117
117
|
def populate(*, **)
|
118
118
|
super
|
119
|
-
return unless outdated? && ref?(Node.ref)
|
119
|
+
return unless (outdated? && ref?(Node.ref)) || @only
|
120
120
|
|
121
121
|
namespace name do
|
122
122
|
Node.subtasks do |action, flags|
|
@@ -429,7 +429,19 @@ module Squared
|
|
429
429
|
workspace.rev_clear(name, sync: sync)
|
430
430
|
return update if !flag && env('NODE_UPDATE')
|
431
431
|
|
432
|
-
|
432
|
+
pnpm = pnpm?
|
433
|
+
yarn = pnpm ? 0 : dependtype(:yarn)
|
434
|
+
if @pm[:__] && !pnpm && yarn == 0
|
435
|
+
case @pm[:__]
|
436
|
+
when 'pnpm'
|
437
|
+
pnpm = true
|
438
|
+
when 'yarn'
|
439
|
+
yarn = 1
|
440
|
+
when 'berry'
|
441
|
+
yarn = 2
|
442
|
+
end
|
443
|
+
end
|
444
|
+
if yarn > 0
|
433
445
|
cmd = session 'yarn'
|
434
446
|
if flag == :add
|
435
447
|
cmd << 'add'
|
@@ -439,7 +451,7 @@ module Squared
|
|
439
451
|
cmd << 'install'
|
440
452
|
cmd << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
|
441
453
|
end
|
442
|
-
elsif pnpm
|
454
|
+
elsif pnpm
|
443
455
|
cmd = session 'pnpm'
|
444
456
|
if flag == :add
|
445
457
|
cmd << 'add' << "--save-#{save}"
|
@@ -737,15 +749,18 @@ module Squared
|
|
737
749
|
when :major
|
738
750
|
if seg[0] != '0' || seg[2].nil?
|
739
751
|
seg[0] = seg[0].succ
|
752
|
+
seg[2] = '0'
|
740
753
|
else
|
741
754
|
seg[2] = seg[2].succ
|
742
755
|
end
|
756
|
+
seg[4] = '0'
|
743
757
|
when :minor
|
744
758
|
if seg[0] == '0'
|
745
759
|
seg[4] &&= seg[4].succ
|
746
760
|
else
|
747
761
|
seg[2] = seg[2].succ
|
748
762
|
end
|
763
|
+
seg[4] = '0'
|
749
764
|
when :patch
|
750
765
|
seg[4] &&= seg[4].succ
|
751
766
|
end
|
@@ -940,7 +955,7 @@ module Squared
|
|
940
955
|
else
|
941
956
|
if key
|
942
957
|
@pm[key]
|
943
|
-
elsif (ret = @pm[:_]) && !
|
958
|
+
elsif (ret = @pm[:_]) && (!version || semgte?(ret[(ret.index('@') + 1)..-1], version))
|
944
959
|
ret
|
945
960
|
end
|
946
961
|
end
|
@@ -87,7 +87,6 @@ module Squared
|
|
87
87
|
initialize_build(Python.ref, **kwargs)
|
88
88
|
initialize_env(**kwargs)
|
89
89
|
end
|
90
|
-
@verbose = verbose.size if verbose.is_a?(String) && verbose.match?(/\Av+\z/)
|
91
90
|
dependfile_set DEP_PYTHON
|
92
91
|
editable_set editable
|
93
92
|
venv_set kwargs[:venv]
|
@@ -95,7 +94,7 @@ module Squared
|
|
95
94
|
|
96
95
|
subtasks({
|
97
96
|
'venv' => %i[exec create remove show].freeze,
|
98
|
-
'pip' => %i[uninstall freeze].freeze,
|
97
|
+
'pip' => %i[upgrade uninstall freeze].freeze,
|
99
98
|
'install' => %i[user force upgrade target editable].freeze,
|
100
99
|
'outdated' => %i[major minor patch].freeze,
|
101
100
|
'build' => %i[python poetry pdm hatch].freeze,
|
@@ -104,13 +103,22 @@ module Squared
|
|
104
103
|
'exec' => nil
|
105
104
|
})
|
106
105
|
|
106
|
+
def verbose=(val)
|
107
|
+
case val
|
108
|
+
when /\Av+\z/
|
109
|
+
@verbose = val.size
|
110
|
+
else
|
111
|
+
super
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
107
115
|
def ref
|
108
116
|
Python.ref
|
109
117
|
end
|
110
118
|
|
111
119
|
def populate(*, **)
|
112
120
|
super
|
113
|
-
return unless outdated? && ref?(Python.ref)
|
121
|
+
return unless (outdated? && ref?(Python.ref)) || @only
|
114
122
|
|
115
123
|
namespace name do
|
116
124
|
Python.subtasks do |action, flags|
|
@@ -159,7 +167,7 @@ module Squared
|
|
159
167
|
found |= 1
|
160
168
|
run(pdm_session('run', val), from: :run)
|
161
169
|
else
|
162
|
-
raise_error
|
170
|
+
raise_error "script: #{val}" if exception
|
163
171
|
found |= 2
|
164
172
|
log.warn "run script \"#{val}\" (not indexed)"
|
165
173
|
end
|
@@ -234,6 +242,14 @@ module Squared
|
|
234
242
|
end
|
235
243
|
when 'pip'
|
236
244
|
case flag
|
245
|
+
when :upgrade
|
246
|
+
format_desc action, flag, 'opts*'
|
247
|
+
task flag do |_, args|
|
248
|
+
args = args.to_a
|
249
|
+
args.unshift('upgrade')
|
250
|
+
args << 'pip'
|
251
|
+
install flag, args
|
252
|
+
end
|
237
253
|
when :freeze
|
238
254
|
format_desc action, flag, "file?=#{DEP_PYTHON[4]},opts*"
|
239
255
|
task flag do |_, args|
|
@@ -287,7 +303,7 @@ module Squared
|
|
287
303
|
when 'build'
|
288
304
|
case flag
|
289
305
|
when :poetry
|
290
|
-
next unless
|
306
|
+
next unless poetry?
|
291
307
|
when :pdm
|
292
308
|
next unless build_backend == 'pdm.backend'
|
293
309
|
when :hatch
|
@@ -325,8 +341,8 @@ module Squared
|
|
325
341
|
elsif outdated?
|
326
342
|
venv_init
|
327
343
|
workspace.rev_clear(name, sync: sync)
|
328
|
-
if !flag &&
|
329
|
-
cmd = poetry_session 'install
|
344
|
+
if !flag && poetry?
|
345
|
+
cmd = poetry_session 'install -n'
|
330
346
|
cmd << '--no-root' if option('no-root')
|
331
347
|
else
|
332
348
|
cmd = pip_session 'install'
|
@@ -351,7 +367,7 @@ module Squared
|
|
351
367
|
end
|
352
368
|
|
353
369
|
def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated'))
|
354
|
-
cmd = pip_session 'list
|
370
|
+
cmd = pip_session 'list --outdated'
|
355
371
|
append_global
|
356
372
|
cmd = session_done cmd
|
357
373
|
log.info cmd
|
@@ -458,6 +474,11 @@ module Squared
|
|
458
474
|
cmd << '--user' if user
|
459
475
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
460
476
|
append_value out
|
477
|
+
if workspace.windows?
|
478
|
+
pip = cmd.to_a.drop(1)
|
479
|
+
cmd = python_session '-m pip'
|
480
|
+
cmd.merge(pip)
|
481
|
+
end
|
461
482
|
end
|
462
483
|
run(from: :install)
|
463
484
|
end
|
@@ -506,7 +527,7 @@ module Squared
|
|
506
527
|
end
|
507
528
|
op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
|
508
529
|
end
|
509
|
-
op
|
530
|
+
op.add_path(srcdir) if srcdir
|
510
531
|
op.clear
|
511
532
|
run(from: :"#{flag}:build")
|
512
533
|
end
|
@@ -552,7 +573,7 @@ module Squared
|
|
552
573
|
out = append_pip(nil, opts, from: flag)
|
553
574
|
case flag
|
554
575
|
when :uninstall
|
555
|
-
raise_error('no packages listed', hint:
|
576
|
+
raise_error('no packages listed', hint: flag) if out.empty?
|
556
577
|
cmd.merge(out)
|
557
578
|
when :freeze
|
558
579
|
venv_init
|
@@ -653,7 +674,7 @@ module Squared
|
|
653
674
|
end
|
654
675
|
op.swap
|
655
676
|
if edit
|
656
|
-
edit = path + edit unless %r{
|
677
|
+
edit = path + edit unless %r{\A[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
657
678
|
if flag == :editable
|
658
679
|
op.push(edit)
|
659
680
|
else
|
@@ -866,6 +887,10 @@ module Squared
|
|
866
887
|
puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
|
867
888
|
end
|
868
889
|
|
890
|
+
def poetry?
|
891
|
+
build_backend ? build_backend == 'poetry.core.masonry.api' : dependtype == 1
|
892
|
+
end
|
893
|
+
|
869
894
|
def requirements?
|
870
895
|
dependtype == 5
|
871
896
|
end
|
@@ -126,7 +126,7 @@ module Squared
|
|
126
126
|
|
127
127
|
def populate(*, **)
|
128
128
|
super
|
129
|
-
return unless outdated? && ref?(Ruby.ref)
|
129
|
+
return unless (outdated? && ref?(Ruby.ref)) || @only
|
130
130
|
|
131
131
|
namespace name do
|
132
132
|
Ruby.subtasks do |action, flags|
|
@@ -171,7 +171,7 @@ module Squared
|
|
171
171
|
format_desc action, nil, 'opts*,args*|:'
|
172
172
|
task action do |_, args|
|
173
173
|
args = args.to_a
|
174
|
-
name = basepath(
|
174
|
+
name = gemlib.any? { |file| basepath(file).join("#{gemname}.rb").exist? } ? gemname : nil
|
175
175
|
irb(name, args, args: (readline('Enter file [arguments]', force: false) if args.delete(':')))
|
176
176
|
end
|
177
177
|
else
|
@@ -275,7 +275,7 @@ module Squared
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
|
-
def copy(from:
|
278
|
+
def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
|
279
279
|
glob = kwargs[:include]
|
280
280
|
pass = kwargs[:exclude]
|
281
281
|
if @copy && !override
|
@@ -565,7 +565,7 @@ module Squared
|
|
565
565
|
minor = 0
|
566
566
|
patch = 0
|
567
567
|
update = []
|
568
|
-
pwd_set(pass: !
|
568
|
+
pwd_set(pass: !gempwd.nil?, from: from) do
|
569
569
|
items = [[%w[Gem Current Latest], nil]]
|
570
570
|
IO.popen(cmd.done).each do |line|
|
571
571
|
if line =~ /^(\S+) \((\S+) < ([^)]+)\)$/
|
@@ -685,11 +685,11 @@ module Squared
|
|
685
685
|
on :last, from
|
686
686
|
return
|
687
687
|
when :build
|
688
|
-
if
|
689
|
-
op
|
690
|
-
|
691
|
-
|
692
|
-
|
688
|
+
if op.empty?
|
689
|
+
op.add_path(gemfile)
|
690
|
+
else
|
691
|
+
op.add_path(op.shift)
|
692
|
+
.clear(pass: false)
|
693
693
|
end
|
694
694
|
when :push
|
695
695
|
if op.empty?
|
@@ -703,7 +703,7 @@ module Squared
|
|
703
703
|
raise_error('gem not found', hint: file) unless file.exist?
|
704
704
|
raise_error("unknown args: #{op.join(', ')}", hint: flag) unless op.empty?
|
705
705
|
end
|
706
|
-
op
|
706
|
+
op.add_path(file)
|
707
707
|
run_rb(from: from, interactive: "Push #{sub_style(gemname, styles: theme[:active])}")
|
708
708
|
return
|
709
709
|
when :exec
|
@@ -730,7 +730,7 @@ module Squared
|
|
730
730
|
raise_error('missing gemname', hint: flag) if op.empty?
|
731
731
|
case flag
|
732
732
|
when :install, :uninstall, :pristine
|
733
|
-
post = readline('Enter command [args]', force: true) if flag == :install && op.
|
733
|
+
post = readline('Enter command [args]', force: true) if flag == :install && op.remove(':')
|
734
734
|
if op.arg?('all')
|
735
735
|
if flag == :pristine
|
736
736
|
append_repeat 'skip', op.extras
|
@@ -797,7 +797,7 @@ module Squared
|
|
797
797
|
run_s(args, banner: false, from: :rake)
|
798
798
|
end
|
799
799
|
|
800
|
-
def irb(name = nil, opts = [], path:
|
800
|
+
def irb(name = nil, opts = [], path: gemlib, args: nil)
|
801
801
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
802
802
|
r = args ? [] : ['bundler/setup']
|
803
803
|
r << name if name
|
@@ -817,7 +817,6 @@ module Squared
|
|
817
817
|
|
818
818
|
begin
|
819
819
|
if (file = gemfile)
|
820
|
-
require 'rubygems'
|
821
820
|
@gemspec = Gem::Specification.load(file.to_s)
|
822
821
|
end
|
823
822
|
rescue StandardError => e
|
@@ -885,7 +884,6 @@ module Squared
|
|
885
884
|
end
|
886
885
|
end
|
887
886
|
end
|
888
|
-
require 'rubygems'
|
889
887
|
@gemdir = Pathname.new(Gem.dir) + gempath
|
890
888
|
else
|
891
889
|
parse = lambda do |path|
|
@@ -983,9 +981,9 @@ module Squared
|
|
983
981
|
|
984
982
|
def read_rakefile
|
985
983
|
@read_rakefile ||= [].tap do |ret|
|
986
|
-
|
987
|
-
pwd_set(pass: !
|
988
|
-
IO.popen(rake_output(
|
984
|
+
opt = rakepwd
|
985
|
+
pwd_set(pass: !opt.nil?) do
|
986
|
+
IO.popen(rake_output(opt, '-AT').to_s).each do |line|
|
989
987
|
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
990
988
|
|
991
989
|
ret << [$1, $2]
|
@@ -1014,13 +1012,13 @@ module Squared
|
|
1014
1012
|
end
|
1015
1013
|
|
1016
1014
|
def rakepwd
|
1017
|
-
return
|
1015
|
+
return unless !pwd? && semgte?(Rake::VERSION, '13.0.4')
|
1018
1016
|
|
1019
1017
|
quote_option 'C', path
|
1020
1018
|
end
|
1021
1019
|
|
1022
1020
|
def gempwd
|
1023
|
-
return
|
1021
|
+
return unless !pwd? && semgte?(Gem::VERSION, '3.4.2')
|
1024
1022
|
|
1025
1023
|
quote_option 'C', path
|
1026
1024
|
end
|
@@ -1033,6 +1031,16 @@ module Squared
|
|
1033
1031
|
.find { |file| File.exist?(file) } || false
|
1034
1032
|
end
|
1035
1033
|
|
1034
|
+
def gemlib
|
1035
|
+
@gemlib ||= begin
|
1036
|
+
lib = Set.new(['lib'])
|
1037
|
+
if (spec = gemspec)
|
1038
|
+
lib.merge(spec.require_paths || [])
|
1039
|
+
end
|
1040
|
+
lib.select { |file| basepath(file).exist? }
|
1041
|
+
end
|
1042
|
+
end
|
1043
|
+
|
1036
1044
|
def gempath(val = version)
|
1037
1045
|
File.join('gems', "#{gemname}-#{val}")
|
1038
1046
|
end
|
@@ -45,6 +45,15 @@ module Squared
|
|
45
45
|
val.map { |s| s.sub(/\A-([a-z\d])(.+)\z/i, '\1=\2').sub(/\A--?/, '') }.reject(&:empty?)
|
46
46
|
end
|
47
47
|
|
48
|
+
def select(list, bare: true, no: true, single: false, double: false)
|
49
|
+
ret = bare ? list.grep_v(/=/) : list.grep(/=/).map! { |val| val.split('=', 2).first }
|
50
|
+
ret.map! { |val| val.split('|', 2).last }
|
51
|
+
ret = ret.grep_v(/^no-/) unless no
|
52
|
+
return ret if single == double
|
53
|
+
|
54
|
+
ret.select { |val| single ? val.size == 1 : val.size > 1 }
|
55
|
+
end
|
56
|
+
|
48
57
|
def arg?(target, *args, value: false, **)
|
49
58
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
50
59
|
unless s.empty?
|
@@ -53,15 +62,22 @@ module Squared
|
|
53
62
|
end
|
54
63
|
target.any? { |opt| r.any? { |val| opt&.match?(val) } }
|
55
64
|
end
|
65
|
+
|
66
|
+
def pattern?(val)
|
67
|
+
val.match?(/(?:\A\^|\$\z)/) || val.match?(/(?:\.[*+]|\(\?:|\\[dsw]|\[.+\]|\{\d+,?\d*\})/)
|
68
|
+
end
|
56
69
|
end
|
57
70
|
|
58
71
|
attr_reader :target, :extras, :found, :errors, :values, :project, :path
|
59
72
|
|
60
73
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
61
|
-
:merge, :delete, :delete?, :delete_if, :grep, :inspect, :to_a, :to_s
|
74
|
+
:merge, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
62
75
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
63
76
|
:pop, :push, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
64
77
|
|
78
|
+
def_delegator :@extras, :delete, :remove
|
79
|
+
def_delegator :@extras, :delete_if, :remove_if
|
80
|
+
|
65
81
|
def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
|
66
82
|
@target = target.is_a?(Set) ? target : Set.new(target)
|
67
83
|
@project = project
|
@@ -138,35 +154,35 @@ module Squared
|
|
138
154
|
skip = false
|
139
155
|
opts.each do |opt|
|
140
156
|
next skip = true if opt == '--'
|
141
|
-
next
|
157
|
+
next push opt if skip
|
142
158
|
|
143
159
|
if single&.match?(opt)
|
144
|
-
|
160
|
+
add "-#{opt}"
|
145
161
|
elsif bare.include?(opt)
|
146
|
-
|
162
|
+
add(opt.size == 1 ? "-#{opt}" : "--#{opt}")
|
147
163
|
elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
|
148
|
-
|
164
|
+
add "--no-#{name}"
|
149
165
|
else
|
150
166
|
if opt =~ /\A([^=]+)=(.+)\z/
|
151
167
|
key = $1
|
152
168
|
val = $2
|
153
169
|
merge = m.include?(key)
|
154
170
|
if e.include?(key)
|
155
|
-
|
171
|
+
add shell_option(key, val, merge: merge)
|
156
172
|
elsif q.include?(key)
|
157
|
-
|
173
|
+
add quote_option(key, val, double: qq.include?(key), merge: merge)
|
158
174
|
elsif p.include?(key) && path
|
159
|
-
|
175
|
+
add quote_option(key, path + val, merge: merge)
|
160
176
|
elsif b.include?(key) || numcheck.call(key, val)
|
161
|
-
|
177
|
+
add basic_option(key, val, merge: merge)
|
162
178
|
elsif merge
|
163
|
-
|
179
|
+
add basic_option(key, val, merge: true)
|
164
180
|
else
|
165
|
-
|
181
|
+
push opt
|
166
182
|
end
|
167
183
|
opt = key
|
168
184
|
else
|
169
|
-
|
185
|
+
push opt
|
170
186
|
skip = true if args
|
171
187
|
end
|
172
188
|
skip = true if first&.any? { |s| s.is_a?(Regexp) ? opt.match?(s) : !opt.include?(s) }
|
@@ -229,7 +245,42 @@ module Squared
|
|
229
245
|
args = items[0...i] + args + items[i..-1]
|
230
246
|
target.clear
|
231
247
|
end
|
232
|
-
merge
|
248
|
+
merge args
|
249
|
+
self
|
250
|
+
end
|
251
|
+
|
252
|
+
def add_path(*args, **kwargs)
|
253
|
+
add shell_quote(path ? path.join(*args) : File.join(*args), **kwargs)
|
254
|
+
self
|
255
|
+
end
|
256
|
+
|
257
|
+
def add_quote(*args, **kwargs)
|
258
|
+
merge(args.map { |val| shell_quote(val, **kwargs) })
|
259
|
+
self
|
260
|
+
end
|
261
|
+
|
262
|
+
def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
|
263
|
+
found, other = if block_given?
|
264
|
+
partition(&blk)
|
265
|
+
elsif exclude.first.is_a?(Symbol)
|
266
|
+
partition(&exclude.first)
|
267
|
+
else
|
268
|
+
partition do |val|
|
269
|
+
next false if pattern && OptionPartition.pattern?(val)
|
270
|
+
|
271
|
+
exclude.none? { |pat| val.match?(Regexp.new(pat)) }
|
272
|
+
end
|
273
|
+
end
|
274
|
+
unless found.empty?
|
275
|
+
add '--' if delim
|
276
|
+
extras.clear
|
277
|
+
extras.concat(other)
|
278
|
+
if path
|
279
|
+
found.each { |val| add_path(val) }
|
280
|
+
else
|
281
|
+
merge(quote ? found.map! { |val| shell_quote(val) } : found)
|
282
|
+
end
|
283
|
+
end
|
233
284
|
self
|
234
285
|
end
|
235
286
|
|
@@ -113,35 +113,17 @@ module Squared
|
|
113
113
|
def __repo__(**kwargs)
|
114
114
|
kwargs.delete(:parallel) if env('REPO_SYNC', ignore: '0')
|
115
115
|
|
116
|
-
namespace(
|
116
|
+
namespace(task_name('repo')) do |ns|
|
117
|
+
path = ns.scope.path
|
117
118
|
branch = env('REPO_MANIFEST') || Repo.read_manifest(root)
|
118
119
|
target = branch || manifest
|
120
|
+
cmd = nil
|
119
121
|
stage = nil
|
120
|
-
failfast = true
|
121
|
-
cmd = []
|
122
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
|
141
123
|
desc = lambda do |val, alt = nil|
|
142
124
|
if (ver = branch || alt)
|
143
|
-
val = val.sub('{0}', 'opts*=force,rebase,detach,
|
144
|
-
task_desc(
|
125
|
+
val = val.sub('{0}', 'opts*=force,rebase,detach,fail,no-update,gc')
|
126
|
+
task_desc(path, val, ver)
|
145
127
|
else
|
146
128
|
task_desc 'inactive'
|
147
129
|
end
|
@@ -149,20 +131,22 @@ module Squared
|
|
149
131
|
|
150
132
|
desc.call('all[{0}]')
|
151
133
|
task 'all', [:opts] do |_, args|
|
152
|
-
|
134
|
+
cmd ||= repo_opts args
|
153
135
|
stage ||= 'all'
|
154
|
-
|
155
|
-
next if env('
|
136
|
+
ns['sync'].invoke
|
137
|
+
next if env('REPO_STAGE', equals: '1')
|
156
138
|
|
157
139
|
@project.select do |_, proj|
|
158
140
|
next unless proj.enabled?(proj.workspace.baseref)
|
159
141
|
|
160
142
|
proj.depend(sync: true) if proj.depend?
|
161
|
-
|
143
|
+
next if env('REPO_STAGE', equals: '2')
|
144
|
+
|
145
|
+
proj.build?
|
162
146
|
end
|
163
147
|
.each_value do |proj|
|
164
148
|
proj.build(sync: true)
|
165
|
-
next unless proj.dev? && proj.copy?
|
149
|
+
next unless proj.dev? && proj.copy? && !env('REPO_STAGE', equals: '3')
|
166
150
|
|
167
151
|
if (ws = proj.workspace).task_defined?(target = task_join(proj.name, 'copy'))
|
168
152
|
task_invoke(target, **ws.invokeargs)
|
@@ -174,38 +158,37 @@ module Squared
|
|
174
158
|
|
175
159
|
desc.call("init[manifest?=#{target},{0}]", target)
|
176
160
|
task 'init', [:manifest, :opts] do |_, args|
|
177
|
-
|
161
|
+
cmd = repo_opts args
|
178
162
|
stage = 'init'
|
179
163
|
puts if newline
|
180
164
|
Common::System.shell("repo init -u #{env('REPO_URL') || manifest_url} -m #{args.manifest || target}.xml",
|
181
165
|
chdir: root)
|
182
|
-
|
166
|
+
next if env('REPO_STAGE', equals: '0')
|
167
|
+
|
168
|
+
ns['all'].invoke
|
183
169
|
end
|
184
170
|
|
185
171
|
desc.call('sync[{0}]')
|
186
|
-
task 'sync', [:opts] do |
|
187
|
-
unless branch || stage == 'init'
|
188
|
-
|
189
|
-
end
|
190
|
-
parse_opts.call(args)
|
172
|
+
task 'sync', [:opts] do |t, args|
|
173
|
+
raise_error 'repo not initialized' unless branch || stage == 'init'
|
174
|
+
cmd ||= repo_opts args
|
191
175
|
cmd << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}"
|
192
|
-
|
193
|
-
puts if newline && stage != 'init'
|
176
|
+
puts unless !newline || stage == 'init'
|
194
177
|
begin
|
195
|
-
Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception:
|
178
|
+
Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception: cmd.include?('--fail-fast'))
|
196
179
|
rescue Errno::ENOENT => e
|
197
180
|
emphasize(e, title: root)
|
198
181
|
raise
|
199
182
|
rescue StandardError => e
|
200
|
-
emphasize(e, title: "rake stash #{
|
183
|
+
emphasize(e, title: "rake stash #{t.name}")
|
201
184
|
raise
|
202
185
|
end
|
203
186
|
end
|
204
187
|
|
205
188
|
series.sync.push(
|
206
|
-
task_join(
|
207
|
-
task_join(
|
208
|
-
task_join(
|
189
|
+
task_join(path, 'all'),
|
190
|
+
task_join(path, 'init'),
|
191
|
+
task_join(path, 'sync')
|
209
192
|
)
|
210
193
|
end
|
211
194
|
end
|
@@ -221,6 +204,27 @@ module Squared
|
|
221
204
|
)
|
222
205
|
end
|
223
206
|
|
207
|
+
def repo_opts(args)
|
208
|
+
ret = []
|
209
|
+
args.to_a.each do |val|
|
210
|
+
case val
|
211
|
+
when 'force'
|
212
|
+
ret << '--force-checkout'
|
213
|
+
when 'rebase'
|
214
|
+
ret << '--rebase'
|
215
|
+
when 'detach'
|
216
|
+
ret << '--detach'
|
217
|
+
when 'fail'
|
218
|
+
ret << '--fail-fast'
|
219
|
+
when 'no-update'
|
220
|
+
ret << '--no-manifest-update'
|
221
|
+
when 'gc'
|
222
|
+
ret << '--auto-gc'
|
223
|
+
end
|
224
|
+
end
|
225
|
+
ret
|
226
|
+
end
|
227
|
+
|
224
228
|
def repo?
|
225
229
|
!manifest_url.nil? && (repo_install? || @repo_override == true)
|
226
230
|
end
|