squared 0.4.21 → 0.4.22

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: 4f67ab37dd0b66feaeb78631ac257ba860df78acba313f2e5fe2ffeb01136acf
4
+ data.tar.gz: 8d0570c44cbdf41ba282b5c2fd9a0196b4c5678d595ca5774393b442b88eb854
5
5
  SHA512:
6
- metadata.gz: 40f3aca8a6df314ce47bfceb7df8c4dffd00a8c05953d4e68ee104f6f33bd15ec8dfcf4d12bc23490d545982376cad0fb4aa17797d3340e120f88ef55907fcfa
7
- data.tar.gz: 24833ff7f8fc10a50760959bf421371049256df809bcf9a2fe742a3d2faf4f8608cb560cefc8cae7c40eabfcc3dbf579de03f46c836f6057a2d74266329ce75f
6
+ metadata.gz: 01b00bf5afdd80a370ef363c0d546f76d8f2533474b25029fc37c9bb0bfb1b2104ea4aa78c38cb044cf8d2f194630496b6d1b48ad4d94e8be284b28dd5dfa03c
7
+ data.tar.gz: 3968c3a15796f1c41939b95b4e50c8a8830f7f95fb6570a193c24c0043e259c82c6ac28571bd4cdbcddd2b77d6b47f38b55a963c3e567bad6e8e949a41ba8698
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.22] - 2025-10-08
4
+
5
+ ### Added
6
+
7
+ - Node package managers support ENV platform options.
8
+
9
+ ### Changed
10
+
11
+ - User installed Ruby is detected before system installed Ruby.
12
+
13
+ ### Fixed
14
+
15
+ - Yarn classic package installs did not recognize dedupe flag.
16
+ - Node command outdated option prune called undefined method.
17
+ - OptionPartition method exist? called undefined method.
18
+ - Ruby method copy? did not perform Hash property override check.
19
+ - OptionPartition static method arg? did not detect single values.
20
+
3
21
  ## [0.4.21] - 2025-10-01
4
22
 
5
23
  ### Added
@@ -992,6 +1010,7 @@
992
1010
 
993
1011
  - Changelog was created.
994
1012
 
1013
+ [0.4.22]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.22
995
1014
  [0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
996
1015
  [0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
997
1016
  [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.22'
5
5
  end
@@ -1301,7 +1301,7 @@ module Squared
1301
1301
  puts val unless val.empty? || (val.size == 1 && val.first.nil?)
1302
1302
  end
1303
1303
 
1304
- def print_banner(*lines, styles: theme[:banner], border: borderstyle, client: false)
1304
+ def print_banner(*lines, client: false, styles: theme[:banner], border: borderstyle, **)
1305
1305
  pad = 0
1306
1306
  if styles
1307
1307
  if styles.any? { |s| s.to_s.end_with?('!') }
@@ -1325,14 +1325,14 @@ module Squared
1325
1325
  (lines << sub_style(ARG[:BORDER][1] * n, styles: border)).join("\n")
1326
1326
  end
1327
1327
 
1328
- def print_footer(*lines, sub: nil, reverse: false, right: false, **kwargs)
1328
+ def print_footer(*lines, sub: nil, reverse: false, right: false, border: borderstyle, **)
1329
1329
  n = Project.max_width(lines)
1330
1330
  lines.map! do |val|
1331
1331
  s = right ? val.rjust(n) : val.ljust(n)
1332
1332
  sub&.each { |h| s = sub_style(s, **h) }
1333
1333
  s
1334
1334
  end
1335
- ret = [sub_style(ARG[:BORDER][1] * n, styles: kwargs.key?(:border) ? kwargs[:border] : borderstyle), *lines]
1335
+ ret = [sub_style(ARG[:BORDER][1] * n, styles: border), *lines]
1336
1336
  ret.reverse! if reverse
1337
1337
  ret.join("\n")
1338
1338
  end
@@ -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, **)
@@ -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
@@ -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
@@ -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')
@@ -616,10 +619,13 @@ module Squared
616
619
  footer.call(modified, found.size)
617
620
  elsif modified > 0
618
621
  modified = -1
619
- footer.call(0, found.size)
620
622
  File.write(dependfile, doc)
623
+ if opts.include?('update') || opts.include?('u') || option('update')
624
+ update
625
+ else
626
+ footer.call(0, found.size)
627
+ end
621
628
  commit(:add, refs: ['package.json'], pass: true)
622
- install if opts.include?('prune') || opts.include?('p')
623
629
  end
624
630
  elsif !avail.empty?
625
631
  col1 = size_col.call(avail, 0) + 4
@@ -645,7 +651,7 @@ module Squared
645
651
  end
646
652
 
647
653
  def update(*)
648
- package('update', from: :update)
654
+ package(:update, from: :update)
649
655
  end
650
656
 
651
657
  def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil)
@@ -689,15 +695,16 @@ module Squared
689
695
  workspace.rev_clear(name)
690
696
  if (yarn = dependtype(:yarn)) > 0
691
697
  cmd = session 'yarn', if flag == :update
692
- flag = yarn == 1 ? 'upgrade' : 'up'
698
+ yarn == 1 ? 'upgrade' : 'up'
693
699
  else
694
- flag
700
+ yarn == 1 && flag == :dedupe ? 'install' : flag
695
701
  end
696
702
  op = OptionPartition.new(opts, if yarn == 1
697
- OPT_YARN.fetch(flag, []) + OPT_YARN[:common]
703
+ OPT_YARN.fetch(flag == :dedupe ? :install : flag, []) + OPT_YARN[:common]
698
704
  else
699
705
  OPT_BERRY[flag]
700
706
  end, cmd, project: self)
707
+ op << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
701
708
  op.clear
702
709
  append_loglevel
703
710
  else
@@ -705,13 +712,13 @@ module Squared
705
712
  cmd = session 'pnpm', flag
706
713
  list = OPT_PNPM[:install_base] + OPT_PNPM.fetch(flag, []) + OPT_PNPM[:common]
707
714
  list.concat(OPT_PNPM[:install_as] + OPT_PNPM[:filter]) unless flag == :dedupe
715
+ list.concat(OPT_PNPM[:cpu]) unless flag == :update
708
716
  no = OPT_PNPM[:"#{flag}_no"]
709
717
  else
710
718
  cmd = session 'npm', flag
711
719
  list = OPT_NPM[:install_base] + OPT_NPM.fetch(flag, []) + OPT_NPM[:common]
712
720
  list.concat(OPT_NPM[:install_as]) unless flag == :dedupe
713
721
  no = OPT_NPM[:install_no]
714
- cmd << '--save=true' if option('save')
715
722
  end
716
723
  op = OptionPartition.new(opts, list, cmd, no: no, project: self)
717
724
  op.each do |opt|
@@ -727,12 +734,13 @@ module Squared
727
734
  end
728
735
  end
729
736
  op.swap
737
+ append_platform if flag == :install
730
738
  append_nocolor
731
739
  append_loglevel
732
740
  if flag == :dedupe
733
741
  op.clear
734
742
  else
735
- op.append(escape: true)
743
+ op.append(quote: true)
736
744
  end
737
745
  op.clear(errors: true)
738
746
  end
@@ -929,6 +937,14 @@ module Squared
929
937
  respond_to?(meth) && __send__(meth) ? @pm[prog] : 0
930
938
  end
931
939
 
940
+ def dependbin
941
+ if yarn?
942
+ 'yarn'
943
+ else
944
+ pnpm? ? 'pnpm' : 'npm'
945
+ end
946
+ end
947
+
932
948
  def version
933
949
  @version ||= read_packagemanager(:version)
934
950
  end
@@ -1009,11 +1025,11 @@ module Squared
1009
1025
  end
1010
1026
  end
1011
1027
 
1012
- def dependbin
1013
- if yarn?
1014
- 'yarn'
1015
- else
1016
- pnpm? ? 'pnpm' : 'npm'
1028
+ def append_platform(target: @session)
1029
+ %w[cpu os libc].each do |name|
1030
+ next unless (val = option(name))
1031
+
1032
+ target << basic_option(name, val)
1017
1033
  end
1018
1034
  end
1019
1035
 
@@ -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
@@ -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.22
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: []