squared 0.5.1 → 0.5.3

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: 3aeb7a32f99a22618e2c6c497d6de2f911df5d126232c63ed986324fc5b31aa7
4
- data.tar.gz: fb144ac3238fcaf22f1c8bf4218847f547db9d03904a45ef8f040501df1ecc9b
3
+ metadata.gz: 54118de98db0adf55417ad35cbc3c118bba709c8bbb98b9d74acccaf7a30621e
4
+ data.tar.gz: 13f6ac344ecdc68f724c10a967f0eba1de6cd0332157abe0c9079db9dba1b9d0
5
5
  SHA512:
6
- metadata.gz: 6c026101681bf8869138b6882044b60dd3b515d2f61feee9529c4ed70f048c1ceca39538ebe4ac3985c974aeff36b22506d4f5429f9b6eb7ac7d5400a14e737b
7
- data.tar.gz: c53bc01a5dbdb5653d67eab02b3bd93229b8cda4fef6d97da16826d70069ab03c085086c49a045281e2da732957a1e920595abd52374bbf76c898f7e63dfe39b
6
+ metadata.gz: cfbfbd1b2a5fcd376fceafe53fa77789726704d6cdf7f3d919c6381e04f89e2fc3888adfb38e819bbeba7bb51cd7f7f0c08e4fe797d16ee688752dddb9ad6b68
7
+ data.tar.gz: 4ffd9c7e92c7d357c6e877fa78ca850b202585721001a2c58dbc5851eac292abad59ab67f12fc8eab5ef7706bf3cd1d8db7aaf4ee9b169f0cebf38dfe1016b99
data/CHANGELOG.md CHANGED
@@ -1,5 +1,76 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.3] - 2025-07-27
4
+
5
+ ### Fixed
6
+
7
+ - See `0.4.16`.
8
+
9
+ ## [0.4.16] - 2025-07-27
10
+
11
+ ### Added
12
+
13
+ - Git command blame was implemented.
14
+ - Project property only for task filtering was implemented.
15
+ - Node command copy uses NPM pack to refresh development packages.
16
+ - Docker command bake action check was implemented.
17
+ - Ruby uses gem specification for name and version.
18
+ - Ruby constructor parameter gemspec was implemented.
19
+
20
+ ### Changed
21
+
22
+ - Project boolean property readers were converted into accessors.
23
+ - Workspace hash singleton methods were relocated under Support.
24
+ - Project property version uses setter method for validation.
25
+ - Node command publish will prompt when tag is not semantic.
26
+ - Gem command push without args uses gemspec to locate archive.
27
+ - Prompts will exit process without raising a generic error.
28
+
29
+ ### Fixed
30
+
31
+ - Gem command exec did not separate command and arguments.
32
+ - Project warning messages were not displayed for errors.
33
+ - Python command outdated did not load virtual env in Windows.
34
+ - Python virtual env original options are not modified.
35
+ - Node could not compare semantic versions above double digits.
36
+
37
+ ## [0.5.2] - 2025-07-16
38
+
39
+ ### Changed
40
+
41
+ - Common method choice can accept dashed ranges for selection lists.
42
+
43
+ ## [0.4.15] - 2025-07-16
44
+
45
+ ### Added
46
+
47
+ - Python command outdated option user was implemented.
48
+ - Git command commit action amend and amend-orig are interactive.
49
+
50
+ ### Changed
51
+
52
+ - Ruby task copy does not guess Gem directory when version is used.
53
+ - Workspace hash-based data uses global method for key creation.
54
+
55
+ ## [0.3.13] - 2025-07-16
56
+
57
+ ### Fixed
58
+
59
+ - See `0.2.13`.
60
+
61
+ ## [0.2.13] - 2025-07-16
62
+
63
+ ### Fixed
64
+
65
+ - Project graph did not ignore circular references.
66
+
67
+ ## [0.1.10] - 2025-07-16
68
+
69
+ ### Fixed
70
+
71
+ - Module namespaces were not combined in the right order.
72
+ - Workspace group tasks were not registered.
73
+
3
74
  ## [0.5.1] - 2025-07-05
4
75
 
5
76
  ### Changed
@@ -837,8 +908,12 @@
837
908
 
838
909
  - Changelog was created.
839
910
 
911
+ [0.5.3]: https://github.com/anpham6/squared/releases/tag/v0.5.3-ruby
912
+ [0.5.2]: https://github.com/anpham6/squared/releases/tag/v0.5.2-ruby
840
913
  [0.5.1]: https://github.com/anpham6/squared/releases/tag/v0.5.1-ruby
841
914
  [0.5.0]: https://github.com/anpham6/squared/releases/tag/v0.5.0-ruby
915
+ [0.4.16]: https://github.com/anpham6/squared/releases/tag/v0.4.16-ruby
916
+ [0.4.15]: https://github.com/anpham6/squared/releases/tag/v0.4.15-ruby
842
917
  [0.4.14]: https://github.com/anpham6/squared/releases/tag/v0.4.14-ruby
843
918
  [0.4.13]: https://github.com/anpham6/squared/releases/tag/v0.4.13-ruby
844
919
  [0.4.12]: https://github.com/anpham6/squared/releases/tag/v0.4.12-ruby
@@ -854,6 +929,7 @@
854
929
  [0.4.2]: https://github.com/anpham6/squared/releases/tag/v0.4.2-ruby
855
930
  [0.4.1]: https://github.com/anpham6/squared/releases/tag/v0.4.1-ruby
856
931
  [0.4.0]: https://github.com/anpham6/squared/releases/tag/v0.4.0-ruby
932
+ [0.3.13]: https://github.com/anpham6/squared/releases/tag/v0.3.13-ruby
857
933
  [0.3.12]: https://github.com/anpham6/squared/releases/tag/v0.3.12-ruby
858
934
  [0.3.11]: https://github.com/anpham6/squared/releases/tag/v0.3.11-ruby
859
935
  [0.3.10]: https://github.com/anpham6/squared/releases/tag/v0.3.10-ruby
@@ -867,6 +943,7 @@
867
943
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
868
944
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
869
945
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
946
+ [0.2.13]: https://github.com/anpham6/squared/releases/tag/v0.2.13-ruby
870
947
  [0.2.12]: https://github.com/anpham6/squared/releases/tag/v0.2.12-ruby
871
948
  [0.2.11]: https://github.com/anpham6/squared/releases/tag/v0.2.11-ruby
872
949
  [0.2.10]: https://github.com/anpham6/squared/releases/tag/v0.2.10-ruby
@@ -880,6 +957,7 @@
880
957
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
881
958
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
882
959
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
960
+ [0.1.10]: https://github.com/anpham6/squared/releases/tag/v0.1.10-ruby
883
961
  [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
884
962
  [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
885
963
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
data/README.ruby.md CHANGED
@@ -66,6 +66,7 @@ require "squared/app" # All workspace related mod
66
66
  # log = /workspaces/logger
67
67
  # emc = /workspaces/e-mc
68
68
  # pir = /workspaces/pi-r
69
+ # pir2 = /workspaces/pi-r2
69
70
  # squared = /workspaces/squared
70
71
  # cli = /workspaces/squared/publish/sqd-cli
71
72
  # sqd-serve = /workspaces/squared/publish/sqd-serve
@@ -83,10 +84,11 @@ Workspace::Application
83
84
  .add("pathname", run: "rake compile", copy: "rake install", test: "rake test", group: "default", env: { # Ruby (with C extensions)
84
85
  "CFLAGS" => "-fPIC -O1"
85
86
  })
86
- .add("optparse", doc: "rake rdoc", group: "default") # Uses bundler/gem_tasks (without C extensions)
87
+ .add("optparse", doc: "rake rdoc", gemspec: "optparse.gemspec", group: "default") # Uses bundler/gem_tasks (without C extensions)
87
88
  .add("logger", copy: { from: "lib", glob: "**/*.rb", into: "~/.rvm/gems/ruby-3.4.0/gems/logger-1.6.1" }, clean: ["tmp/"]) # autodetect: true | "rvm" | "rbenv" | "asdf" | "bundler"
88
89
  .add("e-mc", "emc", copy: { from: "publish", scope: "@e-mc", also: [:pir, "squared-express/"] }, ref: :node) # Node
89
90
  .add("pi-r", "pir", copy: { from: "publish", scope: "@pi-r" }, clean: ["publish/**/*.js", "tmp/"]) # Trailing slash required for directories
91
+ .add("pi-r2", "pir2", copy: { from: :npm, also: %i[squared express], files: ["LICENSE", ["README.md.ruby", "README.md"]] }) # Uses dist files from NPM package spec
90
92
  .add("squared", script: ["build:stage1", "build:stage2"], group: "app") do # Copy target (main)
91
93
  # Repo (global)
92
94
  as(:run, "build:dev", "dev") # npm run build:dev -> npm run dev
@@ -108,7 +110,7 @@ Workspace::Application
108
110
  variable_set :depend, false
109
111
  variable_set :clean, ["build/sqd/"]
110
112
  end
111
- .with(:docker, pass: ["unpack"]) do
113
+ .with(:docker, only: ["build", "compose"]) do
112
114
  .add("squared", "docker", file: "Dockerfile", context: ".", tag: "latest", registry: "localhost:5000", username: "squared",
113
115
  args: "--ssh=default",
114
116
  secrets: ["id=github,env=GITHUB_TOKEN"],
@@ -124,7 +124,7 @@ module Squared
124
124
  def check_style(args, empty: true)
125
125
  ret = []
126
126
  colors = __get__(:colors)
127
- as_a(args, flat: true, compact: true).each do |val|
127
+ Array(args).flatten.compact.each do |val|
128
128
  if !val.is_a?(::Numeric)
129
129
  val = val.to_sym
130
130
  ret << val if colors.key?(val) || TEXT_STYLE.include?(val)
@@ -135,7 +135,9 @@ module Squared
135
135
  ret << "-0.#{b}".to_f unless b.to_i > 255
136
136
  end
137
137
  end
138
- ret if empty || !ret.empty?
138
+ return if ret.empty? && !empty
139
+
140
+ ret
139
141
  end
140
142
 
141
143
  def apply_style(data, key, args, empty: true)
@@ -222,7 +224,7 @@ module Squared
222
224
  n = 0
223
225
  max = ->(v) { n = [n, v.max_by(&:size).size].max }
224
226
  set = lambda do |v|
225
- ret = as_a(v, :to_s)
227
+ ret = Array(v).map(&:to_s)
226
228
  max.call(ret)
227
229
  ret
228
230
  end
@@ -246,7 +248,7 @@ module Squared
246
248
  ret = sub_style(ret, styles: border) if border
247
249
  ret
248
250
  end
249
- sub = as_a sub
251
+ sub = sub.is_a?(::Hash) ? [sub] : Array(sub)
250
252
  pr = lambda do |line|
251
253
  s = line.ljust(n)
252
254
  sub.each { |h| s = sub_style(s, **h) }
@@ -60,27 +60,39 @@ module Squared
60
60
  end}] "
61
61
  end
62
62
  end
63
- valid = ->(s) { s.match?(/^-?\d+$/) && s.to_i.between?(min, max) }
63
+ valid = ->(s) { s.match?(/^\d+$/) && s.to_i.between?(min, max) }
64
64
  Timeout.timeout(timeout) do
65
65
  while (ch = Readline.readline(msg))
66
66
  unless (ch = ch.strip).empty?
67
67
  if multiple
68
68
  a = ch.split(/\s*,\s*/)
69
- b = a.select { |s| valid.call(s) }.map!(&:to_i).sort
70
- next unless a.size == b.size
71
- return b unless items
72
- next if multiple.is_a?(::Numeric) && multiple != b.size
69
+ b = a.map do |s|
70
+ if s =~ /^(\d+)-(\d+)$/
71
+ next unless valid.call($1) && valid.call($2)
73
72
 
74
- return b.map! { |i| items[i - 1] }
73
+ c = $1.to_i
74
+ d = $2.to_i
75
+ next (c..d).to_a if c < d
76
+ elsif valid.call(s)
77
+ s.to_i
78
+ end
79
+ end
80
+ unless b.include?(nil)
81
+ b.flatten!
82
+ b.uniq!
83
+ b.sort!
84
+ return b unless items
85
+ return b.map! { |i| items[i - 1] } unless multiple.is_a?(::Numeric) && multiple != b.size
86
+ end
75
87
  elsif valid.call(ch)
76
88
  return items ? items[ch.to_i - 1] : ch.to_i
77
89
  end
78
90
  end
79
91
  attempts -= 1
80
92
  next if attempts > 0
81
- break unless force
82
93
 
83
- exit 1
94
+ exit 1 if force
95
+ break
84
96
  end
85
97
  rescue Interrupt
86
98
  puts
@@ -113,7 +125,7 @@ module Squared
113
125
  end
114
126
  ret = (prompt.call || '').strip
115
127
  multiline.each { |val| break if ret.delete_suffix!(val) } if multiline.is_a?(::Enumerable)
116
- raise_error 'user cancelled' if force && ret.empty?
128
+ exit 1 if force && ret.empty?
117
129
  ret
118
130
  else
119
131
  prompt.call
@@ -86,8 +86,7 @@ module Squared
86
86
  end
87
87
 
88
88
  def shell_split(val, join: nil, **kwargs)
89
- ret = val.shellsplit
90
- ret.map! { |opt| shell_escape(opt, double: true, option: true, **kwargs) }
89
+ ret = val.shellsplit.map! { |opt| shell_escape(opt, double: true, option: true, **kwargs) }
91
90
  return ret unless join
92
91
 
93
92
  ret.join(join.is_a?(::String) ? join : ' ')
@@ -93,6 +93,15 @@ module Squared
93
93
  Time.now.utc.strftime(s).to_i - Time.parse(val).utc.strftime(s).to_i
94
94
  end
95
95
 
96
+ def rand_s(size)
97
+ if RUBY_VERSION >= '3.1'
98
+ require 'random/formatter'
99
+ Random.new.alphanumeric(size)
100
+ else
101
+ (0...size).map { rand(97..122).chr }.join
102
+ end
103
+ end
104
+
96
105
  def env(key, default = nil, suffix: nil, strict: false, equals: nil, ignore: nil)
97
106
  ret = env_value(key, suffix: suffix, strict: strict)
98
107
  return ret == equals.to_s unless equals.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.1'
4
+ VERSION = '0.5.3'
5
5
  end
@@ -92,7 +92,7 @@ module Squared
92
92
  @prefix = prefix
93
93
  @series = Application.series_wrap(self)
94
94
  @project = {}
95
- @kind = {}
95
+ @kind = Support.hashlist
96
96
  @extensions = []
97
97
  @envname = env_key(@main).freeze
98
98
  @pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
@@ -106,20 +106,20 @@ module Squared
106
106
  else
107
107
  @theme = {}
108
108
  end
109
- @chain = {}
109
+ @chain = Support.hashlist
110
110
  @script = {
111
- group: {},
112
- ref: {},
111
+ group: Support.hashobj,
112
+ ref: Support.hashobj,
113
113
  group!: {},
114
114
  ref!: {}
115
115
  }.freeze
116
116
  @events = {
117
- group: {},
118
- ref: {}
117
+ group: Support.hashobj,
118
+ ref: Support.hashobj
119
119
  }.freeze
120
120
  @pass = {
121
- group: {},
122
- ref: {},
121
+ group: Support.hashobj,
122
+ ref: Support.hashobj,
123
123
  global: {},
124
124
  pattern: []
125
125
  }.freeze
@@ -225,7 +225,7 @@ module Squared
225
225
  end
226
226
  end
227
227
  data = Struct::ChainData.new(action, step, ns.call(with), ns.call(before), ns.call(after), sync)
228
- (@chain[task_name(task.to_s)] ||= []) << data
228
+ @chain[task_name(task.to_s)] << data
229
229
  self
230
230
  end
231
231
 
@@ -267,9 +267,9 @@ module Squared
267
267
 
268
268
  def pass(name, group: @group, ref: @ref, &blk)
269
269
  data = if group
270
- @pass[:group][group] ||= {}
270
+ @pass[:group][group]
271
271
  elsif ref
272
- @pass[:ref][ref] ||= {}
272
+ @pass[:ref][ref]
273
273
  else
274
274
  @pass[:global]
275
275
  end
@@ -625,12 +625,16 @@ module Squared
625
625
  Rake::Win32.windows?
626
626
  end
627
627
 
628
+ def mri?
629
+ RUBY_ENGINE == 'ruby'
630
+ end
631
+
628
632
  def jruby?
629
633
  RUBY_ENGINE == 'jruby'
630
634
  end
631
635
 
632
- def jruby_win?
633
- jruby? && windows?
636
+ def truffleruby?
637
+ RUBY_ENGINE == 'truffleruby'
634
638
  end
635
639
 
636
640
  def docker?
@@ -821,8 +825,8 @@ module Squared
821
825
  items = as_a(ref, :to_sym)
822
826
  end
823
827
  items.each do |name|
824
- (@script[label][name] ||= {})[task] = val
825
- (@events[label][name] ||= {})[task] = on if on.is_a?(Hash)
828
+ @script[label][name][task] = val
829
+ @events[label][name][task] = on if on.is_a?(Hash)
826
830
  end
827
831
  self
828
832
  end
@@ -839,15 +843,17 @@ module Squared
839
843
  end
840
844
 
841
845
  def data_get(*args, group: nil, ref: nil, target: nil)
842
- target[:group][group.to_sym] if group
843
- if ref.is_a?(Enumerable)
846
+ if group && target[:group].key?(key = group.to_sym)
847
+ target[:group][key]
848
+ elsif ref.is_a?(Enumerable)
844
849
  ref.each do |key|
845
- next unless (ret = target[:ref][key])
850
+ next unless target[:ref].key?(key)
846
851
 
852
+ ret = target[:ref][key]
847
853
  return ret if args.empty? || args.any? { |val| ret.key?(val) }
848
854
  end
849
855
  nil
850
- elsif ref
856
+ elsif ref && target[:ref].key?(ref)
851
857
  target[:ref][ref]
852
858
  end
853
859
  end