squared 0.4.8 → 0.4.10
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 +99 -1
- data/README.md +15 -17
- data/README.ruby.md +56 -37
- data/lib/squared/common/format.rb +10 -17
- data/lib/squared/common/prompt.rb +65 -19
- data/lib/squared/common/shell.rb +21 -14
- data/lib/squared/common/system.rb +6 -6
- data/lib/squared/common/utils.rb +1 -1
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +13 -17
- data/lib/squared/workspace/project/base.rb +83 -39
- data/lib/squared/workspace/project/docker.rb +95 -66
- data/lib/squared/workspace/project/git.rb +720 -390
- data/lib/squared/workspace/project/node.rb +39 -38
- data/lib/squared/workspace/project/python.rb +36 -42
- data/lib/squared/workspace/project/ruby.rb +143 -108
- data/lib/squared/workspace/project/support/class.rb +29 -13
- data/lib/squared/workspace/repo.rb +4 -4
- data/lib/squared/workspace/series.rb +9 -6
- data/lib/squared/workspace.rb +1 -1
- metadata +1 -1
@@ -7,23 +7,23 @@ 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
|
11
|
-
|
12
|
-
|
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
|
11
|
+
backtrace-limit=i crash-report=q disable=q dump=q enable=q encoding=b external-encoding=b
|
12
|
+
internal-encoding=b parser=b].freeze,
|
13
13
|
rake: %w[A|all B|build-all comments n|dry-run p|execute-print=q m|multitask P|prereqs q|quiet
|
14
14
|
X|no-deprecation-warnings N|no-search G|no-system nosearch nosystem rules s|silent g|system
|
15
|
-
v|verbose backtrace=b? D|describe=q? e|execute=q E|execute-continue=q
|
16
|
-
|
15
|
+
v|verbose backtrace=b? D|describe=q? e|execute=q E|execute-continue=q job-stats=b? j|jobs=i?
|
16
|
+
I|libdir=p R|rakelib=p rakelibdir=p r|require=b suppress-backtrace=q T|tasks=q? t|trace=b?
|
17
17
|
W|where=q?].freeze,
|
18
|
-
irb: %w[d f U w E=b I=p r=b W=
|
19
|
-
inspect multiline no-pager noautocomplete nocolorize noecho
|
18
|
+
irb: %w[d f U w E=b I=p r=b W=im? autocomplete colorize echo echo-on-assignment extra-doc-dir inf-ruby-mode
|
19
|
+
inspect multiline no-pager noautocomplete nocolorize noecho noecho-on-assignment noinspect
|
20
20
|
nomultiline noprompt noscript nosingleline noverbose regexp-completor sample-book-mode script
|
21
21
|
simple-prompt single-irb singleline tracer truncate-echo-on-assignment type-completor verbose
|
22
22
|
back-trace-limit=i context-mode=i prompt=b prompt-mode=b].freeze
|
23
23
|
}.freeze
|
24
24
|
OPT_BUNDLE = {
|
25
25
|
common: %w[no-color V|verbose retry=i].freeze,
|
26
|
-
install: %w[frozen no-cache no-prune system
|
26
|
+
install: %w[frozen no-cache no-prune system binstubs=p? path=p standalone=q? target-rbconfig=p trust-policy=b
|
27
27
|
with=q without=q].freeze,
|
28
28
|
install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
|
29
29
|
update: %w[conservative local pre redownload ruby strict bundler=b? g|group=q source=b].freeze,
|
@@ -42,18 +42,19 @@ module Squared
|
|
42
42
|
target-rbconfig=p? P|trust-policy=b without=b].freeze,
|
43
43
|
update: %w[system=b?].freeze,
|
44
44
|
uninstall: %w[a D I x vendor n|bindir=p i|install-dir=p platform=b v|version=b].freeze,
|
45
|
-
outdated: %w[b|both clear-sources l|local no-http-proxy r|remote B|bulk-threshold=i p|http-proxy=q?
|
46
|
-
|
47
|
-
push: %w[no-http-proxy attestation=p host=q
|
45
|
+
outdated: %w[b|both clear-sources l|local no-http-proxy r|remote B|bulk-threshold=i p|http-proxy=q? platform=q
|
46
|
+
source=q].freeze,
|
47
|
+
push: %w[no-http-proxy attestation=p host=q p|http-proxy=q? key=b otp=b].freeze,
|
48
48
|
build: %w[force strict o|output=p platform=q].freeze,
|
49
|
-
exec: %w[conservative
|
50
|
-
pristine: %w[all
|
51
|
-
|
49
|
+
exec: %w[conservative no-prerelease prerelease g|gem=v version=b].freeze,
|
50
|
+
pristine: %w[all only-executables only-missing-extensions only-plugins n|bindir=p i|install-dir=p skip=b
|
51
|
+
v|version=b].freeze,
|
52
52
|
no: {
|
53
|
-
install: %w[env-shebang force format-executable http-proxy lock minimal-deps post-install-message
|
54
|
-
|
53
|
+
install: %w[env-shebang force format-executable http-proxy lock minimal-deps post-install-message prerelease
|
54
|
+
suggestions user-install wrappers].freeze,
|
55
55
|
uninstall: %w[abort-on-dependent all check-development executables force format-executable
|
56
|
-
ignore-dependencies user-install].freeze
|
56
|
+
ignore-dependencies user-install].freeze,
|
57
|
+
pristine: %w[env-shebang extensions].freeze
|
57
58
|
}.freeze
|
58
59
|
}.freeze
|
59
60
|
private_constant :GEMFILE, :DIR_RUBY, :OPT_RUBY, :OPT_BUNDLE, :OPT_GEM
|
@@ -101,7 +102,7 @@ module Squared
|
|
101
102
|
end
|
102
103
|
@autodetect = autodetect
|
103
104
|
@dependindex = GEMFILE.index { |file| basepath(file).exist? }
|
104
|
-
@dependfile =
|
105
|
+
@dependfile = @path + GEMFILE[@dependindex || 0]
|
105
106
|
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || (file = rakefile).nil?
|
106
107
|
|
107
108
|
begin
|
@@ -160,17 +161,19 @@ module Squared
|
|
160
161
|
next unless (spec = basepath("#{project}.gemspec") || basepath("#{name}.gemspec"))
|
161
162
|
next unless basepath('lib').join("#{gemname = stripext(spec)}.rb").exist?
|
162
163
|
|
163
|
-
format_desc action, nil, 'opts*,args
|
164
|
+
format_desc action, nil, 'opts*,args*|:'
|
164
165
|
task action do |_, args|
|
165
|
-
|
166
|
+
args = args.to_a
|
167
|
+
if args.last == ':'
|
168
|
+
args.pop
|
169
|
+
load = readline('Enter file and arguments', force: false)
|
170
|
+
end
|
171
|
+
irb(gemname, args, load: load)
|
166
172
|
end
|
167
173
|
else
|
168
174
|
format_desc(action, nil, OPT_BUNDLE[action.to_sym], after: case action
|
169
|
-
when 'cache', 'check'
|
170
|
-
|
171
|
-
else
|
172
|
-
'command+'
|
173
|
-
end)
|
175
|
+
when 'cache', 'check' then nil
|
176
|
+
else 'command+' end)
|
174
177
|
task action do |_, args|
|
175
178
|
bundle(action, *args.to_a)
|
176
179
|
end
|
@@ -187,7 +190,7 @@ module Squared
|
|
187
190
|
when 'gem'
|
188
191
|
case flag
|
189
192
|
when :outdated
|
190
|
-
format_desc action, flag, 'major|minor|patch|
|
193
|
+
format_desc action, flag, 'major|minor|patch|interactive?,opts*'
|
191
194
|
task flag, [:semver] do |_, args|
|
192
195
|
case (filter = args.semver)
|
193
196
|
when 'major', 'minor', 'patch', 'interactive', 'i'
|
@@ -207,8 +210,8 @@ module Squared
|
|
207
210
|
else
|
208
211
|
format_desc action, flag, "opts*,name+#{flag == :pristine ? '|name?@version' : ''}"
|
209
212
|
task flag do |_, args|
|
210
|
-
|
211
|
-
gem! flag,
|
213
|
+
args = param_guard(action, flag, args: args.to_a)
|
214
|
+
gem! flag, args
|
212
215
|
end
|
213
216
|
end
|
214
217
|
when 'ruby'
|
@@ -216,19 +219,21 @@ module Squared
|
|
216
219
|
when :file
|
217
220
|
format_desc action, flag, 'path,opts*,args*'
|
218
221
|
task flag, [:rb] do |_, args|
|
219
|
-
file =
|
220
|
-
|
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
|
222
|
+
if (file = args.rb)
|
223
|
+
args = args.to_a.drop(1)
|
227
224
|
else
|
228
|
-
|
229
|
-
|
225
|
+
file, opts, extra = choice_index('Select a file', Dir.glob('*.rb', base: path),
|
226
|
+
values: %w[Options Arguments], force: true, series: true)
|
227
|
+
args = OptionPartition.strip(opts)
|
228
|
+
ENV['RUBY_ARGS'] = extra if extra
|
230
229
|
end
|
231
|
-
ruby(flag,
|
230
|
+
ruby(flag, args, file: file)
|
231
|
+
end
|
232
|
+
when :script
|
233
|
+
format_desc action, flag, 'opts*,args*'
|
234
|
+
task flag do |_, args|
|
235
|
+
command = ENV['RUBY_E'] || readline('Enter script', force: true, multiline: ['##', ';'])
|
236
|
+
ruby(flag, args.to_a, command: command)
|
232
237
|
end
|
233
238
|
when :version
|
234
239
|
format_desc action, flag
|
@@ -248,8 +253,9 @@ module Squared
|
|
248
253
|
if @depend
|
249
254
|
super
|
250
255
|
elsif outdated?
|
251
|
-
workspace.rev_clear(name)
|
256
|
+
workspace.rev_clear(name, sync: sync)
|
252
257
|
cmd = bundle_session 'install'
|
258
|
+
cmd << '--without=development' if prod?
|
253
259
|
if (n = option('jobs')).to_i > 0
|
254
260
|
cmd << "-j#{n}"
|
255
261
|
end
|
@@ -257,14 +263,18 @@ module Squared
|
|
257
263
|
end
|
258
264
|
end
|
259
265
|
|
260
|
-
def copy(from: 'lib',
|
266
|
+
def copy(from: 'lib', into: @gemdir, override: false, **kwargs)
|
267
|
+
glob = kwargs[:include]
|
268
|
+
pass = kwargs[:exclude]
|
261
269
|
if @copy && !override
|
262
270
|
return super unless @copy.is_a?(Hash)
|
263
271
|
|
264
272
|
from = @copy[:from] if @copy.key?(:from)
|
265
273
|
glob = @copy[:include] if @copy.key?(:include)
|
266
|
-
|
274
|
+
pass = @copy[:exclude] if @copy.key?(:exclude)
|
267
275
|
into = @copy[:into] if @copy.key?(:into)
|
276
|
+
elsif @copy == false
|
277
|
+
return
|
268
278
|
end
|
269
279
|
return unless into
|
270
280
|
|
@@ -273,12 +283,12 @@ module Squared
|
|
273
283
|
print_item unless @output[0] || task_invoked?(/^copy(?::#{Ruby.ref}|$)/)
|
274
284
|
glob = as_a(glob || '**/*')
|
275
285
|
as_a(from).each_with_index do |val, i|
|
276
|
-
a =
|
277
|
-
b = dest
|
278
|
-
c = glob[i] || glob
|
279
|
-
log.info "cp #{a
|
286
|
+
a = path + val
|
287
|
+
b = dest + val
|
288
|
+
c = glob[i] || glob.first
|
289
|
+
log.info "cp #{a + c} #{b}"
|
280
290
|
begin
|
281
|
-
copy_dir(a, b, c, pass:
|
291
|
+
copy_dir(a, b, c, pass: pass, verbose: verbose)
|
282
292
|
rescue StandardError => e
|
283
293
|
log.error e
|
284
294
|
ret = on(:error, :copy, e)
|
@@ -310,8 +320,8 @@ module Squared
|
|
310
320
|
data = line.scan(SEM_VER)
|
311
321
|
next unless (cur = data.shift) && (lat = data.shift)
|
312
322
|
|
313
|
-
semver
|
314
|
-
semver
|
323
|
+
semver cur
|
324
|
+
semver lat
|
315
325
|
c = cur.join
|
316
326
|
l = lat.join
|
317
327
|
styles = []
|
@@ -414,7 +424,7 @@ module Squared
|
|
414
424
|
def update(flag, opts = [])
|
415
425
|
bundle_session 'update', "--#{flag}"
|
416
426
|
append_bundle(opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common],
|
417
|
-
append: flag == :all ? nil :
|
427
|
+
append: flag == :all ? nil : /\A\w+=/)
|
418
428
|
run_rb(from: :update)
|
419
429
|
end
|
420
430
|
|
@@ -423,7 +433,7 @@ module Squared
|
|
423
433
|
when :file, :script
|
424
434
|
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
425
435
|
if file
|
426
|
-
op.extras.unshift(shell_quote(
|
436
|
+
op.extras.unshift(shell_quote(path + file))
|
427
437
|
elsif command
|
428
438
|
op << quote_option('e', command, option: false)
|
429
439
|
end
|
@@ -446,7 +456,7 @@ module Squared
|
|
446
456
|
].each do |val|
|
447
457
|
next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
|
448
458
|
|
449
|
-
trim = ->(s) { s[
|
459
|
+
trim = ->(s) { s[/\A\D+\d+\.\d+(?:\.\S+)?/, 0].sub(/\A([a-z]+)-/i, '\1 ') }
|
450
460
|
ver = '.ruby-version'
|
451
461
|
out << trim.call(case (cmd = File.basename(val))
|
452
462
|
when 'rvm'
|
@@ -490,7 +500,7 @@ module Squared
|
|
490
500
|
end
|
491
501
|
if ver
|
492
502
|
path.ascend do |ent|
|
493
|
-
next unless (ent
|
503
|
+
next unless (ent += ver).exist?
|
494
504
|
|
495
505
|
hint = File.read(ent).lines(chomp: true).reject(&:empty?).join(', ') rescue nil
|
496
506
|
out << message("found #{ent}", hint: hint)
|
@@ -522,21 +532,17 @@ module Squared
|
|
522
532
|
case flag
|
523
533
|
when :install, :update
|
524
534
|
list.concat(OPT_GEM[:install_base])
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
no = OPT_GEM[:no][:uninstall]
|
529
|
-
first = true
|
530
|
-
when :pristine
|
531
|
-
first = true
|
535
|
+
first = ['=']
|
536
|
+
when :uninstall, :pristine
|
537
|
+
first = ['=']
|
532
538
|
end
|
533
539
|
cmd.merge(preopts)
|
534
|
-
op = OptionPartition.new(opts, list, cmd, project: self, no: no, first: first)
|
540
|
+
op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GEM[:no][flag], first: first)
|
535
541
|
op.each do |opt|
|
536
542
|
if opt =~ op.values
|
537
543
|
case $1
|
538
544
|
when 'g', 'gem'
|
539
|
-
op << (flag == :exec ? shell_option($1, $2) : quote_option($1,
|
545
|
+
op << (flag == :exec ? shell_option($1, $2) : quote_option($1, path + $2))
|
540
546
|
end
|
541
547
|
elsif opt.include?('=') && !%i[outdated build push exec].include?(flag)
|
542
548
|
op.errors << opt
|
@@ -559,8 +565,8 @@ module Squared
|
|
559
565
|
items = [[%w[Gem Current Latest], nil]]
|
560
566
|
IO.popen(cmd.done).each do |line|
|
561
567
|
if line =~ /^(\S+) \((\S+) < ([^)]+)\)$/
|
562
|
-
cur = semscan
|
563
|
-
lat = semscan
|
568
|
+
cur = semscan $2
|
569
|
+
lat = semscan $3
|
564
570
|
items << [$~.to_a.drop(1), if semmajor?(cur, lat)
|
565
571
|
1
|
566
572
|
else
|
@@ -570,20 +576,19 @@ module Squared
|
|
570
576
|
puts line
|
571
577
|
end
|
572
578
|
end
|
573
|
-
if items.size
|
574
|
-
puts 'No updates were found'
|
575
|
-
else
|
579
|
+
if items.size > 1
|
576
580
|
pad = [items.size.to_s.size + 1, 3].max
|
577
581
|
d = 0
|
578
582
|
e = 0
|
579
583
|
f = 0
|
584
|
+
j = 0
|
585
|
+
queue = nil
|
580
586
|
items.each do |item|
|
581
587
|
a, b, c = item.first
|
582
588
|
d = a.size if a.size > d
|
583
589
|
e = b.size if b.size > e
|
584
590
|
f = c.size if c.size > f
|
585
591
|
end
|
586
|
-
j = 0
|
587
592
|
items.each_with_index do |item, i|
|
588
593
|
next if i == 0 && stdin?
|
589
594
|
|
@@ -594,11 +599,10 @@ module Squared
|
|
594
599
|
2.times do
|
595
600
|
line = sub_style(line, pat: /^(.+)(?<!\dm)(#{a}|#{c})(.*)$/, styles: theme[:header], index: 2)
|
596
601
|
end
|
597
|
-
|
598
|
-
puts sub_style(ARG[:BORDER][1] * n, styles: borderstyle)
|
602
|
+
queue = [line, sub_style(ARG[:BORDER][1] * n, styles: borderstyle)]
|
599
603
|
else
|
600
604
|
g = a.ljust(d)
|
601
|
-
pat = [
|
605
|
+
pat = [/^([^.]+\.)([^.]+\..+)$/, /^([^.]+\.[^.]+\.)(.+)$/]
|
602
606
|
pre = b.start_with?('0.')
|
603
607
|
latest = [theme[:current]]
|
604
608
|
case item.last
|
@@ -638,50 +642,58 @@ module Squared
|
|
638
642
|
b = sub_style(b, *colormap(styles), pat: pat, index: 2)
|
639
643
|
h = sub_style(c.rjust(f), styles: latest.flatten.compact, pat: pat, index: 2)
|
640
644
|
j += 1
|
645
|
+
if queue
|
646
|
+
puts queue
|
647
|
+
queue = nil
|
648
|
+
end
|
641
649
|
puts "#{"#{j}.".rjust(pad)} #{g} #{b} #{h}"
|
642
650
|
update << a if filter == 'interactive' && confirm_outdated(a, c, item.last)
|
643
651
|
end
|
644
652
|
end
|
645
653
|
end
|
646
654
|
end
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
655
|
+
if major + minor + patch == 0
|
656
|
+
puts 'No updates were found'
|
657
|
+
else
|
658
|
+
unless update.empty?
|
659
|
+
cmd = gem_output 'update', '-f'
|
660
|
+
if (val = option('document', prefix: 'gem', ignore: false))
|
661
|
+
cmd << case val
|
662
|
+
when '0', 'false'
|
663
|
+
'--no-document'
|
664
|
+
else
|
665
|
+
basic_option('document', val)
|
666
|
+
end
|
667
|
+
end
|
668
|
+
if (val = option('user-install', prefix: 'gem', ignore: false))
|
669
|
+
cmd << case val
|
670
|
+
when '0', 'false'
|
671
|
+
'--no-user-install'
|
672
|
+
else
|
673
|
+
'--user-install'
|
674
|
+
end
|
675
|
+
end
|
676
|
+
cmd.merge(update)
|
677
|
+
run(cmd, banner: false, from: :'gem:update')
|
656
678
|
end
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
'--user-install'
|
663
|
-
end
|
679
|
+
unless stdin?
|
680
|
+
status = print_footer("major #{major} / minor #{minor} / patch #{patch}", right: true).split("\n")
|
681
|
+
status[1] = sub_style(status[1], pat: /^( +major )(\d+)(.+)$/, styles: theme[:major], index: 2)
|
682
|
+
status[1] = sub_style(status[1], pat: /^(.+)(minor )(\d+)(.+)$/, styles: theme[:active], index: 3)
|
683
|
+
puts status
|
664
684
|
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
685
|
end
|
674
686
|
on :last, from
|
675
687
|
return
|
676
688
|
when :build, :push
|
677
689
|
if !op.empty?
|
678
690
|
if flag == :build && op.size == 1
|
679
|
-
op << shell_quote(
|
691
|
+
op << shell_quote(path + op.first)
|
680
692
|
else
|
681
693
|
raise_error("unknown args: #{op.join(', ')}", hint: flag)
|
682
694
|
end
|
683
695
|
elsif flag == :build
|
684
|
-
spec = [
|
696
|
+
spec = [path + "#{project}.gemspec", path + "#{name}.gemspec", *Dir.glob(path + '*.gemspec')]
|
685
697
|
op << File.basename(spec) if (spec = spec.find { |file| File.exist?(file) })
|
686
698
|
end
|
687
699
|
when :exec
|
@@ -692,7 +704,7 @@ module Squared
|
|
692
704
|
if flag == :pristine
|
693
705
|
if op.arg?('all')
|
694
706
|
append_repeat 'skip', op.extras
|
695
|
-
op.clear
|
707
|
+
op.extras.clear
|
696
708
|
elsif (n = op.first.index('@'))
|
697
709
|
name = op.shift
|
698
710
|
if n == 0
|
@@ -743,11 +755,16 @@ module Squared
|
|
743
755
|
run_s(args, banner: false, from: :rake)
|
744
756
|
end
|
745
757
|
|
746
|
-
def irb(name, opts = [], path:
|
747
|
-
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first:
|
748
|
-
as_a(name).each { |val| op << shell_option('r', val) }
|
749
|
-
as_a(path).each { |val| op << quote_option('I', val) }
|
750
|
-
|
758
|
+
def irb(name, opts = [], path: @path + 'lib', load: nil)
|
759
|
+
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
760
|
+
as_a(name).each { |val| op << shell_option('r', val, merge: true) }
|
761
|
+
as_a(path).each { |val| op << quote_option('I', val, merge: true) }
|
762
|
+
if load
|
763
|
+
op << '--' << load
|
764
|
+
op.clear
|
765
|
+
else
|
766
|
+
op.append(delim: true)
|
767
|
+
end
|
751
768
|
run(banner: false)
|
752
769
|
end
|
753
770
|
|
@@ -759,8 +776,26 @@ module Squared
|
|
759
776
|
return true if super || (@copy.is_a?(Hash) && copy.fetch(:into, nil))
|
760
777
|
return gemdir? if @gemdir
|
761
778
|
|
762
|
-
if @version
|
763
|
-
|
779
|
+
if @version
|
780
|
+
begin
|
781
|
+
case @autodetect
|
782
|
+
when 'rvm'
|
783
|
+
@gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
|
784
|
+
when 'rbenv'
|
785
|
+
if pwd_set { `rbenv which ruby` } =~ %r{^(.+[\\/]versions[\\/](\d\.\d)\.[^\\/]+)[\\/]bin[\\/]ruby$}
|
786
|
+
@gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
|
787
|
+
end
|
788
|
+
when 'asdf'
|
789
|
+
@gemdir = pwd_set { `asdf where ruby` }
|
790
|
+
@gemdir = @gemdir =~ /(\d\.\d)\.[^.]+$/ && File.join(@gemdir, 'lib/ruby/gems', "#{$1}.0")
|
791
|
+
when /bundler?/
|
792
|
+
@gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
|
793
|
+
end
|
794
|
+
rescue StandardError => e
|
795
|
+
log.debug e
|
796
|
+
else
|
797
|
+
@gemdir = Pathname.new(@gemdir) if @gemdir
|
798
|
+
end
|
764
799
|
return true if gemdir?
|
765
800
|
end
|
766
801
|
return false unless @autodetect
|
@@ -768,7 +803,7 @@ module Squared
|
|
768
803
|
set = lambda do |val, path|
|
769
804
|
log.warn "using version #{val} (given #{@version})" if @version && @version != val
|
770
805
|
@version = val
|
771
|
-
@gemdir = Pathname.new(path.strip)
|
806
|
+
@gemdir = Pathname.new(path.strip) + gempath
|
772
807
|
end
|
773
808
|
if @version
|
774
809
|
pwd = gempwd
|
@@ -899,7 +934,7 @@ module Squared
|
|
899
934
|
end
|
900
935
|
|
901
936
|
def gemdir?
|
902
|
-
@gemdir.exist? && !@gemdir.empty?
|
937
|
+
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
903
938
|
end
|
904
939
|
|
905
940
|
def variables
|
@@ -909,7 +944,7 @@ module Squared
|
|
909
944
|
def rakefile
|
910
945
|
return unless (file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? })
|
911
946
|
|
912
|
-
|
947
|
+
path + file
|
913
948
|
end
|
914
949
|
|
915
950
|
def rakepwd
|
@@ -35,18 +35,25 @@ 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)}] [y/N] ", 'N'
|
38
|
+
return if pass || confirm("Run? [#{sub_style(target, styles: styles)}] [y/N] ", 'N')
|
39
39
|
|
40
40
|
raise_error 'user cancelled'
|
41
41
|
end
|
42
42
|
|
43
|
+
def strip(val)
|
44
|
+
return [] unless val
|
45
|
+
|
46
|
+
val = shell_split(val) if val.is_a?(String)
|
47
|
+
val.map { |s| s.sub(/\A-([a-z\d])(.+)\z/mi, '\1=\2').sub(/\A--?/, '') }.reject(&:empty?)
|
48
|
+
end
|
49
|
+
|
43
50
|
def arg?(target, *args, value: false)
|
44
51
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
45
52
|
unless s.empty?
|
46
53
|
s.map! { |val| Regexp.escape(shell_option(val)) }
|
47
54
|
r << /\A(?:#{s.join('|')})#{value ? '[ =].' : '(?: |=|\z)'}/
|
48
55
|
end
|
49
|
-
target.any? { |opt| r.any? { |val| opt
|
56
|
+
target.any? { |opt| r.any? { |val| opt&.match?(val) } }
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
@@ -66,7 +73,7 @@ module Squared
|
|
66
73
|
parse(list, opts, **kwargs, &blk)
|
67
74
|
end
|
68
75
|
|
69
|
-
def parse(list, opts = extras, no: nil, single: nil, args: false, first:
|
76
|
+
def parse(list, opts = extras, no: nil, single: nil, args: false, first: nil, &blk)
|
70
77
|
@extras = []
|
71
78
|
@values = []
|
72
79
|
bare = []
|
@@ -79,8 +86,8 @@ module Squared
|
|
79
86
|
i = []
|
80
87
|
f = []
|
81
88
|
si = []
|
82
|
-
list.
|
83
|
-
x, y = val.split('|')
|
89
|
+
list.flat_map do |val|
|
90
|
+
x, y = val.split('|', 2)
|
84
91
|
if y
|
85
92
|
if (n = val.index('='))
|
86
93
|
x += val[n..-1]
|
@@ -90,7 +97,6 @@ module Squared
|
|
90
97
|
x
|
91
98
|
end
|
92
99
|
end
|
93
|
-
.flatten
|
94
100
|
.each do |val|
|
95
101
|
if (n = val.index('='))
|
96
102
|
flag = val[0, n]
|
@@ -125,6 +131,12 @@ module Squared
|
|
125
131
|
end
|
126
132
|
no = (no || []).map { |val| (n = val.index('=')) ? val[0, n] : val }
|
127
133
|
bare.concat(no)
|
134
|
+
numtype = [
|
135
|
+
[i, /\A\d+\z/],
|
136
|
+
[f, /\A\d*(?:\.\d+)?\z/],
|
137
|
+
[si, /\A-?\d+\z/]
|
138
|
+
].freeze
|
139
|
+
numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && pat.match?(v) } }
|
128
140
|
skip = false
|
129
141
|
opts.each do |opt|
|
130
142
|
next @extras << opt if skip
|
@@ -140,14 +152,13 @@ module Squared
|
|
140
152
|
key = $1
|
141
153
|
val = $2
|
142
154
|
merge = m.include?(key)
|
143
|
-
r = ->(flag, pat) { flag.include?(key) && pat.match?(val) }
|
144
155
|
if e.include?(key)
|
145
156
|
target << shell_option(key, val, merge: merge)
|
146
157
|
elsif q.include?(key)
|
147
158
|
target << quote_option(key, val, double: qq.include?(key), merge: merge)
|
148
159
|
elsif p.include?(key) && path
|
149
|
-
target << quote_option(key, path
|
150
|
-
elsif b.include?(key) ||
|
160
|
+
target << quote_option(key, path + val, merge: merge)
|
161
|
+
elsif b.include?(key) || numcheck.call(key, val)
|
151
162
|
target << basic_option(key, val, merge: merge)
|
152
163
|
elsif merge
|
153
164
|
target << basic_option(key, val, merge: true)
|
@@ -159,10 +170,10 @@ module Squared
|
|
159
170
|
@extras << opt
|
160
171
|
skip = true if args
|
161
172
|
end
|
162
|
-
skip = true if first
|
173
|
+
skip = true if first&.any? { |s| s.is_a?(Regexp) ? opt.match?(s) : !opt.include?(s) }
|
163
174
|
end
|
164
175
|
end
|
165
|
-
@values = @values.empty? ? /\A\s+\z/ : /\A(#{@values.join('|')})=(.+)\z/
|
176
|
+
@values = @values.empty? ? /\A\s+\z/ : /\A(#{@values.join('|')})=(.+)\z/m
|
166
177
|
@extras.each_with_index(&blk) if block_given?
|
167
178
|
self
|
168
179
|
end
|
@@ -181,9 +192,14 @@ module Squared
|
|
181
192
|
self
|
182
193
|
end
|
183
194
|
|
184
|
-
def clear(opts = nil, **kwargs)
|
185
|
-
opts ||= (kwargs[:errors] ? errors : extras)
|
195
|
+
def clear(opts = nil, errors: false, **kwargs)
|
186
196
|
styles = project.theme[:inline] if project
|
197
|
+
if !opts
|
198
|
+
opts = errors ? @errors : @extras
|
199
|
+
elsif errors
|
200
|
+
OptionPartition.clear(target, @errors, styles: styles, **kwargs)
|
201
|
+
@errors.clear
|
202
|
+
end
|
187
203
|
OptionPartition.clear(target, opts.reject { |val| found.include?(val) }, styles: styles, **kwargs)
|
188
204
|
opts.clear
|
189
205
|
self
|
@@ -6,7 +6,7 @@ module Squared
|
|
6
6
|
class << self
|
7
7
|
def read_manifest(path)
|
8
8
|
require 'rexml/document'
|
9
|
-
return unless (file = path
|
9
|
+
return unless (file = path + '.repo/manifest.xml').exist?
|
10
10
|
|
11
11
|
doc = REXML::Document.new(file.read)
|
12
12
|
doc.elements['manifest/include'].attributes['name']&.sub('.xml', '')
|
@@ -39,12 +39,12 @@ module Squared
|
|
39
39
|
raise_error("path does not exist: #{val}", hint: 'REPO_ROOT') unless repo_confirm
|
40
40
|
end
|
41
41
|
@root.join(main).realdirpath
|
42
|
-
elsif repo_install?(parent: true) && (!@home.exist? || @root
|
42
|
+
elsif repo_install?(parent: true) && (!@home.exist? || @root + main == @home)
|
43
43
|
@home
|
44
44
|
elsif repo_install?(@home)
|
45
|
-
@home
|
45
|
+
@home + main
|
46
46
|
else
|
47
|
-
(path = pwd) == @home || !repo_install?(path) ? @home : path
|
47
|
+
(path = pwd) == @home || !repo_install?(path) ? @home : path + main
|
48
48
|
end
|
49
49
|
@root = @home.parent
|
50
50
|
@manifest_url = url
|