squared 0.4.34 → 0.4.36

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: 0d59b575971efdb7998b924fa5ca7815c4aeaeeaeecb756197fbc79b11433743
4
- data.tar.gz: 9cb428fb205f51803c0b7576b71d78165a8987925f90c04462c266bd03ca48b9
3
+ metadata.gz: 31323c0d6d0f5d2d45c7e4cc882237fb5cc687d6f7f1d3b618b86385f26d6398
4
+ data.tar.gz: ddb3271ef90874b2a716418bfc344744c58a2b433954bd8034551621de500232
5
5
  SHA512:
6
- metadata.gz: 5504784e072989e9e4a25ee08aa2f8bc5b9b73d4476aa9ad5d4633b08b2546847b9945de201f964b04a52124b2e75bc2f9341321348f429e2dc9ea0c4bae3fd8
7
- data.tar.gz: 73786a35bd4255024f235090cc8b11883b95efa8903e2034b8f5d13353fb7a7756ed8d8d335f42756232d595a00bf10cdafb099c3065906617575e3cd035bebf
6
+ metadata.gz: 281d00f10b66df75ed5e2269f566b892a768fa493e68701fd9a73de787c77e0d191e10e1165e846dbd7d93d6de8427811e6193e8970564310d56a42085dd7e5b
7
+ data.tar.gz: 6672b181a9e792ff624dc8876d0b45b954c3b304f8e78abcb6a2ac674e2188aabd347e6f4d86a91c6550c11c2ac6ba842e728562a74dfb8a0740f7214a5200f3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.36] - 2026-03-11
4
+
5
+ ### Added
6
+
7
+ - Python venv initialization installs setuptools when detected.
8
+ - Node task depend adds prod option flags when NODE_ENV=production.
9
+
10
+ ### Changed
11
+
12
+ - Application method with using hide and pass compatibility was implemented.
13
+
14
+ ### Fixed
15
+
16
+ - Docker task clean does not run in parallel without ENV override.
17
+ - OptionPartition methods with escape parameter were reordered.
18
+ - OptionPartition methods with quote parameter were revised.
19
+ - Project base run command was not covered due to lack of communication.
20
+
21
+ ## [0.4.35] - 2025-12-31
22
+
23
+ ### Changed
24
+
25
+ - Ruby task copy uses GEM_HOME as fallback for autodetect.
26
+
27
+ ### Fixed
28
+
29
+ - Git commands [rebase|clone] did not forward sync flag.
30
+ - Pip command install carelessly used an undefined method.
31
+ - Common prompt method readline with multiline did not permit empty lines.
32
+ - Application method with using pass did not ignore exceptions.
33
+
3
34
  ## [0.4.34] - 2025-12-26
4
35
 
5
36
  ### Added
@@ -1137,7 +1168,7 @@
1137
1168
  - Rake did not set original rakefile when calling itself.
1138
1169
  - Extended tasks were not associated to their supporting class method.
1139
1170
 
1140
- ## [0.1.0] - 2024-12-7
1171
+ ## [0.1.0] - 2024-12-07
1141
1172
 
1142
1173
  ### Added
1143
1174
 
@@ -1158,12 +1189,14 @@
1158
1189
  - Git pull did not display colors for diff bar chart.
1159
1190
  - Git commit did not fetch latest refs before submitting.
1160
1191
 
1161
- ## [0.0.12] - 2024-12-1
1192
+ ## [0.0.12] - 2024-12-01
1162
1193
 
1163
1194
  ### Added
1164
1195
 
1165
1196
  - Changelog was created.
1166
1197
 
1198
+ [0.4.36]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.36
1199
+ [0.4.35]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.35
1167
1200
  [0.4.34]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.34
1168
1201
  [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
1169
1202
  [0.4.32]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.32
@@ -186,7 +186,9 @@ module Squared
186
186
  end
187
187
  if hint.nil? ? args.size > 1 : !hint
188
188
  title = log_title(level, color: false)
189
- sub = [pat: /\A(#{Regexp.escape(title)})(.*)\z/m, styles: __get__(:theme)[:logger][log_sym(level)]] if color
189
+ if color
190
+ sub = [{ pat: /\A(#{Regexp.escape(title)})(.*)\z/m, styles: __get__(:theme)[:logger][log_sym(level)] }]
191
+ end
190
192
  emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
191
193
  else
192
194
  msg = [log_title(level, color: color)]
@@ -237,6 +239,8 @@ module Squared
237
239
  lines = val.to_s.lines(chomp: true)
238
240
  lines[0] = "#{val.class}: #{lines.first}" if (err = val.is_a?(::StandardError))
239
241
  end
242
+ return if lines.empty?
243
+
240
244
  n = cols || max.call(lines)
241
245
  if $stdout.tty?
242
246
  require 'io/console'
@@ -94,7 +94,11 @@ module Squared
94
94
  elsif block_given?
95
95
  Readline.readmultiline(msg, history, &blk)
96
96
  else
97
- Readline.readmultiline(msg, history) { |line| multiline.any? { |val| line.split.last.end_with?(val.to_s) } }
97
+ Readline.readmultiline(msg, history) do |line|
98
+ next if line.strip.empty?
99
+
100
+ multiline.any? { |val| line.split.last.end_with?(val.to_s) }
101
+ end
98
102
  end
99
103
  end
100
104
  case force
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.34'
4
+ VERSION = '0.4.36'
5
5
  end
@@ -178,8 +178,25 @@ module Squared
178
178
  self
179
179
  end
180
180
 
181
- def with(*val, pass: false, group: nil, **kwargs, &blk)
182
- return self if pass == true || (pass && Array(pass).map(&:to_s).any? { |s| respond_to?(s) && __send__(s) })
181
+ def with(*val, hide: nil, group: nil, **kwargs, &blk)
182
+ if hide.nil? && kwargs.key?(:pass)
183
+ pass = kwargs[:pass]
184
+ case pass
185
+ when true, false
186
+ hide = pass
187
+ kwargs.delete(:pass)
188
+ else
189
+ hide, pass = Array(pass).partition { |s| respond_to?(s) || s.to_s.end_with?('?') }
190
+ if pass.empty?
191
+ kwargs.delete(:pass)
192
+ elsif hide.empty?
193
+ hide = nil
194
+ else
195
+ kwargs[:pass] = pass
196
+ end
197
+ end
198
+ end
199
+ return self if hide == true || (hide && Array(hide).any? { |s| respond_to?(s) && __send__(s) rescue nil })
183
200
 
184
201
  @group = nil
185
202
  @ref = nil
@@ -810,7 +827,7 @@ module Squared
810
827
  ' (sync)'
811
828
  end}"
812
829
  emphasize(grp, title: title, cols: [cols, title.size].max, border: theme[:border],
813
- sub: [pat: /\A(Step \d+)(.*)\z/, styles: theme[:header]])
830
+ sub: [{ pat: /\A(Step \d+)(.*)\z/, styles: theme[:header] }])
814
831
  end
815
832
  end
816
833
  end
@@ -456,7 +456,7 @@ module Squared
456
456
  args[0] = instance_eval(&blk) || f
457
457
  return unless args.first
458
458
  end
459
- if args.all? { |val| val.is_a?(Array) }
459
+ if args.all?(Array)
460
460
  cmd = []
461
461
  var = {}
462
462
  args.each do |val|
@@ -1065,8 +1065,7 @@ module Squared
1065
1065
  begin
1066
1066
  cmd.flatten.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
1067
1067
  rescue StandardError => e
1068
- ret = on :error, from, e
1069
- raise unless ret == true
1068
+ on_error(e, from, exception: kwargs.fetch(:exception, exception))
1070
1069
  end
1071
1070
  on :last, from
1072
1071
  end
@@ -1114,6 +1113,8 @@ module Squared
1114
1113
  else
1115
1114
  items = check.call(data[start])
1116
1115
  end
1116
+ return done if items.empty?
1117
+
1117
1118
  if out
1118
1119
  a, b, c, d, e = ARG[:GRAPH]
1119
1120
  f = tag.call(target)
@@ -1911,7 +1912,7 @@ module Squared
1911
1912
  ret = []
1912
1913
  if data[:command]
1913
1914
  ret[0] = data[:command]
1914
- ret[1] = data[:opts] unless diso
1915
+ ret[1] = data[:opts] unless noopt
1915
1916
  ret[3] = data[:args]
1916
1917
  elsif data[:script]
1917
1918
  ret[1] = data[:script]
@@ -1920,12 +1921,12 @@ module Squared
1920
1921
  else
1921
1922
  ret[0] = false
1922
1923
  end
1923
- ret[2] = data[:env] unless dise
1924
+ ret[2] = data[:env] unless noenv
1924
1925
  ret
1925
1926
  end
1926
1927
  case cmd
1927
1928
  when Array
1928
- @output = if cmd.all? { |data| data.is_a?(Hash) }
1929
+ @output = if cmd.all?(Hash)
1929
1930
  noopt = false
1930
1931
  noenv = false
1931
1932
  cmd.map { |data| parse.call(data) }
@@ -254,8 +254,8 @@ module Squared
254
254
  def clean(*, sync: invoked_sync?('clean'), **)
255
255
  if runnable?(@clean)
256
256
  super
257
- else
258
- image(:rm, sync: sync)
257
+ elsif sync || option('y', prefix: 'docker')
258
+ image :rm
259
259
  end
260
260
  end
261
261
 
@@ -665,8 +665,8 @@ module Squared
665
665
  end
666
666
  end
667
667
 
668
- def list_image(flag, cmd, hint: nil, from: nil, no: true)
669
- pwd_set do
668
+ def list_image(flag, cmd, hint: nil, no: true, from: nil)
669
+ pwd_set(from: from) do
670
670
  found = false
671
671
  index = 0
672
672
  all = option('all', prefix: 'docker')
@@ -1049,7 +1049,7 @@ module Squared
1049
1049
 
1050
1050
  cmd << "--#{command}"
1051
1051
  end
1052
- source
1052
+ source(sync: sync)
1053
1053
  end
1054
1054
 
1055
1055
  def autostash(*, sync: invoked_sync?('autostash'), **)
@@ -1090,7 +1090,7 @@ module Squared
1090
1090
  append_hash opts
1091
1091
  cmd << '--quiet' unless verbose
1092
1092
  append_value(data[0], path, delim: true)
1093
- source(banner: sync && !quiet?, multiple: !sync || quiet?)
1093
+ source(sync: sync, banner: sync && !quiet?, multiple: !sync || quiet?)
1094
1094
  end
1095
1095
 
1096
1096
  def stash(flag = nil, opts = [], sync: invoked_sync?('stash', flag))
@@ -1181,7 +1181,7 @@ module Squared
1181
1181
  { pat: /^(## )(.+?)(\.{3})(.+)$/, styles: [nil, g, nil, r], index: -1 }
1182
1182
  ]
1183
1183
  else
1184
- [pat: /^(\t+)([a-z]+: +.+)$/, styles: r, index: 2]
1184
+ [{ pat: /^(\t+)([a-z]+: +.+)$/, styles: r, index: 2 }]
1185
1185
  end
1186
1186
  end
1187
1187
  out, banner, from = source(io: true)
@@ -1905,7 +1905,7 @@ module Squared
1905
1905
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1906
1906
  styles << :bold if styles.size <= 1
1907
1907
  puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
1908
- sub: [pat: /^(\d+)(.+)$/, styles: styles])
1908
+ sub: [{ pat: /^(\d+)(.+)$/, styles: styles }])
1909
1909
  end
1910
1910
  on :last, from
1911
1911
  end
@@ -5,7 +5,7 @@ module Squared
5
5
  module Project
6
6
  class Node < Git
7
7
  OPT_NPM = {
8
- common: %w[dry-run=!? include-workspace-root=!? loglevel=b workspaces=!? w|workspace=v].freeze,
8
+ common: %w[dry-run=!? force=!? loglevel=b include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
9
9
  install: %w[package-lock-only=!? prefer-dedupe=!? E|save-exact=!? before=q cpu=b libc=b os=b].freeze,
10
10
  install_base: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
11
11
  package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
@@ -427,13 +427,18 @@ module Squared
427
427
 
428
428
  if (yarn = dependtype(:yarn)) > 0
429
429
  cmd = session 'yarn'
430
- if flag == :add
430
+ if !flag && yarn > 1 && prod?
431
+ cmd << 'workspaces focus --all --production'
432
+ elsif flag == :add
431
433
  cmd << 'add'
432
434
  cmd << "--#{save}" unless save == 'prod'
433
435
  cmd << '--exact' if exact
434
436
  else
435
437
  cmd << 'install'
436
- cmd << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
438
+ if yarn == 1
439
+ cmd << '--production' if prod?
440
+ cmd << '--ignore-engines' unless option('ignore-engines', equals: '0')
441
+ end
437
442
  end
438
443
  elsif pnpm?
439
444
  cmd = session 'pnpm'
@@ -443,6 +448,7 @@ module Squared
443
448
  option('allow-build') { |val| cmd << quote_option('allow-build', val) }
444
449
  else
445
450
  cmd << 'install'
451
+ cmd << '--prod' if prod?
446
452
  append_platform
447
453
  end
448
454
  if (val = option('public-hoist-pattern'))
@@ -457,6 +463,7 @@ module Squared
457
463
  cmd << "--save-#{save}"
458
464
  cmd << '--save-exact' if exact
459
465
  else
466
+ cmd << '--include=prod' if prod?
460
467
  append_platform
461
468
  end
462
469
  cmd << '--workspaces=false' if env('NODE_WORKSPACES', equals: '0')
@@ -678,15 +685,16 @@ module Squared
678
685
  log.info cmd.to_s
679
686
  end
680
687
  if sync
681
- run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
688
+ run(sync: sync, from: from, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
682
689
  else
683
690
  require 'open3'
684
691
  on :first, from
685
692
  pwd_set(from: from, dryrun: dryrun) do
686
693
  cmd = session_done cmd
687
694
  Open3.popen2e(cmd) do |_, out|
688
- write_lines(out, banner: format_banner(cmd),
689
- sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:bright_blue), index: 2])
695
+ write_lines(out,
696
+ banner: format_banner(cmd),
697
+ sub: npmnotice + [{ pat: /^(.+)(Tarball .+)$/, styles: color(:bright_blue), index: 2 }])
690
698
  end
691
699
  end
692
700
  on :last, from
@@ -801,7 +809,7 @@ module Squared
801
809
  raise_error('version not found', hint: dependfile)
802
810
  end
803
811
  rescue StandardError => e
804
- on_error e, :bump
812
+ on_error(e, :bump, dryrun: dryrun?)
805
813
  end
806
814
  end
807
815
 
@@ -228,7 +228,7 @@ module Squared
228
228
  if args.empty?
229
229
  args = readline('Enter command', force: true).split(' ', 2)
230
230
  elsif args.size == 1 && !option('interactive', prefix: 'venv', equals: '0')
231
- args << readline('Enter arguments', force: false)
231
+ args << readline('Enter arguments', force: false) unless args.first.include?(' ')
232
232
  end
233
233
  venv_init
234
234
  run args.join(' ')
@@ -875,10 +875,22 @@ module Squared
875
875
  .clear(pass: false)
876
876
  status = op.arg?(/\A-v+\z/)
877
877
  run(op, env, exception: true, banner: banner)
878
- install(:upgrade, ['poetry']) if poetry?
878
+ if poetry?
879
+ install(:upgrade, ['poetry'])
880
+ elsif setuptools?
881
+ install(:upgrade, ['setuptools', 'wheel'])
882
+ end
879
883
  puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
880
884
  end
881
885
 
886
+ def installable?
887
+ setuptools? || !!pyprojectfile
888
+ end
889
+
890
+ def setuptools?
891
+ dependtype == 2 || dependtype == 4
892
+ end
893
+
882
894
  def poetry?
883
895
  dependtype == 1
884
896
  end
@@ -503,7 +503,7 @@ module Squared
503
503
  `rvm current`[/^\S+/, 0]
504
504
  when 'rbenv'
505
505
  name = `rbenv version-name`
506
- name =~ SEM_VER ? "ruby #{name}" : name
506
+ (name =~ SEM_VER) == 0 ? "ruby #{name}" : name
507
507
  when 'chruby.sh'
508
508
  chruby = session_output 'source', val
509
509
  `#{chruby.with('ruby --version')}`
@@ -768,7 +768,7 @@ module Squared
768
768
  else
769
769
  op.clear
770
770
  end
771
- elsif (n = op.index { |val| val.match?(/(\A|[a-z])@\d/) })
771
+ elsif (n = op.index { |val| val.match?(/(\A|[\w.-])@\d/) })
772
772
  name = op.delete_at(n)
773
773
  pre, ver = if (n = name.index('@')) == 0
774
774
  [gemname, name[1..-1]]
@@ -855,7 +855,16 @@ module Squared
855
855
  def copy?
856
856
  return true if @copy.is_a?(Hash) ? copy[:into] : super
857
857
  return gemdir? if gemdir
858
+ return false unless @autodetect
859
+
860
+ set = lambda do |val, path|
861
+ base = Pathname.new(path.strip)
862
+ return false unless base.join(gempath(val, 'specifications')).exist?
858
863
 
864
+ log.warn "using version #{val} (given #{version})" if version && version != val
865
+ self.version = val
866
+ self.gemdir = base + gempath
867
+ end
859
868
  if version
860
869
  begin
861
870
  case @autodetect
@@ -866,33 +875,20 @@ module Squared
866
875
  self.gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
867
876
  end
868
877
  when 'asdf'
869
- val = pwd_set { `asdf where ruby` }
878
+ val = pwd_set { `asdf where ruby`.chomp }
870
879
  self.gemdir = File.join(val, 'lib/ruby/gems', "#{$1}.0") if val =~ /(\d\.\d)\.[^.]+$/
871
- when 'env'
872
- ENV['GEM_HOME'] || ENV['GEM_ROOT']
873
880
  when /bundler?/
874
881
  path = pwd_set { `bundle env` }[/^\s+Gem Path\s+(.+)$/, 1]
875
882
  self.gemdir = path.split(File::PATH_SEPARATOR).find { |val| Dir.exist?(val) }
883
+ else
884
+ self.gemdir = ENV['GEM_HOME'] || ENV['GEM_ROOT']
876
885
  end
886
+ return true if gemdir?
877
887
  rescue StandardError => e
878
888
  log.debug e
879
889
  end
880
- return true if gemdir?
881
- end
882
- return false unless @autodetect
883
-
884
- set = lambda do |val, path|
885
- base = Pathname.new(path.strip)
886
- return false unless base.join(gempath(val, 'specification')).exist?
887
-
888
- log.warn "using version #{val} (given #{version})" if version && version != val
889
- self.version = val
890
- self.gemdir = base + gempath
891
- end
892
- if version
893
- opt = gempwd
894
- pwd_set(pass: !opt.nil?) do
895
- out = `#{gem_output(opt, 'list --local -d', gemname)}`
890
+ pwd_set(pass: !gempwd.nil?) do
891
+ out = `#{gem_output(gempwd, 'list --local -d', gemname)}`
896
892
  if out =~ /#{Regexp.escape(gemname)}\s+\((.+)\)$/
897
893
  split_escape($1)
898
894
  .unshift(@version)
@@ -32,10 +32,10 @@ module Squared
32
32
  ret.map! do |val|
33
33
  next val if opt?(val)
34
34
 
35
- if quote || val.is_a?(Pathname)
36
- shell_quote(val, force: force, double: double)
37
- elsif escape
35
+ if !(pa = val.is_a?(Pathname)) && escape
38
36
  shell_escape(val, quote: quote, double: double)
37
+ elsif quote || pa
38
+ shell_quote(val, force: force, double: double)
39
39
  else
40
40
  val
41
41
  end
@@ -300,10 +300,13 @@ module Squared
300
300
  self
301
301
  end
302
302
 
303
- def append_any(*args, quote: true, **kwargs)
303
+ def append_any(*args, escape: false, **kwargs)
304
+ quote = kwargs.fetch(:quote, true)
304
305
  (args.empty? ? extras : args.flatten).each do |val|
305
306
  if exist?(val)
306
307
  add_path(val, **kwargs)
308
+ elsif escape
309
+ add shell_escape(val, **kwargs)
307
310
  elsif quote
308
311
  add_quote(val, **kwargs)
309
312
  else
@@ -395,6 +398,7 @@ module Squared
395
398
  end
396
399
 
397
400
  def add_quote(*args, **kwargs)
401
+ kwargs.delete(:quote)
398
402
  args.compact!
399
403
  merge(args.map! { |val| val == '--' || OptionPartition.opt?(val) ? val : shell_quote(val, **kwargs) })
400
404
  self
@@ -411,10 +415,12 @@ module Squared
411
415
  elsif exclude.first.is_a?(Symbol)
412
416
  partition(&exclude.first)
413
417
  else
418
+ exclude.map! { |pat| Regexp.new(pat) }
414
419
  partition do |val|
415
- next false if pattern && OptionPartition.pattern?(val)
420
+ val = val.to_s
421
+ next if pattern && OptionPartition.pattern?(val)
416
422
 
417
- exclude.none? { |pat| val.match?(Regexp.new(pat)) }
423
+ exclude.none? { |pat| val.match?(pat) }
418
424
  end
419
425
  end
420
426
  unless temp.empty?
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.34
4
+ version: 0.4.36
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: 4.0.3
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []