squared 0.5.10 → 0.5.12

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.
@@ -13,7 +13,7 @@ module Squared
13
13
  buildx: {
14
14
  common: %w[builder=b D|debug],
15
15
  build: %w[add-host=q annotation=q attest=q build-arg=qq build-context=qq cache-from=q cache-to=q
16
- cgroup-parent=b ent=q iidfile=p label=q a-file=p network=b no-cache-filter=b o|output=q platform=b
16
+ cgroup-parent=b iidfile=p label=q a-file=p network=b no-cache-filter=b o|output=q platform=b
17
17
  q|quiet secret=qq shm-size=b ssh=qq t|tag=b target=b ulimit=q].freeze,
18
18
  bake: %w[print list=q set=q].freeze,
19
19
  shared: %w[check load no-cache pull push allow=q call=b? f|file=p metadata-file=p progress=b provenance=q
@@ -26,8 +26,8 @@ module Squared
26
26
  provenance=q sbom=q ssh=qq].freeze,
27
27
  exec: %w[d|detach privileged e|env=qq index=i T|no-TTY=b? user=e w|workdir=q].freeze,
28
28
  run: %w[build d|detach no-deps q|quiet quiet-build quiet-pull remove-orphans rm P|service-ports use-aliases
29
- cap-add=b cap-drop=b q e|env=qq env-from-file=p i|interactive=b? l|label=q name=b T|no-TTY=b?
30
- p|publish=e pull=b u|user=e v|volume=q w|workdir=q].freeze,
29
+ cap-add=b cap-drop=b entrypoint=q e|env=qq env-from-file=p i|interactive=b? l|label=q name=b
30
+ T|no-TTY=b? p|publish=q pull=b u|user=e v|volume=q w|workdir=q].freeze,
31
31
  up: %w[abort-on-container-exit abort-on-container-failure always-recreate-deps attach-dependencies build
32
32
  d|detach force-recreate menu no-build no-color no-deps no-log-prefix no-recreate no-start quiet-build
33
33
  quiet-pull remove-orphans V|renew-anon-volumes timestamps wait w|watch y|yes attach=b
@@ -36,25 +36,26 @@ module Squared
36
36
  }.freeze,
37
37
  container: {
38
38
  create: %w[init i|interactive no-healthcheck oom-kill-disable privileged P|publish-all q|quiet read-only
39
- rm runtime t|tty use-api-socket io-maxbandwidth=b io-maxiops=b add-host=q annotation=q a|attach=b
40
- blkio-weight=i blkio-weight-device=i cap-add=b cap-drop=b cgroup-parent=b cgroupns=b cidfile=p
41
- device=q device-cgroup-rule=q device-read-bps=q device-read-iops=q device-write-bps=q
42
- device-write-iops=q disable-content-trust=b? dns=e dns-option=e dns-search=e domainname=b
43
- entrypoint=q e|env=qq env-file=p expose=e gpus=q group-add=b health-cmd=q health-interval=b ip6=e
44
- ipc=b isolation=b kernel-memory=b l|label=q label-file=p link=b link-local-ip=b log-driver=b
45
- log-opt=q mac-address=e m|memory=b memory-reservation=b memory-swap=n memory-swappiness=n
46
- mount=qq name=b network=b network-alias=b oom-score-adj=b pid=b pids-limit=n platform=b
47
- p|publish=e pull=b restart=b runtime=b security-opt=q shm-size=b stop-signal=b stop-timeout=i
48
- storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b v|volume=q volume-driver=b
49
- volumes-from=b w|workdir=q].freeze,
50
- run: %w[d|detach detach-keys=q sig-proxy=b?].freeze,
39
+ rm t|tty use-api-socket add-host=q annotation=q a|attach=b blkio-weight=i blkio-weight-device=i
40
+ cap-add=b cap-drop=b cgroup-parent=b cgroupns=b cidfile=p device=q device-cgroup-rule=q
41
+ device-read-bps=q device-read-iops=q device-write-bps=q device-write-iops=q
42
+ disable-content-trust=b? dns=q dns-option=q dns-search=q domainname=b entrypoint=q e|env=qq
43
+ env-file=p expose=q gpus=q group-add=b health-cmd=q health-interval=b health-retries=i
44
+ health-start-interval=q health-start-period=q health-timeout=q io-maxbandwidth=b io-maxiops=b
45
+ ip=b ip6=q ipc=b isolation=b kernel-memory=b l|label=q label-file=q link=b link-local-ip=q
46
+ log-driver=b log-opt=q mac-address=q m|memory=b memory-reservation=b memory-swap=n
47
+ memory-swappiness=n mount=qq name=b network=b network-alias=b oom-score-adj=b pid=b pids-limit=n
48
+ platform=b p|publish=q pull=b restart=b runtime=b security-opt=q shm-size=b stop-signal=b
49
+ stop-timeout=i storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b v|volume=q
50
+ volume-driver=b volumes-from=b w|workdir=q].freeze,
51
+ run: %w[d|detach detach-keys=q hostname=q sig-proxy=b?].freeze,
51
52
  update: %w[blkio-weight=i cpu-period=i cpu-quota=i cpu-rt-period=i cpu-rt-runtime=i c|cpu-shares=i cpus=f
52
53
  cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=b pids-limit=n
53
54
  restart=q].freeze,
54
55
  exec: %w[d|detach i|interactive privileged t|tty detach-keys=q e|env=qq env-file=p user=e
55
56
  w|workdir=q].freeze,
56
57
  commit: %w[a|author=q c|change=q m|message=q pause=b?].freeze,
57
- inspect: %w[s|size f|format=q].freeze,
58
+ inspect: %w[s|size f|format=q type=b].freeze,
58
59
  start: %w[a|attach i|interactive detach-keys=q].freeze,
59
60
  stop: %w[s|signal=b t|time=i t|timeout=i].freeze,
60
61
  restart: %w[s|signal=b t|time=i t|timeout=i].freeze,
@@ -68,7 +69,7 @@ module Squared
68
69
  save: %w[o|output=p platform=b].freeze
69
70
  }.freeze,
70
71
  network: {
71
- connect: %w[alias=b driver-opt=q gw-priority=n ip=b ip6=b link=b link-local-ip=b].freeze,
72
+ connect: %w[alias=b driver-opt=q gw-priority=n ip=b ip6=q link=b link-local-ip=q].freeze,
72
73
  disconnect: %w[f|force].freeze
73
74
  }.freeze
74
75
  }.freeze
@@ -113,7 +114,7 @@ module Squared
113
114
  return unless dockerfile(file).exist?
114
115
 
115
116
  @context = context
116
- @tag = tag || tagname("#{@project}:#{@version || 'latest'}")
117
+ self.tag = tag || tagname("#{@project}:#{@version || 'latest'}")
117
118
  @mounts = mounts
118
119
  @secrets = secrets
119
120
  @registry = tagjoin registry, kwargs[:username]
@@ -206,7 +207,7 @@ module Squared
206
207
  end
207
208
  end
208
209
  else
209
- format_desc(action, flag, 'opts*,id/name', after: flag == :update ? '+' : '*')
210
+ format_desc action, flag, "opts*,id/name#{flag == :update ? '+' : '*'}"
210
211
  task flag do |_, args|
211
212
  container flag, args.to_a
212
213
  end
@@ -533,7 +534,7 @@ module Squared
533
534
  list_image(flag, docker_output('image ls -a'), from: from) do |val|
534
535
  op << val
535
536
  if flag == :tag
536
- op << tagname("#{@project}:#{op.first}")
537
+ op << tagname("#{project}:#{op.first}")
537
538
  break
538
539
  end
539
540
  end
@@ -554,7 +555,7 @@ module Squared
554
555
  banner = false
555
556
  end
556
557
  ret = run(cmd, sync: sync, exception: exception, banner: banner, from: from)
557
- print_success if success?(ret) && (flag == :tag || flag == :save)
558
+ print_success if success?(ret, flag == :tag || flag == :save)
558
559
  end
559
560
 
560
561
  def network(flag, opts = [], target: nil)
@@ -656,13 +657,14 @@ module Squared
656
657
  when 2, 4
657
658
  return
658
659
  when 3
659
- return unless COMPOSEFILE.map { |val| basepath(val) }.select(&:exist?).size > 1
660
+ return unless COMPOSEFILE.select { |val| basepath(val).exist? }.size > 1
660
661
  end
661
662
  end
662
663
  files = Array(@file).map { |val| quote_option('file', basepath(val)) }
663
664
  if target.is_a?(Set)
664
665
  opts = target.to_a.insert(index, *files)
665
- target.clear.merge(opts)
666
+ target.clear
667
+ .merge(opts)
666
668
  else
667
669
  target.insert(index, *files)
668
670
  end
@@ -678,7 +680,7 @@ module Squared
678
680
  def append_tag(val, target: @session)
679
681
  case val
680
682
  when String
681
- val.split(',')
683
+ split_escape val
682
684
  when Array
683
685
  val
684
686
  else
@@ -820,7 +822,7 @@ module Squared
820
822
  end
821
823
  cmd.merge(Array(out).map! { |val| parse.call(val) })
822
824
  cmd << args
823
- print_success if success?(run(cmd)) && ctx.start_with?(/(?:network|tag|save)/)
825
+ print_success if success?(run(cmd), ctx.start_with?(/(?:network|tag|save)/))
824
826
  end
825
827
  end
826
828
 
@@ -408,10 +408,11 @@ module Squared
408
408
 
409
409
  case flag
410
410
  when :branch
411
- format_desc action, flag, 'path,opts*'
412
- task flag, [:path] do |_, args|
411
+ format_desc action, flag, 'path,name?'
412
+ task flag, [:path, :name] do |_, args|
413
413
  path = param_guard(action, flag, args: args, key: :path)
414
- submodule(flag, args.extras, path: path)
414
+ branch = args.name
415
+ submodule(flag, [branch ? 'b' : 'd'], branch: branch, path: path)
415
416
  end
416
417
  when :url
417
418
  format_desc action, flag, 'path,url,opts*'
@@ -498,7 +499,7 @@ module Squared
498
499
  remote = choice_remote
499
500
  end
500
501
  ret = tag(flag, refs: [name], message: message, commit: commit, remote: remote)
501
- print_success if success?(ret) && !remote
502
+ print_success if success?(ret, !remote)
502
503
  end
503
504
  end
504
505
  when 'stash'
@@ -640,7 +641,7 @@ module Squared
640
641
  task flag, [:commit] do |_, args|
641
642
  commit = commithead args.commit
642
643
  unless commit
643
- commit, merge = choice_commit(values: ['Merge? [y|N]'])
644
+ commit, merge = choice_commit(values: ['Merge? [y/N]'])
644
645
  merge = merge&.upcase == 'Y'
645
646
  end
646
647
  checkout(flag, commit: commit, merge: merge)
@@ -721,7 +722,7 @@ module Squared
721
722
  task flag, [:name, :commit] do |_, args|
722
723
  branch = param_guard(action, flag, args: args, key: :name)
723
724
  commit = commithead args.commit
724
- commit, track = choice_commit(values: ['Track? [Y|n]'], force: false) if commit == ':'
725
+ commit, track = choice_commit(values: ['Track? [Y/n]'], force: false) if commit == ':'
725
726
  switch(flag, branch: branch, commit: commit, track: track)
726
727
  end
727
728
  when :detach
@@ -1476,7 +1477,9 @@ module Squared
1476
1477
  source op
1477
1478
  cached = git_spawn 'diff --cached --name-only --no-color'
1478
1479
  if amend || !cached.empty? || dryrun?
1479
- puts cached if adding.empty? && !cached.empty? && banner?
1480
+ if adding.empty? && !cached.empty? && banner?
1481
+ puts(cached.lines.map! { |val| "cached #{shell_quote(val.chomp)}" })
1482
+ end
1480
1483
  source co
1481
1484
  source pu
1482
1485
  elsif banner?
@@ -1556,7 +1559,7 @@ module Squared
1556
1559
  append_value list
1557
1560
  remote = nil
1558
1561
  when :move, :copy
1559
- s = "-#{flag.to_s[0]}"
1562
+ s = +"-#{flag.to_s[0]}"
1560
1563
  s.upcase! if option('force', 'f')
1561
1564
  cmd << s
1562
1565
  refs.compact.each { |val| cmd << shell_quote(val) }
@@ -1642,21 +1645,19 @@ module Squared
1642
1645
  source
1643
1646
  end
1644
1647
 
1645
- def submodule(flag, opts = [], path: nil, url: nil)
1648
+ def submodule(flag, opts = [], branch: nil, path: nil, url: nil)
1646
1649
  cmd, opts = git_session('submodule', opts: opts)
1647
1650
  op = OptionPartition.new(opts, OPT_GIT[:submodule].fetch(flag, []), cmd, project: self)
1648
1651
  case flag
1649
1652
  when :branch, :url
1650
1653
  op.adjoin("set-#{flag}")
1651
- op << '--'
1652
- op.add_path(path) if path
1653
- op.add_quote(url) if url
1654
+ op.add_quote(branch, '--', path, url)
1654
1655
  else
1655
1656
  op.adjoin(flag)
1656
1657
  op << '--recursive' if option('recursive', 'r')
1657
1658
  op.splice(path: true)
1658
1659
  end
1659
- source
1660
+ print_success if success?(source, flag == :branch)
1660
1661
  end
1661
1662
 
1662
1663
  def restore(flag, opts = [], commit: nil, files: nil)
@@ -1979,7 +1980,7 @@ module Squared
1979
1980
  when 'rebase'
1980
1981
  op << basic_option($1, $2) if VAL_GIT[:rebase][:value].include?($2)
1981
1982
  when 'shallow-since'
1982
- op.append?($1) { Date.parse($2)&.strftime('%F %T') }
1983
+ op.append?($1) { Date.parse($2).strftime('%F %T') }
1983
1984
  when 'recurse-submodules'
1984
1985
  op.append?($1, $2, type: :basic)
1985
1986
  when 'refspec'
@@ -130,10 +130,9 @@ module Squared
130
130
  when 'add'
131
131
  format_desc action, nil, 'save?=prod|dev|optional|peer,name+'
132
132
  task action, [:save] do |_, args|
133
- save = param_guard(action, 'save', args: args, key: :save)
134
- exact = true if save.delete_prefix!('=')
135
- packages = case save
136
- when 'prod', 'dev', 'optional', 'peer'
133
+ packages = if args.save =~ /\A(=)?(prod|dev|optional|peer)\z/
134
+ exact = !$1.nil?
135
+ save = $2
137
136
  args.extras
138
137
  else
139
138
  save = 'prod'
@@ -147,21 +146,21 @@ module Squared
147
146
 
148
147
  format_desc action, nil, "script,opts*|#{indexchar}index+|#,pattern*"
149
148
  task action, [:script] do |_, args|
149
+ list = scripts.to_a
150
150
  if args.script == '#'
151
- format_list(scripts.to_a, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile)
151
+ format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile)
152
152
  else
153
153
  args = param_guard(action, 'script', args: args.to_a)
154
154
  opts = []
155
155
  args.each do |val|
156
156
  if (n, extra = indexitem(val))
157
157
  if (item = list[n - 1])
158
- val = extra ? "#{item.first} #{extra}" : item.first
158
+ run compose([item.first, extra].compact.join(' '), script: true)
159
159
  elsif exception
160
160
  indexerror n, list
161
161
  else
162
162
  next log.warn "run script #{n} of #{list.size} (out of range)"
163
163
  end
164
- run compose(val, script: true)
165
164
  else
166
165
  opts << val
167
166
  end
@@ -374,7 +373,7 @@ module Squared
374
373
  target.mkpath
375
374
  subdir << target.to_s
376
375
  end
377
- FileUtils.cp(basepath(s), dest, verbose: verbose.is_a?(Numeric) && verbose > 0)
376
+ FileUtils.cp(basepath(s), dest, verbose: verbosetype > 0)
378
377
  rescue StandardError => e
379
378
  print_error e
380
379
  errors += 1
@@ -416,7 +415,7 @@ module Squared
416
415
  end
417
416
  target.each do |src, to|
418
417
  glob.each { |val| log.info "cp #{from + val} #{to}" }
419
- copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbose)
418
+ copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbosetype > 0)
420
419
  rescue StandardError => e
421
420
  on_error e, :copy
422
421
  end
@@ -431,19 +430,7 @@ module Squared
431
430
  workspace.rev_clear(name, sync: sync)
432
431
  return update if !flag && env('NODE_UPDATE')
433
432
 
434
- pnpm = pnpm?
435
- yarn = pnpm ? 0 : dependtype(:yarn)
436
- if @pm[:__] && !pnpm && yarn == 0
437
- case @pm[:__]
438
- when 'pnpm'
439
- pnpm = true
440
- when 'yarn'
441
- yarn = 1
442
- when 'berry'
443
- yarn = 2
444
- end
445
- end
446
- if yarn > 0
433
+ if (yarn = dependtype(:yarn)) > 0
447
434
  cmd = session 'yarn'
448
435
  if flag == :add
449
436
  cmd << 'add'
@@ -453,7 +440,7 @@ module Squared
453
440
  cmd << 'install'
454
441
  cmd << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
455
442
  end
456
- elsif pnpm
443
+ elsif pnpm?
457
444
  cmd = session 'pnpm'
458
445
  if flag == :add
459
446
  cmd << 'add' << "--save-#{save}"
@@ -487,7 +474,7 @@ module Squared
487
474
 
488
475
  def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated', flag))
489
476
  dryrun = opts.include?('dry-run') || opts.include?('d')
490
- if pnpm? && read_packagemanager(version: '7.15', update: true)
477
+ if pnpm?
491
478
  cmd = session 'pnpm', 'outdated'
492
479
  dryrun ||= dryrun?('pnpm')
493
480
  else
@@ -642,7 +629,7 @@ module Squared
642
629
  else
643
630
  footer.call(0, found.size)
644
631
  end
645
- commit(:add, refs: ['package.json'], pass: true)
632
+ commit(:add, ['package.json'], pass: true)
646
633
  end
647
634
  elsif !avail.empty?
648
635
  col1 = size_col.call(avail, 0) + 4
@@ -888,45 +875,32 @@ module Squared
888
875
 
889
876
  def yarn?
890
877
  (@pm[:yarn] ||= if rootpath('yarn.lock', ascend: dependext).exist?
891
- if (rc = rootpath('.yarnrc.yml', ascend: dependext)).exist?
892
- begin
893
- require 'yaml'
894
- doc = YAML.load_file(rc)
895
- doc.nodeLinker == 'node-modules' ? 2 : 3
896
- rescue StandardError => e
897
- log.debug e
898
- 3
899
- end
878
+ yarntype
879
+ elsif (ver = read_packagemanager || read_install)
880
+ if ver =~ /^yarn(?:@(\d)|$)/
881
+ $1 && $1.to_i > 1 ? yarntype : 1
900
882
  else
901
- 1
883
+ 0
902
884
  end
903
- elsif (ver = read_packagemanager || read_install)&.start_with?('yarn')
904
- ver == 'yarn' || ver.include?('@1') ? 1 : 3
905
885
  else
906
- 0
886
+ case @pm[:__]
887
+ when 'yarn'
888
+ 1
889
+ when 'berry'
890
+ yarntype
891
+ else
892
+ 0
893
+ end
907
894
  end) > 0
908
895
  end
909
896
 
910
897
  def pnpm?
911
898
  (@pm[:pnpm] ||= if rootpath('pnpm-lock.yaml', ascend: dependext).exist?
912
- begin
913
- require 'yaml'
914
- doc = YAML.load_file(basepath('node_modules/.modules.yaml', ascend: dependext))
915
- @pm[:_] = doc['packageManager']
916
- case doc['nodeLinker']
917
- when 'hoisted'
918
- 1
919
- when 'pnp'
920
- 3
921
- else
922
- 4
923
- end
924
- rescue StandardError => e
925
- log.debug e
926
- 4
927
- end
899
+ pnpmtype
900
+ elsif (ver = read_packagemanager || read_install)
901
+ ver.start_with?('pnpm') ? pnpmtype : 0
928
902
  else
929
- (read_packagemanager || read_install)&.start_with?('pnpm') ? 4 : 0
903
+ @pm[:__] == 'pnpm' ? pnpmtype : 0
930
904
  end) > 0
931
905
  end
932
906
 
@@ -976,14 +950,17 @@ module Squared
976
950
  private
977
951
 
978
952
  def read_packagemanager(key = nil, version: nil, update: false)
979
- if @pm[:_].nil? || update
953
+ if (key ? !@pm.key?(key) : @pm[:_].nil?) || update
980
954
  doc = JSON.parse(dependfile.read)
981
- @pm[:_] = (val = doc['packageManager']) ? val[0, val.index('+') || val.size] : false
982
- @pm[:name] = doc['name']
983
- @pm[:scripts] = doc['scripts']
984
- @pm[:version] = doc['version']
985
- @pm[:private] = doc['private']
986
- @pm[:workspaces] = doc['workspaces']
955
+ if @pm[:_].nil?
956
+ @pm[:_] = (val = doc['packageManager']) ? val[0, val.index('+') || val.size] : false
957
+ @pm[:name] = doc['name']
958
+ @pm[:scripts] = doc['scripts']
959
+ @pm[:version] = doc['version']
960
+ @pm[:private] = doc['private']
961
+ @pm[:workspaces] = doc['workspaces']
962
+ end
963
+ @pm[key] = doc[key.to_s] if key
987
964
  end
988
965
  rescue StandardError => e
989
966
  log.debug e
@@ -1000,10 +977,67 @@ module Squared
1000
977
  def read_install
1001
978
  return unless (ret = env('NODE_INSTALL'))
1002
979
 
1003
- @pm[:_] ||= ret if ret.include?('@')
980
+ if ret.include?(',')
981
+ catch :found do
982
+ split_escape(ret).each do |val|
983
+ case val
984
+ when /^yarn/
985
+ next if yarntype(exist: true) == 0
986
+ when /^pnpm/
987
+ next if pnpmtype(exist: true) == 0
988
+ when /^npm/
989
+ nil
990
+ else
991
+ next
992
+ end
993
+ ret = val
994
+ throw :found
995
+ end
996
+ return
997
+ end
998
+ end
999
+ @pm[:_] ||= ret
1004
1000
  ret
1005
1001
  end
1006
1002
 
1003
+ def yarntype(exist: false)
1004
+ if (rc = rootpath('.yarnrc.yml', ascend: dependext)).exist?
1005
+ require 'yaml'
1006
+ doc = YAML.load_file(rc)
1007
+ doc.nodeLinker == 'node-modules' ? 2 : 3
1008
+ elsif exist && !basepath('yarn.lock').exist?
1009
+ 0
1010
+ else
1011
+ 1
1012
+ end
1013
+ rescue StandardError => e
1014
+ return 0 if exist
1015
+
1016
+ log.debug e
1017
+ 3
1018
+ end
1019
+
1020
+ def pnpmtype(exist: false)
1021
+ require 'yaml'
1022
+ doc = YAML.load_file(basepath('node_modules/.modules.yaml', ascend: dependext))
1023
+ @pm['packageManager'] = doc['packageManager']
1024
+ case doc['nodeLinker']
1025
+ when 'hoisted'
1026
+ 1
1027
+ when 'pnp'
1028
+ 3
1029
+ else
1030
+ 4
1031
+ end
1032
+ rescue StandardError => e
1033
+ if exist
1034
+ %w[pnpm-lock.yaml pnpm-workspace.yaml].any? { |val| basepath(val).exist? } ? 4 : 0
1035
+ else
1036
+ log.debug e
1037
+ 4
1038
+ end
1039
+ end
1040
+
1007
1041
  def append_loglevel(target: @session)
1008
1042
  level = env('NODE_LOGLEVEL')
1009
1043
  silent = !verbose || level == 'silent'
@@ -372,7 +372,7 @@ module Squared
372
372
  end
373
373
  end
374
374
 
375
- def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated'))
375
+ def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated', flag))
376
376
  cmd = pip_session 'list --outdated'
377
377
  append_global
378
378
  cmd = session_done cmd
@@ -279,7 +279,13 @@ module Squared
279
279
  elsif outdated?
280
280
  workspace.rev_clear(name, sync: sync)
281
281
  cmd = bundle_session 'install'
282
- cmd << '--without=development' if prod?
282
+ if prod? && !config_get('without')
283
+ if RUBY_VERSION > '3'
284
+ config_set 'without', 'development'
285
+ else
286
+ cmd << '--without=development'
287
+ end
288
+ end
283
289
  if (n = option('jobs')).to_i > 0
284
290
  cmd << "-j#{n}"
285
291
  end
@@ -312,7 +318,7 @@ module Squared
312
318
  c = glob[i] || glob.first
313
319
  log.info "cp #{a + c} #{b}"
314
320
  begin
315
- copy_dir(a, b, c, pass: pass, verbose: verbose)
321
+ copy_dir(a, b, c, pass: pass, verbose: verbosetype > 0)
316
322
  rescue StandardError => e
317
323
  on_error e, :copy
318
324
  end
@@ -528,7 +534,9 @@ module Squared
528
534
  if @asdf
529
535
  cmd = 'asdf'
530
536
  ver = '.tool-versions'
531
- `asdf current #{@asdf.first}`[/\A\S+\s+\S+/, 0].sub(/\s+/, ' ')
537
+ opt = [@asdf.first]
538
+ opt.unshift('--no-header') unless @@asdf[1] == 15
539
+ `asdf current #{opt.join(' ')}`[/^\S+\s+\S+/, 0].sub(/\s+/, ' ')
532
540
  else
533
541
  ver = nil
534
542
  `ruby --version`
@@ -916,7 +924,7 @@ module Squared
916
924
  pwd_set(pass: !opt.nil?) do
917
925
  out = `#{gem_output(opt, 'list --local -d', gemname)}`
918
926
  if out =~ /#{Regexp.escape(gemname)} \(([^)]+)\)/
919
- $1.split(/\s*,\s*/)
927
+ split_escape($1)
920
928
  .prepend(version)
921
929
  .uniq
922
930
  .each do |val|
@@ -1023,6 +1031,28 @@ module Squared
1023
1031
  session_output('rake', *cmd, **kwargs)
1024
1032
  end
1025
1033
 
1034
+ def config_get(key)
1035
+ ret = if pwd_set { `#{bundle_output('config get --parseable', key)}` } =~ /\A([^=]+)=(.*)\z/ && $1 == key
1036
+ $2.chomp
1037
+ end
1038
+ case ret
1039
+ when 'true'
1040
+ true
1041
+ when '', '[]'
1042
+ nil
1043
+ else
1044
+ if ret =~ /\A\[:(.+)\]\z/
1045
+ $1.split(', :').map! { |val| ((val.delete_prefix!('"') && val.delete_suffix!('"')) || val).to_sym }
1046
+ else
1047
+ ret || false
1048
+ end
1049
+ end
1050
+ end
1051
+
1052
+ def config_set(key, *val)
1053
+ run(bundle_output('config set', key, *val), banner: false, series: false)
1054
+ end
1055
+
1026
1056
  def preopts
1027
1057
  verbosetype > 1 && !session_arg?('quiet') ? ['--verbose'] : []
1028
1058
  end
@@ -10,9 +10,10 @@ module Squared
10
10
  include Common::Shell
11
11
  extend Forwardable
12
12
 
13
+ OPT_NAME = /\A(?:(--)|-)((?(1)[A-Za-z\d]+|[A-Za-z\d]))\z/
13
14
  OPT_VALUE = /\A-{0,2}([^= ]+)(?: *= *| +)(.+)\z/
14
15
  OPT_SINGLE = /\A-([A-Za-z\d])(.+)\z/
15
- private_constant :OPT_VALUE, :OPT_SINGLE
16
+ private_constant :OPT_NAME, :OPT_VALUE, :OPT_SINGLE
16
17
 
17
18
  class << self
18
19
  include Common::Format
@@ -70,8 +71,8 @@ module Squared
70
71
  def strip(val)
71
72
  return [] unless val
72
73
 
73
- val = shell_split(val) if val.is_a?(String)
74
- val.map { |s| s.sub(OPT_SINGLE, '\1=\2').sub(OPT_VALUE, '\1=\2') }.reject(&:empty?)
74
+ val = shell_split val if val.is_a?(String)
75
+ val.map { |s| s.sub(OPT_SINGLE, '\1=\2').sub(OPT_VALUE, '\1=\2').sub(OPT_NAME, '\2') }.reject(&:empty?)
75
76
  end
76
77
 
77
78
  def select(list, bare: true, no: true, single: false, double: false)
@@ -247,9 +248,9 @@ module Squared
247
248
  add quote_option(key, val, double: qq.include?(key), merge: merge)
248
249
  elsif p.include?(key)
249
250
  if val.match?(/\A(["']).+\1\z/)
250
- add shell_option(key, val, escape: false, merge: merge, sep: sep)
251
+ add shell_option(key, val, escape: false, merge: merge)
251
252
  elsif path
252
- add quote_option(key, path + val, merge: merge, sep: sep)
253
+ add quote_option(key, path + val, merge: merge)
253
254
  else
254
255
  push opt
255
256
  end
@@ -414,7 +415,7 @@ module Squared
414
415
  end
415
416
 
416
417
  def add_quote(*args, **kwargs)
417
- merge(args.map! { |val| shell_quote(val, **kwargs) })
418
+ merge(args.compact.map! { |val| val == '--' ? val : shell_quote(val, **kwargs) })
418
419
  self
419
420
  end
420
421
 
@@ -132,19 +132,20 @@ module Squared
132
132
  task 'all' do |_, args|
133
133
  stage ||= 'all'
134
134
  ns['sync'].invoke(*args.to_a)
135
- next if env('REPO_STAGE', equals: '1')
135
+ next if (stage = env('REPO_STAGE')) == '1'
136
136
 
137
137
  @project.select do |_, proj|
138
- next unless proj.enabled?(proj.workspace.baseref)
138
+ next unless proj.enabled?(proj.workspace.baseref) && proj.global
139
139
 
140
140
  proj.depend(sync: true) if proj.depend?
141
- next if env('REPO_STAGE', equals: '2')
141
+ next if stage == '2'
142
142
 
143
143
  proj.build?
144
144
  end
145
145
  .each_value do |proj|
146
146
  proj.build(sync: true)
147
- next unless proj.dev? && proj.copy? && !env('REPO_STAGE', equals: '3')
147
+ next if stage == '3'
148
+ next unless proj.copy? && (proj.dev? || stage == '4')
148
149
 
149
150
  if (ws = proj.workspace).task_defined?(target = task_join(proj.name, 'copy'))
150
151
  task_invoke(target, **ws.invokeargs)