squared 0.4.13 → 0.4.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bc10e49a42c1eda78b4ff20f734efffd74eda16bc8dae742d2a0f29c0f34851
4
- data.tar.gz: 64b5e88317ba5208cc7824f40b9a4ff810a63197bc0b27813906a2293bbe1388
3
+ metadata.gz: fafee0b2a60973f9363c71173b9de4ed4779090e2ef3c2331d3ecd9f3a2a9398
4
+ data.tar.gz: 8eb5bfef9ec19b7985866ffd1f0b55a849ff7d27a895b76d29a1cd85553e717a
5
5
  SHA512:
6
- metadata.gz: f34a4d13854343d0713e34bf964feda5206f1c9a60ec2781fca611e74f7257753e01a895e081663b0c2d154a4c4834c39fa478e4665c58982eea053b53fd9529
7
- data.tar.gz: ff549d38162731add0bbb6dd8bd7566f2200d6006f92c268aa0af4271e4f6a60a5a407b6a3a48fbeeee035c0ede41c135f760eb907582ede90020a1c61c7d890
6
+ metadata.gz: 464952bd65f6c404a89ef8624549e04a7a4ec0cc2c0b211e73d0464cf1bcd8094f760449ab7e0e944fd390cf01029f14ef2b6a082ae67d1ad071d243821ee527
7
+ data.tar.gz: d36b6c580ccabb5bde29585cdb4642c7a81dadfff59b5766fa76efece506983ed0335551fdd31a41eced8c6631967573a6ad4a19f22b912e61a93f6f10e334ec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.14] - 2025-07-05
4
+
5
+ ### Added
6
+
7
+ - Python command run for project scripts was implemented.
8
+ - Python command build and publish with PDM was implemented.
9
+ - Python command run detects program tool scripts.
10
+ - Git command stash action branch was implemented.
11
+ - Docker command compose action exec and run are interactive.
12
+ - Double dash can be used to end parsing for options.
13
+ - Python command outdated tasks with semver was implemented.
14
+
15
+ ### Changed
16
+
17
+ - Ruby command rake supports running multiple indexes.
18
+ - Ruby private method rakefile when nil returns empty string.
19
+ - Ruby private method gempwd and rakepwd ignores current directory.
20
+ - Ruby command gem action update parameters are optional.
21
+ - Gem command install and uninstall can parse name and version.
22
+ - Kernel method Array is used in place of common method as_a.
23
+ - Ruby public method irb parameter load was renamed args.
24
+
25
+ ### Fixed
26
+
27
+ - Box border did not print corners on Windows.
28
+ - Index character was not captured on Windows.
29
+ - Node command publish did not prompt for package to publish.
30
+ - Python command publish did not prompt for package to publish.
31
+ - Project confirmation accept dialog did not always quit.
32
+ - Git command add did not detect when no files were changed.
33
+
34
+ ## [0.3.12] - 2025-07-05
35
+
36
+ ### Fixed
37
+
38
+ - Gem command exec did not include gem option flag.
39
+ - Project graph did not print first level border.
40
+ - Node command update did not use correct event name.
41
+ - Gem command push did not validate gem file to publish.
42
+ - Node command publish did not publish when silent.
43
+
44
+ ## [0.2.12] - 2025-07-05
45
+
46
+ ### Fixed
47
+
48
+ - See `0.1.9`.
49
+
50
+ ## [0.1.9] - 2025-07-05
51
+
52
+ ### Added
53
+
54
+ - Initial support for using JRuby.
55
+ - Config viewer theme color for boolean was implemented.
56
+
57
+ ### Fixed
58
+
59
+ - Project output divider was not printed when not verbose.
60
+ - Directory context was not threaded using JRuby.
61
+ - Index character was not captured on Windows.
62
+ - Common method is used for Kernel shell commands.
63
+ - Git did not highlight output for single commands.
64
+
3
65
  ## [0.4.13] - 2025-06-16
4
66
 
5
67
  ### Added
@@ -53,6 +115,8 @@
53
115
 
54
116
  ## [0.3.11] - 2025-05-15
55
117
 
118
+ ### Fixed
119
+
56
120
  - See `0.2.11`.
57
121
 
58
122
  ## [0.2.11] - 2025-05-15
@@ -315,6 +379,8 @@
315
379
 
316
380
  ## [0.3.7] - 2025-04-08
317
381
 
382
+ ### Fixed
383
+
318
384
  - See `0.2.7`.
319
385
 
320
386
  ## [0.2.7] - 2025-04-08
@@ -736,6 +802,7 @@
736
802
 
737
803
  - Changelog was created.
738
804
 
805
+ [0.4.14]: https://github.com/anpham6/squared/releases/tag/v0.4.14-ruby
739
806
  [0.4.13]: https://github.com/anpham6/squared/releases/tag/v0.4.13-ruby
740
807
  [0.4.12]: https://github.com/anpham6/squared/releases/tag/v0.4.12-ruby
741
808
  [0.4.11]: https://github.com/anpham6/squared/releases/tag/v0.4.11-ruby
@@ -750,6 +817,7 @@
750
817
  [0.4.2]: https://github.com/anpham6/squared/releases/tag/v0.4.2-ruby
751
818
  [0.4.1]: https://github.com/anpham6/squared/releases/tag/v0.4.1-ruby
752
819
  [0.4.0]: https://github.com/anpham6/squared/releases/tag/v0.4.0-ruby
820
+ [0.3.12]: https://github.com/anpham6/squared/releases/tag/v0.3.12-ruby
753
821
  [0.3.11]: https://github.com/anpham6/squared/releases/tag/v0.3.11-ruby
754
822
  [0.3.10]: https://github.com/anpham6/squared/releases/tag/v0.3.10-ruby
755
823
  [0.3.9]: https://github.com/anpham6/squared/releases/tag/v0.3.9-ruby
@@ -762,6 +830,7 @@
762
830
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
763
831
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
764
832
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
833
+ [0.2.12]: https://github.com/anpham6/squared/releases/tag/v0.2.12-ruby
765
834
  [0.2.11]: https://github.com/anpham6/squared/releases/tag/v0.2.11-ruby
766
835
  [0.2.10]: https://github.com/anpham6/squared/releases/tag/v0.2.10-ruby
767
836
  [0.2.9]: https://github.com/anpham6/squared/releases/tag/v0.2.9-ruby
@@ -774,6 +843,7 @@
774
843
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
775
844
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
776
845
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
846
+ [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
777
847
  [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
778
848
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
779
849
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
data/README.ruby.md CHANGED
@@ -508,7 +508,7 @@ Most project classes will inherit from `Git` which enables these tasks:
508
508
  | restore | restore | staged worktree |
509
509
  | rev | rev | commit output |
510
510
  | show | show | format oneline |
511
- | stash | stash | push pop apply drop list |
511
+ | stash | stash | push pop apply branch drop clear list |
512
512
  | switch | switch | create detach merge |
513
513
  | tag | tag | add sign delete list |
514
514
 
@@ -63,6 +63,7 @@ module Squared
63
63
  hash: %i[green black!],
64
64
  array: %i[blue black!],
65
65
  number: [:magenta],
66
+ boolean: [:magenta],
66
67
  undefined: %i[red italic]
67
68
  },
68
69
  logger: {
@@ -103,13 +104,15 @@ module Squared
103
104
  return [] if obj.nil?
104
105
 
105
106
  unless obj.is_a?(::Array)
106
- obj = if obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
107
+ obj = if obj.respond_to?(:to_ary)
108
+ obj.to_ary
109
+ elsif obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
107
110
  val
108
111
  else
109
112
  [obj]
110
113
  end
111
114
  end
112
- obj = obj.flatten(flat.is_a?(::Numeric) ? flat : nil) if flat
115
+ obj = flat.is_a?(::Numeric) ? obj.flatten(flat) : obj.flatten if flat
113
116
  obj = obj.compact if compact
114
117
  obj = obj.map(&meth) if meth
115
118
  block_given? ? obj.select(&blk) : obj
@@ -29,7 +29,13 @@ module Squared
29
29
  bright_white!: '107'
30
30
  }.freeze
31
31
  BOX_GRAPH = ['│', '─', '├', '└', '┬'].freeze
32
- BOX_BORDER = ['│', '─', '', '', '', '', '├', '┤', '┬', '┴'].freeze
32
+ BOX_BORDER = ['│', '─', '', '', '', '', '├', '┤', '┬', '┴'].tap do |val|
33
+ if ENV['TERM']&.end_with?('256color')
34
+ val.slice!(2, 4)
35
+ val.insert(2, '╭', '╮', '╯', '╰')
36
+ end
37
+ val.freeze
38
+ end
33
39
  TEXT_STYLE = [:bold, :dim, :italic, :underline, :blinking, nil, :inverse, :hidden, :strikethrough].freeze
34
40
  private_constant :AIX_TERM, :BOX_GRAPH, :BOX_BORDER, :TEXT_STYLE
35
41
 
@@ -61,7 +67,7 @@ module Squared
61
67
  end
62
68
  wrap = ->(s, n) { "\x1B[#{n.join(';')}m#{s}\x1B[0m" }
63
69
  code = []
64
- args.concat(as_a(styles)).flatten.each_with_index do |type, i|
70
+ args.concat(Array(styles)).flatten.each_with_index do |type, i|
65
71
  next unless type
66
72
 
67
73
  if index == -1
@@ -37,7 +37,7 @@ module Squared
37
37
  require 'readline'
38
38
  require 'timeout'
39
39
  if list
40
- grep &&= (grep.is_a?(::Enumerable) ? grep : [grep]).map { |val| Regexp.new(val) }
40
+ grep &&= Array(grep).map { |val| Regexp.new(val) }
41
41
  items = []
42
42
  list.each do |val|
43
43
  next if grep&.none? { |pat| pat.match?(line) }
@@ -1,23 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pathname'
4
- require 'fileutils'
4
+ require 'rake'
5
5
 
6
6
  module Squared
7
7
  module Common
8
8
  module System
9
9
  module_function
10
10
 
11
- def shell(*args, **kwargs)
12
- if RUBY_VERSION < '2.6'
13
- exception = kwargs.delete(:exception)
14
- ret = Kernel.system(*args, **kwargs)
15
- return ret if ret || !exception
16
-
17
- raise $?.to_s
11
+ def shell(*args, name: :system, **kwargs)
12
+ if RUBY_ENGINE == 'jruby' && Rake::Win32.windows?
13
+ e = kwargs[:exception]
14
+ if (dir = kwargs[:chdir]) && ((pwd = Dir.pwd) != dir)
15
+ Dir.chdir(dir)
16
+ ret = Kernel.send(name, *args)
17
+ Dir.chdir(pwd)
18
+ else
19
+ ret = Kernel.send(name, *args)
20
+ end
21
+ elsif RUBY_VERSION < '2.6'
22
+ e = kwargs.delete(:exception)
23
+ ret = Kernel.send(name, *args, **kwargs)
18
24
  else
19
- Kernel.system(*args, **kwargs)
25
+ return Kernel.send(name, *args, **kwargs)
20
26
  end
27
+ return ret if ret || !e
28
+
29
+ raise $?.to_s
21
30
  end
22
31
 
23
32
  def copy_dir(src, dest, glob = ['**/*'], create: false, link: nil, force: false, pass: nil, verbose: true)
@@ -29,10 +38,9 @@ module Squared
29
38
  dest.mkpath if create
30
39
  if pass
31
40
  exclude = []
32
- pass = [pass] unless pass.is_a?(::Enumerable)
33
- pass.each { |val| exclude.concat(Dir.glob(src + val)) }
41
+ Array(pass).each { |val| exclude.concat(Dir.glob(src + val)) }
34
42
  end
35
- (glob.is_a?(::Enumerable) ? glob : [glob]).each do |val|
43
+ Array(glob).each do |val|
36
44
  Dir.glob(src + val) do |path|
37
45
  next if exclude&.include?(path) || (path = Pathname.new(path)).directory?
38
46
 
@@ -79,8 +87,7 @@ module Squared
79
87
  def copy_guard(src, dest, link: nil, force: false, verbose: true)
80
88
  unless force
81
89
  if (path = Pathname.new(dest)).directory?
82
- src = [src] unless src.is_a?(::Enumerable)
83
- src = src.reject { |val| path.join(File.basename(val)).exist? }
90
+ src = Array(src).reject { |val| path.join(File.basename(val)).exist? }
84
91
  return if src.empty?
85
92
  elsif path.exist?
86
93
  return
@@ -17,13 +17,13 @@ module Squared
17
17
  val = val.strip
18
18
  return [val, '', ''] unless (i = val.index('='))
19
19
 
20
- last = val[i + 1..-1].strip
20
+ last = val[(i + 1)..-1].strip
21
21
  quote = ''
22
22
  if last =~ /\A(["'])(.+)\1\z/
23
23
  last = $2
24
24
  quote = $1
25
25
  end
26
- [val[0..i - 1], last, quote]
26
+ [val[0..(i - 1)], last, quote]
27
27
  end
28
28
 
29
29
  def task_invoke(*cmd, args: [], exception: true, warning: true)
@@ -109,7 +109,11 @@ module Squared
109
109
  ret = env_value(key, suffix: suffix, strict: strict)
110
110
  return ret == equals.to_s unless equals.nil?
111
111
 
112
- ret.empty? || (ignore && as_a(ignore).any? { |val| val.to_s == ret }) ? default : ret
112
+ ret.empty? || (ignore && Array(ignore).any? { |val| val.to_s == ret }) ? default : ret
113
+ end
114
+
115
+ def env_key(*val)
116
+ val.join('_').gsub(/\W+/, '_').upcase
113
117
  end
114
118
 
115
119
  def env_value(key, default = '', suffix: nil, strict: false)
@@ -15,8 +15,7 @@ module Squared
15
15
  def parse(gem, namespace, ext = [pkg])
16
16
  require gem
17
17
  obj = eval namespace
18
- ext = [ext] unless ext.is_a?(Array)
19
- ext.each { |val| @@mime_obj[val] = [obj, ext] }
18
+ Array(ext).each { |val| @@mime_obj[val] = [obj, ext] }
20
19
  rescue LoadError, NameError => e
21
20
  warn e
22
21
  nil
@@ -89,7 +88,7 @@ module Squared
89
88
  @required = true
90
89
  project ? [project, 'not found'] : ['name', 'missing']
91
90
  end
92
- warn log_message(Logger::WARN, msg, subject: self.class, hint: hint, pass: true)
91
+ warn log_message(Logger::WARN, msg, subject: self.class, hint: hint)
93
92
  end
94
93
 
95
94
  def build
@@ -129,7 +128,7 @@ module Squared
129
128
  require(gem || type)
130
129
  obj = eval namespace
131
130
  else
132
- as_a(ext).each do |val|
131
+ Array(ext).each do |val|
133
132
  next unless (data = @@mime_obj[val])
134
133
 
135
134
  obj = data.first
@@ -137,7 +136,7 @@ module Squared
137
136
  end
138
137
  end
139
138
  if obj
140
- ext << type if (ext = as_a(ext)).empty?
139
+ ext << type if (ext = Array(ext)).empty?
141
140
  if !file && target?
142
141
  ext.each do |val|
143
142
  next unless (out = basepath("#{main}.#{val}")).exist?
@@ -249,6 +248,8 @@ module Squared
249
248
  { pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
250
249
  { pat: /\A(.+ : \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
251
250
  { pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
251
+ { pat: /\A(.+ : )(true|false)(\s*)\z/m, styles: theme[:boolean],
252
+ index: 2 },
252
253
  { pat: /\A(.+ : (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
253
254
  index: 2 }
254
255
  ]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.13'
4
+ VERSION = '0.4.14'
5
5
  end
@@ -94,7 +94,7 @@ module Squared
94
94
  @project = {}
95
95
  @kind = {}
96
96
  @extensions = []
97
- @envname = @main.gsub(/[^\w]+/, '_').upcase.freeze
97
+ @envname = env_key(@main).freeze
98
98
  @pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
99
99
  @exception = env_bool exception
100
100
  @verbose = env_bool(verbose, verbose.nil? || verbose.is_a?(String) ? @pipe != 0 : verbose, index: true)
@@ -224,7 +224,7 @@ module Squared
224
224
  end
225
225
  end
226
226
  end
227
- data = Support::ChainData.new(action, step, ns.call(with), ns.call(before), ns.call(after), sync)
227
+ data = Struct::ChainData.new(action, step, ns.call(with), ns.call(before), ns.call(after), sync)
228
228
  (@chain[task_name(task.to_s)] ||= []) << data
229
229
  self
230
230
  end
@@ -306,10 +306,10 @@ module Squared
306
306
  data = {} if !command && data[:order].empty?
307
307
  if group
308
308
  label = :group
309
- items = as_a group
309
+ items = Array(group)
310
310
  else
311
311
  label = :ref
312
- items = ref ? as_a(ref) : [:_]
312
+ items = Array(ref || :_)
313
313
  end
314
314
  items.each { |val| @banner[label][val.to_sym] = data }
315
315
  self
@@ -367,7 +367,7 @@ module Squared
367
367
  end
368
368
 
369
369
  def compose(name, &blk)
370
- namespace(task_name(name), &blk) if block_given?
370
+ namespace(task_name(name), &blk)
371
371
  self
372
372
  end
373
373
 
@@ -379,7 +379,7 @@ module Squared
379
379
  def style(obj, *args, target: nil, empty: false)
380
380
  data = nil
381
381
  if target
382
- as_a(target).each_with_index do |key, i|
382
+ Array(target).each_with_index do |key, i|
383
383
  if i == 0
384
384
  break unless (data = __get__(:theme)[key.to_sym])
385
385
  else
@@ -485,7 +485,7 @@ module Squared
485
485
  end
486
486
 
487
487
  def task_namespace(val, first: false)
488
- return nil unless (ret = val.to_s.split(':')).size > 1
488
+ return unless (ret = val.to_s.split(':')).size > 1
489
489
 
490
490
  first ? ret.first : task_join(*ret[0..-2])
491
491
  end
@@ -630,6 +630,14 @@ module Squared
630
630
  Rake::Win32.windows?
631
631
  end
632
632
 
633
+ def jruby?
634
+ RUBY_ENGINE == 'jruby'
635
+ end
636
+
637
+ def jruby_win?
638
+ jruby? && windows?
639
+ end
640
+
633
641
  def docker?
634
642
  !Dir['/.dockerenv', '/docker-*.{sh,d}'].empty?
635
643
  end
@@ -784,7 +792,7 @@ module Squared
784
792
  task key do
785
793
  unless failed.empty? && group.empty?
786
794
  puts log_message(Logger::ERROR, *(failed + group.map { |val| val.action }.flatten),
787
- subject: 'failed placement', hint: false, pass: true)
795
+ subject: 'failed placement', hint: false)
788
796
  end
789
797
  cols = level.flatten(1).map(&:size).max
790
798
  level.each_with_index do |grp, n|
@@ -806,7 +814,7 @@ module Squared
806
814
 
807
815
  def script_command(task, val, group, ref, on, &blk)
808
816
  if block_given?
809
- val = Support::RunData.new(val, blk)
817
+ val = Struct::RunData.new(val, blk)
810
818
  elsif !val
811
819
  return self
812
820
  end
@@ -827,9 +835,9 @@ module Squared
827
835
  def script_set(data, group: nil, ref: nil)
828
836
  data.freeze
829
837
  if group
830
- as_a(group).each { |val| @script[:group!][val.to_sym] = data }
838
+ Array(group).each { |val| @script[:group!][val.to_sym] = data }
831
839
  elsif ref
832
- as_a(ref).each { |val| @script[:ref!][val.to_sym] = data }
840
+ Array(ref).each { |val| @script[:ref!][val.to_sym] = data }
833
841
  else
834
842
  @script[:ref!][:''] = data
835
843
  end
@@ -869,7 +877,7 @@ module Squared
869
877
  end
870
878
  return false if state == :prod && data[:dev] == true && data[:global]
871
879
 
872
- target && pat.is_a?(Regexp) ? as_a(target).any? { |val| val.match?(pat) } : pat == true
880
+ target && pat.is_a?(Regexp) ? Array(target).any? { |val| val.match?(pat) } : pat == true
873
881
  end
874
882
 
875
883
  def scriptobj