squared 0.4.35 → 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: 87083dafc757443f6f6afb994664bbb3089d4c57af8f32e06e2a9b76a21f520d
4
- data.tar.gz: 8025828b76fce4826e3572e2546977ee7d998027aed144d9b119d84ba0a6e05d
3
+ metadata.gz: 31323c0d6d0f5d2d45c7e4cc882237fb5cc687d6f7f1d3b618b86385f26d6398
4
+ data.tar.gz: ddb3271ef90874b2a716418bfc344744c58a2b433954bd8034551621de500232
5
5
  SHA512:
6
- metadata.gz: 868a4f6d3fbbd406eab3ce1d2c87850f7a59fe2161314b001e8a20b540f9c98bd71a8f4250699d463220337be7124e7d437d34178e5f6036f40087c188e4ab98
7
- data.tar.gz: 60e6625462ad8f9d6efbf4b9029629f6eceee0316647be5bf19098c9c951a7de42b6411395135b1664c76f598ac63a40656541f3e669775cfefa6f9261d356cc
6
+ metadata.gz: 281d00f10b66df75ed5e2269f566b892a768fa493e68701fd9a73de787c77e0d191e10e1165e846dbd7d93d6de8427811e6193e8970564310d56a42085dd7e5b
7
+ data.tar.gz: 6672b181a9e792ff624dc8876d0b45b954c3b304f8e78abcb6a2ac674e2188aabd347e6f4d86a91c6550c11c2ac6ba842e728562a74dfb8a0740f7214a5200f3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
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
+
3
21
  ## [0.4.35] - 2025-12-31
4
22
 
5
23
  ### Changed
@@ -1150,7 +1168,7 @@
1150
1168
  - Rake did not set original rakefile when calling itself.
1151
1169
  - Extended tasks were not associated to their supporting class method.
1152
1170
 
1153
- ## [0.1.0] - 2024-12-7
1171
+ ## [0.1.0] - 2024-12-07
1154
1172
 
1155
1173
  ### Added
1156
1174
 
@@ -1171,12 +1189,13 @@
1171
1189
  - Git pull did not display colors for diff bar chart.
1172
1190
  - Git commit did not fetch latest refs before submitting.
1173
1191
 
1174
- ## [0.0.12] - 2024-12-1
1192
+ ## [0.0.12] - 2024-12-01
1175
1193
 
1176
1194
  ### Added
1177
1195
 
1178
1196
  - Changelog was created.
1179
1197
 
1198
+ [0.4.36]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.36
1180
1199
  [0.4.35]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.35
1181
1200
  [0.4.34]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.34
1182
1201
  [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
@@ -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'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.35'
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 && as_a(pass, :to_s).any? { |s| respond_to?(s) && __send__(s) rescue nil })
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|
@@ -1113,6 +1113,8 @@ module Squared
1113
1113
  else
1114
1114
  items = check.call(data[start])
1115
1115
  end
1116
+ return done if items.empty?
1117
+
1116
1118
  if out
1117
1119
  a, b, c, d, e = ARG[:GRAPH]
1118
1120
  f = tag.call(target)
@@ -1910,7 +1912,7 @@ module Squared
1910
1912
  ret = []
1911
1913
  if data[:command]
1912
1914
  ret[0] = data[:command]
1913
- ret[1] = data[:opts] unless diso
1915
+ ret[1] = data[:opts] unless noopt
1914
1916
  ret[3] = data[:args]
1915
1917
  elsif data[:script]
1916
1918
  ret[1] = data[:script]
@@ -1919,12 +1921,12 @@ module Squared
1919
1921
  else
1920
1922
  ret[0] = false
1921
1923
  end
1922
- ret[2] = data[:env] unless dise
1924
+ ret[2] = data[:env] unless noenv
1923
1925
  ret
1924
1926
  end
1925
1927
  case cmd
1926
1928
  when Array
1927
- @output = if cmd.all? { |data| data.is_a?(Hash) }
1929
+ @output = if cmd.all?(Hash)
1928
1930
  noopt = false
1929
1931
  noenv = false
1930
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
 
@@ -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')
@@ -685,8 +692,9 @@ module Squared
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
@@ -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,7 +875,11 @@ 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
 
@@ -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]]
@@ -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.35
4
+ version: 0.4.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham