squared 0.2.3 → 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,22 +174,15 @@ 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
 
@@ -223,11 +217,11 @@ module Squared
223
217
  on :last, :copy
224
218
  end
225
219
 
226
- def outdated(flag = nil, opts: [], sync: invoked_sync?('outdated', flag))
220
+ def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated', flag))
227
221
  cmd = bundle_output 'outdated'
228
222
  if flag
229
223
  cmd << "--#{flag}"
230
- append_bundle(opts, OPT_OUTDATED, target: cmd)
224
+ append_bundle(opts, OPT_BUNDLE[:outdated] + OPT_BUNDLE[:common], target: cmd)
231
225
  end
232
226
  log.info cmd.to_s
233
227
  on :first, :outdated
@@ -259,10 +253,10 @@ module Squared
259
253
  semmajor?(cur, lat) ? major_set.() : minor_set.()
260
254
  else
261
255
  data.each do |val|
262
- break unless (req = /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/.match(line))
256
+ break unless line =~ /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/
263
257
 
264
258
  v = semver(val).join
265
- case req[1]
259
+ case $1
266
260
  when '>', '>='
267
261
  semmajor?(cur, lat) ? major_set.() : minor_set.()
268
262
  when '<', '<='
@@ -323,8 +317,8 @@ module Squared
323
317
  end
324
318
  if found > 0
325
319
  begin
326
- if major == 0 && (data = /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/.match(dependfile.read))
327
- status = (data[2] || data[3]).chomp('/')
320
+ if major == 0 && dependfile.read =~ /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/
321
+ status = ($2 || $3).chomp('/')
328
322
  right = true
329
323
  end
330
324
  rescue StandardError => e
@@ -340,49 +334,56 @@ module Squared
340
334
  on :last, :outdated
341
335
  end
342
336
 
343
- 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 = [])
344
344
  bundle_session 'update', "--#{flag}"
345
- append_bundle opts, FOR_INSTALL + OPT_UPDATE
345
+ append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common]
346
346
  run_rb(from: :update)
347
347
  end
348
348
 
349
- def gemx(flag, opts: [])
349
+ def gemx(flag, opts = [])
350
350
  cmd = gem_session
351
351
  case flag
352
352
  when :outdated
353
- cmd << "-C #{shell_quote(path)}" if (pass = Gem::VERSION >= '3.4.2')
353
+ cmd << pwd if (pwd = gempwd)
354
354
  cmd << flag
355
+ when :push
356
+ cmd << flag << project
355
357
  when :'user-install'
356
- cmd << 'install' << "--#{flag}"
358
+ cmd << 'install' << '--user-install'
357
359
  else
358
360
  cmd << flag
359
361
  end
360
- no = flag == :pristine || flag == :outdated ? [] : OPT_GEM[:NO_GENERAL]
361
- opts, pat = option_partition(opts, gemoption(flag), no: no, first: true)
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)
362
369
  out = []
363
370
  opts.each do |opt|
364
371
  if opt =~ pat
365
372
  case $1
366
- when 'build-root', 'config-file', 'target-rbconfig',
367
- 'n', 'bindir', 'g', 'file', 'i', 'install-dir'
368
- cmd << quote_option($1, basepath($2))
369
- when 'p', 'http-proxy', 's', 'source'
370
- cmd << quote_option($1, $2)
371
- when 'bulk-threshold'
372
- cmd << basic_option($1, $2) if $2.to_i > 0
373
- else
374
- cmd << shell_option($1, $2)
373
+ when 'g', 'gem'
374
+ cmd << (flag == :exec ? shell_option($1, $2) : quote_option($1, basepath($2)))
375
375
  end
376
376
  else
377
377
  out << opt
378
378
  end
379
379
  end
380
380
  from = :"gem:#{flag == :'user-install' ? 'install' : flag}"
381
- if flag == :outdated
381
+ case flag
382
+ when :outdated
382
383
  log.info cmd.to_s
383
384
  on :first, from
384
385
  print_item format_banner(cmd.to_s)
385
- pwd_set(pass: pass, from: from) do
386
+ pwd_set(pass: !pwd.nil?, from: from) do
386
387
  items = [[%w[Gem Current Latest], nil]]
387
388
  IO.popen(cmd.done).each do |line|
388
389
  if (data = line.match(/^(\S+) \((\S+) < ([^)]+)\)$/))
@@ -454,36 +455,56 @@ module Squared
454
455
  end
455
456
  end
456
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(' ')
457
472
  else
458
- if out.empty? && !cmd.find { |val| val =~ /^--system(?:=|$)/ }
473
+ if out.empty? && cmd.none? { |val| val =~ /^--system(?:=|$)/ }
459
474
  raise_error('gem', flag, hint: 'no gemname given')
460
- else
461
- if flag == :pristine
462
- if cmd.include?('--all')
463
- append_repeat 'skip', out
464
- out.clear
465
- elsif (n = out.first =~ /@/)
466
- name = out.first
467
- if n == 0
468
- cmd << shell_escape(project)
469
- version = name[1..-1]
470
- else
471
- cmd << shell_escape(name[0..n - 1])
472
- version = name[n + 1..-1]
473
- end
474
- cmd << shell_option('version', version)
475
- 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]
476
488
  end
489
+ cmd << shell_option('version', version)
490
+ out.clear
477
491
  end
478
- append_value out
479
492
  end
480
- run_rb(from: from)
493
+ append_value(out, escape: true)
481
494
  end
495
+ run_rb(from: from)
482
496
  end
483
497
 
484
- def bundle(cmd, *args)
498
+ def bundle(flag, *args)
485
499
  args = args.flatten
486
- 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}")
487
508
  end
488
509
 
489
510
  def rake(*cmd)
@@ -509,34 +530,43 @@ module Squared
509
530
  end
510
531
  return false unless @autodetect
511
532
 
512
- set = lambda do |val|
533
+ set = lambda do |val, path|
513
534
  log.warn "using version #{val} (given #{@version})" if @version && @version != val
514
535
  @version = val
536
+ @gemdir = Pathname.new(path.strip).join(gempath)
515
537
  end
516
538
  if @version
517
- out = pwd_set { `#{gem_output('list', '--local', '-d', shell_escape(project, quote: true))}` }
518
- if (data = /#{Regexp.escape(project)} \(([^)]+)\)/.match(out))
519
- ver = data[1].split(/\s*,\s*/)
520
- ver.unshift(@version).uniq!
521
- ver.each do |val|
522
- next unless (data = /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/.match(out))
523
-
524
- set.(val)
525
- 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
526
551
  end
527
552
  end
528
553
  end
529
- unless data || RUBY_VERSION < '2.6'
530
- target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
531
- if (path = target.resolve_feature_path(project)&.last)
532
- gems = ['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR)
533
- if (ver = Regexp.new(gems).match(path)) && (data = /\A(.+)#{gempath(ver[1])}/.match(path))
534
- 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)
535
561
  end
536
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
537
568
  end
538
- raise_error('failed to parse', hint: @version || 'path') unless data
539
- @gemdir = Pathname.new(data[1].strip).join(gempath)
569
+ raise_error('failed to parse', hint: @version || 'path') unless @gemdir
540
570
  rescue StandardError => e
541
571
  log.error e
542
572
  @version = nil
@@ -557,24 +587,7 @@ module Squared
557
587
  end
558
588
 
559
589
  def append_bundle(opts, list, target: @session)
560
- opts, pat = option_partition(opts, list, target: target)
561
- out = []
562
- opts.each do |opt|
563
- if opt =~ pat
564
- case $1
565
- when 'path', 'gemfile', 'binstubs', 'target-rbconfig'
566
- target << quote_option($1, basepath($2))
567
- when 'standalone', 'with', 'without', 'g', 'group'
568
- target << quote_option($1, $2)
569
- when 'retry', 'j', 'jobs'
570
- target << basic_option($1, $2) if $2.to_i > 0
571
- else
572
- target << shell_option($1, $2)
573
- end
574
- else
575
- out << opt
576
- end
577
- end
590
+ out = option_sanitize(opts, list, target: target).first
578
591
  option_clear(out, target: target)
579
592
  end
580
593
 
@@ -610,12 +623,12 @@ module Squared
610
623
  return @rakelist if @rakelist
611
624
 
612
625
  ret = []
613
- pass = Rake::VERSION >= '13.0.4'
614
- pwd_set(pass: pass) do
615
- IO.popen(rake_output(pass ? "-C #{shell_quote(path)}" : nil, '-AT').to_s).each do |line|
616
- 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 ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
617
630
 
618
- ret << [data[1], data[2]]
631
+ ret << [$1, $2]
619
632
  end
620
633
  end
621
634
  @rakelist = ret
@@ -630,26 +643,29 @@ module Squared
630
643
  end
631
644
 
632
645
  def rakefile
633
- file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }
634
- basepath(file) if file
646
+ return unless (file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? })
647
+
648
+ basepath(file)
635
649
  end
636
650
 
637
651
  def rakeapp
638
652
  quote_option 'rakefile', Rake.application.rakefile
639
653
  end
640
654
 
641
- def gempath(val = @version)
642
- File.join('gems', "#{project}-#{val}")
655
+ def rakepwd
656
+ return unless Rake::VERSION >= '13.0.4'
657
+
658
+ quote_option('C', path)
643
659
  end
644
660
 
645
- def gemoption(flag)
646
- target = flag == :'user-install' ? :INSTALL : flag.upcase
647
- OPT_GEM[:COMMON] + OPT_GEM[target] + case flag
648
- when :pristine, :outdated
649
- []
650
- else
651
- OPT_GEM[:GENERAL] + OPT_GEM[:NO_GENERAL]
652
- 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}")
653
669
  end
654
670
  end
655
671
 
@@ -17,7 +17,8 @@ module Squared
17
17
 
18
18
  attr_reader :manifest_url, :manifest
19
19
 
20
- 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)
21
22
  @home = if (val = env('REPO_HOME'))
22
23
  path = Pathname.new(val)
23
24
  if main == path.basename.to_s
@@ -74,6 +75,7 @@ module Squared
74
75
  else
75
76
  data[:script] = script
76
77
  end
78
+ data[:args] = (val = env('REPO_SCRIPT')) ? shell_split(val, join: true) : args
77
79
  elsif (val = env('REPO_BUILD'))
78
80
  data[:run] = val
79
81
  data[:env] = true
@@ -81,8 +83,8 @@ module Squared
81
83
  data[:run] = run
82
84
  end
83
85
  data[:global] = true
84
- data[:dev] = env_match('REPO_DEV', dev, suffix: @envname)
85
- 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)
86
88
  if (val = env('REPO_GROUP'))
87
89
  script_set(data, group: val.split(','))
88
90
  found = true
@@ -92,11 +94,12 @@ module Squared
92
94
  found = true
93
95
  end
94
96
  script_set(data, group: group, ref: ref) unless found
95
- @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
96
98
  @extensions << :__repo__
97
99
  elsif script || run
98
100
  if script
99
101
  data[:script] = script
102
+ data[:args] = args
100
103
  else
101
104
  data[:run] = run
102
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
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-05 00:00:00.000000000 Z
10
+ date: 2025-02-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake