squared 0.3.6 → 0.3.8

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: b59f278e65c23dac20a5c1e9b297190c54f780684979b6573b02acbf26656ac1
4
- data.tar.gz: f932dfb230ca2e002f011c14c216e85360165911bd70524d1a7462b9fec3357d
3
+ metadata.gz: fa6a0925852c1485cd33d015135c405cd857444be25e52a07a3f3b99e4fdb9c1
4
+ data.tar.gz: 1f1007675d785192b7f28800e1bb3be1e6fa42a62afb0cd4a6dd0527cbcdcc80
5
5
  SHA512:
6
- metadata.gz: 56ab1e6ee032fef15a6ccef5f1f2024336d6e97f0bd3b99e1c13e95a71825c3d732ce44a7e429cc172501764d2838c41a1ea126a10f8dde2391d8f3047998d7b
7
- data.tar.gz: 570232bd61ade909d6d1b7d68d9a367f77b66d6aacdac116896a8109195a74eb2047f58b66f4bcadf208fdb0819cedbc7ad535b4ac03456e4cdfb29581aa62a1
6
+ metadata.gz: c8cb9d7a36b8a0b5e7769c0b847670f20abb02a74cb7000caeb36a99d114c6b84aa8b3025bcbe6cd1d1e7922e0fcdd5804796f9a2f606f81fc8d9997b90ced44
7
+ data.tar.gz: bc241dfbb6b61cbd210a47b6bdf56d566b163aaf525b101fa507ef3ad721a022b1c5d1e2d4a78aded5613be994c784366ed1e49fef3b2430f8192917af62f3ab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.8] - 2025-04-12
4
+
5
+ ### Fixed
6
+
7
+ - Project class did not parse verbose string values.
8
+
9
+ ## [0.2.8] - 2025-04-12
10
+
11
+ ### Fixed
12
+
13
+ - User-defined program paths were not sanitized for ENV.
14
+ - Project clean task used incompatible rmtree flag.
15
+ - Git branch unset-upstream used undefined variable.
16
+
17
+ ## [0.3.7] - 2025-04-08
18
+
19
+ - See `0.2.7`.
20
+
21
+ ## [0.2.7] - 2025-04-08
22
+
23
+ ### Fixed
24
+
25
+ - Paths that conflict with git options can be quoted.
26
+ - Bundle command update did not append package names.
27
+ - Git result status type was truncated.
28
+ - Log messages were concatenated without separator.
29
+ - Python pip environment options used undefined session.
30
+ - Regexp "o" modifier was not used properly.
31
+ - Rake did not run individual project Rakefile.
32
+ - Ruby commands did not delimit exec arguments.
33
+
3
34
  ## [0.3.6] - 2025-03-12
4
35
 
5
36
  ### Added
@@ -314,6 +345,8 @@
314
345
 
315
346
  - Changelog was created.
316
347
 
348
+ [0.3.8]: https://github.com/anpham6/squared/releases/tag/v0.3.8-ruby
349
+ [0.3.7]: https://github.com/anpham6/squared/releases/tag/v0.3.7-ruby
317
350
  [0.3.6]: https://github.com/anpham6/squared/releases/tag/v0.3.6-ruby
318
351
  [0.3.5]: https://github.com/anpham6/squared/releases/tag/v0.3.5-ruby
319
352
  [0.3.4]: https://github.com/anpham6/squared/releases/tag/v0.3.4-ruby
@@ -321,6 +354,8 @@
321
354
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
322
355
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
323
356
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
357
+ [0.2.8]: https://github.com/anpham6/squared/releases/tag/v0.2.8-ruby
358
+ [0.2.7]: https://github.com/anpham6/squared/releases/tag/v0.2.7-ruby
324
359
  [0.2.6]: https://github.com/anpham6/squared/releases/tag/v0.2.6-ruby
325
360
  [0.2.5]: https://github.com/anpham6/squared/releases/tag/v0.2.5-ruby
326
361
  [0.2.4]: https://github.com/anpham6/squared/releases/tag/v0.2.4-ruby
@@ -114,7 +114,7 @@ module Squared
114
114
  if !val.is_a?(::Numeric)
115
115
  val = val.to_sym
116
116
  ret << val if colors.key?(val) || TEXT_STYLE.include?(val)
117
- elsif val >= 0 && val <= 256
117
+ elsif val.between?(0, 256)
118
118
  ret << val
119
119
  elsif val < 0 && (b = val.to_s.split('.')[1])
120
120
  b = b[0, 3]
@@ -174,12 +174,8 @@ module Squared
174
174
  emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub)
175
175
  else
176
176
  msg = [log_title(level, color: color)]
177
- if subject
178
- msg << (color ? sub_style(subject, :underline) : subject)
179
- else
180
- msg += args
181
- args.clear
182
- end
177
+ msg << (color ? sub_style(subject, :underline) : subject) if subject
178
+ msg << args.shift if msg.size == 1
183
179
  message(msg.join(' '), *args, hint: hint)
184
180
  end
185
181
  end
@@ -27,7 +27,8 @@ module Squared
27
27
 
28
28
  def shell_quote(val, force: true)
29
29
  val = val.to_s
30
- return val if (!force && !val.include?(' ')) || val.match?(/(?:^|\S=|[^=]\s+)(["']).+\1\z/m)
30
+ return val if !force && !val.include?(' ')
31
+ return val if option && val =~ /(?:^|\S=|[^=]\s+|#{Rake::Win32.windows? ? '[\\\/]' : '\/'})(["']).+\1\z/m
31
32
 
32
33
  Rake::Win32.windows? || ARG[:QUOTE] == '"' ? "\"#{double_quote(val)}\"" : "'#{single_quote(val)}'"
33
34
  end
@@ -79,7 +80,7 @@ module Squared
79
80
  end
80
81
 
81
82
  def split_escape(val, char: ',')
82
- val.split(/\s*(?<!\\)#{char}\s*/o)
83
+ val.split(/\s*(?<!\\)#{char}\s*/)
83
84
  end
84
85
  end
85
86
  end
@@ -88,7 +88,7 @@ module Squared
88
88
  return ret.to_i
89
89
  end
90
90
  when ::Numeric
91
- return key if key >= 0 && key <= 2
91
+ return key if key.between?(0, 2)
92
92
  end
93
93
  default
94
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.3.6'
4
+ VERSION = '0.3.8'
5
5
  end
@@ -404,7 +404,7 @@ module Squared
404
404
  end
405
405
 
406
406
  def task_localname(val)
407
- prefix && val.is_a?(String) ? val.sub(/\A#{Regexp.escape(prefix)}:/o, '') : val.to_s
407
+ prefix && val.is_a?(String) ? val.sub(/\A#{Regexp.escape(prefix)}:/, '') : val.to_s
408
408
  end
409
409
 
410
410
  def task_desc(*args, **kwargs)
@@ -80,7 +80,7 @@ module Squared
80
80
  when nil
81
81
  workspace.verbose
82
82
  when String
83
- env_pipe(verbose, workspace.verbose, strict: true, index: true)
83
+ env_bool(verbose, workspace.verbose, strict: true, index: true)
84
84
  else
85
85
  verbose
86
86
  end
@@ -447,7 +447,7 @@ module Squared
447
447
  path = basepath(val)
448
448
  if path.directory? && val =~ %r{[\\/]\z}
449
449
  log&.warn "rm -rf #{path}"
450
- path.rmtree(verbose: verbose)
450
+ FileUtils.rm_rf(path, verbose: verbose)
451
451
  else
452
452
  log&.warn "rm #{path}"
453
453
  (val.include?('*') ? Dir[path] : [path]).each do |file|
@@ -890,6 +890,7 @@ module Squared
890
890
 
891
891
  def option(*args, prefix: @session&.first, **kwargs)
892
892
  if prefix
893
+ prefix = File.basename(prefix, File.extname(prefix))
893
894
  args.each do |val|
894
895
  ret = env("#{prefix}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
895
896
  return ret if ret
@@ -898,7 +899,7 @@ module Squared
898
899
  nil
899
900
  end
900
901
 
901
- def option_sanitize(opts, list, target: @session, no: nil, first: false, pass: ['='])
902
+ def option_sanitize(opts, list, target: @session, no: nil, args: false, first: false, pass: ['='])
902
903
  ret = []
903
904
  reg = []
904
905
  bare = []
@@ -967,6 +968,7 @@ module Squared
967
968
  opt = a
968
969
  else
969
970
  ret << opt
971
+ found = true if args
970
972
  end
971
973
  found = true if first && pass.none? { |val| opt.include?(val) }
972
974
  end
@@ -975,9 +977,11 @@ module Squared
975
977
  end
976
978
 
977
979
  def option_clear(opts, target: @session, **kwargs)
980
+ return if opts.empty?
981
+
978
982
  kwargs[:subject] ||= target&.first
979
- kwargs[:hint] ||= 'not used'
980
- warn log_message(Logger::WARN, opts.join(', '), **kwargs) unless opts.empty?
983
+ kwargs[:hint] ||= 'unrecognized'
984
+ warn log_message(:warn, opts.join(', '), **kwargs)
981
985
  end
982
986
 
983
987
  def print_item(*val)
@@ -1227,7 +1231,7 @@ module Squared
1227
1231
 
1228
1232
  def param_guard(action, flag, args: nil, key: nil, pat: nil)
1229
1233
  if args && key
1230
- val = args[key]
1234
+ val = args.fetch(key, nil)
1231
1235
  return val unless val.nil? || (pat && !val.match?(pat))
1232
1236
 
1233
1237
  @session = nil
@@ -79,7 +79,7 @@ module Squared
79
79
  contains=e format=q merged=e no-contains=e no-merged=e points-at=e u|set-upstream-to=e sort=q
80
80
  t|track=b].freeze,
81
81
  checkout: %w[l d|detach f|force ignore-other-worktrees ignore-skip-worktree-bits m|merge p|patch
82
- pathspec-file-nul q quiet orphan=e ours theirs conflict=b pathspec-from-file=p
82
+ pathspec-file-nul q|quiet orphan=e ours theirs conflict=b pathspec-from-file=p
83
83
  t|track=b].freeze,
84
84
  diff: {
85
85
  base: %w[0 1|base 2|ours 3|theirs].freeze,
@@ -546,7 +546,7 @@ module Squared
546
546
  format_desc action, flag, 'remote,opts*,pattern*'
547
547
  task flag, [:remote] do |_, args|
548
548
  remote = param_guard(action, flag, args: args, key: :remote)
549
- ls_remote(flag, args.to_a.drop(1), remote: remote)
549
+ ls_remote(flag, args.extras, remote: remote)
550
550
  end
551
551
  else
552
552
  format_desc action, flag, 'opts*,pattern*'
@@ -914,10 +914,10 @@ module Squared
914
914
  unless (origin = option('repository', prefix: 'git', ignore: false))
915
915
  out = source(git_output('log -n1 --format=%h%d'), io: true, stdout: true, banner: false).first
916
916
  if out =~ /^#{data[2]} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)$/
917
- split_escape($1).each do |val|
918
- next unless val.end_with?("/#{branch}")
917
+ split_escape($1).each do |s|
918
+ next unless s.end_with?("/#{branch}")
919
919
 
920
- origin = val[0, val.size - branch.size - 1]
920
+ origin = s[0, s.size - branch.size - 1]
921
921
  break
922
922
  end
923
923
  end
@@ -975,7 +975,7 @@ module Squared
975
975
  return unless ref
976
976
 
977
977
  if ref.start_with?('^')
978
- cmd << '--unset-upstream' << shell_escape(arg[1..-1])
978
+ cmd << '--unset-upstream' << shell_escape(ref[1..-1])
979
979
  target = nil
980
980
  stdout = true
981
981
  else
@@ -1212,7 +1212,7 @@ module Squared
1212
1212
  if size > 0
1213
1213
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1214
1214
  styles << :bold if styles.size <= 1
1215
- puts print_footer("#{size} #{size == 1 ? type.sub(/e?s\z/, '') : type}",
1215
+ puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
1216
1216
  sub: { pat: /\A(\d+)(.+)\z/, styles: styles })
1217
1217
  else
1218
1218
  puts empty_status("No #{type} were #{action}", 'grep', grep.is_a?(Array) ? case grep.size
@@ -265,10 +265,12 @@ module Squared
265
265
  end
266
266
 
267
267
  def append_pip(flag, opts, target: @session, from: nil)
268
- append_nocolor(target: target)
269
- return [] unless from && !opts.empty?
270
-
268
+ if !from || opts.empty?
269
+ append_global(target: target)
270
+ return []
271
+ end
271
272
  opts, pat = option_sanitize(opts, OPT_PIP[from] + OPT_PIP[:common], target: target)
273
+ append_global(target: target)
272
274
  out = []
273
275
  edit = nil
274
276
  opts.each do |opt|
@@ -302,18 +304,18 @@ module Squared
302
304
  end
303
305
  end
304
306
 
305
- def append_global
307
+ def append_global(target: @session)
306
308
  if (val = option('cache-dir'))
307
- cmd << case val
308
- when '0', 'false'
309
- '--no-cache-dir'
310
- else
311
- quote_option('cache-dir', basepath(val))
312
- end
309
+ target << case val
310
+ when '0', 'false'
311
+ '--no-cache-dir'
312
+ else
313
+ quote_option('cache-dir', basepath(val))
314
+ end
313
315
  end
314
- cmd << shell_option('proxy', val) if (val = option('proxy'))
315
- cmd << quote_option('python', basepath(val)) if (val = option('python'))
316
- append_nocolor
316
+ target << shell_option('proxy', val) if (val = option('proxy'))
317
+ target << quote_option('python', basepath(val)) if (val = option('python'))
318
+ append_nocolor(target: target)
317
319
  end
318
320
  end
319
321
 
@@ -7,7 +7,7 @@ module Squared
7
7
  GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
8
8
  DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
9
9
  OPT_BUNDLE = {
10
- common: %w[no-color V verbose retry=i].freeze,
10
+ common: %w[no-color V|verbose retry=i].freeze,
11
11
  install: %w[frozen no-cache no-prune system path=p binstubs=p? standalone=q? target-rbconfig=p trust-policy=b
12
12
  with=q without=q].freeze,
13
13
  install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
@@ -342,7 +342,8 @@ module Squared
342
342
 
343
343
  def update(flag, opts = [])
344
344
  bundle_session 'update', "--#{flag}"
345
- append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common]
345
+ append_bundle(opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common],
346
+ append: flag != :all)
346
347
  run_rb(from: :update)
347
348
  end
348
349
 
@@ -366,8 +367,11 @@ module Squared
366
367
  when :install, :'user-install', :update
367
368
  list += OPT_GEM[:shared]
368
369
  no = OPT_GEM[:shared_no]
370
+ first = true
371
+ when :pristine
372
+ first = true
369
373
  end
370
- opts, pat = option_sanitize(opts, list, no: no, first: true)
374
+ opts, pat = option_sanitize(opts, list, no: no, first: first)
371
375
  out = []
372
376
  opts.each do |opt|
373
377
  if opt =~ pat
@@ -502,7 +506,7 @@ module Squared
502
506
  cmd = bundle_session flag
503
507
  case flag
504
508
  when 'exec', 'check'
505
- args = option_sanitize(args, OPT_BUNDLE[flag.to_sym] + OPT_BUNDLE[:common]).first
509
+ args = option_sanitize(args, OPT_BUNDLE[flag.to_sym] + OPT_BUNDLE[:common], args: flag == :exec).first
506
510
  end
507
511
  raise_error('bundle', flag, hint: 'no command given') unless !args.empty? || flag == 'check'
508
512
  cmd.merge(args)
@@ -511,7 +515,7 @@ module Squared
511
515
 
512
516
  def rake(*cmd)
513
517
  if cmd.empty?
514
- run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd)
518
+ run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd, banner: false)
515
519
  else
516
520
  cmd = cmd.flatten.map { |val| rake_output(rakeapp, val) }
517
521
  run_s(cmd, from: :rake, chdir: workspace.pwd, banner: false)
@@ -588,9 +592,13 @@ module Squared
588
592
  run(banner: !@session.include?('--quiet'), **kwargs)
589
593
  end
590
594
 
591
- def append_bundle(opts, list, target: @session)
595
+ def append_bundle(opts, list, target: @session, append: false)
592
596
  out = option_sanitize(opts, list, target: target).first
593
- option_clear(out, target: target)
597
+ if append
598
+ append_value(out, target: target, escape: true)
599
+ else
600
+ option_clear(out, target: target)
601
+ end
594
602
  end
595
603
 
596
604
  def gem_session(*cmd, **kwargs)
@@ -651,7 +659,7 @@ module Squared
651
659
  end
652
660
 
653
661
  def rakeapp
654
- quote_option 'rakefile', Rake.application.rakefile
662
+ quote_option 'f', rakefile
655
663
  end
656
664
 
657
665
  def rakepwd
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.6.2
123
+ rubygems_version: 3.6.7
124
124
  specification_version: 4
125
125
  summary: Rake task generator for managing multi-language workspaces.
126
126
  test_files: []