squared 0.0.7 → 0.0.8
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/README.ruby.md +20 -7
- data/lib/squared/common/base.rb +9 -9
- data/lib/squared/common/format.rb +1 -1
- data/lib/squared/common/task.rb +2 -2
- data/lib/squared/config.rb +18 -14
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +81 -69
- data/lib/squared/workspace/project/base.rb +36 -20
- data/lib/squared/workspace/project/git.rb +55 -55
- data/lib/squared/workspace/project/node.rb +36 -21
- data/lib/squared/workspace/project/python.rb +43 -21
- data/lib/squared/workspace/project/ruby.rb +35 -51
- data/lib/squared/workspace/repo.rb +27 -18
- data/lib/squared/workspace/series.rb +50 -41
- data/lib/squared/workspace.rb +8 -2
- data/squared.gemspec +1 -0
- metadata +16 -2
@@ -8,6 +8,7 @@ module Squared
|
|
8
8
|
module Project
|
9
9
|
class Base
|
10
10
|
include Common
|
11
|
+
include Format
|
11
12
|
include System
|
12
13
|
include Shell
|
13
14
|
include Task
|
@@ -44,7 +45,6 @@ module Squared
|
|
44
45
|
@@tasks = {}
|
45
46
|
|
46
47
|
attr_reader :name, :project, :workspace, :group, :path, :theme
|
47
|
-
attr_accessor :warning
|
48
48
|
|
49
49
|
def initialize(name, path, workspace, *, group: nil, **kwargs)
|
50
50
|
@name = name.to_s
|
@@ -58,8 +58,6 @@ module Squared
|
|
58
58
|
@output = [kwargs[:run], nil]
|
59
59
|
@copy = kwargs[:copy]
|
60
60
|
@clean = kwargs[:clean]
|
61
|
-
@exclude = as_a(kwargs[:exclude])
|
62
|
-
@warning = workspace.warning
|
63
61
|
@theme = if !workspace.verbose
|
64
62
|
{}
|
65
63
|
elsif kwargs.fetch(:common, true)
|
@@ -67,6 +65,9 @@ module Squared
|
|
67
65
|
else
|
68
66
|
__get__(:theme)[:project][to_sym] ||= {}
|
69
67
|
end
|
68
|
+
@ref = []
|
69
|
+
@exclude = as_a(kwargs[:exclude], :to_sym).freeze
|
70
|
+
initialize_ref(Base.ref)
|
70
71
|
initialize_logger(**kwargs)
|
71
72
|
end
|
72
73
|
|
@@ -91,7 +92,7 @@ module Squared
|
|
91
92
|
raise if @workspace.exception
|
92
93
|
|
93
94
|
file = nil
|
94
|
-
warn e if @warning
|
95
|
+
warn e if @workspace.warning
|
95
96
|
end
|
96
97
|
end
|
97
98
|
log[:progname] = @name
|
@@ -118,23 +119,30 @@ module Squared
|
|
118
119
|
end
|
119
120
|
|
120
121
|
def initialize_script(ref, **)
|
122
|
+
initialize_ref(ref)
|
121
123
|
return unless (script = workspace.script(group: group, ref: ref))
|
122
124
|
|
123
125
|
@depend = script[:depend] if @depend.nil?
|
124
126
|
@doc = script[:doc] if @doc.nil?
|
125
127
|
@test = script[:test] if @test.nil?
|
126
128
|
@clean = script[:clean] if @clean.nil?
|
129
|
+
@exclude = script[:exclude] if @exclude.empty? && script.key?(:exclude)
|
127
130
|
@script = script
|
128
131
|
end
|
129
132
|
|
133
|
+
def initialize_ref(ref)
|
134
|
+
@ref << ref unless @exclude.include?(ref)
|
135
|
+
end
|
136
|
+
|
130
137
|
def populate(*)
|
131
|
-
|
138
|
+
valid = ref?(Base.ref)
|
139
|
+
series = workspace.series
|
132
140
|
|
133
141
|
namespace name do
|
134
|
-
|
135
|
-
next unless
|
142
|
+
series.each_key do |key|
|
143
|
+
next unless series.include?(key) ? has?(key) && valid : workspace.task_extend?(self, key)
|
136
144
|
|
137
|
-
desc message(name, key)
|
145
|
+
desc message(*name.split(':'), key)
|
138
146
|
task key do
|
139
147
|
__send__(key)
|
140
148
|
end
|
@@ -170,7 +178,7 @@ module Squared
|
|
170
178
|
build(sync: invoked_sync?('depend'))
|
171
179
|
key = "#{name}:copy"
|
172
180
|
if workspace.task_defined?(key)
|
173
|
-
invoke
|
181
|
+
invoke(key, exception: workspace.exception, warning: workspace.warning)
|
174
182
|
else
|
175
183
|
copy
|
176
184
|
end
|
@@ -251,6 +259,10 @@ module Squared
|
|
251
259
|
respond_to?(m = :"#{method}?") && __send__(m)
|
252
260
|
end
|
253
261
|
|
262
|
+
def ref?(val)
|
263
|
+
@ref.include?(val)
|
264
|
+
end
|
265
|
+
|
254
266
|
def build?
|
255
267
|
!!@output[0]
|
256
268
|
end
|
@@ -283,17 +295,19 @@ module Squared
|
|
283
295
|
!!@dev
|
284
296
|
end
|
285
297
|
|
286
|
-
|
298
|
+
private
|
287
299
|
|
288
300
|
def run(cmd = @session, exception: workspace.exception, banner: true, sync: true, req: nil, **)
|
289
|
-
|
290
|
-
|
301
|
+
if req && !base_path(req).exist?
|
302
|
+
log.warn "#{req} (not found)"
|
303
|
+
return
|
304
|
+
end
|
291
305
|
cmd = close_session(cmd)
|
292
306
|
log.info cmd
|
293
307
|
begin
|
294
308
|
if cmd =~ /^\S+:(\S+:?)+$/ && workspace.task_defined?(cmd)
|
295
309
|
print_item if sync
|
296
|
-
invoke(cmd, exception: exception)
|
310
|
+
invoke(cmd, exception: exception, warning: workspace.warning)
|
297
311
|
else
|
298
312
|
print_item format_banner(cmd, banner: banner) if sync
|
299
313
|
shell(cmd, chdir: path, exception: exception)
|
@@ -309,7 +323,8 @@ module Squared
|
|
309
323
|
end
|
310
324
|
|
311
325
|
def env(key, default = nil, equals: nil, ignore: ['0'].freeze, suffix: nil, strict: false)
|
312
|
-
|
326
|
+
@env ||= name.gsub(/[^\w]+/, '_').upcase
|
327
|
+
a = "#{key}_#{@env}"
|
313
328
|
b = ''
|
314
329
|
if suffix
|
315
330
|
a = [a, suffix].flatten.join('_')
|
@@ -381,13 +396,14 @@ module Squared
|
|
381
396
|
ret.join("\n")
|
382
397
|
end
|
383
398
|
|
384
|
-
def format_desc(action, flag, opts = nil, req: 'opts*')
|
385
|
-
opts = "#{
|
386
|
-
|
399
|
+
def format_desc(action, flag, opts = nil, req: '', arg: 'opts*')
|
400
|
+
opts = "#{arg}=#{opts.join(',')}" if opts.is_a?(::Array)
|
401
|
+
unless flag
|
387
402
|
flag = action
|
388
403
|
action = ''
|
389
404
|
end
|
390
|
-
|
405
|
+
req = opts ? "#{req}," : "[#{req}]" unless req.to_s.empty?
|
406
|
+
message(*name.split(':'), action, opts ? "#{flag}[#{req}#{opts}]" : flag.to_s + req)
|
391
407
|
end
|
392
408
|
|
393
409
|
def format_banner(cmd, banner: true, multiple: false)
|
@@ -457,8 +473,8 @@ module Squared
|
|
457
473
|
workspace.pipe
|
458
474
|
end
|
459
475
|
|
460
|
-
def invoked_sync?(action)
|
461
|
-
return true if workspace.series.sync?("#{action}:sync")
|
476
|
+
def invoked_sync?(action, flag = nil)
|
477
|
+
return true if !flag.nil? || workspace.series.sync?("#{action}:sync")
|
462
478
|
|
463
479
|
check = lambda do |val|
|
464
480
|
if invoked?(val)
|
@@ -4,8 +4,6 @@ module Squared
|
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
6
|
class Git < Base
|
7
|
-
include Format
|
8
|
-
|
9
7
|
OPT_PULL = %w[all tags prune ff-only autostash dry-run].freeze
|
10
8
|
OPT_FETCH = %w[tags prune prune-tags depth=n dry-run].freeze
|
11
9
|
private_constant :OPT_PULL, :OPT_FETCH
|
@@ -13,23 +11,26 @@ module Squared
|
|
13
11
|
class << self
|
14
12
|
include ::Rake::DSL
|
15
13
|
|
16
|
-
def populate(workspace,
|
14
|
+
def populate(workspace, **)
|
17
15
|
return if workspace.series.pull.empty?
|
18
16
|
|
19
17
|
desc 'all[git?=rebase|stash]'
|
20
18
|
task 'all', [:git] do |_, args|
|
21
|
-
|
19
|
+
exception = workspace.exception
|
20
|
+
warning = workspace.warning
|
21
|
+
sync = ->(key) { workspace.task_defined?(s = "#{key}:sync") ? s : key }
|
22
22
|
pull = case args.git
|
23
23
|
when 'rebase'
|
24
|
-
sync.(
|
24
|
+
sync.('rebase')
|
25
25
|
when 'stash'
|
26
|
-
invoke
|
27
|
-
sync.(
|
26
|
+
invoke(sync.('stash'), exception: exception, warning: warning)
|
27
|
+
sync.('pull')
|
28
28
|
else
|
29
|
-
sync.(
|
29
|
+
sync.('pull')
|
30
30
|
end
|
31
|
-
Common::Task.invoke(pull, exception:
|
32
|
-
Common::Task.invoke(workspace.dev? ? :refresh : :build,
|
31
|
+
Common::Task.invoke(pull, exception: exception, warning: warning)
|
32
|
+
Common::Task.invoke(workspace.dev? && workspace.series.has?(:refresh) ? :refresh : :build,
|
33
|
+
exception: exception, warning: warning)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -60,9 +61,14 @@ module Squared
|
|
60
61
|
rev: %i[commit branch]
|
61
62
|
}.freeze
|
62
63
|
|
64
|
+
def initialize(*, **)
|
65
|
+
super
|
66
|
+
initialize_ref(Git.ref)
|
67
|
+
end
|
68
|
+
|
63
69
|
def populate(*)
|
64
70
|
super
|
65
|
-
return unless gitdir.exist? &&
|
71
|
+
return unless gitdir.exist? && ref?(Git.ref)
|
66
72
|
|
67
73
|
namespace name do
|
68
74
|
@@tasks[Git.ref].each do |action, flags|
|
@@ -121,7 +127,7 @@ module Squared
|
|
121
127
|
desc format_desc(action, flag, 'index?=0,pathspec*')
|
122
128
|
task flag, [:pathspec] do |_, args|
|
123
129
|
files = args.to_a
|
124
|
-
index = /^\d+$/.match?(files.first) && !
|
130
|
+
index = /^\d+$/.match?(files.first) && !git_option('index') ? files.shift.to_i : 0
|
125
131
|
diff(flag, files, index: index)
|
126
132
|
end
|
127
133
|
when :cached
|
@@ -202,12 +208,12 @@ module Squared
|
|
202
208
|
cmd = git_session 'pull'
|
203
209
|
if flag == :'no-rebase'
|
204
210
|
cmd << '--no-rebase'
|
205
|
-
elsif flag == :rebase ||
|
211
|
+
elsif flag == :rebase || git_option('rebase')
|
206
212
|
cmd << '--rebase'
|
207
213
|
end
|
208
214
|
if flag == :'no-commit'
|
209
215
|
cmd << '--no-commit'
|
210
|
-
elsif flag == :commit ||
|
216
|
+
elsif flag == :commit || git_option('commit')
|
211
217
|
cmd << '--commit'
|
212
218
|
end
|
213
219
|
append_pull opts, OPT_PULL, flag
|
@@ -220,28 +226,28 @@ module Squared
|
|
220
226
|
|
221
227
|
def fetch(flag = nil, opts: [])
|
222
228
|
cmd = git_session 'fetch'
|
223
|
-
cmd << '--all' if flag == :all ||
|
229
|
+
cmd << '--all' if flag == :all || git_option('all')
|
224
230
|
append_pull opts, OPT_FETCH, flag
|
225
231
|
source(sync: invoked_sync?('fetch', flag), stderr: true, exception: !workspace.series.multiple?)
|
226
232
|
end
|
227
233
|
|
228
|
-
def stash(flag =
|
229
|
-
cmd = git_session 'stash', flag.to_s
|
234
|
+
def stash(flag = nil, files = [], commit: nil)
|
235
|
+
cmd = git_session 'stash', (flag || 'push').to_s
|
230
236
|
case flag
|
231
237
|
when :apply, :pop
|
232
|
-
cmd << '--index' if
|
238
|
+
cmd << '--index' if git_option('index')
|
233
239
|
cmd << commit
|
234
240
|
else
|
235
241
|
append_option %w[all staged include-untracked]
|
236
|
-
append_message
|
242
|
+
append_message git_option('message', 'm', zero: false)
|
237
243
|
append_pathspec files
|
238
244
|
end
|
239
245
|
source(sync: invoked_sync?('stash', flag), exception: workspace.exception)
|
240
246
|
end
|
241
247
|
|
242
248
|
def status
|
243
|
-
cmd = git_session 'status',
|
244
|
-
if (val =
|
249
|
+
cmd = git_session 'status', git_option('long') ? '--long' : '--short'
|
250
|
+
if (val = git_option('ignore-submodules'))
|
245
251
|
cmd << "--ignore-submodules=#{case val
|
246
252
|
when '0', 'none'
|
247
253
|
'none'
|
@@ -282,7 +288,7 @@ module Squared
|
|
282
288
|
append_submodules flag
|
283
289
|
else
|
284
290
|
cmd << '--mixed'
|
285
|
-
cmd << '--no-refresh' if
|
291
|
+
cmd << '--no-refresh' if git_option('refresh', equals: '0')
|
286
292
|
end
|
287
293
|
append_commit ref
|
288
294
|
end
|
@@ -293,10 +299,10 @@ module Squared
|
|
293
299
|
cmd = git_session 'checkout'
|
294
300
|
case flag
|
295
301
|
when :branch
|
296
|
-
cmd << '--detach' if detach == 'd' ||
|
302
|
+
cmd << '--detach' if detach == 'd' || git_option('detach')
|
297
303
|
if create
|
298
304
|
cmd << "-#{create}" << branch
|
299
|
-
if (val =
|
305
|
+
if (val = git_option('start-point'))
|
300
306
|
cmd << val
|
301
307
|
end
|
302
308
|
else
|
@@ -351,22 +357,22 @@ module Squared
|
|
351
357
|
sha = nil
|
352
358
|
end
|
353
359
|
end
|
354
|
-
if (val =
|
360
|
+
if (val = git_option('unified')).to_i > 0
|
355
361
|
cmd << "--unified=#{val}"
|
356
362
|
end
|
357
363
|
append_nocolor
|
358
364
|
case flag
|
359
365
|
when :cached
|
360
366
|
cmd << '--cached'
|
361
|
-
cmd << '--merge-base' if
|
367
|
+
cmd << '--merge-base' if git_option('merge-base')
|
362
368
|
when :branch
|
363
369
|
cmd << branch
|
364
370
|
when :files
|
365
371
|
cmd << '--no-index'
|
366
372
|
else
|
367
|
-
if (val =
|
373
|
+
if (val = git_option('index')) || index > 0
|
368
374
|
cmd << "HEAD~#{val || index}"
|
369
|
-
elsif sha &&
|
375
|
+
elsif sha && git_option('merge-base')
|
370
376
|
cmd << '--merge-base'
|
371
377
|
end
|
372
378
|
end
|
@@ -376,7 +382,7 @@ module Squared
|
|
376
382
|
end
|
377
383
|
|
378
384
|
def commit(flag, files = [], message: nil, pass: false)
|
379
|
-
message ||=
|
385
|
+
message ||= git_option('message', 'm', zero: false)
|
380
386
|
amend = flag.to_s.start_with?('amend')
|
381
387
|
if !message && !amend
|
382
388
|
return if pass
|
@@ -391,7 +397,7 @@ module Squared
|
|
391
397
|
"-- #{files.join(' ')}"
|
392
398
|
end
|
393
399
|
if !push?
|
394
|
-
source('git branch -vv --list', io: true, banner: false)
|
400
|
+
source('git branch -vv --list', io: true, banner: false).first.each do |val|
|
395
401
|
origin = %r{^\* [^\[]+(?<= )\[([\w.-/]+?)/([\w.-]+)\] }.match(val)
|
396
402
|
next unless origin
|
397
403
|
|
@@ -403,7 +409,7 @@ module Squared
|
|
403
409
|
raise_error('commit', 'work tree is not usable') unless push?
|
404
410
|
|
405
411
|
cmd = git_session 'commit'
|
406
|
-
cmd << '--dry-run' if
|
412
|
+
cmd << '--dry-run' if git_option('dry-run')
|
407
413
|
if amend
|
408
414
|
cmd << '--amend'
|
409
415
|
else
|
@@ -411,7 +417,7 @@ module Squared
|
|
411
417
|
end
|
412
418
|
if message
|
413
419
|
append_message message
|
414
|
-
elsif flag == :'amend-orig' ||
|
420
|
+
elsif flag == :'amend-orig' || git_option('no-edit')
|
415
421
|
cmd << '--no-edit'
|
416
422
|
end
|
417
423
|
a = ['git add --verbose']
|
@@ -440,14 +446,14 @@ module Squared
|
|
440
446
|
source(stdout: true)
|
441
447
|
end
|
442
448
|
|
443
|
-
|
449
|
+
private
|
444
450
|
|
445
451
|
def source(cmd = @session, exception: true, banner: true, io: false, sync: true, stdout: false, stderr: false)
|
446
452
|
cmd = close_session(cmd)
|
447
453
|
log.info cmd
|
454
|
+
banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner, multiple: true)
|
455
|
+
cmd = cmd.sub(/^git\b/, "git --work-tree #{shell_quote(path)} --git-dir #{shell_quote(gitdir)}")
|
448
456
|
begin
|
449
|
-
banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner, multiple: true)
|
450
|
-
cmd = cmd.sub(/^git\b/, "git --work-tree #{shell_quote(path)} --git-dir #{shell_quote(gitdir)}")
|
451
457
|
if io
|
452
458
|
[IO.popen(cmd), banner]
|
453
459
|
elsif pipe? ? sync : stdout
|
@@ -480,7 +486,7 @@ module Squared
|
|
480
486
|
log.error e
|
481
487
|
raise if exception
|
482
488
|
|
483
|
-
warn e
|
489
|
+
warn e if workspace.warning
|
484
490
|
end
|
485
491
|
end
|
486
492
|
|
@@ -526,14 +532,6 @@ module Squared
|
|
526
532
|
files.map { |val| val == '.' ? '.' : shell_quote(base_path(val.strip)) }
|
527
533
|
end
|
528
534
|
|
529
|
-
def source_path?(val)
|
530
|
-
return val.to_s.start_with?(File.join(path, '').to_s) if Pathname.new(val).absolute?
|
531
|
-
|
532
|
-
!val.match?(%r{^\.\.[/\\]})
|
533
|
-
end
|
534
|
-
|
535
|
-
private
|
536
|
-
|
537
535
|
def append_pull(opts, list, flag = nil)
|
538
536
|
append_submodules flag
|
539
537
|
opts.each do |opt|
|
@@ -551,7 +549,7 @@ module Squared
|
|
551
549
|
end
|
552
550
|
|
553
551
|
def append_pathspec(files = [], expect: false, pass: false)
|
554
|
-
if files.empty? && (val =
|
552
|
+
if files.empty? && (val = git_option('pathspec'))
|
555
553
|
files = split_escape(val)
|
556
554
|
end
|
557
555
|
files = source_path(files, pass: pass)
|
@@ -567,30 +565,30 @@ module Squared
|
|
567
565
|
end
|
568
566
|
|
569
567
|
def append_head
|
570
|
-
@session << (
|
568
|
+
@session << (git_option('head') || git_option('tree-ish'))
|
571
569
|
end
|
572
570
|
|
573
571
|
def append_ours
|
574
|
-
if
|
572
|
+
if git_option('ours')
|
575
573
|
@session << '--ours'
|
576
|
-
elsif
|
574
|
+
elsif git_option('theirs')
|
577
575
|
@session << '--theirs'
|
578
576
|
end
|
579
577
|
end
|
580
578
|
|
581
579
|
def append_submodules(flag = nil)
|
582
|
-
if
|
580
|
+
if git_option('recurse-submodules', equals: '0')
|
583
581
|
@session << '--no-recurse-submodules'
|
584
|
-
elsif flag == :submodules ||
|
582
|
+
elsif flag == :submodules || git_option('recurse-submodules')
|
585
583
|
@session << '--recurse-submodules'
|
586
584
|
end
|
587
585
|
end
|
588
586
|
|
589
587
|
def append_option(list)
|
590
|
-
list.each { |val| @session << "--#{val}" if
|
588
|
+
list.each { |val| @session << "--#{val}" if git_option(val) }
|
591
589
|
end
|
592
590
|
|
593
|
-
def
|
591
|
+
def git_option(*args, equals: nil, zero: true)
|
594
592
|
for val in args
|
595
593
|
break if (ret = ENV["GIT_#{val.gsub(/\W/, '_').upcase}"])
|
596
594
|
end
|
@@ -606,11 +604,13 @@ module Squared
|
|
606
604
|
end
|
607
605
|
|
608
606
|
def gitdir
|
609
|
-
|
607
|
+
base_path('.git')
|
610
608
|
end
|
611
609
|
|
612
|
-
def
|
613
|
-
|
610
|
+
def source_path?(val)
|
611
|
+
return val.to_s.start_with?(File.join(path, '').to_s) if Pathname.new(val).absolute?
|
612
|
+
|
613
|
+
!val.match?(%r{^\.\.[/\\]})
|
614
614
|
end
|
615
615
|
|
616
616
|
def push?
|
@@ -32,24 +32,33 @@ module Squared
|
|
32
32
|
|
33
33
|
attr_reader :package
|
34
34
|
|
35
|
-
def initialize(*, **kwargs)
|
35
|
+
def initialize(*, script: nil, **kwargs)
|
36
36
|
super
|
37
37
|
initialize_script(Node.ref, **kwargs)
|
38
|
-
if (opts = env('BUILD', strict: true))
|
39
|
-
raise_error("BUILD_#{@name.upcase}", opts) if @output[0].is_a?(::Array)
|
40
|
-
@output[1] = opts
|
41
|
-
else
|
42
|
-
@output[1] = (@script && @script[:run]) || @workspace.script
|
43
|
-
end
|
44
38
|
@dev = kwargs[:dev]
|
45
39
|
@prod = kwargs[:prod]
|
46
40
|
@pm = {}
|
47
41
|
@package = base_path('package.json')
|
42
|
+
return if @output[0] == false
|
43
|
+
|
44
|
+
if @output[0].nil?
|
45
|
+
val, ext = @workspace.script(Node.ref, @group)
|
46
|
+
apply_script val
|
47
|
+
unless ext
|
48
|
+
if script
|
49
|
+
apply_script script
|
50
|
+
elsif (val = @script && @script[:run])
|
51
|
+
@output[0] = val
|
52
|
+
@output[1] = nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
@output[@output[0] || val.include?(' ') ? 0 : 1] = val if (val = env('BUILD', strict: true))
|
48
57
|
end
|
49
58
|
|
50
59
|
def populate(*)
|
51
60
|
super
|
52
|
-
return unless outdated? &&
|
61
|
+
return unless outdated? && ref?(Node.ref)
|
53
62
|
|
54
63
|
namespace name do
|
55
64
|
@@tasks[Node.ref].each do |action, flags|
|
@@ -70,10 +79,10 @@ module Squared
|
|
70
79
|
when :install
|
71
80
|
desc format_desc(action, flag)
|
72
81
|
task flag do
|
73
|
-
depend(flag
|
82
|
+
depend(flag)
|
74
83
|
end
|
75
84
|
when :outdated
|
76
|
-
desc format_desc(action, flag, %w[prune interactive dry-run],
|
85
|
+
desc format_desc(action, flag, %w[prune interactive dry-run], arg: 'opts?')
|
77
86
|
task flag, [:opts] do |_, args|
|
78
87
|
outdated(flag, opts: args.to_a)
|
79
88
|
end
|
@@ -95,7 +104,7 @@ module Squared
|
|
95
104
|
into = @copy[:into] if @copy.key?(:into)
|
96
105
|
also = @copy[:also] if @copy.key?(:also)
|
97
106
|
end
|
98
|
-
items = [
|
107
|
+
items = [name == workspace.main ? nil : workspace.home].concat(as_a(also))
|
99
108
|
items.each_with_index do |dir, i|
|
100
109
|
if i == 0
|
101
110
|
next unless dev? & !doc?
|
@@ -133,8 +142,8 @@ module Squared
|
|
133
142
|
end
|
134
143
|
end
|
135
144
|
|
136
|
-
def depend(flag = nil
|
137
|
-
if @depend && !
|
145
|
+
def depend(flag = nil)
|
146
|
+
if @depend && !flag
|
138
147
|
super
|
139
148
|
elsif outdated?
|
140
149
|
frozen = flag == :frozen
|
@@ -191,7 +200,7 @@ module Squared
|
|
191
200
|
append_nocolor
|
192
201
|
end
|
193
202
|
append_loglevel
|
194
|
-
run(sync: invoked_sync?('depend'))
|
203
|
+
run(sync: invoked_sync?('depend', flag))
|
195
204
|
end
|
196
205
|
end
|
197
206
|
|
@@ -200,7 +209,7 @@ module Squared
|
|
200
209
|
equ = rev || (prod? ? :patch : :minor)
|
201
210
|
cmd = pnpm? ? 'pnpm outdated' : 'npm outdated'
|
202
211
|
log.info cmd
|
203
|
-
if store_pwd || invoked_sync?("outdated#{rev
|
212
|
+
if store_pwd || invoked_sync?("outdated#{rev && ":#{rev}"}")
|
204
213
|
print_item format_banner("#{cmd}#{opts.include?('dry-run') ? ' --dry-run' : ''}", multiple: true)
|
205
214
|
end
|
206
215
|
data = `#{cmd} --json --loglevel=error`
|
@@ -300,10 +309,10 @@ module Squared
|
|
300
309
|
elsif modified == cur
|
301
310
|
'FAIL'
|
302
311
|
elsif d == 1
|
303
|
-
a = sub_style(a, styles: theme[:
|
312
|
+
a = sub_style(a, styles: theme[:major])
|
304
313
|
sub_style(c, :green, :bold)
|
305
314
|
else
|
306
|
-
sub_style(c, :green,
|
315
|
+
sub_style(c, :green, pat: SEM_VER, index: d)
|
307
316
|
end
|
308
317
|
puts "#{pad_ord.(i, found)}. #{a}#{b.ljust(col2)}#{c}"
|
309
318
|
end
|
@@ -433,7 +442,7 @@ module Squared
|
|
433
442
|
Node.prod? || workspace.prod?(script: @output[1], pat: @prod, **runargs)
|
434
443
|
end
|
435
444
|
|
436
|
-
|
445
|
+
private
|
437
446
|
|
438
447
|
def append_loglevel(cmd = @session)
|
439
448
|
return unless (level = env('NODE_LOGLEVEL'))
|
@@ -466,16 +475,22 @@ module Squared
|
|
466
475
|
end
|
467
476
|
end
|
468
477
|
|
469
|
-
private
|
470
|
-
|
471
478
|
def confirm_outdated(rev, pkg, ver)
|
472
479
|
m = ver == :major
|
473
480
|
confirm("Upgrade to #{rev}? #{sub_style("#{pkg} #{ver}", styles: theme[:inline])} [#{m ? 'y/N' : 'Y/n'}] ",
|
474
481
|
default: m ? 'N' : 'Y', timeout: 60)
|
475
482
|
end
|
476
483
|
|
484
|
+
def apply_script(val)
|
485
|
+
@output[1] = if val.is_a?(::Array)
|
486
|
+
val[Node.prod? ? 1 : 0]
|
487
|
+
else
|
488
|
+
val
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
477
492
|
def runargs
|
478
|
-
{ ref: Node.ref, group: group, global:
|
493
|
+
{ ref: Node.ref, group: group, global: @output[0].nil? && !(@script && @script[:run]) }
|
479
494
|
end
|
480
495
|
end
|
481
496
|
end
|