squared 0.4.29 → 0.4.31
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 +32 -0
- data/README.md +35 -26
- data/lib/squared/common/class.rb +15 -8
- data/lib/squared/common/format.rb +10 -8
- data/lib/squared/common/prompt.rb +3 -3
- data/lib/squared/common/shell.rb +8 -3
- data/lib/squared/config.rb +6 -7
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +2 -2
- data/lib/squared/workspace/project/base.rb +22 -25
- data/lib/squared/workspace/project/docker.rb +2 -3
- data/lib/squared/workspace/project/git.rb +20 -18
- data/lib/squared/workspace/project/node.rb +23 -20
- data/lib/squared/workspace/project/python.rb +4 -4
- data/lib/squared/workspace/project/ruby.rb +30 -37
- data/lib/squared/workspace/project/support/class.rb +17 -17
- data/lib/squared/workspace/repo.rb +8 -6
- data/lib/squared/workspace.rb +4 -2
- 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: e24f3f18639483d5b698d06a1fd471251623658359121940dd4d6597d3e5f453
|
|
4
|
+
data.tar.gz: 90eb6cd2b8b5e28497d666d655758422d124b4eb47701164ce3712a11ecc2936
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a7a4c5283e6bd65ed22fe9053d3f14552f2de61200e48c8c0c8e8013d0915db2c72a76ad2f7de784d0127ac47a8dd87c48ceea7a6c8c93468119487820886d7
|
|
7
|
+
data.tar.gz: 8aee7c98eb186fec5968373ab0f3acffefcbe45d6c85adce46c581536ca51d77c71af89f1c0b95cf4be10e850a24df6b783c35eb9fc32da0fa3918d360f8d779
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.31] - 2025-11-22
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Project base attribute project was converted into an accessor.
|
|
8
|
+
- Ruby command flag is given precedence to a program file.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Repo application tasks are not created on Windows.
|
|
13
|
+
- Repo module used conflicting REPO_URL with Repo application.
|
|
14
|
+
- Project task outdated did not check pass and only exclusions.
|
|
15
|
+
- Workspace static method resolve did nothing when given a String.
|
|
16
|
+
- Project base run command types did not include Struct.
|
|
17
|
+
- Project change directory context did not always restore when raised.
|
|
18
|
+
- Ruby file method attributes did not always return nil.
|
|
19
|
+
- JoinSet with a delimiter did not report correct size.
|
|
20
|
+
|
|
21
|
+
## [0.4.30] - 2025-11-14
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Config viewer can read items by index in an Array.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Node command add uses event name "add" and not "depend".
|
|
30
|
+
- Node command add did not include packages with Yarn and PNPM.
|
|
31
|
+
- Git method revbuild did not splat build arguments.
|
|
32
|
+
|
|
3
33
|
## [0.4.29] - 2025-11-08
|
|
4
34
|
|
|
5
35
|
### Fixed
|
|
@@ -1091,6 +1121,8 @@
|
|
|
1091
1121
|
|
|
1092
1122
|
- Changelog was created.
|
|
1093
1123
|
|
|
1124
|
+
[0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
|
|
1125
|
+
[0.4.30]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.30
|
|
1094
1126
|
[0.4.29]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.29
|
|
1095
1127
|
[0.4.28]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.28
|
|
1096
1128
|
[0.4.27]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.27
|
data/README.md
CHANGED
|
@@ -20,23 +20,9 @@ The range chart indicates the latest Ruby tested against at the time of release.
|
|
|
20
20
|
gem install squared
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
### Optional
|
|
24
|
-
|
|
25
|
-
* [Repo](https://source.android.com/docs/setup/reference/repo)
|
|
26
|
-
* https://github.com/anpham6/squared-repo
|
|
27
|
-
* Python 3.6
|
|
28
|
-
* Not compatible with Windows
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
mkdir -p ~/.bin
|
|
32
|
-
PATH="${HOME}/.bin:${PATH}"
|
|
33
|
-
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
|
|
34
|
-
chmod a+rx ~/.bin/repo
|
|
35
|
-
```
|
|
36
|
-
|
|
37
23
|
## Example - Rakefile
|
|
38
24
|
|
|
39
|
-
Projects from any accessible folder can be added relative to the parent directory
|
|
25
|
+
Projects from any accessible folder can be added relative to the parent directory or absolutely. Missing projects will simply be excluded from the task runner.
|
|
40
26
|
|
|
41
27
|
```ruby
|
|
42
28
|
require "squared"
|
|
@@ -52,14 +38,6 @@ require "squared/app" # All workspace related mod
|
|
|
52
38
|
|
|
53
39
|
# NODE_ENV = production
|
|
54
40
|
|
|
55
|
-
# REPO_ROOT = /workspaces |
|
|
56
|
-
# REPO_HOME = /workspaces/squared | Dir.pwd
|
|
57
|
-
# rake = /workspaces/squared/Rakefile | main?
|
|
58
|
-
# OR
|
|
59
|
-
# REPO_ROOT = /workspaces | Dir.pwd
|
|
60
|
-
# rake = /workspaces/Rakefile |
|
|
61
|
-
# REPO_HOME = /workspaces/squared | main: "squared"
|
|
62
|
-
|
|
63
41
|
# pathname = /workspaces/pathname
|
|
64
42
|
# optparse = /workspaces/optparse
|
|
65
43
|
# log = /workspaces/logger
|
|
@@ -74,7 +52,6 @@ require "squared/app" # All workspace related mod
|
|
|
74
52
|
Workspace::Application
|
|
75
53
|
.new(Dir.pwd, main: "squared") # Dir.pwd? (main? is implicitly basename)
|
|
76
54
|
.banner("group", "project", styles: ["yellow", "black"], border: "bold") # name | project | path | ref | group? | parent? | version?
|
|
77
|
-
.repo("https://github.com/anpham6/squared-repo", "nightly", script: ["build:dev", "build:prod"], ref: :node) # Repo (optional)
|
|
78
55
|
.run("rake install", ref: :ruby)
|
|
79
56
|
.depend(false, group: "default")
|
|
80
57
|
.clean("rake clean", group: "default")
|
|
@@ -708,7 +685,37 @@ DOCKER_Y=1 # confirm all
|
|
|
708
685
|
|
|
709
686
|
### Repo
|
|
710
687
|
|
|
711
|
-
|
|
688
|
+
* [Repo](https://source.android.com/docs/setup/reference/repo)
|
|
689
|
+
* https://github.com/anpham6/squared-repo
|
|
690
|
+
* Python 3.6
|
|
691
|
+
* Not compatible with Windows
|
|
692
|
+
|
|
693
|
+
```sh
|
|
694
|
+
mkdir -p ~/.bin
|
|
695
|
+
PATH="${HOME}/.bin:${PATH}"
|
|
696
|
+
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
|
|
697
|
+
chmod a+rx ~/.bin/repo
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
```ruby
|
|
701
|
+
# REPO_ROOT = /workspaces |
|
|
702
|
+
# REPO_HOME = /workspaces/squared | Dir.pwd
|
|
703
|
+
# rake = /workspaces/squared/Rakefile | main?
|
|
704
|
+
#
|
|
705
|
+
# OR
|
|
706
|
+
#
|
|
707
|
+
# REPO_ROOT = /workspaces | Dir.pwd
|
|
708
|
+
# rake = /workspaces/Rakefile |
|
|
709
|
+
# REPO_HOME = /workspaces/squared | main: "squared"
|
|
710
|
+
|
|
711
|
+
Workspace::Application
|
|
712
|
+
.new(main: "squared")
|
|
713
|
+
.repo("https://github.com/anpham6/squared-repo", "nightly", script: ["build:dev", "prod"], ref: :node)
|
|
714
|
+
.add("squared", script: ["build:stage1", "build:stage2"])
|
|
715
|
+
.build
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
These global options also can target the application main suffix `${NAME}`. (e.g. *REPO_ROOT_SQUARED*)
|
|
712
719
|
|
|
713
720
|
```sh
|
|
714
721
|
REPO_ROOT # parent dir
|
|
@@ -720,7 +727,7 @@ REPO_DEV # pattern,0,1
|
|
|
720
727
|
REPO_PROD # pattern,0,1
|
|
721
728
|
REPO_WARN # 0,1
|
|
722
729
|
REPO_SYNC # 0,1
|
|
723
|
-
|
|
730
|
+
REPO_GIT # manifest repository
|
|
724
731
|
REPO_MANIFEST # e.g. latest,nightly,prod
|
|
725
732
|
REPO_GROUPS # e.g. base,prod,docs
|
|
726
733
|
REPO_STAGE # 0,1,2,3,4
|
|
@@ -728,6 +735,8 @@ REPO_SUBMODULLES # 0,1
|
|
|
728
735
|
REPO_TIMEOUT # confirm dialog (seconds)
|
|
729
736
|
```
|
|
730
737
|
|
|
738
|
+
Other similarly cloned `Repo` repositories can be managed remotely by setting the `REPO_ROOT` environment variable to the location.
|
|
739
|
+
|
|
731
740
|
## LICENSE
|
|
732
741
|
|
|
733
742
|
BSD 3-Clause
|
data/lib/squared/common/class.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Squared
|
|
|
42
42
|
|
|
43
43
|
attr_reader :delim, :extras
|
|
44
44
|
|
|
45
|
-
def initialize(data = [], delim: ' ', partition: '--', uniq: /\A--?[
|
|
45
|
+
def initialize(data = [], delim: ' ', partition: '--', uniq: /\A--?[^=\s-][^=\s]*(?:=|\s+)\S/)
|
|
46
46
|
@delim = delim
|
|
47
47
|
@partition = partition
|
|
48
48
|
@uniq = uniq
|
|
@@ -50,13 +50,17 @@ module Squared
|
|
|
50
50
|
super(data.compact)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def compact
|
|
54
|
+
to_ary.map!(&:to_s).reject(&:empty?)
|
|
55
|
+
end
|
|
56
|
+
|
|
53
57
|
def last(val, pat)
|
|
54
58
|
(@last ||= []).push([val, pat, $1]) if val =~ pat
|
|
55
59
|
self << val
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
def pass(&blk)
|
|
59
|
-
ret =
|
|
63
|
+
ret = compact
|
|
60
64
|
@last&.each do |val, pat, key|
|
|
61
65
|
i = []
|
|
62
66
|
j = nil
|
|
@@ -130,8 +134,8 @@ module Squared
|
|
|
130
134
|
extras!(obj) || super
|
|
131
135
|
end
|
|
132
136
|
|
|
133
|
-
def
|
|
134
|
-
|
|
137
|
+
def size
|
|
138
|
+
super + extras.size
|
|
135
139
|
end
|
|
136
140
|
|
|
137
141
|
def to_a
|
|
@@ -139,21 +143,24 @@ module Squared
|
|
|
139
143
|
end
|
|
140
144
|
|
|
141
145
|
def to_s
|
|
142
|
-
|
|
146
|
+
to_a.join(@delim)
|
|
143
147
|
end
|
|
144
148
|
|
|
145
149
|
def to_enum(*args)
|
|
146
|
-
|
|
150
|
+
to_a.to_enum(*args)
|
|
147
151
|
end
|
|
148
152
|
|
|
149
153
|
def to_json(*args)
|
|
150
|
-
|
|
154
|
+
to_a.to_json(*args)
|
|
151
155
|
end
|
|
152
156
|
|
|
153
157
|
def to_yaml(*args)
|
|
154
|
-
|
|
158
|
+
to_a.to_yaml(*args)
|
|
155
159
|
end
|
|
156
160
|
|
|
161
|
+
alias add :<<
|
|
162
|
+
alias add? :<<
|
|
163
|
+
|
|
157
164
|
private
|
|
158
165
|
|
|
159
166
|
def extras!(obj)
|
|
@@ -67,6 +67,7 @@ module Squared
|
|
|
67
67
|
end
|
|
68
68
|
wrap = ->(s, n) { "\x1B[#{n.join(';')}m#{s}\x1B[0m" }
|
|
69
69
|
code = []
|
|
70
|
+
args.clear if args.size == 1 && args.first.nil?
|
|
70
71
|
args.concat(Array(styles)).flatten.each_with_index do |type, i|
|
|
71
72
|
next unless type
|
|
72
73
|
|
|
@@ -178,19 +179,20 @@ module Squared
|
|
|
178
179
|
args = args.map(&:to_s)
|
|
179
180
|
if level.is_a?(::Numeric)
|
|
180
181
|
if append && respond_to?(:log)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
end
|
|
182
|
+
ref = log rescue nil
|
|
183
|
+
ref.add(level, message(subject, *args, hint: hint, space: ', ')) if ref.is_a?(::Logger)
|
|
184
184
|
end
|
|
185
|
-
return false
|
|
185
|
+
return false unless pass || level >= ARG[:LEVEL]
|
|
186
186
|
end
|
|
187
|
-
if
|
|
187
|
+
if hint.nil? ? args.size > 1 : !hint
|
|
188
188
|
title = log_title(level, color: false)
|
|
189
189
|
sub = [pat: /\A(#{Regexp.escape(title)})(.*)\z/m, styles: __get__(:theme)[:logger][log_sym(level)]] if color
|
|
190
190
|
emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
|
|
191
191
|
else
|
|
192
192
|
msg = [log_title(level, color: color)]
|
|
193
|
-
|
|
193
|
+
if subject
|
|
194
|
+
msg << (color ? sub_style(subject.to_s, (@theme.is_a?(::Hash) && @theme[:subject]) || :bold) : subject)
|
|
195
|
+
end
|
|
194
196
|
msg << args.shift if msg.size == 1
|
|
195
197
|
message(msg.join(' '), *args, hint: hint)
|
|
196
198
|
end
|
|
@@ -223,7 +225,7 @@ module Squared
|
|
|
223
225
|
end
|
|
224
226
|
|
|
225
227
|
def emphasize(val, title: nil, footer: nil, right: false, cols: nil, sub: nil, pipe: nil,
|
|
226
|
-
border: @theme && @theme[:border])
|
|
228
|
+
border: @theme.is_a?(::Hash) && @theme[:border])
|
|
227
229
|
n = 0
|
|
228
230
|
max = ->(a) { n = [n, a.max_by(&:size).size].max }
|
|
229
231
|
set = ->(s) { Array(s).map(&:to_s).tap { |a| max.call(a) } }
|
|
@@ -288,7 +290,7 @@ module Squared
|
|
|
288
290
|
else
|
|
289
291
|
pipe = $stdout unless pipe.respond_to?(:puts)
|
|
290
292
|
end
|
|
291
|
-
pipe.puts
|
|
293
|
+
pipe.puts(out)
|
|
292
294
|
else
|
|
293
295
|
err ? warn(out) : puts(out)
|
|
294
296
|
end
|
|
@@ -49,9 +49,9 @@ module Squared
|
|
|
49
49
|
raise_error 'empty selection list' if max == 0
|
|
50
50
|
min = grep ? 1 : [min, max].min
|
|
51
51
|
if auto
|
|
52
|
-
msg = "#{msg
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
msg = "#{msg}: [#{min}-#{max}#{if multiple
|
|
53
|
+
"|,#{multiple.is_a?(::Numeric) ? "{#{multiple}}" : ''}"
|
|
54
|
+
end}] "
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
valid = ->(s) { s.match?(/^-?\d+$/) && s.to_i.between?(min, max) }
|
data/lib/squared/common/shell.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Squared
|
|
|
29
29
|
r[7]
|
|
30
30
|
end
|
|
31
31
|
r[1] + (data ? data[2] : r[2]) + r[4] + shell_quote(opt, force: force, double: double, override: override)
|
|
32
|
-
elsif option && val =~ /\A(-{0,2}[
|
|
32
|
+
elsif option && val =~ /\A(-{0,2}[^=\s-][^=\s]*)=(.+)\z/m
|
|
33
33
|
return val if $2.match?(QUOTE_VALUE)
|
|
34
34
|
|
|
35
35
|
"#{$1}=%s" % if $2.include?(' ')
|
|
@@ -51,7 +51,7 @@ module Squared
|
|
|
51
51
|
return val if (!force && !val.include?(' ')) || val.empty?
|
|
52
52
|
|
|
53
53
|
if option
|
|
54
|
-
pat = /\A(?:-[
|
|
54
|
+
pat = /\A(?:-[^=\s-](?:=|\s+)?|(--)?[^=\s-][^=\s]*(?(1)(?:=|\s+)|=))(["']).+\2\z/m
|
|
55
55
|
return val if val.match?(pat)
|
|
56
56
|
end
|
|
57
57
|
q = ->(s) { s.gsub("'\\\\''", "'") }
|
|
@@ -78,7 +78,11 @@ module Squared
|
|
|
78
78
|
end
|
|
79
79
|
sep = unless flag.empty?
|
|
80
80
|
if flag[0] == '-'
|
|
81
|
-
flag[1] == '-'
|
|
81
|
+
if flag[1] == '-'
|
|
82
|
+
'='
|
|
83
|
+
else
|
|
84
|
+
merge ? '' : ' '
|
|
85
|
+
end
|
|
82
86
|
elsif flag.size == 1
|
|
83
87
|
pre = '-'
|
|
84
88
|
merge ? '' : ' '
|
|
@@ -112,6 +116,7 @@ module Squared
|
|
|
112
116
|
end
|
|
113
117
|
|
|
114
118
|
def fill_option(val, **kwargs)
|
|
119
|
+
return val unless val.is_a?(::String)
|
|
115
120
|
return "-#{val}" if val.match?(/\A(?:[a-z]\d*|\d)\z/i)
|
|
116
121
|
|
|
117
122
|
shell_escape(val.start_with?('-') ? val : "--#{val}", **kwargs)
|
data/lib/squared/config.rb
CHANGED
|
@@ -12,15 +12,14 @@ module Squared
|
|
|
12
12
|
include Rake::DSL
|
|
13
13
|
|
|
14
14
|
class << self
|
|
15
|
-
def parse(gem, namespace, ext = [
|
|
15
|
+
def parse(gem, namespace, ext = [gem])
|
|
16
16
|
require gem
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
[eval(namespace), Array(ext)].tap do |data|
|
|
18
|
+
data.last.each { |key| @@mime_obj[key] = data }
|
|
19
|
+
end
|
|
19
20
|
rescue LoadError, NameError => e
|
|
20
21
|
warn e
|
|
21
22
|
nil
|
|
22
|
-
else
|
|
23
|
-
@@mime_obj[ext.first]
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def link(project, main = project.dependfile.basename, name = nil, **kwargs, &blk)
|
|
@@ -246,7 +245,7 @@ module Squared
|
|
|
246
245
|
{ pat: /\A(.+ : )(-?[\d.]+)(\s*)\z/m, styles: theme[:number],
|
|
247
246
|
index: 2 },
|
|
248
247
|
{ pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
|
|
249
|
-
{ pat: /\A(.+ : \{)(.+)(
|
|
248
|
+
{ pat: /\A(.+ : \{)(.+)(}\s*)\z/m, styles: theme[:hash], index: 2 },
|
|
250
249
|
{ pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
|
|
251
250
|
{ pat: /\A(.+ : )(true|false)(\s*)\z/m, styles: theme[:boolean],
|
|
252
251
|
index: 2 },
|
|
@@ -262,7 +261,7 @@ module Squared
|
|
|
262
261
|
symbolize = opts[:symbolize_names]
|
|
263
262
|
keys.each do |key|
|
|
264
263
|
begin
|
|
265
|
-
items = key.split('.')
|
|
264
|
+
items = key.split('.').flat_map { |name| name =~ /^(.+)\[(\d+)\]$/ ? [$1, $2.to_i] : name }
|
|
266
265
|
items = items.map(&:to_sym) if symbolize
|
|
267
266
|
val = data.dig(*items)
|
|
268
267
|
if val.nil?
|
data/lib/squared/version.rb
CHANGED
|
@@ -488,7 +488,7 @@ module Squared
|
|
|
488
488
|
if (base = task_base?(key))
|
|
489
489
|
tasks << key if obj.has?(key, baseref)
|
|
490
490
|
elsif (batch = series.batch_get(key))
|
|
491
|
-
obj.allref
|
|
491
|
+
obj.allref do |ref|
|
|
492
492
|
next unless obj.has?(key, ref) && (data = batch[ref])
|
|
493
493
|
|
|
494
494
|
data.each do |val|
|
|
@@ -507,7 +507,7 @@ module Squared
|
|
|
507
507
|
if tasks.empty?
|
|
508
508
|
return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
|
|
509
509
|
|
|
510
|
-
obj.allref
|
|
510
|
+
obj.allref do |ref|
|
|
511
511
|
next unless obj.has?(key, ref) && (alt = data[ref])
|
|
512
512
|
|
|
513
513
|
ret = task_resolve(obj, alt)
|
|
@@ -72,9 +72,9 @@ module Squared
|
|
|
72
72
|
'unpack' => %i[zip tar gem ext].freeze
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
attr_reader :name, :
|
|
75
|
+
attr_reader :name, :workspace, :path, :theme, :group, :parent, :dependfile,
|
|
76
76
|
:exception, :pipe, :verbose
|
|
77
|
-
attr_accessor :global
|
|
77
|
+
attr_accessor :global, :project
|
|
78
78
|
|
|
79
79
|
def initialize(workspace, path, name, *, group: nil, first: {}, last: {}, error: {}, common: ARG[:COMMON],
|
|
80
80
|
**kwargs)
|
|
@@ -1005,8 +1005,8 @@ module Squared
|
|
|
1005
1005
|
@log = Logger.new(enabled? ? @log.first : nil, **@log.last)
|
|
1006
1006
|
end
|
|
1007
1007
|
|
|
1008
|
-
def allref
|
|
1009
|
-
@ref.reverse_each
|
|
1008
|
+
def allref(&blk)
|
|
1009
|
+
@ref.reverse_each(&blk)
|
|
1010
1010
|
end
|
|
1011
1011
|
|
|
1012
1012
|
def basepath(*args)
|
|
@@ -1020,7 +1020,7 @@ module Squared
|
|
|
1020
1020
|
path.parent.ascend.each do |dir|
|
|
1021
1021
|
target = dir.join(*args)
|
|
1022
1022
|
return target if target.exist?
|
|
1023
|
-
break if (ascend && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
|
|
1023
|
+
break if (ascend.is_a?(String) && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
|
|
1024
1024
|
end
|
|
1025
1025
|
ret
|
|
1026
1026
|
end
|
|
@@ -1290,7 +1290,9 @@ module Squared
|
|
|
1290
1290
|
end
|
|
1291
1291
|
|
|
1292
1292
|
def print_error(*args, loglevel: Logger::WARN, **kwargs)
|
|
1293
|
-
|
|
1293
|
+
return unless warning?
|
|
1294
|
+
|
|
1295
|
+
warn log_message(loglevel, *args, **kwargs)
|
|
1294
1296
|
end
|
|
1295
1297
|
|
|
1296
1298
|
def print_item(*val)
|
|
@@ -1444,8 +1446,8 @@ module Squared
|
|
|
1444
1446
|
"#{msg}#{!always && (!obj || obj == 0 || obj.to_s.empty?) ? '' : message(hint: message(title, obj.to_s))}"
|
|
1445
1447
|
end
|
|
1446
1448
|
|
|
1447
|
-
def append_repeat(flag, opts, target: @session)
|
|
1448
|
-
opts.each { |val| target << shell_option(flag, val) }
|
|
1449
|
+
def append_repeat(flag, opts, target: @session, **kwargs)
|
|
1450
|
+
opts.each { |val| target << shell_option(flag, val, **kwargs) }
|
|
1449
1451
|
end
|
|
1450
1452
|
|
|
1451
1453
|
def append_hash(data, target: @session || [], build: false)
|
|
@@ -1471,6 +1473,8 @@ module Squared
|
|
|
1471
1473
|
target << basic_option(key, val)
|
|
1472
1474
|
when FalseClass
|
|
1473
1475
|
target << shell_option(key).sub(/^--(?!no-)/, '--no-')
|
|
1476
|
+
when Pathname
|
|
1477
|
+
target << shell_option(key, val, escape: false)
|
|
1474
1478
|
else
|
|
1475
1479
|
target << shell_option(key, val.is_a?(String) ? val : nil)
|
|
1476
1480
|
end
|
|
@@ -1855,17 +1859,15 @@ module Squared
|
|
|
1855
1859
|
pwd = Pathname.pwd
|
|
1856
1860
|
if block_given?
|
|
1857
1861
|
begin
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
Dir.chdir path
|
|
1862
|
-
ret = yield
|
|
1863
|
-
Dir.chdir pwd
|
|
1862
|
+
unless (path == pwd || pass == true) && (workspace.mri? || !workspace.windows?)
|
|
1863
|
+
restore = true
|
|
1864
|
+
Dir.chdir(path)
|
|
1864
1865
|
end
|
|
1866
|
+
yield
|
|
1865
1867
|
rescue StandardError => e
|
|
1866
1868
|
on_error(e, from, dryrun: dryrun)
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
+
ensure
|
|
1870
|
+
Dir.chdir(pwd) if restore
|
|
1869
1871
|
end
|
|
1870
1872
|
elsif @pwd == pwd
|
|
1871
1873
|
@pwd = nil
|
|
@@ -2052,7 +2054,7 @@ module Squared
|
|
|
2052
2054
|
|
|
2053
2055
|
def runnable?(val)
|
|
2054
2056
|
case val
|
|
2055
|
-
when String, Enumerable, Proc, Method
|
|
2057
|
+
when String, Enumerable, Proc, Method, Struct
|
|
2056
2058
|
true
|
|
2057
2059
|
else
|
|
2058
2060
|
false
|
|
@@ -2111,14 +2113,9 @@ module Squared
|
|
|
2111
2113
|
end
|
|
2112
2114
|
|
|
2113
2115
|
def has_value?(data, other)
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
when Enumerable
|
|
2118
|
-
other.is_a?(Enumerable) ? other.any? { |obj| data.include?(obj) } : data.include?(other)
|
|
2119
|
-
else
|
|
2120
|
-
false
|
|
2121
|
-
end
|
|
2116
|
+
return false unless data.is_a?(Enumerable)
|
|
2117
|
+
|
|
2118
|
+
other.is_a?(Enumerable) ? other.any? { |obj,| data.include?(obj) } : data.include?(other)
|
|
2122
2119
|
end
|
|
2123
2120
|
|
|
2124
2121
|
def variables
|
|
@@ -375,7 +375,6 @@ module Squared
|
|
|
375
375
|
case flag
|
|
376
376
|
when :run, :create, :exec
|
|
377
377
|
if rc && !op.arg?('mount')
|
|
378
|
-
run = VAL_DOCKER[:run]
|
|
379
378
|
all = collect_hash VAL_DOCKER[:run]
|
|
380
379
|
delim = Regexp.new(",\\s*(?=#{all.join('|')})")
|
|
381
380
|
Array(@mounts).each do |val|
|
|
@@ -392,8 +391,8 @@ module Squared
|
|
|
392
391
|
end
|
|
393
392
|
elsif all.include?(k)
|
|
394
393
|
unless type
|
|
395
|
-
run.each_pair do |key,
|
|
396
|
-
next unless
|
|
394
|
+
VAL_DOCKER[:run].each_pair do |key, a|
|
|
395
|
+
next unless a.include?(k)
|
|
397
396
|
|
|
398
397
|
type = key.to_s unless key == :common
|
|
399
398
|
break
|
|
@@ -134,7 +134,7 @@ module Squared
|
|
|
134
134
|
File.write(@revfile, JSON.pretty_generate(@revdoc))
|
|
135
135
|
rescue StandardError => e
|
|
136
136
|
log&.debug e
|
|
137
|
-
warn log_message(Logger::WARN, e, pass: true) if warning
|
|
137
|
+
warn log_message(Logger::WARN, e, pass: true) if warning
|
|
138
138
|
ensure
|
|
139
139
|
@revlock = false
|
|
140
140
|
end
|
|
@@ -674,7 +674,7 @@ module Squared
|
|
|
674
674
|
branch(flag, target: target, ref: ref, remote: remote)
|
|
675
675
|
end
|
|
676
676
|
when :delete
|
|
677
|
-
format_desc action, flag, '
|
|
677
|
+
format_desc action, flag, '[^~]name*,:?'
|
|
678
678
|
task flag do |_, args|
|
|
679
679
|
refs = args.to_a
|
|
680
680
|
if refs.empty? || (r = refs.last == ':')
|
|
@@ -1232,7 +1232,7 @@ module Squared
|
|
|
1232
1232
|
end
|
|
1233
1233
|
end
|
|
1234
1234
|
start = epochtime
|
|
1235
|
-
build(
|
|
1235
|
+
build(*@output, sync: sync, from: :'git:revbuild')
|
|
1236
1236
|
rescue StandardError => e
|
|
1237
1237
|
print_error(e, pass: true)
|
|
1238
1238
|
else
|
|
@@ -1448,7 +1448,6 @@ module Squared
|
|
|
1448
1448
|
end
|
|
1449
1449
|
origin = readline('Enter an upstream', force: true)
|
|
1450
1450
|
end
|
|
1451
|
-
raise_error('missing remote name', hint: origin) unless origin.include?('/')
|
|
1452
1451
|
upstream = true
|
|
1453
1452
|
end
|
|
1454
1453
|
break
|
|
@@ -1697,7 +1696,7 @@ module Squared
|
|
|
1697
1696
|
cmd, opts = git_session('rev-parse', opts: opts)
|
|
1698
1697
|
case flag
|
|
1699
1698
|
when :commit
|
|
1700
|
-
cmd << (
|
|
1699
|
+
cmd << (size.to_i.zero? ? '--verify' : basic_option('short', [size.to_i, 5].max))
|
|
1701
1700
|
append_commit(ref, head: true)
|
|
1702
1701
|
when :branch
|
|
1703
1702
|
cmd << '--abbrev-ref'
|
|
@@ -1761,12 +1760,11 @@ module Squared
|
|
|
1761
1760
|
grep, list = op.partition { |val| OptionPartition.pattern?(val) }
|
|
1762
1761
|
unless grep.empty? && !list.empty?
|
|
1763
1762
|
grep.map! { |val| Regexp.new(val[1..-2]) }
|
|
1764
|
-
files = []
|
|
1765
|
-
|
|
1766
|
-
|
|
1763
|
+
files = []
|
|
1764
|
+
status_data.each do |a, b|
|
|
1765
|
+
next if b.strip.empty? || (!grep.empty? && grep.none? { |pat| pat.match?(a) })
|
|
1767
1766
|
|
|
1768
|
-
|
|
1769
|
-
end
|
|
1767
|
+
files << "#{sub_style(b, styles: color(:red))} #{a}"
|
|
1770
1768
|
end
|
|
1771
1769
|
unless files.empty?
|
|
1772
1770
|
files = choice_index('Select files', files, multiple: true, force: true, trim: /^\S+\s/,
|
|
@@ -1922,7 +1920,7 @@ module Squared
|
|
|
1922
1920
|
end
|
|
1923
1921
|
args = []
|
|
1924
1922
|
args << quote_option('sort', sort) if sort
|
|
1925
|
-
args <<
|
|
1923
|
+
args << basic_option('count', env('GIT_COUNT', ARG[:CHOICE])) if count
|
|
1926
1924
|
choice_index(msg, foreachref(type, *args, format: format), trim: trim, **kwargs)
|
|
1927
1925
|
end
|
|
1928
1926
|
|
|
@@ -1955,13 +1953,13 @@ module Squared
|
|
|
1955
1953
|
end
|
|
1956
1954
|
|
|
1957
1955
|
def status_data(*args)
|
|
1958
|
-
[]
|
|
1959
|
-
|
|
1960
|
-
|
|
1956
|
+
ret = []
|
|
1957
|
+
git_spawn('status -z -uall', *args).split("\x0").each do |line|
|
|
1958
|
+
next unless line =~ /^(.)(.) (.+)$/
|
|
1961
1959
|
|
|
1962
|
-
|
|
1963
|
-
end
|
|
1960
|
+
ret << [$3, $2, $1]
|
|
1964
1961
|
end
|
|
1962
|
+
ret
|
|
1965
1963
|
end
|
|
1966
1964
|
|
|
1967
1965
|
def append_pull(opts, list, target: @session, flag: nil, no: nil, remote: nil, from: nil)
|
|
@@ -2038,7 +2036,9 @@ module Squared
|
|
|
2038
2036
|
|
|
2039
2037
|
def append_message(val = nil, target: @session)
|
|
2040
2038
|
val = messageopt if val.to_s.empty?
|
|
2041
|
-
|
|
2039
|
+
return unless val
|
|
2040
|
+
|
|
2041
|
+
target << quote_option('message', val)
|
|
2042
2042
|
end
|
|
2043
2043
|
|
|
2044
2044
|
def append_head(val = nil, target: @session)
|
|
@@ -2122,7 +2122,9 @@ module Squared
|
|
|
2122
2122
|
end
|
|
2123
2123
|
|
|
2124
2124
|
def repotrack(origin, branch, quote: true)
|
|
2125
|
-
i = origin.index('/')
|
|
2125
|
+
unless origin && branch && (i = origin.index('/'))
|
|
2126
|
+
raise_error(ArgumentError, "missing #{origin ? 'branch' : 'remote'} name", hint: origin)
|
|
2127
|
+
end
|
|
2126
2128
|
branch = "#{branch}:#{origin[(i + 1)..-1]}" unless origin.end_with?("/#{branch}")
|
|
2127
2129
|
ret = [origin[0..(i - 1)], branch]
|
|
2128
2130
|
quote ? ret.map! { |val| shell_quote(val) } : ret
|
|
@@ -6,18 +6,19 @@ module Squared
|
|
|
6
6
|
class Node < Git
|
|
7
7
|
OPT_NPM = {
|
|
8
8
|
common: %w[dry-run=!? include-workspace-root=!? loglevel=b workspaces=!? w|workspace=v].freeze,
|
|
9
|
-
install: %w[package-lock-only=!? prefer-dedupe=!? cpu=b libc=b os=b].freeze,
|
|
10
|
-
install_base: %w[audit=! bin-links=! fund=! ignore-scripts=!? install-links=!?
|
|
11
|
-
strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
|
|
9
|
+
install: %w[package-lock-only=!? prefer-dedupe=!? E|save-exact=!? before=q cpu=b libc=b os=b].freeze,
|
|
10
|
+
install_base: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
|
|
11
|
+
package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
|
|
12
12
|
install_no: %w[audit bin-links fund package-lock].freeze,
|
|
13
|
-
install_as: %w[no-save save-bundle save-dev save-optional save-peer save-prod
|
|
14
|
-
|
|
13
|
+
install_as: %w[no-save B|save-bundle D|save-dev O|save-optional save-peer P|save-prod g|global=!?
|
|
14
|
+
S|save=!?].freeze,
|
|
15
15
|
run: %w[foreground-scripts=!? if-present=!? ignore-scripts=!? script-shell=p].freeze,
|
|
16
16
|
exec: %w[c|call=q package=b].freeze,
|
|
17
17
|
pack: %w[ignore-scripts=!? json=!? pack-destination=p].freeze
|
|
18
18
|
}.freeze
|
|
19
19
|
OPT_PNPM = {
|
|
20
|
-
common: %w[aggregate-output color no-color stream use-stderr C|dir=p loglevel=b
|
|
20
|
+
common: %w[aggregate-output color ignore-workspace-root-check no-color stream use-stderr C|dir=p loglevel=b
|
|
21
|
+
r|recursive w|workspace-root].freeze,
|
|
21
22
|
cpu: %w[cpu=b libc=b os=b].freeze,
|
|
22
23
|
filter: %w[fail-if-no-match changed-files-ignore-pattern=q filter=q filter-prod=q test-pattern=q].freeze,
|
|
23
24
|
install: %w[fix-lockfile force ignore-pnpmfile ignore-workspace lockfile-only merge-git-branch-lockfiles
|
|
@@ -28,12 +29,12 @@ module Squared
|
|
|
28
29
|
reporter=b].freeze,
|
|
29
30
|
install_base: %w[global-dir ignore-scripts offline prefer-offline store-dir=p virtual-store-dir=p].freeze,
|
|
30
31
|
install_no: %w[frozen-lockfile verify-store-integrity].freeze,
|
|
31
|
-
install_as: %w[D|dev
|
|
32
|
+
install_as: %w[D|dev no-optional P|prod].freeze,
|
|
32
33
|
update: %w[g|global i|interactive L|latest depth=i].freeze,
|
|
33
34
|
dedupe: %w[check].freeze,
|
|
34
|
-
run: %w[if-present no-bail parallel
|
|
35
|
+
run: %w[if-present no-bail parallel report-summary reporter-hide-prefix resume-from
|
|
35
36
|
sequential].freeze,
|
|
36
|
-
exec: %w[no-reporter-hide-prefix parallel
|
|
37
|
+
exec: %w[no-reporter-hide-prefix parallel report-summary resume-from c|shell-mode].freeze,
|
|
37
38
|
pack: %w[json pack-destination=p pack-gzip-level=i].freeze
|
|
38
39
|
}.freeze
|
|
39
40
|
OPT_YARN = {
|
|
@@ -157,7 +158,8 @@ module Squared
|
|
|
157
158
|
elsif exception
|
|
158
159
|
indexerror n, list
|
|
159
160
|
else
|
|
160
|
-
|
|
161
|
+
log.warn "run script #{n} of #{list.size} (out of range)"
|
|
162
|
+
next
|
|
161
163
|
end
|
|
162
164
|
run compose(val, script: true)
|
|
163
165
|
else
|
|
@@ -268,6 +270,8 @@ module Squared
|
|
|
268
270
|
|
|
269
271
|
def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, files: nil, workspace: false,
|
|
270
272
|
link: false, force: false, override: false, sync: invoked_sync?('copy'), **kwargs)
|
|
273
|
+
return if @copy == false
|
|
274
|
+
|
|
271
275
|
glob = kwargs[:include]
|
|
272
276
|
pass = kwargs[:exclude]
|
|
273
277
|
if @copy && !override
|
|
@@ -284,8 +288,6 @@ module Squared
|
|
|
284
288
|
create = @copy[:create] if @copy.key?(:create)
|
|
285
289
|
glob = @copy[:include] if @copy.key?(:include)
|
|
286
290
|
pass = @copy[:exclude] if @copy.key?(:exclude)
|
|
287
|
-
elsif @copy == false
|
|
288
|
-
return
|
|
289
291
|
end
|
|
290
292
|
items = []
|
|
291
293
|
if build? && path != @workspace.home && @workspace.home?
|
|
@@ -437,11 +439,12 @@ module Squared
|
|
|
437
439
|
if flag == :add
|
|
438
440
|
cmd << 'add' << "--save-#{save}"
|
|
439
441
|
cmd << '--save-exact' if exact
|
|
442
|
+
option('allow-build') { |val| cmd << quote_option('allow-build', val) }
|
|
440
443
|
else
|
|
441
444
|
cmd << 'install'
|
|
442
445
|
append_platform
|
|
443
446
|
end
|
|
444
|
-
if (val = option('public-hoist-pattern'
|
|
447
|
+
if (val = option('public-hoist-pattern'))
|
|
445
448
|
split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt) }
|
|
446
449
|
end
|
|
447
450
|
cmd << '--ignore-workspace' if env('NODE_WORKSPACES', equals: '0')
|
|
@@ -451,7 +454,6 @@ module Squared
|
|
|
451
454
|
if flag == :add
|
|
452
455
|
cmd << "--save-#{save}"
|
|
453
456
|
cmd << '--save-exact' if exact
|
|
454
|
-
cmd.merge(packages.map { |pkg| shell_quote(pkg) })
|
|
455
457
|
else
|
|
456
458
|
append_platform
|
|
457
459
|
end
|
|
@@ -460,7 +462,8 @@ module Squared
|
|
|
460
462
|
append_nocolor
|
|
461
463
|
end
|
|
462
464
|
append_loglevel
|
|
463
|
-
|
|
465
|
+
cmd.merge(packages.map { |pkg| shell_quote(pkg) }) if flag == :add
|
|
466
|
+
run(from: flag || :depend, sync: sync)
|
|
464
467
|
end
|
|
465
468
|
end
|
|
466
469
|
|
|
@@ -713,7 +716,7 @@ module Squared
|
|
|
713
716
|
else
|
|
714
717
|
cmd = session 'npm', flag
|
|
715
718
|
list = OPT_NPM[:install_base] + OPT_NPM.fetch(flag, []) + OPT_NPM[:common]
|
|
716
|
-
list.concat(OPT_NPM[:install_as])
|
|
719
|
+
list.concat(OPT_NPM[:install_as]) if flag == :install || flag == :update
|
|
717
720
|
no = OPT_NPM[:install_no]
|
|
718
721
|
end
|
|
719
722
|
op = OptionPartition.new(opts, list, cmd, no: no, project: self)
|
|
@@ -733,13 +736,13 @@ module Squared
|
|
|
733
736
|
append_platform if flag == :install
|
|
734
737
|
append_nocolor
|
|
735
738
|
append_loglevel
|
|
736
|
-
if flag == :dedupe
|
|
739
|
+
if flag == :dedupe || pnpm?
|
|
737
740
|
op.clear
|
|
738
741
|
else
|
|
739
742
|
op.append(quote: true)
|
|
740
743
|
end
|
|
741
|
-
op.clear(errors: true)
|
|
742
744
|
end
|
|
745
|
+
op.clear(errors: true)
|
|
743
746
|
run(from: from || :"package:#{flag}")
|
|
744
747
|
end
|
|
745
748
|
|
|
@@ -855,7 +858,7 @@ module Squared
|
|
|
855
858
|
end
|
|
856
859
|
|
|
857
860
|
def outdated?
|
|
858
|
-
dependfile.exist?
|
|
861
|
+
dependfile.exist? && !task_pass?('outdated')
|
|
859
862
|
end
|
|
860
863
|
|
|
861
864
|
def update?
|
|
@@ -1038,7 +1041,7 @@ module Squared
|
|
|
1038
1041
|
|
|
1039
1042
|
def append_loglevel(target: @session)
|
|
1040
1043
|
level = env('NODE_LOGLEVEL')
|
|
1041
|
-
silent =
|
|
1044
|
+
silent = verbosetype == 0 || level == 'silent'
|
|
1042
1045
|
return unless silent || level
|
|
1043
1046
|
|
|
1044
1047
|
if yarn?
|
|
@@ -602,7 +602,7 @@ module Squared
|
|
|
602
602
|
end
|
|
603
603
|
|
|
604
604
|
def outdated?
|
|
605
|
-
dependtype > 0
|
|
605
|
+
dependtype > 0 && !task_pass?('outdated')
|
|
606
606
|
end
|
|
607
607
|
|
|
608
608
|
private
|
|
@@ -614,7 +614,7 @@ module Squared
|
|
|
614
614
|
def python_session(*cmd, opts: nil)
|
|
615
615
|
return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
|
|
616
616
|
|
|
617
|
-
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single:
|
|
617
|
+
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: singleopt(:python))
|
|
618
618
|
ret = session('python', *op.to_a, *cmd, path: venv.nil?)
|
|
619
619
|
[ret, op.extras]
|
|
620
620
|
end
|
|
@@ -712,7 +712,7 @@ module Squared
|
|
|
712
712
|
quote_option('cache-dir', basepath(val))
|
|
713
713
|
end
|
|
714
714
|
end
|
|
715
|
-
target <<
|
|
715
|
+
target << quote_option('proxy', val) if (val = option('proxy', target: target))
|
|
716
716
|
target << quote_option('python', basepath(val)) if (val = option('python', target: target))
|
|
717
717
|
append_nocolor(target: target)
|
|
718
718
|
end
|
|
@@ -793,7 +793,7 @@ module Squared
|
|
|
793
793
|
def singleopt(flag = nil)
|
|
794
794
|
case flag
|
|
795
795
|
when :python
|
|
796
|
-
/\A(?:v+|q+|b+)\z/
|
|
796
|
+
/\A(?:v+|q+|b+|V+|O+)\z/
|
|
797
797
|
when :twine
|
|
798
798
|
nil
|
|
799
799
|
else
|
|
@@ -288,6 +288,8 @@ module Squared
|
|
|
288
288
|
end
|
|
289
289
|
|
|
290
290
|
def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
|
|
291
|
+
return if @copy == false
|
|
292
|
+
|
|
291
293
|
glob = kwargs[:include]
|
|
292
294
|
pass = kwargs[:exclude]
|
|
293
295
|
if @copy && !override
|
|
@@ -297,8 +299,6 @@ module Squared
|
|
|
297
299
|
glob = @copy[:include] if @copy.key?(:include)
|
|
298
300
|
pass = @copy[:exclude] if @copy.key?(:exclude)
|
|
299
301
|
into = @copy[:into] if @copy.key?(:into)
|
|
300
|
-
elsif @copy == false
|
|
301
|
-
return
|
|
302
302
|
end
|
|
303
303
|
return unless into
|
|
304
304
|
|
|
@@ -462,13 +462,15 @@ module Squared
|
|
|
462
462
|
case flag
|
|
463
463
|
when :file, :script
|
|
464
464
|
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
|
465
|
-
if
|
|
466
|
-
op.unshift(shell_quote(basepath(file)))
|
|
467
|
-
elsif command
|
|
465
|
+
if command
|
|
468
466
|
op << quote_option('e', command, option: false)
|
|
467
|
+
elsif file
|
|
468
|
+
op.unshift(basepath(file))
|
|
469
|
+
end
|
|
470
|
+
unless op.arg?('e')
|
|
471
|
+
op.push(args) if args
|
|
472
|
+
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
|
469
473
|
end
|
|
470
|
-
op.push(args) if args
|
|
471
|
-
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
|
472
474
|
when :version
|
|
473
475
|
pwd_set do
|
|
474
476
|
out = []
|
|
@@ -561,7 +563,6 @@ module Squared
|
|
|
561
563
|
when :install, :update
|
|
562
564
|
list.concat(OPT_GEM[:install_base])
|
|
563
565
|
end
|
|
564
|
-
cmd.merge(preopts)
|
|
565
566
|
op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GEM[:no][flag])
|
|
566
567
|
op.each do |opt|
|
|
567
568
|
if !opt.match?(/\A[A-Za-z\d][A-Za-z\d_.-]*\z/) && %i[install uninstall update pristine].include?(flag)
|
|
@@ -764,7 +765,7 @@ module Squared
|
|
|
764
765
|
else
|
|
765
766
|
[name[0, n], name[(n + 1)..-1]]
|
|
766
767
|
end
|
|
767
|
-
op.adjoin(pre,
|
|
768
|
+
op.adjoin(pre, basic_option('version', ver))
|
|
768
769
|
.clear
|
|
769
770
|
elsif flag == :install
|
|
770
771
|
op.append_any
|
|
@@ -829,13 +830,8 @@ module Squared
|
|
|
829
830
|
end
|
|
830
831
|
|
|
831
832
|
def gemspec
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
@gemspec = if gemfile
|
|
835
|
-
Gem::Specification.load(gemfile.to_s) rescue false
|
|
836
|
-
else
|
|
837
|
-
false
|
|
838
|
-
end
|
|
833
|
+
@gemspec = !gemfile.nil? && Gem::Specification.load(gemfile.to_s) rescue false if @gemspec.nil?
|
|
834
|
+
@gemspec || nil
|
|
839
835
|
end
|
|
840
836
|
|
|
841
837
|
def gemname
|
|
@@ -925,7 +921,7 @@ module Squared
|
|
|
925
921
|
end
|
|
926
922
|
|
|
927
923
|
def outdated?
|
|
928
|
-
dependtype > 0
|
|
924
|
+
dependtype > 0 && !task_pass?('outdated')
|
|
929
925
|
end
|
|
930
926
|
|
|
931
927
|
private
|
|
@@ -959,18 +955,11 @@ module Squared
|
|
|
959
955
|
end
|
|
960
956
|
|
|
961
957
|
def gem_session(*cmd, **kwargs)
|
|
962
|
-
|
|
963
|
-
return ret if cmd.empty?
|
|
964
|
-
|
|
965
|
-
ret.merge(preopts)
|
|
958
|
+
session('gem', *cmd, *preopts, **kwargs)
|
|
966
959
|
end
|
|
967
960
|
|
|
968
961
|
def bundle_session(*cmd, **kwargs)
|
|
969
|
-
|
|
970
|
-
return ret if cmd.empty?
|
|
971
|
-
|
|
972
|
-
append_nocolor
|
|
973
|
-
ret.merge(preopts)
|
|
962
|
+
session('bundle', *cmd, *preopts, **kwargs).tap { append_nocolor }
|
|
974
963
|
end
|
|
975
964
|
|
|
976
965
|
def rake_session(*cmd, **kwargs)
|
|
@@ -994,7 +983,7 @@ module Squared
|
|
|
994
983
|
end
|
|
995
984
|
|
|
996
985
|
def preopts
|
|
997
|
-
verbosetype > 1
|
|
986
|
+
verbosetype > 1 ? ['--verbose'] : []
|
|
998
987
|
end
|
|
999
988
|
|
|
1000
989
|
def variables
|
|
@@ -1002,10 +991,11 @@ module Squared
|
|
|
1002
991
|
end
|
|
1003
992
|
|
|
1004
993
|
def rakefile
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
994
|
+
if @rakefile.nil?
|
|
995
|
+
file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }
|
|
996
|
+
@rakefile = !file.nil? && basepath(file)
|
|
997
|
+
end
|
|
998
|
+
@rakefile || nil
|
|
1009
999
|
end
|
|
1010
1000
|
|
|
1011
1001
|
def rakepwd
|
|
@@ -1034,11 +1024,12 @@ module Squared
|
|
|
1034
1024
|
end
|
|
1035
1025
|
|
|
1036
1026
|
def gemfile
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1027
|
+
if @gemfile.nil?
|
|
1028
|
+
@gemfile = [project, name].map! { |val| basepath("#{val}.gemspec") }
|
|
1029
|
+
.concat(Dir.glob(basepath('*.gemspec')))
|
|
1030
|
+
.find { |file| File.exist?(file) } || false
|
|
1031
|
+
end
|
|
1032
|
+
@gemfile || nil
|
|
1042
1033
|
end
|
|
1043
1034
|
|
|
1044
1035
|
def gemlib
|
|
@@ -1056,7 +1047,9 @@ module Squared
|
|
|
1056
1047
|
end
|
|
1057
1048
|
|
|
1058
1049
|
def gemdir?
|
|
1059
|
-
|
|
1050
|
+
return false unless @gemdir
|
|
1051
|
+
|
|
1052
|
+
@gemdir.exist? && !@gemdir.empty?
|
|
1060
1053
|
end
|
|
1061
1054
|
|
|
1062
1055
|
alias read_rakefile raketasks
|
|
@@ -10,9 +10,9 @@ module Squared
|
|
|
10
10
|
include Common::Shell
|
|
11
11
|
extend Forwardable
|
|
12
12
|
|
|
13
|
-
OPT_NAME = /\A(?:(--)|-)((?(1)[
|
|
14
|
-
OPT_VALUE = /\A-{0,2}([
|
|
15
|
-
OPT_SINGLE = /\A-([
|
|
13
|
+
OPT_NAME = /\A(?:(--)|-)((?(1)[^=\s-][^=\s]*|[^=\s-]))\z/
|
|
14
|
+
OPT_VALUE = /\A-{0,2}([^=\s-][^=\s]*)(?:=|\s+)(\S.*)\z/
|
|
15
|
+
OPT_SINGLE = /\A-([^=\s-])(.+)\z/
|
|
16
16
|
private_constant :OPT_NAME, :OPT_VALUE, :OPT_SINGLE
|
|
17
17
|
|
|
18
18
|
class << self
|
|
@@ -29,15 +29,15 @@ module Squared
|
|
|
29
29
|
pat, s = Array(strip)
|
|
30
30
|
ret.map! { |val| val.is_a?(String) ? val.gsub(pat, s || '') : val }
|
|
31
31
|
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
ret.map! do |val|
|
|
33
|
+
next val if opt?(val)
|
|
34
|
+
|
|
35
|
+
if quote || val.is_a?(Pathname)
|
|
36
|
+
shell_quote(val, force: force, double: double)
|
|
37
|
+
elsif escape
|
|
38
|
+
shell_escape(val, quote: quote, double: double)
|
|
39
|
+
else
|
|
40
|
+
val
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
if target.is_a?(Set)
|
|
@@ -103,7 +103,7 @@ module Squared
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def pattern?(val)
|
|
106
|
-
val.match?(/(?:\A\^|\$\z)/) || val.match?(/(?:\.[*+]|\(\?:|\\[dsw]|\[.+\]|\{\d+,?\d
|
|
106
|
+
val.match?(/(?:\A\^|\$\z)/) || val.match?(/(?:\.[*+]|\(\?:|\\[dsw]|\[.+\]|\{\d+,?\d*})/)
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
private
|
|
@@ -134,7 +134,7 @@ module Squared
|
|
|
134
134
|
attr_reader :target, :extras, :found, :errors, :values, :project, :path
|
|
135
135
|
|
|
136
136
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
|
137
|
-
:merge, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
|
137
|
+
:merge, :compact, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
|
138
138
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
|
139
139
|
:pop, :push, :concat, :index, :join, :map, :map!, :detect, :select, :select!, :reject, :size,
|
|
140
140
|
:delete_at
|
|
@@ -340,7 +340,7 @@ module Squared
|
|
|
340
340
|
|
|
341
341
|
def adjoin(*args, with: nil, start: false)
|
|
342
342
|
i = -1
|
|
343
|
-
temp =
|
|
343
|
+
temp = compact
|
|
344
344
|
if with
|
|
345
345
|
pat = case with
|
|
346
346
|
when String, Symbol
|
|
@@ -359,11 +359,11 @@ module Squared
|
|
|
359
359
|
else
|
|
360
360
|
temp.each_with_index do |val, index|
|
|
361
361
|
if i == 0
|
|
362
|
-
next unless val.start_with?('-')
|
|
362
|
+
next unless val.is_a?(String) && val.start_with?('-')
|
|
363
363
|
|
|
364
364
|
i = index
|
|
365
365
|
break
|
|
366
|
-
elsif index > 0 && !val.start_with?('-')
|
|
366
|
+
elsif index > 0 && !val.to_s.start_with?('-')
|
|
367
367
|
if start
|
|
368
368
|
i = index + (start.is_a?(Numeric) ? start : 1)
|
|
369
369
|
break
|
|
@@ -132,20 +132,20 @@ module Squared
|
|
|
132
132
|
task 'all' do |_, args|
|
|
133
133
|
stage ||= 'all'
|
|
134
134
|
ns['sync'].invoke(*args.to_a)
|
|
135
|
-
next if (
|
|
135
|
+
next if (n = env('REPO_STAGE')) == '1'
|
|
136
136
|
|
|
137
137
|
@project.select do |_, proj|
|
|
138
138
|
next unless proj.enabled?(proj.workspace.baseref) && proj.global
|
|
139
139
|
|
|
140
140
|
proj.depend(sync: true) if proj.depend?
|
|
141
|
-
next if
|
|
141
|
+
next if n == '2'
|
|
142
142
|
|
|
143
143
|
proj.build?
|
|
144
144
|
end
|
|
145
145
|
.each_value do |proj|
|
|
146
146
|
proj.build(sync: true)
|
|
147
|
-
next if
|
|
148
|
-
next unless proj.copy? && (proj.dev? ||
|
|
147
|
+
next if n == '3'
|
|
148
|
+
next unless proj.copy? && (proj.dev? || n == '4')
|
|
149
149
|
|
|
150
150
|
if (ws = proj.workspace).task_defined?(target = task_join(proj.name, 'copy'))
|
|
151
151
|
task_invoke(target, **ws.invokeargs)
|
|
@@ -158,7 +158,7 @@ module Squared
|
|
|
158
158
|
desc.call("init[manifest?=#{target},groups?,{0}]", target)
|
|
159
159
|
task 'init' do |_, args|
|
|
160
160
|
args = args.to_a
|
|
161
|
-
u = env('
|
|
161
|
+
u = env('REPO_GIT') || manifest_url
|
|
162
162
|
m = args.first && !opts.include?(args.first) ? args.shift : target
|
|
163
163
|
g = args.first && !opts.include?(args.first) ? args.shift : nil
|
|
164
164
|
g = case (val = env('REPO_GROUPS'))
|
|
@@ -251,7 +251,9 @@ module Squared
|
|
|
251
251
|
end
|
|
252
252
|
|
|
253
253
|
def repo?
|
|
254
|
-
|
|
254
|
+
return false unless manifest_url && !windows?
|
|
255
|
+
|
|
256
|
+
repo_install? || @repo_override == true
|
|
255
257
|
end
|
|
256
258
|
|
|
257
259
|
def repo_submodules?(val = false)
|
data/lib/squared/workspace.rb
CHANGED
|
@@ -5,12 +5,14 @@ module Squared
|
|
|
5
5
|
class << self
|
|
6
6
|
include Common
|
|
7
7
|
|
|
8
|
-
def resolve(*args)
|
|
8
|
+
def resolve(*args, base: '..')
|
|
9
|
+
values = __get__(:project).values
|
|
9
10
|
ret = args.map do |id|
|
|
10
11
|
if id.is_a?(Symbol)
|
|
11
12
|
project id
|
|
12
13
|
else
|
|
13
|
-
|
|
14
|
+
values.find { |proj| proj.name == id } || values.find { |proj| proj.project == id } ||
|
|
15
|
+
values.find { |proj| proj.path.to_s == File.expand_path(id, base) }
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
ret.size == 1 ? ret.first : ret
|