squared 0.8.3 → 0.8.5
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 +112 -6
- data/README.md +8 -9
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/format.rb +2 -1
- data/lib/squared/common/host.rb +39 -0
- data/lib/squared/common/prompt.rb +4 -3
- data/lib/squared/common/shell.rb +13 -12
- data/lib/squared/common/utils.rb +7 -4
- data/lib/squared/common.rb +1 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +5 -27
- data/lib/squared/workspace/project/base.rb +41 -17
- data/lib/squared/workspace/project/docker.rb +215 -147
- data/lib/squared/workspace/project/git.rb +125 -113
- data/lib/squared/workspace/project/node.rb +69 -36
- data/lib/squared/workspace/project/python.rb +13 -9
- data/lib/squared/workspace/project/ruby.rb +13 -12
- data/lib/squared/workspace/project/support/optionpartition.rb +108 -53
- data/lib/squared/workspace/repo.rb +3 -2
- data/lib/squared/workspace/series.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e486fab218bc18e8b6e3921184c1d4a9aeaf155e2d19f70b62062b279606714d
|
|
4
|
+
data.tar.gz: c5d1cf6cabf110cce2befee1fc6d34dcb9f437d5c84b6dc552bd304b3f7af304
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba4f0d602d818ad424fc9fc940954f1c7a8d4fc138fd98e8ebb6f4b7d98baa45188a3f0476f4a7de0512c60e06d74f965da7f4a54a34cdcda76d7baec525e2d1
|
|
7
|
+
data.tar.gz: 52f518b0aaeb168633399c34f62cf19cb14fc1ed463047cf795b527e82d9439e5c2266c3d0f0709777f6bdafdf40cd88f76bbb118e1236f4b8e8ca9a81741a16
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.5] - 2026-09-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Docker command network action rm was implemented.
|
|
8
|
+
- Git command options were updated to version 2.56.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Node package managers will check for a lock file when in CI.
|
|
13
|
+
- Docker method network param target was renamed to name.
|
|
14
|
+
|
|
15
|
+
## [0.7.12]
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- See `0.4.42`.
|
|
20
|
+
|
|
21
|
+
## [0.6.19]
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- See `0.4.42`.
|
|
26
|
+
|
|
27
|
+
## [0.5.27]
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- See `0.4.42`.
|
|
32
|
+
|
|
33
|
+
## [0.4.42]
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- OptionPartition did not strip pre-existing quotes when parsing options.
|
|
38
|
+
- Node command outdated did not strip styling from semver in package.json.
|
|
39
|
+
- Git command show did not recognize object names.
|
|
40
|
+
- Docker destination mounts that are not absolute are treated as errors.
|
|
41
|
+
- Docker source mounts for any named volumes or images were inoperable.
|
|
42
|
+
|
|
43
|
+
## [0.8.4] - 2026-09-04
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- Common module Host for capabilities was created.
|
|
48
|
+
- OptionPartition can parse option values with a Regexp.
|
|
49
|
+
- OptionPartition can parse option values with a set group.
|
|
50
|
+
- Docker property registry was converted into an accessor.
|
|
51
|
+
- Docker banner arguments [context|registry|tag] were implemented.
|
|
52
|
+
- OptionPartition can parse single flags with a quoted merged value.
|
|
53
|
+
- Docker command image action push is interactive.
|
|
54
|
+
- Docker accessor tag can be initialized through ENV with TAG_${NAME}.
|
|
55
|
+
- OptionPartition can parse option values with an explicit boolean.
|
|
56
|
+
|
|
57
|
+
### Changed
|
|
58
|
+
|
|
59
|
+
- Git command log action view with interactive supports exclusions.
|
|
60
|
+
- OptionPartition static method union returns a copy of original target.
|
|
61
|
+
|
|
62
|
+
## [0.7.11]
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
- Node command package action [approve|deny] is interactive.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- Docker container commands [run|exec] did not sanitize input prompt.
|
|
71
|
+
|
|
72
|
+
## [0.6.18]
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
|
|
76
|
+
- Docker command bake action buildx with first arg "-" inherits base args.
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- Git action grep did not recognize format and max-count.
|
|
81
|
+
|
|
82
|
+
## [0.5.26]
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- Node command nvm did not quote executable path.
|
|
87
|
+
|
|
88
|
+
## [0.4.41]
|
|
89
|
+
|
|
90
|
+
### Added
|
|
91
|
+
|
|
92
|
+
- Common base argument SUCCESS for command confirmation was created.
|
|
93
|
+
|
|
94
|
+
### Changed
|
|
95
|
+
|
|
96
|
+
- Program options prefer using quotes instead of escape.
|
|
97
|
+
- Docker container run arguments with a leading dash are concatenated.
|
|
98
|
+
|
|
99
|
+
### Fixed
|
|
100
|
+
|
|
101
|
+
- OptionPartition static method strip did not parse flags with dashes.
|
|
102
|
+
- Project base method choice_index did not support multiple selections.
|
|
103
|
+
|
|
3
104
|
## [0.8.3] - 2026-08-18
|
|
4
105
|
|
|
5
106
|
### Added
|
|
@@ -28,10 +129,6 @@
|
|
|
28
129
|
|
|
29
130
|
## [0.6.17]
|
|
30
131
|
|
|
31
|
-
### Added
|
|
32
|
-
|
|
33
|
-
- NPM command install can bypass engines with ENV and engine-strict=false.
|
|
34
|
-
|
|
35
132
|
### Fixed
|
|
36
133
|
|
|
37
134
|
- Ruby command gem action push interactive file selector did nothing.
|
|
@@ -54,7 +151,6 @@
|
|
|
54
151
|
### Changed
|
|
55
152
|
|
|
56
153
|
- OptionPartition method uniq! parameter pass was converted into keyword.
|
|
57
|
-
- Project global ENV for BANNER and STRICT can accept boolean values.
|
|
58
154
|
- Series method exclude? parameter empty was converted into keyword.
|
|
59
155
|
|
|
60
156
|
## [0.7.9] - 2026-07-04
|
|
@@ -562,7 +658,7 @@
|
|
|
562
658
|
|
|
563
659
|
### Fixed
|
|
564
660
|
|
|
565
|
-
- See `0.
|
|
661
|
+
- See `0.4.32`.
|
|
566
662
|
|
|
567
663
|
## [0.4.32]
|
|
568
664
|
|
|
@@ -2028,10 +2124,14 @@
|
|
|
2028
2124
|
|
|
2029
2125
|
- Changelog was created.
|
|
2030
2126
|
|
|
2127
|
+
[0.8.5]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.5
|
|
2128
|
+
[0.8.4]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.4
|
|
2031
2129
|
[0.8.3]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.3
|
|
2032
2130
|
[0.8.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.2
|
|
2033
2131
|
[0.8.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.1
|
|
2034
2132
|
[0.8.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.0
|
|
2133
|
+
[0.7.12]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.12
|
|
2134
|
+
[0.7.11]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.11
|
|
2035
2135
|
[0.7.10]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.10
|
|
2036
2136
|
[0.7.9]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.9
|
|
2037
2137
|
[0.7.8]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.8
|
|
@@ -2043,6 +2143,8 @@
|
|
|
2043
2143
|
[0.7.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.2
|
|
2044
2144
|
[0.7.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.1
|
|
2045
2145
|
[0.7.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.0
|
|
2146
|
+
[0.6.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.19
|
|
2147
|
+
[0.6.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.18
|
|
2046
2148
|
[0.6.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.17
|
|
2047
2149
|
[0.6.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.16
|
|
2048
2150
|
[0.6.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.15
|
|
@@ -2061,6 +2163,8 @@
|
|
|
2061
2163
|
[0.6.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.2
|
|
2062
2164
|
[0.6.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.1
|
|
2063
2165
|
[0.6.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.0
|
|
2166
|
+
[0.5.27]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.27
|
|
2167
|
+
[0.5.26]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.26
|
|
2064
2168
|
[0.5.25]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.25
|
|
2065
2169
|
[0.5.24]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.24
|
|
2066
2170
|
[0.5.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.23
|
|
@@ -2087,6 +2191,8 @@
|
|
|
2087
2191
|
[0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
|
|
2088
2192
|
[0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
|
|
2089
2193
|
[0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
|
|
2194
|
+
[0.4.42]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.42
|
|
2195
|
+
[0.4.41]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.41
|
|
2090
2196
|
[0.4.40]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.40
|
|
2091
2197
|
[0.4.39]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.39
|
|
2092
2198
|
[0.4.38]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.38
|
data/README.md
CHANGED
|
@@ -678,7 +678,7 @@ LOG_LEVEL # See gem "logger"
|
|
|
678
678
|
|
|
679
679
|
### Git
|
|
680
680
|
|
|
681
|
-
* Version: [2.
|
|
681
|
+
* Version: [2.56](https://github.com/git/git/blob/v2.56.0/Documentation/RelNotes/2.56.0.adoc)
|
|
682
682
|
|
|
683
683
|
```sh
|
|
684
684
|
GIT_OPTIONS=q,strategy=ort # all
|
|
@@ -693,11 +693,9 @@ GIT_COUNT=50 # list display limit
|
|
|
693
693
|
| :--------- | :---------------- | :------------------------------------------------------------------ |
|
|
694
694
|
| branch | create | TRACK=0,1,s F|FORCE |
|
|
695
695
|
| branch | move copy | F|FORCE |
|
|
696
|
-
| branch | delete | COUNT=n |
|
|
697
696
|
| branch | global | SYNC |
|
|
698
|
-
| checkout | branch | DETACH TRACK=s
|
|
697
|
+
| checkout | branch | D|DETACH TRACK=s |
|
|
699
698
|
| checkout | detach | REFLOG=1 |
|
|
700
|
-
| checkout | track | COUNT=n |
|
|
701
699
|
| checkout | global path | HEAD=s PATHSPEC=s |
|
|
702
700
|
| checkout | * | F|FORCE MERGE |
|
|
703
701
|
| clone | * | DEPTH=n ORIGIN=s BRANCH=s REVISION=s BARE=1 LOCAL=0,1 |
|
|
@@ -721,10 +719,10 @@ GIT_COUNT=50 # list display limit
|
|
|
721
719
|
| rebase | onto | INTERACTIVE I HEAD=s |
|
|
722
720
|
| reset | mode (mixed) | N REFRESH=0 |
|
|
723
721
|
| reset | index | PATHSPEC=s |
|
|
724
|
-
| reset | commit |
|
|
722
|
+
| reset | commit | REFLOG=1 |
|
|
725
723
|
| reset | -commit | HEAD=s |
|
|
726
724
|
| restore | * | PATHSPEC=s |
|
|
727
|
-
| revbuild | global
|
|
725
|
+
| revbuild | global (status) | UNTRACKED_FILES=s IGNORE_SUBMODULES=s IGNORED=s |
|
|
728
726
|
| stash | push | PATHSPEC=s |
|
|
729
727
|
| stash | global | ALL=0,1 KEEP_INDEX=0,1 INCLUDE_UNTRACKED=0,1 STAGED=0,1 M|MESSAGE=s |
|
|
730
728
|
| status | global | BRANCH LONG IGNORE_SUBMODULES=s,0-3 PATHSPEC=s |
|
|
@@ -732,9 +730,7 @@ GIT_COUNT=50 # list display limit
|
|
|
732
730
|
| switch | detach | REFLOG=1 |
|
|
733
731
|
| switch | -detach | HEAD=s |
|
|
734
732
|
| switch | * | F|FORCE |
|
|
735
|
-
| tag | add
|
|
736
|
-
| tag | sign | F|FORCE HEAD=s M|MESSAGE=s TRAILER=s |
|
|
737
|
-
| tag | delete | COUNT=n |
|
|
733
|
+
| tag | add sign | F|FORCE HEAD=s M|MESSAGE=s TRAILER=s |
|
|
738
734
|
| rev | commit branch | HEAD=s |
|
|
739
735
|
|
|
740
736
|
### Docker
|
|
@@ -749,6 +745,8 @@ DOCKER_TAG_${NAME}=v0.1.0 # project only (override)
|
|
|
749
745
|
DOCKER_ALL=1 # list every image/container
|
|
750
746
|
DOCKER_Y=1 # confirm all
|
|
751
747
|
|
|
748
|
+
TAG_${NAME}=1.0.0 # initialize
|
|
749
|
+
|
|
752
750
|
BUILD_SQUARED_OPTS="NODE_TAG=24 RUBY_VERSION=4.0.0" DOCKER_SQUARED_OPTS="--no-cache --label=v1" rake squared:build
|
|
753
751
|
docker build --no-cache --label=v1 --build-arg="NODE_TAG=24" --build-arg="RUBY_VERSION=4.0.0" .
|
|
754
752
|
```
|
|
@@ -761,6 +759,7 @@ docker build --no-cache --label=v1 --build-arg="NODE_TAG=24" --build-arg="RUBY_V
|
|
|
761
759
|
| compose | run | VERSION=s |
|
|
762
760
|
| compose | publish | TAG=s REGISTRY=s |
|
|
763
761
|
| container | commit | REGISTRY=s PLATFORM=s DISABLE_CONTENT_TRUST=0,1 |
|
|
762
|
+
| container | run | ENTRYPOINT=s |
|
|
764
763
|
| container | -run -create -exec | ALL=1 FILTER=s |
|
|
765
764
|
| | -update -commit | |
|
|
766
765
|
| image | rm | Y=1 |
|
data/lib/squared/common/base.rb
CHANGED
|
@@ -89,7 +89,8 @@ module Squared
|
|
|
89
89
|
end
|
|
90
90
|
else
|
|
91
91
|
t = type.to_sym
|
|
92
|
-
|
|
92
|
+
c = __get__(:colors)[t] || __get__(:colors)[t.to_s.sub('bright_', '').to_sym]
|
|
93
|
+
if c
|
|
93
94
|
if index == -1
|
|
94
95
|
s = wrap.call(s, [c])
|
|
95
96
|
else
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rake'
|
|
4
|
+
|
|
5
|
+
module Squared
|
|
6
|
+
module Common
|
|
7
|
+
module Host
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def windows?
|
|
11
|
+
!!Rake::Win32.windows?
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def mri?
|
|
15
|
+
RUBY_ENGINE == 'ruby'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def docker?
|
|
19
|
+
!Dir['/.dockerenv', '/docker-*.{sh,d}'].empty?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ci?
|
|
23
|
+
ENV['CI'] == 'true' || ENV.key?('BUILD_NUMBER')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def powershell?
|
|
27
|
+
return true if ENV['SHELL']&.end_with?(File.join('', 'pwsh'))
|
|
28
|
+
return false unless windows?
|
|
29
|
+
|
|
30
|
+
case ENV['TERM_PROGRAM']
|
|
31
|
+
when 'powershell.exe', 'vscode'
|
|
32
|
+
true
|
|
33
|
+
else
|
|
34
|
+
ENV.fetch('PSModulePath', '').split(';', 2).size > 1
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -57,6 +57,7 @@ module Squared
|
|
|
57
57
|
def choice(msg, list = nil, min: 1, max: 1, multiple: false, index: false, grep: nil, border: nil, auto: true,
|
|
58
58
|
force: true, attempts: 3, timeout: 0, empty: nil)
|
|
59
59
|
require 'timeout'
|
|
60
|
+
multiple = Array(multiple) if multiple.is_a?(::Numeric)
|
|
60
61
|
if list
|
|
61
62
|
grep &&= Array(grep).map { |val| Regexp.new(val) }
|
|
62
63
|
items = list.each_with_object([]) do |val, out|
|
|
@@ -81,7 +82,7 @@ module Squared
|
|
|
81
82
|
puts print_footer(border: border)
|
|
82
83
|
end
|
|
83
84
|
msg = "#{msg + (force ? ':' : '?')} [#{min}-#{max}#{if (n = multiple)
|
|
84
|
-
"|,#{n.is_a?(::
|
|
85
|
+
"|,#{n.is_a?(::Array) ? "{#{n.join(',')}}" : '*'}"
|
|
85
86
|
end}] "
|
|
86
87
|
end
|
|
87
88
|
end
|
|
@@ -110,7 +111,7 @@ module Squared
|
|
|
110
111
|
unless k.include?(nil)
|
|
111
112
|
k.uniq!
|
|
112
113
|
k.sort!
|
|
113
|
-
unless multiple.is_a?(::
|
|
114
|
+
unless multiple.is_a?(::Array) && !multiple.include?(k.size)
|
|
114
115
|
return index || !items ? k : k.map { |i| items[i.pred] }
|
|
115
116
|
end
|
|
116
117
|
end
|
|
@@ -156,7 +157,7 @@ module Squared
|
|
|
156
157
|
[multiline || (force ? ':' : '?'), '']
|
|
157
158
|
end
|
|
158
159
|
end} "
|
|
159
|
-
ret =
|
|
160
|
+
ret = read.call.to_s.strip
|
|
160
161
|
multiline.each { |val| break if ret.delete_suffix!(val.to_s) } if multiline.is_a?(::Enumerable)
|
|
161
162
|
exit 1 if force && ret.empty?
|
|
162
163
|
ret
|
data/lib/squared/common/shell.rb
CHANGED
|
@@ -41,12 +41,12 @@ module Squared
|
|
|
41
41
|
|
|
42
42
|
"#{$1}=%s" % if $2.include?(' ')
|
|
43
43
|
shell_quote($2, option: false)
|
|
44
|
-
elsif
|
|
44
|
+
elsif windows?
|
|
45
45
|
$2
|
|
46
46
|
else
|
|
47
47
|
Shellwords.escape($2)
|
|
48
48
|
end
|
|
49
|
-
elsif
|
|
49
|
+
elsif windows?
|
|
50
50
|
quote ? shell_quote(val, force: force, double: double) : val
|
|
51
51
|
else
|
|
52
52
|
val.empty? ? '' : Shellwords.escape(val)
|
|
@@ -61,7 +61,7 @@ module Squared
|
|
|
61
61
|
if val =~ QUOTE_VALUE
|
|
62
62
|
if pass == '"' || pass == "'"
|
|
63
63
|
return val if pass == $1
|
|
64
|
-
elsif pass || ($1 == '"' &&
|
|
64
|
+
elsif pass || ($1 == '"' && windows? && val.match?(/([#{File::SEPARATOR} ]|\\")/o))
|
|
65
65
|
return val
|
|
66
66
|
end
|
|
67
67
|
case preserve
|
|
@@ -74,7 +74,7 @@ module Squared
|
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
q = -> { (base || val).gsub("'\\\\''", "'") }
|
|
77
|
-
if double ||
|
|
77
|
+
if double || windows? || (ARG[:QUOTE] == '"' && !override)
|
|
78
78
|
"\"#{q.call.gsub(/(?<!\\)"/, '\\"')}\""
|
|
79
79
|
else
|
|
80
80
|
"'#{q.call.gsub("'", "'\\\\''")}'"
|
|
@@ -82,7 +82,7 @@ module Squared
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def shell_option(flag, val = nil, sep: '=', escape: true, quote: true, force: true, double: false, merge: false,
|
|
85
|
-
switch: nil, override: false)
|
|
85
|
+
switch: nil, explicit: false, override: false)
|
|
86
86
|
flag = flag.to_s
|
|
87
87
|
if flag =~ QUOTE_VALUE
|
|
88
88
|
double = $1 == '"'
|
|
@@ -91,18 +91,15 @@ module Squared
|
|
|
91
91
|
override = true
|
|
92
92
|
end
|
|
93
93
|
sep = unless flag.empty?
|
|
94
|
+
single = merge ? '' : explicit.is_a?(::String) ? explicit : ' '
|
|
94
95
|
if flag[0] == '-'
|
|
95
|
-
|
|
96
|
-
sep
|
|
97
|
-
else
|
|
98
|
-
merge ? '' : ' '
|
|
99
|
-
end
|
|
96
|
+
flag[1] == '-' ? sep : single
|
|
100
97
|
elsif switch
|
|
101
98
|
pre = switch unless flag.start_with?(switch)
|
|
102
99
|
merge ? '' : sep
|
|
103
100
|
elsif flag.size == 1
|
|
104
101
|
pre = '-'
|
|
105
|
-
|
|
102
|
+
single
|
|
106
103
|
else
|
|
107
104
|
pre = '--'
|
|
108
105
|
sep
|
|
@@ -164,7 +161,7 @@ module Squared
|
|
|
164
161
|
def shell_bin(name, env: true)
|
|
165
162
|
path = defined?(PATH) ? PATH : {}
|
|
166
163
|
key = name.to_s.upcase
|
|
167
|
-
key = File.basename(key, '.*') if
|
|
164
|
+
key = File.basename(key, '.*') if windows?
|
|
168
165
|
shell_quote((env && ENV["PATH_#{key}"]) || path[key] || path[key.to_sym] || path[key = key.downcase] ||
|
|
169
166
|
path[key.to_sym] || name, option: false, force: false, double: true)
|
|
170
167
|
end
|
|
@@ -187,6 +184,10 @@ module Squared
|
|
|
187
184
|
def basic_option(flag, val, **kwargs)
|
|
188
185
|
shell_option(flag, val, escape: false, force: false, **kwargs)
|
|
189
186
|
end
|
|
187
|
+
|
|
188
|
+
def windows?
|
|
189
|
+
!!Rake::Win32.windows?
|
|
190
|
+
end
|
|
190
191
|
end
|
|
191
192
|
end
|
|
192
193
|
end
|
data/lib/squared/common/utils.rb
CHANGED
|
@@ -105,18 +105,21 @@ module Squared
|
|
|
105
105
|
time << "#{d}d"
|
|
106
106
|
epoch -= d * dd
|
|
107
107
|
end
|
|
108
|
-
|
|
108
|
+
h = epoch / hh
|
|
109
|
+
if h > 0
|
|
109
110
|
time << (clock ? h.to_s : "#{h}h")
|
|
110
111
|
epoch -= h * hh
|
|
111
112
|
end
|
|
112
|
-
|
|
113
|
+
m = epoch / mm
|
|
114
|
+
if m > 0
|
|
113
115
|
time << (clock ? m.to_s.rjust(2, '0') : "#{m}m")
|
|
114
116
|
epoch -= m * mm
|
|
115
117
|
elsif clock
|
|
116
118
|
time << '00'
|
|
117
119
|
end
|
|
118
120
|
unless hm
|
|
119
|
-
|
|
121
|
+
s = epoch / ss
|
|
122
|
+
if s > 0
|
|
120
123
|
time << (clock ? s.to_s.rjust(2, '0') : "#{s}s")
|
|
121
124
|
epoch -= s * ss
|
|
122
125
|
elsif clock
|
|
@@ -144,7 +147,7 @@ module Squared
|
|
|
144
147
|
end
|
|
145
148
|
|
|
146
149
|
def env_key(*val)
|
|
147
|
-
val.join('_').gsub(/\W+/, '_').upcase
|
|
150
|
+
val.join('_').sub(/\A\d+\W*/, '__').gsub(/\W+/, '_').upcase
|
|
148
151
|
end
|
|
149
152
|
|
|
150
153
|
def env_bool(key, default = false, index: false, **kwargs)
|
data/lib/squared/common.rb
CHANGED
data/lib/squared/version.rb
CHANGED
|
@@ -5,6 +5,7 @@ module Squared
|
|
|
5
5
|
class Application
|
|
6
6
|
include Enumerable
|
|
7
7
|
include Common::Format
|
|
8
|
+
include Host
|
|
8
9
|
include Utils
|
|
9
10
|
include Rake::DSL
|
|
10
11
|
|
|
@@ -13,8 +14,8 @@ module Squared
|
|
|
13
14
|
|
|
14
15
|
class << self
|
|
15
16
|
def implement(*objs, base: nil)
|
|
16
|
-
objs.each_with_index do |obj,
|
|
17
|
-
if base &&
|
|
17
|
+
objs.each_with_index do |obj, i|
|
|
18
|
+
if base && i == 0
|
|
18
19
|
case base
|
|
19
20
|
when 0, true
|
|
20
21
|
@kind_extend[0] = obj
|
|
@@ -215,7 +216,7 @@ module Squared
|
|
|
215
216
|
end
|
|
216
217
|
raise 'method not found'
|
|
217
218
|
rescue => e
|
|
218
|
-
warn
|
|
219
|
+
warn log_warn(e, subject: main, hint: hint || args)
|
|
219
220
|
end
|
|
220
221
|
end
|
|
221
222
|
@group = nil
|
|
@@ -740,30 +741,6 @@ module Squared
|
|
|
740
741
|
!!find(home)&.enabled?
|
|
741
742
|
end
|
|
742
743
|
|
|
743
|
-
def windows?
|
|
744
|
-
Rake::Win32.windows?
|
|
745
|
-
end
|
|
746
|
-
|
|
747
|
-
def mri?
|
|
748
|
-
RUBY_ENGINE == 'ruby'
|
|
749
|
-
end
|
|
750
|
-
|
|
751
|
-
def docker?
|
|
752
|
-
!Dir['/.dockerenv', '/docker-*.{sh,d}'].empty?
|
|
753
|
-
end
|
|
754
|
-
|
|
755
|
-
def powershell?
|
|
756
|
-
return true if ENV['SHELL']&.end_with?(File.join('', 'pwsh'))
|
|
757
|
-
return false unless windows?
|
|
758
|
-
|
|
759
|
-
case ENV['TERM_PROGRAM']
|
|
760
|
-
when 'powershell.exe', 'vscode'
|
|
761
|
-
true
|
|
762
|
-
else
|
|
763
|
-
ENV.fetch('PSModulePath', '').split(';', 2).size > 1
|
|
764
|
-
end
|
|
765
|
-
end
|
|
766
|
-
|
|
767
744
|
def rootpath(*args)
|
|
768
745
|
root.join(*args)
|
|
769
746
|
end
|
|
@@ -797,6 +774,7 @@ module Squared
|
|
|
797
774
|
end
|
|
798
775
|
|
|
799
776
|
public :task_join
|
|
777
|
+
public(*Host.private_instance_methods(false))
|
|
800
778
|
|
|
801
779
|
private
|
|
802
780
|
|