squared 0.5.2 → 0.5.4
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 +74 -0
- data/README.ruby.md +21 -15
- data/lib/squared/common/format.rb +6 -4
- data/lib/squared/common/prompt.rb +3 -3
- data/lib/squared/common/shell.rb +9 -5
- data/lib/squared/common/system.rb +3 -3
- data/lib/squared/common/utils.rb +9 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +25 -16
- data/lib/squared/workspace/project/base.rb +201 -140
- data/lib/squared/workspace/project/docker.rb +83 -70
- data/lib/squared/workspace/project/git.rb +234 -152
- data/lib/squared/workspace/project/node.rb +87 -34
- data/lib/squared/workspace/project/python.rb +55 -22
- data/lib/squared/workspace/project/ruby.rb +101 -58
- data/lib/squared/workspace/project/support/class.rb +66 -17
- data/lib/squared/workspace/repo.rb +47 -43
- data/lib/squared/workspace/series.rb +4 -4
- data/lib/squared/workspace/support/base.rb +17 -0
- data/lib/squared/workspace/support.rb +1 -0
- data/lib/squared/workspace.rb +0 -8
- data/squared.gemspec +2 -2
- metadata +2 -1
@@ -91,7 +91,7 @@ module Squared
|
|
91
91
|
'irb' => nil
|
92
92
|
})
|
93
93
|
|
94
|
-
def initialize(*, autodetect: false, **kwargs)
|
94
|
+
def initialize(*, autodetect: false, gemspec: nil, **kwargs)
|
95
95
|
super
|
96
96
|
if @pass.include?(Ruby.ref)
|
97
97
|
initialize_ref Ruby.ref
|
@@ -102,7 +102,8 @@ module Squared
|
|
102
102
|
end
|
103
103
|
dependfile_set GEMFILE
|
104
104
|
@autodetect = autodetect
|
105
|
-
|
105
|
+
@gemfile = path + gemspec if gemspec
|
106
|
+
return if !@output[0].nil? || !@copy.nil? || version || @autodetect || !rakefile
|
106
107
|
|
107
108
|
begin
|
108
109
|
File.foreach(rakefile) do |line|
|
@@ -125,16 +126,16 @@ module Squared
|
|
125
126
|
|
126
127
|
def populate(*, **)
|
127
128
|
super
|
128
|
-
return unless outdated? && ref?(Ruby.ref)
|
129
|
+
return unless (outdated? && ref?(Ruby.ref)) || @only
|
129
130
|
|
130
131
|
namespace name do
|
131
132
|
Ruby.subtasks do |action, flags|
|
132
|
-
next if
|
133
|
+
next if task_pass?(action)
|
133
134
|
|
134
135
|
if flags.nil?
|
135
136
|
case action
|
136
137
|
when 'rake'
|
137
|
-
next
|
138
|
+
next unless rakefile
|
138
139
|
|
139
140
|
format_desc action, nil, "task+,opts*|#{indexchar}index+|#,pattern*"
|
140
141
|
task action, [:command] do |_, args|
|
@@ -167,13 +168,11 @@ module Squared
|
|
167
168
|
end
|
168
169
|
end
|
169
170
|
when 'irb'
|
170
|
-
next unless (spec = basepath("#{project}.gemspec") || basepath("#{name}.gemspec"))
|
171
|
-
next unless basepath('lib').join("#{gemname = stripext(spec)}.rb").exist?
|
172
|
-
|
173
171
|
format_desc action, nil, 'opts*,args*|:'
|
174
172
|
task action do |_, args|
|
175
173
|
args = args.to_a
|
176
|
-
|
174
|
+
name = gemlib.any? { |file| basepath(file).join("#{gemname}.rb").exist? } ? gemname : nil
|
175
|
+
irb(name, args, args: (readline('Enter file [arguments]', force: false) if args.delete(':')))
|
177
176
|
end
|
178
177
|
else
|
179
178
|
format_desc(action, nil, 'opts*', before: case action
|
@@ -276,7 +275,7 @@ module Squared
|
|
276
275
|
end
|
277
276
|
end
|
278
277
|
|
279
|
-
def copy(from:
|
278
|
+
def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
|
280
279
|
glob = kwargs[:include]
|
281
280
|
pass = kwargs[:exclude]
|
282
281
|
if @copy && !override
|
@@ -303,9 +302,7 @@ module Squared
|
|
303
302
|
begin
|
304
303
|
copy_dir(a, b, c, pass: pass, verbose: verbose)
|
305
304
|
rescue StandardError => e
|
306
|
-
|
307
|
-
ret = on :error, :copy, e
|
308
|
-
raise if exception && ret != true
|
305
|
+
on_error e, :copy
|
309
306
|
end
|
310
307
|
end
|
311
308
|
on :last, :copy
|
@@ -445,11 +442,11 @@ module Squared
|
|
445
442
|
when :file, :script
|
446
443
|
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
447
444
|
if file
|
448
|
-
op.
|
445
|
+
op.unshift(shell_quote(path + file))
|
449
446
|
elsif command
|
450
447
|
op << quote_option('e', command, option: false)
|
451
448
|
end
|
452
|
-
op.
|
449
|
+
op.push(args) if (args = ENV.fetch('RUBY_ARGS', args))
|
453
450
|
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
454
451
|
when :version
|
455
452
|
pwd_set do
|
@@ -569,7 +566,7 @@ module Squared
|
|
569
566
|
minor = 0
|
570
567
|
patch = 0
|
571
568
|
update = []
|
572
|
-
pwd_set(pass: !
|
569
|
+
pwd_set(pass: !gempwd.nil?, from: from) do
|
573
570
|
items = [[%w[Gem Current Latest], nil]]
|
574
571
|
IO.popen(cmd.done).each do |line|
|
575
572
|
if line =~ /^(\S+) \((\S+) < ([^)]+)\)$/
|
@@ -689,36 +686,43 @@ module Squared
|
|
689
686
|
return
|
690
687
|
when :build
|
691
688
|
if op.empty?
|
692
|
-
|
693
|
-
op << File.basename(spec) if (spec = spec.find { |file| File.exist?(file) })
|
689
|
+
op.add_path(gemfile)
|
694
690
|
else
|
695
|
-
op
|
696
|
-
|
691
|
+
op.add_path(op.shift)
|
692
|
+
.clear(pass: false)
|
697
693
|
end
|
698
694
|
when :push
|
699
695
|
if op.empty?
|
700
|
-
|
696
|
+
file = path + (if (spec = gemspec)
|
697
|
+
"#{spec.name}-#{spec.version}.gem"
|
698
|
+
else
|
699
|
+
choice_index('Select a file', Dir.glob('*.gem', base: path), force: true)
|
700
|
+
end)
|
701
701
|
else
|
702
702
|
file = path + op.shift
|
703
|
+
raise_error('gem not found', hint: file) unless file.exist?
|
703
704
|
raise_error("unknown args: #{op.join(', ')}", hint: flag) unless op.empty?
|
704
|
-
if file.exist?
|
705
|
-
op << shell_quote(file)
|
706
|
-
else
|
707
|
-
raise_error('gem not found', hint: file)
|
708
|
-
end
|
709
705
|
end
|
710
|
-
|
706
|
+
op.add_path(file)
|
707
|
+
run_rb(from: from, interactive: "Push #{sub_style(gemname, styles: theme[:active])}")
|
711
708
|
return
|
712
709
|
when :exec
|
713
|
-
|
714
|
-
|
715
|
-
|
710
|
+
min = if op.arg?('g', 'gem')
|
711
|
+
1
|
712
|
+
elsif op.empty?
|
713
|
+
op << basic_option('gem', gemname)
|
714
|
+
1
|
715
|
+
else
|
716
|
+
op << op.shift
|
717
|
+
0
|
718
|
+
end
|
719
|
+
if (args = command_args(op.extras, min: min, force: min == 1 && op.empty?))
|
716
720
|
op.push(args)
|
717
721
|
end
|
718
|
-
op.append(
|
722
|
+
op.append(quote: false)
|
719
723
|
when :update
|
720
724
|
unless op.arg?('system')
|
721
|
-
op.push(
|
725
|
+
op.push(gemname) if op.empty?
|
722
726
|
op.adjoin
|
723
727
|
end
|
724
728
|
op.clear(errors: true)
|
@@ -726,7 +730,7 @@ module Squared
|
|
726
730
|
raise_error('missing gemname', hint: flag) if op.empty?
|
727
731
|
case flag
|
728
732
|
when :install, :uninstall, :pristine
|
729
|
-
post = readline('Enter command [args]', force: true) if flag == :install && op.
|
733
|
+
post = readline('Enter command [args]', force: true) if flag == :install && op.remove(':')
|
730
734
|
if op.arg?('all')
|
731
735
|
if flag == :pristine
|
732
736
|
append_repeat 'skip', op.extras
|
@@ -738,7 +742,7 @@ module Squared
|
|
738
742
|
items = op.extras.to_a
|
739
743
|
name = items.delete_at(n)
|
740
744
|
if (n = name.index('@')) == 0
|
741
|
-
pre =
|
745
|
+
pre = gemname
|
742
746
|
ver = name[1..-1]
|
743
747
|
else
|
744
748
|
pre = name[0, n]
|
@@ -793,10 +797,11 @@ module Squared
|
|
793
797
|
run_s(args, banner: false, from: :rake)
|
794
798
|
end
|
795
799
|
|
796
|
-
def irb(name, opts = [], path:
|
800
|
+
def irb(name = nil, opts = [], path: gemlib, args: nil)
|
797
801
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
798
802
|
r = args ? [] : ['bundler/setup']
|
799
|
-
|
803
|
+
r << name if name
|
804
|
+
r.each { |val| op << shell_option('r', val, merge: true) }
|
800
805
|
Array(path).each { |val| op << quote_option('I', val, merge: true) }
|
801
806
|
if args
|
802
807
|
op << '--' << args
|
@@ -807,6 +812,23 @@ module Squared
|
|
807
812
|
run(banner: false)
|
808
813
|
end
|
809
814
|
|
815
|
+
def gemspec
|
816
|
+
return @gemspec unless @gemspec.nil?
|
817
|
+
|
818
|
+
begin
|
819
|
+
if (file = gemfile)
|
820
|
+
@gemspec = Gem::Specification.load(file.to_s)
|
821
|
+
end
|
822
|
+
rescue StandardError => e
|
823
|
+
log.debug e
|
824
|
+
end
|
825
|
+
@gemspec ||= false
|
826
|
+
end
|
827
|
+
|
828
|
+
def gemname
|
829
|
+
@gemname ||= ((spec = gemspec) ? spec.name : project)
|
830
|
+
end
|
831
|
+
|
810
832
|
def depend?
|
811
833
|
@depend != false && (!@depend.nil? || outdated?)
|
812
834
|
end
|
@@ -815,7 +837,7 @@ module Squared
|
|
815
837
|
return true if super || (@copy.is_a?(Hash) && copy.fetch(:into, nil))
|
816
838
|
return gemdir? if @gemdir
|
817
839
|
|
818
|
-
if
|
840
|
+
if version
|
819
841
|
begin
|
820
842
|
case @autodetect
|
821
843
|
when 'rvm'
|
@@ -840,17 +862,19 @@ module Squared
|
|
840
862
|
return false unless @autodetect
|
841
863
|
|
842
864
|
set = lambda do |val, path|
|
843
|
-
|
844
|
-
|
865
|
+
if (ver = version) && ver != val
|
866
|
+
log.warn "using version #{val} (given #{ver})"
|
867
|
+
end
|
868
|
+
self.version = val
|
845
869
|
@gemdir = Pathname.new(path.strip) + gempath
|
846
870
|
end
|
847
|
-
if
|
848
|
-
|
849
|
-
pwd_set(pass: !
|
850
|
-
out = `#{gem_output(
|
851
|
-
if out =~ /#{Regexp.escape(
|
871
|
+
if version
|
872
|
+
opt = gempwd
|
873
|
+
pwd_set(pass: !opt.nil?) do
|
874
|
+
out = `#{gem_output(opt, 'list --local -d', gemname)}`
|
875
|
+
if out =~ /#{Regexp.escape(gemname)} \(([^)]+)\)/
|
852
876
|
$1.split(/\s*,\s*/)
|
853
|
-
.prepend(
|
877
|
+
.prepend(version)
|
854
878
|
.uniq
|
855
879
|
.each do |val|
|
856
880
|
next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
|
@@ -860,22 +884,21 @@ module Squared
|
|
860
884
|
end
|
861
885
|
end
|
862
886
|
end
|
863
|
-
require 'rubygems'
|
864
887
|
@gemdir = Pathname.new(Gem.dir) + gempath
|
865
888
|
else
|
866
889
|
parse = lambda do |path|
|
867
890
|
next unless path
|
868
891
|
|
869
|
-
lib = Regexp.new(['', 'gems', "#{
|
892
|
+
lib = Regexp.new(['', 'gems', "#{gemname}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
|
870
893
|
if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
|
871
894
|
set.call(ver, val)
|
872
895
|
end
|
873
896
|
end
|
874
897
|
if RUBY_VERSION >= '2.6'
|
875
898
|
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
876
|
-
parse.call(target.resolve_feature_path(
|
899
|
+
parse.call(target.resolve_feature_path(gemname)&.last)
|
877
900
|
end
|
878
|
-
if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show',
|
901
|
+
if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
|
879
902
|
raise_error 'gems directory not found'
|
880
903
|
end
|
881
904
|
end
|
@@ -958,9 +981,9 @@ module Squared
|
|
958
981
|
|
959
982
|
def read_rakefile
|
960
983
|
@read_rakefile ||= [].tap do |ret|
|
961
|
-
|
962
|
-
pwd_set(pass: !
|
963
|
-
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|
|
964
987
|
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
965
988
|
|
966
989
|
ret << [$1, $2]
|
@@ -982,25 +1005,45 @@ module Squared
|
|
982
1005
|
end
|
983
1006
|
|
984
1007
|
def rakefile
|
985
|
-
@rakefile
|
986
|
-
|
1008
|
+
return @rakefile unless @rakefile.nil?
|
1009
|
+
|
1010
|
+
@rakefile = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }.yield_self do |file|
|
1011
|
+
file ? path + file : false
|
987
1012
|
end
|
988
1013
|
end
|
989
1014
|
|
990
1015
|
def rakepwd
|
991
|
-
return
|
1016
|
+
return unless !pwd? && semgte?(Rake::VERSION, '13.0.4')
|
992
1017
|
|
993
1018
|
quote_option 'C', path
|
994
1019
|
end
|
995
1020
|
|
996
1021
|
def gempwd
|
997
|
-
return
|
1022
|
+
return unless !pwd? && semgte?(Gem::VERSION, '3.4.2')
|
998
1023
|
|
999
1024
|
quote_option 'C', path
|
1000
1025
|
end
|
1001
1026
|
|
1002
|
-
def
|
1003
|
-
|
1027
|
+
def gemfile
|
1028
|
+
return @gemfile unless @gemfile.nil?
|
1029
|
+
|
1030
|
+
@gemfile = [project, name].map! { |val| path + "#{val}.gemspec" }
|
1031
|
+
.concat(path.glob('*.gemspec'))
|
1032
|
+
.find { |file| File.exist?(file) } || false
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
def gemlib
|
1036
|
+
@gemlib ||= begin
|
1037
|
+
lib = Set.new(['lib'])
|
1038
|
+
if (spec = gemspec)
|
1039
|
+
lib.merge(spec.require_paths || [])
|
1040
|
+
end
|
1041
|
+
lib.select { |file| basepath(file).exist? }
|
1042
|
+
end
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
def gempath(val = version)
|
1046
|
+
File.join('gems', "#{gemname}-#{val}")
|
1004
1047
|
end
|
1005
1048
|
end
|
1006
1049
|
|
@@ -35,9 +35,7 @@ module Squared
|
|
35
35
|
kwargs[:hint] ||= 'unrecognized'
|
36
36
|
append(target, opts, delim: true) if kwargs.delete(:append)
|
37
37
|
warn log_message(Logger::WARN, opts.join(', '), pass: true, **kwargs)
|
38
|
-
|
39
|
-
|
40
|
-
raise_error 'user cancelled'
|
38
|
+
exit 1 unless pass || confirm("Run? [#{sub_style(target, styles: styles)}]", 'N')
|
41
39
|
end
|
42
40
|
|
43
41
|
def strip(val)
|
@@ -47,6 +45,15 @@ module Squared
|
|
47
45
|
val.map { |s| s.sub(/\A-([a-z\d])(.+)\z/i, '\1=\2').sub(/\A--?/, '') }.reject(&:empty?)
|
48
46
|
end
|
49
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
|
+
|
50
57
|
def arg?(target, *args, value: false, **)
|
51
58
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
52
59
|
unless s.empty?
|
@@ -56,14 +63,21 @@ module Squared
|
|
56
63
|
s = target.to_a.compact
|
57
64
|
r.any? { |pat| s.any?(pat) }
|
58
65
|
end
|
66
|
+
|
67
|
+
def pattern?(val)
|
68
|
+
val.match?(/(?:\A\^|\$\z)/) || val.match?(/(?:\.[*+]|\(\?:|\\[dsw]|\[.+\]|\{\d+,?\d*\})/)
|
69
|
+
end
|
59
70
|
end
|
60
71
|
|
61
72
|
attr_reader :target, :extras, :found, :errors, :values, :project, :path
|
62
73
|
|
63
74
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
64
|
-
:merge, :delete, :delete?, :delete_if, :grep, :inspect, :to_a, :to_s
|
75
|
+
:merge, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
65
76
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
66
|
-
:pop, :push, :join, :map, :map!, :select, :reject, :size
|
77
|
+
:pop, :push, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
78
|
+
|
79
|
+
def_delegator :@extras, :delete, :remove
|
80
|
+
def_delegator :@extras, :delete_if, :remove_if
|
67
81
|
|
68
82
|
def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
|
69
83
|
@target = target.is_a?(Set) ? target : target.to_set
|
@@ -141,35 +155,35 @@ module Squared
|
|
141
155
|
skip = false
|
142
156
|
opts.each do |opt|
|
143
157
|
next skip = true if opt == '--'
|
144
|
-
next
|
158
|
+
next push opt if skip
|
145
159
|
|
146
160
|
if single&.match?(opt)
|
147
|
-
|
161
|
+
add "-#{opt}"
|
148
162
|
elsif bare.include?(opt)
|
149
|
-
|
163
|
+
add(opt.size == 1 ? "-#{opt}" : "--#{opt}")
|
150
164
|
elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
|
151
|
-
|
165
|
+
add "--no-#{name}"
|
152
166
|
else
|
153
167
|
if opt =~ /\A([^=]+)=(.+)\z/
|
154
168
|
key = $1
|
155
169
|
val = $2
|
156
170
|
merge = m.include?(key)
|
157
171
|
if e.include?(key)
|
158
|
-
|
172
|
+
add shell_option(key, val, merge: merge)
|
159
173
|
elsif q.include?(key)
|
160
|
-
|
174
|
+
add quote_option(key, val, double: qq.include?(key), merge: merge)
|
161
175
|
elsif p.include?(key) && path
|
162
|
-
|
176
|
+
add quote_option(key, path + val, merge: merge)
|
163
177
|
elsif b.include?(key) || numcheck.call(key, val)
|
164
|
-
|
178
|
+
add basic_option(key, val, merge: merge)
|
165
179
|
elsif merge
|
166
|
-
|
180
|
+
add basic_option(key, val, merge: true)
|
167
181
|
else
|
168
|
-
|
182
|
+
push opt
|
169
183
|
end
|
170
184
|
opt = key
|
171
185
|
else
|
172
|
-
|
186
|
+
push opt
|
173
187
|
skip = true if args
|
174
188
|
end
|
175
189
|
skip = true if first&.any? { |s| s.is_a?(Regexp) ? opt.match?(s) : !opt.include?(s) }
|
@@ -232,7 +246,42 @@ module Squared
|
|
232
246
|
args = items[0...i] + args + items[i..-1]
|
233
247
|
target.clear
|
234
248
|
end
|
235
|
-
merge
|
249
|
+
merge args
|
250
|
+
self
|
251
|
+
end
|
252
|
+
|
253
|
+
def add_path(*args, **kwargs)
|
254
|
+
add shell_quote(path ? path.join(*args) : File.join(*args), **kwargs)
|
255
|
+
self
|
256
|
+
end
|
257
|
+
|
258
|
+
def add_quote(*args, **kwargs)
|
259
|
+
merge(args.map { |val| shell_quote(val, **kwargs) })
|
260
|
+
self
|
261
|
+
end
|
262
|
+
|
263
|
+
def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
|
264
|
+
found, other = if block_given?
|
265
|
+
partition(&blk)
|
266
|
+
elsif exclude.first.is_a?(Symbol)
|
267
|
+
partition(&exclude.first)
|
268
|
+
else
|
269
|
+
partition do |val|
|
270
|
+
next false if pattern && OptionPartition.pattern?(val)
|
271
|
+
|
272
|
+
exclude.none? { |pat| val.match?(Regexp.new(pat)) }
|
273
|
+
end
|
274
|
+
end
|
275
|
+
unless found.empty?
|
276
|
+
add '--' if delim
|
277
|
+
extras.clear
|
278
|
+
extras.concat(other)
|
279
|
+
if path
|
280
|
+
found.each { |val| add_path(val) }
|
281
|
+
else
|
282
|
+
merge(quote ? found.map! { |val| shell_quote(val) } : found)
|
283
|
+
end
|
284
|
+
end
|
236
285
|
self
|
237
286
|
end
|
238
287
|
|
@@ -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
|
-
|
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
|
122
|
+
newline = ARGV.any?(/^repo:/)
|
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.append(
|
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
|
@@ -10,9 +10,9 @@ module Squared
|
|
10
10
|
|
11
11
|
TASK_BASE = []
|
12
12
|
TASK_BATCH = {}
|
13
|
-
TASK_EXTEND =
|
13
|
+
TASK_EXTEND = Support.hashlist
|
14
14
|
TASK_KEYS = []
|
15
|
-
TASK_ALIAS =
|
15
|
+
TASK_ALIAS = Support.hashobj
|
16
16
|
TASK_NAME = {}
|
17
17
|
private_constant :TASK_BASE, :TASK_BATCH, :TASK_EXTEND, :TASK_KEYS, :TASK_ALIAS, :TASK_NAME
|
18
18
|
|
@@ -79,8 +79,8 @@ module Squared
|
|
79
79
|
@chain = {}
|
80
80
|
@exclude = exclude.freeze
|
81
81
|
@session = {
|
82
|
-
group:
|
83
|
-
parent:
|
82
|
+
group: Support.hashlist,
|
83
|
+
parent: Support.hashlist,
|
84
84
|
id: []
|
85
85
|
}
|
86
86
|
@data = {}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Squared
|
4
|
+
module Workspace
|
5
|
+
module Support
|
6
|
+
class << self
|
7
|
+
def hashobj
|
8
|
+
Hash.new { |data, key| data[key] = {} }
|
9
|
+
end
|
10
|
+
|
11
|
+
def hashlist
|
12
|
+
Hash.new { |data, key| data[key] = [] }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|