squared 0.2.10 → 0.3.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.
@@ -6,28 +6,36 @@ module Squared
6
6
  class Ruby < Git
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
- FOR_INSTALL = %w[full-index quiet retry gemfile=s j=i jobs=i retry=i].freeze
10
- OPT_INSTALL = %w[binstubs frozen system no-cache no-prune path=s binstubs=? standalone=? target-rbconfig=s
11
- trust-policy=s with=s without=s].freeze
12
- OPT_UPDATE = %w[conservative local pre redownload ruby strict bundler=? g=s group=s source=s].freeze
13
- OPT_OUTDATED = %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
14
- update-strict g=s group=s source=s].freeze
9
+ OPT_BUNDLE = {
10
+ common: %w[no-color V verbose retry=i].freeze,
11
+ install: %w[frozen no-cache no-prune system path=p binstubs=p? standalone=q? target-rbconfig=p trust-policy=b
12
+ with=q without=q].freeze,
13
+ install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
14
+ update: %w[conservative local pre redownload ruby strict bundler=e? g|group=q source=e].freeze,
15
+ outdated: %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
16
+ update-strict g|group=q source=e].freeze,
17
+ exec: %w[gemfile=p].freeze,
18
+ check: %w[dry-run gemfile=p].freeze
19
+ }.freeze
15
20
  OPT_GEM = {
16
- COMMON: %w[V backtrace debug q quiet norc silent verbose no-verbose config-file=s].freeze,
17
- INSTALL: ['version=s'].freeze,
18
- UPDATE: ['system=?'].freeze,
19
- OUTDATED: %w[b both clear-sources l local no-http-proxy r remote B bulk-threshold=i p=s http-proxy=?
20
- platform=s source=s].freeze,
21
- PRISTINE: %w[all env-shebang no-env-shebang extensions no-extensions only-missing-extensions only-executables
22
- only-plugins n=s bindir=s i=s install-dir=s skip=s v=s version=s].freeze,
23
- NO_GENERAL: %w[env-shebang force format-executable http-proxy lock minimal-deps post-install-message
24
- prerelease suggestions user-install wrappers].freeze,
25
- GENERAL: %w[f g w b both clear-sources conservative document=? default development development-all E explain
26
- ignore-dependencies l local N no-document r remote vendor n=s bindir=s build-root=s
27
- bulk-threshold=i document=s g=s file=? p=s http-proxy=s i=s install-dir=s platform=s s=s source=s
28
- target-rbconfig=? P=s trust-policy=s without=s].freeze
21
+ common: %w[backtrace debug q|quiet no-verbose norc silent V|verbose config-file=p].freeze,
22
+ install: %w[version=e].freeze,
23
+ update: %w[system=e?].freeze,
24
+ outdated: %w[b|both clear-sources l|local no-http-proxy r|remote B|bulk-threshold=i p|http-proxy=q?
25
+ platform=q source=q].freeze,
26
+ push: %w[no-http-proxy attestation=p host=q key=e otp=e p|http-proxy=q?].freeze,
27
+ build: %w[force strict o|output=p platform=q].freeze,
28
+ exec: %w[conservative prerelease no-prerelease g|gem=s version=e].freeze,
29
+ pristine: %w[all env-shebang extensions no-env-shebang no-extensions only-executables only-missing-extensions
30
+ only-plugins n|bindir=p i|install-dir=p skip=e v|version=e].freeze,
31
+ shared: %w[f b|both clear-sources conservative default development development-all E|explain
32
+ ignore-dependencies l|local N|no-document r|remote w|vendor n|bindir=p build-root=p
33
+ bulk-threshold=i document=b? g|file=p? p|http-proxy=q i|install-dir=p platform=q s|source=q
34
+ target-rbconfig=p? P|trust-policy=b without=e].freeze,
35
+ shared_no: %w[env-shebang force format-executable http-proxy lock minimal-deps post-install-message
36
+ prerelease suggestions user-install wrappers].freeze
29
37
  }.freeze
30
- private_constant :GEMFILE, :DIR_RUBY, :FOR_INSTALL, :OPT_INSTALL, :OPT_UPDATE, :OPT_OUTDATED, :OPT_GEM
38
+ private_constant :GEMFILE, :DIR_RUBY, :OPT_BUNDLE, :OPT_GEM
31
39
 
32
40
  class << self
33
41
  def populate(*); end
@@ -52,9 +60,10 @@ module Squared
52
60
  'install' => %i[redownload local prefer-local].freeze,
53
61
  'update' => %i[patch minor major all].freeze,
54
62
  'outdated' => %i[patch minor major].freeze,
55
- 'gem' => %i[install user-install update outdated pristine].freeze,
63
+ 'gem' => %i[install user-install update pristine outdated push build exec].freeze,
56
64
  'exec' => nil,
57
65
  'config' => nil,
66
+ 'check' => nil,
58
67
  'rake' => nil
59
68
  }.freeze
60
69
 
@@ -101,11 +110,13 @@ module Squared
101
110
 
102
111
  if flags.nil?
103
112
  case action
104
- when 'exec', 'config'
105
- format_desc action, nil, 'command+'
113
+ when 'config', 'exec', 'check'
114
+ format_desc(action, nil, case action
115
+ when 'exec', 'check'
116
+ OPT_BUNDLE[action.to_sym]
117
+ end, after: action == 'check' ? nil : 'command+')
106
118
  task action do |_, args|
107
- args = param_guard('bundle', action, args: args.to_a)
108
- bundle(action, *args)
119
+ bundle action, args.to_a
109
120
  end
110
121
  when 'rake'
111
122
  next unless rakefile
@@ -126,7 +137,7 @@ module Squared
126
137
  log.warn "rake task #{n} of #{list.size} (out of range)"
127
138
  next
128
139
  end
129
- rake(args.extras.empty? ? cmd : "#{cmd}#{shell_escape("[#{args.extras.join(',')}]")}")
140
+ rake(args.extras.empty? ? cmd : cmd + shell_escape("[#{args.extras.join(',')}]"))
130
141
  else
131
142
  rake(*args.to_a)
132
143
  end
@@ -136,33 +147,23 @@ module Squared
136
147
  namespace action do
137
148
  flags.each do |flag|
138
149
  case action
139
- when 'install'
140
- format_desc(action, flag, FOR_INSTALL + OPT_INSTALL) if @@task_desc
141
- task flag do |_, args|
142
- depend(flag, opts: args.to_a)
143
- end
144
- when 'update', 'outdated'
145
- if @@task_desc
146
- format_desc(action, flag, action == 'update' ? FOR_INSTALL + OPT_UPDATE : OPT_OUTDATED)
147
- end
150
+ when 'install', 'update', 'outdated'
151
+ format_desc action, flag, 'opts*'
148
152
  task flag do |_, args|
149
- __send__(action, flag, opts: args.to_a)
153
+ __send__ action, flag, args.to_a
150
154
  end
151
155
  when 'gem'
152
156
  case flag
153
- when :outdated
154
- format_desc action, flag, gemoption(flag) if @@task_desc
157
+ when :outdated, :build, :push, :exec
158
+ format_desc action, flag, 'opts*'
155
159
  task flag do |_, args|
156
- gemx(flag, opts: args.to_a)
160
+ gemx flag, args.to_a
157
161
  end
158
162
  else
159
- if @@task_desc
160
- format_desc(action, flag, gemoption(flag),
161
- after: "name+#{flag == :pristine ? '|name?@version' : ''}")
162
- end
163
- task flag, [:name] do |_, args|
163
+ format_desc action, flag, "opts*,name+#{flag == :pristine ? '|name?@version' : ''}"
164
+ task flag do |_, args|
164
165
  opts = param_guard(action, flag, args: args.to_a)
165
- gemx(flag, opts: opts)
166
+ gemx flag, opts
166
167
  end
167
168
  end
168
169
  end
@@ -173,34 +174,25 @@ module Squared
173
174
  end
174
175
  end
175
176
 
176
- def depend(flag = nil, opts: [], sync: invoked_sync?('depend', flag))
177
- if @depend && !flag
177
+ def depend(*, sync: invoked_sync?('depend'), **)
178
+ if @depend
178
179
  super
179
180
  elsif outdated?
180
181
  cmd = bundle_session 'install'
181
- if flag
182
- cmd << "--#{flag}"
183
- append_bundle opts, FOR_INSTALL + OPT_INSTALL
184
- from = :install
185
- else
186
- if (n = option('jobs')).to_i > 0
187
- cmd << "-j#{n}"
188
- end
189
- from = :depend
182
+ if (n = option('jobs')).to_i > 0
183
+ cmd << "-j#{n}"
190
184
  end
191
- run_rb(from: from, sync: sync)
185
+ run_rb(from: :depend, sync: sync)
192
186
  end
193
187
  end
194
188
 
195
- def copy(from: 'lib', into: @gemdir, override: false, **kwargs)
196
- glob = kwargs[:include]
197
- pass = kwargs[:exclude]
189
+ def copy(from: 'lib', include: nil, exclude: nil, into: @gemdir, override: false)
198
190
  if @copy && !override
199
191
  return super if runnable?(@copy)
200
192
 
201
193
  from = @copy[:from] if @copy.key?(:from)
202
194
  glob = @copy[:include] if @copy.key?(:include)
203
- pass = @copy[:exclude] if @copy.key?(:exclude)
195
+ exclude = @copy[:exclude] if @copy.key?(:exclude)
204
196
  into = @copy[:into] if @copy.key?(:into)
205
197
  end
206
198
  return unless into
@@ -212,10 +204,10 @@ module Squared
212
204
  as_a(from).each_with_index do |val, i|
213
205
  a = basepath(val)
214
206
  b = dest.join(val)
215
- c = glob[i] || glob.first
207
+ c = glob[i] || glob[0]
216
208
  log.info "cp #{a.join(c)} #{b}"
217
209
  begin
218
- copy_dir(a, b, c, pass: pass, verbose: verbose)
210
+ copy_dir(a, b, c, pass: exclude, verbose: verbose)
219
211
  rescue StandardError => e
220
212
  log.error e
221
213
  ret = on(:error, :copy, e)
@@ -225,11 +217,11 @@ module Squared
225
217
  on :last, :copy
226
218
  end
227
219
 
228
- def outdated(flag = nil, opts: [], sync: invoked_sync?('outdated', flag))
220
+ def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated', flag))
229
221
  cmd = bundle_output 'outdated'
230
222
  if flag
231
223
  cmd << "--#{flag}"
232
- append_bundle(opts, OPT_OUTDATED, target: cmd)
224
+ append_bundle(opts, OPT_BUNDLE[:outdated] + OPT_BUNDLE[:common], target: cmd)
233
225
  end
234
226
  log.info cmd.to_s
235
227
  on :first, :outdated
@@ -261,10 +253,10 @@ module Squared
261
253
  semmajor?(cur, lat) ? major_set.() : minor_set.()
262
254
  else
263
255
  data.each do |val|
264
- break unless (req = /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/.match(line))
256
+ break unless line =~ /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/
265
257
 
266
258
  v = semver(val).join
267
- case req[1]
259
+ case $1
268
260
  when '>', '>='
269
261
  semmajor?(cur, lat) ? major_set.() : minor_set.()
270
262
  when '<', '<='
@@ -325,8 +317,8 @@ module Squared
325
317
  end
326
318
  if found > 0
327
319
  begin
328
- if major == 0 && (data = /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/.match(dependfile.read))
329
- status = (data[2] || data[3]).chomp('/')
320
+ if major == 0 && dependfile.read =~ /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/
321
+ status = ($2 || $3).chomp('/')
330
322
  right = true
331
323
  end
332
324
  rescue StandardError => e
@@ -342,49 +334,56 @@ module Squared
342
334
  on :last, :outdated
343
335
  end
344
336
 
345
- def update(flag, opts: [])
337
+ def install(flag, opts = [])
338
+ bundle_session 'install', "--#{flag}"
339
+ append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:install] + OPT_BUNDLE[:common]
340
+ run_rb(from: :install)
341
+ end
342
+
343
+ def update(flag, opts = [])
346
344
  bundle_session 'update', "--#{flag}"
347
- append_bundle(opts, FOR_INSTALL + OPT_UPDATE, append: flag != :all)
345
+ append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common]
348
346
  run_rb(from: :update)
349
347
  end
350
348
 
351
- def gemx(flag, opts: [])
349
+ def gemx(flag, opts = [])
352
350
  cmd = gem_session
353
351
  case flag
354
352
  when :outdated
355
- cmd << "-C #{shell_quote(path)}" if (pass = Gem::VERSION >= '3.4.2')
353
+ cmd << pwd if (pwd = gempwd)
356
354
  cmd << flag
355
+ when :push
356
+ cmd << flag << project
357
357
  when :'user-install'
358
- cmd << 'install' << "--#{flag}"
358
+ cmd << 'install' << '--user-install'
359
359
  else
360
360
  cmd << flag
361
361
  end
362
- no = flag == :pristine || flag == :outdated ? [] : OPT_GEM[:NO_GENERAL]
363
- opts, pat = option_partition(opts, gemoption(flag), no: no, first: flag != :outdated)
362
+ list = OPT_GEM[flag == :'user-install' ? :install : flag] + OPT_GEM[:common]
363
+ case flag
364
+ when :install, :'user-install', :update
365
+ list += OPT_GEM[:shared]
366
+ no = OPT_GEM[:shared_no]
367
+ end
368
+ opts, pat = option_sanitize(opts, list, no: no, first: true)
364
369
  out = []
365
370
  opts.each do |opt|
366
371
  if opt =~ pat
367
372
  case $1
368
- when 'build-root', 'config-file', 'target-rbconfig',
369
- 'n', 'bindir', 'g', 'file', 'i', 'install-dir'
370
- cmd << quote_option($1, basepath($2))
371
- when 'p', 'http-proxy', 's', 'source'
372
- cmd << quote_option($1, $2)
373
- when 'bulk-threshold'
374
- cmd << basic_option($1, $2) if $2.to_i > 0
375
- else
376
- cmd << shell_option($1, $2)
373
+ when 'g', 'gem'
374
+ cmd << (flag == :exec ? shell_option($1, $2) : quote_option($1, basepath($2)))
377
375
  end
378
376
  else
379
377
  out << opt
380
378
  end
381
379
  end
382
380
  from = :"gem:#{flag == :'user-install' ? 'install' : flag}"
383
- if flag == :outdated
381
+ case flag
382
+ when :outdated
384
383
  log.info cmd.to_s
385
384
  on :first, from
386
385
  print_item format_banner(cmd.to_s)
387
- pwd_set(pass: pass, from: from) do
386
+ pwd_set(pass: !pwd.nil?, from: from) do
388
387
  items = [[%w[Gem Current Latest], nil]]
389
388
  IO.popen(cmd.done).each do |line|
390
389
  if (data = line.match(/^(\S+) \((\S+) < ([^)]+)\)$/))
@@ -456,41 +455,61 @@ module Squared
456
455
  end
457
456
  end
458
457
  on :last, from
458
+ return
459
+ when :build, :push
460
+ if !out.empty?
461
+ if flag == :build && out.size == 1
462
+ cmd << basepath(out.first)
463
+ else
464
+ raise_error('gem', flag, out.join(', '), hint: 'unrecognized option')
465
+ end
466
+ elsif flag == :build
467
+ cmd << "#{project}.gemspec"
468
+ end
469
+ when :exec
470
+ raise_error('gem', flag, hint: 'no command given') if out.empty?
471
+ cmd << out.join(' ')
459
472
  else
460
- if out.empty? && !cmd.find { |val| val =~ /^--system(?:=|$)/ }
473
+ if out.empty? && cmd.none? { |val| val =~ /^--system(?:=|$)/ }
461
474
  raise_error('gem', flag, hint: 'no gemname given')
462
- else
463
- if flag == :pristine
464
- if cmd.include?('--all')
465
- append_repeat 'skip', out
466
- out.clear
467
- elsif (n = out.first =~ /@/)
468
- name = out.first
469
- if n == 0
470
- cmd << shell_escape(project)
471
- version = name[1..-1]
472
- else
473
- cmd << shell_escape(name[0..n - 1])
474
- version = name[n + 1..-1]
475
- end
476
- cmd << shell_option('version', version)
477
- out.clear
475
+ end
476
+ if flag == :pristine
477
+ if session_arg?('all')
478
+ append_repeat 'skip', out
479
+ out.clear
480
+ elsif (n = out.first =~ /@/)
481
+ name = out.first
482
+ if n == 0
483
+ cmd << project
484
+ version = name[1..-1]
485
+ else
486
+ cmd << shell_escape(name[0, n])
487
+ version = name[n + 1..-1]
478
488
  end
489
+ cmd << shell_option('version', version)
490
+ out.clear
479
491
  end
480
- append_value out
481
492
  end
482
- run_rb(from: from)
493
+ append_value(out, escape: true)
483
494
  end
495
+ run_rb(from: from)
484
496
  end
485
497
 
486
- def bundle(cmd, *args)
498
+ def bundle(flag, *args)
487
499
  args = args.flatten
488
- run_s(bundle_session(cmd, *args), from: :bundle)
500
+ cmd = bundle_session flag
501
+ case flag
502
+ when 'exec', 'check'
503
+ args = option_sanitize(args, OPT_BUNDLE[flag.to_sym] + OPT_BUNDLE[:common]).first
504
+ end
505
+ raise_error('bundle', flag, hint: 'no command given') unless !args.empty? || flag == 'check'
506
+ cmd.merge!(args)
507
+ run(from: :"bundle:#{flag}")
489
508
  end
490
509
 
491
510
  def rake(*cmd)
492
511
  if cmd.empty?
493
- run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd, banner: false)
512
+ run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd)
494
513
  else
495
514
  cmd = cmd.flatten.map { |val| rake_output(rakeapp, val) }
496
515
  run_s(cmd, from: :rake, chdir: workspace.pwd, banner: false)
@@ -511,34 +530,43 @@ module Squared
511
530
  end
512
531
  return false unless @autodetect
513
532
 
514
- set = lambda do |val|
533
+ set = lambda do |val, path|
515
534
  log.warn "using version #{val} (given #{@version})" if @version && @version != val
516
535
  @version = val
536
+ @gemdir = Pathname.new(path.strip).join(gempath)
517
537
  end
518
538
  if @version
519
- out = pwd_set { `#{gem_output('list', '--local', '-d', shell_escape(project, quote: true))}` }
520
- if (data = /#{Regexp.escape(project)} \(([^)]+)\)/.match(out))
521
- ver = data[1].split(/\s*,\s*/)
522
- ver.unshift(@version).uniq!
523
- ver.each do |val|
524
- next unless (data = /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/.match(out))
525
-
526
- set.(val)
527
- break
539
+ pwd = gempwd
540
+ pwd_set(pass: !pwd.nil?) do
541
+ out = `#{gem_output(pwd, 'list', '--local', '-d', project)}`
542
+ if out =~ /#{Regexp.escape(project)} \(([^)]+)\)/
543
+ ver = $1.split(/\s*,\s*/)
544
+ ver.unshift(@version).uniq!
545
+ ver.each do |val|
546
+ next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
547
+
548
+ set.(val, $1)
549
+ break
550
+ end
528
551
  end
529
552
  end
530
553
  end
531
- unless data || RUBY_VERSION < '2.6'
532
- target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
533
- if (path = target.resolve_feature_path(project)&.last)
534
- gems = ['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR)
535
- if (ver = Regexp.new(gems).match(path)) && (data = /\A(.+)#{gempath(ver[1])}/.match(path))
536
- set.(ver[1])
554
+ unless @gemdir
555
+ parse = lambda do |path|
556
+ next unless path
557
+
558
+ lib = Regexp.new(['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
559
+ if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
560
+ set.(ver, val)
537
561
  end
538
562
  end
563
+ if RUBY_VERSION >= '2.6'
564
+ target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
565
+ parse.(target.resolve_feature_path(project)&.last)
566
+ end
567
+ pwd_set { parse.(`#{bundle_output('show', project)}`) } unless @gemdir
539
568
  end
540
- raise_error('failed to parse', hint: @version || 'path') unless data
541
- @gemdir = Pathname.new(data[1].strip).join(gempath)
569
+ raise_error('failed to parse', hint: @version || 'path') unless @gemdir
542
570
  rescue StandardError => e
543
571
  log.error e
544
572
  @version = nil
@@ -558,30 +586,9 @@ module Squared
558
586
  run(banner: !@session.include?('--quiet'), **kwargs)
559
587
  end
560
588
 
561
- def append_bundle(opts, list, target: @session, append: false)
562
- opts, pat = option_partition(opts, list, target: target)
563
- out = []
564
- opts.each do |opt|
565
- if opt =~ pat
566
- case $1
567
- when 'path', 'gemfile', 'binstubs', 'target-rbconfig'
568
- target << quote_option($1, basepath($2))
569
- when 'standalone', 'with', 'without', 'g', 'group'
570
- target << quote_option($1, $2)
571
- when 'retry', 'j', 'jobs'
572
- target << basic_option($1, $2) if $2.to_i > 0
573
- else
574
- target << shell_option($1, $2)
575
- end
576
- else
577
- out << opt
578
- end
579
- end
580
- if append
581
- append_value(out, target: target, escape: true)
582
- else
583
- option_clear(out, target: target)
584
- end
589
+ def append_bundle(opts, list, target: @session)
590
+ out = option_sanitize(opts, list, target: target).first
591
+ option_clear(out, target: target)
585
592
  end
586
593
 
587
594
  def gem_session(*cmd, **kwargs)
@@ -616,12 +623,12 @@ module Squared
616
623
  return @rakelist if @rakelist
617
624
 
618
625
  ret = []
619
- pass = Rake::VERSION >= '13.0.4'
620
- pwd_set(pass: pass) do
621
- IO.popen(rake_output(pass ? "-C #{shell_quote(path)}" : nil, '-AT').to_s).each do |line|
622
- next unless (data = /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/.match(line))
626
+ pwd = rakepwd
627
+ pwd_set(pass: !pwd.nil?) do
628
+ IO.popen(rake_output(pwd, '-AT').to_s).each do |line|
629
+ next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
623
630
 
624
- ret << [data[1], data[2]]
631
+ ret << [$1, $2]
625
632
  end
626
633
  end
627
634
  @rakelist = ret
@@ -636,26 +643,29 @@ module Squared
636
643
  end
637
644
 
638
645
  def rakefile
639
- file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }
640
- basepath(file) if file
646
+ return unless (file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? })
647
+
648
+ basepath(file)
641
649
  end
642
650
 
643
651
  def rakeapp
644
- quote_option 'f', rakefile
652
+ quote_option 'rakefile', Rake.application.rakefile
645
653
  end
646
654
 
647
- def gempath(val = @version)
648
- File.join('gems', "#{project}-#{val}")
655
+ def rakepwd
656
+ return unless Rake::VERSION >= '13.0.4'
657
+
658
+ quote_option('C', path)
649
659
  end
650
660
 
651
- def gemoption(flag)
652
- target = flag == :'user-install' ? :INSTALL : flag.upcase
653
- OPT_GEM[:COMMON] + OPT_GEM[target] + case flag
654
- when :pristine, :outdated
655
- []
656
- else
657
- OPT_GEM[:GENERAL] + OPT_GEM[:NO_GENERAL]
658
- end
661
+ def gempwd
662
+ return unless Gem::VERSION >= '3.4.2'
663
+
664
+ quote_option('C', path)
665
+ end
666
+
667
+ def gempath(val = @version)
668
+ File.join('gems', "#{project}-#{val}")
659
669
  end
660
670
  end
661
671
 
@@ -3,6 +3,8 @@
3
3
  module Squared
4
4
  module Workspace
5
5
  module Repo
6
+ include Common::Format
7
+
6
8
  class << self
7
9
  def read_manifest(path)
8
10
  require 'rexml/document'
@@ -15,7 +17,8 @@ module Squared
15
17
 
16
18
  attr_reader :manifest_url, :manifest
17
19
 
18
- def repo(url, manifest = 'latest', run: nil, script: nil, dev: nil, prod: nil, ref: @ref, group: @group)
20
+ def repo(url, manifest = 'latest', run: nil, script: nil, args: nil, dev: nil, prod: nil,
21
+ ref: @ref, group: @group)
19
22
  @home = if (val = env('REPO_HOME'))
20
23
  path = Pathname.new(val)
21
24
  if main == path.basename.to_s
@@ -72,6 +75,7 @@ module Squared
72
75
  else
73
76
  data[:script] = script
74
77
  end
78
+ data[:args] = (val = env('REPO_SCRIPT')) ? shell_split(val, join: true) : args
75
79
  elsif (val = env('REPO_BUILD'))
76
80
  data[:run] = val
77
81
  data[:env] = true
@@ -79,8 +83,8 @@ module Squared
79
83
  data[:run] = run
80
84
  end
81
85
  data[:global] = true
82
- data[:dev] = env_match('REPO_DEV', dev, suffix: @envname)
83
- data[:prod] = env_match('REPO_PROD', prod, suffix: @envname)
86
+ data[:dev] = env_match('REPO_DEV', dev)
87
+ data[:prod] = env_match('REPO_PROD', prod)
84
88
  if (val = env('REPO_GROUP'))
85
89
  script_set(data, group: val.split(','))
86
90
  found = true
@@ -90,11 +94,12 @@ module Squared
90
94
  found = true
91
95
  end
92
96
  script_set(data, group: group, ref: ref) unless found
93
- @warning = env_match('REPO_WARN', @warning && !root?(@root, pass: ['.repo']), suffix: @envname) != false
97
+ @warning = env_match('REPO_WARN', @warning && !root?(@root, pass: ['.repo'])) != false
94
98
  @extensions << :__repo__
95
99
  elsif script || run
96
100
  if script
97
101
  data[:script] = script
102
+ data[:args] = args
98
103
  else
99
104
  data[:run] = run
100
105
  end
@@ -85,7 +85,7 @@ module Squared
85
85
  (TASK_BASE + TASK_KEYS).each { |key| @data[key] = [] }
86
86
  end
87
87
 
88
- def populate(proj)
88
+ def populate(proj, **)
89
89
  group, parent, id = @session.values
90
90
  ws = proj.workspace
91
91
  @data.each do |key, items|
@@ -97,7 +97,7 @@ module Squared
97
97
  else
98
98
  items.concat(tasks)
99
99
  end
100
- if tasks.size > 1 && (data = batch_get(key)) && data.keys.any? { |ref| proj.ref?(ref) }
100
+ if tasks.size > 1 && batch?(proj, key) && !ws.task_exclude?(key, proj)
101
101
  ws.task_desc(t = ws.task_join(proj.name, key))
102
102
  task t => tasks
103
103
  end
@@ -113,9 +113,9 @@ module Squared
113
113
  @data.merge!(@session[:parent]) if @session[:id].uniq.size > 1
114
114
  @data.merge!(@session[:group])
115
115
  @data.each do |key, items|
116
- next if items.empty?
116
+ next if items.empty? || @workspace.task_exclude?(t = name_get(key))
117
117
 
118
- key = task_name(t = name_get(key))
118
+ key = task_name(t)
119
119
  val = format_desc(key, out: true)
120
120
  if items.size > 1
121
121
  @multiple << key
@@ -181,6 +181,12 @@ module Squared
181
181
  ret
182
182
  end
183
183
 
184
+ def batch?(obj, key)
185
+ return false unless (data = batch_get(key))
186
+
187
+ data.keys.any? { |ref| obj.ref?(ref) }
188
+ end
189
+
184
190
  def multiple?(val = nil)
185
191
  already_invoked?(multiple, val)
186
192
  end
data/squared.gemspec CHANGED
@@ -27,5 +27,4 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "rake"
28
28
  spec.add_dependency "logger"
29
29
  spec.add_dependency "rexml"
30
- spec.add_dependency "readline"
31
30
  end