squared 0.0.12 → 0.1.1
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 +55 -0
- data/README.md +9 -2
- data/README.ruby.md +6 -4
- data/lib/squared/common/class.rb +2 -2
- data/lib/squared/common/format.rb +1 -1
- data/lib/squared/common/system.rb +7 -3
- data/lib/squared/common/utils.rb +6 -2
- data/lib/squared/config.rb +34 -34
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +68 -36
- data/lib/squared/workspace/project/base.rb +232 -161
- data/lib/squared/workspace/project/git.rb +115 -61
- data/lib/squared/workspace/project/node.rb +189 -102
- data/lib/squared/workspace/project/python.rb +11 -9
- data/lib/squared/workspace/project/ruby.rb +31 -27
- data/lib/squared/workspace/repo.rb +28 -14
- data/lib/squared/workspace/series.rb +36 -12
- data/lib/squared/workspace.rb +8 -8
- data/squared.gemspec +1 -1
- 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: e2fd23c5964fe7c987966b8d237b569883b2dae5b70d9c120a924e2cc0227873
|
4
|
+
data.tar.gz: 8ef09d80e13c53fda678aa6a7194e33abf04728fb9d1c17739a5dc6c814e3b03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c41b98512dfc370a056716c3af2a599321b6113fa4883ab1f9c6b1418332f6b973560ce2cb1550c3813521eaa326150371ef3e60906cb694d6a6fd41ac1e0f05
|
7
|
+
data.tar.gz: cedbdcb188a6fb4a8407fc36836ffbeb4b93893217cec168d291845ce9a4f3f4dede9936022b8c950efa48ec21e2f93d013dc7e6fa929397ac80df7d6e3b099a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.1.1] - 2024-12-14
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Node package manager update command was implemented.
|
8
|
+
- Git pull and fetch retrieve options were expanded.
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Git show does not require an object argument.
|
13
|
+
- Project base class is implemented through Application.
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Listing tasks did not check for rake -C option availability.
|
18
|
+
- Listing gems did not check for gem -C option availability.
|
19
|
+
- Disabled extension tasks by individual project were being created.
|
20
|
+
- Git commit did not locate origin from nested branches.
|
21
|
+
- Project clean command used incompatible folder delete option.
|
22
|
+
- Rake did not set original dir when calling itself.
|
23
|
+
- Rake did not set original rakefile when calling itself.
|
24
|
+
- Extended tasks were not associated to their supporting class method.
|
25
|
+
|
26
|
+
## [0.1.0] - 2024-12-7
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- Git command show was implemented.
|
31
|
+
- Projects can run arbitrarily ordered graphs.
|
32
|
+
- Repo can be installed from a nested directory without a Rakefile.
|
33
|
+
- Python interpreter can be set using ENV option PIP_PYTHON.
|
34
|
+
- Node workspaces can be copied by registry package name.
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
|
38
|
+
- Parallel tasks support using Regexp patterns.
|
39
|
+
- Project copy globs were renamed include and exclude.
|
40
|
+
|
41
|
+
### Fixed
|
42
|
+
|
43
|
+
- Project workspaces did not detect for a valid directory.
|
44
|
+
- Git pull did not display colors for diff bar chart.
|
45
|
+
- Git commit did not fetch latest refs before submitting.
|
46
|
+
|
47
|
+
## [0.0.12] - 2024-12-1
|
48
|
+
|
49
|
+
### Added
|
50
|
+
|
51
|
+
- Changelog was created.
|
52
|
+
|
53
|
+
[0.1.1]: https://github.com/anpham6/squared/releases/tag/v0.1.1-ruby
|
54
|
+
[0.1.0]: https://github.com/anpham6/squared/releases/tag/v0.1.0-ruby
|
55
|
+
[0.0.12]: https://github.com/anpham6/squared/releases/tag/v0.0.12-ruby
|
data/README.md
CHANGED
@@ -108,7 +108,7 @@ Workspace management uses [Ruby](https://www.ruby-lang.org/en/documentation/inst
|
|
108
108
|
mkdir workspaces
|
109
109
|
cd workspaces # REPO_ROOT
|
110
110
|
|
111
|
-
wget https://
|
111
|
+
wget https://unpkg.com/squared/Rakefile
|
112
112
|
|
113
113
|
rake -T # List tasks
|
114
114
|
|
@@ -129,10 +129,17 @@ REPO_ROOT=/tmp/123 NODE_INSTALL=pnpm repo:init
|
|
129
129
|
```sh
|
130
130
|
# NODE_TAG=latest
|
131
131
|
# RUBY_VERSION=2.4.0-3.3.0
|
132
|
+
# MANIFEST=nightly,staging,prod,android
|
132
133
|
# BUILD={dev,prod}
|
133
134
|
# DEV={0,1,local}
|
134
|
-
# DOCS=
|
135
|
+
# DOCS=any
|
136
|
+
# PIPE_FAIL={0,1}
|
135
137
|
docker build -t squared --build-arg MANIFEST=prod --build-arg SQUARED=prod .
|
138
|
+
docker build -t node --build-arg NODE_TAG=20 --build-arg NODE_INSTALL=pnpm -f Dockerfile.slim . # no docs
|
139
|
+
# OR
|
140
|
+
# RUBY_TAG=latest
|
141
|
+
# NODE_VERSION=22.x
|
142
|
+
docker build -t ruby --build-arg RUBY_TAG=3.0 --build-arg NODE_VERSION=20.x --build-arg PIPE_FAIL=0 -f Dockerfile.ruby .
|
136
143
|
|
137
144
|
# Express
|
138
145
|
docker run -it --name express --rm -p 127.0.0.1:80:80 \
|
data/README.ruby.md
CHANGED
@@ -20,6 +20,7 @@ gem install squared
|
|
20
20
|
|
21
21
|
* [Repo](https://source.android.com/docs/setup/reference/repo)
|
22
22
|
* Python 3.6
|
23
|
+
* Not compatible with Windows
|
23
24
|
|
24
25
|
```sh
|
25
26
|
mkdir -p ~/.bin
|
@@ -30,7 +31,7 @@ chmod a+rx ~/.bin/repo
|
|
30
31
|
|
31
32
|
## Example - Rakefile
|
32
33
|
|
33
|
-
Projects from any accessible folder can be added
|
34
|
+
Projects from any accessible folder can be added relative to the parent directory (e.g. *REPO_ROOT*) or absolutely. The same Rakefile can also manage other similarly cloned `Repo` repositories remotely by setting the `REPO_ROOT` environment variable to the location. Missing projects will simply be excluded from the task runner.
|
34
35
|
|
35
36
|
```ruby
|
36
37
|
require "squared"
|
@@ -45,7 +46,7 @@ require "squared/app" # All workspace related modules
|
|
45
46
|
|
46
47
|
# NODE_ENV = production
|
47
48
|
# REPO_ROOT = /workspaces
|
48
|
-
# REPO_HOME = /workspaces/squared
|
49
|
+
# REPO_HOME = /workspaces/squared
|
49
50
|
# rake = /workspaces/squared/Rakefile
|
50
51
|
# pathname = /workspaces/pathname
|
51
52
|
# optparse = /workspaces/optparse
|
@@ -88,7 +89,7 @@ Workspace::Application
|
|
88
89
|
variable_set :clean, ["build/sqd/"]
|
89
90
|
end
|
90
91
|
.style("banner", 255.255) # 256 colors (fg | fg.bg | -0.bg)
|
91
|
-
.build(default: "
|
92
|
+
.build(default: "build", parallel: ["pull", "fetch", "rebase", "copy", "clean", /^outdated:/]) do |workspace|
|
92
93
|
workspace
|
93
94
|
.enable_aixterm
|
94
95
|
.style({
|
@@ -130,12 +131,13 @@ Workspace::Application
|
|
130
131
|
```ruby
|
131
132
|
Workspace::Application
|
132
133
|
.new(main: "squared")
|
134
|
+
.graph(["depend"], ref: :git) # Optional
|
133
135
|
.with(:python) do
|
134
136
|
add("android-docs", "android")
|
135
137
|
add("chrome-docs", "chrome", graph: "android")
|
136
138
|
end
|
137
139
|
.with(:node) do
|
138
|
-
graph(["build", "copy"]) #
|
140
|
+
graph(["build", "copy"]) # Overrides "git"
|
139
141
|
add("e-mc", "emc")
|
140
142
|
add("pi-r", "pir", graph: "emc")
|
141
143
|
add("squared-express", "express", graph: "pir")
|
data/lib/squared/common/class.rb
CHANGED
@@ -15,7 +15,7 @@ module Squared
|
|
15
15
|
def_delegators :@data, :+, :each, :each_with_index, :entries, :to_a, :include?
|
16
16
|
|
17
17
|
def initialize(data = [])
|
18
|
-
@data =
|
18
|
+
@data = Set.new(data)
|
19
19
|
end
|
20
20
|
|
21
21
|
def add(val)
|
@@ -29,7 +29,7 @@ module Squared
|
|
29
29
|
alias inspect to_s
|
30
30
|
end
|
31
31
|
|
32
|
-
class JoinSet <
|
32
|
+
class JoinSet < Set
|
33
33
|
def self.to_s
|
34
34
|
super.match(/[^:]+$/)[0]
|
35
35
|
end
|
@@ -20,17 +20,21 @@ module Squared
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def copy_d(src, dest, glob: ['**/*'], create: false, verbose: true)
|
23
|
+
def copy_d(src, dest, glob: ['**/*'], pass: nil, create: false, verbose: true)
|
24
24
|
src = ::Pathname.new(src)
|
25
25
|
dest = ::Pathname.new(dest)
|
26
|
-
raise "#{dest} (not found)" if !create && !dest.exist?
|
26
|
+
raise "#{dest} (not found)" if !create && !dest.parent.exist?
|
27
27
|
|
28
28
|
subdir = []
|
29
29
|
files = 0
|
30
30
|
dest.mkpath if create
|
31
|
+
if pass
|
32
|
+
exclude = []
|
33
|
+
(pass.is_a?(::Array) ? pass : [pass]).each { |val| exclude += ::Dir.glob(src.join(val)) }
|
34
|
+
end
|
31
35
|
(glob.is_a?(::Array) ? glob : [glob]).each do |val|
|
32
36
|
::Dir.glob(src.join(val)) do |path|
|
33
|
-
next if (path = ::Pathname.new(path)).directory?
|
37
|
+
next if exclude&.include?(path) || (path = ::Pathname.new(path)).directory?
|
34
38
|
|
35
39
|
target = dest.join(path.relative_path_from(src))
|
36
40
|
dir = target.dirname
|
data/lib/squared/common/utils.rb
CHANGED
@@ -27,8 +27,12 @@ module Squared
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def task_invoked?(
|
31
|
-
::Rake::Task.tasks.any?
|
30
|
+
def task_invoked?(*args)
|
31
|
+
::Rake::Task.tasks.any? do |obj|
|
32
|
+
next unless obj.already_invoked
|
33
|
+
|
34
|
+
args.any? { |val| val.is_a?(::Regexp) ? val.match?(obj.name) : val == obj.name }
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
def env(key, default = nil, suffix: @envname, equals: nil, ignore: nil)
|
data/lib/squared/config.rb
CHANGED
@@ -9,7 +9,7 @@ module Squared
|
|
9
9
|
class Viewer
|
10
10
|
include Common::Format
|
11
11
|
include Utils
|
12
|
-
include
|
12
|
+
include Rake::DSL
|
13
13
|
|
14
14
|
def self.to_s
|
15
15
|
super.match(/[^:]+$/)[0]
|
@@ -51,7 +51,7 @@ module Squared
|
|
51
51
|
['path not found', realpath]
|
52
52
|
else
|
53
53
|
@required = true
|
54
|
-
project ? [project, 'not found'] :
|
54
|
+
project ? [project, 'not found'] : ['name', 'missing']
|
55
55
|
end
|
56
56
|
warn log_message(:warn, msg, subject: self.class, hint: hint)
|
57
57
|
end
|
@@ -63,18 +63,18 @@ module Squared
|
|
63
63
|
view = @command && @command != name ? @command : 'view'
|
64
64
|
params = ->(args) { exist? ? [realpath, [args.keys] + args.extras] : [args.keys, args.extras] }
|
65
65
|
namespace view do
|
66
|
-
if @mime['json'] && (exist? ||
|
66
|
+
if @mime['json'] && (exist? || !Rake::Task.task_defined?("#{ns}:#{view}:json"))
|
67
67
|
desc format_desc(view, 'json')
|
68
68
|
task 'json', [:keys] do |_, args|
|
69
69
|
read_keys(JSON, 'json', *params.(args))
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
if @mime['yaml'] && (exist? ||
|
73
|
+
if @mime['yaml'] && (exist? || !Rake::Task.task_defined?("#{ns}:#{view}:yaml"))
|
74
74
|
desc format_desc(view, 'yaml', 'yml')
|
75
75
|
task 'yaml', [:keys] do |_, args|
|
76
76
|
require 'yaml'
|
77
|
-
read_keys(YAML, 'yaml', *params.(args), ext:
|
77
|
+
read_keys(YAML, 'yaml', *params.(args), ext: ['yml', 'yaml'])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -120,7 +120,7 @@ module Squared
|
|
120
120
|
def also(path, type = nil, name: nil, gem: nil, parse: nil, opts: {})
|
121
121
|
return self if @mime.frozen? || !(file = basepath(path)).exist?
|
122
122
|
|
123
|
-
ext =
|
123
|
+
ext = mimetype(file)
|
124
124
|
type = type&.to_s || ext
|
125
125
|
unless parse
|
126
126
|
case type
|
@@ -140,6 +140,12 @@ module Squared
|
|
140
140
|
self
|
141
141
|
end
|
142
142
|
|
143
|
+
def enabled?
|
144
|
+
return File.exist?(realpath) if exist?
|
145
|
+
|
146
|
+
!@required || !!project&.enabled?
|
147
|
+
end
|
148
|
+
|
143
149
|
def extensions
|
144
150
|
exist? ? [@ext.sub('.', '')] : @mime.keys
|
145
151
|
end
|
@@ -154,12 +160,6 @@ module Squared
|
|
154
160
|
"#<#{self.class}: #{name} => #{exist? ? realpath : "#{main} {#{extensions.join(', ')}}"}>"
|
155
161
|
end
|
156
162
|
|
157
|
-
def enabled?
|
158
|
-
return File.exist?(realpath) if exist?
|
159
|
-
|
160
|
-
!@required || !!project&.enabled?
|
161
|
-
end
|
162
|
-
|
163
163
|
private
|
164
164
|
|
165
165
|
def puts(*args)
|
@@ -167,7 +167,7 @@ module Squared
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def read_keys(reader, type, file, keys, ext: [type])
|
170
|
-
if file && (mime =
|
170
|
+
if file && (mime = mimetype(file)) && basepath(file).exist?
|
171
171
|
raise_error(file, mime, hint: 'invalid') unless ext.include?(mime)
|
172
172
|
else
|
173
173
|
if ext.include?(mime)
|
@@ -227,7 +227,7 @@ module Squared
|
|
227
227
|
if val.nil?
|
228
228
|
val = data
|
229
229
|
items.each do |name|
|
230
|
-
raise name unless val.is_a?(
|
230
|
+
raise name unless val.is_a?(Hash) && val.key?(name)
|
231
231
|
|
232
232
|
val = val[name]
|
233
233
|
end
|
@@ -256,15 +256,28 @@ module Squared
|
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
|
-
def basepath(file)
|
260
|
-
project ? project.basepath(file) : Pathname.new(file).realdirpath
|
261
|
-
end
|
262
|
-
|
263
259
|
def task_name(val)
|
264
260
|
@prefix ? "#{@prefix}:#{val}" : val.to_s
|
265
261
|
end
|
266
262
|
|
267
|
-
def
|
263
|
+
def format_desc(command, *ext, exist: exist?)
|
264
|
+
val = "#{ext.first}[#{exist ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys+]"
|
265
|
+
message(@prefix, *name.split(':'), command, val, empty: true)
|
266
|
+
end
|
267
|
+
|
268
|
+
def exist?
|
269
|
+
!@ext.empty? && (!@required || !project.nil?)
|
270
|
+
end
|
271
|
+
|
272
|
+
def warning?
|
273
|
+
project ? project.workspace.warning : true
|
274
|
+
end
|
275
|
+
|
276
|
+
def stdin?
|
277
|
+
pipe == 0
|
278
|
+
end
|
279
|
+
|
280
|
+
def mimetype(file)
|
268
281
|
case (ret = File.extname(file).sub('.', '').downcase)
|
269
282
|
when 'yml'
|
270
283
|
'yaml'
|
@@ -277,25 +290,12 @@ module Squared
|
|
277
290
|
end
|
278
291
|
end
|
279
292
|
|
280
|
-
def format_desc(command, *ext, exist: exist?)
|
281
|
-
val = "#{ext.first}[#{exist ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys+]"
|
282
|
-
message(@prefix, *name.split(':'), command, val, empty: true)
|
283
|
-
end
|
284
|
-
|
285
293
|
def realpath
|
286
294
|
basepath(file = main + @ext).to_s rescue file
|
287
295
|
end
|
288
296
|
|
289
|
-
def
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
def warning?
|
294
|
-
project ? project.workspace.warning : true
|
295
|
-
end
|
296
|
-
|
297
|
-
def stdin?
|
298
|
-
pipe == 0
|
297
|
+
def basepath(file)
|
298
|
+
project ? project.basepath(file) : Pathname.new(file).realdirpath
|
299
299
|
end
|
300
300
|
end
|
301
301
|
end
|
data/lib/squared/version.rb
CHANGED
@@ -5,7 +5,7 @@ module Squared
|
|
5
5
|
class Application
|
6
6
|
include Common::Format
|
7
7
|
include Utils
|
8
|
-
include
|
8
|
+
include Rake::DSL
|
9
9
|
|
10
10
|
SCRIPT_OBJ = {
|
11
11
|
run: nil,
|
@@ -18,12 +18,19 @@ module Squared
|
|
18
18
|
private_constant :SCRIPT_OBJ
|
19
19
|
|
20
20
|
class << self
|
21
|
-
def implement(*objs)
|
21
|
+
def implement(*objs, base: false)
|
22
|
+
return if base && objs.size > 1
|
23
|
+
|
22
24
|
objs.each do |obj|
|
23
|
-
next unless obj < impl_project
|
25
|
+
next unless base || obj < impl_project
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
if base
|
28
|
+
@impl_project = obj
|
29
|
+
impl_series.base_set(obj)
|
30
|
+
else
|
31
|
+
kind_project.unshift(obj)
|
32
|
+
obj.tasks&.each { |task| impl_series.add(task, obj) }
|
33
|
+
end
|
27
34
|
if (args = obj.batchargs)
|
28
35
|
impl_series.batch(*args)
|
29
36
|
end
|
@@ -71,12 +78,12 @@ module Squared
|
|
71
78
|
@extensions = []
|
72
79
|
@pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
|
73
80
|
@exception = env_bool(exception)
|
74
|
-
@verbose = env_bool(verbose, verbose.nil? || verbose.is_a?(
|
81
|
+
@verbose = env_bool(verbose, verbose.nil? || verbose.is_a?(String) ? @pipe != 0 : verbose)
|
75
82
|
@warning = @verbose != false
|
76
83
|
@closed = false
|
77
84
|
if common
|
78
85
|
@theme = __get__(:theme)[:workspace]
|
79
|
-
ARG[:COLOR] = false if @pipe == 0 || @pipe.is_a?(
|
86
|
+
ARG[:COLOR] = false if @pipe == 0 || @pipe.is_a?(Pathname)
|
80
87
|
else
|
81
88
|
@theme = {}
|
82
89
|
end
|
@@ -95,7 +102,7 @@ module Squared
|
|
95
102
|
|
96
103
|
def initialize_session
|
97
104
|
@envname = @main.gsub(/[^\w]+/, '_').upcase.freeze
|
98
|
-
return unless @pipe.is_a?(
|
105
|
+
return unless @pipe.is_a?(Pathname)
|
99
106
|
|
100
107
|
bord = '#' * Project.line_width
|
101
108
|
puts bord, format('Session started on %s by %s', Time.now.to_s, @main), bord
|
@@ -104,7 +111,13 @@ module Squared
|
|
104
111
|
def build(parallel: [], **kwargs)
|
105
112
|
return self unless enabled? && !@closed
|
106
113
|
|
107
|
-
kwargs[:
|
114
|
+
if kwargs[:pattern].is_a?(Array)
|
115
|
+
kwargs[:parallel] = parallel.map(&:to_s)
|
116
|
+
else
|
117
|
+
kwargs[:pattern] = []
|
118
|
+
kwargs[:parallel] = parallel.reject { |val| val.is_a?(Regexp) && (kwargs[:pattern] << val) }
|
119
|
+
.map(&:to_s)
|
120
|
+
end
|
108
121
|
@project.each_value do |proj|
|
109
122
|
next unless proj.enabled?
|
110
123
|
|
@@ -131,9 +144,9 @@ module Squared
|
|
131
144
|
kind = val.first
|
132
145
|
val = kind if val.size == 1
|
133
146
|
case kind
|
134
|
-
when
|
147
|
+
when String
|
135
148
|
@group = val
|
136
|
-
when
|
149
|
+
when Symbol
|
137
150
|
@ref = val
|
138
151
|
else
|
139
152
|
raise_error('group{Symbol} | ref{String}', hint: 'missing') if block_given?
|
@@ -182,14 +195,14 @@ module Squared
|
|
182
195
|
def banner(*args, command: true, styles: nil, border: nil, group: @group, ref: @ref)
|
183
196
|
data = { command: command, order: [], styles: check_style(styles, empty: false), border: check_style(border) }
|
184
197
|
args.each do |meth|
|
185
|
-
if meth.is_a?(
|
198
|
+
if meth.is_a?(Array)
|
186
199
|
found = false
|
187
200
|
meth = meth.select do |val|
|
188
201
|
case val
|
189
|
-
when
|
202
|
+
when Symbol
|
190
203
|
found = true
|
191
204
|
Application.attr_banner.include?(val)
|
192
|
-
when
|
205
|
+
when String
|
193
206
|
true
|
194
207
|
else
|
195
208
|
false
|
@@ -227,10 +240,10 @@ module Squared
|
|
227
240
|
ref = if kwargs.key?(:ref)
|
228
241
|
kwargs = kwargs.dup unless @withargs
|
229
242
|
kwargs.delete(:ref)
|
230
|
-
elsif @ref.is_a?(
|
243
|
+
elsif @ref.is_a?(Symbol)
|
231
244
|
@ref
|
232
245
|
end
|
233
|
-
if @group.is_a?(
|
246
|
+
if @group.is_a?(String) && !kwargs.key?(:group)
|
234
247
|
kwargs = kwargs.dup unless @withargs
|
235
248
|
kwargs[:group] = @group
|
236
249
|
end
|
@@ -242,7 +255,7 @@ module Squared
|
|
242
255
|
index += 1
|
243
256
|
name = "#{project}-#{index}"
|
244
257
|
end
|
245
|
-
proj = ((if !ref.is_a?(
|
258
|
+
proj = ((if !ref.is_a?(Class)
|
246
259
|
Application.find(ref, path: path)
|
247
260
|
elsif ref < Project::Base
|
248
261
|
ref
|
@@ -359,18 +372,33 @@ module Squared
|
|
359
372
|
ret
|
360
373
|
end
|
361
374
|
|
375
|
+
def task_sync(key)
|
376
|
+
key = task_name(key)
|
377
|
+
task_defined?(ret = task_join(key, 'sync')) ? ret : key
|
378
|
+
end
|
379
|
+
|
362
380
|
def script_find(*args)
|
363
381
|
args.reverse_each do |val|
|
364
|
-
next unless val && (ret = val.is_a?(
|
382
|
+
next unless val && (ret = val.is_a?(Symbol) ? @script[:ref!][val] : @script[:group!][val.to_sym])
|
365
383
|
|
366
384
|
return ret
|
367
385
|
end
|
368
386
|
@script[:ref!][:_] || SCRIPT_OBJ
|
369
387
|
end
|
370
388
|
|
371
|
-
def script_get(group: nil, ref: nil)
|
389
|
+
def script_get(*args, group: nil, ref: nil)
|
372
390
|
if group
|
373
391
|
@script[:group][group.to_sym]
|
392
|
+
elsif ref.is_a?(Array)
|
393
|
+
ref = ref.each
|
394
|
+
end
|
395
|
+
if ref.instance_of?(Enumerator)
|
396
|
+
ref.each do |key|
|
397
|
+
next unless (ret = @script[:ref][key])
|
398
|
+
|
399
|
+
return ret if args.empty? || args.any? { |val| ret.key?(val) }
|
400
|
+
end
|
401
|
+
nil
|
374
402
|
elsif ref
|
375
403
|
@script[:ref][ref]
|
376
404
|
end
|
@@ -384,14 +412,6 @@ module Squared
|
|
384
412
|
@banner[:ref][:_]
|
385
413
|
end
|
386
414
|
|
387
|
-
def to_s
|
388
|
-
(home? ? home : root).to_s
|
389
|
-
end
|
390
|
-
|
391
|
-
def inspect
|
392
|
-
"#<#{self.class}: #{main} => #{self}>"
|
393
|
-
end
|
394
|
-
|
395
415
|
def enabled?
|
396
416
|
!@extensions.empty? || @project.values.any?(&:enabled?)
|
397
417
|
end
|
@@ -409,7 +429,7 @@ module Squared
|
|
409
429
|
end
|
410
430
|
|
411
431
|
def task_defined?(*key)
|
412
|
-
|
432
|
+
Rake::Task.task_defined?(key.size == 1 ? key.first : task_join(*key))
|
413
433
|
end
|
414
434
|
|
415
435
|
def dev?(**kwargs)
|
@@ -432,6 +452,10 @@ module Squared
|
|
432
452
|
home.join(*args)
|
433
453
|
end
|
434
454
|
|
455
|
+
def pwd
|
456
|
+
Pathname.new(Rake.application.original_dir)
|
457
|
+
end
|
458
|
+
|
435
459
|
def baseref
|
436
460
|
Application.baseref
|
437
461
|
end
|
@@ -440,14 +464,22 @@ module Squared
|
|
440
464
|
{ exception: exception, warning: warning }
|
441
465
|
end
|
442
466
|
|
467
|
+
def to_s
|
468
|
+
(home? ? home : root).to_s
|
469
|
+
end
|
470
|
+
|
471
|
+
def inspect
|
472
|
+
"#<#{self.class}: #{main} => #{self}>"
|
473
|
+
end
|
474
|
+
|
443
475
|
public :task_join
|
444
476
|
|
445
477
|
private
|
446
478
|
|
447
479
|
def __build__(default: nil, **)
|
448
|
-
|
449
|
-
|
450
|
-
|
480
|
+
return unless default && task_defined?(out = task_name(default))
|
481
|
+
|
482
|
+
task Rake.application.default_task_name => out
|
451
483
|
end
|
452
484
|
|
453
485
|
def puts(*args)
|
@@ -477,10 +509,6 @@ module Squared
|
|
477
509
|
end
|
478
510
|
end
|
479
511
|
|
480
|
-
def script_obj
|
481
|
-
SCRIPT_OBJ.dup
|
482
|
-
end
|
483
|
-
|
484
512
|
def script?(state, target: nil, pat: nil, group: nil, ref: baseref, global: false)
|
485
513
|
data = script_find(ref, group)
|
486
514
|
if global
|
@@ -489,7 +517,11 @@ module Squared
|
|
489
517
|
end
|
490
518
|
return false if state == :prod && data[:dev] == true && data[:global]
|
491
519
|
|
492
|
-
target && pat.is_a?(
|
520
|
+
target && pat.is_a?(Regexp) ? as_a(target).any? { |val| pat.match?(val) } : pat == true
|
521
|
+
end
|
522
|
+
|
523
|
+
def scriptobj
|
524
|
+
SCRIPT_OBJ.dup
|
493
525
|
end
|
494
526
|
end
|
495
527
|
end
|