squared 0.4.19 → 0.4.21
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 +48 -0
- data/README.md +17 -13
- data/lib/squared/common/format.rb +3 -7
- data/lib/squared/common/shell.rb +3 -3
- data/lib/squared/common/system.rb +2 -3
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +3 -1
- data/lib/squared/workspace/project/base.rb +83 -89
- data/lib/squared/workspace/project/docker.rb +14 -15
- data/lib/squared/workspace/project/git.rb +28 -31
- data/lib/squared/workspace/project/node.rb +32 -30
- data/lib/squared/workspace/project/python.rb +24 -32
- data/lib/squared/workspace/project/ruby.rb +108 -108
- data/lib/squared/workspace/project/support/class.rb +166 -42
- data/lib/squared/workspace/repo.rb +0 -3
- data/lib/squared/workspace/series.rb +16 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d8a1b2cbf68268501ff6e6d0c93376a695f65d5d39f3e54d51fc3782869080a
|
4
|
+
data.tar.gz: d79358deea9e25c69c7c1e43730109b9609bb52949b367f457c972166da38485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40f3aca8a6df314ce47bfceb7df8c4dffd00a8c05953d4e68ee104f6f33bd15ec8dfcf4d12bc23490d545982376cad0fb4aa17797d3340e120f88ef55907fcfa
|
7
|
+
data.tar.gz: 24833ff7f8fc10a50760959bf421371049256df809bcf9a2fe742a3d2faf4f8608cb560cefc8cae7c40eabfcc3dbf579de03f46c836f6057a2d74266329ce75f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,51 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.4.21] - 2025-10-01
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Project base method variable_set was aliased to the name apply.
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Project base method run visibility was changed to public.
|
12
|
+
- OptionPartition method uniq! returns self or nil.
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- Docker attribute file did not search for nearest config.
|
17
|
+
- Project task run did not accept Proc or Method definitions.
|
18
|
+
- Gem command options were revalidated to 3.7.2.
|
19
|
+
- Bundler command options were revalidated to 2.7.2.
|
20
|
+
- Ruby class method bundle did not pass through commands.
|
21
|
+
- Ruby task ruby did not separate options and arguments.
|
22
|
+
- Pip commands uninstall and freeze did not filter options.
|
23
|
+
- Ruby command gem action update did not append packages.
|
24
|
+
- OptionPartition did not detect short options with a merged value.
|
25
|
+
- Gem commands option version did not use quotes.
|
26
|
+
- Git command pull action all used undefined delete_prefix! method.
|
27
|
+
- OptionPartition did not delete added values from extras.
|
28
|
+
- Python editable projects can override requirements detection.
|
29
|
+
- Project session method did delete short options with a merged value.
|
30
|
+
- Gem command install did not try to resolve local paths.
|
31
|
+
- Ruby commands did not always check for file target exists.
|
32
|
+
|
33
|
+
## [0.4.20] - 2025-09-14
|
34
|
+
|
35
|
+
### Changed
|
36
|
+
|
37
|
+
- Project banners when requested return consistent arguments.
|
38
|
+
|
39
|
+
### Fixed
|
40
|
+
|
41
|
+
- Workspace global as command alias used undefined parameter.
|
42
|
+
- Python did not separate dependency manager and build backend.
|
43
|
+
- Gem command build did not validate gemspec was located.
|
44
|
+
- Project class Ruby used glob methods not available in Ruby 2.4.
|
45
|
+
- Shell options support using boolean as values.
|
46
|
+
- Git command merge action commit failed when using interactive menu.
|
47
|
+
- NPM command line options did not support boolean flags.
|
48
|
+
|
3
49
|
## [0.4.19] - 2025-08-30
|
4
50
|
|
5
51
|
### Added
|
@@ -946,6 +992,8 @@
|
|
946
992
|
|
947
993
|
- Changelog was created.
|
948
994
|
|
995
|
+
[0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
|
996
|
+
[0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
|
949
997
|
[0.4.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.19
|
950
998
|
[0.4.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.18
|
951
999
|
[0.4.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.17-ruby
|
data/README.md
CHANGED
@@ -105,9 +105,9 @@ Workspace::Application
|
|
105
105
|
revbuild(include: %w[src/ framework/ types/]) # Synchronous is recommended
|
106
106
|
end
|
107
107
|
.add("squared/sqd", exclude: :git, pass: [:node, "checkout", "bump"]) do # Skip initialize(:node) + squared:checkout:* + squared:bump:*
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
apply :script, "build:sqd" # Override detection
|
109
|
+
apply :depend, false #
|
110
|
+
apply :clean, ["build/sqd/"] # variable_set (alias)
|
111
111
|
end
|
112
112
|
.with(:docker, only: ["build", "compose"]) do
|
113
113
|
.add("squared", "docker", file: "Dockerfile", context: ".", tag: "latest", registry: "localhost:5000", username: "squared",
|
@@ -303,7 +303,7 @@ Workspace::Application
|
|
303
303
|
doc(windows? ? ".\make.bat html" : "make html") # rake android-docs:doc | rake doc:python
|
304
304
|
add("android-docs", "android", venv: "/home/user/.venv") # rake android-docs:depend
|
305
305
|
add("chrome-docs", "chrome", graph: "android", venv: %w[.venv --clear]) do # /workspaces/chrome-docs/.venv
|
306
|
-
|
306
|
+
apply :dependindex, 1 # Use Poetry for dependencies (optional)
|
307
307
|
end
|
308
308
|
end
|
309
309
|
.with(:node) do
|
@@ -495,22 +495,23 @@ Most project classes will inherit from `Git` which enables these tasks:
|
|
495
495
|
|
496
496
|
| Task | Git | Command |
|
497
497
|
| :--------- | :--------------- | :-------------------------------------------- |
|
498
|
-
| branch | branch | create
|
498
|
+
| branch | branch | create track delete move copy list current |
|
499
499
|
| checkout | checkout | commit branch track detach path |
|
500
500
|
| commit | commit | add all amend amend-orig fixup |
|
501
|
-
| diff | diff | head
|
501
|
+
| diff | diff | head branch files view between contain |
|
502
502
|
| fetch | fetch | origin remote all |
|
503
503
|
| files | ls-files | cached modified deleted others |
|
504
|
-
| git | | add blame clean mv rm
|
504
|
+
| git | | add blame clean mv revert rm status |
|
505
|
+
| log | log | view between contain |
|
505
506
|
| merge | merge | commit no-commit send |
|
506
507
|
| pull | pull | origin remote all |
|
507
508
|
| rebase | rebase | branch onto send |
|
508
509
|
| refs | ls-remote --refs | heads tags remote |
|
509
|
-
| reset | reset | commit index patch mode
|
510
|
-
| restore | restore | staged worktree
|
511
|
-
| rev | rev | commit output
|
512
|
-
| show | show | format oneline
|
513
|
-
| stash | stash | push pop apply branch drop clear list
|
510
|
+
| reset | reset | commit index patch mode undo |
|
511
|
+
| restore | restore | source staged worktree |
|
512
|
+
| rev | rev | commit build output |
|
513
|
+
| show | show | format oneline textconv |
|
514
|
+
| stash | stash | push pop apply branch drop clear list |
|
514
515
|
| submodule | submodule | status update branch url sync |
|
515
516
|
| switch | switch | branch create detach |
|
516
517
|
| tag | tag | add sign delete list |
|
@@ -597,6 +598,9 @@ BUILD_${NAME}_VERSION=0.1.0 # publish + detection
|
|
597
598
|
BANNER=0 # hide banner
|
598
599
|
BANNER_${NAME}=0 #
|
599
600
|
|
601
|
+
VERBOSE=0 # console output level
|
602
|
+
VERBOSE_${NAME}=0 # 0,1,2,n
|
603
|
+
|
600
604
|
REVBUILD_FORCE=1 # Rebuild all targets
|
601
605
|
REVBUILD_FORCE_${NAME}=1 # Rebuild project
|
602
606
|
|
@@ -639,7 +643,7 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
|
|
639
643
|
| :--------- | :---------------- | :-------------------------------------------------------------------- |
|
640
644
|
| branch | create | TRACK=0,1,s F|FORCE |
|
641
645
|
| branch | move copy | F|FORCE |
|
642
|
-
| branch |
|
646
|
+
| branch | delete | COUNT=n |
|
643
647
|
| branch | global | SYNC |
|
644
648
|
| checkout | branch | DETACH TRACK=s COUNT=n |
|
645
649
|
| checkout | detach | REFLOG=1 |
|
@@ -189,7 +189,7 @@ module Squared
|
|
189
189
|
emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
|
190
190
|
else
|
191
191
|
msg = [log_title(level, color: color)]
|
192
|
-
msg << (color ? sub_style(subject, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
|
192
|
+
msg << (color ? sub_style(subject.to_s, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
|
193
193
|
msg << args.shift if msg.size == 1
|
194
194
|
message(msg.join(' '), *args, hint: hint)
|
195
195
|
end
|
@@ -223,12 +223,8 @@ module Squared
|
|
223
223
|
def emphasize(val, title: nil, footer: nil, right: false, cols: nil, sub: nil, pipe: nil,
|
224
224
|
border: @theme && @theme[:border])
|
225
225
|
n = 0
|
226
|
-
max = ->(
|
227
|
-
set =
|
228
|
-
ret = as_a(v, :to_s)
|
229
|
-
max.call(ret)
|
230
|
-
ret
|
231
|
-
end
|
226
|
+
max = ->(a) { n = [n, a.max_by(&:size).size].max }
|
227
|
+
set = ->(s) { Array(s).map(&:to_s).tap { |a| max.call(a) } }
|
232
228
|
title &&= set.call(title)
|
233
229
|
footer &&= set.call(footer)
|
234
230
|
if val.is_a?(::Array)
|
data/lib/squared/common/shell.rb
CHANGED
@@ -74,7 +74,7 @@ module Squared
|
|
74
74
|
a = '--'
|
75
75
|
b = '='
|
76
76
|
end
|
77
|
-
"#{a}#{flag}#{
|
77
|
+
"#{a}#{flag}#{unless val.nil?
|
78
78
|
"#{b}#{if escape
|
79
79
|
shell_escape(val, quote: quote, double: double, override: override)
|
80
80
|
elsif quote
|
@@ -94,8 +94,8 @@ module Squared
|
|
94
94
|
|
95
95
|
def shell_bin(name, env: true)
|
96
96
|
key = name.upcase
|
97
|
-
shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
|
98
|
-
|
97
|
+
shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name, option: false, force: false,
|
98
|
+
double: true)
|
99
99
|
end
|
100
100
|
|
101
101
|
def fill_option(val, **kwargs)
|
data/lib/squared/config.rb
CHANGED
@@ -213,7 +213,7 @@ module Squared
|
|
213
213
|
ext[0] = mime
|
214
214
|
elsif file
|
215
215
|
keys.unshift(file)
|
216
|
-
alt = basepath
|
216
|
+
alt = basepath "#{main}.{#{ext.join(',')}}"
|
217
217
|
file = Dir[alt].first
|
218
218
|
else
|
219
219
|
alt = main
|
@@ -346,8 +346,8 @@ module Squared
|
|
346
346
|
basepath(file = main + @ext).to_s rescue file
|
347
347
|
end
|
348
348
|
|
349
|
-
def basepath(
|
350
|
-
project ? project.basepath(
|
349
|
+
def basepath(*args)
|
350
|
+
project ? project.basepath(*args) : Pathname.pwd.join(*args)
|
351
351
|
end
|
352
352
|
end
|
353
353
|
end
|
data/lib/squared/version.rb
CHANGED
@@ -9,6 +9,7 @@ module Squared
|
|
9
9
|
module Workspace
|
10
10
|
module Project
|
11
11
|
class Base
|
12
|
+
include Comparable
|
12
13
|
include Common::Format
|
13
14
|
include System
|
14
15
|
include Shell
|
@@ -16,7 +17,6 @@ module Squared
|
|
16
17
|
include Utils
|
17
18
|
include Support
|
18
19
|
include Rake::DSL
|
19
|
-
include ::Comparable
|
20
20
|
|
21
21
|
VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
|
22
22
|
pass only exclude].freeze
|
@@ -83,6 +83,7 @@ module Squared
|
|
83
83
|
@name = name.to_s.freeze
|
84
84
|
@project = @path.basename.to_s.freeze
|
85
85
|
@group = group&.to_s.freeze
|
86
|
+
@envname = env_key(@name).freeze
|
86
87
|
@depend = kwargs[:depend]
|
87
88
|
@doc = kwargs[:doc]
|
88
89
|
@lint = kwargs[:lint]
|
@@ -98,7 +99,7 @@ module Squared
|
|
98
99
|
@ref = []
|
99
100
|
@children = []
|
100
101
|
@events = hashobj.update({ first: first, last: last, error: error })
|
101
|
-
@
|
102
|
+
@as = hashobj
|
102
103
|
@desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
|
103
104
|
@parent = nil
|
104
105
|
@global = false
|
@@ -195,7 +196,7 @@ module Squared
|
|
195
196
|
file &&= @workspace.home.join(env('LOG_DIR', ''), file).realdirpath
|
196
197
|
rescue StandardError => e
|
197
198
|
file = nil
|
198
|
-
|
199
|
+
print_error e
|
199
200
|
end
|
200
201
|
log[:progname] ||= @name
|
201
202
|
if (val = env('LOG_LEVEL', ignore: false))
|
@@ -287,7 +288,7 @@ module Squared
|
|
287
288
|
end
|
288
289
|
|
289
290
|
def verbose=(val)
|
290
|
-
@verbose = case val
|
291
|
+
@verbose = case (val = env('VERBOSE', val))
|
291
292
|
when NilClass
|
292
293
|
workspace.verbose
|
293
294
|
when String
|
@@ -362,7 +363,7 @@ module Squared
|
|
362
363
|
else
|
363
364
|
force = args.fetch(:force, false)
|
364
365
|
end
|
365
|
-
unpack(
|
366
|
+
unpack(basepath(dir), uri: tag, digest: digest, ext: ext, force: force)
|
366
367
|
end
|
367
368
|
end
|
368
369
|
end
|
@@ -410,7 +411,6 @@ module Squared
|
|
410
411
|
kwargs[:group] = group unless kwargs.key?(:group)
|
411
412
|
kwargs[:ref] = ref unless kwargs.key?(:ref)
|
412
413
|
parent = self
|
413
|
-
proj = nil
|
414
414
|
name = case name
|
415
415
|
when String, Symbol
|
416
416
|
name.to_s
|
@@ -419,10 +419,9 @@ module Squared
|
|
419
419
|
end
|
420
420
|
workspace.add(path, name, **kwargs) do
|
421
421
|
__send__ :parent_set, parent
|
422
|
-
|
422
|
+
@children << self
|
423
|
+
instance_eval(&blk) if block_given?
|
423
424
|
end
|
424
|
-
@children << proj
|
425
|
-
proj.instance_eval(&blk) if block_given?
|
426
425
|
self
|
427
426
|
end
|
428
427
|
|
@@ -436,7 +435,7 @@ module Squared
|
|
436
435
|
|
437
436
|
out = obj.link(self, *args, **kwargs, &blk) if obj.respond_to?(:link)
|
438
437
|
if !out
|
439
|
-
|
438
|
+
print_error('link not compatible', subject: obj, hint: name)
|
440
439
|
elsif out.respond_to?(:build)
|
441
440
|
out.build
|
442
441
|
end
|
@@ -476,7 +475,7 @@ module Squared
|
|
476
475
|
else
|
477
476
|
next unless respond_to?(:compose)
|
478
477
|
|
479
|
-
cmd << a if (a = compose(as_get(b), d, script: true, args: e, from: from))
|
478
|
+
cmd << a if (a = compose(as_get(b, from), d, script: true, args: e, from: from))
|
480
479
|
end
|
481
480
|
var.merge!(c) if c.is_a?(Hash)
|
482
481
|
end
|
@@ -484,8 +483,12 @@ module Squared
|
|
484
483
|
else
|
485
484
|
cmd, opts, var, flags, extra = args
|
486
485
|
end
|
486
|
+
if cmd.is_a?(Proc) || cmd.is_a?(Method)
|
487
|
+
run_b(cmd, sync: sync, from: from)
|
488
|
+
return
|
489
|
+
end
|
487
490
|
if cmd
|
488
|
-
cmd = as_get
|
491
|
+
cmd = as_get(cmd, from)
|
489
492
|
opts = compose(opts, script: false) if opts && respond_to?(:compose)
|
490
493
|
flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
|
491
494
|
case opts
|
@@ -502,7 +505,7 @@ module Squared
|
|
502
505
|
else
|
503
506
|
return unless (opts || extra) && respond_to?(:compose)
|
504
507
|
|
505
|
-
cmd = compose(as_get(opts), flags, script: true, args: extra, from: from)
|
508
|
+
cmd = compose(as_get(opts, from), flags, script: true, args: extra, from: from)
|
506
509
|
from = :script if from == :run && script?
|
507
510
|
end
|
508
511
|
run(cmd, var, sync: sync, from: from, banner: banner)
|
@@ -527,7 +530,7 @@ module Squared
|
|
527
530
|
on_error(:prereqs, e, exception: true)
|
528
531
|
end
|
529
532
|
end
|
530
|
-
|
533
|
+
print_error(name, 'method not found', subject: 'prereqs', hint: meth)
|
531
534
|
end
|
532
535
|
elsif proj.build?
|
533
536
|
proj.build(sync: sync)
|
@@ -582,7 +585,7 @@ module Squared
|
|
582
585
|
else
|
583
586
|
if @clean.is_a?(Enumerable) && !series?(@clean)
|
584
587
|
@clean.each do |val|
|
585
|
-
entry =
|
588
|
+
entry = basepath(val = val.to_s)
|
586
589
|
if entry.directory? && val.match?(%r{[\\/]\z})
|
587
590
|
log&.warn "rm -rf #{entry}"
|
588
591
|
rm_rf(entry, verbose: verbose)
|
@@ -715,7 +718,7 @@ module Squared
|
|
715
718
|
delete = true
|
716
719
|
end
|
717
720
|
if create
|
718
|
-
|
721
|
+
print_error('force remove', subject: name, hint: target)
|
719
722
|
target.rmtree
|
720
723
|
target.mkpath
|
721
724
|
end
|
@@ -788,9 +791,8 @@ module Squared
|
|
788
791
|
end
|
789
792
|
|
790
793
|
def as(cmd, script, to = nil)
|
791
|
-
|
792
|
-
|
793
|
-
script.each { |key, val| data[key.to_s] = val }
|
794
|
+
data = @as[cmd.to_sym]
|
795
|
+
(to ? [[script, to]] : script).each { |key, val| data[key.to_s] = val }
|
794
796
|
self
|
795
797
|
end
|
796
798
|
|
@@ -807,6 +809,56 @@ module Squared
|
|
807
809
|
self
|
808
810
|
end
|
809
811
|
|
812
|
+
def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
|
813
|
+
interactive: nil, hint: nil, **)
|
814
|
+
unless cmd
|
815
|
+
print_error('no command given', subject: project, hint: from || 'unknown', pass: true)
|
816
|
+
return
|
817
|
+
end
|
818
|
+
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
819
|
+
if interactive && (!@session || !option('y'))
|
820
|
+
title, y = case interactive
|
821
|
+
when Array
|
822
|
+
interactive
|
823
|
+
when String
|
824
|
+
[interactive, 'N']
|
825
|
+
else
|
826
|
+
['Run', 'Y']
|
827
|
+
end
|
828
|
+
yn = y == 'Y' ? 'Y/n' : 'y/N'
|
829
|
+
exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
|
830
|
+
end
|
831
|
+
cmd = session_done cmd
|
832
|
+
log&.info cmd
|
833
|
+
on :first, from
|
834
|
+
begin
|
835
|
+
if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
|
836
|
+
log&.warn "ENV discarded: #{var}" if var
|
837
|
+
task_invoke(cmd, exception: exception, warning: warning?)
|
838
|
+
else
|
839
|
+
print_item format_banner(hint ? "#{cmd} (#{hint})" : cmd, banner: banner) if sync
|
840
|
+
if var != false && (pre = runenv)
|
841
|
+
case pre
|
842
|
+
when Hash
|
843
|
+
var = var.is_a?(Hash) ? pre.merge(var) : pre
|
844
|
+
when Enumerable
|
845
|
+
cmd = command(*pre.to_a, cmd)
|
846
|
+
else
|
847
|
+
cmd = command(pre, cmd)
|
848
|
+
end
|
849
|
+
end
|
850
|
+
args = var.is_a?(Hash) ? [var, cmd] : [cmd]
|
851
|
+
ret = shell(*args, chdir: chdir, exception: exception)
|
852
|
+
end
|
853
|
+
rescue StandardError => e
|
854
|
+
on_error(from, e, exception: true)
|
855
|
+
false
|
856
|
+
else
|
857
|
+
on :last, from
|
858
|
+
ret
|
859
|
+
end
|
860
|
+
end
|
861
|
+
|
810
862
|
def variable_set(key, *args, **kwargs, &blk)
|
811
863
|
if variables.include?(key) || blocks.include?(key)
|
812
864
|
val = case args.size
|
@@ -856,6 +908,8 @@ module Squared
|
|
856
908
|
self
|
857
909
|
end
|
858
910
|
|
911
|
+
alias apply variable_set
|
912
|
+
|
859
913
|
def enabled?(ref = nil, **)
|
860
914
|
return false if ref && !ref?(ref)
|
861
915
|
|
@@ -966,7 +1020,7 @@ module Squared
|
|
966
1020
|
path.parent.ascend.each do |dir|
|
967
1021
|
target = dir.join(*args)
|
968
1022
|
return target if target.exist?
|
969
|
-
break if (ascend
|
1023
|
+
break if (ascend && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
|
970
1024
|
end
|
971
1025
|
ret
|
972
1026
|
end
|
@@ -993,56 +1047,6 @@ module Squared
|
|
993
1047
|
log_console(*args, pipe: kwargs[:pipe] || pipe)
|
994
1048
|
end
|
995
1049
|
|
996
|
-
def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
|
997
|
-
interactive: nil, hint: nil, **)
|
998
|
-
unless cmd
|
999
|
-
warn log_message(Logger::WARN, 'no command given', subject: project, hint: from || 'unknown', pass: true)
|
1000
|
-
return
|
1001
|
-
end
|
1002
|
-
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
1003
|
-
if interactive && (!@session || !option('y'))
|
1004
|
-
title, y = case interactive
|
1005
|
-
when Array
|
1006
|
-
interactive
|
1007
|
-
when String
|
1008
|
-
[interactive, 'N']
|
1009
|
-
else
|
1010
|
-
['Run', 'Y']
|
1011
|
-
end
|
1012
|
-
yn = y == 'Y' ? 'Y/n' : 'y/N'
|
1013
|
-
exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
|
1014
|
-
end
|
1015
|
-
cmd = session_done cmd
|
1016
|
-
log&.info cmd
|
1017
|
-
on :first, from
|
1018
|
-
begin
|
1019
|
-
if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
|
1020
|
-
log&.warn "ENV discarded: #{var}" if var
|
1021
|
-
task_invoke(cmd, exception: exception, warning: warning?)
|
1022
|
-
else
|
1023
|
-
print_item format_banner(hint ? "#{cmd} (#{hint})" : cmd, banner: banner) if sync
|
1024
|
-
if var != false && (pre = runenv)
|
1025
|
-
case pre
|
1026
|
-
when Hash
|
1027
|
-
var = var.is_a?(Hash) ? pre.merge(var) : pre
|
1028
|
-
when Enumerable
|
1029
|
-
cmd = command(*pre.to_a, cmd)
|
1030
|
-
else
|
1031
|
-
cmd = command(pre, cmd)
|
1032
|
-
end
|
1033
|
-
end
|
1034
|
-
args = var.is_a?(Hash) ? [var, cmd] : [cmd]
|
1035
|
-
ret = shell(*args, chdir: chdir, exception: exception)
|
1036
|
-
end
|
1037
|
-
rescue StandardError => e
|
1038
|
-
on_error(from, e, exception: true)
|
1039
|
-
false
|
1040
|
-
else
|
1041
|
-
on :last, from
|
1042
|
-
ret
|
1043
|
-
end
|
1044
|
-
end
|
1045
|
-
|
1046
1050
|
def run_s(*cmd, env: nil, sync: true, from: nil, banner: verbose != false, **kwargs)
|
1047
1051
|
on :first, from
|
1048
1052
|
begin
|
@@ -1241,15 +1245,7 @@ module Squared
|
|
1241
1245
|
end
|
1242
1246
|
|
1243
1247
|
def session_delete(*args, target: @session)
|
1244
|
-
|
1245
|
-
args.each do |val|
|
1246
|
-
pat = /\A#{Regexp.escape(shell_option(val))}(?: |=|\z)/
|
1247
|
-
if (key = target.find { |opt| opt.match?(pat) })
|
1248
|
-
target.delete(key)
|
1249
|
-
ret << key
|
1250
|
-
end
|
1251
|
-
end
|
1252
|
-
ret
|
1248
|
+
OptionPartition.delete(target, *args)
|
1253
1249
|
end
|
1254
1250
|
|
1255
1251
|
def session_output(*cmd, **kwargs)
|
@@ -1295,8 +1291,8 @@ module Squared
|
|
1295
1291
|
puts 'Success'
|
1296
1292
|
end
|
1297
1293
|
|
1298
|
-
def print_error(
|
1299
|
-
warn log_message(loglevel,
|
1294
|
+
def print_error(*args, loglevel: Logger::WARN, **kwargs)
|
1295
|
+
warn log_message(loglevel, *args, **kwargs) if warning?
|
1300
1296
|
end
|
1301
1297
|
|
1302
1298
|
def print_item(*val)
|
@@ -1467,7 +1463,7 @@ module Squared
|
|
1467
1463
|
next if (key = key.to_s).start_with?('__')
|
1468
1464
|
|
1469
1465
|
if val.nil? || extra || session_arg?(key, target: target)
|
1470
|
-
|
1466
|
+
OptionPartition.delete_key(target, key)
|
1471
1467
|
next if val.nil?
|
1472
1468
|
end
|
1473
1469
|
case val
|
@@ -1601,7 +1597,7 @@ module Squared
|
|
1601
1597
|
raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
|
1602
1598
|
rescue StandardError => e
|
1603
1599
|
log&.warn e
|
1604
|
-
|
1600
|
+
print_error(e, subject: name)
|
1605
1601
|
else
|
1606
1602
|
ret
|
1607
1603
|
end
|
@@ -1739,7 +1735,7 @@ module Squared
|
|
1739
1735
|
raise_error 'pathspec not within worktree' unless pass || files.size == proj.size
|
1740
1736
|
files = proj
|
1741
1737
|
end
|
1742
|
-
files.map { |val| val == '.' ? '.' : shell_quote(
|
1738
|
+
files.map { |val| val == '.' ? '.' : shell_quote(basepath(val)) }
|
1743
1739
|
end
|
1744
1740
|
|
1745
1741
|
def matchmap(list, prefix = nil)
|
@@ -2006,14 +2002,12 @@ module Squared
|
|
2006
2002
|
|
2007
2003
|
def dependfile_set(list)
|
2008
2004
|
@dependindex = list.index { |file| basepath(file).exist? }.tap do |index|
|
2009
|
-
@dependfile =
|
2005
|
+
@dependfile = basepath(list[index || 0])
|
2010
2006
|
end
|
2011
2007
|
end
|
2012
2008
|
|
2013
|
-
def as_get(val)
|
2014
|
-
|
2015
|
-
|
2016
|
-
@global && (ret = @as && @as[from] && @as[from][val]) ? ret : val
|
2009
|
+
def as_get(val, from)
|
2010
|
+
(@global && @as[from][val]) || val
|
2017
2011
|
end
|
2018
2012
|
|
2019
2013
|
def task_build(keys)
|