squared 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ruby.md +55 -2
- data/lib/squared/common/base.rb +5 -3
- data/lib/squared/common/class.rb +10 -2
- data/lib/squared/common/format.rb +29 -18
- data/lib/squared/common/prompt.rb +2 -4
- data/lib/squared/common/shell.rb +4 -3
- data/lib/squared/common/system.rb +12 -14
- data/lib/squared/common/utils.rb +29 -3
- data/lib/squared/common.rb +0 -4
- data/lib/squared/config.rb +35 -32
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +51 -45
- data/lib/squared/workspace/project/base.rb +248 -83
- data/lib/squared/workspace/project/git.rb +38 -44
- data/lib/squared/workspace/project/node.rb +57 -96
- data/lib/squared/workspace/project/python.rb +16 -19
- data/lib/squared/workspace/project/ruby.rb +69 -48
- data/lib/squared/workspace/repo.rb +12 -11
- data/lib/squared/workspace/series.rb +15 -14
- data/lib/squared/workspace.rb +1 -1
- metadata +2 -3
- data/lib/squared/common/task.rb +0 -25
@@ -3,8 +3,8 @@
|
|
3
3
|
module Squared
|
4
4
|
module Workspace
|
5
5
|
class Application
|
6
|
-
include Common
|
7
|
-
include
|
6
|
+
include Common::Format
|
7
|
+
include Utils
|
8
8
|
include ::Rake::DSL
|
9
9
|
|
10
10
|
SCRIPT_OBJ = {
|
@@ -20,9 +20,9 @@ module Squared
|
|
20
20
|
class << self
|
21
21
|
def implement(*objs)
|
22
22
|
objs.each do |obj|
|
23
|
-
next unless obj <
|
23
|
+
next unless obj < impl_project
|
24
24
|
|
25
|
-
|
25
|
+
kind_project.unshift(obj)
|
26
26
|
obj.tasks&.each { |task| impl_series.add(task, obj) }
|
27
27
|
if (args = obj.batchargs)
|
28
28
|
impl_series.batch(*args)
|
@@ -30,36 +30,38 @@ module Squared
|
|
30
30
|
if (args = obj.aliasargs)
|
31
31
|
impl_series.alias(*args)
|
32
32
|
end
|
33
|
+
if (args = obj.bannerargs)
|
34
|
+
@attr_banner += args
|
35
|
+
end
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
36
39
|
def find(ref = nil, path: nil)
|
37
|
-
if ref && (ret =
|
40
|
+
if ref && (ret = kind_project.find { |proj| proj.ref == ref })
|
38
41
|
ret
|
39
42
|
elsif path
|
40
|
-
|
43
|
+
kind_project.find { |proj| proj.config?(path) }
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
47
|
def baseref
|
45
|
-
|
48
|
+
impl_project.ref
|
46
49
|
end
|
47
50
|
|
48
51
|
def to_s
|
49
|
-
super.
|
52
|
+
super.match(/[^:]+$/)[0]
|
50
53
|
end
|
51
54
|
|
52
|
-
attr_reader :
|
53
|
-
attr_accessor :impl_series, :
|
55
|
+
attr_reader :kind_project
|
56
|
+
attr_accessor :impl_series, :impl_project, :attr_banner
|
54
57
|
end
|
55
58
|
|
56
|
-
@
|
57
|
-
@attr_banner = SymSet.new(%i[name project path ref group parent version])
|
59
|
+
@kind_project = []
|
58
60
|
|
59
61
|
attr_reader :root, :home, :main, :prefix, :exception, :warning, :pipe, :verbose, :theme, :series, :closed
|
60
62
|
|
61
|
-
def initialize(home = Dir.pwd, *, main: nil, prefix: nil,
|
62
|
-
common: ARG[:COMMON], pipe: ARG[:PIPE], exception: ARG[:FAIL], **)
|
63
|
+
def initialize(home = Dir.pwd, *, main: nil, prefix: nil,
|
64
|
+
verbose: ARG[:VERBOSE], common: ARG[:COMMON], pipe: ARG[:PIPE], exception: ARG[:FAIL], **)
|
63
65
|
@home = Pathname.new(home).realdirpath
|
64
66
|
@root = @home.parent
|
65
67
|
@main = (main || @home.basename).to_s.freeze
|
@@ -69,7 +71,7 @@ module Squared
|
|
69
71
|
@extensions = []
|
70
72
|
@pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
|
71
73
|
@exception = env_bool(exception)
|
72
|
-
@verbose = verbose.nil? ? @pipe != 0 : verbose
|
74
|
+
@verbose = env_bool(verbose, verbose.nil? || verbose.is_a?(::String) ? @pipe != 0 : verbose)
|
73
75
|
@warning = @verbose != false
|
74
76
|
@closed = false
|
75
77
|
if common
|
@@ -100,9 +102,9 @@ module Squared
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def build(parallel: [], **kwargs)
|
103
|
-
|
104
|
-
return if @closed || !enabled?
|
105
|
+
return self unless enabled? && !@closed
|
105
106
|
|
107
|
+
kwargs[:parallel] = parallel.map(&:to_s)
|
106
108
|
@project.each_value do |proj|
|
107
109
|
next unless proj.enabled?
|
108
110
|
|
@@ -110,7 +112,7 @@ module Squared
|
|
110
112
|
series.populate(proj)
|
111
113
|
end
|
112
114
|
|
113
|
-
Application.
|
115
|
+
Application.kind_project.each { |obj| obj.populate(self, **kwargs) }
|
114
116
|
@extensions.each { |ext| __send__(ext, **kwargs) }
|
115
117
|
|
116
118
|
series.build(**kwargs)
|
@@ -118,13 +120,14 @@ module Squared
|
|
118
120
|
|
119
121
|
yield self if block_given?
|
120
122
|
@closed = true
|
123
|
+
self
|
121
124
|
end
|
122
125
|
|
123
126
|
def with(*val, group: nil, **kwargs, &blk)
|
124
127
|
@group = nil
|
125
128
|
@ref = nil
|
126
129
|
@withargs = kwargs.empty? ? nil : kwargs
|
127
|
-
val =
|
130
|
+
val = as_a(group || kwargs[:ref], flat: true, compact: true) if val.empty?
|
128
131
|
kind = val.first
|
129
132
|
val = kind if val.size == 1
|
130
133
|
case kind
|
@@ -152,6 +155,10 @@ module Squared
|
|
152
155
|
script_command :depend, script, group, ref
|
153
156
|
end
|
154
157
|
|
158
|
+
def graph(script, group: @group, ref: @ref)
|
159
|
+
script_command :graph, as_a(script, :to_s).freeze, group, ref
|
160
|
+
end
|
161
|
+
|
155
162
|
def clean(script, group: @group, ref: @ref)
|
156
163
|
script_command :clean, script, group, ref
|
157
164
|
end
|
@@ -211,7 +218,7 @@ module Squared
|
|
211
218
|
self
|
212
219
|
end
|
213
220
|
|
214
|
-
def add(path,
|
221
|
+
def add(path, project = nil, **kwargs, &blk)
|
215
222
|
if @withargs
|
216
223
|
data = @withargs.dup
|
217
224
|
data.merge!(kwargs)
|
@@ -227,19 +234,19 @@ module Squared
|
|
227
234
|
kwargs = kwargs.dup unless @withargs
|
228
235
|
kwargs[:group] = @group
|
229
236
|
end
|
230
|
-
path =
|
231
|
-
|
232
|
-
name =
|
237
|
+
path = rootpath(path)
|
238
|
+
project = (project || path.basename).to_s
|
239
|
+
name = task_name(project)
|
233
240
|
index = 0
|
234
241
|
while @project[name]
|
235
242
|
index += 1
|
236
|
-
name =
|
243
|
+
name = "#{project}-#{index}"
|
237
244
|
end
|
238
245
|
proj = ((if !ref.is_a?(::Class)
|
239
246
|
Application.find(ref, path: path)
|
240
247
|
elsif ref < Project::Base
|
241
248
|
ref
|
242
|
-
end) || Project::Base).new(self, path,
|
249
|
+
end) || Project::Base).new(self, path, name, **kwargs)
|
243
250
|
@project[name] = proj
|
244
251
|
__get__(:project)[name] = proj unless kwargs[:private]
|
245
252
|
proj.instance_eval(&blk) if block_given?
|
@@ -247,11 +254,11 @@ module Squared
|
|
247
254
|
end
|
248
255
|
|
249
256
|
def group(path, val, override: {}, **kwargs, &blk)
|
250
|
-
|
257
|
+
rootpath(path).children.map do |dir|
|
251
258
|
next unless dir.directory?
|
252
259
|
|
253
|
-
basename = dir.basename.to_s
|
254
|
-
[dir, basename, override[basename]]
|
260
|
+
basename = dir.basename.to_s
|
261
|
+
[dir, basename, override[basename.to_sym]]
|
255
262
|
end
|
256
263
|
.each do |dir, basename, opts|
|
257
264
|
args = kwargs.dup
|
@@ -271,7 +278,7 @@ module Squared
|
|
271
278
|
self
|
272
279
|
end
|
273
280
|
|
274
|
-
def style(
|
281
|
+
def style(obj, *args, target: nil, empty: false)
|
275
282
|
data = nil
|
276
283
|
if target
|
277
284
|
as_a(target).each_with_index do |key, i|
|
@@ -282,13 +289,14 @@ module Squared
|
|
282
289
|
end
|
283
290
|
end
|
284
291
|
end
|
285
|
-
apply_style(data || theme,
|
292
|
+
apply_style(data || theme, obj, args, empty: empty) unless target && !data
|
286
293
|
self
|
287
294
|
end
|
288
295
|
|
289
296
|
def find(path = nil, name: nil)
|
290
|
-
path
|
291
|
-
|
297
|
+
path &&= rootpath(path)
|
298
|
+
name &&= name.to_s
|
299
|
+
ret = @project.find { |_, item| (path && item.path == path) || (name && item.name == name) }&.last
|
292
300
|
return ret unless block_given?
|
293
301
|
|
294
302
|
yield ret if ret
|
@@ -296,7 +304,7 @@ module Squared
|
|
296
304
|
end
|
297
305
|
|
298
306
|
def find_base(obj)
|
299
|
-
Application.
|
307
|
+
Application.kind_project.find { |proj| obj.instance_of?(proj) }
|
300
308
|
end
|
301
309
|
|
302
310
|
def task_name(val, desc: false)
|
@@ -310,10 +318,6 @@ module Squared
|
|
310
318
|
first ? ret.first : task_join(*ret[0..-2])
|
311
319
|
end
|
312
320
|
|
313
|
-
def task_join(*val)
|
314
|
-
val.join(':')
|
315
|
-
end
|
316
|
-
|
317
321
|
def task_resolve(obj, key)
|
318
322
|
tasks = []
|
319
323
|
if (base = task_base?(key))
|
@@ -355,14 +359,6 @@ module Squared
|
|
355
359
|
ret
|
356
360
|
end
|
357
361
|
|
358
|
-
def root_path(*args)
|
359
|
-
root.join(*args)
|
360
|
-
end
|
361
|
-
|
362
|
-
def home_path(*args)
|
363
|
-
home.join(*args)
|
364
|
-
end
|
365
|
-
|
366
362
|
def script_find(*args)
|
367
363
|
args.reverse_each do |val|
|
368
364
|
next unless val && (ret = val.is_a?(::Symbol) ? @script[:ref!][val] : @script[:group!][val.to_sym])
|
@@ -428,6 +424,14 @@ module Squared
|
|
428
424
|
!(proj = find(home)).nil? && proj.enabled?
|
429
425
|
end
|
430
426
|
|
427
|
+
def rootpath(*args)
|
428
|
+
root.join(*args)
|
429
|
+
end
|
430
|
+
|
431
|
+
def homepath(*args)
|
432
|
+
home.join(*args)
|
433
|
+
end
|
434
|
+
|
431
435
|
def baseref
|
432
436
|
Application.baseref
|
433
437
|
end
|
@@ -436,6 +440,8 @@ module Squared
|
|
436
440
|
{ exception: exception, warning: warning }
|
437
441
|
end
|
438
442
|
|
443
|
+
public :task_join
|
444
|
+
|
439
445
|
private
|
440
446
|
|
441
447
|
def __build__(default: nil, **)
|