squared 0.1.8 → 0.1.10

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: 2de07baaee5e8dab48b40441f8ec83a471e1b54c464fe8d06bb360eeef06c6d0
4
- data.tar.gz: 3f2fab32edfcbec1cd13a0f320ce540f174d8da54b89e70c29eff9033c3b8244
3
+ metadata.gz: 1283f1d3569c68e4f0c547dcdd6e84ebffef516cd7cfbf01914b4ff0615a61f9
4
+ data.tar.gz: 7c637c6bf63303b7b2e41406b384356a541c5321c3f9f94b1990c5003965cb56
5
5
  SHA512:
6
- metadata.gz: e9199678633fe880e68d0adc7d9a2bb61cef4b9d7298b395e4d34621669f8db4b74f38321bc644f5113783d4b722a0547228e21d53c36ea22d5f25f34778aff1
7
- data.tar.gz: 6c4905fd7a1d74e68951644633c40f78e3acc6dde48ac8ba397c853759101439ef7d43ef5a2e446cc1c99eb73ef237ebd3caf22764b9593331c44b87b764b034
6
+ metadata.gz: 0aae27adafb209e0f7b15ffd43dda5d13766acb9b7f506352481c740fee584b469574b8772fafa6fd3d55d785f28b8389bac21bfd6fbd6038856b710c1125479
7
+ data.tar.gz: 0a55a9deb920a0ea929fcbadb4fbac4513b6d784fef3d844ea1de4e0c2e7a33faf9b8d9610692c707d9b8364a91ec436de18ca35defb21ccb10efac57bab40c1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.10] - 2025-07-16
4
+
5
+ ### Fixed
6
+
7
+ - Module namespaces were not combined in the right order.
8
+ - Workspace group tasks were not registered.
9
+
10
+ ## [0.1.9] - 2025-07-05
11
+
12
+ ### Added
13
+
14
+ - Initial support for using JRuby.
15
+ - Config viewer theme color for boolean was implemented.
16
+
17
+ ### Fixed
18
+
19
+ - Workspace did not add prefix to duplicate project names.
20
+ - Project output divider was not printed when not verbose.
21
+ - Directory context was not threaded using JRuby.
22
+ - Index character was not captured on Windows.
23
+ - Common method is used for Kernel shell commands.
24
+ - Git did not highlight output for single commands.
25
+
3
26
  ## [0.1.8] - 2025-05-15
4
27
 
5
28
  ### Fixed
@@ -127,6 +150,8 @@
127
150
 
128
151
  - Changelog was created.
129
152
 
153
+ [0.1.10]: https://github.com/anpham6/squared/releases/tag/v0.1.10-ruby
154
+ [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
130
155
  [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
131
156
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
132
157
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-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
@@ -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.8'
4
+ VERSION = '0.1.10'
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)
@@ -393,20 +393,19 @@ module Squared
393
393
  end
394
394
 
395
395
  def script_get(*args, group: nil, ref: nil)
396
- if group
397
- @script[:group][group.to_sym]
398
- elsif ref.is_a?(Array)
399
- ref = ref.each
400
- end
401
- if ref.instance_of?(Enumerator)
402
- ref.each do |key|
403
- next unless (ret = @script[:ref][key])
396
+ if group && (ret = @script[:group][group.to_sym])
397
+ ret
398
+ elsif ref
399
+ if ref.is_a?(Enumerable)
400
+ ref.each do |key|
401
+ next unless (ret = @script[:ref][key])
404
402
 
405
- return ret if args.empty? || args.any? { |val| ret.key?(val) }
403
+ return ret if args.empty? || args.any? { |val| ret.key?(val) }
404
+ end
405
+ nil
406
+ else
407
+ @script[:ref][ref]
406
408
  end
407
- nil
408
- elsif ref
409
- @script[:ref][ref]
410
409
  end
411
410
  end
412
411
 
@@ -454,6 +453,14 @@ module Squared
454
453
  Rake::Win32.windows?
455
454
  end
456
455
 
456
+ def jruby?
457
+ RUBY_ENGINE == 'jruby'
458
+ end
459
+
460
+ def jruby_win?
461
+ jruby? && windows?
462
+ end
463
+
457
464
  def rootpath(*args)
458
465
  root.join(*args)
459
466
  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|
@@ -618,7 +619,7 @@ module Squared
618
619
  def read_packagemanager(version: nil)
619
620
  if @pm[:_].nil?
620
621
  doc = JSON.parse(dependfile.read)
621
- @pm[:_] = (val = doc['packageManager']) ? val[0..(val.index('+') || 0) - 1] : false
622
+ @pm[:_] = (val = doc['packageManager']) ? val[0..((val.index('+') || 0) - 1)] : false
622
623
  @pm[:name] = doc['name']
623
624
  @pm[:scripts] = doc['scripts']
624
625
  @pm[:version] = doc['version']
@@ -629,7 +630,7 @@ module Squared
629
630
  @pm[:_] = false
630
631
  nil
631
632
  else
632
- !(ret = @pm[:_]) || (version && ret[ret.index('@') + 1..-1] < version) ? nil : ret
633
+ !(ret = @pm[:_]) || (version && ret[(ret.index('@') + 1)..-1] < version) ? nil : ret
633
634
  end
634
635
 
635
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.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-05-15 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.1.6
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: []