squared 0.4.23 → 0.4.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d6cb2868bb0cf1337f5b55837f5347d280408fece9d5ced520fa0a4b4dcf66a
4
- data.tar.gz: 473e53ee64c8f98d4005ae4a36a31f652f67513fb9892f3beb9696a6eba27df4
3
+ metadata.gz: c07babae909a985bae708b8a2bec453b223d9889af828da70d990609e9966142
4
+ data.tar.gz: 5375a660bbcc0f49b5a3eaad5ab2740b103beeb3823a0d7b027b9005bf39faa9
5
5
  SHA512:
6
- metadata.gz: e99a8c8804d50e7b051ccb3a3fc5233f8209a0a2ec9a4b8ca82fae5a5917da851b639123294f5948a1dbe1e1749157e0a150c9b7b9a4053f043fc600477d2f9a
7
- data.tar.gz: bbc77a9801a42360e468a388c008e24f7e2c5d2d431de46174871bcc11d482b7595d9339455824d9077861d889577c55649bcfada9a5617c058ab1ba95db04ad
6
+ metadata.gz: 23cd1e57c7d0039fed851d6d426eec51022dba2c26bbce9faafddd20ded4aad3d00d6db023c3a99e2aa485aace597567df4f603130746daa5dc5e2d661c658dd
7
+ data.tar.gz: cb9556662d393d458413df3669f9859b4b3df9d9ca3e659b9098fac0d550349eaf8b414e6cb85b0828f522f3b78f1627c282350eb6b9b62218f76413ebcaabb8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.24] - 2025-10-17
4
+
5
+ ### Added
6
+
7
+ - Repo task [init|all] can bypass dev? copy requirement with REPO_STAGE=4.
8
+
9
+ ### Changed
10
+
11
+ - Node command outdated does not check PNPM minimum version.
12
+
13
+ ### Fixed
14
+
15
+ - Project base rescue error handling used reversed parameters.
16
+ - Project absolute paths did not append wildcard with trailing slash.
17
+ - Powershell commands did not escape nested double quotes.
18
+ - OptionPartition did not strip flags without a value.
19
+ - Project base method add did not use parent context.
20
+ - Application property pipe did not parse numeric values.
21
+
3
22
  ## [0.4.23] - 2025-10-11
4
23
 
5
24
  ### Fixed
@@ -1018,6 +1037,7 @@
1018
1037
 
1019
1038
  - Changelog was created.
1020
1039
 
1040
+ [0.4.24]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.24
1021
1041
  [0.4.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.23
1022
1042
  [0.4.22]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.22
1023
1043
  [0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
data/README.md CHANGED
@@ -723,7 +723,7 @@ REPO_SYNC # 0,1
723
723
  REPO_URL # manifest repository
724
724
  REPO_MANIFEST # e.g. latest,nightly,prod
725
725
  REPO_GROUPS # e.g. base,prod,docs
726
- REPO_STAGE # 0,1,2,3
726
+ REPO_STAGE # 0,1,2,3,4
727
727
  REPO_SUBMODULLES # 0,1
728
728
  REPO_TIMEOUT # confirm dialog (seconds)
729
729
  ```
@@ -178,8 +178,9 @@ module Squared
178
178
  args = args.map(&:to_s)
179
179
  if level.is_a?(::Numeric)
180
180
  if append && respond_to?(:log)
181
- ref = log rescue nil
182
- ref.add(level, message(subject, *args, hint: hint, space: ', ')) if ref.is_a?(Logger)
181
+ (log rescue nil).tap do |ref|
182
+ ref.add(level, message(subject, *args, hint: hint, space: ', ')) if ref.is_a?(Logger)
183
+ end
183
184
  end
184
185
  return false if !pass && level < ARG[:LEVEL]
185
186
  end
@@ -217,7 +218,8 @@ module Squared
217
218
  module_function
218
219
 
219
220
  def message(*args, hint: nil, empty: false, space: ARG[:SPACE])
220
- (empty ? args.reject { |val| val.nil? || val.empty? } : args).join(space) + (hint ? " (#{hint})" : '')
221
+ (empty ? args.reject { |val| val.nil? || (val.respond_to?(:empty?) && val.empty?) } : args)
222
+ .join(space) + (hint ? " (#{hint})" : '')
221
223
  end
222
224
 
223
225
  def emphasize(val, title: nil, footer: nil, right: false, cols: nil, sub: nil, pipe: nil,
@@ -16,15 +16,15 @@ module Squared
16
16
  elsif !r[3] || r[6]
17
17
  return val
18
18
  end
19
- if r[7].match?(/\A["']/)
20
- opt = "#{r[7]}#{r[7][0]}"
21
- elsif r[7].match?(/["']\z/)
22
- opt = "#{r[7][-1]}#{r[7]}"
23
- else
24
- return val unless r[7].match?(/\s/)
25
-
26
- opt = r[7]
27
- end
19
+ opt = if r[7].match?(/\A["']/)
20
+ "#{r[7]}#{r[7][0]}"
21
+ elsif r[7].match?(/["']\z/)
22
+ "#{r[7][-1]}#{r[7]}"
23
+ else
24
+ return val unless r[7].match?(/\s/)
25
+
26
+ r[7]
27
+ end
28
28
  r[1] + (data ? data[2] : r[2]) + r[4] + shell_quote(opt, double: double, force: force, override: override)
29
29
  elsif option && val =~ /\A([^=]+)=(.+)\z/m
30
30
  return val if $2.match?(/\A(["']).+\1\z/m)
@@ -65,15 +65,15 @@ module Squared
65
65
  escape = false
66
66
  override = true
67
67
  end
68
- if flag[0] == '-'
69
- b = flag[1] == '-' ? '=' : ' '
70
- elsif flag.size == 1
71
- a = '-'
72
- b = merge ? '' : ' '
73
- else
74
- a = '--'
75
- b = '='
76
- end
68
+ b = if flag[0] == '-'
69
+ flag[1] == '-' ? '=' : ' '
70
+ elsif flag.size == 1
71
+ a = '-'
72
+ merge ? '' : ' '
73
+ else
74
+ a = '--'
75
+ '='
76
+ end
77
77
  "#{a}#{flag}#{unless val.nil?
78
78
  "#{b}#{if escape
79
79
  shell_escape(val, quote: quote, double: double, override: override)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.23'
4
+ VERSION = '0.4.24'
5
5
  end
@@ -140,7 +140,7 @@ module Squared
140
140
  return unless @pipe.is_a?(Pathname)
141
141
 
142
142
  msg = "Session started on #{Time.now} by #{@main}"
143
- bord = '#' * s.size
143
+ bord = '#' * msg.size
144
144
  puts bord, msg, bord
145
145
  end
146
146
 
@@ -410,6 +410,7 @@ module Squared
410
410
  kwargs[:group] = group unless kwargs.key?(:group)
411
411
  kwargs[:ref] = ref unless kwargs.key?(:ref)
412
412
  parent = self
413
+ proj = nil
413
414
  name = case name
414
415
  when String, Symbol
415
416
  name.to_s
@@ -418,9 +419,10 @@ module Squared
418
419
  end
419
420
  workspace.add(path, name, **kwargs) do
420
421
  __send__ :parent_set, parent
421
- @children << self
422
+ proj = self
422
423
  instance_eval(&blk) if block_given?
423
424
  end
425
+ @children << proj
424
426
  self
425
427
  end
426
428
 
@@ -482,11 +484,9 @@ module Squared
482
484
  else
483
485
  cmd, opts, var, flags, extra = args
484
486
  end
485
- if cmd.is_a?(Proc) || cmd.is_a?(Method)
486
- run_b(cmd, sync: sync, from: from)
487
- return
488
- end
489
487
  if cmd
488
+ return run_b(cmd, sync: sync, from: from) if cmd.is_a?(Proc) || cmd.is_a?(Method)
489
+
490
490
  cmd = as_get(cmd, from)
491
491
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
492
492
  flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
@@ -528,7 +528,7 @@ module Squared
528
528
  proj.__send__(meth, sync: sync)
529
529
  next
530
530
  rescue StandardError => e
531
- on_error(:prereqs, e, exception: true)
531
+ on_error(e, :prereqs, exception: true)
532
532
  end
533
533
  end
534
534
  print_error(name, 'method not found', subject: 'prereqs', hint: meth)
@@ -548,7 +548,7 @@ module Squared
548
548
  end
549
549
 
550
550
  def doc(*, sync: invoked_sync?('doc'), **)
551
- run_b(@doc, sync: sync, from: :doc, banner: from_base?('doc') ? verbosetype > 1 : verbose)
551
+ run_b(@doc, sync: sync, banner: verbosetype > (from_base?('doc') ? 1 : 0), from: :doc)
552
552
  end
553
553
 
554
554
  def lint(*, sync: invoked_sync?('lint'), **)
@@ -569,9 +569,9 @@ module Squared
569
569
  on :first, :clean unless pass
570
570
  case @clean
571
571
  when Struct
572
- if (any = instance_eval(&@clean.block) || @clean.run)
572
+ if (val = instance_eval(&@clean.block) || @clean.run)
573
573
  temp = @clean
574
- @clean = any
574
+ @clean = val
575
575
  clean(*args, sync: sync, pass: true, **kwargs)
576
576
  @clean = temp
577
577
  end
@@ -589,7 +589,7 @@ module Squared
589
589
  entry = basepath(val = val.to_s)
590
590
  if entry.directory? && val.match?(%r{[\\/]\z})
591
591
  log&.warn "rm -rf #{entry}"
592
- rm_rf(entry, verbose: verbose)
592
+ rm_rf(entry, verbose: verbosetype > 0)
593
593
  else
594
594
  log&.warn "rm #{entry}"
595
595
  (val.include?('*') ? Dir[entry] : [entry]).each do |file|
@@ -630,7 +630,7 @@ module Squared
630
630
  end
631
631
  ret = graph_branch(self, data, tasks, out, sync: sync, pass: pass)
632
632
  rescue StandardError => e
633
- on_error(:graph, e, exception: true)
633
+ on_error(e, :graph, exception: true)
634
634
  else
635
635
  if out
636
636
  [out, ret]
@@ -688,7 +688,7 @@ module Squared
688
688
  case f.content_type
689
689
  when 'application/zip'
690
690
  ext = 'zip'
691
- when 'application/x-gzip'
691
+ when %r{application/(?:x-)?gzip}
692
692
  ext = 'tgz'
693
693
  when 'application/x-xz'
694
694
  ext = 'txz'
@@ -750,9 +750,7 @@ module Squared
750
750
  break unless entry.directory?
751
751
 
752
752
  i = 0
753
- while (dest = target + "#{File.basename(file)}-#{i}").exist?
754
- i += 1
755
- end
753
+ i += 1 while (dest = target + "#{File.basename(file)}-#{i}").exist?
756
754
  FileUtils.mv(entry, dest)
757
755
  dest.children.each { |child| FileUtils.mv(child, target) }
758
756
  dest.rmdir
@@ -852,7 +850,7 @@ module Squared
852
850
  ret = shell(*args, chdir: chdir, exception: exception)
853
851
  end
854
852
  rescue StandardError => e
855
- on_error(from, e, exception: true)
853
+ on_error(e, from, exception: true)
856
854
  false
857
855
  else
858
856
  on :last, from
@@ -1641,8 +1639,8 @@ module Squared
1641
1639
  confirm "Upgrade to #{a}? #{b + e} [#{c}] ", d
1642
1640
  end
1643
1641
 
1644
- def choice_index(msg, list, values: nil, accept: nil, series: false, trim: nil, column: nil,
1645
- multiple: false, force: true, **kwargs)
1642
+ def choice_index(msg, list, values: nil, accept: nil, series: false, trim: nil, column: nil, multiple: false,
1643
+ force: true, **kwargs)
1646
1644
  puts if !series && !printfirst?
1647
1645
  msg = "#{msg} (optional)" unless force
1648
1646
  unless (ret = choice(msg, list, multiple: multiple, force: force, **kwargs)) && !ret.empty?
@@ -1658,14 +1656,11 @@ module Squared
1658
1656
  if accept
1659
1657
  hint = Array(ret).map { |val| sub_style(val, styles: theme[:inline]) }.join(', ')
1660
1658
  accept = Array(accept).map { |val| Array(val) }
1661
- if accept.any? { |val| val[1] == true }
1662
- ret = [ret]
1663
- multiple = -1
1664
- end
1659
+ ret = Array(ret) if accept.any? { |val| val[1] == true }
1665
1660
  loop do
1666
1661
  item = accept.first
1667
1662
  d, e = item[2] ? ['Y', '[Y/n]'] : ['N', '[y/N]']
1668
- c = confirm("#{item[0]}#{a ? " [#{a}]" : ''} #{e} ", d, timeout: 60)
1663
+ c = confirm("#{item[0]}#{hint ? " [#{hint}]" : ''} #{e} ", d, timeout: 60)
1669
1664
  if item[1] == true
1670
1665
  ret << c
1671
1666
  elsif !c
@@ -1678,7 +1673,7 @@ module Squared
1678
1673
  exit 1 unless accept.empty?
1679
1674
  end
1680
1675
  if values
1681
- ret = [ret] unless accept && multiple == -1
1676
+ ret = Array(ret)
1682
1677
  values.each do |val|
1683
1678
  if val.is_a?(Array)
1684
1679
  val, force = val
@@ -1712,21 +1707,17 @@ module Squared
1712
1707
  end
1713
1708
 
1714
1709
  def command(*args)
1715
- if workspace.powershell?
1716
- "powershell.exe -Command \"& {#{args.join(' ; ')}}\""
1717
- else
1718
- args.join(' && ')
1719
- end
1710
+ return args.join(' && ') unless workspace.powershell?
1711
+
1712
+ "powershell.exe -Command #{shell_quote("& {#{args.join(' ; ')}}", option: false, double: true)}"
1720
1713
  end
1721
1714
 
1722
1715
  def relativepath(*list, all: false)
1723
1716
  return [] if list.empty?
1724
1717
 
1725
1718
  list.flatten.map! { |val| Pathname.new(val) }.select { |val| projectpath?(val) }.map! do |val|
1726
- val = val.absolute? ? val.relative_path_from(path).to_s : val.to_s
1727
- val = val[2..-1] if val.start_with?('./')
1728
- val = "#{val}*" if all && val.end_with?('/')
1729
- val
1719
+ ret = (val.absolute? ? val.relative_path_from(path) : val.cleanpath).to_s
1720
+ all && val.to_s.end_with?('/') ? "#{ret}/*" : ret
1730
1721
  end
1731
1722
  end
1732
1723
 
@@ -1811,8 +1802,7 @@ module Squared
1811
1802
  end
1812
1803
 
1813
1804
  def color(val)
1814
- ret = theme[val]
1815
- ret && !ret.empty? ? ret : [val]
1805
+ (ret = theme[val]) && !ret.empty? ? ret : [val]
1816
1806
  end
1817
1807
 
1818
1808
  def colormap(val)
@@ -2041,8 +2031,8 @@ module Squared
2041
2031
  end
2042
2032
 
2043
2033
  def projectpath?(val)
2044
- val = Pathname.new(val).cleanpath
2045
- val.absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?(File.join('..', ''))
2034
+ ret = Pathname.new(val).cleanpath
2035
+ ret.absolute? ? ret.to_s.start_with?(File.join(path, '')) : !ret.to_s.start_with?(File.join('..', ''))
2046
2036
  end
2047
2037
 
2048
2038
  def checkdir?(val)
@@ -113,7 +113,7 @@ module Squared
113
113
  return unless dockerfile(file).exist?
114
114
 
115
115
  @context = context
116
- @tag = tag || tagname("#{@project}:#{@version || 'latest'}")
116
+ self.tag = tag || tagname("#{@project}:#{@version || 'latest'}")
117
117
  @mounts = mounts
118
118
  @secrets = secrets
119
119
  @registry = tagjoin registry, kwargs[:username]
@@ -206,7 +206,7 @@ module Squared
206
206
  end
207
207
  end
208
208
  else
209
- format_desc(action, flag, 'opts*,id/name', after: flag == :update ? '+' : '*')
209
+ format_desc action, flag, "opts*,id/name#{flag == :update ? '+' : '*'}"
210
210
  task flag do |_, args|
211
211
  container flag, args.to_a
212
212
  end
@@ -522,7 +522,7 @@ module Squared
522
522
  list_image(flag, docker_output('image ls -a'), from: from) do |val|
523
523
  op << val
524
524
  if flag == :tag
525
- op << tagname("#{@project}:#{op.first}")
525
+ op << tagname("#{project}:#{op.first}")
526
526
  break
527
527
  end
528
528
  end
@@ -653,7 +653,7 @@ module Squared
653
653
  ver = option('version', target: target, ignore: false)
654
654
  list = case val
655
655
  when String
656
- val.split(',')
656
+ split_escape val
657
657
  when Array
658
658
  val
659
659
  else
@@ -637,7 +637,7 @@ module Squared
637
637
  task flag, [:commit] do |_, args|
638
638
  commit = commithead args.commit
639
639
  unless commit
640
- commit, merge = choice_commit(values: ['Merge? [y|N]'])
640
+ commit, merge = choice_commit(values: ['Merge? [y/N]'])
641
641
  merge = merge&.upcase == 'Y'
642
642
  end
643
643
  checkout(flag, commit: commit, merge: merge)
@@ -721,7 +721,7 @@ module Squared
721
721
  task flag, [:name, :commit] do |_, args|
722
722
  branch = param_guard(action, flag, args: args, key: :name)
723
723
  commit = commithead args.commit
724
- commit, track = choice_commit(values: ['Track? [Y|n]'], force: false) if commit == ':'
724
+ commit, track = choice_commit(values: ['Track? [Y/n]'], force: false) if commit == ':'
725
725
  switch(flag, branch: branch, commit: commit, track: track)
726
726
  end
727
727
  when :detach
@@ -366,7 +366,7 @@ module Squared
366
366
  subdir << target.to_s
367
367
  end
368
368
  begin
369
- FileUtils.cp(basepath(s), dest, verbose: verbose.is_a?(Numeric) && verbose > 0)
369
+ FileUtils.cp(basepath(s), dest, verbose: verbosetype > 0)
370
370
  rescue StandardError => e
371
371
  print_error e
372
372
  errors += 1
@@ -410,7 +410,7 @@ module Squared
410
410
  target.each do |src, to|
411
411
  glob.each { |val| log.info "cp #{from + val} #{to}" }
412
412
  begin
413
- copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbose)
413
+ copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbosetype > 0)
414
414
  rescue StandardError => e
415
415
  on_error e, :copy
416
416
  end
@@ -482,7 +482,7 @@ module Squared
482
482
 
483
483
  def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated', flag))
484
484
  dryrun = opts.include?('dry-run') || opts.include?('d')
485
- if pnpm? && read_packagemanager(version: '7.15', update: true)
485
+ if pnpm?
486
486
  cmd = session 'pnpm', 'outdated'
487
487
  dryrun ||= dryrun?('pnpm')
488
488
  else
@@ -312,7 +312,7 @@ module Squared
312
312
  c = glob[i] || glob.first
313
313
  log.info "cp #{a + c} #{b}"
314
314
  begin
315
- copy_dir(a, b, c, pass: pass, verbose: verbose)
315
+ copy_dir(a, b, c, pass: pass, verbose: verbosetype > 0)
316
316
  rescue StandardError => e
317
317
  on_error e, :copy
318
318
  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)
@@ -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
138
  next unless proj.enabled?(proj.workspace.baseref)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.23
4
+ version: 0.4.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.7.2
128
+ rubygems_version: 3.6.9
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []