squared 0.1.4 → 0.1.6
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 +24 -2
- data/lib/squared/common/format.rb +7 -7
- data/lib/squared/common/shell.rb +5 -4
- data/lib/squared/common/utils.rb +1 -1
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/project/base.rb +15 -13
- data/lib/squared/workspace/project/git.rb +6 -6
- data/lib/squared/workspace/project/node.rb +5 -2
- data/lib/squared/workspace/project/ruby.rb +3 -3
- data/squared.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7630bfea46c3328ad2c6a12c865a913c3efad5609815b4b5dee647abd9e43665
|
4
|
+
data.tar.gz: 7c791bd8356e85949829196c6eddca1ad29227189471a9a89c02b8eb48c101cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa16263ea3d1d1012d308bc41dda0f72557329c1e0e491fce519b3cb9d9fd67b6ebc635747737053213ffb3dd21e86d4318b49c1de72dbffdce7d93f5cb698a
|
7
|
+
data.tar.gz: 73d2f5163e5d5c87abbb9894933829a88a8d589424eb70bfb39ae8c8721af1050da7f8e1c2e3d2566f914ccd90ea230fc7138dcad7d77fbd559131aa4121c7aa
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [0.1.
|
3
|
+
## [0.1.6] - 2025-04-17
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
- Log messages were concatenated without separator.
|
8
|
+
- Regexp "o" modifier was not used properly.
|
9
|
+
- Rake did not run individual project Rakefile.
|
10
|
+
- User-defined program paths were not reduced to bare name.
|
11
|
+
- Project path validation did not include separator.
|
12
|
+
|
13
|
+
## [0.1.5] - 2025-02-25
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Node copy method ignored include argument when called directly.
|
18
|
+
- Logger is not initialized when using only Git base class.
|
19
|
+
- Hide warnings about readline during execution.
|
20
|
+
- Logger is not initialized when using only base class.
|
21
|
+
- Merging ENV build options were double escaped.
|
22
|
+
|
23
|
+
## [0.1.4] - 2025-02-05
|
4
24
|
|
5
25
|
### Fixed
|
6
26
|
|
@@ -9,7 +29,7 @@
|
|
9
29
|
- Git command refs did not include ref option.
|
10
30
|
- Pip upgrade did not append package names.
|
11
31
|
|
12
|
-
## [0.1.3] -
|
32
|
+
## [0.1.3] - 2025-01-02
|
13
33
|
|
14
34
|
### Fixed
|
15
35
|
|
@@ -88,6 +108,8 @@
|
|
88
108
|
|
89
109
|
- Changelog was created.
|
90
110
|
|
111
|
+
[0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
|
112
|
+
[0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
|
91
113
|
[0.1.4]: https://github.com/anpham6/squared/releases/tag/v0.1.4-ruby
|
92
114
|
[0.1.3]: https://github.com/anpham6/squared/releases/tag/v0.1.3-ruby
|
93
115
|
[0.1.2]: https://github.com/anpham6/squared/releases/tag/v0.1.2-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
|
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..2]
|
@@ -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
|
-
|
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
|
@@ -278,6 +274,10 @@ module Squared
|
|
278
274
|
val.gsub(/\x1B\[(\d+;?)+m/, '')
|
279
275
|
end
|
280
276
|
|
277
|
+
def stripext(val)
|
278
|
+
File.basename(val, File.extname(val))
|
279
|
+
end
|
280
|
+
|
281
281
|
def raise_error(*args, hint: nil, kind: ArgumentError)
|
282
282
|
raise kind, message(*args, hint: hint, empty: true)
|
283
283
|
end
|
data/lib/squared/common/shell.rb
CHANGED
@@ -10,7 +10,7 @@ module Squared
|
|
10
10
|
|
11
11
|
def shell_escape(val, quote: false, force: false)
|
12
12
|
if (data = /\A(--?[^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
|
13
|
-
return val
|
13
|
+
return val if !data[2] || (!data[4] && data[5] =~ /\s/)
|
14
14
|
|
15
15
|
join = ->(opt) { data[1] + data[3] + shell_quote(opt) }
|
16
16
|
if data[4] == data[6]
|
@@ -32,8 +32,9 @@ module Squared
|
|
32
32
|
Rake::Win32.windows? ? "\"#{double_quote(val)}\"" : "'#{single_quote(val)}'"
|
33
33
|
end
|
34
34
|
|
35
|
-
def shell_split(val, quote: false, join: nil)
|
36
|
-
val = Shellwords.split(val)
|
35
|
+
def shell_split(val, escape: true, quote: false, join: nil)
|
36
|
+
val = Shellwords.split(val)
|
37
|
+
val = val.map { |opt| shell_escape(opt, quote: quote) } if escape
|
37
38
|
return val unless join
|
38
39
|
|
39
40
|
val.join(join.is_a?(::String) ? join : ' ')
|
@@ -64,7 +65,7 @@ module Squared
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def split_escape(val, char: ',')
|
67
|
-
val.split(/\s*(?<!\\)#{char}\s*/
|
68
|
+
val.split(/\s*(?<!\\)#{char}\s*/)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
data/lib/squared/common/utils.rb
CHANGED
data/lib/squared/version.rb
CHANGED
@@ -187,7 +187,7 @@ module Squared
|
|
187
187
|
@prod = env_match("#{pre}_PROD", prod)
|
188
188
|
cmd = @output[0]
|
189
189
|
unless cmd == false || cmd.is_a?(Array) || (val = env('BUILD', suffix: 'OPTS')).nil?
|
190
|
-
@output[cmd ? 1 : 3] = shell_split(val, join: true)
|
190
|
+
@output[cmd ? 1 : 3] = shell_split(val, escape: false, join: true)
|
191
191
|
end
|
192
192
|
unless @output[2] == false || (val = env('BUILD', suffix: 'ENV')).nil?
|
193
193
|
begin
|
@@ -195,7 +195,7 @@ module Squared
|
|
195
195
|
raise_error('invalid JSON object', val, hint: "#{prefix}_ENV") unless data.is_a?(Hash)
|
196
196
|
@output[2] = data
|
197
197
|
rescue StandardError => e
|
198
|
-
log
|
198
|
+
log&.warn e
|
199
199
|
end
|
200
200
|
end
|
201
201
|
return unless (val = env('BUILD', strict: true))
|
@@ -291,7 +291,7 @@ module Squared
|
|
291
291
|
if val.directory? && !val.empty?
|
292
292
|
true
|
293
293
|
else
|
294
|
-
log
|
294
|
+
log&.warn "workspace \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
|
295
295
|
false
|
296
296
|
end
|
297
297
|
end
|
@@ -380,7 +380,7 @@ module Squared
|
|
380
380
|
val = val.to_s
|
381
381
|
path = basepath(val)
|
382
382
|
if path.directory? && val =~ %r{[\\/]$}
|
383
|
-
log
|
383
|
+
log&.warn "rm -rf #{path}"
|
384
384
|
path.rmtree
|
385
385
|
else
|
386
386
|
files = val.include?('*') ? Dir[path] : [path]
|
@@ -390,7 +390,7 @@ module Squared
|
|
390
390
|
begin
|
391
391
|
File.delete(file)
|
392
392
|
rescue StandardError => e
|
393
|
-
log
|
393
|
+
log&.error e
|
394
394
|
end
|
395
395
|
end
|
396
396
|
end
|
@@ -440,7 +440,7 @@ module Squared
|
|
440
440
|
instance_variable_set :"@#{key}", val.first
|
441
441
|
end
|
442
442
|
else
|
443
|
-
log
|
443
|
+
log&.warn "variable_set: @#{key} (private)"
|
444
444
|
end
|
445
445
|
end
|
446
446
|
|
@@ -548,10 +548,10 @@ module Squared
|
|
548
548
|
|
549
549
|
def run(cmd = @session, var = nil, exception: @exception, sync: true, banner: true, chdir: path, **)
|
550
550
|
cmd = session_done(cmd)
|
551
|
-
log
|
551
|
+
log&.info cmd
|
552
552
|
begin
|
553
553
|
if cmd =~ /\A[^:]+:[^:]/ && workspace.task_defined?(cmd)
|
554
|
-
log
|
554
|
+
log&.warn "ENV was discarded: #{var}" if var
|
555
555
|
task_invoke(cmd, exception: exception, warning: warning?)
|
556
556
|
else
|
557
557
|
print_item format_banner(cmd, banner: banner) if sync
|
@@ -559,7 +559,7 @@ module Squared
|
|
559
559
|
shell(*args, chdir: chdir, exception: exception)
|
560
560
|
end
|
561
561
|
rescue StandardError => e
|
562
|
-
log
|
562
|
+
log&.error e
|
563
563
|
raise
|
564
564
|
end
|
565
565
|
end
|
@@ -679,7 +679,8 @@ module Squared
|
|
679
679
|
end
|
680
680
|
|
681
681
|
def session(*cmd, prefix: cmd.first)
|
682
|
-
|
682
|
+
prefix = stripext(prefix.to_s).upcase
|
683
|
+
if (val = env("#{prefix}_OPTIONS"))
|
683
684
|
split_escape(val).each { |opt| cmd << fill_option(opt) }
|
684
685
|
end
|
685
686
|
@session = JoinSet.new(cmd)
|
@@ -696,7 +697,7 @@ module Squared
|
|
696
697
|
def option(*args, prefix: @session&.first, **kwargs)
|
697
698
|
if prefix
|
698
699
|
args.each do |val|
|
699
|
-
ret = env("#{prefix}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
|
700
|
+
ret = env("#{stripext(prefix)}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
|
700
701
|
return ret if ret
|
701
702
|
end
|
702
703
|
end
|
@@ -869,7 +870,7 @@ module Squared
|
|
869
870
|
|
870
871
|
def guard_params(action, flag, args: nil, key: nil, pat: nil)
|
871
872
|
if args && key
|
872
|
-
val = args
|
873
|
+
val = args.fetch(key, nil)
|
873
874
|
return val unless val.nil? || (pat && !val.match?(pat))
|
874
875
|
|
875
876
|
@session = nil
|
@@ -974,7 +975,8 @@ module Squared
|
|
974
975
|
end
|
975
976
|
|
976
977
|
def projectpath?(val)
|
977
|
-
Pathname.new(val).
|
978
|
+
val = Pathname.new(val).cleanpath
|
979
|
+
val.absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?(File.join('..', ''))
|
978
980
|
end
|
979
981
|
|
980
982
|
def semmajor?(cur, want)
|
@@ -478,10 +478,10 @@ module Squared
|
|
478
478
|
unless (origin = option('repository', prefix: 'git', ignore: false))
|
479
479
|
out = source('git log -n1 --format=%h%d', io: true, stdout: true, banner: false).first
|
480
480
|
if (data = /\A#{sha} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)\z/.match(out))
|
481
|
-
split_escape(data[1]).each do |
|
482
|
-
next unless
|
481
|
+
split_escape(data[1]).each do |s|
|
482
|
+
next unless s.end_with?("/#{branch}")
|
483
483
|
|
484
|
-
origin =
|
484
|
+
origin = s[0..s.size - branch.size - 2]
|
485
485
|
break
|
486
486
|
end
|
487
487
|
end
|
@@ -552,7 +552,7 @@ module Squared
|
|
552
552
|
def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
|
553
553
|
sub: nil)
|
554
554
|
cmd = session_done(cmd)
|
555
|
-
log
|
555
|
+
log&.info cmd
|
556
556
|
banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner)
|
557
557
|
cmd = cmd.sub(/\Agit\b/, "git --work-tree=#{shell_quote(path)} --git-dir=#{shell_quote(gitpath)}")
|
558
558
|
begin
|
@@ -586,7 +586,7 @@ module Squared
|
|
586
586
|
end
|
587
587
|
end
|
588
588
|
rescue StandardError => e
|
589
|
-
log
|
589
|
+
log&.error e
|
590
590
|
raise if exception
|
591
591
|
|
592
592
|
warn log_message(Logger::WARN, e) if warning?
|
@@ -602,7 +602,7 @@ module Squared
|
|
602
602
|
next if grep && !line.match?(grep)
|
603
603
|
|
604
604
|
if loglevel
|
605
|
-
log
|
605
|
+
log&.add loglevel, line
|
606
606
|
else
|
607
607
|
sub&.each { |h| line = sub_style(line, **h) }
|
608
608
|
if banner
|
@@ -123,8 +123,8 @@ module Squared
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
def copy(from: 'build', into: 'node_modules', workspace: false,
|
127
|
-
also: nil, create: nil, override: false)
|
126
|
+
def copy(from: 'build', into: 'node_modules', workspace: false, scope: nil,
|
127
|
+
also: nil, create: nil, override: false, **kwargs)
|
128
128
|
return if @copy == false
|
129
129
|
|
130
130
|
if @copy && !override
|
@@ -138,6 +138,9 @@ module Squared
|
|
138
138
|
scope = @copy[:scope]
|
139
139
|
also = @copy[:also]
|
140
140
|
create = @copy[:create]
|
141
|
+
else
|
142
|
+
glob = kwargs[:include]
|
143
|
+
exclude = kwargs[:exclude]
|
141
144
|
end
|
142
145
|
items = []
|
143
146
|
items << @workspace.home if build? && path != @workspace.home && @workspace.home?
|
@@ -364,11 +364,11 @@ module Squared
|
|
364
364
|
end
|
365
365
|
|
366
366
|
def rake(*cmd)
|
367
|
-
|
367
|
+
file = shell_option('rakefile', rakefile, quote: true, escape: false)
|
368
368
|
if cmd.empty?
|
369
|
-
run_s("rake #{
|
369
|
+
run_s("rake #{file}", chdir: workspace.pwd)
|
370
370
|
else
|
371
|
-
run_s(*cmd.map { |val| "rake #{
|
371
|
+
run_s(*cmd.map { |val| "rake #{file} #{val}" }, chdir: workspace.pwd, banner: false)
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
data/squared.gemspec
CHANGED
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rake
|
@@ -51,6 +51,20 @@ dependencies:
|
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: readline
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
54
68
|
description: Rake task generator for managing multi-language workspaces.
|
55
69
|
email:
|
56
70
|
- anpham6@gmail.com
|
@@ -106,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
120
|
- !ruby/object:Gem::Version
|
107
121
|
version: '0'
|
108
122
|
requirements: []
|
109
|
-
rubygems_version: 3.6.
|
123
|
+
rubygems_version: 3.6.8
|
110
124
|
specification_version: 4
|
111
125
|
summary: Rake task generator for managing multi-language workspaces.
|
112
126
|
test_files: []
|