squared 0.7.4 → 0.7.5
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 +46 -0
- data/README.md +11 -4
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/prompt.rb +1 -1
- data/lib/squared/common/shell.rb +10 -10
- data/lib/squared/common/system.rb +2 -1
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +5 -4
- data/lib/squared/workspace/project/base.rb +13 -8
- data/lib/squared/workspace/project/docker.rb +21 -21
- data/lib/squared/workspace/project/git.rb +146 -112
- data/lib/squared/workspace/project/node.rb +15 -12
- data/lib/squared/workspace/project/python.rb +49 -21
- data/lib/squared/workspace/project/ruby.rb +57 -37
- data/lib/squared/workspace/project/support/optionpartition.rb +72 -34
- data/lib/squared/workspace/project/support/utils.rb +4 -6
- data/lib/squared/workspace/repo.rb +5 -4
- metadata +2 -2
|
@@ -65,14 +65,14 @@ module Squared
|
|
|
65
65
|
ret
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def clear(target, opts, pass: true, styles: nil, **kwargs)
|
|
68
|
+
def clear(target, opts, pass: true, strict: false, styles: nil, **kwargs)
|
|
69
69
|
return if opts.empty?
|
|
70
70
|
|
|
71
71
|
kwargs[:subject] ||= target.first.stripext
|
|
72
72
|
kwargs[:hint] ||= 'unrecognized'
|
|
73
73
|
append(target, opts, delim: true) if kwargs.delete(:append)
|
|
74
74
|
warn log_warn(opts.join(', '), pass: true, **kwargs)
|
|
75
|
-
exit 1 unless pass || confirm("Run? [#{sub_style(target, styles)}]", 'N')
|
|
75
|
+
exit 1 unless !strict && (pass || confirm("Run? [#{sub_style(target, styles)}]", 'N'))
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def delete_key(target, *args, value: false, reverse: false, count: -1)
|
|
@@ -195,10 +195,12 @@ module Squared
|
|
|
195
195
|
def_delegator :@extras, :find_all, :detect_all
|
|
196
196
|
def_delegator :@extras, :find_index, :detect_index
|
|
197
197
|
|
|
198
|
-
def initialize(opts, list, target = JoinSet.new, project: nil, path: nil, sep: '=', **kwargs,
|
|
198
|
+
def initialize(opts, list, target = JoinSet.new, project: nil, path: nil, strict: false, sep: '=', **kwargs,
|
|
199
|
+
&blk)
|
|
199
200
|
@target = target.is_a?(Set) ? target : target.to_set
|
|
200
201
|
@project = project
|
|
201
202
|
@path = path || project&.path
|
|
203
|
+
@strict = strict
|
|
202
204
|
@sep = sep
|
|
203
205
|
@errors = []
|
|
204
206
|
@found = []
|
|
@@ -242,42 +244,51 @@ module Squared
|
|
|
242
244
|
end
|
|
243
245
|
if (n = val.index('='))
|
|
244
246
|
flag = val[0, n]
|
|
247
|
+
enum = flag.split(':')
|
|
248
|
+
mod = if enum.size > 1
|
|
249
|
+
pre = enum.shift
|
|
250
|
+
enum.map { |s| "#{pre}:#{s}" }
|
|
251
|
+
else
|
|
252
|
+
[flag]
|
|
253
|
+
end
|
|
245
254
|
case val[n.succ]
|
|
246
255
|
when 'e'
|
|
247
|
-
e
|
|
256
|
+
e.concat(mod)
|
|
248
257
|
when 'b'
|
|
249
|
-
b
|
|
258
|
+
b.concat(mod)
|
|
250
259
|
when 'm'
|
|
251
|
-
m
|
|
260
|
+
m.concat(mod)
|
|
252
261
|
when 'q'
|
|
253
|
-
qq
|
|
254
|
-
q
|
|
262
|
+
qq.concat(mod) if val[n + 2] == 'q'
|
|
263
|
+
q.concat(mod)
|
|
255
264
|
when 'p'
|
|
256
|
-
p
|
|
265
|
+
p.concat(mod)
|
|
257
266
|
when 'i'
|
|
258
|
-
i
|
|
267
|
+
i.concat(mod)
|
|
259
268
|
when 'f'
|
|
260
|
-
f
|
|
269
|
+
f.concat(mod)
|
|
261
270
|
when 'n'
|
|
262
|
-
si
|
|
271
|
+
si.concat(mod)
|
|
263
272
|
when 'v'
|
|
264
|
-
@values
|
|
273
|
+
@values.concat(mod.map { |s| Regexp.escape(s) })
|
|
265
274
|
when '!'
|
|
266
|
-
bl
|
|
275
|
+
bl.concat(mod)
|
|
267
276
|
when '+'
|
|
268
|
-
ml
|
|
269
|
-
bare
|
|
277
|
+
ml.concat(mod)
|
|
278
|
+
bare.concat(mod)
|
|
270
279
|
else
|
|
271
280
|
next
|
|
272
281
|
end
|
|
273
|
-
m
|
|
274
|
-
bare
|
|
275
|
-
val = flag
|
|
282
|
+
m.concat(mod) if val[n + 2] == 'm'
|
|
283
|
+
bare.concat(mod) if val.end_with?('?')
|
|
276
284
|
else
|
|
277
285
|
bare << val
|
|
286
|
+
mod = [val]
|
|
287
|
+
end
|
|
288
|
+
mod.each do |key|
|
|
289
|
+
sw[key] = op1 if op1
|
|
290
|
+
se[key] = op2 if op2
|
|
278
291
|
end
|
|
279
|
-
sw[val] = op1 if op1
|
|
280
|
-
se[val] = op2 if op2
|
|
281
292
|
end
|
|
282
293
|
no = (no || []).map { |val| (n = val.index('=')) ? val[0, n] : val }
|
|
283
294
|
bare.concat(no)
|
|
@@ -337,14 +348,18 @@ module Squared
|
|
|
337
348
|
if opt =~ OPT_VALUE
|
|
338
349
|
key = $1
|
|
339
350
|
val = $2
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
351
|
+
has = lambda do |a|
|
|
352
|
+
return true if a.include?(key)
|
|
353
|
+
return false unless (k = a.find { |s| s.end_with?(':*') })
|
|
354
|
+
|
|
355
|
+
key.start_with?(k.chomp('*')) && !key.end_with?(':')
|
|
356
|
+
end
|
|
357
|
+
kwargs = { sep: se[key] || sep, merge: has.call(m), switch: sw[key] }
|
|
358
|
+
if has.call(e) || (has.call(bl) && %w[true false].include?(val))
|
|
344
359
|
add shell_option(key, val, **kwargs)
|
|
345
|
-
elsif
|
|
346
|
-
add quote_option(key, val, double:
|
|
347
|
-
elsif
|
|
360
|
+
elsif has.call(q)
|
|
361
|
+
add quote_option(key, val, double: has.call(qq), **kwargs)
|
|
362
|
+
elsif has.call(p)
|
|
348
363
|
if val.match?(/\A(["']).+\1\z/)
|
|
349
364
|
add shell_option(key, val, escape: false, **kwargs)
|
|
350
365
|
elsif path
|
|
@@ -352,7 +367,7 @@ module Squared
|
|
|
352
367
|
else
|
|
353
368
|
push opt
|
|
354
369
|
end
|
|
355
|
-
elsif
|
|
370
|
+
elsif kwargs[:merge] || has.call(b) || numcheck.call(key, val) || se[key] || sw[key]
|
|
356
371
|
add basic_option(key, val, **kwargs)
|
|
357
372
|
else
|
|
358
373
|
push opt
|
|
@@ -380,8 +395,8 @@ module Squared
|
|
|
380
395
|
self
|
|
381
396
|
end
|
|
382
397
|
|
|
383
|
-
def append(*args, **kwargs, &blk)
|
|
384
|
-
args = extras if args.empty?
|
|
398
|
+
def append(*args, clear: false, **kwargs, &blk)
|
|
399
|
+
args = clear ? extras.dup.tap { extras.clear } : extras if args.empty?
|
|
385
400
|
pass = kwargs[:pass] ||= []
|
|
386
401
|
OptionPartition.append(target, *args, **kwargs, &blk)
|
|
387
402
|
errors.concat(pass)
|
|
@@ -459,15 +474,15 @@ module Squared
|
|
|
459
474
|
list.reject { |val| ignore.include?(s = nameonly(val)) || any?(OptionPartition.send(:matchopt, s)) }
|
|
460
475
|
end
|
|
461
476
|
|
|
462
|
-
def clear(opts = nil, errors: false, **kwargs)
|
|
477
|
+
def clear(opts = nil, errors: false, strict: @strict, **kwargs)
|
|
463
478
|
styles = project.theme[:inline] if project
|
|
464
479
|
if errors
|
|
465
|
-
OptionPartition.clear(target, @errors, styles: styles, **kwargs)
|
|
480
|
+
OptionPartition.clear(target, @errors, strict: strict, styles: styles, **kwargs)
|
|
466
481
|
@errors.clear
|
|
467
482
|
return self unless opts
|
|
468
483
|
end
|
|
469
484
|
opts ||= extras
|
|
470
|
-
OptionPartition.clear(target, opts - found, styles: styles, **kwargs)
|
|
485
|
+
OptionPartition.clear(target, opts - found, strict: strict, styles: styles, **kwargs)
|
|
471
486
|
opts.clear
|
|
472
487
|
self
|
|
473
488
|
end
|
|
@@ -641,6 +656,29 @@ module Squared
|
|
|
641
656
|
self
|
|
642
657
|
end
|
|
643
658
|
|
|
659
|
+
def readline(msg, fallback = nil, option: nil, quote: false, force: true, double: false)
|
|
660
|
+
begin
|
|
661
|
+
require 'readline' unless defined?(Readline)
|
|
662
|
+
ret = Readline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
|
|
663
|
+
rescue LoadError
|
|
664
|
+
raise unless (ret = fallback) || !force
|
|
665
|
+
rescue Interrupt
|
|
666
|
+
exit(force ? 1 : 0)
|
|
667
|
+
else
|
|
668
|
+
exit 1 if ret.empty? && !(ret = fallback) && force
|
|
669
|
+
end
|
|
670
|
+
return unless ret
|
|
671
|
+
|
|
672
|
+
if option
|
|
673
|
+
add quote_option(option, ret, double: double)
|
|
674
|
+
elsif quote
|
|
675
|
+
add shell_quote(ret, option: false, double: double)
|
|
676
|
+
else
|
|
677
|
+
add ret
|
|
678
|
+
end
|
|
679
|
+
ret
|
|
680
|
+
end
|
|
681
|
+
|
|
644
682
|
def reset(errors: false)
|
|
645
683
|
extras.clear
|
|
646
684
|
found.clear
|
|
@@ -8,12 +8,10 @@ module Squared
|
|
|
8
8
|
private
|
|
9
9
|
|
|
10
10
|
def rand_s(size)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(0...size).map { rand(97..122).chr }.join
|
|
16
|
-
end
|
|
11
|
+
require 'random/formatter'
|
|
12
|
+
Random.new.alphanumeric(size)
|
|
13
|
+
rescue LoadError
|
|
14
|
+
(0...size).map { rand(97..122).chr }.join
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
def merge_list(target, list)
|
|
@@ -47,8 +47,8 @@ module Squared
|
|
|
47
47
|
envargs = name ? { suffix: name.upcase, strict: true } : {}
|
|
48
48
|
data = scriptobj
|
|
49
49
|
if repo?
|
|
50
|
-
env('REPO_GROUP', **envargs) { |
|
|
51
|
-
env('REPO_REF', **envargs) { |
|
|
50
|
+
env('REPO_GROUP', **envargs) { |s| group = split_escape(s) }
|
|
51
|
+
env('REPO_REF', **envargs) { |s| ref = split_escape(s) }
|
|
52
52
|
data[:dev] = env_match('REPO_DEV', dev, **envargs)
|
|
53
53
|
data[:prod] = env_match('REPO_PROD', prod, **envargs)
|
|
54
54
|
@warning = env_match('REPO_WARN', @warning && !root?(@root, pass: ['.repo'])) != false unless name
|
|
@@ -76,7 +76,7 @@ module Squared
|
|
|
76
76
|
sc
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
|
-
data[:args] = env('REPO_SCRIPT', **envargs) { |
|
|
79
|
+
data[:args] = env('REPO_SCRIPT', **envargs) { |s| shell_split(s, join: true) } || args
|
|
80
80
|
global[:script] = true
|
|
81
81
|
else
|
|
82
82
|
ru ||= sc
|
|
@@ -207,7 +207,8 @@ module Squared
|
|
|
207
207
|
opts = if stage == 'init'
|
|
208
208
|
[]
|
|
209
209
|
else
|
|
210
|
-
|
|
210
|
+
raise 'repo not initialized' unless branch
|
|
211
|
+
|
|
211
212
|
repo_opts
|
|
212
213
|
end
|
|
213
214
|
args.to_a.each do |val|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: squared
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- An Pham
|
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
125
|
- !ruby/object:Gem::Version
|
|
126
126
|
version: '0'
|
|
127
127
|
requirements: []
|
|
128
|
-
rubygems_version: 4.0.
|
|
128
|
+
rubygems_version: 4.0.6
|
|
129
129
|
specification_version: 4
|
|
130
130
|
summary: Rake task generator for managing multi-language workspaces.
|
|
131
131
|
test_files: []
|