squared 0.4.18 → 0.5.0
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 +62 -242
- data/README.md +1280 -647
- data/README.ruby.md +722 -0
- data/lib/squared/common/base.rb +8 -9
- data/lib/squared/common/format.rb +6 -14
- data/lib/squared/common/prompt.rb +38 -42
- data/lib/squared/common/shell.rb +10 -10
- data/lib/squared/common/system.rb +31 -35
- data/lib/squared/common/utils.rb +3 -28
- data/lib/squared/common.rb +2 -1
- data/lib/squared/config.rb +19 -19
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +55 -89
- data/lib/squared/workspace/project/base.rb +258 -399
- data/lib/squared/workspace/project/docker.rb +106 -120
- data/lib/squared/workspace/project/git.rb +330 -467
- data/lib/squared/workspace/project/node.rb +96 -141
- data/lib/squared/workspace/project/python.rb +73 -299
- data/lib/squared/workspace/project/ruby.rb +158 -237
- data/lib/squared/workspace/project/support/class.rb +81 -134
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +51 -79
- data/lib/squared/workspace/series.rb +16 -16
- data/lib/squared/workspace/support/data.rb +3 -2
- data/lib/squared/workspace/support.rb +0 -1
- data/lib/squared/workspace.rb +1 -1
- data/squared.gemspec +5 -5
- metadata +7 -8
- data/lib/squared/common/class.rb +0 -110
- data/lib/squared/workspace/support/base.rb +0 -17
@@ -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
|
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
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
|
@@ -25,8 +25,8 @@ module Squared
|
|
25
25
|
common: %w[no-color V|verbose retry=i].freeze,
|
26
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
|
-
install_base: %w[
|
29
|
-
update: %w[conservative local pre ruby strict bundler=b? g|group=q source=b].freeze,
|
28
|
+
install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
|
29
|
+
update: %w[conservative local pre redownload ruby strict bundler=b? g|group=q source=b].freeze,
|
30
30
|
outdated: %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
|
31
31
|
update-strict g|group=q source=b].freeze,
|
32
32
|
exec: %w[gemfile=p].freeze,
|
@@ -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 build
|
84
|
+
'gem' => %i[install uninstall update pristine outdated push build exec].freeze,
|
85
85
|
'ruby' => %i[file script version].freeze,
|
86
86
|
'exec' => nil,
|
87
87
|
'cache' => nil,
|
@@ -91,7 +91,7 @@ module Squared
|
|
91
91
|
'irb' => nil
|
92
92
|
})
|
93
93
|
|
94
|
-
def initialize(*, autodetect: false,
|
94
|
+
def initialize(*, autodetect: false, **kwargs)
|
95
95
|
super
|
96
96
|
if @pass.include?(Ruby.ref)
|
97
97
|
initialize_ref Ruby.ref
|
@@ -102,17 +102,11 @@ module Squared
|
|
102
102
|
end
|
103
103
|
dependfile_set GEMFILE
|
104
104
|
@autodetect = autodetect
|
105
|
-
@
|
106
|
-
|
107
|
-
elsif gemspec
|
108
|
-
path + (gemspec.include?('.') ? gemspec : "#{gemspec}.gemspec")
|
109
|
-
elsif (gemspec = path + "#{name}.gemspec").exist? || (gemspec = path + "#{project}.gemspec").exist?
|
110
|
-
gemspec
|
111
|
-
end
|
112
|
-
return if !@output[0].nil? || !@copy.nil? || version || @autodetect || !rakefile
|
105
|
+
@rakelist = nil
|
106
|
+
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || (file = rakefile).nil?
|
113
107
|
|
114
108
|
begin
|
115
|
-
File.foreach(
|
109
|
+
File.foreach(file) do |line|
|
116
110
|
next unless line.match?(%r{\brequire\s+(["'])bundler/gem_tasks\1})
|
117
111
|
|
118
112
|
cmd = bundle_output('exec rake').to_s
|
@@ -132,58 +126,54 @@ module Squared
|
|
132
126
|
|
133
127
|
def populate(*, **)
|
134
128
|
super
|
135
|
-
return unless
|
129
|
+
return unless outdated? && ref?(Ruby.ref)
|
136
130
|
|
137
131
|
namespace name do
|
138
132
|
Ruby.subtasks do |action, flags|
|
139
|
-
next if
|
133
|
+
next if @pass.include?(action)
|
140
134
|
|
141
135
|
if flags.nil?
|
142
136
|
case action
|
143
137
|
when 'rake'
|
144
138
|
next unless rakefile
|
145
139
|
|
146
|
-
format_desc action, nil,
|
140
|
+
format_desc action, nil, 'tasks*,opts*|^index|#,pattern*'
|
147
141
|
task action, [:command] do |_, args|
|
148
142
|
if args.command == '#'
|
149
|
-
format_list(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
if
|
154
|
-
|
143
|
+
format_list(read_rakefile, 'rake[^N]', 'tasks', grep: args.extras, from: rakefile.to_s,
|
144
|
+
each: ->(val) { val[0] + val[1].to_s })
|
145
|
+
elsif (n, opts = indexitem(args.command))
|
146
|
+
list = read_rakefile
|
147
|
+
if (item = list[n - 1])
|
148
|
+
cmd = opts ? "#{opts} #{item.first}" : item.first
|
149
|
+
elsif exception
|
150
|
+
indexerror n, list
|
155
151
|
else
|
156
|
-
|
157
|
-
|
158
|
-
if (item = tasks[n - 1])
|
159
|
-
cmd = pre ? "#{pre} #{item.first}" : item.first
|
160
|
-
elsif exception
|
161
|
-
indexerror n, tasks
|
162
|
-
else
|
163
|
-
log.warn "rake task #{n} of #{tasks.size} (out of range)"
|
164
|
-
next
|
165
|
-
end
|
166
|
-
if opts.empty?
|
167
|
-
rake cmd
|
168
|
-
else
|
169
|
-
rake(cmd + shell_escape("[#{opts.join(',')}]"))
|
170
|
-
opts.clear
|
171
|
-
end
|
172
|
-
end
|
152
|
+
log.warn "rake task #{n} of #{list.size} (out of range)"
|
153
|
+
next
|
173
154
|
end
|
155
|
+
rake(args.extras.empty? ? cmd : cmd + shell_escape("[#{args.extras.join(',')}]"))
|
156
|
+
else
|
157
|
+
rake(opts: args.to_a)
|
174
158
|
end
|
175
159
|
end
|
176
160
|
when 'irb'
|
161
|
+
next unless (spec = basepath("#{project}.gemspec") || basepath("#{name}.gemspec"))
|
162
|
+
next unless basepath('lib').join("#{gemname = stripext(spec)}.rb").exist?
|
163
|
+
|
177
164
|
format_desc action, nil, 'opts*,args*|:'
|
178
165
|
task action do |_, args|
|
179
166
|
args = args.to_a
|
180
|
-
|
181
|
-
|
167
|
+
if args.last == ':'
|
168
|
+
args.pop
|
169
|
+
load = readline('Enter file and arguments', force: false)
|
170
|
+
end
|
171
|
+
irb(gemname, args, load: load)
|
182
172
|
end
|
183
173
|
else
|
184
|
-
format_desc(action, nil,
|
185
|
-
|
186
|
-
|
174
|
+
format_desc(action, nil, OPT_BUNDLE[action.to_sym], after: case action
|
175
|
+
when 'cache', 'check' then nil
|
176
|
+
else 'command+' end)
|
187
177
|
task action do |_, args|
|
188
178
|
bundle(action, *args.to_a)
|
189
179
|
end
|
@@ -205,24 +195,20 @@ module Squared
|
|
205
195
|
case (filter = args.semver)
|
206
196
|
when 'major', 'minor', 'patch', 'interactive', 'i'
|
207
197
|
filter = 'interactive' if filter == 'i'
|
208
|
-
args = args.
|
198
|
+
args = args.to_a.drop(1)
|
209
199
|
else
|
210
200
|
filter = nil
|
211
201
|
args = args.to_a
|
212
202
|
end
|
213
203
|
gem!(flag, args, filter: filter)
|
214
204
|
end
|
215
|
-
when :build, :push, :exec
|
216
|
-
format_desc(action, flag, 'opts*',
|
217
|
-
when :exec then 'command,args*'
|
218
|
-
when :push then 'file?'
|
219
|
-
when :update then 'name*'
|
220
|
-
end)
|
205
|
+
when :build, :push, :exec
|
206
|
+
format_desc(action, flag, 'opts*', before: flag == :exec ? 'command,args*' : nil)
|
221
207
|
task flag do |_, args|
|
222
208
|
gem! flag, args.to_a
|
223
209
|
end
|
224
210
|
else
|
225
|
-
format_desc
|
211
|
+
format_desc action, flag, "opts*,name+#{flag == :pristine ? '|name?@version' : ''}"
|
226
212
|
task flag do |_, args|
|
227
213
|
args = param_guard(action, flag, args: args.to_a)
|
228
214
|
gem! flag, args
|
@@ -234,18 +220,19 @@ module Squared
|
|
234
220
|
format_desc action, flag, 'path,opts*,args*'
|
235
221
|
task flag, [:rb] do |_, args|
|
236
222
|
file = args.rb
|
237
|
-
args = args.
|
223
|
+
args = args.to_a.drop(1)
|
238
224
|
unless file && !file.include?('*')
|
239
|
-
|
240
|
-
|
241
|
-
|
225
|
+
values = ['Arguments']
|
226
|
+
values.prepend('Options') unless file
|
227
|
+
file, opts, extra = choice_index('Select a file', Dir.glob(file || '*.rb', base: path),
|
228
|
+
values: values, force: true, series: !args.include?('v'))
|
242
229
|
if file
|
243
|
-
|
230
|
+
extra = opts
|
244
231
|
else
|
245
232
|
args.concat(OptionPartition.strip(opts))
|
246
233
|
end
|
247
234
|
end
|
248
|
-
ruby(flag, args, file: file, args:
|
235
|
+
ruby(flag, args, file: file, args: extra)
|
249
236
|
end
|
250
237
|
when :script
|
251
238
|
format_desc action, flag, 'opts*,args*'
|
@@ -281,7 +268,7 @@ module Squared
|
|
281
268
|
end
|
282
269
|
end
|
283
270
|
|
284
|
-
def copy(from:
|
271
|
+
def copy(from: 'lib', into: @gemdir, override: false, **kwargs)
|
285
272
|
glob = kwargs[:include]
|
286
273
|
pass = kwargs[:exclude]
|
287
274
|
if @copy && !override
|
@@ -299,8 +286,8 @@ module Squared
|
|
299
286
|
on :first, :copy
|
300
287
|
dest = Pathname.new(into).realpath
|
301
288
|
print_item unless @output[0] || task_invoked?(/^copy(?::#{Ruby.ref}|$)/)
|
302
|
-
glob =
|
303
|
-
|
289
|
+
glob = as_a(glob || '**/*')
|
290
|
+
as_a(from).each_with_index do |val, i|
|
304
291
|
a = path + val
|
305
292
|
b = dest + val
|
306
293
|
c = glob[i] || glob.first
|
@@ -308,7 +295,9 @@ module Squared
|
|
308
295
|
begin
|
309
296
|
copy_dir(a, b, c, pass: pass, verbose: verbose)
|
310
297
|
rescue StandardError => e
|
311
|
-
|
298
|
+
log.error e
|
299
|
+
ret = on(:error, :copy, e)
|
300
|
+
raise if exception && ret != true
|
312
301
|
end
|
313
302
|
end
|
314
303
|
on :last, :copy
|
@@ -322,7 +311,7 @@ module Squared
|
|
322
311
|
end
|
323
312
|
log.info cmd.to_s
|
324
313
|
on :first, :outdated
|
325
|
-
banner = format_banner
|
314
|
+
banner = format_banner cmd.to_s
|
326
315
|
print_item banner if sync
|
327
316
|
pwd_set(from: :outdated) do
|
328
317
|
start = 0
|
@@ -413,7 +402,7 @@ module Squared
|
|
413
402
|
end
|
414
403
|
if found > 0
|
415
404
|
begin
|
416
|
-
if major == 0 && dependfile.read =~ /\b(?:source\s+(["'])(
|
405
|
+
if major == 0 && dependfile.read =~ /\b(?:source\s+(["'])((?~\1))\1|remote:\s+(\S+))/
|
417
406
|
status = ($2 || $3).chomp('/')
|
418
407
|
right = true
|
419
408
|
end
|
@@ -432,23 +421,14 @@ module Squared
|
|
432
421
|
|
433
422
|
def install(flag, opts = [])
|
434
423
|
bundle_session 'install', "--#{flag}"
|
435
|
-
|
436
|
-
if op.arg?('force')
|
437
|
-
op.delete('--force')
|
438
|
-
if flag != :redownload
|
439
|
-
op << '--redownload'
|
440
|
-
elsif (lock = basepath('Gemfile.lock')).exist?
|
441
|
-
config = basepath('.bundle', 'config')
|
442
|
-
lock.delete unless config.exist? && config.read.match?(/\bBUNDLE_FROZEN:\s+"true"/)
|
443
|
-
end
|
444
|
-
end
|
424
|
+
append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:install] + OPT_BUNDLE[:common]
|
445
425
|
run_rb(from: :install)
|
446
426
|
end
|
447
427
|
|
448
428
|
def update(flag, opts = [])
|
449
429
|
bundle_session 'update', "--#{flag}"
|
450
430
|
append_bundle(opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common],
|
451
|
-
append: flag == :all ? nil : /\A
|
431
|
+
append: flag == :all ? nil : /\A[a-z\-]+=/)
|
452
432
|
run_rb(from: :update)
|
453
433
|
end
|
454
434
|
|
@@ -457,11 +437,11 @@ module Squared
|
|
457
437
|
when :file, :script
|
458
438
|
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
459
439
|
if file
|
460
|
-
op.
|
440
|
+
op.extras.prepend(shell_quote(path + file))
|
461
441
|
elsif command
|
462
442
|
op << quote_option('e', command, option: false)
|
463
443
|
end
|
464
|
-
op.
|
444
|
+
op.extras << args if (args = ENV.fetch('RUBY_ARGS', args))
|
465
445
|
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
466
446
|
when :version
|
467
447
|
pwd_set do
|
@@ -484,8 +464,9 @@ module Squared
|
|
484
464
|
when 'rvm'
|
485
465
|
`rvm current`[/^\S+/, 0]
|
486
466
|
when 'rbenv'
|
487
|
-
|
488
|
-
|
467
|
+
`rbenv version-name`.yield_self do |name|
|
468
|
+
name.match?(SEM_VER) ? "ruby #{name}" : name
|
469
|
+
end
|
489
470
|
when 'chruby.sh'
|
490
471
|
chruby = session_output 'source', val
|
491
472
|
`#{chruby.with('ruby --version')}`
|
@@ -496,14 +477,12 @@ module Squared
|
|
496
477
|
ver = nil
|
497
478
|
`ruby --version`
|
498
479
|
end)
|
499
|
-
break if workspace.windows?
|
500
|
-
|
501
480
|
unless val.empty?
|
502
481
|
out << trim.call(case cmd
|
503
482
|
when 'chruby.sh'
|
504
483
|
`#{chruby.with('chruby --version')}`.sub(':', '')
|
505
484
|
when 'install'
|
506
|
-
"asdf #{`asdf version`.
|
485
|
+
"asdf #{`asdf version`.delete_prefix('v')}"
|
507
486
|
else
|
508
487
|
`#{cmd} --version`
|
509
488
|
end)
|
@@ -546,6 +525,8 @@ module Squared
|
|
546
525
|
case flag
|
547
526
|
when :outdated
|
548
527
|
cmd << gempwd << 'outdated'
|
528
|
+
when :push
|
529
|
+
cmd << 'push' << project
|
549
530
|
else
|
550
531
|
cmd << flag
|
551
532
|
end
|
@@ -554,9 +535,12 @@ module Squared
|
|
554
535
|
case flag
|
555
536
|
when :install, :update
|
556
537
|
list.concat(OPT_GEM[:install_base])
|
538
|
+
first = ['=']
|
539
|
+
when :uninstall, :pristine
|
540
|
+
first = ['=']
|
557
541
|
end
|
558
542
|
cmd.merge(preopts)
|
559
|
-
op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GEM[:no][flag])
|
543
|
+
op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GEM[:no][flag], first: first)
|
560
544
|
op.each do |opt|
|
561
545
|
if opt =~ op.values
|
562
546
|
case $1
|
@@ -580,7 +564,7 @@ module Squared
|
|
580
564
|
minor = 0
|
581
565
|
patch = 0
|
582
566
|
update = []
|
583
|
-
pwd_set(pass: !
|
567
|
+
pwd_set(pass: !pwd.nil?, from: from) do
|
584
568
|
items = [[%w[Gem Current Latest], nil]]
|
585
569
|
IO.popen(cmd.done).each do |line|
|
586
570
|
if line =~ /^(\S+) \((\S+) < ([^)]+)\)$/
|
@@ -657,8 +641,7 @@ module Squared
|
|
657
641
|
styles = %i[yellow]
|
658
642
|
pat = pat.last
|
659
643
|
end
|
660
|
-
b = b.rjust(e)
|
661
|
-
b = sub_style(b, *colormap(styles), pat: pat, index: 2)
|
644
|
+
b = sub_style(b.rjust(e), *colormap(styles), pat: pat, index: 2)
|
662
645
|
h = sub_style(c.rjust(f), styles: latest.flatten.compact, pat: pat, index: 2)
|
663
646
|
j += 1
|
664
647
|
if queue
|
@@ -676,15 +659,15 @@ module Squared
|
|
676
659
|
else
|
677
660
|
unless update.empty?
|
678
661
|
cmd = gem_output 'update', '-f'
|
679
|
-
|
662
|
+
option('document', prefix: 'gem', ignore: false) do |val|
|
680
663
|
cmd << case val
|
681
664
|
when '0', 'false'
|
682
665
|
'--no-document'
|
683
666
|
else
|
684
|
-
basic_option
|
667
|
+
basic_option 'document', val
|
685
668
|
end
|
686
669
|
end
|
687
|
-
|
670
|
+
option('user-install', prefix: 'gem', ignore: false) do |val|
|
688
671
|
cmd << case val
|
689
672
|
when '0', 'false'
|
690
673
|
'--no-user-install'
|
@@ -695,83 +678,58 @@ module Squared
|
|
695
678
|
cmd.merge(update)
|
696
679
|
run(cmd, banner: false, from: :'gem:update')
|
697
680
|
end
|
698
|
-
|
681
|
+
unless stdin?
|
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
|
699
692
|
end
|
700
693
|
on :last, from
|
701
694
|
return
|
702
|
-
when :build
|
703
|
-
if op.empty?
|
704
|
-
op.
|
705
|
-
|
706
|
-
|
707
|
-
.
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
"#{spec.name}-#{spec.version}.gem"
|
713
|
-
else
|
714
|
-
choice_index('Select a file', Dir.glob('*.gem', base: path), force: true)
|
715
|
-
end)
|
716
|
-
else
|
717
|
-
file = path + op.shift
|
718
|
-
raise_error('gem not found', hint: file) unless file.exist?
|
719
|
-
raise_error("unknown args: #{op.join(', ')}", hint: flag) unless op.empty?
|
695
|
+
when :build, :push
|
696
|
+
if !op.empty?
|
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
|
703
|
+
spec = [path + "#{project}.gemspec", path + "#{name}.gemspec", *path.glob('*.gemspec')]
|
704
|
+
op << File.basename(spec) if (spec = spec.find { |file| File.exist?(file) })
|
720
705
|
end
|
721
|
-
op.add_path(file)
|
722
|
-
run_rb(from: from, interactive: "Push #{sub_style(gemname, styles: theme[:active])}")
|
723
|
-
return
|
724
706
|
when :exec
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
op << basic_option('gem', gemname)
|
729
|
-
1
|
730
|
-
else
|
731
|
-
op << op.shift
|
732
|
-
0
|
733
|
-
end
|
734
|
-
if (args = command_args(op.extras, min: min, force: min == 1 && op.empty?))
|
707
|
+
raise_error('missing command', hint: flag) if op.empty?
|
708
|
+
op << basic_option('gem', project) unless op.arg?('g', 'gem')
|
709
|
+
if (args = command_args(op.extras))
|
735
710
|
op.push(args)
|
736
711
|
end
|
737
|
-
op.append(quote: false)
|
738
|
-
when :update
|
739
|
-
unless op.arg?('system')
|
740
|
-
op.push(gemname) if op.empty?
|
741
|
-
op.adjoin
|
742
|
-
end
|
743
|
-
op.clear(errors: true)
|
712
|
+
op.append(delim: true, quote: false)
|
744
713
|
else
|
745
|
-
raise_error('missing gemname', hint: flag) if op.empty?
|
746
|
-
|
747
|
-
when :install, :uninstall, :pristine
|
748
|
-
post = readline('Enter command [args]', force: true) if flag == :install && op.remove(':')
|
714
|
+
raise_error('missing gemname', hint: flag) if op.empty? && !op.arg?('system')
|
715
|
+
if flag == :pristine
|
749
716
|
if op.arg?('all')
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
elsif (n = op.extras.find_index { |val| val.match?(/(\A|[a-z])@\d/) })
|
757
|
-
items = op.extras.to_a
|
758
|
-
name = items.delete_at(n)
|
759
|
-
if (n = name.index('@')) == 0
|
760
|
-
pre = gemname
|
717
|
+
append_repeat 'skip', op.extras
|
718
|
+
op.extras.clear
|
719
|
+
elsif (n = op.first.index('@'))
|
720
|
+
name = op.shift
|
721
|
+
if n == 0
|
722
|
+
op << project
|
761
723
|
ver = name[1..-1]
|
762
724
|
else
|
763
|
-
|
764
|
-
ver = name[
|
725
|
+
op << shell_escape(name[0, n])
|
726
|
+
ver = name[n + 1..-1]
|
765
727
|
end
|
766
|
-
op
|
767
|
-
|
768
|
-
.reset
|
769
|
-
elsif flag != :install
|
770
|
-
op.adjoin
|
728
|
+
op << shell_option('version', ver)
|
729
|
+
op.clear
|
771
730
|
end
|
772
731
|
end
|
773
732
|
op.append.clear(errors: true)
|
774
|
-
op << '--' << post if post
|
775
733
|
end
|
776
734
|
run_rb(from: from)
|
777
735
|
end
|
@@ -812,14 +770,14 @@ module Squared
|
|
812
770
|
run_s(args, banner: false, from: :rake)
|
813
771
|
end
|
814
772
|
|
815
|
-
def irb(name
|
773
|
+
def irb(name, opts = [], path: @path + 'lib', load: nil)
|
816
774
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
817
|
-
r =
|
818
|
-
r
|
775
|
+
r = as_a name
|
776
|
+
r.prepend('bundler/setup') unless load
|
819
777
|
r.each { |val| op << shell_option('r', val, merge: true) }
|
820
|
-
|
821
|
-
if
|
822
|
-
op << '--' <<
|
778
|
+
as_a(path).each { |val| op << quote_option('I', val, merge: true) }
|
779
|
+
if load
|
780
|
+
op << '--' << load
|
823
781
|
op.clear
|
824
782
|
else
|
825
783
|
op.append(delim: true)
|
@@ -827,20 +785,6 @@ module Squared
|
|
827
785
|
run(banner: false)
|
828
786
|
end
|
829
787
|
|
830
|
-
def gemspec
|
831
|
-
return @gemspec unless @gemspec.nil?
|
832
|
-
|
833
|
-
@gemspec = if (file = gemfile)
|
834
|
-
Gem::Specification.load(file.to_s) rescue false
|
835
|
-
else
|
836
|
-
false
|
837
|
-
end
|
838
|
-
end
|
839
|
-
|
840
|
-
def gemname
|
841
|
-
@gemname ||= ((spec = gemspec) ? spec.name : project)
|
842
|
-
end
|
843
|
-
|
844
788
|
def depend?
|
845
789
|
@depend != false && (!@depend.nil? || outdated?)
|
846
790
|
end
|
@@ -849,7 +793,7 @@ module Squared
|
|
849
793
|
return true if super || (@copy.is_a?(Hash) && copy.fetch(:into, nil))
|
850
794
|
return gemdir? if @gemdir
|
851
795
|
|
852
|
-
if version
|
796
|
+
if @version
|
853
797
|
begin
|
854
798
|
case @autodetect
|
855
799
|
when 'rvm'
|
@@ -874,46 +818,43 @@ module Squared
|
|
874
818
|
return false unless @autodetect
|
875
819
|
|
876
820
|
set = lambda do |val, path|
|
877
|
-
|
878
|
-
|
879
|
-
end
|
880
|
-
self.version = val
|
821
|
+
log.warn "using version #{val} (given #{@version})" if @version && @version != val
|
822
|
+
@version = val
|
881
823
|
@gemdir = Pathname.new(path.strip) + gempath
|
882
824
|
end
|
883
|
-
if version
|
884
|
-
|
885
|
-
pwd_set(pass: !
|
886
|
-
out = `#{gem_output(
|
887
|
-
if out =~ /#{Regexp.escape(
|
825
|
+
if @version
|
826
|
+
pwd = gempwd
|
827
|
+
pwd_set(pass: !pwd.nil?) do
|
828
|
+
out = `#{gem_output(pwd, 'list --local -d', project)}`
|
829
|
+
if out =~ /#{Regexp.escape(project)} \(([^)]+)\)/
|
888
830
|
$1.split(/\s*,\s*/)
|
889
|
-
.
|
831
|
+
.prepend(@version)
|
890
832
|
.uniq
|
891
833
|
.each do |val|
|
892
834
|
next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
|
893
835
|
|
894
836
|
set.call(val, $1)
|
895
|
-
|
837
|
+
break
|
896
838
|
end
|
897
839
|
end
|
898
840
|
end
|
899
|
-
|
900
|
-
|
841
|
+
end
|
842
|
+
unless @gemdir
|
901
843
|
parse = lambda do |path|
|
902
844
|
next unless path
|
903
845
|
|
904
|
-
lib = Regexp.new(['', 'gems', "#{
|
846
|
+
lib = Regexp.new(['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
|
905
847
|
if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
|
906
848
|
set.call(ver, val)
|
907
849
|
end
|
908
850
|
end
|
909
851
|
if RUBY_VERSION >= '2.6'
|
910
852
|
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
911
|
-
parse.call(target.resolve_feature_path(
|
912
|
-
end
|
913
|
-
if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
|
914
|
-
raise_error 'gems directory not found'
|
853
|
+
parse.call(target.resolve_feature_path(project)&.last)
|
915
854
|
end
|
855
|
+
pwd_set { parse.call(`#{bundle_output('show', project)}`) } unless @gemdir
|
916
856
|
end
|
857
|
+
raise_error('parse failed', hint: @version || 'path') unless @gemdir
|
917
858
|
rescue StandardError => e
|
918
859
|
log.error e
|
919
860
|
@version = nil
|
@@ -930,7 +871,7 @@ module Squared
|
|
930
871
|
private
|
931
872
|
|
932
873
|
def run_rb(**kwargs)
|
933
|
-
run(banner: !@session
|
874
|
+
run(banner: !@session.include?('--quiet'), **kwargs)
|
934
875
|
end
|
935
876
|
|
936
877
|
def append_bundle(opts, list, target: @session, append: nil)
|
@@ -950,7 +891,6 @@ module Squared
|
|
950
891
|
else
|
951
892
|
op.clear
|
952
893
|
end
|
953
|
-
op
|
954
894
|
end
|
955
895
|
|
956
896
|
def ruby_session(*cmd, **kwargs)
|
@@ -992,73 +932,54 @@ module Squared
|
|
992
932
|
session_output('rake', *cmd, **kwargs)
|
993
933
|
end
|
994
934
|
|
935
|
+
def read_rakefile
|
936
|
+
return @rakelist if @rakelist
|
937
|
+
|
938
|
+
ret = []
|
939
|
+
pwd = rakepwd
|
940
|
+
pwd_set(pass: !pwd.nil?) do
|
941
|
+
IO.popen(rake_output(pwd, '-AT').to_s).each do |line|
|
942
|
+
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
943
|
+
|
944
|
+
ret << [$1, $2]
|
945
|
+
end
|
946
|
+
end
|
947
|
+
@rakelist = ret
|
948
|
+
end
|
949
|
+
|
995
950
|
def preopts
|
996
951
|
verbosetype > 1 && !session_arg?('quiet') ? ['--verbose'] : []
|
997
952
|
end
|
998
953
|
|
954
|
+
def gemdir?
|
955
|
+
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
956
|
+
end
|
957
|
+
|
999
958
|
def variables
|
1000
959
|
(super + %i[version autodetect]).freeze
|
1001
960
|
end
|
1002
961
|
|
1003
962
|
def rakefile
|
1004
|
-
return
|
963
|
+
return unless (file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? })
|
1005
964
|
|
1006
|
-
|
1007
|
-
@rakefile = file ? path + file : false
|
965
|
+
path + file
|
1008
966
|
end
|
1009
967
|
|
1010
968
|
def rakepwd
|
1011
|
-
return unless
|
969
|
+
return unless Rake::VERSION >= '13.0.4'
|
1012
970
|
|
1013
971
|
quote_option 'C', path
|
1014
972
|
end
|
1015
973
|
|
1016
|
-
def raketasks
|
1017
|
-
@raketasks ||= [].tap do |ret|
|
1018
|
-
opt = rakepwd
|
1019
|
-
pwd_set(pass: !opt.nil?) do
|
1020
|
-
IO.popen(rake_output(opt, '-AT').to_s).each do |line|
|
1021
|
-
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
1022
|
-
|
1023
|
-
ret << [$1, $2]
|
1024
|
-
end
|
1025
|
-
end
|
1026
|
-
end
|
1027
|
-
end
|
1028
|
-
|
1029
974
|
def gempwd
|
1030
|
-
return unless
|
975
|
+
return unless Gem::VERSION >= '3.4.2'
|
1031
976
|
|
1032
977
|
quote_option 'C', path
|
1033
978
|
end
|
1034
979
|
|
1035
|
-
def
|
1036
|
-
|
1037
|
-
|
1038
|
-
@gemfile = [project, name].map! { |val| path + "#{val}.gemspec" }
|
1039
|
-
.concat(path.glob('*.gemspec'))
|
1040
|
-
.find { |file| File.exist?(file) } || false
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
def gemlib
|
1044
|
-
@gemlib ||= begin
|
1045
|
-
lib = Set.new(['lib'])
|
1046
|
-
if (spec = gemspec)
|
1047
|
-
lib.merge(spec.require_paths || [])
|
1048
|
-
end
|
1049
|
-
lib.select { |file| basepath(file).exist? }
|
1050
|
-
end
|
1051
|
-
end
|
1052
|
-
|
1053
|
-
def gempath(val = version)
|
1054
|
-
File.join('gems', "#{gemname}-#{val}")
|
1055
|
-
end
|
1056
|
-
|
1057
|
-
def gemdir?
|
1058
|
-
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
980
|
+
def gempath(val = @version)
|
981
|
+
File.join('gems', "#{project}-#{val}")
|
1059
982
|
end
|
1060
|
-
|
1061
|
-
alias read_rakefile raketasks
|
1062
983
|
end
|
1063
984
|
|
1064
985
|
Application.implement Ruby
|