squared 0.5.9 → 0.5.10

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: fb4a8d7a97fde66c49f38e36f6f4ae0325f7bf54b7e73e6c14febb5b01814cc4
4
- data.tar.gz: 64385a46e4260b50fd1a7dbc4c69558cb9ba15324b3263a2f3d7fd4c48a23322
3
+ metadata.gz: 1614a1b7a4674c33cbc895cc8ee6e475ec2ed577f431a52df251c9b1415b128f
4
+ data.tar.gz: f24f7926cda7af396f681670f35008473d56bd35f29b7c3a982826be9b2ffaa7
5
5
  SHA512:
6
- metadata.gz: b8a6195350bf86b98c5dda0509b57304e69f7f2d04ebb2d16b4bc7a59f26bedd1d0f53adca066768101273270f10dac31f90c069ea9379f30ca437acaa73a134
7
- data.tar.gz: dad1693756f55833558187af4a8d51864ca2b6387c51955720146425c58f2416102f3d0e119269c095dd159801c8a9d850a9b5c879016ba44fbd7d1766ce5cee
6
+ metadata.gz: c8e181a06665254466e0fffc3cb1c00e33ebeaa56354689a1b40b4c7a302e5e3554ceca1b45dea389eff4fd8653eec8e756fc8fe9921447d28fd5cd62b100235
7
+ data.tar.gz: e6ed8bbcdb2a38741f0562bf5ff00ee638d359ea0af7674c5e6346dd125e692e350999e027c560641b708ec2dbcd3438f184ab4565387a5adbe942ef014a264d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.10] - 2025-10-11
4
+
5
+ ### Fixed
6
+
7
+ - See `0.4.23`.
8
+
9
+ ## [0.4.23] - 2025-10-11
10
+
11
+ ### Fixed
12
+
13
+ - Node task outdated did not compare wanted and latest by semver.
14
+ - Project base method append_hash did not have target when joined.
15
+ - Docker build for compose and bake was completely incapacitated.
16
+
3
17
  ## [0.5.9] - 2025-10-08
4
18
 
5
19
  ### Fixed
@@ -1107,6 +1121,7 @@
1107
1121
 
1108
1122
  - Changelog was created.
1109
1123
 
1124
+ [0.5.10]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.10
1110
1125
  [0.5.9]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.9
1111
1126
  [0.5.8]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.8
1112
1127
  [0.5.7]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.7
@@ -1117,6 +1132,7 @@
1117
1132
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1118
1133
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1119
1134
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1135
+ [0.4.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.23
1120
1136
  [0.4.22]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.22
1121
1137
  [0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
1122
1138
  [0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.9'
4
+ VERSION = '0.5.10'
5
5
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'json'
4
4
  require 'date'
5
- require 'time'
6
5
  require 'logger'
7
6
 
8
7
  module Squared
@@ -221,7 +220,7 @@ module Squared
221
220
  def initialize_env(dev: nil, prod: nil, **)
222
221
  @dev = env_match('BUILD', dev, suffix: 'DEV', strict: true)
223
222
  @prod = env_match('BUILD', prod, suffix: 'PROD', strict: true)
224
- unless @output[2] == false || !(val = env('BUILD', suffix: 'ENV'))
223
+ if (val = env('BUILD', suffix: 'ENV')) && @output[2] != false
225
224
  @output[2] = parse_json(val, hint: "BUILD_#{@envname}_ENV") || @output[2]
226
225
  end
227
226
  unless @output[0] == false || @output[0].is_a?(Array)
@@ -496,11 +495,11 @@ module Squared
496
495
  a, b, c, d, e = val
497
496
  case b
498
497
  when Hash
499
- b = append_hash(b, build: true).join(' ')
498
+ b = append_hash(b, target: [], build: true).join(' ')
500
499
  when Enumerable
501
500
  b = b.to_a.join(' ')
502
501
  end
503
- d = append_hash(d).join(' ') if d.is_a?(Hash)
502
+ d = append_hash(d, target: []).join(' ') if d.is_a?(Hash)
504
503
  if a
505
504
  cmd << [a, d, b].compact.join(' ')
506
505
  else
@@ -521,11 +520,13 @@ module Squared
521
520
  if cmd
522
521
  cmd = as_get(cmd, from)
523
522
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
524
- flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
523
+ flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
525
524
  case opts
526
525
  when Hash
527
- opts = append_hash(opts, build: true)
528
- cmd = Array(cmd).append(flags).concat(opts).compact.join(' ')
526
+ cmd = Array(cmd).append(flags)
527
+ .concat(append_hash(opts, target: [], build: true))
528
+ .compact
529
+ .join(' ')
529
530
  when Enumerable
530
531
  cmd = Array(cmd).concat(opts.to_a)
531
532
  cmd.map! { |val| "#{val} #{flags}" } if flags
@@ -1325,12 +1326,12 @@ module Squared
1325
1326
  end
1326
1327
 
1327
1328
  def option(*args, target: @session, prefix: target&.first, **kwargs)
1328
- if prefix
1329
- args.each do |val|
1330
- next unless (ret = env(env_key(stripext(prefix), val), **kwargs))
1329
+ return unless prefix
1331
1330
 
1332
- return block_given? ? yield(ret) : ret
1333
- end
1331
+ args.each do |val|
1332
+ next unless (ret = env(env_key(stripext(prefix), val), **kwargs))
1333
+
1334
+ return block_given? ? yield(ret) : ret
1334
1335
  end
1335
1336
  nil
1336
1337
  end
@@ -1503,7 +1504,7 @@ module Squared
1503
1504
  opts.each { |val| target << shell_option(flag, val) }
1504
1505
  end
1505
1506
 
1506
- def append_hash(data, target: @session, build: false)
1507
+ def append_hash(data, target: @session || [], build: false)
1507
1508
  if build && (type = env('BUILD', suffix: 'TYPE') || ENV['BUILD_TYPE'])
1508
1509
  type = "__#{type}__"
1509
1510
  if (extra = data[type] || data[type.to_sym]).is_a?(Hash)
@@ -1608,7 +1609,7 @@ module Squared
1608
1609
  when String
1609
1610
  "#{base} #{data}"
1610
1611
  when Hash
1611
- "#{append_hash(base).join(' ')} #{data}"
1612
+ "#{append_hash(base, target: []).join(' ')} #{data}"
1612
1613
  when Enumerable
1613
1614
  "#{base.to_a.join(' ')} #{data}"
1614
1615
  else
@@ -1617,11 +1618,11 @@ module Squared
1617
1618
  when Hash
1618
1619
  case base
1619
1620
  when String
1620
- "#{base} #{append_hash(data).join(' ')}"
1621
+ "#{base} #{append_hash(data, target: []).join(' ')}"
1621
1622
  when Hash
1622
1623
  base.merge(data)
1623
1624
  when Enumerable
1624
- Set.new(base.to_a + append_hash(data)).to_a
1625
+ Set.new(base.to_a + append_hash(data, target: [])).to_a
1625
1626
  else
1626
1627
  data
1627
1628
  end
@@ -1630,7 +1631,7 @@ module Squared
1630
1631
  when String
1631
1632
  "#{base} #{data.to_a.join(' ')}"
1632
1633
  when Hash
1633
- "#{append_hash(base).join(' ')} #{data.to_a.join(' ')}"
1634
+ "#{append_hash(base, target: []).join(' ')} #{data.to_a.join(' ')}"
1634
1635
  when Enumerable
1635
1636
  Set.new(base.to_a + data.to_a).to_a
1636
1637
  else
@@ -264,11 +264,11 @@ module Squared
264
264
  ret = docker_session
265
265
  if from == :run
266
266
  if bake?(n = filetype)
267
- ret << 'buildx' << 'bake'
267
+ ret << 'buildx bake'
268
268
  append_file n
269
269
  from = :bake
270
270
  elsif compose?(n)
271
- ret << 'compose' << 'build'
271
+ ret << 'compose build'
272
272
  append_file n
273
273
  from = :compose
274
274
  else
@@ -281,7 +281,7 @@ module Squared
281
281
  when String
282
282
  ret << opts
283
283
  when Hash
284
- ret.merge(append_hash(opts, build: true))
284
+ ret.merge(append_hash(opts, target: [], build: true))
285
285
  when Enumerable
286
286
  ret.merge(opts.to_a)
287
287
  end
@@ -648,7 +648,7 @@ module Squared
648
648
  target << list.join(' && ') unless list.empty?
649
649
  end
650
650
 
651
- def append_file(type, target: @session)
651
+ def append_file(type, target: @session, index: 2)
652
652
  return if !@file || (ENV['COMPOSE_FILE'] && compose?(type))
653
653
 
654
654
  unless @file.is_a?(Array)
@@ -661,10 +661,10 @@ module Squared
661
661
  end
662
662
  files = Array(@file).map { |val| quote_option('file', basepath(val)) }
663
663
  if target.is_a?(Set)
664
- opts = target.to_a.insert(2, *files)
664
+ opts = target.to_a.insert(index, *files)
665
665
  target.clear.merge(opts)
666
666
  else
667
- target.insert(2, *files)
667
+ target.insert(index, *files)
668
668
  end
669
669
  end
670
670
 
@@ -607,7 +607,7 @@ module Squared
607
607
  detach = args.detach
608
608
  commit = commithead args.commit
609
609
  end
610
- param_guard(action, flag, args: { create: create }, key: :create, pat: /\Ab\z/i) if create
610
+ param_guard(action, flag, args: { create: create }, key: :create, pat: /\A[Bb]\z/) if create
611
611
  else
612
612
  branch = choice_refs 'Choose a branch to switch'
613
613
  end
@@ -824,7 +824,7 @@ module Squared
824
824
  []
825
825
  else
826
826
  commit = choice_refs 'Choose "onto" branch'
827
- target, opts = choice_commit(multiple: 2, values: ['Options'], reflog: false)
827
+ target, opts = choice_commit(reflog: false, multiple: 2, values: ['Options'])
828
828
  branch, upstream = target
829
829
  OptionPartition.strip(opts)
830
830
  end
@@ -132,13 +132,13 @@ module Squared
132
132
  task action, [:save] do |_, args|
133
133
  save = param_guard(action, 'save', args: args, key: :save)
134
134
  exact = true if save.delete_prefix!('=')
135
- case save
136
- when 'prod', 'dev', 'optional', 'peer'
137
- packages = args.extras
138
- else
139
- save = 'prod'
140
- packages = args.to_a
141
- end
135
+ packages = case save
136
+ when 'prod', 'dev', 'optional', 'peer'
137
+ args.extras
138
+ else
139
+ save = 'prod'
140
+ args.to_a
141
+ end
142
142
  param_guard(action, 'name', args: packages)
143
143
  depend(:add, packages: packages, save: save, exact: exact)
144
144
  end
@@ -532,7 +532,19 @@ module Squared
532
532
  next
533
533
  end
534
534
  current = val['current'] || file
535
- want = rev == :major && !latest[SEM_VER, 6] ? latest : val['wanted']
535
+ want = val['wanted']
536
+ unless latest[SEM_VER, 6]
537
+ case rev
538
+ when :major
539
+ want = latest
540
+ when :minor
541
+ want = latest if latest[SEM_VER, 1] == want[SEM_VER, 1]
542
+ when :patch
543
+ if (g = latest.match(SEM_VER)) && (h = want.match(SEM_VER)) && g[1] == h[1] && g[3] == h[3]
544
+ want = latest
545
+ end
546
+ end
547
+ end
536
548
  next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
537
549
 
538
550
  f = semscan file
@@ -849,7 +861,7 @@ module Squared
849
861
  when String
850
862
  target
851
863
  when Hash
852
- append_hash(target).join(' ')
864
+ append_hash(target, target: []).join(' ')
853
865
  when Enumerable
854
866
  target.to_a.join(' ')
855
867
  else
@@ -7,7 +7,7 @@ module Squared
7
7
  DEP_PYTHON = %w[poetry.lock setup.cfg pyproject.toml setup.py requirements.txt].freeze
8
8
  DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
9
9
  OPT_PYTHON = {
10
- common: %w[b B d E h i I O OO P q s S u v x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
10
+ common: %w[b B d E h i I O P q s S u v x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
11
11
  build: %w[n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel C|config-setting=q installer=b
12
12
  o|outdir=p].freeze,
13
13
  venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files without-pip
@@ -636,7 +636,7 @@ module Squared
636
636
  def python_session(*cmd, opts: nil)
637
637
  return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
638
638
 
639
- op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\Av+\z/)
639
+ op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\A(?:v+|OO)\z/)
640
640
  ret = session('python', *op.to_a, *cmd, path: venv.nil?)
641
641
  [ret, op.extras]
642
642
  end
@@ -895,7 +895,7 @@ module Squared
895
895
  op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
896
896
  status = op.append(dir, delim: true)
897
897
  .clear(pass: false)
898
- .arg?(/\A-v+\z/, 'verbose')
898
+ .arg?(/\A-v+\z/)
899
899
  run(op, env, exception: true, banner: banner)
900
900
  puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
901
901
  end
@@ -77,7 +77,7 @@ module Squared
77
77
  def select(list, bare: true, no: true, single: false, double: false)
78
78
  ret = bare ? list.grep_v(/=/) : list.grep(/=/).map! { |val| val.split('=', 2).first }
79
79
  ret.map! { |val| val.split('|', 2).last }
80
- ret = ret.grep_v(/^no-/) unless no
80
+ ret = ret.grep_v(/\Ano-/) unless no
81
81
  return ret if single == double
82
82
 
83
83
  ret.select { |val| single ? val.size == 1 : val.size > 1 }
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.9
4
+ version: 0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham