squared 0.2.1 → 0.2.2
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 +19 -0
- data/lib/squared/common/shell.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +1 -1
- data/lib/squared/workspace/project/base.rb +34 -25
- data/lib/squared/workspace/project/git.rb +21 -17
- data/lib/squared/workspace/project/node.rb +1 -1
- data/lib/squared/workspace/project/python.rb +3 -3
- data/lib/squared/workspace/project/ruby.rb +17 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82c53d370d6535fd30824fafd72a2f68fd7db161600d2740fd643f270d68d6f6
|
4
|
+
data.tar.gz: 26b8eb9e45b508923bacce4bc06502d3031fc7a8b9c844dfd02775a86191ec3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f32e8ae4585c328c298791628eca4e18e00ac2818bee7aa9c5e1f1f680fd6b60f0a59cc1fd1b4313794d1d7d926dfc195762cf9912e83034d553d248f90f8743
|
7
|
+
data.tar.gz: '091805806ce97b61bf45f6df58bf5232ce75f65e0d1bcbcdffb0aed949e3e38200b5ea8d9bd600e9c2150e24296af2faf2ac3a99312ec290112bf55770ea38a7'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.2.2] - 2025-01-19
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
- Ruby version detection did not parse currently installed gem.
|
8
|
+
- Build options with array args were not recognized.
|
9
|
+
- Base clean command did not enumerate non-string values.
|
10
|
+
- Git pull did not append origin without option separator.
|
11
|
+
- Command options from a hash did not parse single character flags.
|
12
|
+
- Git command refs did not include ref option.
|
13
|
+
- Base copy command did not accept array parameters.
|
14
|
+
- Shell option escape did not detect quotes for Windows.
|
15
|
+
- Git command reset did not include mode argument.
|
16
|
+
- Git command show format argument was not optional.
|
17
|
+
- Clean directory did not set verbose flag.
|
18
|
+
- Git clone was not enabled when all project folders were missing.
|
19
|
+
- Git commit does not parse global ENV options.
|
20
|
+
|
3
21
|
## [0.2.1] - 2025-01-08
|
4
22
|
|
5
23
|
### Fixed
|
@@ -151,6 +169,7 @@
|
|
151
169
|
|
152
170
|
- Changelog was created.
|
153
171
|
|
172
|
+
[0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
|
154
173
|
[0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
|
155
174
|
[0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
|
156
175
|
[0.1.3]: https://github.com/anpham6/squared/releases/tag/v0.1.3-ruby
|
data/lib/squared/common/shell.rb
CHANGED
@@ -39,7 +39,7 @@ module Squared
|
|
39
39
|
val.join(join.is_a?(::String) ? join : ' ')
|
40
40
|
end
|
41
41
|
|
42
|
-
def shell_option(flag, val = nil,
|
42
|
+
def shell_option(flag, val = nil, escape: true, quote: true)
|
43
43
|
a, b = flag.size == 1 ? ['-', ' '] : ['--', '=']
|
44
44
|
"#{a}#{flag}#{if val
|
45
45
|
"#{b}#{if escape
|
@@ -57,11 +57,11 @@ module Squared
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def quote_option(flag, val)
|
60
|
-
shell_option(flag, val, escape: false
|
60
|
+
shell_option(flag, val, escape: false)
|
61
61
|
end
|
62
62
|
|
63
63
|
def basic_option(flag, val)
|
64
|
-
shell_option(flag, val, escape: false)
|
64
|
+
shell_option(flag, val, escape: false, quote: false)
|
65
65
|
end
|
66
66
|
|
67
67
|
def single_quote(val)
|
data/lib/squared/version.rb
CHANGED
@@ -348,20 +348,22 @@ module Squared
|
|
348
348
|
end
|
349
349
|
|
350
350
|
def build(*args, from: :build, sync: invoked_sync?('build'), **)
|
351
|
+
banner = verbose
|
351
352
|
if args.empty?
|
353
|
+
return unless from == :build
|
354
|
+
|
352
355
|
cmd, opts, var, flags = @output
|
353
|
-
banner = verbose == 1
|
356
|
+
banner = verbose == 1 if task_invoked?('build', 'build:sync')
|
354
357
|
else
|
355
358
|
cmd = args.shift
|
356
359
|
opts = args.map { |val| shell_quote(val, force: false) }.join(' ')
|
357
|
-
banner = verbose
|
358
360
|
end
|
359
361
|
if cmd
|
360
362
|
case opts
|
361
363
|
when String
|
362
364
|
cmd = "#{cmd} #{opts}"
|
363
365
|
when Array
|
364
|
-
cmd = cmd.join(' && ')
|
366
|
+
cmd = as_a(cmd).concat(opts).join(' && ')
|
365
367
|
else
|
366
368
|
cmd = [cmd, compose(opts, script: false)].compact.join(' ') unless opts == false || !respond_to?(:compose)
|
367
369
|
end
|
@@ -388,13 +390,13 @@ module Squared
|
|
388
390
|
def doc(*, sync: invoked_sync?('doc'), **)
|
389
391
|
return unless @doc
|
390
392
|
|
391
|
-
build(@doc, from: :doc, sync: sync)
|
393
|
+
build(*as_a(@doc), from: :doc, sync: sync)
|
392
394
|
end
|
393
395
|
|
394
396
|
def test(*, sync: invoked_sync?('test'), **)
|
395
397
|
return unless @test
|
396
398
|
|
397
|
-
build(@test, from: :test, sync: sync)
|
399
|
+
build(*as_a(@test), from: :test, sync: sync)
|
398
400
|
end
|
399
401
|
|
400
402
|
def clean(*, sync: invoked_sync?('clean'), **)
|
@@ -403,21 +405,21 @@ module Squared
|
|
403
405
|
on :first, :clean
|
404
406
|
case @clean
|
405
407
|
when String
|
406
|
-
|
408
|
+
run(@clean, from: :clean, sync: sync)
|
407
409
|
when Enumerable
|
408
|
-
as_a(@clean).each do |val|
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
log.warn "rm -rf #{dir}"
|
415
|
-
dir.rmtree
|
410
|
+
(@clean.is_a?(Hash) ? @clean.values : as_a(@clean)).each do |val|
|
411
|
+
val = val.to_s
|
412
|
+
path = basepath(val)
|
413
|
+
if path.directory? && val =~ %r{[\\/]\z}
|
414
|
+
log.warn "rm -rf #{path}"
|
415
|
+
path.rmtree(verbose: true)
|
416
416
|
else
|
417
|
-
|
418
|
-
|
417
|
+
log.warn "rm #{path}"
|
418
|
+
(val.include?('*') ? Dir[path] : [path]).each do |file|
|
419
|
+
next unless File.file?(file)
|
420
|
+
|
419
421
|
begin
|
420
|
-
File.delete(file)
|
422
|
+
File.delete(file)
|
421
423
|
rescue StandardError => e
|
422
424
|
log.error e
|
423
425
|
end
|
@@ -558,6 +560,12 @@ module Squared
|
|
558
560
|
@prod != false && workspace.prod?(pat: @prod, **scriptargs)
|
559
561
|
end
|
560
562
|
|
563
|
+
def exclude?(*refs)
|
564
|
+
return false if @exclude.empty?
|
565
|
+
|
566
|
+
refs.flatten.any? { |ref| @exclude.include?(ref) }
|
567
|
+
end
|
568
|
+
|
561
569
|
def task_include?(key, ref = nil)
|
562
570
|
workspace.task_include?(self, key, ref) && !@pass.include?(key.to_s)
|
563
571
|
end
|
@@ -639,7 +647,7 @@ module Squared
|
|
639
647
|
def run_s(*cmd, env: nil, sync: true, banner: verbose != false, from: nil, **kwargs)
|
640
648
|
on :first, from if from
|
641
649
|
begin
|
642
|
-
cmd.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
|
650
|
+
cmd.flatten.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
|
643
651
|
rescue StandardError => e
|
644
652
|
ret = on(:error, from, e) if from
|
645
653
|
raise unless ret == true
|
@@ -971,21 +979,21 @@ module Squared
|
|
971
979
|
end
|
972
980
|
|
973
981
|
def append_repeat(flag, opts, target: @session)
|
974
|
-
opts.each { |val| target << shell_option(flag, val
|
982
|
+
opts.each { |val| target << shell_option(flag, val) }
|
975
983
|
end
|
976
984
|
|
977
|
-
def append_value(opts, target: @session, delim: false, escape: true)
|
978
|
-
return if opts.empty?
|
985
|
+
def append_value(*opts, target: @session, delim: false, escape: true, quote: false)
|
986
|
+
return if (opts = opts.flatten).empty?
|
979
987
|
|
980
988
|
target << '--' if delim
|
981
|
-
opts.each { |val| target << (escape ? shell_escape(val) : shell_quote(val)) }
|
989
|
+
opts.each { |val| target << (escape ? shell_escape(val, quote: quote) : shell_quote(val)) }
|
982
990
|
end
|
983
991
|
|
984
992
|
def append_hash(opts, target: @session)
|
985
993
|
out = target.to_s
|
986
994
|
opts.each do |key, val|
|
987
995
|
key = key.to_s
|
988
|
-
key =
|
996
|
+
key = shell_option(key) unless key[0] == '-'
|
989
997
|
next if out =~ Regexp.new(" #{key}(?: |=|$)")
|
990
998
|
|
991
999
|
case val
|
@@ -994,7 +1002,7 @@ module Squared
|
|
994
1002
|
when Array
|
995
1003
|
append_repeat(key, val, target: target)
|
996
1004
|
when Numeric
|
997
|
-
target << (key + (key.start_with?('--') ? '=' : '') + val)
|
1005
|
+
target << (key + (key.start_with?('--') ? '=' : '') + val.to_s)
|
998
1006
|
when false
|
999
1007
|
target << key.sub(/^--(?!no-)/, '--no-')
|
1000
1008
|
else
|
@@ -1013,6 +1021,7 @@ module Squared
|
|
1013
1021
|
shell_quote(val)
|
1014
1022
|
end)
|
1015
1023
|
end
|
1024
|
+
nil
|
1016
1025
|
end
|
1017
1026
|
|
1018
1027
|
def append_option(list, target: @session, equals: false, quote: false, escape: true, **kwargs)
|
@@ -1097,7 +1106,7 @@ module Squared
|
|
1097
1106
|
when Proc, Method
|
1098
1107
|
cmd.call(*args, **opts)
|
1099
1108
|
when String
|
1100
|
-
|
1109
|
+
run(cmd, **opts)
|
1101
1110
|
end
|
1102
1111
|
end
|
1103
1112
|
end
|
@@ -9,7 +9,7 @@ module Squared
|
|
9
9
|
|
10
10
|
def git(name, uri = nil, base: nil, repo: [], options: {})
|
11
11
|
data = {}
|
12
|
-
check = ->(proj) { proj.is_a?(Project::Git) && git_clone?(proj.path) }
|
12
|
+
check = ->(proj) { proj.is_a?(Project::Git) && !proj.exclude?(Project::Git.ref) && git_clone?(proj.path) }
|
13
13
|
if uri.is_a?(Array)
|
14
14
|
base = name
|
15
15
|
uri.each { |val| repo << proj if (proj = @project[val.to_s]) && check.(proj) }
|
@@ -569,7 +569,7 @@ module Squared
|
|
569
569
|
list_result(ret, 'files', from: from, action: 'modified')
|
570
570
|
end
|
571
571
|
|
572
|
-
def reset(flag, files =
|
572
|
+
def reset(flag, files = nil, mode: nil, ref: nil)
|
573
573
|
cmd = git_session 'reset'
|
574
574
|
case flag
|
575
575
|
when :mode
|
@@ -591,7 +591,7 @@ module Squared
|
|
591
591
|
cmd << '--patch'
|
592
592
|
end
|
593
593
|
append_commit ref
|
594
|
-
append_pathspec files
|
594
|
+
append_pathspec files if files
|
595
595
|
source
|
596
596
|
end
|
597
597
|
|
@@ -746,7 +746,7 @@ module Squared
|
|
746
746
|
break
|
747
747
|
end
|
748
748
|
raise_error('commit', 'work tree is not usable') unless origin && branch
|
749
|
-
cmd = git_session
|
749
|
+
cmd = git_session('commit', option('dry-run') && '--dry-run', options: false)
|
750
750
|
if amend
|
751
751
|
cmd << '--amend'
|
752
752
|
else
|
@@ -865,12 +865,16 @@ module Squared
|
|
865
865
|
def show(objs, format: nil, opts: nil)
|
866
866
|
cmd = git_session 'show'
|
867
867
|
if format
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
868
|
+
case (val = format.downcase)
|
869
|
+
when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
|
870
|
+
cmd << basic_option('format', val)
|
871
|
+
else
|
872
|
+
if format =~ /^t?format:/ || format.include?('%')
|
873
|
+
cmd << quote_option('pretty', format)
|
874
|
+
else
|
875
|
+
objs << format
|
876
|
+
end
|
877
|
+
end
|
874
878
|
end
|
875
879
|
if opts
|
876
880
|
append_hash opts
|
@@ -879,7 +883,7 @@ module Squared
|
|
879
883
|
cmd << basic_option('abbrev', val) if (val = option('abbrev')) && val.to_i > 0
|
880
884
|
banner = true
|
881
885
|
end
|
882
|
-
append_value
|
886
|
+
append_value(objs, delim: true)
|
883
887
|
source(exception: false, banner: banner)
|
884
888
|
end
|
885
889
|
|
@@ -894,7 +898,7 @@ module Squared
|
|
894
898
|
end
|
895
899
|
|
896
900
|
def ls_remote(flag, grep: nil)
|
897
|
-
git_session 'ls-remote', "
|
901
|
+
git_session 'ls-remote', "--#{flag}", '--refs'
|
898
902
|
out, banner, from = source(io: true)
|
899
903
|
print_item banner
|
900
904
|
ret = write_lines(out, grep: grep)
|
@@ -902,7 +906,7 @@ module Squared
|
|
902
906
|
end
|
903
907
|
|
904
908
|
def ls_files(flag, grep: nil)
|
905
|
-
git_session 'ls-files', "
|
909
|
+
git_session 'ls-files', "--#{flag}"
|
906
910
|
out, banner, from = source(io: true)
|
907
911
|
print_item banner
|
908
912
|
ret = write_lines(out, grep: grep)
|
@@ -1029,7 +1033,7 @@ module Squared
|
|
1029
1033
|
|
1030
1034
|
target << quote_option($1, val.strftime('%F %T'))
|
1031
1035
|
when 'recurse-submodules'
|
1032
|
-
target <<
|
1036
|
+
target << basic_option($1, $2) unless modules
|
1033
1037
|
when 'shallow-exclude', 'gpg-sign', 'signoff', 'strategy', 'strategy-option'
|
1034
1038
|
target << shell_option($1, $2)
|
1035
1039
|
when 'refmap', 'negotiation-tip'
|
@@ -1044,9 +1048,9 @@ module Squared
|
|
1044
1048
|
end
|
1045
1049
|
end
|
1046
1050
|
if remote
|
1047
|
-
target
|
1051
|
+
append_value(remote, target: target, delim: true, quote: true)
|
1048
1052
|
if (val = option('refspec', strict: true))
|
1049
|
-
append_value(split_escape(val), escape: false)
|
1053
|
+
append_value(split_escape(val), target: target, escape: false)
|
1050
1054
|
else
|
1051
1055
|
target.merge(refspec)
|
1052
1056
|
end
|
@@ -1060,7 +1064,7 @@ module Squared
|
|
1060
1064
|
|
1061
1065
|
def append_commit(val, target: @session)
|
1062
1066
|
val = val.to_s.strip
|
1063
|
-
target << (val.empty? ? 'HEAD' : val)
|
1067
|
+
target << (val.empty? ? append_head(target: target) || 'HEAD' : val)
|
1064
1068
|
end
|
1065
1069
|
|
1066
1070
|
def append_pathspec(files = [], target: @session, expect: false, parent: false)
|
@@ -294,7 +294,7 @@ module Squared
|
|
294
294
|
end
|
295
295
|
cmd << '--prod' if flag && prod?
|
296
296
|
if (val = option('public-hoist-pattern', ignore: false))
|
297
|
-
split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt
|
297
|
+
split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt) }
|
298
298
|
end
|
299
299
|
cmd << '--ignore-workspace' if env('NODE_WORKSPACES', equals: '0')
|
300
300
|
append_nocolor
|
@@ -121,7 +121,7 @@ module Squared
|
|
121
121
|
when :force
|
122
122
|
cmd << '--force-reinstall'
|
123
123
|
when :target
|
124
|
-
cmd <<
|
124
|
+
cmd << quote_option('target', basepath(param))
|
125
125
|
else
|
126
126
|
append_global
|
127
127
|
end
|
@@ -275,7 +275,7 @@ module Squared
|
|
275
275
|
target << quote_option($1, val =~ %r{^[a-z]+\+[a-z]+://} ? val : basepath(val))
|
276
276
|
when 'proxy', 'config-settings', 'global-option', 'extra-index-url',
|
277
277
|
'f', 'find-links', 'i', 'index-url'
|
278
|
-
target <<
|
278
|
+
target << quote_option($1, $2)
|
279
279
|
when 'retries', 'timeout'
|
280
280
|
target << basic_option($1, $2) if $2.to_i > 0
|
281
281
|
else
|
@@ -297,7 +297,7 @@ module Squared
|
|
297
297
|
quote_option('cache-dir', basepath(val))
|
298
298
|
end
|
299
299
|
end
|
300
|
-
cmd <<
|
300
|
+
cmd << quote_option('proxy', val) if (val = option('proxy'))
|
301
301
|
cmd << quote_option('python', basepath(val)) if (val = option('python'))
|
302
302
|
append_nocolor
|
303
303
|
end
|
@@ -482,6 +482,7 @@ module Squared
|
|
482
482
|
end
|
483
483
|
|
484
484
|
def bundle(cmd, *args)
|
485
|
+
args = args.flatten
|
485
486
|
run_s(bundle_session(cmd, *args), from: :bundle)
|
486
487
|
end
|
487
488
|
|
@@ -489,7 +490,8 @@ module Squared
|
|
489
490
|
if cmd.empty?
|
490
491
|
run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd)
|
491
492
|
else
|
492
|
-
|
493
|
+
cmd = cmd.flatten.map { |val| rake_output(rakeapp, val) }
|
494
|
+
run_s(cmd, from: :rake, chdir: workspace.pwd, banner: false)
|
493
495
|
end
|
494
496
|
end
|
495
497
|
|
@@ -511,22 +513,24 @@ module Squared
|
|
511
513
|
log.warn "using version #{val} (given #{@version})" if @version && @version != val
|
512
514
|
@version = val
|
513
515
|
end
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
516
|
+
if @version
|
517
|
+
out = pwd_set { `#{gem_output('list', '--local', '-d', shell_escape(project, quote: true))}` }
|
518
|
+
if (data = /#{Regexp.escape(project)} \(([^)]+)\)/.match(out))
|
519
|
+
ver = data[1].split(/\s*,\s*/)
|
520
|
+
ver.unshift(@version).uniq!
|
521
|
+
ver.each do |val|
|
522
|
+
next unless (data = /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/.match(out))
|
523
|
+
|
524
|
+
set.(val)
|
525
|
+
break
|
526
|
+
end
|
523
527
|
end
|
524
528
|
end
|
525
529
|
unless data || RUBY_VERSION < '2.6'
|
526
530
|
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
527
531
|
if (path = target.resolve_feature_path(project)&.last)
|
528
532
|
gems = ['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR)
|
529
|
-
if (ver = Regexp.new(gems).match(path)) && (data = /\A(.+)#{gempath}/.match(path))
|
533
|
+
if (ver = Regexp.new(gems).match(path)) && (data = /\A(.+)#{gempath(ver[1])}/.match(path))
|
530
534
|
set.(ver[1])
|
531
535
|
end
|
532
536
|
end
|
@@ -634,8 +638,8 @@ module Squared
|
|
634
638
|
quote_option 'rakefile', Rake.application.rakefile
|
635
639
|
end
|
636
640
|
|
637
|
-
def gempath
|
638
|
-
File.join('gems', "#{project}-#{
|
641
|
+
def gempath(val = @version)
|
642
|
+
File.join('gems', "#{project}-#{val}")
|
639
643
|
end
|
640
644
|
|
641
645
|
def gemoption(flag)
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rake
|