squared 0.5.6 → 0.5.7

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: 40b39041151c559d38910aa11e68b6aa9cc28d1bb67176559193da4005cdda15
4
- data.tar.gz: cc6753a83f0390110e723cf92830cbb4c441d0e0c794d837fe5c20956cab713a
3
+ metadata.gz: a2f2ae101197ffdfdc4f744db59b842e2d1d7f333f9fd2f450ea94aa89a57dcd
4
+ data.tar.gz: b935b9e2787c79ea413e3449df1ba53e524928f0f1a48e90639147c91a945e43
5
5
  SHA512:
6
- metadata.gz: 36c3de2c6763c0d66b28a353cf36fca2de5eb5fe90de5eee457bf1802d23b18db8ac4a2e78d01799a993cf370cb96b068f2d4acda4cc049c1e70f2f5cbcfb004
7
- data.tar.gz: 0e8d0aee698b441c8c4b3eec2a79cb52cf6e22e0a4aad88567defd0d8587dc16f678fdde318048220edb33ef5aa80ff7f2b253ede61fa3a03aac71849ba8179e
6
+ metadata.gz: 982f19b327aa713258196aeaa3514edbc685840f838cc25eef01c7fef812807c9ac089b67d0145e6d6ee70ee1f57620b5254b9fe23bf6315a40a8d8dfa9a9816
7
+ data.tar.gz: 59ba49e317403c120081d842afb0e9747a63b79669bd852fa064e09da51176a3bdcbad973b7c64b771a1ccb8ac58654918d830719c8700610c5de07fb7096d07
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.7] - 2025-09-14
4
+
5
+ ### Fixed
6
+
7
+ - See `0.4.20`.
8
+
9
+ ## [0.4.20] - 2025-09-14
10
+
11
+ ### Changed
12
+
13
+ - Project banners when requested return consistent arguments.
14
+
15
+ ### Fixed
16
+
17
+ - Workspace global as command alias used undefined parameter.
18
+ - Python did not separate dependency manager and build backend.
19
+ - Gem command build did not validate gemspec was located.
20
+ - Project class Ruby used glob methods not available in Ruby 2.4.
21
+ - Shell options support using boolean as values.
22
+ - Git command merge action commit failed when using interactive menu.
23
+ - NPM command line options did not support boolean flags.
24
+
3
25
  ## [0.5.6] - 2025-08-30
4
26
 
5
27
  ### Added
@@ -42,7 +64,7 @@
42
64
 
43
65
  - Git command commit did not check for pushes with nothing staged.
44
66
  - Git command submodule did not include name of command.
45
- - Shellwords method shellsplit was missing from String class.
67
+ - Shellwords method shellsplit was missing from String class.
46
68
 
47
69
  ## [0.4.18] - 2025-08-23
48
70
 
@@ -1025,6 +1047,7 @@
1025
1047
 
1026
1048
  - Changelog was created.
1027
1049
 
1050
+ [0.5.7]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.7
1028
1051
  [0.5.6]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.6
1029
1052
  [0.5.5]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.5
1030
1053
  [0.5.4]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.4-ruby
@@ -1032,6 +1055,9 @@
1032
1055
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1033
1056
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1034
1057
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1058
+ [0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
1059
+ [0.4.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.19
1060
+ [0.4.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.18
1035
1061
  [0.4.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.17-ruby
1036
1062
  [0.4.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.16-ruby
1037
1063
  [0.4.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.15-ruby
@@ -78,7 +78,7 @@ module Squared
78
78
  a = '--'
79
79
  b = '='
80
80
  end
81
- "#{a}#{flag}#{if val
81
+ "#{a}#{flag}#{unless val.nil?
82
82
  "#{b}#{if escape
83
83
  shell_escape(val, quote: quote, double: double, override: override)
84
84
  elsif quote
@@ -98,8 +98,8 @@ module Squared
98
98
 
99
99
  def shell_bin(name, env: true)
100
100
  key = name.upcase
101
- shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
102
- option: false, force: false)
101
+ shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name, option: false, force: false,
102
+ double: true)
103
103
  end
104
104
 
105
105
  def line_width(lines)
@@ -63,10 +63,9 @@ module Squared
63
63
  files.clear
64
64
  items.each do |file|
65
65
  if file.exist?
66
- if file.symlink?
67
- next unless force
68
- else
66
+ if !file.symlink?
69
67
  files << file
68
+ elsif !force
70
69
  next
71
70
  end
72
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.6'
4
+ VERSION = '0.5.7'
5
5
  end
@@ -104,6 +104,7 @@ module Squared
104
104
  @ref = []
105
105
  @children = []
106
106
  @events = hashobj.update({ first: first, last: last, error: error })
107
+ @as = hashobj
107
108
  @envname = env_key(@name).freeze
108
109
  @desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
109
110
  @parent = nil
@@ -507,7 +508,7 @@ module Squared
507
508
  else
508
509
  next unless respond_to?(:compose)
509
510
 
510
- cmd << a if (a = compose(as_get(b), d, script: true, args: e, from: from))
511
+ cmd << a if (a = compose(as_get(b, from), d, script: true, args: e, from: from))
511
512
  end
512
513
  var.update(c) if c.is_a?(Hash)
513
514
  end
@@ -516,7 +517,7 @@ module Squared
516
517
  cmd, opts, var, flags, extra = args
517
518
  end
518
519
  if cmd
519
- cmd = as_get cmd
520
+ cmd = as_get(cmd, from)
520
521
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
521
522
  flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
522
523
  case opts
@@ -533,7 +534,7 @@ module Squared
533
534
  else
534
535
  return unless (opts || extra) && respond_to?(:compose)
535
536
 
536
- cmd = compose(as_get(opts), flags, script: true, args: extra, from: from)
537
+ cmd = compose(as_get(opts, from), flags, script: true, args: extra, from: from)
537
538
  from = :script if from == :run && script?
538
539
  end
539
540
  run(cmd, var, sync: sync, from: from, banner: banner)
@@ -847,9 +848,8 @@ module Squared
847
848
  end
848
849
 
849
850
  def as(cmd, script, to = nil)
850
- script = { "#{script}": to } if to
851
- data = (@as ||= {})[cmd.to_sym] ||= {}
852
- script.each { |key, val| data[key.to_s] = val }
851
+ data = @as[cmd.to_sym]
852
+ (to ? [[script, to]] : script).each { |key, val| data[key.to_s] = val }
853
853
  self
854
854
  end
855
855
 
@@ -2045,10 +2045,8 @@ module Squared
2045
2045
  end
2046
2046
  end
2047
2047
 
2048
- def as_get(val)
2049
- return unless val
2050
-
2051
- @global && (ret = @as && @as[from] && @as[from][val]) ? ret : val
2048
+ def as_get(val, from)
2049
+ (@global && @as[from][val]) || val
2052
2050
  end
2053
2051
 
2054
2052
  def task_build(keys)
@@ -531,7 +531,7 @@ module Squared
531
531
  list_image(flag, docker_output('image ls -a'), from: from) do |val|
532
532
  op << val
533
533
  if flag == :tag
534
- op << tagname("#{@project}:#{op.extras.first}")
534
+ op << tagname("#{@project}:#{op.first}")
535
535
  break
536
536
  end
537
537
  end
@@ -545,7 +545,7 @@ module Squared
545
545
  commit1 = commithead args.commit1
546
546
  if commit1
547
547
  commit2 = commithead param_guard(action, flag, args: args, key: :commit2)
548
- args = args.extras.to_a
548
+ args = args.extras
549
549
  range = [commit1, commit2]
550
550
  else
551
551
  range, opts, refs = choice_commit(multiple: view ? true : 2, values: %w[Options Pathspec])
@@ -752,12 +752,12 @@ module Squared
752
752
  args = args.extras
753
753
  else
754
754
  commit, mode = choice_commit(values: ['Mode [mixed|soft|hard|N]'])
755
- args = args.extras.to_a.concat(case mode&.downcase
756
- when 'h', 'hard' then ['hard']
757
- when 's', 'soft' then ['soft']
758
- when 'n', 'N' then ['mixed', 'N']
759
- else ['mixed']
760
- end)
755
+ args = args.extras.concat(case mode&.downcase
756
+ when 'h', 'hard' then ['hard']
757
+ when 's', 'soft' then ['soft']
758
+ when 'n', 'N' then ['mixed', 'N']
759
+ else ['mixed']
760
+ end)
761
761
  end
762
762
  print_success if success?(reset(flag, args, commit: commit))
763
763
  end
@@ -1028,7 +1028,7 @@ module Squared
1028
1028
  return unless upstream
1029
1029
 
1030
1030
  op = OptionPartition.new(opts, OPT_GIT[:rebase], cmd, project: self, no: OPT_GIT[:no][:rebase])
1031
- cmd << upstream
1031
+ op << upstream
1032
1032
  append_head op.shift
1033
1033
  op.clear(pass: false)
1034
1034
  when :onto
@@ -1117,7 +1117,7 @@ module Squared
1117
1117
  if op.empty?
1118
1118
  values = [['Branch name', true]]
1119
1119
  else
1120
- op << op.pop
1120
+ op << op.shift
1121
1121
  end
1122
1122
  end
1123
1123
  out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
@@ -1128,7 +1128,7 @@ module Squared
1128
1128
  op << out
1129
1129
  end
1130
1130
  elsif !op.empty?
1131
- op << op.pop
1131
+ op << op.shift
1132
1132
  elsif flag == :branch
1133
1133
  raise_error 'no branch name'
1134
1134
  end
@@ -1270,7 +1270,6 @@ module Squared
1270
1270
  end
1271
1271
  when :patch
1272
1272
  cmd << '--patch'
1273
- append_pathspec(refs, pass: false)
1274
1273
  when :undo
1275
1274
  cmd << '--hard HEAD@{1}'
1276
1275
  ref = false
@@ -1490,12 +1489,12 @@ module Squared
1490
1489
  case flag
1491
1490
  when :commit, :'no-commit'
1492
1491
  op = OptionPartition.new(opts, OPT_GIT[:merge], cmd, project: self, no: OPT_GIT[:no][:merge])
1493
- raise_error 'no branch/commit' if op.empty?
1494
1492
  op << "--#{flag}" << '--'
1495
1493
  if branch
1496
1494
  op << branch
1497
1495
  op.clear(pass: false)
1498
1496
  else
1497
+ raise_error 'no branch/commit' if op.empty?
1499
1498
  append_commit(*op.extras)
1500
1499
  end
1501
1500
  else
@@ -1812,7 +1811,10 @@ module Squared
1812
1811
  from = nil
1813
1812
  banner = nil
1814
1813
  else
1815
- banner = nil if banner && (multiple || !banner?)
1814
+ if banner
1815
+ banner = nil unless banner? && !multiple
1816
+ args = true
1817
+ end
1816
1818
  if cmd.respond_to?(:done)
1817
1819
  if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) })
1818
1820
  from = :"git:#{from}"
@@ -1825,17 +1827,14 @@ module Squared
1825
1827
  log&.info cmd
1826
1828
  banner = if banner
1827
1829
  banner = (banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), '')
1828
- format_banner(hint ? "#{banner} (#{hint})" : banner, banner: true)
1830
+ format_banner(hint ? "#{banner} (#{hint})" : banner)
1829
1831
  end
1830
1832
  on :first, from
1831
1833
  begin
1832
1834
  if io
1833
- ret = if stdout
1834
- `#{cmd}`
1835
- else
1836
- banner ? [IO.popen(cmd), banner, from] : IO.popen(cmd)
1837
- end
1838
- return ret
1835
+ return `#{cmd}` if stdout
1836
+
1837
+ return args ? [IO.popen(cmd), banner || '', from] : IO.popen(cmd)
1839
1838
  elsif stdin? ? sync : stdout
1840
1839
  print_item banner unless multiple
1841
1840
  ret = `#{cmd}`
@@ -5,15 +5,17 @@ module Squared
5
5
  module Project
6
6
  class Node < Git
7
7
  OPT_NPM = {
8
- common: %w[dry-run include-workspace-root workspaces=b? w|workspace=v].freeze,
9
- install: %w[prefer-dedupe package-lock-only cpu=b libc=b os=b].freeze,
10
- install_base: %w[ignore-scripts install-links strict-peer-deps include=b omit=b install-strategy=b].freeze,
8
+ common: %w[dry-run=!? include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
9
+ install: %w[prefer-dedupe=!? package-lock-only=!? audit=! bin-links=! cpu=b fund=! libc=b os=b
10
+ package-lock=!].freeze,
11
+ install_base: %w[ignore-scripts=!? install-links=!? strict-peer-deps=!? include=b omit=b
12
+ install-strategy=b].freeze,
11
13
  install_no: %w[audit bin-links fund package-lock].freeze,
12
- install_as: %w[foreground-scripts g|global no-save save save-bundle save-dev E|save-exact save-optional
13
- save-peer S|save-prod].freeze,
14
- run: %w[foreground-scripts if-present ignore-scripts script-shell=p].freeze,
14
+ install_as: %w[no-save save-bundle save-dev save-optional save-peer save-prod foreground-scripts=!?
15
+ g|global=!? S|save=!? E|save-exact=!?].freeze,
16
+ run: %w[foreground-scripts=!? if-present=!? ignore-scripts=!? script-shell=p].freeze,
15
17
  exec: %w[c|call=q package=b].freeze,
16
- pack: %w[json ignore-scripts pack-destination=p].freeze
18
+ pack: %w[json=!? pack-destination=p].freeze
17
19
  }.freeze
18
20
  OPT_PNPM = {
19
21
  common: %w[aggregate-output color no-color stream use-stderr C|dir=p loglevel=b w|workspace-root].freeze,
@@ -679,13 +681,13 @@ module Squared
679
681
  if sync
680
682
  run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
681
683
  else
684
+ require 'open3'
682
685
  on :first, from
683
686
  pwd_set(from: from, dryrun: dryrun) do
684
- require 'open3'
685
- banner = format_banner cmd.to_s
686
- Open3.popen2e(cmd.done) do |_, out|
687
- write_lines(out, sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2],
688
- banner: banner)
687
+ cmd = session_done cmd
688
+ Open3.popen2e(cmd) do |_, out|
689
+ write_lines(out, banner: format_banner(cmd),
690
+ sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:bright_blue), index: 2])
689
691
  end
690
692
  end
691
693
  on :last, from
@@ -1028,9 +1030,9 @@ module Squared
1028
1030
 
1029
1031
  def npmnotice
1030
1032
  [
1031
- { pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:cyan), index: 2 },
1032
- { pat: /^(npm )(error)(.*)$/, styles: color(:red), index: 2 },
1033
- { pat: /^(npm )(notice)(.*)$/, styles: color(:cyan), index: 2 },
1033
+ { pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:bright_cyan), index: 2 },
1034
+ { pat: /^(npm )(error)(.*)$/, styles: color(:bright_red), index: 2 },
1035
+ { pat: /^(npm )(notice)(.*)$/, styles: color(:bright_cyan), index: 2 },
1034
1036
  { pat: /^(npm )(.+)$/, styles: :bold }
1035
1037
  ]
1036
1038
  end
@@ -37,8 +37,8 @@ module Squared
37
37
  common: %w[I|ignore-python no-cache n|non-interactive].freeze,
38
38
  build: %w[C=bm no-clean no-isolation no-sdist no-wheel quiet verbose config-setting=q d|dest=p p|project=p
39
39
  k|skip=b].freeze,
40
- publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p identity=b
41
- p|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
40
+ publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
41
+ i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
42
42
  }.freeze
43
43
  OPT_HATCH = {
44
44
  common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
@@ -306,7 +306,7 @@ module Squared
306
306
  when 'build'
307
307
  case flag
308
308
  when :poetry
309
- next unless poetry?
309
+ next unless build_backend == 'poetry.core.masonry.api'
310
310
  when :pdm
311
311
  next unless build_backend == 'pdm.backend'
312
312
  when :hatch
@@ -909,11 +909,11 @@ module Squared
909
909
  end
910
910
 
911
911
  def setuptools?
912
- build_backend ? build_backend == 'setuptools.build_meta' : dependtype == 2 || dependtype == 4
912
+ dependtype == 2 || dependtype == 4
913
913
  end
914
914
 
915
915
  def poetry?
916
- build_backend ? build_backend == 'poetry.core.masonry.api' : dependtype == 1
916
+ dependtype == 1
917
917
  end
918
918
 
919
919
  def requirements?
@@ -733,6 +733,7 @@ module Squared
733
733
  return
734
734
  when :build
735
735
  if op.empty?
736
+ raise_error('gemspec not found', hint: project) unless gemfile
736
737
  op.add_path(gemfile)
737
738
  else
738
739
  op.add_path(op.shift)
@@ -785,9 +786,8 @@ module Squared
785
786
  else
786
787
  op.clear
787
788
  end
788
- elsif (n = op.extras.find_index { |val| val.match?(/(\A|[a-z])@\d/) })
789
- items = op.extras.to_a
790
- name = items.delete_at(n)
789
+ elsif (n = op.index { |val| val.match?(/(\A|[a-z])@\d/) })
790
+ name = op.delete_at(n)
791
791
  if (n = name.index('@')) == 0
792
792
  pre = gemname
793
793
  ver = name[1..-1]
@@ -796,8 +796,7 @@ module Squared
796
796
  ver = name[(n + 1)..-1]
797
797
  end
798
798
  op.adjoin(pre, shell_option('version', ver))
799
- .clear(items)
800
- .reset
799
+ .clear
801
800
  elsif flag != :install
802
801
  op.adjoin
803
802
  end
@@ -862,8 +861,8 @@ module Squared
862
861
  def gemspec
863
862
  return @gemspec unless @gemspec.nil?
864
863
 
865
- @gemspec = if (file = gemfile)
866
- Gem::Specification.load(file.to_s) rescue false
864
+ @gemspec = if gemfile
865
+ Gem::Specification.load(gemfile.to_s) rescue false
867
866
  else
868
867
  false
869
868
  end
@@ -84,6 +84,7 @@ module Squared
84
84
  :pop, :push, :concat, :index, :delete_at, :join, :map, :map!, :select, :select!, :reject, :size
85
85
 
86
86
  def_delegator :@extras, :delete, :remove
87
+ def_delegator :@extras, :delete_at, :remove_at
87
88
  def_delegator :@extras, :delete_if, :remove_if
88
89
 
89
90
  def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
@@ -108,6 +109,7 @@ module Squared
108
109
  i = []
109
110
  f = []
110
111
  si = []
112
+ bl = []
111
113
  list.flat_map do |val|
112
114
  x, y = val.split('|', 2)
113
115
  if y
@@ -142,6 +144,8 @@ module Squared
142
144
  si << flag
143
145
  when 'v'
144
146
  @values << Regexp.escape(flag)
147
+ when '!'
148
+ bl << flag
145
149
  else
146
150
  next
147
151
  end
@@ -181,7 +185,7 @@ module Squared
181
185
  add quote_option(key, val, double: qq.include?(key), merge: merge)
182
186
  elsif p.include?(key) && path
183
187
  add quote_option(key, path + val, merge: merge)
184
- elsif b.include?(key) || numcheck.call(key, val)
188
+ elsif b.include?(key) || (bl.include?(key) && %w[true false].include?(val)) || numcheck.call(key, val)
185
189
  add basic_option(key, val, merge: merge)
186
190
  elsif merge
187
191
  add basic_option(key, val, merge: true)
@@ -119,7 +119,6 @@ module Squared
119
119
  target = branch || manifest
120
120
  stage = nil
121
121
  opts = %w[force rebase detach submodules fail no-update gc]
122
- newline = ARGV.any?(/^repo:/)
123
122
  desc = lambda do |val, alt = nil|
124
123
  if (ver = branch || alt)
125
124
  val = val.sub('{0}', "opts*=#{opts.join(',')}")
@@ -170,7 +169,6 @@ module Squared
170
169
  val
171
170
  end
172
171
  stage = 'init'
173
- puts if newline
174
172
  opts = repo_opts "-u #{u}", "-m #{m}.xml"
175
173
  opts << "-g #{g}" if g
176
174
  opts << '--submodules' if repo_submodules?(args.include?('submodules'))
@@ -206,7 +204,6 @@ module Squared
206
204
  end
207
205
  opts << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}" unless opts.any?(/^--?j(?:obs)?/)
208
206
  opts << '--fetch-submodules' if repo_submodules?
209
- puts unless !newline || stage == 'init'
210
207
  begin
211
208
  repo_run("#{repo_bin} sync #{opts.uniq.join(' ')}", exception: opts.include?('--fail-fast'))
212
209
  rescue Errno::ENOENT => e
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.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham