squared 0.5.0 → 0.5.2
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 +123 -0
- data/README.ruby.md +1 -1
- data/lib/squared/common/base.rb +5 -2
- data/lib/squared/common/format.rb +8 -2
- data/lib/squared/common/prompt.rb +28 -8
- data/lib/squared/common/system.rb +21 -14
- data/lib/squared/common/utils.rb +7 -3
- data/lib/squared/config.rb +7 -6
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +40 -30
- data/lib/squared/workspace/project/base.rb +104 -66
- data/lib/squared/workspace/project/docker.rb +15 -14
- data/lib/squared/workspace/project/git.rb +90 -61
- data/lib/squared/workspace/project/node.rb +40 -44
- data/lib/squared/workspace/project/python.rb +248 -47
- data/lib/squared/workspace/project/ruby.rb +132 -110
- data/lib/squared/workspace/project/support/class.rb +38 -2
- data/lib/squared/workspace/repo.rb +3 -2
- data/lib/squared/workspace/series.rb +8 -8
- data/lib/squared/workspace/support/data.rb +3 -3
- data/lib/squared/workspace.rb +8 -0
- metadata +1 -1
@@ -4,7 +4,7 @@ module Squared
|
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
6
|
class Ruby < Git
|
7
|
-
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
|
7
|
+
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb gems.rb Isolate].freeze
|
8
8
|
DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
|
9
9
|
OPT_RUBY = {
|
10
10
|
ruby: %w[0=im? a c e=q E=bm F=qm i=bm? I=pm l n p r=bm s S w W=bm? x=pm? d|debug jit rjit v|verbose y|yydebug
|
@@ -81,7 +81,7 @@ module Squared
|
|
81
81
|
'install' => %i[redownload local prefer-local].freeze,
|
82
82
|
'update' => %i[patch minor major all].freeze,
|
83
83
|
'outdated' => %i[patch minor major].freeze,
|
84
|
-
'gem' => %i[install uninstall update pristine outdated push
|
84
|
+
'gem' => %i[install uninstall update pristine outdated build push exec].freeze,
|
85
85
|
'ruby' => %i[file script version].freeze,
|
86
86
|
'exec' => nil,
|
87
87
|
'cache' => nil,
|
@@ -102,11 +102,10 @@ module Squared
|
|
102
102
|
end
|
103
103
|
dependfile_set GEMFILE
|
104
104
|
@autodetect = autodetect
|
105
|
-
@
|
106
|
-
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || (file = rakefile).nil?
|
105
|
+
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || rakefile.empty?
|
107
106
|
|
108
107
|
begin
|
109
|
-
File.foreach(
|
108
|
+
File.foreach(rakefile) do |line|
|
110
109
|
next unless line.match?(%r{\brequire\s+(["'])bundler/gem_tasks\1})
|
111
110
|
|
112
111
|
cmd = bundle_output('exec rake').to_s
|
@@ -135,26 +134,36 @@ module Squared
|
|
135
134
|
if flags.nil?
|
136
135
|
case action
|
137
136
|
when 'rake'
|
138
|
-
next
|
137
|
+
next if rakefile.empty?
|
139
138
|
|
140
|
-
format_desc action, nil,
|
139
|
+
format_desc action, nil, "task+,opts*|#{indexchar}index+|#,pattern*"
|
141
140
|
task action, [:command] do |_, args|
|
142
141
|
if args.command == '#'
|
143
|
-
format_list(read_rakefile,
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
if
|
148
|
-
|
149
|
-
elsif exception
|
150
|
-
indexerror n, list
|
142
|
+
format_list(read_rakefile, "rake[#{indexchar}N]", 'tasks', grep: args.extras, from: rakefile,
|
143
|
+
each: ->(val) { val[0] + val[1].to_s })
|
144
|
+
else
|
145
|
+
args, opts = args.to_a.partition { |val| indexitem(val) }
|
146
|
+
if args.empty?
|
147
|
+
rake(opts: opts)
|
151
148
|
else
|
152
|
-
|
153
|
-
|
149
|
+
list = read_rakefile
|
150
|
+
while (n, pre = indexitem(args.shift))
|
151
|
+
if (item = list[n - 1])
|
152
|
+
cmd = pre ? "#{pre} #{item.first}" : item.first
|
153
|
+
elsif exception
|
154
|
+
indexerror n, list
|
155
|
+
else
|
156
|
+
log.warn "rake task #{n} of #{list.size} (out of range)"
|
157
|
+
next
|
158
|
+
end
|
159
|
+
if opts.empty?
|
160
|
+
rake cmd
|
161
|
+
else
|
162
|
+
rake(cmd + shell_escape("[#{opts.join(',')}]"))
|
163
|
+
opts.clear
|
164
|
+
end
|
165
|
+
end
|
154
166
|
end
|
155
|
-
rake(args.extras.empty? ? cmd : cmd + shell_escape("[#{args.extras.join(',')}]"))
|
156
|
-
else
|
157
|
-
rake(opts: args.to_a)
|
158
167
|
end
|
159
168
|
end
|
160
169
|
when 'irb'
|
@@ -164,16 +173,12 @@ module Squared
|
|
164
173
|
format_desc action, nil, 'opts*,args*|:'
|
165
174
|
task action do |_, args|
|
166
175
|
args = args.to_a
|
167
|
-
|
168
|
-
args.pop
|
169
|
-
load = readline('Enter file and arguments', force: false)
|
170
|
-
end
|
171
|
-
irb(gemname, args, load: load)
|
176
|
+
irb(gemname, args, args: (readline('Enter file [arguments]', force: false) if args.delete(':')))
|
172
177
|
end
|
173
178
|
else
|
174
|
-
format_desc(action, nil,
|
175
|
-
|
176
|
-
|
179
|
+
format_desc(action, nil, 'opts*', before: case action
|
180
|
+
when 'cache', 'check' then nil
|
181
|
+
else 'command+' end)
|
177
182
|
task action do |_, args|
|
178
183
|
bundle(action, *args.to_a)
|
179
184
|
end
|
@@ -195,20 +200,24 @@ module Squared
|
|
195
200
|
case (filter = args.semver)
|
196
201
|
when 'major', 'minor', 'patch', 'interactive', 'i'
|
197
202
|
filter = 'interactive' if filter == 'i'
|
198
|
-
args = args.
|
203
|
+
args = args.extras
|
199
204
|
else
|
200
205
|
filter = nil
|
201
206
|
args = args.to_a
|
202
207
|
end
|
203
208
|
gem!(flag, args, filter: filter)
|
204
209
|
end
|
205
|
-
when :build, :push, :exec
|
206
|
-
format_desc(action, flag, 'opts*',
|
210
|
+
when :build, :push, :exec, :update
|
211
|
+
format_desc(action, flag, 'opts*', after: case flag
|
212
|
+
when :exec then 'command,args*'
|
213
|
+
when :push then 'file?'
|
214
|
+
when :update then 'name*'
|
215
|
+
end)
|
207
216
|
task flag do |_, args|
|
208
217
|
gem! flag, args.to_a
|
209
218
|
end
|
210
219
|
else
|
211
|
-
format_desc
|
220
|
+
format_desc(action, flag, 'opts*', after: flag == :pristine ? 'name*|name?@version' : 'name*')
|
212
221
|
task flag do |_, args|
|
213
222
|
args = param_guard(action, flag, args: args.to_a)
|
214
223
|
gem! flag, args
|
@@ -220,19 +229,18 @@ module Squared
|
|
220
229
|
format_desc action, flag, 'path,opts*,args*'
|
221
230
|
task flag, [:rb] do |_, args|
|
222
231
|
file = args.rb
|
223
|
-
args = args.
|
232
|
+
args = args.extras
|
224
233
|
unless file && !file.include?('*')
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
values: values, force: true, series: !args.include?('v'))
|
234
|
+
file, opts, prog = choice_index('Select a file', Dir.glob(file || '*.rb', base: path),
|
235
|
+
values: (file ? [] : ['Options']) << 'Arguments',
|
236
|
+
force: true, series: !args.include?('v'))
|
229
237
|
if file
|
230
|
-
|
238
|
+
prog = opts
|
231
239
|
else
|
232
240
|
args.concat(OptionPartition.strip(opts))
|
233
241
|
end
|
234
242
|
end
|
235
|
-
ruby(flag, args, file: file, args:
|
243
|
+
ruby(flag, args, file: file, args: prog)
|
236
244
|
end
|
237
245
|
when :script
|
238
246
|
format_desc action, flag, 'opts*,args*'
|
@@ -286,8 +294,8 @@ module Squared
|
|
286
294
|
on :first, :copy
|
287
295
|
dest = Pathname.new(into).realpath
|
288
296
|
print_item unless @output[0] || task_invoked?(/^copy(?::#{Ruby.ref}|$)/)
|
289
|
-
glob =
|
290
|
-
|
297
|
+
glob = Array(glob || '**/*')
|
298
|
+
Array(from).each_with_index do |val, i|
|
291
299
|
a = path + val
|
292
300
|
b = dest + val
|
293
301
|
c = glob[i] || glob.first
|
@@ -296,7 +304,7 @@ module Squared
|
|
296
304
|
copy_dir(a, b, c, pass: pass, verbose: verbose)
|
297
305
|
rescue StandardError => e
|
298
306
|
log.error e
|
299
|
-
ret = on
|
307
|
+
ret = on :error, :copy, e
|
300
308
|
raise if exception && ret != true
|
301
309
|
end
|
302
310
|
end
|
@@ -385,7 +393,7 @@ module Squared
|
|
385
393
|
index: 2)
|
386
394
|
end
|
387
395
|
end
|
388
|
-
out.call(
|
396
|
+
out.call('%2d. %s' % [start, line])
|
389
397
|
elsif line.start_with?('Gem')
|
390
398
|
unless stdin?
|
391
399
|
sub = { pat: /^(.+)(?<!\dm)(Gem|Latest)(.+)$/, styles: theme[:header], index: 2 }
|
@@ -477,6 +485,8 @@ module Squared
|
|
477
485
|
ver = nil
|
478
486
|
`ruby --version`
|
479
487
|
end)
|
488
|
+
break if workspace.windows?
|
489
|
+
|
480
490
|
unless val.empty?
|
481
491
|
out << trim.call(case cmd
|
482
492
|
when 'chruby.sh'
|
@@ -513,7 +523,7 @@ module Squared
|
|
513
523
|
end
|
514
524
|
out.map!(&:split)
|
515
525
|
pad = out.map(&:first).map!(&:size).max
|
516
|
-
puts(out.map! { |line|
|
526
|
+
puts(out.map! { |line| '%*s %s' % [pad, line.first, line[1..-1].join(' ')] })
|
517
527
|
end
|
518
528
|
return
|
519
529
|
end
|
@@ -525,8 +535,6 @@ module Squared
|
|
525
535
|
case flag
|
526
536
|
when :outdated
|
527
537
|
cmd << gempwd << 'outdated'
|
528
|
-
when :push
|
529
|
-
cmd << 'push' << project
|
530
538
|
else
|
531
539
|
cmd << flag
|
532
540
|
end
|
@@ -535,12 +543,9 @@ module Squared
|
|
535
543
|
case flag
|
536
544
|
when :install, :update
|
537
545
|
list.concat(OPT_GEM[:install_base])
|
538
|
-
first = ['=']
|
539
|
-
when :uninstall, :pristine
|
540
|
-
first = ['=']
|
541
546
|
end
|
542
547
|
cmd.merge(preopts)
|
543
|
-
op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GEM[:no][flag]
|
548
|
+
op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GEM[:no][flag])
|
544
549
|
op.each do |opt|
|
545
550
|
if opt =~ op.values
|
546
551
|
case $1
|
@@ -597,7 +602,7 @@ module Squared
|
|
597
602
|
|
598
603
|
a, b, c = item.first
|
599
604
|
if i == 0
|
600
|
-
line =
|
605
|
+
line = '%-*s %-*s %*s %*s' % [pad, ' #', d, a, e, b, f, c]
|
601
606
|
n = line.size
|
602
607
|
2.times do
|
603
608
|
line = sub_style(line, pat: /^(.+)(?<!\dm)(#{a}|#{c})(.*)$/, styles: theme[:header], index: 2)
|
@@ -648,7 +653,7 @@ module Squared
|
|
648
653
|
puts queue
|
649
654
|
queue = nil
|
650
655
|
end
|
651
|
-
puts "#{
|
656
|
+
puts '%*s %s %s %s' % [pad, "#{j}.", g, b, h]
|
652
657
|
update << a if filter == 'interactive' && confirm_outdated(a, c, item.last)
|
653
658
|
end
|
654
659
|
end
|
@@ -678,31 +683,32 @@ module Squared
|
|
678
683
|
cmd.merge(update)
|
679
684
|
run(cmd, banner: false, from: :'gem:update')
|
680
685
|
end
|
681
|
-
|
682
|
-
status = print_footer("major #{major} / minor #{minor} / patch #{patch}", right: true).split("\n")
|
683
|
-
status[1] = status[1]
|
684
|
-
.yield_self do |s|
|
685
|
-
sub_style(s, pat: /^( +major )(\d+)(.+)$/, styles: theme[:major], index: 2)
|
686
|
-
end
|
687
|
-
.yield_self do |s|
|
688
|
-
sub_style(s, pat: /^(.+)(minor )(\d+)(.+)$/, styles: theme[:active], index: 3)
|
689
|
-
end
|
690
|
-
puts status
|
691
|
-
end
|
686
|
+
print_status(major, minor, patch, from: :outdated)
|
692
687
|
end
|
693
688
|
on :last, from
|
694
689
|
return
|
695
|
-
when :build
|
696
|
-
if
|
697
|
-
if flag == :build && op.size == 1
|
698
|
-
op << shell_quote(path + op.first)
|
699
|
-
else
|
700
|
-
raise_error("unknown args: #{op.join(', ')}", hint: flag)
|
701
|
-
end
|
702
|
-
elsif flag == :build
|
690
|
+
when :build
|
691
|
+
if op.empty?
|
703
692
|
spec = [path + "#{project}.gemspec", path + "#{name}.gemspec", *path.glob('*.gemspec')]
|
704
693
|
op << File.basename(spec) if (spec = spec.find { |file| File.exist?(file) })
|
694
|
+
else
|
695
|
+
op << shell_quote(path + op.shift)
|
696
|
+
op.clear(pass: false)
|
705
697
|
end
|
698
|
+
when :push
|
699
|
+
if op.empty?
|
700
|
+
op << shell_quote(path + choice_index('Select a file', Dir.glob('*.gem', base: path), force: true))
|
701
|
+
else
|
702
|
+
file = path + op.shift
|
703
|
+
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
|
+
end
|
710
|
+
run_rb(from: from, interactive: "Push #{sub_style(project, styles: theme[:active])}")
|
711
|
+
return
|
706
712
|
when :exec
|
707
713
|
raise_error('missing command', hint: flag) if op.empty?
|
708
714
|
op << basic_option('gem', project) unless op.arg?('g', 'gem')
|
@@ -710,26 +716,43 @@ module Squared
|
|
710
716
|
op.push(args)
|
711
717
|
end
|
712
718
|
op.append(delim: true, quote: false)
|
719
|
+
when :update
|
720
|
+
unless op.arg?('system')
|
721
|
+
op.push(project) if op.empty?
|
722
|
+
op.adjoin
|
723
|
+
end
|
724
|
+
op.clear(errors: true)
|
713
725
|
else
|
714
|
-
raise_error('missing gemname', hint: flag) if op.empty?
|
715
|
-
|
726
|
+
raise_error('missing gemname', hint: flag) if op.empty?
|
727
|
+
case flag
|
728
|
+
when :install, :uninstall, :pristine
|
729
|
+
post = readline('Enter command [args]', force: true) if flag == :install && op.extras.delete(':')
|
716
730
|
if op.arg?('all')
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
731
|
+
if flag == :pristine
|
732
|
+
append_repeat 'skip', op.extras
|
733
|
+
op.reset
|
734
|
+
else
|
735
|
+
op.clear
|
736
|
+
end
|
737
|
+
elsif (n = op.extras.find_index { |val| val.match?(/(\A|[a-z])@\d/) })
|
738
|
+
items = op.extras.to_a
|
739
|
+
name = items.delete_at(n)
|
740
|
+
if (n = name.index('@')) == 0
|
741
|
+
pre = project
|
723
742
|
ver = name[1..-1]
|
724
743
|
else
|
725
|
-
|
726
|
-
ver = name[n + 1..-1]
|
744
|
+
pre = name[0, n]
|
745
|
+
ver = name[(n + 1)..-1]
|
727
746
|
end
|
728
|
-
op
|
729
|
-
|
747
|
+
op.adjoin(pre, shell_option('version', ver))
|
748
|
+
.clear(items)
|
749
|
+
.reset
|
750
|
+
elsif flag != :install
|
751
|
+
op.adjoin
|
730
752
|
end
|
731
753
|
end
|
732
754
|
op.append.clear(errors: true)
|
755
|
+
op << '--' << post if post
|
733
756
|
end
|
734
757
|
run_rb(from: from)
|
735
758
|
end
|
@@ -770,14 +793,13 @@ module Squared
|
|
770
793
|
run_s(args, banner: false, from: :rake)
|
771
794
|
end
|
772
795
|
|
773
|
-
def irb(name, opts = [], path: @path + 'lib',
|
796
|
+
def irb(name, opts = [], path: @path + 'lib', args: nil)
|
774
797
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
775
|
-
r =
|
776
|
-
r.
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
op << '--' << load
|
798
|
+
r = args ? [] : ['bundler/setup']
|
799
|
+
(r << name).each { |val| op << shell_option('r', val, merge: true) }
|
800
|
+
Array(path).each { |val| op << quote_option('I', val, merge: true) }
|
801
|
+
if args
|
802
|
+
op << '--' << args
|
781
803
|
op.clear
|
782
804
|
else
|
783
805
|
op.append(delim: true)
|
@@ -834,12 +856,13 @@ module Squared
|
|
834
856
|
next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
|
835
857
|
|
836
858
|
set.call(val, $1)
|
837
|
-
|
859
|
+
return gemdir? if @gemdir
|
838
860
|
end
|
839
861
|
end
|
840
862
|
end
|
841
|
-
|
842
|
-
|
863
|
+
require 'rubygems'
|
864
|
+
@gemdir = Pathname.new(Gem.dir) + gempath
|
865
|
+
else
|
843
866
|
parse = lambda do |path|
|
844
867
|
next unless path
|
845
868
|
|
@@ -852,9 +875,10 @@ module Squared
|
|
852
875
|
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
853
876
|
parse.call(target.resolve_feature_path(project)&.last)
|
854
877
|
end
|
855
|
-
pwd_set { parse.call(`#{bundle_output('show', project)}`) }
|
878
|
+
if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', project)}`) }
|
879
|
+
raise_error 'gems directory not found'
|
880
|
+
end
|
856
881
|
end
|
857
|
-
raise_error('parse failed', hint: @version || 'path') unless @gemdir
|
858
882
|
rescue StandardError => e
|
859
883
|
log.error e
|
860
884
|
@version = nil
|
@@ -871,7 +895,7 @@ module Squared
|
|
871
895
|
private
|
872
896
|
|
873
897
|
def run_rb(**kwargs)
|
874
|
-
run(banner: !@session
|
898
|
+
run(banner: !@session&.include?('--quiet'), **kwargs)
|
875
899
|
end
|
876
900
|
|
877
901
|
def append_bundle(opts, list, target: @session, append: nil)
|
@@ -933,18 +957,16 @@ module Squared
|
|
933
957
|
end
|
934
958
|
|
935
959
|
def read_rakefile
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
IO.popen(rake_output(pwd, '-AT').to_s).each do |line|
|
942
|
-
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
960
|
+
@read_rakefile ||= [].tap do |ret|
|
961
|
+
pwd = rakepwd
|
962
|
+
pwd_set(pass: !pwd.nil?) do
|
963
|
+
IO.popen(rake_output(pwd, '-AT').to_s).each do |line|
|
964
|
+
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
943
965
|
|
944
|
-
|
966
|
+
ret << [$1, $2]
|
967
|
+
end
|
945
968
|
end
|
946
969
|
end
|
947
|
-
@rakelist = ret
|
948
970
|
end
|
949
971
|
|
950
972
|
def preopts
|
@@ -960,19 +982,19 @@ module Squared
|
|
960
982
|
end
|
961
983
|
|
962
984
|
def rakefile
|
963
|
-
|
964
|
-
|
965
|
-
|
985
|
+
@rakefile ||= Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }.yield_self do |file|
|
986
|
+
file ? path + file : ''
|
987
|
+
end
|
966
988
|
end
|
967
989
|
|
968
990
|
def rakepwd
|
969
|
-
return
|
991
|
+
return if pwd? || Rake::VERSION < '13.0.4'
|
970
992
|
|
971
993
|
quote_option 'C', path
|
972
994
|
end
|
973
995
|
|
974
996
|
def gempwd
|
975
|
-
return
|
997
|
+
return if pwd? || Gem::VERSION < '3.4.2'
|
976
998
|
|
977
999
|
quote_option 'C', path
|
978
1000
|
end
|
@@ -35,7 +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
|
-
return if pass || confirm("Run? [#{sub_style(target, styles: styles)}]
|
38
|
+
return if pass || confirm("Run? [#{sub_style(target, styles: styles)}]", 'N')
|
39
39
|
|
40
40
|
raise_error 'user cancelled'
|
41
41
|
end
|
@@ -140,6 +140,7 @@ module Squared
|
|
140
140
|
numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && pat.match?(v) } }
|
141
141
|
skip = false
|
142
142
|
opts.each do |opt|
|
143
|
+
next skip = true if opt == '--'
|
143
144
|
next @extras << opt if skip
|
144
145
|
|
145
146
|
if single&.match?(opt)
|
@@ -189,7 +190,8 @@ module Squared
|
|
189
190
|
end
|
190
191
|
|
191
192
|
def append(*args, **kwargs)
|
192
|
-
|
193
|
+
args = extras if args.empty?
|
194
|
+
OptionPartition.append(target, *args, **kwargs)
|
193
195
|
self
|
194
196
|
end
|
195
197
|
|
@@ -206,6 +208,40 @@ module Squared
|
|
206
208
|
self
|
207
209
|
end
|
208
210
|
|
211
|
+
def adjoin(*args, start: false)
|
212
|
+
i = -1
|
213
|
+
(items = to_a).each_with_index do |val, index|
|
214
|
+
if i == 0
|
215
|
+
next unless val.start_with?('-')
|
216
|
+
|
217
|
+
i = index
|
218
|
+
break
|
219
|
+
elsif index > 0 && !val.start_with?('-')
|
220
|
+
if start
|
221
|
+
i = index + (start.is_a?(Numeric) ? start : 1)
|
222
|
+
break
|
223
|
+
end
|
224
|
+
i = 0
|
225
|
+
end
|
226
|
+
end
|
227
|
+
if i > 0
|
228
|
+
if args.empty?
|
229
|
+
args = dup
|
230
|
+
reset
|
231
|
+
end
|
232
|
+
args = items[0...i] + args + items[i..-1]
|
233
|
+
target.clear
|
234
|
+
end
|
235
|
+
merge(args)
|
236
|
+
self
|
237
|
+
end
|
238
|
+
|
239
|
+
def reset(errors: false)
|
240
|
+
extras.clear
|
241
|
+
clear(errors: true) if errors
|
242
|
+
self
|
243
|
+
end
|
244
|
+
|
209
245
|
def arg?(*args, **kwargs)
|
210
246
|
OptionPartition.arg?(target, *args, **kwargs)
|
211
247
|
end
|
@@ -177,7 +177,8 @@ module Squared
|
|
177
177
|
parse_opts.call(args)
|
178
178
|
stage = 'init'
|
179
179
|
puts if newline
|
180
|
-
|
180
|
+
Common::System.shell("repo init -u #{env('REPO_URL') || manifest_url} -m #{args.manifest || target}.xml",
|
181
|
+
chdir: root)
|
181
182
|
repo['all'].invoke
|
182
183
|
end
|
183
184
|
|
@@ -214,7 +215,7 @@ module Squared
|
|
214
215
|
|
215
216
|
path = sub_style(root, styles: theme[:inline])
|
216
217
|
@repo_override = Common::Prompt.confirm(
|
217
|
-
"#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation?
|
218
|
+
"#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation?",
|
218
219
|
'N',
|
219
220
|
timeout: env('REPO_TIMEOUT', 15, ignore: '0')
|
220
221
|
)
|
@@ -10,16 +10,16 @@ module Squared
|
|
10
10
|
|
11
11
|
TASK_BASE = []
|
12
12
|
TASK_BATCH = {}
|
13
|
-
TASK_EXTEND =
|
13
|
+
TASK_EXTEND = Workspace.hashlist
|
14
14
|
TASK_KEYS = []
|
15
|
-
TASK_ALIAS =
|
15
|
+
TASK_ALIAS = Workspace.hashobj
|
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
|
-
|
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|
|
40
|
+
obj.each { |key, val| TASK_ALIAS[key][ref] = val }
|
41
41
|
else
|
42
42
|
TASK_ALIAS[obj]&.delete(ref)
|
43
43
|
end
|
@@ -79,8 +79,8 @@ module Squared
|
|
79
79
|
@chain = {}
|
80
80
|
@exclude = exclude.freeze
|
81
81
|
@session = {
|
82
|
-
group:
|
83
|
-
parent:
|
82
|
+
group: Workspace.hashlist,
|
83
|
+
parent: Workspace.hashlist,
|
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
|
-
|
98
|
+
group[:"#{key}:#{g}"].concat(tasks)
|
99
99
|
else
|
100
100
|
items.concat(tasks)
|
101
101
|
end
|
@@ -106,7 +106,7 @@ module Squared
|
|
106
106
|
next unless (b = ws.find_base(proj)) && (n = b.ref.to_s) != g
|
107
107
|
|
108
108
|
id << n
|
109
|
-
|
109
|
+
parent[:"#{key}:#{n}"].concat(tasks)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Squared
|
4
4
|
module Workspace
|
5
5
|
module Support
|
6
|
-
RunData = Struct.new(:run, :block)
|
7
|
-
ChainData = Struct.new(:action, :step, :with, :before, :after, :sync)
|
8
|
-
BannerData = Struct.new(:command, :order, :styles, :border)
|
6
|
+
RunData = Struct.new('RunData', :run, :block)
|
7
|
+
ChainData = Struct.new('ChainData', :action, :step, :with, :before, :after, :sync)
|
8
|
+
BannerData = Struct.new('BannerData', :command, :order, :styles, :border)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/squared/workspace.rb
CHANGED