squared 0.0.10 → 0.0.11

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.
@@ -23,6 +23,8 @@ module Squared
23
23
 
24
24
  class << self
25
25
  def populate(*); end
26
+ def batchargs(*); end
27
+ def aliasargs(*); end
26
28
 
27
29
  def tasks
28
30
  [].freeze
@@ -44,30 +46,31 @@ module Squared
44
46
  def to_s
45
47
  super.to_s.match(/[^:]+$/)[0]
46
48
  end
49
+
50
+ def config?(*)
51
+ false
52
+ end
47
53
  end
48
54
 
49
55
  @@print_order = 0
50
56
  @@tasks = {}
51
57
 
52
- attr_reader :name, :project, :workspace, :group, :path, :theme, :parent
53
- attr_accessor :exception, :pipe, :verbose
58
+ attr_reader :name, :project, :workspace, :path, :exception, :pipe, :verbose, :theme, :group, :parent
54
59
 
55
- def initialize(name, path, workspace, *,
56
- group: nil, verbose: nil, pass: nil, exclude: nil,
57
- common: Common::KEY[:COMMON], pipe: Common::KEY[:PIPE], **kwargs)
58
- @name = name.to_s
60
+ def initialize(workspace, path, name, *, group: nil, pass: nil, exclude: nil, common: ARG[:COMMON], **kwargs)
59
61
  @path = path
60
- @project = @path.basename.to_s
61
62
  @workspace = workspace
62
- @group = group&.to_s
63
+ @name = name.to_s.freeze
64
+ @project = @path.basename.to_s.freeze
65
+ @group = group&.to_s.freeze
63
66
  @depend = kwargs[:depend]
64
67
  @doc = kwargs[:doc]
65
68
  @test = kwargs[:test]
66
69
  @copy = kwargs[:copy]
67
70
  @clean = kwargs[:clean]
68
- @exception = workspace.exception
69
- @pipe = env_pipe(pipe, workspace.pipe)
70
- @verbose = verbose.nil? ? workspace.verbose : verbose
71
+ @exception = kwargs.key?(:exception) ? env_bool(kwargs[:exception]) : workspace.exception
72
+ @pipe = kwargs.key?(:pipe) ? env_pipe(kwargs[:pipe]) : workspace.pipe
73
+ @verbose = kwargs.key?(:verbose) ? kwargs[:verbose] : workspace.verbose
71
74
  @theme = if !@verbose
72
75
  {}
73
76
  elsif common
@@ -80,10 +83,11 @@ module Squared
80
83
  @children = []
81
84
  @pass = (pass ? as_a(pass, :to_sym) : []).freeze
82
85
  @exclude = (exclude ? as_a(exclude, :to_sym) : []).freeze
83
- @envname = @name.gsub(/[^\w]+/, '_').upcase
84
- @desc = @name.split(':').join(' => ')
86
+ @envname = @name.gsub(/[^\w]+/, '_').upcase.freeze
87
+ @desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
88
+ @parent = nil
85
89
  @global = false
86
- run_set kwargs[:run], kwargs[:env]
90
+ run_set(kwargs[:run], kwargs[:env], opts: kwargs.fetch(:opts, true))
87
91
  initialize_ref(Base.ref)
88
92
  end
89
93
 
@@ -93,7 +97,7 @@ module Squared
93
97
 
94
98
  def initialize_build(ref, **kwargs)
95
99
  initialize_ref(ref)
96
- if (@script = @workspace.script(group: @group, ref: ref))
100
+ if (@script = @workspace.script_get(group: @group, ref: ref))
97
101
  if @script[:log] && !kwargs.key?(:log)
98
102
  kwargs[:log] = @script[:log]
99
103
  @log = nil
@@ -107,7 +111,7 @@ module Squared
107
111
  initialize_logger(**kwargs)
108
112
  return if @output[0] == false
109
113
 
110
- data = @workspace.script(*@ref, @group)
114
+ data = @workspace.script_find(*@ref, @group)
111
115
  if @output[0].nil?
112
116
  if (scr = data[:script])
113
117
  @global = true
@@ -140,8 +144,8 @@ module Squared
140
144
  return if @log
141
145
 
142
146
  log = log.is_a?(::Hash) ? log.dup : { file: log }
143
- if (file = env('LOG_FILE')).nil? && (auto = env('LOG_AUTO'))
144
- file = case auto
147
+ unless (file = env('LOG_FILE'))
148
+ file = case env('LOG_AUTO')
145
149
  when 'y', 'year'
146
150
  "#{@name}-#{Date.today.year}.log"
147
151
  when 'm', 'month'
@@ -152,7 +156,7 @@ module Squared
152
156
  end
153
157
  if file ||= log[:file]
154
158
  file = Date.today.strftime(file)
155
- file = (dir = env('LOG_DIR')) ? Pathname.new(dir).join(file) : Pathname.new(file)
159
+ file = (dir = env('LOG_DIR')) ? @workspace.home.join(dir, file) : @workspace.home.join(file)
156
160
  begin
157
161
  file = file.realdirpath
158
162
  rescue StandardError => e
@@ -163,7 +167,7 @@ module Squared
163
167
  end
164
168
  end
165
169
  log[:progname] ||= @name
166
- if (val = env('LOG_LEVEL', ignore: nil))
170
+ if (val = env('LOG_LEVEL', ignore: false))
167
171
  log[:level] = val
168
172
  end
169
173
  log.delete(:file)
@@ -171,10 +175,14 @@ module Squared
171
175
  end
172
176
 
173
177
  def initialize_env(dev: nil, prod: nil, **)
174
- prefix = "BUILD_#{@envname}"
175
- @dev = env_match("#{prefix}_DEV", dev)
176
- @prod = env_match("#{prefix}_PROD", prod)
177
- if (val = env('BUILD', suffix: 'ENV'))
178
+ pre = "BUILD_#{@envname}"
179
+ @dev = env_match("#{pre}_DEV", dev)
180
+ @prod = env_match("#{pre}_PROD", prod)
181
+ cmd = @output[0]
182
+ unless cmd == false || cmd.is_a?(::Array) || (val = env('BUILD', suffix: 'OPTS')).nil?
183
+ @output[cmd ? 1 : 3] = shell_split(val, join: true)
184
+ end
185
+ unless @output[2] == false || (val = env('BUILD', suffix: 'ENV')).nil?
178
186
  begin
179
187
  data = JSON.parse(val)
180
188
  raise_error('invalid JSON object', val, hint: "#{prefix}_ENV") unless data.is_a?(::Hash)
@@ -186,10 +194,12 @@ module Squared
186
194
  return unless (val = env('BUILD', strict: true))
187
195
 
188
196
  @global = false
189
- if script?
197
+ if val == '0'
198
+ @output = [false]
199
+ elsif script?
190
200
  script_set val
191
201
  else
192
- run_set(val, opts: false)
202
+ run_set val
193
203
  end
194
204
  end
195
205
 
@@ -198,36 +208,57 @@ module Squared
198
208
  end
199
209
 
200
210
  def populate(*)
201
- check = lambda do |proj, key|
202
- workspace.series.include?(key) ? proj.has?(key, Base.ref) : workspace.task_extend?(proj, key)
203
- end
204
-
205
211
  namespace name do
206
212
  workspace.series.each_key do |key|
207
- next unless check.(self, key)
213
+ next unless workspace.task_include?(self, key)
208
214
 
209
- unless workspace.task_defined?("#{name}:#{key}")
210
- desc message(@desc, key)
211
- task key do
215
+ alt = workspace.series.name_get(key)
216
+ unless workspace.task_defined?(name, alt)
217
+ desc message(@desc, alt)
218
+ task alt do
212
219
  __send__(key)
213
220
  end
214
221
  end
215
- next if (items = @children.select { |item| check.(item, key) }).empty?
222
+ next if (items = @children.select { |item| workspace.task_include?(item, key) }).empty?
216
223
 
217
- desc message(@desc, key, 'workspace')
218
- task "#{key}:workspace" => items.map { |item| "#{item.name}:#{key}" }
224
+ desc message(@desc, alt, 'workspace')
225
+ task task_join(alt, 'workspace') => items.map { |item| task_join(item.name, alt) }
219
226
  end
220
227
  end
221
228
  end
222
229
 
223
- def add(path, name = nil, **kwargs, &blk)
224
- return self unless source_path?(path = base_path(path))
230
+ def with(**kwargs, &blk)
231
+ @withargs = kwargs.empty? ? nil : kwargs
232
+ if block_given?
233
+ instance_eval(&blk)
234
+ @withargs = nil
235
+ end
236
+ self
237
+ end
225
238
 
239
+ def add(path, name = nil, **kwargs, &blk)
240
+ if path.is_a?(::String) && (data = %r{^(.+)[\\/]\*+$}.match(path))
241
+ path = base_path(data[1]).children.select(&:directory?)
242
+ end
243
+ if path.is_a?(::Array)
244
+ name = @name if name == true
245
+ path.each { |val| add(val, name && task_join(name, File.basename(val)), **kwargs, &blk) }
246
+ return self
247
+ elsif !source_path?(path = base_path(path))
248
+ return self
249
+ elsif !name.is_a?(::String) && !name.is_a?(::Symbol)
250
+ name = nil
251
+ end
252
+ if @withargs
253
+ data = @withargs.dup
254
+ data.merge!(kwargs)
255
+ kwargs = data
256
+ end
226
257
  kwargs[:group] = group unless kwargs.key?(:group)
227
258
  kwargs[:ref] = ref unless kwargs.key?(:ref)
228
259
  parent = self
229
260
  proj = nil
230
- workspace.add(path, name || path.basename.to_s, **kwargs) do
261
+ workspace.add(path, name || path.basename, **kwargs) do
231
262
  variable_set :parent, parent
232
263
  proj = self
233
264
  end
@@ -236,54 +267,49 @@ module Squared
236
267
  self
237
268
  end
238
269
 
239
- def build(*args, sync: true)
270
+ def build(*args, sync: invoked_sync?('build'), **)
240
271
  if args.empty?
241
- cmd, opts, var = @output
242
- opts &&= shell_split(opts, join: true)
272
+ cmd, opts, var, flags = @output
273
+ banner = verbose == 1
243
274
  else
244
275
  cmd = args.shift
245
276
  opts = args.map { |val| shell_quote(val, force: false) }.join(' ')
277
+ banner = verbose
246
278
  end
247
279
  if cmd
248
- if opts
280
+ case opts
281
+ when ::String
249
282
  cmd = "#{cmd} #{opts}"
250
- elsif cmd.is_a?(::Array)
283
+ when ::Array
251
284
  cmd = cmd.join(' && ')
285
+ else
286
+ cmd = [cmd, compose(opts, script: false)].compact.join(' ') unless opts == false || !respond_to?(:compose)
252
287
  end
253
- banner = verbose != false
254
288
  else
255
289
  return unless respond_to?(:compose)
256
290
 
257
- cmd = compose(opts)
258
- banner = verbose == 1
291
+ cmd = compose(opts, flags, script: true)
259
292
  end
260
293
  run(cmd, var, banner: banner, sync: sync)
261
294
  end
262
295
 
263
- def refresh(*)
264
- build(sync: invoked_sync?('refresh') || invoked_sync?('build'))
265
- return if run_task "#{name}:copy"
266
-
267
- copy if copy?
296
+ def depend(*, sync: invoked_sync?('depend'), **)
297
+ run(@depend, sync: sync) if @depend
268
298
  end
269
299
 
270
- def depend(*)
271
- run(@depend, sync: invoked_sync?('depend')) if @depend
300
+ def copy(*, sync: invoked_sync?('copy'), **)
301
+ run_s(@copy, sync: sync) if @copy
272
302
  end
273
303
 
274
- def copy(*)
275
- run_s(@copy, sync: invoked_sync?('copy')) if @copy
304
+ def doc(*, sync: invoked_sync?('doc'), **)
305
+ build(@doc, sync: sync) if @doc
276
306
  end
277
307
 
278
- def doc
279
- build(@doc, sync: invoked_sync?('doc')) if @doc
308
+ def test(*, sync: invoked_sync?('test'), **)
309
+ build(@test, sync: sync) if @test
280
310
  end
281
311
 
282
- def test
283
- build(@test, sync: invoked_sync?('test')) if @test
284
- end
285
-
286
- def clean
312
+ def clean(*)
287
313
  case @clean
288
314
  when ::String
289
315
  run_s(@clean, sync: invoked_sync?('clean'))
@@ -311,15 +337,21 @@ module Squared
311
337
  end
312
338
 
313
339
  def log
314
- if @log.is_a?(::Array)
315
- @log = Logger.new(enabled? ? @log[0] : nil, **@log[1])
316
- else
317
- @log
318
- end
340
+ return @log unless @log.is_a?(::Array)
341
+
342
+ @log = Logger.new(enabled? ? @log[0] : nil, **@log[1])
319
343
  end
320
344
 
321
- def base_path(*args)
322
- path.join(*args)
345
+ def base_path(*args, ascend: nil)
346
+ ret = path.join(*args)
347
+ return ret unless ascend && !ret.exist?
348
+
349
+ path.parent.ascend.each do |dir|
350
+ target = dir.join(*args)
351
+ return target if target.exist?
352
+ break if (ascend.is_a?(String) && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
353
+ end
354
+ ret
323
355
  end
324
356
 
325
357
  def color(val)
@@ -328,26 +360,34 @@ module Squared
328
360
  end
329
361
 
330
362
  def variable_set(key, *val, **kwargs)
331
- if variable_all.include?(key)
363
+ if variables.include?(key)
332
364
  case key
333
365
  when :run
334
- run_set(*val, opts: false, **kwargs)
366
+ run_set(*val, **kwargs)
335
367
  when :script
336
368
  script_set(*val, **kwargs)
337
369
  when :env
338
- run_set(output[0], *val, opts: false, **kwargs)
370
+ run_set(output[0], *val, **kwargs)
371
+ when :parent
372
+ @parent = val if (val = val.first).is_a?(Project::Base)
339
373
  else
340
374
  instance_variable_set :"@#{key}", val.first
341
375
  end
342
376
  else
343
- log.warn "variable_set: @#{key} (not defined)"
377
+ log.warn "variable_set: @#{key} (private)"
344
378
  end
345
379
  end
346
380
 
347
- def variable_all
381
+ def variables
348
382
  VAR_SET
349
383
  end
350
384
 
385
+ def allref
386
+ @ref.reverse_each
387
+ end
388
+
389
+ def version(*); end
390
+
351
391
  def inspect
352
392
  "#<#{self.class}: #{name} => #{self}>"
353
393
  end
@@ -384,12 +424,12 @@ module Squared
384
424
  @output[0].nil? && !!@output[1] && respond_to?(:compose)
385
425
  end
386
426
 
387
- def refresh?
388
- build? && copy?
427
+ def depend?
428
+ !!@depend
389
429
  end
390
430
 
391
- def depend?
392
- @depend != false && (!@depend.nil? || has?('outdated'))
431
+ def copy?
432
+ runnable?(@copy) || workspace.task_defined?(name, 'copy')
393
433
  end
394
434
 
395
435
  def doc?
@@ -400,12 +440,8 @@ module Squared
400
440
  !!@test
401
441
  end
402
442
 
403
- def copy?
404
- runnable?(@copy) || workspace.task_defined?("#{name}:copy")
405
- end
406
-
407
443
  def clean?
408
- runnable?(@clean) || workspace.task_defined?("#{name}:clean")
444
+ runnable?(@clean) || workspace.task_defined?(name, 'clean')
409
445
  end
410
446
 
411
447
  def dev?
@@ -418,12 +454,16 @@ module Squared
418
454
 
419
455
  private
420
456
 
421
- def run(cmd = @session, var = nil, exception: @exception, banner: true, sync: true, req: nil, **)
457
+ def puts(*args)
458
+ puts_oe(*args, pipe: pipe)
459
+ end
460
+
461
+ def run(cmd = @session, var = nil, exception: @exception, sync: true, req: nil, banner: ARG[:BANNER], **)
422
462
  if req && !base_path(req).exist?
423
463
  log.warn "#{req} (not found)"
424
464
  return
425
465
  end
426
- cmd = close_session(cmd)
466
+ cmd = session_done(cmd)
427
467
  log.info cmd
428
468
  begin
429
469
  if cmd =~ /^\S+:(\S+:?)+$/ && workspace.task_defined?(cmd)
@@ -441,50 +481,55 @@ module Squared
441
481
  end
442
482
  end
443
483
 
444
- def run_s(cmd, **kwargs)
445
- as_a(cmd).each { |val| run(val, banner: !!verbose, **kwargs) if val.is_a?(::String) }
484
+ def run_s(*cmd, env: nil, **kwargs)
485
+ cmd.each { |val| run(val, env, banner: !!verbose, **kwargs) }
446
486
  end
447
487
 
448
488
  def run_task(key)
449
489
  return false unless workspace.task_defined?(key)
450
490
 
451
- invoke(key, exception: exception, warning: warning?)
491
+ invoke(key, **workspace.invokeargs)
452
492
  true
453
493
  end
454
494
 
455
- def env(key, default = nil, equals: nil, ignore: ['0'].freeze, suffix: nil, strict: false)
495
+ def env(key, default = nil, suffix: nil, equals: nil, ignore: nil, strict: false)
456
496
  a = "#{key}_#{@envname}"
457
- b = ''
458
- if suffix
459
- a = "#{a}_#{suffix}"
460
- elsif !strict
461
- b = ENV.fetch(key, '')
462
- end
463
- ret = ENV.fetch(a, b)
497
+ ret = if suffix
498
+ ENV.fetch("#{a}_#{suffix}", '')
499
+ else
500
+ ignore = ['0'].freeze if ignore.nil? && !strict
501
+ ENV[a] || (strict ? '' : ENV.fetch(key, ''))
502
+ end
464
503
  return ret == equals.to_s unless equals.nil?
465
504
 
466
- ret.empty? || as_a(ignore).any? { |val| ret == val.to_s } ? default : ret
505
+ ret.empty? || (ignore && as_a(ignore).any? { |val| ret == val.to_s }) ? default : ret
467
506
  end
468
507
 
469
- def puts(*args)
470
- pipe == 2 ? $stderr.puts(*args) : $stdout.puts(*args)
471
- end
472
-
473
- def session(*cmd, prefix: nil)
474
- if (val = ENV["#{(prefix || cmd.first).upcase}_OPTIONS"])
508
+ def session(*cmd, prefix: cmd.first)
509
+ if (val = env("#{prefix.upcase}_OPTIONS"))
475
510
  split_escape(val).each { |opt| cmd << fill_option(opt) }
476
511
  end
477
512
  @session = JoinSet.new(cmd)
478
513
  end
479
514
 
480
- def close_session(cmd)
481
- return cmd unless cmd.respond_to?(:done)
515
+ def session_done(cmd)
516
+ return cmd.to_s unless cmd.respond_to?(:done)
482
517
 
483
518
  raise_error('no args were added', hint: cmd.first || name) unless cmd.size > 1
484
519
  @session = nil if cmd == @session
485
520
  cmd.done
486
521
  end
487
522
 
523
+ def option(*args, prefix: @session&.first, **kwargs)
524
+ if prefix
525
+ args.each do |val|
526
+ ret = env("#{prefix}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
527
+ return ret if ret
528
+ end
529
+ end
530
+ nil
531
+ end
532
+
488
533
  def print_item(*val)
489
534
  puts unless @@print_order == 0 || stdin?
490
535
  @@print_order += 1
@@ -516,33 +561,37 @@ module Squared
516
561
  out.join("\n")
517
562
  end
518
563
 
519
- def print_footer(*lines, sub: nil, border: theme[:border], reverse: false)
564
+ def print_footer(*lines, sub: nil, reverse: false, right: false, **kwargs)
565
+ border = kwargs.key?(:border) ? kwargs[:border] : borderstyle
520
566
  n = Project.max_width(lines)
521
567
  sub = as_a(sub)
522
568
  lines.map! do |val|
523
- s = val.ljust(n)
569
+ s = right ? val.rjust(n) : val.ljust(n)
524
570
  sub.each { |h| s = sub_style(s, **h) }
525
571
  s
526
572
  end
527
- ret = [sub_style('-' * n, styles: border), *lines]
573
+ ret = [sub_style('-' * n, styles: border || theme[:border]), *lines]
528
574
  ret.reverse! if reverse
529
575
  ret.join("\n")
530
576
  end
531
577
 
532
- def format_desc(action, flag, opts = nil, req: '', arg: 'opts*')
578
+ def format_desc(action, flag, opts = nil, req: nil, arg: 'opts*')
533
579
  opts = "#{arg}=#{opts.join(',')}" if opts.is_a?(::Array)
534
- unless flag
580
+ val = [@desc]
581
+ if flag
582
+ val << action
583
+ else
535
584
  flag = action
536
- action = ''
537
585
  end
538
- req = opts ? "#{req}," : "[#{req}]" unless req.to_s.empty?
539
- message(@desc, action, opts ? "#{flag}[#{req}#{opts}]" : flag.to_s + req)
586
+ req = opts ? "#{req}," : "[#{req}]" if req
587
+ val << (opts ? "#{flag}[#{req}#{opts}]" : "#{flag}#{req}")
588
+ message(*val)
540
589
  end
541
590
 
542
- def format_banner(cmd, banner: true, multiple: false)
591
+ def format_banner(cmd, banner: ARG[:BANNER], multiple: false)
543
592
  return unless banner
544
593
 
545
- if (data = workspace.banner(group: group, ref: ref))
594
+ if (data = workspace.banner_get(*@ref, group: group))
546
595
  client = true
547
596
  else
548
597
  data = { command: true, order: %i[path], styles: theme[:banner], border: theme[:border] }
@@ -550,7 +599,26 @@ module Squared
550
599
  if verbose
551
600
  out = []
552
601
  out << cmd.sub(/^\S+/, &:upcase) if data[:command]
553
- data[:order].each { |val| out << val.to_s if (val = __send__(val)) }
602
+ data[:order].each do |val|
603
+ if val.is_a?(::Array)
604
+ s = ' '
605
+ found = false
606
+ val = val.map do |meth|
607
+ if meth.is_a?(::String)
608
+ s = ''
609
+ meth
610
+ elsif respond_to?(meth)
611
+ found = true
612
+ __send__(meth)
613
+ end
614
+ end
615
+ val = val.compact.join(s)
616
+ next unless found && !val.empty?
617
+ elsif (val = __send__(val)).nil?
618
+ next
619
+ end
620
+ out << val.to_s
621
+ end
554
622
  print_banner(*out, styles: data[:styles], border: data[:border], client: client)
555
623
  elsif multiple && workspace.series.multiple?
556
624
  "## #{__send__(data[:order].first || :path)} ##"
@@ -569,8 +637,12 @@ module Squared
569
637
  opts.each { |val| @session << val }
570
638
  end
571
639
 
572
- def append_nocolor
573
- @session << (!ENV.fetch('NO_COLOR', '').empty? || stdin? ? '--no-color' : '')
640
+ def append_nocolor(flag = nil)
641
+ @session << '--no-color' if flag || !ARG[:COLOR] || stdin?
642
+ end
643
+
644
+ def task_join(*val)
645
+ val.join(':')
574
646
  end
575
647
 
576
648
  def guard_params(action, flag, args: nil, key: nil, pat: nil)
@@ -587,6 +659,26 @@ module Squared
587
659
  end
588
660
  end
589
661
 
662
+ def semver(val)
663
+ return val if val[3]
664
+
665
+ val[3] = '.'
666
+ val[4] = '0'
667
+ unless val[1]
668
+ val[1] = '.'
669
+ val[2] = '0'
670
+ end
671
+ val
672
+ end
673
+
674
+ def semmajor(cur, want)
675
+ (cur[0] == '0' && want[0] == '0' ? cur[2] != want[2] : cur[0] != want[0]) && !want[5]
676
+ end
677
+
678
+ def semscan(val)
679
+ val.scan(SEM_VER).first
680
+ end
681
+
590
682
  def pwd_set(done = nil, &blk)
591
683
  pwd = Pathname.pwd
592
684
  if block_given?
@@ -612,39 +704,27 @@ module Squared
612
704
  end
613
705
  end
614
706
 
615
- def semver(val)
616
- unless val[3]
617
- val[3] = '.'
618
- val[4] = '0'
707
+ def run_set(cmd, val = nil, opts: nil, **)
708
+ unless @output[1] == false && !@output[0].nil?
709
+ if opts == false
710
+ @output[1] = false
711
+ elsif opts && opts != true
712
+ @output[1] = opts
713
+ end
619
714
  end
620
- unless val[1]
621
- val[1] = '.'
622
- val[2] = '0'
715
+ unless @output[2] == false
716
+ if val.is_a?(::Hash)
717
+ @output[2] = val
718
+ elsif val == false
719
+ @output[2] = false
720
+ end
623
721
  end
624
- val
625
- end
626
-
627
- def semmajor(cur, want)
628
- (cur[0] == '0' && want[0] == '0' ? cur[2] != want[2] : cur[0] != want[0]) && !want[5]
629
- end
630
-
631
- def scriptargs
632
- { target: script? ? @output[1] : @output[0], ref: ref, group: group, global: @global }
633
- end
634
-
635
- def run_set(cmd, val = nil, *, opts: true, **)
636
722
  @output[0] = cmd
637
- @output[1] = if cmd && opts
638
- env('BUILD', opts.is_a?(::String) ? opts : nil, suffix: 'OPTS')
639
- end
640
- if val.is_a?(::Hash)
641
- @output[2] = val
642
- elsif val == false
643
- @output[2] = nil
644
- end
645
723
  end
646
724
 
647
- def script_set(cmd, *, prod: nil, **)
725
+ def script_set(cmd, prod: nil, **)
726
+ return if @output[1] == false && @output[0].nil?
727
+
648
728
  @output[0] = nil
649
729
  @output[1] = if @global && cmd.is_a?(::Array)
650
730
  cmd[prod == true ? 1 : 0]
@@ -657,14 +737,6 @@ module Squared
657
737
  Pathname.new(val).absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.match?(%r{^\.\.[/\\]})
658
738
  end
659
739
 
660
- def warning?
661
- workspace.warning
662
- end
663
-
664
- def stdin?
665
- pipe == 0
666
- end
667
-
668
740
  def runnable?(val)
669
741
  case val
670
742
  when ::String
@@ -676,10 +748,10 @@ module Squared
676
748
  end
677
749
  end
678
750
 
679
- def from_sync?(val)
680
- if invoked?(val)
681
- !workspace.task_defined?("#{val}:sync")
682
- elsif workspace.series.sync?("#{val}:sync")
751
+ def from_sync?(*val)
752
+ if invoked?(key = task_join(*val))
753
+ !workspace.task_defined?(key, 'sync')
754
+ elsif workspace.series.sync?(task_join(key, 'sync'))
683
755
  true
684
756
  end
685
757
  end
@@ -687,12 +759,35 @@ module Squared
687
759
  def invoked_sync?(action, val = nil)
688
760
  return true if !val.nil? || from_sync?(ac = workspace.task_name(action))
689
761
 
690
- return val if group && !(val = from_sync?("#{ac}:#{group}")).nil?
691
- return val if (base = workspace.find_base(self)) && !(val = from_sync?("#{ac}:#{base.ref}")).nil?
762
+ return val if group && !(val = from_sync?(ac, group)).nil?
763
+ return val if (base = workspace.find_base(self)) && !(val = from_sync?(ac, base.ref)).nil?
764
+
765
+ return true if invoked?(name, ac) && (!invoked?(ac) || !workspace.task_defined?(ac, 'sync'))
766
+
767
+ val = workspace.series.name_get(action)
768
+ val == action ? false : invoked_sync?(val)
769
+ end
770
+
771
+ def stdin?
772
+ pipe == 0
773
+ end
774
+
775
+ def warning?
776
+ workspace.warning
777
+ end
778
+
779
+ def borderstyle
780
+ if (data = workspace.banner_get(*@ref, group: group))
781
+ data[:border]
782
+ end
783
+ end
692
784
 
693
- invoked?("#{name}:#{ac}") && (!invoked?(ac) || !workspace.task_defined?("#{ac}:sync"))
785
+ def scriptargs
786
+ { target: script? ? @output[1] : @output[0], ref: ref, group: group, global: @global }
694
787
  end
695
788
  end
789
+
790
+ Application.base_project = Base
696
791
  end
697
792
  end
698
793
  end