squared 0.0.10 → 0.0.11
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 +45 -26
- data/lib/squared/app.rb +10 -0
- data/lib/squared/common/base.rb +7 -13
- data/lib/squared/common/class.rb +20 -3
- data/lib/squared/common/format.rb +59 -15
- data/lib/squared/common/prompt.rb +38 -0
- data/lib/squared/common/system.rb +6 -36
- data/lib/squared/common/task.rb +3 -2
- data/lib/squared/common/utils.rb +25 -16
- data/lib/squared/common.rb +1 -0
- data/lib/squared/config.rb +18 -16
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +224 -110
- data/lib/squared/workspace/project/base.rb +258 -163
- data/lib/squared/workspace/project/git.rb +66 -76
- data/lib/squared/workspace/project/node.rb +220 -73
- data/lib/squared/workspace/project/python.rb +22 -16
- data/lib/squared/workspace/project/ruby.rb +76 -60
- data/lib/squared/workspace/project.rb +0 -3
- data/lib/squared/workspace/repo.rb +25 -12
- data/lib/squared/workspace/series.rb +80 -52
- data/lib/squared/workspace.rb +5 -4
- data/lib/squared.rb +1 -11
- metadata +4 -2
@@ -14,25 +14,25 @@ module Squared
|
|
14
14
|
|
15
15
|
class << self
|
16
16
|
def populate(*); end
|
17
|
+
def batchargs(*); end
|
18
|
+
def aliasargs(*); end
|
17
19
|
|
18
20
|
def tasks
|
19
|
-
|
21
|
+
%i[outdated].freeze
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
24
|
+
def config?(val)
|
25
|
+
return false unless (val = as_path(val))
|
26
|
+
|
27
|
+
RUBY_DIR.any? { |file| val.join(file).exist? }
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
@@tasks[ref] = {
|
32
|
-
install: %i[redownload local prefer-local gem with without],
|
33
|
-
update: %i[all patch minor major],
|
34
|
-
outdated: %i[patch minor major],
|
35
|
-
pristine: %i[gem all version],
|
32
|
+
install: %i[redownload local prefer-local gem with without].freeze,
|
33
|
+
update: %i[all patch minor major].freeze,
|
34
|
+
outdated: %i[patch minor major].freeze,
|
35
|
+
pristine: %i[gem all version].freeze,
|
36
36
|
exec: nil,
|
37
37
|
config: nil,
|
38
38
|
rake: nil
|
@@ -154,7 +154,7 @@ module Squared
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
def depend(flag = nil, opts: [])
|
157
|
+
def depend(flag = nil, opts: [], sync: invoked_sync?('depend', flag))
|
158
158
|
if @depend && !flag
|
159
159
|
super
|
160
160
|
elsif outdated?
|
@@ -167,7 +167,7 @@ module Squared
|
|
167
167
|
append_repeat flag, opts
|
168
168
|
when :redownload, :local, :'prefer-local'
|
169
169
|
cmd = bundle_session 'install', "--#{flag}"
|
170
|
-
if (val =
|
170
|
+
if (val = option('trust-policy', ignore: false))
|
171
171
|
cmd << "--trust-policy=#{case val
|
172
172
|
when '0'
|
173
173
|
'NoSecurity'
|
@@ -188,28 +188,28 @@ module Squared
|
|
188
188
|
bundle_session 'install'
|
189
189
|
append_bundle
|
190
190
|
end
|
191
|
-
run_rb(sync:
|
191
|
+
run_rb(sync: sync)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
def copy(from: 'lib', glob: '**/*',
|
195
|
+
def copy(from: 'lib', glob: '**/*', into: @gemdir, override: false)
|
196
196
|
if @copy && !override
|
197
197
|
return super if runnable?(@copy)
|
198
198
|
|
199
199
|
from = @copy[:from] if @copy.key?(:from)
|
200
200
|
glob = @copy[:glob] if @copy.key?(:glob)
|
201
|
-
|
201
|
+
into = @copy[:into] if @copy.key?(:into)
|
202
202
|
end
|
203
|
-
return unless
|
203
|
+
return unless into
|
204
204
|
|
205
|
-
dest = Pathname.new(
|
205
|
+
dest = Pathname.new(into).realpath
|
206
206
|
print_item unless @output[0]
|
207
207
|
glob = as_a(glob)
|
208
208
|
as_a(from).each_with_index do |val, i|
|
209
209
|
a = base_path(val)
|
210
210
|
b = dest.join(val)
|
211
211
|
c = glob[i] || '**/*'
|
212
|
-
log.
|
212
|
+
log.info "cp #{a.join(c)} #{b}"
|
213
213
|
copy_d(a, b, glob: c, verbose: verbose)
|
214
214
|
end
|
215
215
|
end
|
@@ -217,7 +217,7 @@ module Squared
|
|
217
217
|
def outdated(rev = nil, opts: [])
|
218
218
|
cmd = bundle_session 'outdated', rev && "--#{rev}"
|
219
219
|
append_bundle opts, OPT_OUTDATED
|
220
|
-
cmd =
|
220
|
+
cmd = session_done(cmd)
|
221
221
|
log.info cmd
|
222
222
|
banner = format_banner(cmd)
|
223
223
|
if invoked_sync?('outdated', rev)
|
@@ -232,31 +232,32 @@ module Squared
|
|
232
232
|
if start > 0
|
233
233
|
unless stdin?
|
234
234
|
data = line.scan(SEM_VER)
|
235
|
-
cur = data.shift
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
235
|
+
next unless (cur = data.shift) && (lat = data.shift)
|
236
|
+
|
237
|
+
semver(cur)
|
238
|
+
semver(lat)
|
239
|
+
c = cur.join
|
240
|
+
l = lat.join
|
241
|
+
styles = []
|
242
|
+
major_set = lambda do
|
243
|
+
styles = %i[green bold]
|
244
|
+
major += 1
|
245
|
+
end
|
246
|
+
minor_set = -> { styles[0] = cur[2] == lat[2] ? :yellow : :green }
|
247
|
+
if data.empty?
|
248
|
+
semmajor(cur, lat) ? major_set.() : minor_set.()
|
249
|
+
else
|
243
250
|
data.each do |val|
|
244
251
|
break unless (req = /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/.match(line))
|
245
252
|
|
246
253
|
v = semver(val).join
|
247
254
|
case req[1]
|
248
255
|
when '>', '>='
|
249
|
-
|
250
|
-
styles = %i[green bold]
|
251
|
-
major += 1
|
252
|
-
else
|
253
|
-
styles[0] = cur[2] == lat[2] ? :yellow : :green
|
254
|
-
end
|
256
|
+
semmajor(cur, lat) ? major_set.() : minor_set.()
|
255
257
|
when '<', '<='
|
256
258
|
if c <= v
|
257
259
|
if semmajor(cur, lat)
|
258
|
-
|
259
|
-
major += 1
|
260
|
+
major_set.()
|
260
261
|
else
|
261
262
|
styles[0] = :yellow
|
262
263
|
end
|
@@ -277,20 +278,20 @@ module Squared
|
|
277
278
|
end
|
278
279
|
end
|
279
280
|
end
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
styles = styles.compact
|
289
|
-
.map { |s| s == :green || s == :yellow ? color(s) : s }
|
290
|
-
.flatten
|
291
|
-
line = sub_style(line, pat: /^((?:\S+\s+){2})(#{Regexp.escape(l)})(.+)$/, styles: styles,
|
292
|
-
index: 2)
|
281
|
+
end
|
282
|
+
unless styles.empty?
|
283
|
+
case styles[0]
|
284
|
+
when :green
|
285
|
+
line = sub_style(line, pat: /^(\S+)(.+)$/, styles: theme[styles[1] == :bold ? :major : :active])
|
286
|
+
found += 1
|
287
|
+
when :yellow
|
288
|
+
found += 1
|
293
289
|
end
|
290
|
+
styles = styles.compact
|
291
|
+
.map { |s| s == :green || s == :yellow ? color(s) : s }
|
292
|
+
.flatten
|
293
|
+
line = sub_style(line, pat: /^((?:\S+\s+){2})(#{Regexp.escape(l)})(.*)$/, styles: styles,
|
294
|
+
index: 2)
|
294
295
|
end
|
295
296
|
end
|
296
297
|
puts "#{start.to_s.rjust(2)}. #{line}"
|
@@ -298,16 +299,24 @@ module Squared
|
|
298
299
|
elsif line =~ /^Gem /
|
299
300
|
print_item banner if banner
|
300
301
|
unless stdin?
|
301
|
-
|
302
|
-
|
303
|
-
{ pat: /^(.+)(Latest)(.+)$/, styles: theme[:header], index: 2 }
|
304
|
-
])
|
302
|
+
sub = { pat: /^(.+)(?<!\dm)(Gem|Latest)(.+)$/, styles: theme[:header], index: 2 }
|
303
|
+
puts print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub])
|
305
304
|
end
|
306
305
|
start += 1
|
307
306
|
end
|
308
307
|
end
|
309
308
|
if found > 0
|
310
|
-
|
309
|
+
begin
|
310
|
+
if major == 0 && (data = /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/.match(@gemfile.read))
|
311
|
+
status = (data[2] || data[3]).chomp('/')
|
312
|
+
right = true
|
313
|
+
end
|
314
|
+
rescue StandardError => e
|
315
|
+
log.debug e
|
316
|
+
ensure
|
317
|
+
status ||= 'Updates are available'
|
318
|
+
end
|
319
|
+
puts print_footer(empty_status(status, 'major', major, always: !right), right: right)
|
311
320
|
elsif start == 0
|
312
321
|
puts 'No updates were found'
|
313
322
|
end
|
@@ -357,13 +366,17 @@ module Squared
|
|
357
366
|
end
|
358
367
|
end
|
359
368
|
|
360
|
-
def
|
369
|
+
def variables
|
361
370
|
ret = super + VAR_SET
|
362
371
|
ret.freeze
|
363
372
|
end
|
364
373
|
|
374
|
+
def depend?
|
375
|
+
@depend != false && (!@depend.nil? || outdated?)
|
376
|
+
end
|
377
|
+
|
365
378
|
def copy?
|
366
|
-
return true if super || (@copy.is_a?(::Hash) && copy.fetch(:
|
379
|
+
return true if super || (@copy.is_a?(::Hash) && copy.fetch(:into, nil))
|
367
380
|
return gemdir? if @gemdir
|
368
381
|
|
369
382
|
if @version && (val = ENV['GEM_HOME'])
|
@@ -407,7 +420,7 @@ module Squared
|
|
407
420
|
end
|
408
421
|
|
409
422
|
def append_bundle(opts = nil, list = nil)
|
410
|
-
if (val =
|
423
|
+
if (val = option('jobs')).to_i > 0
|
411
424
|
@session << "-j#{val}"
|
412
425
|
end
|
413
426
|
return unless opts && list
|
@@ -423,16 +436,17 @@ module Squared
|
|
423
436
|
|
424
437
|
def gem_session(*cmd)
|
425
438
|
ret = session('gem', *cmd)
|
426
|
-
if (val =
|
439
|
+
if (val = option('config-file', ignore: false))
|
427
440
|
ret << "--config-file=#{shell_escape(base_path(val).to_s, quote: true)}"
|
428
441
|
end
|
429
|
-
ret << '--norc' if
|
442
|
+
ret << '--norc' if option('norc')
|
430
443
|
ret
|
431
444
|
end
|
432
445
|
|
433
446
|
def bundle_session(*cmd)
|
434
447
|
session('bundle', *cmd)
|
435
|
-
append_nocolor
|
448
|
+
append_nocolor option('no-color')
|
449
|
+
@session
|
436
450
|
end
|
437
451
|
|
438
452
|
def gempath
|
@@ -443,6 +457,8 @@ module Squared
|
|
443
457
|
@gemdir.exist? && !@gemdir.empty?
|
444
458
|
end
|
445
459
|
end
|
460
|
+
|
461
|
+
Application.implement Ruby
|
446
462
|
end
|
447
463
|
end
|
448
464
|
end
|
@@ -1,16 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rexml/document'
|
4
|
+
|
3
5
|
module Squared
|
4
6
|
module Workspace
|
5
7
|
module Repo
|
6
8
|
include Common
|
7
9
|
include Format
|
10
|
+
include Prompt
|
8
11
|
include System
|
9
12
|
include Utils
|
10
13
|
|
11
14
|
class << self
|
12
15
|
def read_manifest(path)
|
13
|
-
require 'rexml/document'
|
14
16
|
return unless (file = path.join('.repo/manifest.xml')).exist?
|
15
17
|
|
16
18
|
doc = REXML::Document.new(file.read)
|
@@ -22,6 +24,8 @@ module Squared
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
attr_reader :manifest_url, :manifest
|
28
|
+
|
25
29
|
def repo(url, manifest = 'latest', run: nil, script: nil, dev: nil, prod: nil, ref: @ref, group: @group)
|
26
30
|
@home = if (val = env('REPO_HOME'))
|
27
31
|
home = Pathname.new(val)
|
@@ -59,10 +63,10 @@ module Squared
|
|
59
63
|
when 'verbose'
|
60
64
|
@verbose = 1
|
61
65
|
if script.is_a?(::Array)
|
62
|
-
script[0] =
|
66
|
+
script[0] = task_join(script[0], 'verbose')
|
63
67
|
script
|
64
68
|
else
|
65
|
-
|
69
|
+
task_join(script, 'verbose')
|
66
70
|
end
|
67
71
|
when 'silent'
|
68
72
|
@verbose = false
|
@@ -114,7 +118,7 @@ module Squared
|
|
114
118
|
kwargs.delete(:parallel) if env('REPO_SYNC', ignore: '0')
|
115
119
|
|
116
120
|
branch = env('REPO_MANIFEST') || Repo.read_manifest(root)
|
117
|
-
target = branch ||
|
121
|
+
target = branch || manifest
|
118
122
|
stage = nil
|
119
123
|
failfast = true
|
120
124
|
cmd = []
|
@@ -140,7 +144,7 @@ module Squared
|
|
140
144
|
status = lambda do |val, alt = nil|
|
141
145
|
return 'inactive' unless (ver = branch || alt)
|
142
146
|
|
143
|
-
message(@prefix
|
147
|
+
message(@prefix, 'repo', val.sub('{0}', 'opts*=force,rebase,detach,gc,no-update,no-fail'), ver, empty: true)
|
144
148
|
end
|
145
149
|
|
146
150
|
namespace task_name('repo') do |repo|
|
@@ -150,12 +154,21 @@ module Squared
|
|
150
154
|
stage ||= 'all'
|
151
155
|
repo['sync'].invoke
|
152
156
|
@project.select do |_, proj|
|
153
|
-
next unless proj.enabled?(
|
157
|
+
next unless proj.enabled?(proj.workspace.baseref)
|
154
158
|
|
155
|
-
proj.depend if proj.depend?
|
159
|
+
proj.depend(sync: true) if proj.depend?
|
156
160
|
proj.build?
|
157
161
|
end
|
158
|
-
.each_value
|
162
|
+
.each_value do |proj|
|
163
|
+
proj.build(sync: true)
|
164
|
+
next unless proj.has?('dev') && proj.copy?
|
165
|
+
|
166
|
+
if (ws = proj.workspace).task_defined?(target = ws.task_name(proj.name, 'copy'))
|
167
|
+
Common::Task.invoke(target, **ws.invokeargs)
|
168
|
+
else
|
169
|
+
proj.copy(sync: true)
|
170
|
+
end
|
171
|
+
end
|
159
172
|
end
|
160
173
|
|
161
174
|
desc status.("init[manifest?=#{target},{0}]", target)
|
@@ -163,7 +176,7 @@ module Squared
|
|
163
176
|
parse_opts.(args)
|
164
177
|
stage = 'init'
|
165
178
|
puts if newline
|
166
|
-
system("repo init -u #{
|
179
|
+
system("repo init -u #{manifest_url} -m #{args.manifest || target}.xml", chdir: root)
|
167
180
|
repo['all'].invoke
|
168
181
|
end
|
169
182
|
|
@@ -179,7 +192,7 @@ module Squared
|
|
179
192
|
begin
|
180
193
|
shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
|
181
194
|
rescue StandardError => e
|
182
|
-
emphasize(e, title: "rake stash #{task_name(
|
195
|
+
emphasize(e, title: "rake stash #{task_name(task_join('repo', stage || 'sync'))}")
|
183
196
|
raise
|
184
197
|
end
|
185
198
|
end
|
@@ -190,7 +203,7 @@ module Squared
|
|
190
203
|
return false unless root.directory?
|
191
204
|
|
192
205
|
path = sub_style(root, styles: theme[:inline])
|
193
|
-
@
|
206
|
+
@repo_override = confirm(
|
194
207
|
"#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation? [y/N] ",
|
195
208
|
'N',
|
196
209
|
timeout: env('REPO_TIMEOUT', 15, ignore: '0')
|
@@ -198,7 +211,7 @@ module Squared
|
|
198
211
|
end
|
199
212
|
|
200
213
|
def repo?
|
201
|
-
|
214
|
+
!manifest_url.nil? && (repo_install? || @repo_override == true)
|
202
215
|
end
|
203
216
|
|
204
217
|
def repo_install?(dir = root, parent: false)
|
@@ -8,22 +8,51 @@ module Squared
|
|
8
8
|
include ::Rake::DSL
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
TASK_BASE = %i[build
|
12
|
-
|
13
|
-
refresh: :build
|
14
|
-
}
|
15
|
-
TASK_KEYS = TASK_BASE.dup
|
11
|
+
TASK_BASE = %i[build depend doc test copy clean]
|
12
|
+
TASK_BATCH = {}
|
16
13
|
TASK_EXTEND = {}
|
17
|
-
|
14
|
+
TASK_KEYS = TASK_BASE.dup
|
15
|
+
TASK_ALIAS = {}
|
16
|
+
TASK_NAME = {}
|
17
|
+
private_constant :TASK_BASE, :TASK_BATCH, :TASK_KEYS, :TASK_NAME, :TASK_EXTEND
|
18
18
|
|
19
19
|
class << self
|
20
20
|
def add(task, obj)
|
21
|
-
|
21
|
+
key_set task
|
22
22
|
(TASK_EXTEND[task] ||= []).push(obj)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
25
|
+
def batch(ref, obj)
|
26
|
+
if obj.is_a?(::Hash)
|
27
|
+
obj.each do |key, val|
|
28
|
+
key_set key
|
29
|
+
data = TASK_BATCH[key] ||= {}
|
30
|
+
(data[ref] ||= []).concat(val)
|
31
|
+
end
|
32
|
+
elsif (data = TASK_BATCH[obj]) && data.delete(ref) && data.empty?
|
33
|
+
TASK_KEYS.delete(obj)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def alias(ref, obj)
|
38
|
+
if obj.is_a?(::Hash)
|
39
|
+
obj.each { |key, val| (TASK_ALIAS[key] ||= {})[ref] = val }
|
40
|
+
elsif (data = TASK_ALIAS[obj])
|
41
|
+
data.delete(ref)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def rename(key, task)
|
46
|
+
TASK_NAME[key.to_sym] = task.to_sym
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def key_set(val)
|
52
|
+
return if TASK_KEYS.include?(val)
|
53
|
+
|
54
|
+
TASK_KEYS << val
|
55
|
+
TASK_BASE.delete(val)
|
27
56
|
end
|
28
57
|
end
|
29
58
|
|
@@ -45,57 +74,48 @@ module Squared
|
|
45
74
|
TASK_KEYS.each { |key| @data[key] = [] }
|
46
75
|
end
|
47
76
|
|
48
|
-
def
|
49
|
-
@data[key.to_sym] ||= []
|
50
|
-
end
|
51
|
-
|
52
|
-
def __populate__(proj)
|
53
|
-
return unless @session
|
54
|
-
|
77
|
+
def populate(proj)
|
55
78
|
group, parent, id = @session.values
|
56
|
-
ws = proj.workspace
|
57
|
-
ref = Project::Base.ref
|
58
79
|
@data.each do |key, items|
|
59
|
-
|
60
|
-
|
61
|
-
next if (base && !proj.ref?(ref)) || (alt = TASK_ALIAS[key]).nil?
|
62
|
-
|
63
|
-
task = "#{proj.name}:#{alt}"
|
64
|
-
end
|
65
|
-
next unless ws.task_defined?(task)
|
80
|
+
ws = proj.workspace
|
81
|
+
next if (tasks = ws.task_resolve(proj, key)).empty?
|
66
82
|
|
67
83
|
if (g = proj.group)
|
68
84
|
id << g
|
69
|
-
(group[:"#{key}:#{g}"] ||= []).push(
|
85
|
+
(group[:"#{key}:#{g}"] ||= []).push(*tasks)
|
70
86
|
else
|
71
|
-
items
|
87
|
+
items.concat(tasks)
|
88
|
+
end
|
89
|
+
if tasks.size > 1 && (data = batch_get(key)) && data.keys.any? { |ref| proj.ref?(ref) }
|
90
|
+
desc ws.task_name(t = ws.task_join(proj.name, key), desc: true)
|
91
|
+
task ws.task_name(t) => tasks
|
72
92
|
end
|
73
93
|
next unless (b = ws.find_base(proj)) && (name = b.ref.to_s) != g
|
74
94
|
|
75
95
|
id << name
|
76
|
-
(parent[:"#{key}:#{name}"] ||= []).push(
|
96
|
+
(parent[:"#{key}:#{name}"] ||= []).push(*tasks)
|
77
97
|
end
|
78
98
|
end
|
79
99
|
|
80
|
-
def
|
81
|
-
|
82
|
-
@data.merge!(
|
83
|
-
@data.merge!(group)
|
100
|
+
def build(parallel: [], **)
|
101
|
+
@data.merge!(@session[:parent]) if @session[:id].uniq.size > 1
|
102
|
+
@data.merge!(@session[:group])
|
84
103
|
@data.each do |key, items|
|
85
104
|
next if items.empty?
|
86
105
|
|
87
|
-
key = @workspace.task_name(
|
88
|
-
val = @workspace.task_name(
|
106
|
+
key = @workspace.task_name(t = name_get(key))
|
107
|
+
val = @workspace.task_name(t, desc: true)
|
89
108
|
if items.size > 1
|
90
109
|
@multiple << key
|
91
|
-
if parallel.include?(
|
110
|
+
if parallel.include?(t) || ((ns = @workspace.task_namespace(t)) && parallel.include?(ns))
|
92
111
|
desc "#{val} (thread)"
|
93
112
|
multitask key => items
|
94
113
|
@parallel << key
|
95
114
|
|
115
|
+
s = @workspace.task_join(key, 'sync')
|
96
116
|
desc "#{val} (sync)"
|
97
|
-
task
|
98
|
-
@sync <<
|
117
|
+
task s => items
|
118
|
+
@sync << s
|
99
119
|
next
|
100
120
|
end
|
101
121
|
end
|
@@ -103,19 +123,31 @@ module Squared
|
|
103
123
|
desc val
|
104
124
|
task key => items
|
105
125
|
end
|
106
|
-
TASK_ALIAS.each_key do |key|
|
107
|
-
suf = ":#{key}"
|
108
|
-
@data[key].clear unless @data[key].any? { |val| val.end_with?(suf) }
|
109
|
-
end
|
110
126
|
@multiple += sync
|
111
|
-
|
127
|
+
end
|
128
|
+
|
129
|
+
def name_get(key)
|
130
|
+
(TASK_NAME[key] || key).to_s
|
131
|
+
end
|
132
|
+
|
133
|
+
def batch_get(key)
|
134
|
+
TASK_BATCH[key]
|
135
|
+
end
|
136
|
+
|
137
|
+
def alias_get(key)
|
138
|
+
TASK_ALIAS[key]
|
112
139
|
end
|
113
140
|
|
114
141
|
def some?(key)
|
115
|
-
@data.key?(key) && !@data[key].empty?
|
142
|
+
return @data.key?(key) && !@data[key].empty? unless (batch = batch_get(key))
|
143
|
+
|
144
|
+
batch.each_value do |items|
|
145
|
+
return true if items.all? { |val| some?(val) || alias_get(val)&.any? { |_, alt| some?(alt) } }
|
146
|
+
end
|
147
|
+
false
|
116
148
|
end
|
117
149
|
|
118
|
-
def
|
150
|
+
def base?(key)
|
119
151
|
TASK_BASE.include?(key)
|
120
152
|
end
|
121
153
|
|
@@ -137,17 +169,13 @@ module Squared
|
|
137
169
|
|
138
170
|
private
|
139
171
|
|
140
|
-
def method_missing(key, *)
|
141
|
-
raise NoMethodError, key unless @data.key?(key)
|
142
|
-
|
143
|
-
@data[key]
|
144
|
-
end
|
145
|
-
|
146
172
|
def already_invoked?(list, val)
|
147
|
-
return
|
173
|
+
return false unless val && !list.include?(val)
|
148
174
|
|
149
|
-
::Rake::Task.tasks.any? { |obj| obj.already_invoked && list.include?(obj.name) }
|
175
|
+
::Rake::Task.tasks.any? { |obj| obj.already_invoked && (val ? val == obj.name : list.include?(obj.name)) }
|
150
176
|
end
|
151
177
|
end
|
178
|
+
|
179
|
+
Application.impl_series = Series
|
152
180
|
end
|
153
181
|
end
|
data/lib/squared/workspace.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'common'
|
4
|
-
|
5
3
|
module Squared
|
6
4
|
module Workspace
|
7
5
|
class << self
|
@@ -23,7 +21,7 @@ module Squared
|
|
23
21
|
ret = project(name)
|
24
22
|
return ret if ret&.path&.directory?
|
25
23
|
|
26
|
-
raise NoMethodError,
|
24
|
+
raise NoMethodError, "project is not initialized (#{name})"
|
27
25
|
end
|
28
26
|
|
29
27
|
def dirpath(val, absolute: true)
|
@@ -45,6 +43,9 @@ module Squared
|
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
|
-
require_relative 'workspace/series'
|
49
46
|
require_relative 'workspace/application'
|
47
|
+
require_relative 'workspace/series'
|
50
48
|
require_relative 'workspace/project'
|
49
|
+
|
50
|
+
Workspace = Squared::Workspace
|
51
|
+
Project = Squared::Workspace::Project
|
data/lib/squared.rb
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'squared/version'
|
4
|
-
require_relative 'squared/
|
5
|
-
|
6
|
-
Workspace = Squared::Workspace
|
7
|
-
Project = Squared::Workspace::Project
|
8
|
-
|
9
|
-
Workspace::Application.implement(
|
10
|
-
Project::Git,
|
11
|
-
Project::Node,
|
12
|
-
Project::Python,
|
13
|
-
Project::Ruby
|
14
|
-
)
|
4
|
+
require_relative 'squared/common'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -63,10 +63,12 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- README.ruby.md
|
65
65
|
- lib/squared.rb
|
66
|
+
- lib/squared/app.rb
|
66
67
|
- lib/squared/common.rb
|
67
68
|
- lib/squared/common/base.rb
|
68
69
|
- lib/squared/common/class.rb
|
69
70
|
- lib/squared/common/format.rb
|
71
|
+
- lib/squared/common/prompt.rb
|
70
72
|
- lib/squared/common/shell.rb
|
71
73
|
- lib/squared/common/system.rb
|
72
74
|
- lib/squared/common/task.rb
|