squared 0.3.1 → 0.3.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: 73841385e6cf27c4865e2e1ff419fb6b2c7a4364fb2dbc45ea6be3e160fa4a8a
4
- data.tar.gz: 49182d71ec996c4e0404e91ceb286ff0c51ef27c128ce4797951f613bedcd97d
3
+ metadata.gz: a43b1a5fec18ebf3523f1c1c2ddfb231cd9ad45bf355b0859430c7a6ca530be3
4
+ data.tar.gz: cc18478c20b2c20265db59b5e73ee5587139cc27925fd438a5897e5440736b82
5
5
  SHA512:
6
- metadata.gz: 0ff95d1a348a9755d2cc80a7797be77cb693e5381923a83e29c2952d240b8ecae9f047c4cd18257ab6a4d7c5b3716a03574a4ddbad81263d4fb1a5231a9a6ab1
7
- data.tar.gz: 00fea0a58cebde46cae1b67c1a58b6f7e8cd5f685e28220910d5a3c768be76a931cae175806e050b5fa3ef48b40cf8945ae69ef2d2896dec512727a52793a68f
6
+ metadata.gz: 13dfb9fbeb271d9b8dceb8f7558e777bb9bee68fb2f898725340791c484fb4b37c3f5666c9b48f01d7518e722ad24660309f24f5e26980527e20fbe7a0d6beb2
7
+ data.tar.gz: c89f3475e9cbd5d794b3920e7e8cd628708c07247a720ed7ba83df505f350e4d568ec6fdc412df4257ae33c67b5132a1699ed2e83c132068d399cd1471a23b88
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.3] - 2024-03-02
4
+
5
+ ### Fixed
6
+
7
+ - Project exceptions were hard coded preventing override.
8
+ - Project clean events were called twice.
9
+ - Git events were fired for internal background tasks.
10
+ - Git list display did not support single grep pattern.
11
+ - Gem outdated did not pass -C option for PWD.
12
+
13
+ ## [0.3.2] - 2024-02-25
14
+
15
+ ### Fixed
16
+
17
+ - Task program command options used unrecognized symbol.
18
+
19
+ ## [0.2.5] - 2024-02-25
20
+
21
+ ### Fixed
22
+
23
+ - See `0.1.5`.
24
+
25
+ ## [0.1.5] - 2024-02-25
26
+
27
+ ### Fixed
28
+
29
+ - Node copy method ignored include argument when called directly.
30
+ - Logger is not initialized when using only Git base class.
31
+ - Hide warnings about readline during execution.
32
+ - Logger is not initialized when using only base class.
33
+ - Merging ENV build options were double escaped.
34
+
3
35
  ## [0.3.1] - 2025-02-12
4
36
 
5
37
  ### Fixed
@@ -73,7 +105,7 @@
73
105
 
74
106
  ### Fixed
75
107
 
76
- - Project hash options duplicated dash prefix.
108
+ - Project hash options duplicated dash prefix.
77
109
 
78
110
  ## [0.1.4] - 2024-02-05
79
111
 
@@ -251,13 +283,17 @@
251
283
 
252
284
  - Changelog was created.
253
285
 
286
+ [0.3.3]: https://github.com/anpham6/squared/releases/tag/v0.3.3-ruby
287
+ [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
254
288
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
255
289
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
290
+ [0.2.5]: https://github.com/anpham6/squared/releases/tag/v0.2.5-ruby
256
291
  [0.2.4]: https://github.com/anpham6/squared/releases/tag/v0.2.4-ruby
257
292
  [0.2.3]: https://github.com/anpham6/squared/releases/tag/v0.2.3-ruby
258
293
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
259
294
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
260
295
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
296
+ [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
261
297
  [0.1.4]: https://github.com/anpham6/squared/releases/tag/v0.1.4-ruby
262
298
  [0.1.3]: https://github.com/anpham6/squared/releases/tag/v0.1.3-ruby
263
299
  [0.1.2]: https://github.com/anpham6/squared/releases/tag/v0.1.2-ruby
@@ -10,7 +10,7 @@ module Squared
10
10
 
11
11
  def shell_escape(val, quote: false, force: false)
12
12
  if (data = /\A(--?[^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
- return val unless data[2]
13
+ return val if !data[2] || (!data[4] && data[5] =~ /\s/)
14
14
 
15
15
  join = ->(opt) { data[1] + data[3] + shell_quote(opt) }
16
16
  if data[4] == data[6]
@@ -32,8 +32,9 @@ module Squared
32
32
  Rake::Win32.windows? || ARG[:QUOTE] == '"' ? "\"#{double_quote(val)}\"" : "'#{single_quote(val)}'"
33
33
  end
34
34
 
35
- def shell_split(val, quote: false, join: nil)
36
- val = Shellwords.split(val).map { |opt| shell_escape(opt, quote: quote) }
35
+ def shell_split(val, escape: true, quote: false, join: nil)
36
+ val = Shellwords.split(val)
37
+ val = val.map { |opt| shell_escape(opt, quote: quote) } if escape
37
38
  return val unless join
38
39
 
39
40
  val.join(join.is_a?(::String) ? join : ' ')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.3'
5
5
  end
@@ -59,7 +59,7 @@ module Squared
59
59
  attr_reader :name, :project, :workspace, :path, :theme, :exception, :pipe, :verbose,
60
60
  :group, :parent, :dependfile
61
61
 
62
- def initialize(workspace, path, name, *, group: nil, graph: nil, pass: nil, exclude: nil,
62
+ def initialize(workspace, path, name, *, group: nil, graph: nil, pass: nil, exclude: nil, verbose: nil,
63
63
  first: {}, last: {}, error: {}, common: ARG[:COMMON], **kwargs)
64
64
  @path = path
65
65
  @workspace = workspace
@@ -74,14 +74,16 @@ module Squared
74
74
  @clean = kwargs[:clean]
75
75
  @version = kwargs[:version]
76
76
  @envname = @name.gsub(/[^\w]+/, '_').upcase.freeze
77
- kwargs[:exception] = 'PIPE_FAIL'
78
- @exception = if kwargs.key?(:exception)
79
- env_bool(kwargs[:exception], workspace.exception, strict: true)
80
- else
81
- workspace.exception
82
- end
83
- @pipe = kwargs.key?(:pipe) ? env_pipe(kwargs[:pipe], workspace.pipe, strict: true) : workspace.pipe
84
- @verbose = kwargs.key?(:verbose) ? kwargs[:verbose] : workspace.verbose
77
+ @exception = env_bool(kwargs[:exception], workspace.exception, strict: true)
78
+ @pipe = env_pipe(kwargs[:pipe], workspace.pipe, strict: true)
79
+ @verbose = case verbose
80
+ when nil
81
+ workspace.verbose
82
+ when String
83
+ env_pipe(verbose, workspace.verbose, strict: true, index: true)
84
+ else
85
+ verbose
86
+ end
85
87
  @theme = if !@verbose
86
88
  {}
87
89
  elsif common
@@ -210,14 +212,14 @@ module Squared
210
212
  data = JSON.parse(val)
211
213
  raise_error('invalid JSON object', val, hint: "BUILD_#{@envname}_ENV") unless data.is_a?(Hash)
212
214
  rescue StandardError => e
213
- log.warn e
215
+ log&.warn e
214
216
  else
215
217
  @output[2] = data
216
218
  end
217
219
  end
218
220
  if cmd != false && !cmd.is_a?(Array)
219
- @output[cmd ? 1 : 3] = shell_split(val, join: true) if (val = env('BUILD', suffix: 'OPTS'))
220
- @output[4] = shell_split(val, join: true) if cmd.nil? && (val = env('SCRIPT', suffix: 'OPTS'))
221
+ @output[cmd ? 1 : 3] = shell_split(val, escape: false, join: true) if (val = env('BUILD', suffix: 'OPTS'))
222
+ @output[4] = shell_split(val, escape: false, join: true) if !cmd && (val = env('SCRIPT', suffix: 'OPTS'))
221
223
  end
222
224
  @version = val if (val = env('BUILD', suffix: 'VERSION'))
223
225
  return unless (val = env('BUILD', strict: true))
@@ -298,7 +300,7 @@ module Squared
298
300
  if val.directory? && !val.empty?
299
301
  true
300
302
  else
301
- log.warn "workspace \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
303
+ log&.warn "workspace \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
302
304
  false
303
305
  end
304
306
  end
@@ -430,12 +432,12 @@ module Squared
430
432
  on :first, :clean
431
433
  case @clean
432
434
  when String
433
- run_s(@clean, from: :clean, sync: sync)
435
+ run_s(@clean, sync: sync)
434
436
  when Hash
435
437
  begin
436
438
  @clean.each { |cmd, opts| build(cmd.to_s, opts, sync: sync) }
437
439
  rescue StandardError => e
438
- log.error e
440
+ log&.error e
439
441
  ret = on(:error, from, e)
440
442
  raise if @exception && ret != true
441
443
  end
@@ -444,17 +446,17 @@ module Squared
444
446
  val = val.to_s
445
447
  path = basepath(val)
446
448
  if path.directory? && val =~ %r{[\\/]\z}
447
- log.warn "rm -rf #{path}"
449
+ log&.warn "rm -rf #{path}"
448
450
  path.rmtree(verbose: verbose)
449
451
  else
450
- log.warn "rm #{path}"
452
+ log&.warn "rm #{path}"
451
453
  (val.include?('*') ? Dir[path] : [path]).each do |file|
452
454
  next unless File.file?(file)
453
455
 
454
456
  begin
455
457
  File.delete(file)
456
458
  rescue StandardError => e
457
- log.error e
459
+ log&.error e
458
460
  end
459
461
  end
460
462
  end
@@ -540,7 +542,7 @@ module Squared
540
542
  instance_variable_set :"@#{key}", val.first
541
543
  end
542
544
  else
543
- log.warn "variable_set: @#{key} (private)"
545
+ log&.warn "variable_set: @#{key} (private)"
544
546
  end
545
547
  end
546
548
 
@@ -675,11 +677,11 @@ module Squared
675
677
  return
676
678
  end
677
679
  cmd = session_done(cmd)
678
- log.info cmd
680
+ log&.info cmd
679
681
  on :first, from
680
682
  begin
681
683
  if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
682
- log.warn "ENV was discarded: #{var}" if var
684
+ log&.warn "ENV was discarded: #{var}" if var
683
685
  task_invoke(cmd, exception: exception, warning: warning?)
684
686
  else
685
687
  print_item format_banner(cmd, banner: banner) if sync
@@ -687,7 +689,7 @@ module Squared
687
689
  shell(*args, chdir: chdir, exception: exception)
688
690
  end
689
691
  rescue StandardError => e
690
- log.error e
692
+ log&.error e
691
693
  ret = on(:error, from, e)
692
694
  raise unless ret == true
693
695
  else
@@ -976,7 +978,7 @@ module Squared
976
978
  puts val unless val.empty? || (val.size == 1 && val.first.nil?)
977
979
  end
978
980
 
979
- def print_banner(*lines, styles: theme[:banner], border: theme[:border], client: false)
981
+ def print_banner(*lines, styles: theme[:banner], border: borderstyle, client: false)
980
982
  pad = 0
981
983
  if styles
982
984
  if styles.any? { |s| s.to_s.end_with?('!') }
@@ -1002,7 +1004,6 @@ module Squared
1002
1004
  end
1003
1005
 
1004
1006
  def print_footer(*lines, sub: nil, reverse: false, right: false, **kwargs)
1005
- border = kwargs.key?(:border) ? kwargs[:border] : borderstyle
1006
1007
  n = Project.max_width(lines)
1007
1008
  sub = as_a(sub)
1008
1009
  lines.map! do |val|
@@ -1010,7 +1011,7 @@ module Squared
1010
1011
  sub.each { |h| s = sub_style(s, **h) }
1011
1012
  s
1012
1013
  end
1013
- ret = [sub_style('-' * n, styles: border || theme[:border]), *lines]
1014
+ ret = [sub_style('-' * n, styles: kwargs.key?(:border) ? kwargs[:border] : borderstyle), *lines]
1014
1015
  ret.reverse! if reverse
1015
1016
  ret.join("\n")
1016
1017
  end
@@ -1303,7 +1304,7 @@ module Squared
1303
1304
  Dir.chdir(pwd)
1304
1305
  end
1305
1306
  rescue StandardError => e
1306
- log.error e
1307
+ log&.error e
1307
1308
  unless dryrun
1308
1309
  ret = on(:error, from, e)
1309
1310
  raise if exception && ret != true
@@ -1443,9 +1444,7 @@ module Squared
1443
1444
  end
1444
1445
 
1445
1446
  def borderstyle
1446
- return unless (data = workspace.banner_get(*@ref, group: group))
1447
-
1448
- data[:border]
1447
+ ((data = workspace.banner_get(*@ref, group: group)) && data[:border]) || theme[:border]
1449
1448
  end
1450
1449
 
1451
1450
  def headerstyle
@@ -84,11 +84,11 @@ module Squared
84
84
  show: %w[s exit-code histogram].freeze
85
85
  }.freeze,
86
86
  fetch: {
87
- base: %w[multiple progress P|prune-tags refetch stdin u|update-head-ok recurse-submodules=s
87
+ base: %w[multiple progress P|prune-tags refetch stdin u|update-head-ok recurse-submodules=b
88
88
  recurse-submodules-default=b].freeze,
89
89
  pull: %w[4 6 n t a|append atomic dry-run f|force k|keep n|negotiate-only prefetch p|prune q|quiet
90
90
  set-upstream unshallow update-shallow v|verbose deepen=i depth=i j|jobs=i negotiation-tip=q
91
- refmap=q o|server-option=e shallow-exclude=e shallow-since=s upload-pack=e].freeze
91
+ refmap=q o|server-option=e shallow-exclude=e shallow-since=b upload-pack=e].freeze
92
92
  }.freeze,
93
93
  log: {
94
94
  base: %w[all all-match alternate-refs author-date-order basic-regexp bisect boundary cherry cherry-mark
@@ -119,7 +119,7 @@ module Squared
119
119
  no-empty-directory recurse-submodules sparse s|stage u|unmerged abbrev=i x|exclude=q
120
120
  X|exclude-from=p exclude-per-directory=p format=q with-tree=q].freeze,
121
121
  ls_remote: %w[exit-code get-url q|quiet o|server-option=e symref sort=q upload-pack=e].freeze,
122
- pull: %w[e n allow-unrelated-histories ff-only S|gpg-sign=e log=i rebase=s s|strategy=b
122
+ pull: %w[e n allow-unrelated-histories ff-only S|gpg-sign=e log=i r|rebase=b? s|strategy=b
123
123
  X|strategy-option=e].freeze,
124
124
  rebase: %w[n C=i allow-empty-message apply committer-date-is-author-date edit-todo f|force-rebase ignore-date
125
125
  ignore-whitespace i|interactive keep-base m merge no-ff q|quiet quit r|rebase-merges=b?
@@ -1115,13 +1115,15 @@ module Squared
1115
1115
  multiple: false, sub: nil)
1116
1116
  banner = nil if multiple && banner
1117
1117
  if cmd.respond_to?(:done)
1118
- if !(io && banner == false) && (from = cmd.drop(1).find { |val| val =~ /^[a-z][a-z\-]{2,}$/ })
1118
+ if io && banner == false
1119
+ from = nil
1120
+ elsif !from && (from = cmd.drop(1).find { |val| val =~ /^[a-z][a-z\-]{2,}$/ })
1119
1121
  from = :"git:#{from}"
1120
1122
  end
1121
1123
  banner &&= cmd.temp { |val| val.start_with?('--work-tree') || val.start_with?('--git-dir') }
1122
1124
  end
1123
1125
  cmd = session_done(cmd)
1124
- log.info cmd
1126
+ log&.info cmd
1125
1127
  on :first, from
1126
1128
  banner = if banner
1127
1129
  format_banner((banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), ''), banner: true)
@@ -1157,7 +1159,7 @@ module Squared
1157
1159
  end
1158
1160
  end
1159
1161
  rescue StandardError => e
1160
- log.error e
1162
+ log&.error e
1161
1163
  ret = on(:error, from, e)
1162
1164
  raise if exception && ret != true
1163
1165
 
@@ -1168,13 +1170,12 @@ module Squared
1168
1170
  end
1169
1171
 
1170
1172
  def write_lines(data, banner: nil, loglevel: nil, grep: nil, sub: nil, pass: false)
1171
- grep = if grep && !grep.empty?
1172
- as_a(grep).map do |val|
1173
- next val if val.is_a?(Regexp)
1173
+ grep = as_a(grep).map do |val|
1174
+ next val if val.is_a?(Regexp)
1174
1175
 
1175
- Regexp.new(val == '*' ? '.+' : val.to_s)
1176
- end
1177
- end
1176
+ Regexp.new(val == '*' ? '.+' : val.to_s)
1177
+ end
1178
+ grep = nil if grep.empty?
1178
1179
  sub = nil if stdin?
1179
1180
  ret = 0
1180
1181
  out = []
@@ -1182,7 +1183,7 @@ module Squared
1182
1183
  next if grep&.none? { |pat| pat.match?(line) }
1183
1184
 
1184
1185
  if loglevel
1185
- log.add loglevel, line
1186
+ log&.add loglevel, line
1186
1187
  else
1187
1188
  sub&.each { |h| line = sub_style(line, **h) }
1188
1189
  if banner
@@ -1221,7 +1222,7 @@ module Squared
1221
1222
  rsm = append_submodules(target: target)
1222
1223
  out = []
1223
1224
  refspec = []
1224
- opts, pat = option_sanitize(opts, remote ? list + ['refspec=s'] : list, target: target, no: no)
1225
+ opts, pat = option_sanitize(opts, remote ? list + ['refspec=b'] : list, target: target, no: no)
1225
1226
  opts.each do |opt|
1226
1227
  if opt =~ pat
1227
1228
  case $1
@@ -5,7 +5,7 @@ module Squared
5
5
  module Project
6
6
  class Node < Git
7
7
  OPT_NPM = {
8
- common: %w[dry-run include-workspace-root workspaces=b? w|workspace=s].freeze,
8
+ common: %w[dry-run include-workspace-root workspaces=b? w|workspace=b].freeze,
9
9
  install: %w[prefer-dedupe package-lock-only cpu=q libc=e os=q].freeze,
10
10
  install_base: %w[ignore-scripts install-links strict-peer-deps include=b omit=b install-strategy=b].freeze,
11
11
  install_no: %w[audit bin-links fund package-lock].freeze,
@@ -218,8 +218,8 @@ module Squared
218
218
  end
219
219
  end
220
220
 
221
- def copy(from: 'build', into: 'node_modules', workspace: false, include: nil, exclude: nil, scope: nil,
222
- also: nil, create: nil, link: false, force: false, override: false)
221
+ def copy(from: 'build', into: 'node_modules', workspace: false, scope: nil, also: nil, create: nil,
222
+ link: false, force: false, override: false, **kwargs)
223
223
  return if @copy == false
224
224
 
225
225
  if @copy && !override
@@ -235,6 +235,9 @@ module Squared
235
235
  scope = @copy[:scope]
236
236
  also = @copy[:also]
237
237
  create = @copy[:create]
238
+ else
239
+ glob = kwargs[:include]
240
+ exclude = kwargs[:exclude]
238
241
  end
239
242
  items = []
240
243
  items << @workspace.home if build? && path != @workspace.home && @workspace.home?
@@ -14,7 +14,7 @@ module Squared
14
14
  install: %w[break-system-packages check-build-dependencies compile dry-run force-reinstall I|ignore-installed
15
15
  ignore-requires-python no-build-isolation no-clean no-compile no-deps no-index no-warn-conflicts
16
16
  no-warn-script-location pre prefer-binary require-hashes U|upgrade use-pep517 user abi=e
17
- config-settings=q c|constraint=p e|editable=s? extra-index-url=q f|find-links=q global-option=q
17
+ config-settings=q c|constraint=p e|editable=b? extra-index-url=q f|find-links=q global-option=q
18
18
  implementation=b i|index-url=q no-binary=q only-binary=q platform=q prefix=p progress-bar=b
19
19
  python-version=q report=p r|requirement=p root=p root-user-action=e src=p t|target=p
20
20
  upgrade-strategy=b].freeze
@@ -25,7 +25,7 @@ module Squared
25
25
  platform=q source=q].freeze,
26
26
  push: %w[no-http-proxy attestation=p host=q key=e otp=e p|http-proxy=q?].freeze,
27
27
  build: %w[force strict o|output=p platform=q].freeze,
28
- exec: %w[conservative prerelease no-prerelease g|gem=s version=e].freeze,
28
+ exec: %w[conservative prerelease no-prerelease g|gem=b version=e].freeze,
29
29
  pristine: %w[all env-shebang extensions no-env-shebang no-extensions only-executables only-missing-extensions
30
30
  only-plugins n|bindir=p i|install-dir=p skip=e v|version=e].freeze,
31
31
  shared: %w[f b|both clear-sources conservative default development development-all E|explain
@@ -350,7 +350,9 @@ module Squared
350
350
  cmd = gem_session
351
351
  case flag
352
352
  when :outdated
353
- cmd << pwd if (pwd = gempwd)
353
+ if (pwd = gempwd)
354
+ cmd << pwd
355
+ end
354
356
  cmd << flag
355
357
  when :push
356
358
  cmd << flag << project
data/squared.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "rake"
28
28
  spec.add_dependency "logger"
29
29
  spec.add_dependency "rexml"
30
+ spec.add_dependency "readline"
30
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-13 00:00:00.000000000 Z
10
+ date: 2025-03-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: readline
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
54
68
  description: Rake task generator for managing multi-language workspaces.
55
69
  email:
56
70
  - anpham6@gmail.com