squared 0.4.21 → 0.4.23

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: 4d8a1b2cbf68268501ff6e6d0c93376a695f65d5d39f3e54d51fc3782869080a
4
- data.tar.gz: d79358deea9e25c69c7c1e43730109b9609bb52949b367f457c972166da38485
3
+ metadata.gz: 8d6cb2868bb0cf1337f5b55837f5347d280408fece9d5ced520fa0a4b4dcf66a
4
+ data.tar.gz: 473e53ee64c8f98d4005ae4a36a31f652f67513fb9892f3beb9696a6eba27df4
5
5
  SHA512:
6
- metadata.gz: 40f3aca8a6df314ce47bfceb7df8c4dffd00a8c05953d4e68ee104f6f33bd15ec8dfcf4d12bc23490d545982376cad0fb4aa17797d3340e120f88ef55907fcfa
7
- data.tar.gz: 24833ff7f8fc10a50760959bf421371049256df809bcf9a2fe742a3d2faf4f8608cb560cefc8cae7c40eabfcc3dbf579de03f46c836f6057a2d74266329ce75f
6
+ metadata.gz: e99a8c8804d50e7b051ccb3a3fc5233f8209a0a2ec9a4b8ca82fae5a5917da851b639123294f5948a1dbe1e1749157e0a150c9b7b9a4053f043fc600477d2f9a
7
+ data.tar.gz: bbc77a9801a42360e468a388c008e24f7e2c5d2d431de46174871bcc11d482b7595d9339455824d9077861d889577c55649bcfada9a5617c058ab1ba95db04ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.23] - 2025-10-11
4
+
5
+ ### Fixed
6
+
7
+ - Node task outdated did not compare wanted and latest by semver.
8
+ - Project base method append_hash did not have target when joined.
9
+ - Docker build for compose and bake was completely incapacitated.
10
+
11
+ ## [0.4.22] - 2025-10-08
12
+
13
+ ### Added
14
+
15
+ - Node package managers support ENV platform options.
16
+
17
+ ### Changed
18
+
19
+ - User installed Ruby is detected before system installed Ruby.
20
+
21
+ ### Fixed
22
+
23
+ - Yarn classic package installs did not recognize dedupe flag.
24
+ - Node command outdated option prune called undefined method.
25
+ - OptionPartition method exist? called undefined method.
26
+ - Ruby method copy? did not perform Hash property override check.
27
+ - OptionPartition static method arg? did not detect single values.
28
+
3
29
  ## [0.4.21] - 2025-10-01
4
30
 
5
31
  ### Added
@@ -992,6 +1018,8 @@
992
1018
 
993
1019
  - Changelog was created.
994
1020
 
1021
+ [0.4.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.23
1022
+ [0.4.22]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.22
995
1023
  [0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
996
1024
  [0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
997
1025
  [0.4.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.19
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.21'
4
+ VERSION = '0.4.23'
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
@@ -209,7 +208,7 @@ module Squared
209
208
  def initialize_env(dev: nil, prod: nil, **)
210
209
  @dev = env_match('BUILD', dev, suffix: 'DEV', strict: true)
211
210
  @prod = env_match('BUILD', prod, suffix: 'PROD', strict: true)
212
- unless @output[2] == false || !(val = env('BUILD', suffix: 'ENV'))
211
+ if (val = env('BUILD', suffix: 'ENV')) && @output[2] != false
213
212
  @output[2] = parse_json(val, hint: "BUILD_#{@envname}_ENV") || @output[2]
214
213
  end
215
214
  unless @output[0] == false || @output[0].is_a?(Array)
@@ -465,11 +464,11 @@ module Squared
465
464
  a, b, c, d, e = val
466
465
  case b
467
466
  when Hash
468
- b = append_hash(b, build: true).join(' ')
467
+ b = append_hash(b, target: [], build: true).join(' ')
469
468
  when Enumerable
470
469
  b = b.to_a.join(' ')
471
470
  end
472
- d = append_hash(d).join(' ') if d.is_a?(Hash)
471
+ d = append_hash(d, target: []).join(' ') if d.is_a?(Hash)
473
472
  if a
474
473
  cmd << [a, d, b].compact.join(' ')
475
474
  else
@@ -490,11 +489,13 @@ module Squared
490
489
  if cmd
491
490
  cmd = as_get(cmd, from)
492
491
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
493
- flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
492
+ flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
494
493
  case opts
495
494
  when Hash
496
- opts = append_hash(opts, build: true)
497
- cmd = Array(cmd).push(flags).concat(opts).compact.join(' ')
495
+ cmd = Array(cmd).push(flags)
496
+ .concat(append_hash(opts, target: [], build: true))
497
+ .compact
498
+ .join(' ')
498
499
  when Enumerable
499
500
  cmd = Array(cmd).concat(opts.to_a)
500
501
  cmd.map! { |val| "#{val} #{flags}" } if flags
@@ -1267,11 +1268,11 @@ module Squared
1267
1268
  end
1268
1269
 
1269
1270
  def option(*args, target: @session, prefix: target&.first, **kwargs)
1270
- if prefix
1271
- args.each do |val|
1272
- ret = env(env_key(stripext(prefix), val), **kwargs)
1273
- return ret if ret
1274
- end
1271
+ return unless prefix
1272
+
1273
+ args.each do |val|
1274
+ ret = env(env_key(stripext(prefix), val), **kwargs)
1275
+ return ret if ret
1275
1276
  end
1276
1277
  nil
1277
1278
  end
@@ -1301,7 +1302,7 @@ module Squared
1301
1302
  puts val unless val.empty? || (val.size == 1 && val.first.nil?)
1302
1303
  end
1303
1304
 
1304
- def print_banner(*lines, styles: theme[:banner], border: borderstyle, client: false)
1305
+ def print_banner(*lines, client: false, styles: theme[:banner], border: borderstyle, **)
1305
1306
  pad = 0
1306
1307
  if styles
1307
1308
  if styles.any? { |s| s.to_s.end_with?('!') }
@@ -1325,14 +1326,14 @@ module Squared
1325
1326
  (lines << sub_style(ARG[:BORDER][1] * n, styles: border)).join("\n")
1326
1327
  end
1327
1328
 
1328
- def print_footer(*lines, sub: nil, reverse: false, right: false, **kwargs)
1329
+ def print_footer(*lines, sub: nil, reverse: false, right: false, border: borderstyle, **)
1329
1330
  n = Project.max_width(lines)
1330
1331
  lines.map! do |val|
1331
1332
  s = right ? val.rjust(n) : val.ljust(n)
1332
1333
  sub&.each { |h| s = sub_style(s, **h) }
1333
1334
  s
1334
1335
  end
1335
- ret = [sub_style(ARG[:BORDER][1] * n, styles: kwargs.key?(:border) ? kwargs[:border] : borderstyle), *lines]
1336
+ ret = [sub_style(ARG[:BORDER][1] * n, styles: border), *lines]
1336
1337
  ret.reverse! if reverse
1337
1338
  ret.join("\n")
1338
1339
  end
@@ -1450,7 +1451,7 @@ module Squared
1450
1451
  opts.each { |val| target << shell_option(flag, val) }
1451
1452
  end
1452
1453
 
1453
- def append_hash(data, target: @session, build: false)
1454
+ def append_hash(data, target: @session || [], build: false)
1454
1455
  if build && (type = env('BUILD', suffix: 'TYPE') || ENV['BUILD_TYPE'])
1455
1456
  type = "__#{type}__"
1456
1457
  if (extra = data[type] || data[type.to_sym]).is_a?(Hash)
@@ -1553,7 +1554,7 @@ module Squared
1553
1554
  when String
1554
1555
  "#{base} #{data}"
1555
1556
  when Hash
1556
- "#{append_hash(base).join(' ')} #{data}"
1557
+ "#{append_hash(base, target: []).join(' ')} #{data}"
1557
1558
  when Enumerable
1558
1559
  "#{base.to_a.join(' ')} #{data}"
1559
1560
  else
@@ -1562,11 +1563,11 @@ module Squared
1562
1563
  when Hash
1563
1564
  case base
1564
1565
  when String
1565
- "#{base} #{append_hash(data).join(' ')}"
1566
+ "#{base} #{append_hash(data, target: []).join(' ')}"
1566
1567
  when Hash
1567
1568
  base.merge(data)
1568
1569
  when Enumerable
1569
- Set.new(base.to_a + append_hash(data)).to_a
1570
+ Set.new(base.to_a + append_hash(data, target: [])).to_a
1570
1571
  else
1571
1572
  data
1572
1573
  end
@@ -1575,7 +1576,7 @@ module Squared
1575
1576
  when String
1576
1577
  "#{base} #{data.to_a.join(' ')}"
1577
1578
  when Hash
1578
- "#{append_hash(base).join(' ')} #{data.to_a.join(' ')}"
1579
+ "#{append_hash(base, target: []).join(' ')} #{data.to_a.join(' ')}"
1579
1580
  when Enumerable
1580
1581
  Set.new(base.to_a + data.to_a).to_a
1581
1582
  else
@@ -251,9 +251,11 @@ module Squared
251
251
  end
252
252
 
253
253
  def clean(*, sync: invoked_sync?('clean'), **)
254
- return super unless @clean.nil?
255
-
256
- image(:rm, sync: sync)
254
+ if runnable?(@clean)
255
+ super
256
+ else
257
+ image(:rm, sync: sync)
258
+ end
257
259
  end
258
260
 
259
261
  def compose(opts, flags = nil, script: false, args: nil, from: :run, **)
@@ -262,11 +264,11 @@ module Squared
262
264
  ret = docker_session
263
265
  if from == :run
264
266
  if bake?(n = filetype)
265
- ret << 'buildx' << 'bake'
267
+ ret << 'buildx bake'
266
268
  append_file n
267
269
  from = :bake
268
270
  elsif compose?(n)
269
- ret << 'compose' << 'build'
271
+ ret << 'compose build'
270
272
  append_file n
271
273
  from = :compose
272
274
  else
@@ -279,7 +281,7 @@ module Squared
279
281
  when String
280
282
  ret << opts
281
283
  when Hash
282
- ret.merge(append_hash(opts, build: true))
284
+ ret.merge(append_hash(opts, target: [], build: true))
283
285
  when Enumerable
284
286
  ret.merge(opts.to_a)
285
287
  end
@@ -620,7 +622,7 @@ module Squared
620
622
  target << list.join(' && ') unless list.empty?
621
623
  end
622
624
 
623
- def append_file(type, target: @session)
625
+ def append_file(type, target: @session, index: 2)
624
626
  return if !@file || (ENV['COMPOSE_FILE'] && compose?(type))
625
627
 
626
628
  unless @file.is_a?(Array)
@@ -633,10 +635,10 @@ module Squared
633
635
  end
634
636
  files = Array(@file).map { |val| quote_option('file', basepath(val)) }
635
637
  if target.is_a?(Set)
636
- opts = target.to_a.insert(2, *files)
638
+ opts = target.to_a.insert(index, *files)
637
639
  target.clear.merge(opts)
638
640
  else
639
- target.insert(2, *files)
641
+ target.insert(index, *files)
640
642
  end
641
643
  end
642
644
 
@@ -161,7 +161,7 @@ module Squared
161
161
  add: %w[A|all e|edit f|force ignore-errors ignore-missing ignore-removal i|interactive no-all
162
162
  no-ignore-removal n|dry-run p|patch pathspec-file-nul renormalize sparse u|update v|verbose
163
163
  chmod=b pathspec-from-file=p].freeze,
164
- branch: %w[a|all create-reflog i|ignore-case q|quiet r|remotes v|verbose vv abbrev=i color=b column=b
164
+ branch: %w[a|all create-reflog i|ignore-case q|quiet r|remotes v|verbose abbrev=i color=b column=b
165
165
  contains=b format=q merged=b no-contains=b no-merged=b points-at=b u|set-upstream-to=b sort=q
166
166
  t|track=b].freeze,
167
167
  checkout: %w[l d|detach f|force ignore-other-worktrees ignore-skip-worktree-bits m|merge p|patch
@@ -604,7 +604,7 @@ module Squared
604
604
  detach = args.detach
605
605
  commit = commithead args.commit
606
606
  end
607
- param_guard(action, flag, args: { create: create }, key: :create, pat: /\Ab\z/i) if create
607
+ param_guard(action, flag, args: { create: create }, key: :create, pat: /\A[Bb]\z/) if create
608
608
  else
609
609
  branch = choice_refs 'Choose a branch to switch'
610
610
  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
@@ -1756,7 +1756,7 @@ module Squared
1756
1756
  else
1757
1757
  append_commit(*op.extras)
1758
1758
  end
1759
- when :add, :clean
1759
+ when :add
1760
1760
  if flag == :add && !op.arg?('pathspec-from-file')
1761
1761
  grep, list = op.partition { |val| OptionPartition.pattern?(val) }
1762
1762
  unless grep.empty? && !list.empty?
@@ -1783,8 +1783,8 @@ module Squared
1783
1783
  refs = projectmap op.extras
1784
1784
  raise_error 'no source/destination' unless refs.size > 1
1785
1785
  op.merge(refs)
1786
- when :rm
1787
- append_pathspec(op.extras, expect: true)
1786
+ when :rm, :clean
1787
+ append_pathspec(op.extras, expect: flag == :rm)
1788
1788
  end
1789
1789
  source(sync: false, stderr: true)
1790
1790
  end
@@ -2143,7 +2143,7 @@ module Squared
2143
2143
  end
2144
2144
 
2145
2145
  def matchpathspec
2146
- [/\A[^a-z\d-]+/i, %r{\A[^=\\/*]*[\\/*]}]
2146
+ [/\A[^a-z\d-]+/i, %r{\A[^=\\/*]*[\\/*]}, /\A--\z/]
2147
2147
  end
2148
2148
 
2149
2149
  def messageopt
@@ -6,33 +6,33 @@ module Squared
6
6
  class Node < Git
7
7
  OPT_NPM = {
8
8
  common: %w[dry-run=!? include-workspace-root=!? loglevel=b workspaces=!? w|workspace=v].freeze,
9
- install: %w[package-lock-only=!? prefer-dedupe=!? 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 install-strategy=b
12
- omit=b].freeze,
9
+ install: %w[package-lock-only=!? prefer-dedupe=!? cpu=b libc=b os=b].freeze,
10
+ install_base: %w[audit=! bin-links=! fund=! ignore-scripts=!? install-links=!? package-lock=!
11
+ strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
13
12
  install_no: %w[audit bin-links fund package-lock].freeze,
14
- install_as: %w[no-save save-bundle save-dev save-optional save-peer save-prod foreground-scripts=!?
13
+ install_as: %w[no-save save-bundle save-dev save-optional save-peer save-prod before=q foreground-scripts=!?
15
14
  g|global=!? S|save=!? E|save-exact=!?].freeze,
16
15
  run: %w[foreground-scripts=!? if-present=!? ignore-scripts=!? script-shell=p].freeze,
17
16
  exec: %w[c|call=q package=b].freeze,
18
- pack: %w[json=!? pack-destination=p].freeze
17
+ pack: %w[ignore-scripts=!? json=!? pack-destination=p].freeze
19
18
  }.freeze
20
19
  OPT_PNPM = {
21
20
  common: %w[aggregate-output color no-color stream use-stderr C|dir=p loglevel=b w|workspace-root].freeze,
21
+ cpu: %w[cpu=b libc=b os=b].freeze,
22
22
  filter: %w[fail-if-no-match changed-files-ignore-pattern=q filter=q filter-prod=q test-pattern=q].freeze,
23
23
  install: %w[fix-lockfile force ignore-pnpmfile ignore-workspace lockfile-only merge-git-branch-lockfiles
24
- no-hoist no-lockfile no-optional prefer-frozen-lockfile resolution-only shamefully-hoist
25
- side-effects-cache side-effects-cache-readonly s|silent strict-peer-dependencies
24
+ optimistic-repeat-install no-hoist no-lockfile no-optional prefer-frozen-lockfile resolution-only
25
+ shamefully-hoist side-effects-cache side-effects-cache-readonly s|silent strict-peer-dependencies
26
26
  use-running-store-server use-store-server child-concurrency=i hoist-pattern=q lockfile-dir=p
27
27
  modules-dir=p network-concurrency=i package-import-method=b public-hoist-pattern=q
28
28
  reporter=b].freeze,
29
29
  install_base: %w[global-dir ignore-scripts offline prefer-offline store-dir=p virtual-store-dir=p].freeze,
30
30
  install_no: %w[frozen-lockfile verify-store-integrity].freeze,
31
31
  install_as: %w[D|dev global-dir no-optional P|prod r|recursive].freeze,
32
- update: %w[global interactive latest depth=i].freeze,
32
+ update: %w[g|global i|interactive L|latest depth=i].freeze,
33
33
  dedupe: %w[check].freeze,
34
- run: %w[if-present no-bail parallel r|recursive report-summary reporter-hide-prefix resume-from sequential
35
- stream use-stderr].freeze,
34
+ run: %w[if-present no-bail parallel r|recursive report-summary reporter-hide-prefix resume-from
35
+ sequential].freeze,
36
36
  exec: %w[no-reporter-hide-prefix parallel r|recursive report-summary resume-from c|shell-mode].freeze,
37
37
  pack: %w[json pack-destination=p pack-gzip-level=i].freeze
38
38
  }.freeze
@@ -134,13 +134,13 @@ module Squared
134
134
  exact = true
135
135
  save = save[1..-1]
136
136
  end
137
- case save
138
- when 'prod', 'dev', 'optional', 'peer'
139
- packages = args.extras
140
- else
141
- save = 'prod'
142
- packages = args.to_a
143
- end
137
+ packages = case save
138
+ when 'prod', 'dev', 'optional', 'peer'
139
+ args.extras
140
+ else
141
+ save = 'prod'
142
+ args.to_a
143
+ end
144
144
  param_guard(action, 'name', args: packages)
145
145
  depend(:add, packages: packages, save: save, exact: exact)
146
146
  end
@@ -223,7 +223,7 @@ module Squared
223
223
  flags.each do |flag|
224
224
  case action
225
225
  when 'outdated'
226
- format_desc(action, flag, %w[prune interactive dry-run].freeze, arg: 'opts?')
226
+ format_desc(action, flag, %w[update interactive dry-run], arg: 'opts?')
227
227
  task flag do |_, args|
228
228
  outdated flag, args.to_a
229
229
  end
@@ -455,6 +455,7 @@ module Squared
455
455
  cmd << '--save-exact' if exact
456
456
  else
457
457
  cmd << 'install'
458
+ append_platform
458
459
  end
459
460
  if (val = option('public-hoist-pattern', ignore: false))
460
461
  split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt) }
@@ -467,6 +468,8 @@ module Squared
467
468
  cmd << "--save-#{save}"
468
469
  cmd << '--save-exact' if exact
469
470
  cmd.merge(packages.map { |pkg| shell_quote(pkg) })
471
+ else
472
+ append_platform
470
473
  end
471
474
  cmd << '--workspaces=false' if env('NODE_WORKSPACES', equals: '0')
472
475
  cmd << '--package-lock=false' if option('package-lock', equals: '0')
@@ -524,7 +527,19 @@ module Squared
524
527
  next
525
528
  end
526
529
  current = val['current'] || file
527
- want = rev == :major && !latest[SEM_VER, 6] ? latest : val['wanted']
530
+ want = val['wanted']
531
+ unless latest[SEM_VER, 6]
532
+ case rev
533
+ when :major
534
+ want = latest
535
+ when :minor
536
+ want = latest if latest[SEM_VER, 1] == want[SEM_VER, 1]
537
+ when :patch
538
+ if (g = latest.match(SEM_VER)) && (h = want.match(SEM_VER)) && g[1] == h[1] && g[3] == h[3]
539
+ want = latest
540
+ end
541
+ end
542
+ end
528
543
  next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
529
544
 
530
545
  f = semscan file
@@ -616,10 +631,13 @@ module Squared
616
631
  footer.call(modified, found.size)
617
632
  elsif modified > 0
618
633
  modified = -1
619
- footer.call(0, found.size)
620
634
  File.write(dependfile, doc)
635
+ if opts.include?('update') || opts.include?('u') || option('update')
636
+ update
637
+ else
638
+ footer.call(0, found.size)
639
+ end
621
640
  commit(:add, refs: ['package.json'], pass: true)
622
- install if opts.include?('prune') || opts.include?('p')
623
641
  end
624
642
  elsif !avail.empty?
625
643
  col1 = size_col.call(avail, 0) + 4
@@ -645,7 +663,7 @@ module Squared
645
663
  end
646
664
 
647
665
  def update(*)
648
- package('update', from: :update)
666
+ package(:update, from: :update)
649
667
  end
650
668
 
651
669
  def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil)
@@ -689,15 +707,16 @@ module Squared
689
707
  workspace.rev_clear(name)
690
708
  if (yarn = dependtype(:yarn)) > 0
691
709
  cmd = session 'yarn', if flag == :update
692
- flag = yarn == 1 ? 'upgrade' : 'up'
710
+ yarn == 1 ? 'upgrade' : 'up'
693
711
  else
694
- flag
712
+ yarn == 1 && flag == :dedupe ? 'install' : flag
695
713
  end
696
714
  op = OptionPartition.new(opts, if yarn == 1
697
- OPT_YARN.fetch(flag, []) + OPT_YARN[:common]
715
+ OPT_YARN.fetch(flag == :dedupe ? :install : flag, []) + OPT_YARN[:common]
698
716
  else
699
717
  OPT_BERRY[flag]
700
718
  end, cmd, project: self)
719
+ op << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
701
720
  op.clear
702
721
  append_loglevel
703
722
  else
@@ -705,13 +724,13 @@ module Squared
705
724
  cmd = session 'pnpm', flag
706
725
  list = OPT_PNPM[:install_base] + OPT_PNPM.fetch(flag, []) + OPT_PNPM[:common]
707
726
  list.concat(OPT_PNPM[:install_as] + OPT_PNPM[:filter]) unless flag == :dedupe
727
+ list.concat(OPT_PNPM[:cpu]) unless flag == :update
708
728
  no = OPT_PNPM[:"#{flag}_no"]
709
729
  else
710
730
  cmd = session 'npm', flag
711
731
  list = OPT_NPM[:install_base] + OPT_NPM.fetch(flag, []) + OPT_NPM[:common]
712
732
  list.concat(OPT_NPM[:install_as]) unless flag == :dedupe
713
733
  no = OPT_NPM[:install_no]
714
- cmd << '--save=true' if option('save')
715
734
  end
716
735
  op = OptionPartition.new(opts, list, cmd, no: no, project: self)
717
736
  op.each do |opt|
@@ -727,12 +746,13 @@ module Squared
727
746
  end
728
747
  end
729
748
  op.swap
749
+ append_platform if flag == :install
730
750
  append_nocolor
731
751
  append_loglevel
732
752
  if flag == :dedupe
733
753
  op.clear
734
754
  else
735
- op.append(escape: true)
755
+ op.append(quote: true)
736
756
  end
737
757
  op.clear(errors: true)
738
758
  end
@@ -837,7 +857,7 @@ module Squared
837
857
  when String
838
858
  target
839
859
  when Hash
840
- append_hash(target).join(' ')
860
+ append_hash(target, target: []).join(' ')
841
861
  when Enumerable
842
862
  target.to_a.join(' ')
843
863
  else
@@ -929,6 +949,14 @@ module Squared
929
949
  respond_to?(meth) && __send__(meth) ? @pm[prog] : 0
930
950
  end
931
951
 
952
+ def dependbin
953
+ if yarn?
954
+ 'yarn'
955
+ else
956
+ pnpm? ? 'pnpm' : 'npm'
957
+ end
958
+ end
959
+
932
960
  def version
933
961
  @version ||= read_packagemanager(:version)
934
962
  end
@@ -1009,11 +1037,11 @@ module Squared
1009
1037
  end
1010
1038
  end
1011
1039
 
1012
- def dependbin
1013
- if yarn?
1014
- 'yarn'
1015
- else
1016
- pnpm? ? 'pnpm' : 'npm'
1040
+ def append_platform(target: @session)
1041
+ %w[cpu os libc].each do |name|
1042
+ next unless (val = option(name))
1043
+
1044
+ target << basic_option(name, val)
1017
1045
  end
1018
1046
  end
1019
1047
 
@@ -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
@@ -614,7 +614,7 @@ module Squared
614
614
  def python_session(*cmd, opts: nil)
615
615
  return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
616
616
 
617
- op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\Av+\z/)
617
+ op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\A(?:v+|OO)\z/)
618
618
  ret = session('python', *op.to_a, *cmd, path: venv.nil?)
619
619
  [ret, op.extras]
620
620
  end
@@ -874,7 +874,7 @@ module Squared
874
874
  op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
875
875
  op.append(dir, delim: true)
876
876
  .clear(pass: false)
877
- status = op.arg?(/\A-v+\z/, 'verbose')
877
+ status = op.arg?(/\A-v+\z/)
878
878
  run(op, env, exception: true, banner: banner)
879
879
  puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
880
880
  end
@@ -7,8 +7,8 @@ module Squared
7
7
  GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb gems.rb Isolate].freeze
8
8
  DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
9
9
  OPT_RUBY = {
10
- ruby: %w[0=im? a c e=q E=bm F=qm i=bm? I=pm l n p r=bm s S w W=bm? x=pm? d|debug jit rjit verbose y|yydebug
11
- backtrace-limit=i crash-report=q disable=q dump=q enable=q encoding=b external-encoding=b
10
+ ruby: %w[0=im? a c C=pm e=q E=bm F=qm i=bm? I=pm l n p r=bm s S w W=bm? x=pm? d|debug jit rjit verbose
11
+ y|yydebug backtrace-limit=i crash-report=q disable=q dump=q enable=q encoding=b external-encoding=b
12
12
  internal-encoding=b parser=b].freeze,
13
13
  rake: %w[A|all B|build-all comments n|dry-run m|multitask P|prereqs q|quiet X|no-deprecation-warnings
14
14
  N|no-search G|no-system nosearch nosystem rules s|silent g|system v|verbose backtrace=b?
@@ -473,13 +473,13 @@ module Squared
473
473
  pwd_set do
474
474
  out = []
475
475
  [
476
+ "#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
476
477
  '$HOME/.rvm/bin/rvm',
478
+ "#{ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf')}/plugins/ruby/bin/install",
479
+ '/usr/bin/rbenv',
477
480
  '/usr/local/rvm/bin/rvm',
478
481
  '/usr/share/rvm/bin/rvm',
479
- "#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
480
- '/usr/bin/rbenv',
481
482
  '/usr/local/share/chruby/chruby.sh',
482
- "#{ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf')}/plugins/ruby/bin/install",
483
483
  ''
484
484
  ].each do |val|
485
485
  next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
@@ -847,7 +847,7 @@ module Squared
847
847
  end
848
848
 
849
849
  def copy?
850
- return true if super || (@copy.is_a?(Hash) && copy.fetch(:into, nil))
850
+ return true if @copy.is_a?(Hash) ? copy[:into] : super
851
851
  return gemdir? if @gemdir
852
852
 
853
853
  if version
@@ -19,7 +19,8 @@ module Squared
19
19
  include Shell
20
20
  include Prompt
21
21
 
22
- def append(target, *args, delim: false, escape: false, quote: true, strip: nil, **)
22
+ def append(target, *args, delim: false, escape: false, quote: true, strip: nil, force: true, double: false,
23
+ **)
23
24
  return if (ret = args.flatten).empty?
24
25
 
25
26
  target << '--' if delim && !target.include?('--')
@@ -27,7 +28,15 @@ module Squared
27
28
  pat, s = Array(strip)
28
29
  ret.map! { |val| val.gsub(pat, s || '') }
29
30
  end
30
- ret.map! { |val| escape ? shell_escape(val, quote: quote) : shell_quote(val) } if escape || quote
31
+ if escape || quote
32
+ ret.map! do |val|
33
+ if escape
34
+ shell_escape(val, quote: quote, double: double)
35
+ else
36
+ shell_quote(val, force: force, double: double)
37
+ end
38
+ end
39
+ end
31
40
  if target.is_a?(Set)
32
41
  target.merge(ret)
33
42
  else
@@ -68,7 +77,7 @@ module Squared
68
77
  def select(list, bare: true, no: true, single: false, double: false)
69
78
  ret = bare ? list.grep_v(/=/) : list.grep(/=/).map! { |val| val.split('=', 2).first }
70
79
  ret.map! { |val| val.split('|', 2).last }
71
- ret = ret.grep_v(/^no-/) unless no
80
+ ret = ret.grep_v(/\Ano-/) unless no
72
81
  return ret if single == double
73
82
 
74
83
  ret.select { |val| single ? val.size == 1 : val.size > 1 }
@@ -91,7 +100,10 @@ module Squared
91
100
  end
92
101
 
93
102
  def matchopts(list, value = false)
94
- a, b = list.partition { |val| val.size == 1 || val.match?(OPT_SINGLE) }
103
+ a, b = Array(list).partition { |val| val.size == 1 || val.match?(OPT_SINGLE) }
104
+ return /\A#{shortopt(*a)}}/ if b.empty?
105
+ return /\A#{longopt(*b, value)}/ if a.empty?
106
+
95
107
  /\A(?:#{shortopt(*a)}|#{longopt(*b, value)})/
96
108
  end
97
109
 
@@ -436,7 +448,7 @@ module Squared
436
448
  path.join(val).exist?.tap do |ret|
437
449
  next unless add && ret
438
450
 
439
- add_first(path: true, reverse: !first)
451
+ add_path(first ? shift : pop)
440
452
  end
441
453
  else
442
454
  each_with_index do |val, index|
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.21
4
+ version: 0.4.23
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.6.9
128
+ rubygems_version: 3.7.2
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []