squared 0.8.2 → 0.8.4
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 +111 -0
- data/README.md +10 -10
- data/lib/squared/common/base.rb +8 -0
- data/lib/squared/common/format.rb +2 -1
- data/lib/squared/common/host.rb +35 -0
- data/lib/squared/common/prompt.rb +11 -6
- 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/config.rb +1 -2
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +5 -27
- data/lib/squared/workspace/project/base.rb +59 -19
- data/lib/squared/workspace/project/docker.rb +180 -126
- data/lib/squared/workspace/project/git.rb +363 -174
- data/lib/squared/workspace/project/node.rb +53 -22
- data/lib/squared/workspace/project/python.rb +52 -35
- data/lib/squared/workspace/project/ruby.rb +24 -25
- data/lib/squared/workspace/project/support/optionpartition.rb +121 -57
- data/lib/squared/workspace/repo.rb +5 -7
- 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: 8864164b082f5ec20e4e23ec0cea81a0d2ad0cde6977a0d484b113e72058421a
|
|
4
|
+
data.tar.gz: 2b46eca82d45c97c5a5e3ee5881e40429967916e2d569a6cf16271a0d0851a94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d03eca41b747dc5fe16d9767870b83733cf475e60df90358631aed94fe4fa1dbc07b00fe6bfea7e845d9b6cf361e028504c3e6302e17564fcbad5e5c3ea7a80
|
|
7
|
+
data.tar.gz: 20e7c2931780199d66ac670a4fa5b74e6a3a2b71215b1edb32cd48d0c1ca0c0622ee7bdabca21291d10add12231540092936f1e9aa3ffd8f065170ad3c65630f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,107 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.4] - 2026-09-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Common module Host for capabilities was created.
|
|
8
|
+
- OptionPartition can parse option values with a Regexp.
|
|
9
|
+
- OptionPartition can parse option values with a set group.
|
|
10
|
+
- Docker property registry was converted into an accessor.
|
|
11
|
+
- Docker banner arguments [context|registry|tag] were implemented.
|
|
12
|
+
- OptionPartition can parse single flags with a quoted merged value.
|
|
13
|
+
- Docker command image action push is interactive.
|
|
14
|
+
- Docker accessor tag can be initialized through ENV with TAG_${NAME}.
|
|
15
|
+
- OptionPartition can parse option values with an explicit boolean.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Git command log action view with interactive supports exclusions.
|
|
20
|
+
- OptionPartition static method union returns a copy of original target.
|
|
21
|
+
|
|
22
|
+
## [0.7.11]
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Node command package action [approve|deny] is interactive.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Docker container commands [run|exec] did not sanitize input prompt.
|
|
31
|
+
|
|
32
|
+
## [0.6.18]
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Docker command bake action buildx with first arg "-" inherits base args.
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- Git action grep did not recognize format and max-count.
|
|
41
|
+
- Node command nvm did not quote executable path.
|
|
42
|
+
|
|
43
|
+
## [0.5.26]
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- Node command nvm did not quote executable path.
|
|
48
|
+
|
|
49
|
+
## [0.4.41]
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- Common base argument SUCCESS for command confirmation was created.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Program options prefer using quotes instead of escape.
|
|
58
|
+
- Docker container run arguments with a leading dash are concatenated.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- Common prompt method choice did not grep list items.
|
|
63
|
+
- OptionPartition static method strip did not parse flags with dashes.
|
|
64
|
+
- Project base method choice_index did not support multiple selections.
|
|
65
|
+
|
|
66
|
+
## [0.8.3] - 2026-08-18
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- Docker command options were updated to 29.6.
|
|
71
|
+
- Git command clone was implemented.
|
|
72
|
+
- Docker command [container|compose] action logs was implemented.
|
|
73
|
+
- Git command [refs|files] action remote is interactive.
|
|
74
|
+
- Git command push was implemented.
|
|
75
|
+
- Git command commit action head was implemented.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- Python virtual environment will use a detected package manager.
|
|
80
|
+
- Git command argument ref was renamed commit with interactive.
|
|
81
|
+
|
|
82
|
+
### Fixed
|
|
83
|
+
|
|
84
|
+
- Common prompt method choice did not grep list items.
|
|
85
|
+
|
|
86
|
+
## [0.7.10] - 2026-08-06
|
|
87
|
+
|
|
88
|
+
### Fixed
|
|
89
|
+
|
|
90
|
+
- See `0.6.17`.
|
|
91
|
+
|
|
92
|
+
## [0.6.17]
|
|
93
|
+
|
|
94
|
+
### Fixed
|
|
95
|
+
|
|
96
|
+
- Ruby command gem action push interactive file selector did nothing.
|
|
97
|
+
- Git choice prompt did not permit optional empty values.
|
|
98
|
+
|
|
99
|
+
## [0.4.40]
|
|
100
|
+
|
|
101
|
+
### Changed
|
|
102
|
+
|
|
103
|
+
- Series method exclude? was made compatible with v0.8 signature.
|
|
104
|
+
|
|
3
105
|
## [0.8.2] - 2026-07-05
|
|
4
106
|
|
|
5
107
|
### Added
|
|
@@ -1985,9 +2087,13 @@
|
|
|
1985
2087
|
|
|
1986
2088
|
- Changelog was created.
|
|
1987
2089
|
|
|
2090
|
+
[0.8.4]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.4
|
|
2091
|
+
[0.8.3]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.3
|
|
1988
2092
|
[0.8.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.2
|
|
1989
2093
|
[0.8.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.1
|
|
1990
2094
|
[0.8.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.8.0
|
|
2095
|
+
[0.7.11]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.11
|
|
2096
|
+
[0.7.10]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.10
|
|
1991
2097
|
[0.7.9]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.9
|
|
1992
2098
|
[0.7.8]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.8
|
|
1993
2099
|
[0.7.7]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.7
|
|
@@ -1998,6 +2104,8 @@
|
|
|
1998
2104
|
[0.7.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.2
|
|
1999
2105
|
[0.7.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.1
|
|
2000
2106
|
[0.7.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.7.0
|
|
2107
|
+
[0.6.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.18
|
|
2108
|
+
[0.6.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.17
|
|
2001
2109
|
[0.6.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.16
|
|
2002
2110
|
[0.6.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.15
|
|
2003
2111
|
[0.6.14]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.14
|
|
@@ -2015,6 +2123,7 @@
|
|
|
2015
2123
|
[0.6.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.2
|
|
2016
2124
|
[0.6.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.1
|
|
2017
2125
|
[0.6.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.0
|
|
2126
|
+
[0.5.26]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.26
|
|
2018
2127
|
[0.5.25]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.25
|
|
2019
2128
|
[0.5.24]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.24
|
|
2020
2129
|
[0.5.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.23
|
|
@@ -2041,6 +2150,8 @@
|
|
|
2041
2150
|
[0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
|
|
2042
2151
|
[0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
|
|
2043
2152
|
[0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
|
|
2153
|
+
[0.4.41]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.41
|
|
2154
|
+
[0.4.40]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.40
|
|
2044
2155
|
[0.4.39]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.39
|
|
2045
2156
|
[0.4.38]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.38
|
|
2046
2157
|
[0.4.37]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.37
|
data/README.md
CHANGED
|
@@ -548,6 +548,7 @@ Most project classes will inherit from `Git` which enables these tasks:
|
|
|
548
548
|
| log | log | view between contain |
|
|
549
549
|
| merge | merge | commit no-commit send |
|
|
550
550
|
| pull | pull | origin remote all |
|
|
551
|
+
| push | push | origin remote commit all tags |
|
|
551
552
|
| range-diff | range-diff | view between contain |
|
|
552
553
|
| rebase | rebase | branch onto send |
|
|
553
554
|
| remote | remote | add select |
|
|
@@ -692,17 +693,15 @@ GIT_COUNT=50 # list display limit
|
|
|
692
693
|
| :--------- | :---------------- | :------------------------------------------------------------------ |
|
|
693
694
|
| branch | create | TRACK=0,1,s F|FORCE |
|
|
694
695
|
| branch | move copy | F|FORCE |
|
|
695
|
-
| branch | delete | COUNT=n |
|
|
696
696
|
| branch | global | SYNC |
|
|
697
|
-
| checkout | branch | DETACH TRACK=s
|
|
697
|
+
| checkout | branch | D|DETACH TRACK=s |
|
|
698
698
|
| checkout | detach | REFLOG=1 |
|
|
699
|
-
| checkout | track | COUNT=n |
|
|
700
699
|
| checkout | global path | HEAD=s PATHSPEC=s |
|
|
701
700
|
| checkout | * | F|FORCE MERGE |
|
|
702
701
|
| clone | * | DEPTH=n ORIGIN=s BRANCH=s REVISION=s BARE=1 LOCAL=0,1 |
|
|
703
702
|
| | | SINGLE_BRANCH=0,1 NO_CHECKOUT=1 NO_TAGS=1 QUIET=1 |
|
|
704
703
|
| commit | amend | F|FORCE |
|
|
705
|
-
| commit | * | UPSTREAM=s DRY_RUN EDIT=0 M|MESSAGE=s
|
|
704
|
+
| commit | * | UPSTREAM|ORIGIN=s DRY_RUN EDIT=0 M|MESSAGE=s |
|
|
706
705
|
| diff | head branch | INDEX=n |
|
|
707
706
|
| diff | * | PATHSPEC=s |
|
|
708
707
|
| fetch | -remote | ALL |
|
|
@@ -714,15 +713,16 @@ GIT_COUNT=50 # list display limit
|
|
|
714
713
|
| pull | -remote | REBASE=0,1 ALL |
|
|
715
714
|
| pull | all | FF_ONLY=0 |
|
|
716
715
|
| pull | * | AUTOSTASH F|FORCE RECURSE_SUBMODULES=0,1,s |
|
|
716
|
+
| push | all,tags | ORIGIN=s |
|
|
717
717
|
| range-diff | * | PATHSPEC=s |
|
|
718
718
|
| rebase | branch | HEAD=s |
|
|
719
719
|
| rebase | onto | INTERACTIVE I HEAD=s |
|
|
720
720
|
| reset | mode (mixed) | N REFRESH=0 |
|
|
721
721
|
| reset | index | PATHSPEC=s |
|
|
722
|
-
| reset | commit |
|
|
722
|
+
| reset | commit | REFLOG=1 |
|
|
723
723
|
| reset | -commit | HEAD=s |
|
|
724
724
|
| restore | * | PATHSPEC=s |
|
|
725
|
-
| revbuild | global
|
|
725
|
+
| revbuild | global (status) | UNTRACKED_FILES=s IGNORE_SUBMODULES=s IGNORED=s |
|
|
726
726
|
| stash | push | PATHSPEC=s |
|
|
727
727
|
| stash | global | ALL=0,1 KEEP_INDEX=0,1 INCLUDE_UNTRACKED=0,1 STAGED=0,1 M|MESSAGE=s |
|
|
728
728
|
| status | global | BRANCH LONG IGNORE_SUBMODULES=s,0-3 PATHSPEC=s |
|
|
@@ -730,14 +730,12 @@ GIT_COUNT=50 # list display limit
|
|
|
730
730
|
| switch | detach | REFLOG=1 |
|
|
731
731
|
| switch | -detach | HEAD=s |
|
|
732
732
|
| switch | * | F|FORCE |
|
|
733
|
-
| tag | add
|
|
734
|
-
| tag | sign | F|FORCE HEAD=s M|MESSAGE=s TRAILER=s |
|
|
735
|
-
| tag | delete | COUNT=n |
|
|
733
|
+
| tag | add sign | F|FORCE HEAD=s M|MESSAGE=s TRAILER=s |
|
|
736
734
|
| rev | commit branch | HEAD=s |
|
|
737
735
|
|
|
738
736
|
### Docker
|
|
739
737
|
|
|
740
|
-
* Version: [29.
|
|
738
|
+
* Version: [29.6](https://docs.docker.com/engine/release-notes/29)
|
|
741
739
|
|
|
742
740
|
```sh
|
|
743
741
|
DOCKER_OPTIONS=q,no-cache # all
|
|
@@ -747,6 +745,8 @@ DOCKER_TAG_${NAME}=v0.1.0 # project only (override)
|
|
|
747
745
|
DOCKER_ALL=1 # list every image/container
|
|
748
746
|
DOCKER_Y=1 # confirm all
|
|
749
747
|
|
|
748
|
+
TAG_${NAME}=1.0.0 # initialize
|
|
749
|
+
|
|
750
750
|
BUILD_SQUARED_OPTS="NODE_TAG=24 RUBY_VERSION=4.0.0" DOCKER_SQUARED_OPTS="--no-cache --label=v1" rake squared:build
|
|
751
751
|
docker build --no-cache --label=v1 --build-arg="NODE_TAG=24" --build-arg="RUBY_VERSION=4.0.0" .
|
|
752
752
|
```
|
data/lib/squared/common/base.rb
CHANGED
|
@@ -15,6 +15,7 @@ module Squared
|
|
|
15
15
|
CHOICE: 25,
|
|
16
16
|
QUOTE: "'",
|
|
17
17
|
SPACE: ' => ',
|
|
18
|
+
SUCCESS: 'Success',
|
|
18
19
|
GRAPH: %w[| - | \\ -].freeze,
|
|
19
20
|
BORDER: %w[| - - - - - | | - -].freeze,
|
|
20
21
|
VIEW: 'view',
|
|
@@ -91,6 +92,13 @@ module Squared
|
|
|
91
92
|
VAR[key.is_a?(::String) ? key.to_sym : key] = val
|
|
92
93
|
end
|
|
93
94
|
|
|
95
|
+
def __arg__(key, name = nil, &blk)
|
|
96
|
+
ret = ARG[key.to_sym]
|
|
97
|
+
return ret unless name && ret.is_a?(::Hash)
|
|
98
|
+
|
|
99
|
+
ret[name = name.downcase] || (block_given? ? ret.fetch(name.to_sym, &blk) : ret[name.to_sym])
|
|
100
|
+
end
|
|
101
|
+
|
|
94
102
|
def __freeze__
|
|
95
103
|
PATH.freeze
|
|
96
104
|
ARG.freeze
|
|
@@ -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,35 @@
|
|
|
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 powershell?
|
|
23
|
+
return true if ENV['SHELL']&.end_with?(File.join('', 'pwsh'))
|
|
24
|
+
return false unless windows?
|
|
25
|
+
|
|
26
|
+
case ENV['TERM_PROGRAM']
|
|
27
|
+
when 'powershell.exe', 'vscode'
|
|
28
|
+
true
|
|
29
|
+
else
|
|
30
|
+
ENV.fetch('PSModulePath', '').split(';', 2).size > 1
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -55,19 +55,24 @@ module Squared
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def choice(msg, list = nil, min: 1, max: 1, multiple: false, index: false, grep: nil, border: nil, auto: true,
|
|
58
|
-
force: true, attempts: 3, timeout: 0)
|
|
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|
|
|
63
|
-
next if grep&.none? { |pat| pat.match?(
|
|
64
|
+
next if grep&.none? { |pat| pat.match?(val) }
|
|
64
65
|
|
|
65
66
|
out << val.to_s.chomp
|
|
66
67
|
puts '%2d. %s' % [out.size, val]
|
|
67
68
|
end
|
|
68
69
|
max = items.size
|
|
69
|
-
|
|
70
|
+
if max == 0
|
|
71
|
+
raise ArgumentError, 'empty selection list' unless empty
|
|
70
72
|
|
|
73
|
+
puts empty
|
|
74
|
+
exit 1
|
|
75
|
+
end
|
|
71
76
|
min = grep ? 1 : [min, max].min
|
|
72
77
|
if auto
|
|
73
78
|
auto.times { puts } if auto.is_a?(::Numeric)
|
|
@@ -77,11 +82,11 @@ module Squared
|
|
|
77
82
|
puts print_footer(border: border)
|
|
78
83
|
end
|
|
79
84
|
msg = "#{msg + (force ? ':' : '?')} [#{min}-#{max}#{if (n = multiple)
|
|
80
|
-
"|,#{n.is_a?(::
|
|
85
|
+
"|,#{n.is_a?(::Array) ? "{#{n.join(',')}}" : '*'}"
|
|
81
86
|
end}] "
|
|
82
87
|
end
|
|
83
88
|
end
|
|
84
|
-
between = ->(s) { s.match?(/^\d+$/) && s.to_i.between?(min, max) }
|
|
89
|
+
between = ->(s) { s.match?(/^\d+$/) && s.to_i.between?(min, max <= min ? Float::INFINITY : max) }
|
|
85
90
|
Timeout.timeout(timeout) do
|
|
86
91
|
while (ch = Prompt.reline.readline(msg))
|
|
87
92
|
ch.strip!
|
|
@@ -106,7 +111,7 @@ module Squared
|
|
|
106
111
|
unless k.include?(nil)
|
|
107
112
|
k.uniq!
|
|
108
113
|
k.sort!
|
|
109
|
-
unless multiple.is_a?(::
|
|
114
|
+
unless multiple.is_a?(::Array) && !multiple.include?(k.size)
|
|
110
115
|
return index || !items ? k : k.map { |i| items[i.pred] }
|
|
111
116
|
end
|
|
112
117
|
end
|
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/config.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
|
|