squared 0.1.7 → 0.1.9

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: a84fd3fef43628c438131d98c9ac058b2511a7a7f0edab355ae534137a612d1d
4
- data.tar.gz: 46e0925a6e7d854d71602aee88d54c2efff7e7ff782d847fd85e95759bad3ffb
3
+ metadata.gz: addae758d36dc852622753e60909d36ba8ec6a69c23e24807f5f4fbf6c0df727
4
+ data.tar.gz: 5b925297744f78e61a4a7b576059e4945b9d057653b0e88e26b41512d2f1a6cc
5
5
  SHA512:
6
- metadata.gz: e90a44a3914f551b4567d2013882ce362dfdc43b44bb157cb24fb2b6171cb64c46dbbb680ba7fcc17fd32f76d0e8d82bfa5ddc411eb00de5524ab5407135d413
7
- data.tar.gz: 993f3899bf89ed18f8b89ddda7019c33484b76d2a770a72b8280fa898af6a7caecceafe862de7854236c9e52ddb7c2100cd9e388b8afb4dd3d0f4427647f15ad
6
+ metadata.gz: 72206ed4177ac84f344d40f87fca044f1673788be0f39e1f3988e29120d43351b3971925edf87b8d24a035b027cc2eb4276f8bc30c04467f77c5d18bed505c99
7
+ data.tar.gz: 106b51f41c26c4acf4cd6379ce25f3bf3ab50c6e97001d4b119c9590977eb64899cc577b439a83d2457a6fb5cbfaf296ba4edd69f30772c4b3249f336f52876f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.9] - 2025-07-05
4
+
5
+ ### Added
6
+
7
+ - Initial support for using JRuby.
8
+ - Config viewer theme color for boolean was implemented.
9
+
10
+ ### Fixed
11
+
12
+ - Workspace did not add prefix to duplicate project names.
13
+ - Project output divider was not printed when not verbose.
14
+ - Directory context was not threaded using JRuby.
15
+ - Index character was not captured on Windows.
16
+ - Common method is used for Kernel shell commands.
17
+ - Git did not highlight output for single commands.
18
+
19
+ ## [0.1.8] - 2025-05-15
20
+
21
+ ### Fixed
22
+
23
+ - Disabled batch and alias tasks were not hidden.
24
+ - Log messages were written to terminal twice when emphasized.
25
+ - Node outdated interactive for major would sometimes deactivate.
26
+ - Node outdated interactive for major was mislabeled as minor.
27
+
3
28
  ## [0.1.7] - 2025-04-27
4
29
 
5
30
  ### Fixed
@@ -118,6 +143,8 @@
118
143
 
119
144
  - Changelog was created.
120
145
 
146
+ [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
147
+ [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
121
148
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
122
149
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
123
150
  [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
@@ -49,6 +49,7 @@ module Squared
49
49
  hash: %i[green black!],
50
50
  array: %i[blue black!],
51
51
  number: %i[magenta],
52
+ boolean: %i[magenta],
52
53
  undefined: %i[red italic]
53
54
  },
54
55
  logger: {
@@ -88,13 +89,15 @@ module Squared
88
89
  return [] if obj.nil?
89
90
 
90
91
  unless obj.is_a?(::Array)
91
- obj = if obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
92
+ obj = if obj.respond_to?(:to_ary)
93
+ obj.to_ary
94
+ elsif obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
92
95
  val
93
96
  else
94
97
  [obj]
95
98
  end
96
99
  end
97
- obj = obj.flatten(flat.is_a?(::Numeric) ? flat : nil) if flat
100
+ obj = flat.is_a?(::Numeric) ? obj.flatten(flat) : obj.flatten if flat
98
101
  obj = obj.compact if compact
99
102
  meth ? obj.map(&meth) : obj
100
103
  end
@@ -171,7 +171,7 @@ module Squared
171
171
  if args.size > 1
172
172
  title = log_title(level, color: false)
173
173
  sub = { pat: /^(#{title})(.+)$/, styles: __get__(:theme)[:logger][log_sym(level)] } if color
174
- emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub)
174
+ emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
175
175
  else
176
176
  msg = [log_title(level, color: color)]
177
177
  msg << (color ? sub_style(subject, :underline) : subject) if subject
@@ -257,6 +257,8 @@ module Squared
257
257
  yield out
258
258
  elsif pipe
259
259
  case pipe
260
+ when -1
261
+ return out
260
262
  when 0
261
263
  pipe = $stdin
262
264
  when 2
@@ -1,23 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pathname'
4
- require 'fileutils'
4
+ require 'rake'
5
5
 
6
6
  module Squared
7
7
  module Common
8
8
  module System
9
9
  module_function
10
10
 
11
- def shell(*args, **kwargs)
12
- if RUBY_VERSION < '2.6'
13
- exception = kwargs.delete(:exception)
14
- ret = system(*args, **kwargs)
15
- return ret if ret || !exception
16
-
17
- raise $?.to_s
11
+ def shell(*args, name: :system, **kwargs)
12
+ if RUBY_ENGINE == 'jruby' && Rake::Win32.windows?
13
+ e = kwargs[:exception]
14
+ if (dir = kwargs[:chdir]) && ((pwd = Dir.pwd) != dir)
15
+ Dir.chdir(dir)
16
+ ret = Kernel.send(name, *args)
17
+ Dir.chdir(pwd)
18
+ else
19
+ ret = Kernel.send(name, *args)
20
+ end
21
+ elsif RUBY_VERSION < '2.6'
22
+ e = kwargs.delete(:exception)
23
+ ret = Kernel.send(name, *args, **kwargs)
18
24
  else
19
- system(*args, **kwargs)
25
+ return Kernel.send(name, *args, **kwargs)
20
26
  end
27
+ return ret if ret || !e
28
+
29
+ raise $?.to_s
21
30
  end
22
31
 
23
32
  def copy_d(src, dest, glob: ['**/*'], pass: nil, create: false, verbose: true)
@@ -30,9 +39,9 @@ module Squared
30
39
  dest.mkpath if create
31
40
  if pass
32
41
  exclude = []
33
- (pass.is_a?(::Array) ? pass : [pass]).each { |val| exclude += ::Dir.glob(src.join(val)) }
42
+ Array(pass).each { |val| exclude += ::Dir.glob(src.join(val)) }
34
43
  end
35
- (glob.is_a?(::Array) ? glob : [glob]).each do |val|
44
+ Array(glob).each do |val|
36
45
  ::Dir.glob(src.join(val)) do |path|
37
46
  next if exclude&.include?(path) || (path = ::Pathname.new(path)).directory?
38
47
 
@@ -52,7 +61,7 @@ module Squared
52
61
  def copy_f(src, dest, overwrite: true, verbose: false)
53
62
  unless overwrite
54
63
  if (path = ::Pathname.new(dest)).directory?
55
- src = (src.is_a?(::Array) ? src : [src]).reject { |val| path.join(::File.basename(val)).exist? }
64
+ src = Array(src).reject { |val| path.join(::File.basename(val)).exist? }
56
65
  elsif path.exist?
57
66
  return
58
67
  end
@@ -210,6 +210,8 @@ module Squared
210
210
  { pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
211
211
  { pat: /\A(.+ : \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
212
212
  { pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
213
+ { pat: /\A(.+ : )(true|false)(\s*)\z/m, styles: theme[:boolean],
214
+ index: 2 },
213
215
  { pat: /\A(.+ : (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
214
216
  index: 2 }
215
217
  ]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.9'
5
5
  end
@@ -259,7 +259,7 @@ module Squared
259
259
  index = 0
260
260
  while @project[name]
261
261
  index += 1
262
- name = "#{project}-#{index}"
262
+ name = task_name "#{project}-#{index}"
263
263
  end
264
264
  proj = ((if !ref.is_a?(Class)
265
265
  Application.find(ref, path: path)
@@ -343,7 +343,7 @@ module Squared
343
343
  tasks << key if obj.has?(key, baseref)
344
344
  elsif (batch = series.batch_get(key))
345
345
  obj.allref.each do |ref|
346
- next unless (data = batch[ref])
346
+ next unless obj.has?(key, ref) && (data = batch[ref])
347
347
 
348
348
  data.each do |val|
349
349
  if (items = task_resolve(obj, val)).empty?
@@ -362,7 +362,7 @@ module Squared
362
362
  return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
363
363
 
364
364
  obj.allref.each do |ref|
365
- next unless (alt = data[ref])
365
+ next unless obj.has?(key, ref) && (alt = data[ref])
366
366
 
367
367
  ret = task_resolve(obj, alt)
368
368
  break unless ret.empty?
@@ -454,6 +454,14 @@ module Squared
454
454
  Rake::Win32.windows?
455
455
  end
456
456
 
457
+ def jruby?
458
+ RUBY_ENGINE == 'jruby'
459
+ end
460
+
461
+ def jruby_win?
462
+ jruby? && windows?
463
+ end
464
+
457
465
  def rootpath(*args)
458
466
  root.join(*args)
459
467
  end
@@ -608,7 +608,7 @@ module Squared
608
608
  s = proj.name
609
609
  t = dedupe.(s)
610
610
  j = if out
611
- if i == items.size - 1 || check.(post = items[i + 1..-1]).empty?
611
+ if i == items.size - 1 || check.(post = items[(i + 1)..-1]).empty?
612
612
  true
613
613
  elsif !t.empty? && depth > 0
614
614
  post.reject { |pr| t.include?(pr) }.empty?
@@ -705,7 +705,7 @@ module Squared
705
705
  end
706
706
 
707
707
  def print_item(*val)
708
- puts if @@print_order > 0 && verbose && !stdin?
708
+ puts if @@print_order > 0
709
709
  @@print_order += 1
710
710
  puts val unless val.empty? || (val.size == 1 && val.first.nil?)
711
711
  end
@@ -905,15 +905,17 @@ module Squared
905
905
  end
906
906
 
907
907
  def indexitem(val)
908
- return unless (data = /\A\^(\d+)(:.+)?\z/.match(val))
909
-
910
- [data[1].to_i, data[2] ? data[2][1..-1] : nil]
908
+ [$1.to_i, $2 && $2[1..-1]] if val =~ /\A#{Regexp.escape(indexchar)}(\d+)(:.+)?\z/
911
909
  end
912
910
 
913
911
  def indexerror(val, list = nil)
914
912
  raise_error("requested index #{val}", hint: list && "of #{list.size}")
915
913
  end
916
914
 
915
+ def indexchar
916
+ workspace.windows? ? '+' : '^'
917
+ end
918
+
917
919
  def color(val)
918
920
  ret = theme[val]
919
921
  ret && !ret.empty? ? ret : [val]
@@ -922,7 +924,8 @@ module Squared
922
924
  def pwd_set(done = nil, pass: false, &blk)
923
925
  pwd = Pathname.pwd
924
926
  if block_given?
925
- if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
927
+ pass = semscan(pass).join <= RUBY_VERSION if pass.is_a?(String)
928
+ if (path == pwd || pass == true) && !workspace.jruby_win?
926
929
  ret = instance_eval(&blk)
927
930
  else
928
931
  Dir.chdir(path)
@@ -112,9 +112,9 @@ module Squared
112
112
  end
113
113
  when :merged
114
114
  desc format_desc(action, flag, 'commit,pattern*')
115
- task flag, [:commit, :pattern] do |_, args|
115
+ task flag, [:commit] do |_, args|
116
116
  commit = guard_params(action, flag, args: args, key: :commit)
117
- tag(flag, args.to_a.drop(1), commit: commit)
117
+ tag(flag, args.extras, commit: commit)
118
118
  end
119
119
  when :delete
120
120
  desc format_desc(action, flag, 'name+')
@@ -168,7 +168,7 @@ module Squared
168
168
  desc format_desc(action, flag, 'name,pathspec*')
169
169
  task flag, [:name] do |_, args|
170
170
  branch = guard_params(action, flag, args: args, key: :name)
171
- diff(flag, args.to_a.drop(1), branch: branch)
171
+ diff(flag, args.extras, branch: branch)
172
172
  end
173
173
  when :files
174
174
  desc format_desc(action, flag, 'path1,path2')
@@ -217,8 +217,8 @@ module Squared
217
217
  when :reset
218
218
  if flag == :head
219
219
  desc format_desc(action, flag, 'ref,pathspec+')
220
- task flag, [:ref, :pathspec] do |_, args|
221
- files = guard_params(action, flag, args: args.to_a.drop(1))
220
+ task flag, [:ref] do |_, args|
221
+ files = guard_params(action, flag, args: args.extras)
222
222
  reset(flag, files, ref: args.ref)
223
223
  end
224
224
  else
@@ -235,8 +235,8 @@ module Squared
235
235
  end
236
236
  else
237
237
  desc format_desc(action, flag, 'format,object*')
238
- task flag, [:format, :object] do |_, args|
239
- show(args.to_a.drop(1), "#{flag}": args.format)
238
+ task flag, [:format] do |_, args|
239
+ show(args.extras, "#{flag}": args.format)
240
240
  end
241
241
  end
242
242
  end
@@ -262,7 +262,7 @@ module Squared
262
262
  sub = if verbose
263
263
  [
264
264
  { pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: :red, index: 4 },
265
- { pat: /^(.+)(\|\s+\d+\s+)(\++)(-*)(.*)$/, styles: :green, index: 3 }
265
+ { pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: :green, index: 3 }
266
266
  ]
267
267
  end
268
268
  source(sync: sync, sub: sub, **threadargs)
@@ -470,7 +470,9 @@ module Squared
470
470
  branch = nil
471
471
  origin = nil
472
472
  source('git fetch --no-tags --quiet', io: true, banner: false, stdout: true)
473
- source("git for-each-ref --format=\"#{format}\" refs/heads", io: true, banner: false).first.each do |line|
473
+ out = source("git for-each-ref --format=\"#{format}\" refs/heads",
474
+ io: true, banner: false, stdout: workspace.windows?).first
475
+ (workspace.windows? ? out.lines : out).each do |line|
474
476
  next if (line = line.chomp).empty?
475
477
 
476
478
  branch, origin, hint = line.split('...')
@@ -484,8 +486,8 @@ module Squared
484
486
  break
485
487
  end
486
488
  i = origin.index('/')
487
- branch = "#{branch}:#{origin[i + 1..-1]}" unless origin.end_with?("/#{branch}")
488
- origin = origin[0..i - 1]
489
+ branch = "#{branch}:#{origin[(i + 1)..-1]}" unless origin.end_with?("/#{branch}")
490
+ origin = origin[0..(i - 1)]
489
491
  cmd = git_session 'commit'
490
492
  cmd << '--dry-run' if option('dry-run')
491
493
  cmd << '--amend' if amend
@@ -541,9 +543,9 @@ module Squared
541
543
  banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner)
542
544
  cmd = cmd.sub(/\Agit\b/, "git --work-tree=#{shell_quote(path)} --git-dir=#{shell_quote(gitpath)}")
543
545
  begin
544
- if io
545
- [stdout ? `#{cmd}` : IO.popen(cmd), banner]
546
- elsif stdin? ? sync : stdout
546
+ return [stdout ? `#{cmd}` : IO.popen(cmd), banner] if io
547
+
548
+ if stdin? ? sync : stdout
547
549
  print_item banner
548
550
  ret = `#{cmd}`
549
551
  if !ret.empty?
@@ -551,7 +553,7 @@ module Squared
551
553
  elsif banner && stdout && !stdin?
552
554
  puts 'Success'
553
555
  end
554
- elsif sync || (!exception && !stderr)
556
+ elsif !sub && (sync || (!exception && !stderr))
555
557
  print_item banner
556
558
  shell(cmd, exception: exception)
557
559
  else
@@ -603,15 +605,13 @@ module Squared
603
605
  end
604
606
 
605
607
  def list_result(size, type, action: 'found', grep: nil)
606
- return unless verbose
607
-
608
- if size > 0
608
+ if size == 0
609
+ puts empty_status("No #{type} were #{action}", 'grep', grep)
610
+ elsif verbose
609
611
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
610
612
  styles << :bold if styles.size <= 1
611
613
  puts print_footer("#{size} #{size == 1 ? type.sub(/s\z/, '') : type}",
612
614
  sub: { pat: /\A(\d+)(.+)\z/, styles: styles })
613
- else
614
- puts empty_status("No #{type} were #{action}", 'grep', grep)
615
615
  end
616
616
  end
617
617
 
@@ -68,10 +68,11 @@ module Squared
68
68
  if flags.nil?
69
69
  case action
70
70
  when :run
71
- desc format_desc(action, nil, 'command+|^index|#,pattern*')
71
+ desc format_desc(action, nil, "command+|#{indexchar}index|#,pattern*")
72
72
  task action, [:command] do |_, args|
73
73
  if args.command == '#'
74
- format_list(read_scripts, 'run[^N]', 'scripts', grep: args.extras, from: dependfile.to_s)
74
+ format_list(read_scripts, "run[#{indexchar}N]", 'scripts', grep: args.extras,
75
+ from: dependfile.to_s)
75
76
  else
76
77
  cmd = guard_params(action, 'command', args: args.to_a)
77
78
  cmd.each do |val|
@@ -340,7 +341,7 @@ module Squared
340
341
  index = if a != c
341
342
  1
342
343
  elsif b != d
343
- 3
344
+ a == '0' ? 1 : 3
344
345
  else
345
346
  5
346
347
  end
@@ -373,7 +374,8 @@ module Squared
373
374
  col2 = size_col.(found, 1) + 4
374
375
  found.each_with_index do |item, i|
375
376
  a, b, c, d, e = item
376
- if inter && (rev != :major || e || semmajor?(item[5], item[6])) && !confirm_outdated(a, c, d, e)
377
+ f = inter && (rev != :major || e || semmajor?(item[5], item[6]))
378
+ if f && !confirm_outdated(a, c, d, e)
377
379
  cur = -1
378
380
  else
379
381
  cur = modified
@@ -532,6 +534,10 @@ module Squared
532
534
  dependfile.exist?
533
535
  end
534
536
 
537
+ def refresh?
538
+ !Node.prod?
539
+ end
540
+
535
541
  def yarn?
536
542
  (@pm[:yarn] ||= if basepath('yarn.lock', ascend: dependext).exist?
537
543
  if (rc = basepath('.yarnrc.yml', ascend: dependext)).exist?
@@ -613,7 +619,7 @@ module Squared
613
619
  def read_packagemanager(version: nil)
614
620
  if @pm[:_].nil?
615
621
  doc = JSON.parse(dependfile.read)
616
- @pm[:_] = (val = doc['packageManager']) ? val[0..(val.index('+') || 0) - 1] : false
622
+ @pm[:_] = (val = doc['packageManager']) ? val[0..((val.index('+') || 0) - 1)] : false
617
623
  @pm[:name] = doc['name']
618
624
  @pm[:scripts] = doc['scripts']
619
625
  @pm[:version] = doc['version']
@@ -624,7 +630,7 @@ module Squared
624
630
  @pm[:_] = false
625
631
  nil
626
632
  else
627
- !(ret = @pm[:_]) || (version && ret[ret.index('@') + 1..-1] < version) ? nil : ret
633
+ !(ret = @pm[:_]) || (version && ret[(ret.index('@') + 1)..-1] < version) ? nil : ret
628
634
  end
629
635
 
630
636
  def read_install
@@ -78,9 +78,9 @@ module Squared
78
78
  list += OPT_GENERAL
79
79
  desc format_desc(action, flag, list, req: req)
80
80
  if flag == :target
81
- task flag, [:dir, :opts] do |_, args|
81
+ task flag, [:dir] do |_, args|
82
82
  dir = guard_params(action, flag, args: args, key: :dir)
83
- depend(flag, dir: dir, opts: args.to_a.drop(1))
83
+ depend(flag, dir: dir, opts: args.extras)
84
84
  end
85
85
  else
86
86
  task flag do |_, args|
@@ -90,11 +90,11 @@ module Squared
90
90
  when :rake
91
91
  next unless rakefile
92
92
 
93
- desc format_desc(action, nil, 'command*|^index,args*|#,pattern*')
93
+ desc format_desc(action, nil, "command*|#{indexchar}index,args*|#,pattern*")
94
94
  task action, [:command] do |_, args|
95
95
  if args.command == '#'
96
- format_list(read_rakefile, 'rake[^N]', 'tasks', grep: args.extras, from: rakefile.to_s,
97
- each: ->(val) { val[0] + val[1].to_s })
96
+ format_list(read_rakefile, "rake[#{indexchar}N]", 'tasks', grep: args.extras, from: rakefile.to_s,
97
+ each: ->(val) { val[0] + val[1].to_s })
98
98
  elsif (data = indexitem(args.command))
99
99
  n, opts = data
100
100
  list = read_rakefile
@@ -183,7 +183,7 @@ module Squared
183
183
  parse_opts.(args)
184
184
  stage = 'init'
185
185
  puts if newline
186
- system("repo init -u #{manifest_url} -m #{args.manifest || target}.xml", chdir: root)
186
+ Common::System.shell("repo init -u #{manifest_url} -m #{args.manifest || target}.xml", chdir: root)
187
187
  repo['all'].invoke
188
188
  end
189
189
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-04-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -107,7 +106,6 @@ metadata:
107
106
  homepage_uri: https://github.com/anpham6/squared
108
107
  source_code_uri: https://github.com/anpham6/squared
109
108
  documentation_uri: https://squared.readthedocs.io
110
- post_install_message:
111
109
  rdoc_options: []
112
110
  require_paths:
113
111
  - lib
@@ -122,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
120
  - !ruby/object:Gem::Version
123
121
  version: '0'
124
122
  requirements: []
125
- rubygems_version: 3.3.27
126
- signing_key:
123
+ rubygems_version: 3.6.7
127
124
  specification_version: 4
128
125
  summary: Rake task generator for managing multi-language workspaces.
129
126
  test_files: []