squared 0.4.19 → 0.4.20
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/shell.rb +3 -3
- data/lib/squared/common/system.rb +2 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/project/base.rb +8 -10
- data/lib/squared/workspace/project/docker.rb +1 -1
- data/lib/squared/workspace/project/git.rb +19 -20
- data/lib/squared/workspace/project/node.rb +17 -15
- data/lib/squared/workspace/project/python.rb +4 -4
- data/lib/squared/workspace/project/ruby.rb +9 -9
- data/lib/squared/workspace/project/support/class.rb +5 -1
- data/lib/squared/workspace/repo.rb +0 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1b0859a60110d19550ba8436a184dbf5475d9103cc844d4bcab7850f2065dc5
|
4
|
+
data.tar.gz: 887a31b94a66e59b0981f6dcbe64544e1f721b07cb5d82d9a71b8bbbc209820e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5936f90594961c71af2f1420607ed9c739bd0f182a440aff4c2d474a8bcc9bbb3e0db1c2bfa6ba27052823414d2f6db981f4251a32c09769595b89a561ecfc84
|
7
|
+
data.tar.gz: 19cc6e69dda54b8d0a3f2cb43606bfb23e25f1f20c071b8e47421156af30d5763162f4a5b14df5f8787a465e53bbabf18b0a9943e7a3c809c31a9825e885e32a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.4.20] - 2025-09-14
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
- Project banners when requested return consistent arguments.
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Workspace global as command alias used undefined parameter.
|
12
|
+
- Python did not separate dependency manager and build backend.
|
13
|
+
- Gem command build did not validate gemspec was located.
|
14
|
+
- Project class Ruby used glob methods not available in Ruby 2.4.
|
15
|
+
- Shell options support using boolean as values.
|
16
|
+
- Git command merge action commit failed when using interactive menu.
|
17
|
+
- NPM command line options did not support boolean flags.
|
18
|
+
|
3
19
|
## [0.4.19] - 2025-08-30
|
4
20
|
|
5
21
|
### Added
|
@@ -946,6 +962,7 @@
|
|
946
962
|
|
947
963
|
- Changelog was created.
|
948
964
|
|
965
|
+
[0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
|
949
966
|
[0.4.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.19
|
950
967
|
[0.4.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.18
|
951
968
|
[0.4.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.17-ruby
|
data/lib/squared/common/shell.rb
CHANGED
@@ -74,7 +74,7 @@ module Squared
|
|
74
74
|
a = '--'
|
75
75
|
b = '='
|
76
76
|
end
|
77
|
-
"#{a}#{flag}#{
|
77
|
+
"#{a}#{flag}#{unless val.nil?
|
78
78
|
"#{b}#{if escape
|
79
79
|
shell_escape(val, quote: quote, double: double, override: override)
|
80
80
|
elsif quote
|
@@ -94,8 +94,8 @@ module Squared
|
|
94
94
|
|
95
95
|
def shell_bin(name, env: true)
|
96
96
|
key = name.upcase
|
97
|
-
shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
|
98
|
-
|
97
|
+
shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name, option: false, force: false,
|
98
|
+
double: true)
|
99
99
|
end
|
100
100
|
|
101
101
|
def fill_option(val, **kwargs)
|
data/lib/squared/version.rb
CHANGED
@@ -98,6 +98,7 @@ module Squared
|
|
98
98
|
@ref = []
|
99
99
|
@children = []
|
100
100
|
@events = hashobj.update({ first: first, last: last, error: error })
|
101
|
+
@as = hashobj
|
101
102
|
@envname = env_key(@name).freeze
|
102
103
|
@desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
|
103
104
|
@parent = nil
|
@@ -476,7 +477,7 @@ module Squared
|
|
476
477
|
else
|
477
478
|
next unless respond_to?(:compose)
|
478
479
|
|
479
|
-
cmd << a if (a = compose(as_get(b), d, script: true, args: e, from: from))
|
480
|
+
cmd << a if (a = compose(as_get(b, from), d, script: true, args: e, from: from))
|
480
481
|
end
|
481
482
|
var.merge!(c) if c.is_a?(Hash)
|
482
483
|
end
|
@@ -485,7 +486,7 @@ module Squared
|
|
485
486
|
cmd, opts, var, flags, extra = args
|
486
487
|
end
|
487
488
|
if cmd
|
488
|
-
cmd = as_get
|
489
|
+
cmd = as_get(cmd, from)
|
489
490
|
opts = compose(opts, script: false) if opts && respond_to?(:compose)
|
490
491
|
flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
|
491
492
|
case opts
|
@@ -502,7 +503,7 @@ module Squared
|
|
502
503
|
else
|
503
504
|
return unless (opts || extra) && respond_to?(:compose)
|
504
505
|
|
505
|
-
cmd = compose(as_get(opts), flags, script: true, args: extra, from: from)
|
506
|
+
cmd = compose(as_get(opts, from), flags, script: true, args: extra, from: from)
|
506
507
|
from = :script if from == :run && script?
|
507
508
|
end
|
508
509
|
run(cmd, var, sync: sync, from: from, banner: banner)
|
@@ -788,9 +789,8 @@ module Squared
|
|
788
789
|
end
|
789
790
|
|
790
791
|
def as(cmd, script, to = nil)
|
791
|
-
|
792
|
-
|
793
|
-
script.each { |key, val| data[key.to_s] = val }
|
792
|
+
data = @as[cmd.to_sym]
|
793
|
+
(to ? [[script, to]] : script).each { |key, val| data[key.to_s] = val }
|
794
794
|
self
|
795
795
|
end
|
796
796
|
|
@@ -2010,10 +2010,8 @@ module Squared
|
|
2010
2010
|
end
|
2011
2011
|
end
|
2012
2012
|
|
2013
|
-
def as_get(val)
|
2014
|
-
|
2015
|
-
|
2016
|
-
@global && (ret = @as && @as[from] && @as[from][val]) ? ret : val
|
2013
|
+
def as_get(val, from)
|
2014
|
+
(@global && @as[from][val]) || val
|
2017
2015
|
end
|
2018
2016
|
|
2019
2017
|
def task_build(keys)
|
@@ -542,7 +542,7 @@ module Squared
|
|
542
542
|
commit1 = commithead args.commit1
|
543
543
|
if commit1
|
544
544
|
commit2 = commithead param_guard(action, flag, args: args, key: :commit2)
|
545
|
-
args = args.extras
|
545
|
+
args = args.extras
|
546
546
|
range = [commit1, commit2]
|
547
547
|
else
|
548
548
|
range, opts, refs = choice_commit(multiple: view ? true : 2, values: %w[Options Pathspec])
|
@@ -752,12 +752,12 @@ module Squared
|
|
752
752
|
args = args.extras
|
753
753
|
else
|
754
754
|
commit, mode = choice_commit(values: ['Mode [mixed|soft|hard|N]'])
|
755
|
-
args = args.extras.
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
755
|
+
args = args.extras.concat(case mode&.downcase
|
756
|
+
when 'h', 'hard' then ['hard']
|
757
|
+
when 's', 'soft' then ['soft']
|
758
|
+
when 'n', 'N' then ['mixed', 'N']
|
759
|
+
else ['mixed']
|
760
|
+
end)
|
761
761
|
end
|
762
762
|
print_success if success?(reset(flag, args, commit: commit))
|
763
763
|
end
|
@@ -1028,7 +1028,7 @@ module Squared
|
|
1028
1028
|
return unless upstream
|
1029
1029
|
|
1030
1030
|
op = OptionPartition.new(opts, OPT_GIT[:rebase], cmd, project: self, no: OPT_GIT[:no][:rebase])
|
1031
|
-
|
1031
|
+
op << upstream
|
1032
1032
|
append_head op.shift
|
1033
1033
|
op.clear(pass: false)
|
1034
1034
|
when :onto
|
@@ -1110,7 +1110,7 @@ module Squared
|
|
1110
1110
|
if op.empty?
|
1111
1111
|
values = [['Branch name', true]]
|
1112
1112
|
else
|
1113
|
-
op << op.
|
1113
|
+
op << op.shift
|
1114
1114
|
end
|
1115
1115
|
end
|
1116
1116
|
out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
|
@@ -1121,7 +1121,7 @@ module Squared
|
|
1121
1121
|
op << out
|
1122
1122
|
end
|
1123
1123
|
elsif !op.empty?
|
1124
|
-
op << op.
|
1124
|
+
op << op.shift
|
1125
1125
|
elsif flag == :branch
|
1126
1126
|
raise_error 'no branch name'
|
1127
1127
|
end
|
@@ -1265,7 +1265,6 @@ module Squared
|
|
1265
1265
|
end
|
1266
1266
|
when :patch
|
1267
1267
|
cmd << '--patch'
|
1268
|
-
append_pathspec(refs, pass: false)
|
1269
1268
|
when :undo
|
1270
1269
|
cmd << '--hard HEAD@{1}'
|
1271
1270
|
ref = false
|
@@ -1486,12 +1485,12 @@ module Squared
|
|
1486
1485
|
case flag
|
1487
1486
|
when :commit, :'no-commit'
|
1488
1487
|
op = OptionPartition.new(opts, OPT_GIT[:merge], cmd, project: self, no: OPT_GIT[:no][:merge])
|
1489
|
-
raise_error 'no branch/commit' if op.empty?
|
1490
1488
|
op << "--#{flag}" << '--'
|
1491
1489
|
if branch
|
1492
1490
|
op << branch
|
1493
1491
|
op.clear(pass: false)
|
1494
1492
|
else
|
1493
|
+
raise_error 'no branch/commit' if op.empty?
|
1495
1494
|
append_commit(*op.extras)
|
1496
1495
|
end
|
1497
1496
|
else
|
@@ -1813,7 +1812,10 @@ module Squared
|
|
1813
1812
|
from = nil
|
1814
1813
|
banner = nil
|
1815
1814
|
else
|
1816
|
-
|
1815
|
+
if banner
|
1816
|
+
banner = nil unless banner? && !multiple
|
1817
|
+
args = true
|
1818
|
+
end
|
1817
1819
|
if cmd.respond_to?(:done)
|
1818
1820
|
if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) })
|
1819
1821
|
from = :"git:#{from}"
|
@@ -1826,17 +1828,14 @@ module Squared
|
|
1826
1828
|
log&.info cmd
|
1827
1829
|
banner = if banner
|
1828
1830
|
banner = (banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), '')
|
1829
|
-
format_banner(hint ? "#{banner} (#{hint})" : banner
|
1831
|
+
format_banner(hint ? "#{banner} (#{hint})" : banner)
|
1830
1832
|
end
|
1831
1833
|
on :first, from
|
1832
1834
|
begin
|
1833
1835
|
if io
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
banner ? [IO.popen(cmd), banner, from] : IO.popen(cmd)
|
1838
|
-
end
|
1839
|
-
return ret
|
1836
|
+
return `#{cmd}` if stdout
|
1837
|
+
|
1838
|
+
return args ? [IO.popen(cmd), banner || '', from] : IO.popen(cmd)
|
1840
1839
|
elsif stdin? ? sync : stdout
|
1841
1840
|
print_item banner unless multiple
|
1842
1841
|
ret = `#{cmd}`
|
@@ -5,15 +5,17 @@ module Squared
|
|
5
5
|
module Project
|
6
6
|
class Node < Git
|
7
7
|
OPT_NPM = {
|
8
|
-
common: %w[dry-run include-workspace-root workspaces
|
9
|
-
install: %w[prefer-dedupe package-lock-only cpu=b libc=b os=b
|
10
|
-
|
8
|
+
common: %w[dry-run=!? include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
|
9
|
+
install: %w[prefer-dedupe=!? package-lock-only=!? audit=! bin-links=! cpu=b fund=! libc=b os=b
|
10
|
+
package-lock=!].freeze,
|
11
|
+
install_base: %w[ignore-scripts=!? install-links=!? strict-peer-deps=!? include=b omit=b
|
12
|
+
install-strategy=b].freeze,
|
11
13
|
install_no: %w[audit bin-links fund package-lock].freeze,
|
12
|
-
install_as: %w[
|
13
|
-
|
14
|
-
run: %w[foreground-scripts if-present ignore-scripts script-shell=p].freeze,
|
14
|
+
install_as: %w[no-save save-bundle save-dev save-optional save-peer save-prod foreground-scripts=!?
|
15
|
+
g|global=!? S|save=!? E|save-exact=!?].freeze,
|
16
|
+
run: %w[foreground-scripts=!? if-present=!? ignore-scripts=!? script-shell=p].freeze,
|
15
17
|
exec: %w[c|call=q package=b].freeze,
|
16
|
-
pack: %w[json
|
18
|
+
pack: %w[json=!? pack-destination=p].freeze
|
17
19
|
}.freeze
|
18
20
|
OPT_PNPM = {
|
19
21
|
common: %w[aggregate-output color no-color stream use-stderr C|dir=p loglevel=b w|workspace-root].freeze,
|
@@ -670,13 +672,13 @@ module Squared
|
|
670
672
|
if sync
|
671
673
|
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
|
672
674
|
else
|
675
|
+
require 'open3'
|
673
676
|
on :first, from
|
674
677
|
pwd_set(from: from, dryrun: dryrun) do
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
banner: banner)
|
678
|
+
cmd = session_done cmd
|
679
|
+
Open3.popen2e(cmd) do |_, out|
|
680
|
+
write_lines(out, banner: format_banner(cmd),
|
681
|
+
sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:bright_blue), index: 2])
|
680
682
|
end
|
681
683
|
end
|
682
684
|
on :last, from
|
@@ -1025,9 +1027,9 @@ module Squared
|
|
1025
1027
|
|
1026
1028
|
def npmnotice
|
1027
1029
|
[
|
1028
|
-
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:
|
1029
|
-
{ pat: /^(npm )(error)(.*)$/, styles: color(:
|
1030
|
-
{ pat: /^(npm )(notice)(.*)$/, styles: color(:
|
1030
|
+
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:bright_cyan), index: 2 },
|
1031
|
+
{ pat: /^(npm )(error)(.*)$/, styles: color(:bright_red), index: 2 },
|
1032
|
+
{ pat: /^(npm )(notice)(.*)$/, styles: color(:bright_cyan), index: 2 },
|
1031
1033
|
{ pat: /^(npm )(.+)$/, styles: :bold }
|
1032
1034
|
]
|
1033
1035
|
end
|
@@ -37,8 +37,8 @@ module Squared
|
|
37
37
|
common: %w[I|ignore-python no-cache n|non-interactive].freeze,
|
38
38
|
build: %w[C=bm no-clean no-isolation no-sdist no-wheel quiet verbose config-setting=q d|dest=p p|project=p
|
39
39
|
k|skip=b].freeze,
|
40
|
-
publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
|
41
|
-
|
40
|
+
publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
|
41
|
+
i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
|
42
42
|
}.freeze
|
43
43
|
OPT_HATCH = {
|
44
44
|
common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
|
@@ -303,7 +303,7 @@ module Squared
|
|
303
303
|
when 'build'
|
304
304
|
case flag
|
305
305
|
when :poetry
|
306
|
-
next unless poetry
|
306
|
+
next unless build_backend == 'poetry.core.masonry.api'
|
307
307
|
when :pdm
|
308
308
|
next unless build_backend == 'pdm.backend'
|
309
309
|
when :hatch
|
@@ -888,7 +888,7 @@ module Squared
|
|
888
888
|
end
|
889
889
|
|
890
890
|
def poetry?
|
891
|
-
|
891
|
+
dependtype == 1
|
892
892
|
end
|
893
893
|
|
894
894
|
def requirements?
|
@@ -702,6 +702,7 @@ module Squared
|
|
702
702
|
return
|
703
703
|
when :build
|
704
704
|
if op.empty?
|
705
|
+
raise_error('gemspec not found', hint: project) unless gemfile
|
705
706
|
op.add_path(gemfile)
|
706
707
|
else
|
707
708
|
op.add_path(op.shift)
|
@@ -712,7 +713,8 @@ module Squared
|
|
712
713
|
file = path + (if (spec = gemspec)
|
713
714
|
"#{spec.name}-#{spec.version}.gem"
|
714
715
|
else
|
715
|
-
|
716
|
+
gems = Dir.glob(path.join('*.gem')).map { |val| File.basename(val) }
|
717
|
+
choice_index('Select a file', gems, force: true)
|
716
718
|
end)
|
717
719
|
else
|
718
720
|
file = path + op.shift
|
@@ -754,9 +756,8 @@ module Squared
|
|
754
756
|
else
|
755
757
|
op.clear
|
756
758
|
end
|
757
|
-
elsif (n = op.
|
758
|
-
|
759
|
-
name = items.delete_at(n)
|
759
|
+
elsif (n = op.index { |val| val.match?(/(\A|[a-z])@\d/) })
|
760
|
+
name = op.delete_at(n)
|
760
761
|
if (n = name.index('@')) == 0
|
761
762
|
pre = gemname
|
762
763
|
ver = name[1..-1]
|
@@ -765,8 +766,7 @@ module Squared
|
|
765
766
|
ver = name[(n + 1)..-1]
|
766
767
|
end
|
767
768
|
op.adjoin(pre, shell_option('version', ver))
|
768
|
-
.clear
|
769
|
-
.reset
|
769
|
+
.clear
|
770
770
|
elsif flag != :install
|
771
771
|
op.adjoin
|
772
772
|
end
|
@@ -831,8 +831,8 @@ module Squared
|
|
831
831
|
def gemspec
|
832
832
|
return @gemspec unless @gemspec.nil?
|
833
833
|
|
834
|
-
@gemspec = if
|
835
|
-
Gem::Specification.load(
|
834
|
+
@gemspec = if gemfile
|
835
|
+
Gem::Specification.load(gemfile.to_s) rescue false
|
836
836
|
else
|
837
837
|
false
|
838
838
|
end
|
@@ -1037,7 +1037,7 @@ module Squared
|
|
1037
1037
|
return @gemfile unless @gemfile.nil?
|
1038
1038
|
|
1039
1039
|
@gemfile = [project, name].map! { |val| path + "#{val}.gemspec" }
|
1040
|
-
.concat(
|
1040
|
+
.concat(Dir.glob(path.join('*.gemspec')))
|
1041
1041
|
.find { |file| File.exist?(file) } || false
|
1042
1042
|
end
|
1043
1043
|
|
@@ -83,6 +83,7 @@ module Squared
|
|
83
83
|
:pop, :push, :concat, :index, :delete_at, :join, :map, :map!, :select, :select!, :reject, :size
|
84
84
|
|
85
85
|
def_delegator :@extras, :delete, :remove
|
86
|
+
def_delegator :@extras, :delete_at, :remove_at
|
86
87
|
def_delegator :@extras, :delete_if, :remove_if
|
87
88
|
|
88
89
|
def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
|
@@ -107,6 +108,7 @@ module Squared
|
|
107
108
|
i = []
|
108
109
|
f = []
|
109
110
|
si = []
|
111
|
+
bl = []
|
110
112
|
list.flat_map do |val|
|
111
113
|
x, y = val.split('|', 2)
|
112
114
|
if y
|
@@ -141,6 +143,8 @@ module Squared
|
|
141
143
|
si << flag
|
142
144
|
when 'v'
|
143
145
|
@values << Regexp.escape(flag)
|
146
|
+
when '!'
|
147
|
+
bl << flag
|
144
148
|
else
|
145
149
|
next
|
146
150
|
end
|
@@ -180,7 +184,7 @@ module Squared
|
|
180
184
|
add quote_option(key, val, double: qq.include?(key), merge: merge)
|
181
185
|
elsif p.include?(key) && path
|
182
186
|
add quote_option(key, path + val, merge: merge)
|
183
|
-
elsif b.include?(key) || numcheck.call(key, val)
|
187
|
+
elsif b.include?(key) || (bl.include?(key) && %w[true false].include?(val)) || numcheck.call(key, val)
|
184
188
|
add basic_option(key, val, merge: merge)
|
185
189
|
elsif merge
|
186
190
|
add basic_option(key, val, merge: true)
|
@@ -119,7 +119,6 @@ module Squared
|
|
119
119
|
target = branch || manifest
|
120
120
|
stage = nil
|
121
121
|
opts = %w[force rebase detach submodules fail no-update gc]
|
122
|
-
newline = !ARGV.grep(/^repo:/).empty?
|
123
122
|
desc = lambda do |val, alt = nil|
|
124
123
|
if (ver = branch || alt)
|
125
124
|
val = val.sub('{0}', "opts*=#{opts.join(',')}")
|
@@ -170,7 +169,6 @@ module Squared
|
|
170
169
|
val
|
171
170
|
end
|
172
171
|
stage = 'init'
|
173
|
-
puts if newline
|
174
172
|
opts = repo_opts "-u #{u}", "-m #{m}.xml"
|
175
173
|
opts << "-g #{g}" if g
|
176
174
|
opts << '--submodules' if repo_submodules?(args.include?('submodules'))
|
@@ -206,7 +204,6 @@ module Squared
|
|
206
204
|
end
|
207
205
|
opts << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}" unless opts.grep(/^--?j(?:obs)?/).empty?
|
208
206
|
opts << '--fetch-submodules' if repo_submodules?
|
209
|
-
puts unless !newline || stage == 'init'
|
210
207
|
begin
|
211
208
|
repo_run("#{repo_bin} sync #{opts.uniq.join(' ')}", exception: opts.include?('--fail-fast'))
|
212
209
|
rescue Errno::ENOENT => e
|