squared 0.1.8 → 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 +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/squared/common/base.rb +5 -2
- data/lib/squared/common/system.rb +21 -12
- data/lib/squared/config.rb +2 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +9 -1
- data/lib/squared/workspace/project/base.rb +9 -6
- data/lib/squared/workspace/project/git.rb +20 -20
- data/lib/squared/workspace/project/node.rb +5 -4
- data/lib/squared/workspace/project/python.rb +2 -2
- data/lib/squared/workspace/project/ruby.rb +3 -3
- data/lib/squared/workspace/repo.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: addae758d36dc852622753e60909d36ba8ec6a69c23e24807f5f4fbf6c0df727
|
4
|
+
data.tar.gz: 5b925297744f78e61a4a7b576059e4945b9d057653b0e88e26b41512d2f1a6cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72206ed4177ac84f344d40f87fca044f1673788be0f39e1f3988e29120d43351b3971925edf87b8d24a035b027cc2eb4276f8bc30c04467f77c5d18bed505c99
|
7
|
+
data.tar.gz: 106b51f41c26c4acf4cd6379ce25f3bf3ab50c6e97001d4b119c9590977eb64899cc577b439a83d2457a6fb5cbfaf296ba4edd69f30772c4b3249f336f52876f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
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
|
+
|
3
19
|
## [0.1.8] - 2025-05-15
|
4
20
|
|
5
21
|
### Fixed
|
@@ -127,6 +143,7 @@
|
|
127
143
|
|
128
144
|
- Changelog was created.
|
129
145
|
|
146
|
+
[0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
|
130
147
|
[0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
|
131
148
|
[0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
|
132
149
|
[0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
|
data/lib/squared/common/base.rb
CHANGED
@@ -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?(:
|
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 =
|
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 '
|
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
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
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
|
42
|
+
Array(pass).each { |val| exclude += ::Dir.glob(src.join(val)) }
|
34
43
|
end
|
35
|
-
(glob
|
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
|
64
|
+
src = Array(src).reject { |val| path.join(::File.basename(val)).exist? }
|
56
65
|
elsif path.exist?
|
57
66
|
return
|
58
67
|
end
|
data/lib/squared/config.rb
CHANGED
@@ -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
|
]
|
data/lib/squared/version.rb
CHANGED
@@ -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)
|
@@ -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
|
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
|
-
|
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
|
-
|
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
|
115
|
+
task flag, [:commit] do |_, args|
|
116
116
|
commit = guard_params(action, flag, args: args, key: :commit)
|
117
|
-
tag(flag, args.
|
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.
|
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
|
221
|
-
files = guard_params(action, flag, args: args.
|
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
|
239
|
-
show(args.
|
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+)(\++)(
|
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",
|
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
|
-
|
546
|
-
|
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
|
-
|
607
|
-
|
608
|
-
|
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,
|
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,
|
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
|
81
|
+
task flag, [:dir] do |_, args|
|
82
82
|
dir = guard_params(action, flag, args: args, key: :dir)
|
83
|
-
depend(flag, dir: dir, opts: args.
|
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,
|
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,
|
97
|
-
|
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
|
-
|
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.
|
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:
|
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.
|
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: []
|