squared 0.3.10 → 0.3.12

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: 86709d5961b0a4cf2fd7192ea64d178737ca047b286f5d1888cc9cb58412697a
4
- data.tar.gz: e95da9ca85b3e493e20743da05b552840b0a4a77f4afec1b0edd947ec3e27229
3
+ metadata.gz: f6ba5fce68ca21d291620e1877a4a00733e795d1cc9fa5cccfe9866d422554b6
4
+ data.tar.gz: 8b22eaea56b0a8ccc5ad9880fd3efc12060246228a09e902d346a054947b31b6
5
5
  SHA512:
6
- metadata.gz: f2e5eeda8962c5d2e8e0734f0784c2138312e2c6b0c27ccd07e9c7c0a3fde17fe1b32e4c596206696a6c29daf05414c8f5474b141ff604292f18e1a3563d8aa0
7
- data.tar.gz: af7771a53f01d2083c5d7ad7832e036aade52441493733a76604b5af884214cf26fb84ef9b7a451a84e1f725f15f396123b6eda9b49560ef7f722a24b4173b71
6
+ metadata.gz: 8312fe3ccf942363b0bce6b05e24fbb012860b3e1dd3e36956dfc754a0b563db1edac58e054a1409c65d71cdf82f2dd5d4b487e2ee6d1da8c24a650c73132e42
7
+ data.tar.gz: 6553a12173f0e5e4ee421772fa503c58d9e77f98738cedd25c5d06775ac4f13bf6c1a2b5eab6b0cae07f7ce23e60b60ed95c098b6eb2eaf938bc081c0f1f7e55
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.12] - 2025-07-05
4
+
5
+ ### Fixed
6
+
7
+ - Gem command exec did not include gem option flag.
8
+ - Project graph did not print first level border.
9
+ - Node command update did not use correct event name.
10
+ - Gem command push did not validate gem file to publish.
11
+ - Node command publish did not publish when silent.
12
+
13
+ ## [0.2.12] - 2025-07-05
14
+
15
+ ### Fixed
16
+
17
+ - See `0.1.9`.
18
+
19
+ ## [0.1.9] - 2025-07-05
20
+
21
+ ### Added
22
+
23
+ - Initial support for using JRuby.
24
+ - Config viewer theme color for boolean was implemented.
25
+
26
+ ### Fixed
27
+
28
+ - Workspace did not add prefix to duplicate project names.
29
+ - Project output divider was not printed when not verbose.
30
+ - Directory context was not threaded using JRuby.
31
+ - Index character was not captured on Windows.
32
+ - Common method is used for Kernel shell commands.
33
+ - Git did not highlight output for single commands.
34
+
35
+ ## [0.3.11] - 2025-05-15
36
+
37
+ ### Fixed
38
+
39
+ - See `0.2.11`.
40
+
41
+ ## [0.2.11] - 2025-05-15
42
+
43
+ ### Fixed
44
+
45
+ - Disabled batch and alias tasks were not hidden.
46
+ - Workspace git did not parse multiple download URIs.
47
+
48
+ ## [0.1.8] - 2025-05-15
49
+
50
+ ### Fixed
51
+
52
+ - Disabled batch and alias tasks were not hidden.
53
+ - Log messages were written to terminal twice when emphasized.
54
+ - Node outdated interactive for major would sometimes deactivate.
55
+ - Node outdated interactive for major was mislabeled as minor.
56
+
3
57
  ## [0.3.10] - 2025-04-27
4
58
 
5
59
  ### Fixed
@@ -72,6 +126,8 @@
72
126
 
73
127
  ## [0.3.7] - 2025-04-08
74
128
 
129
+ ### Fixed
130
+
75
131
  - See `0.2.7`.
76
132
 
77
133
  ## [0.2.7] - 2025-04-08
@@ -401,6 +457,8 @@
401
457
 
402
458
  - Changelog was created.
403
459
 
460
+ [0.3.12]: https://github.com/anpham6/squared/releases/tag/v0.3.12-ruby
461
+ [0.3.11]: https://github.com/anpham6/squared/releases/tag/v0.3.11-ruby
404
462
  [0.3.10]: https://github.com/anpham6/squared/releases/tag/v0.3.10-ruby
405
463
  [0.3.9]: https://github.com/anpham6/squared/releases/tag/v0.3.9-ruby
406
464
  [0.3.8]: https://github.com/anpham6/squared/releases/tag/v0.3.8-ruby
@@ -412,6 +470,8 @@
412
470
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
413
471
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
414
472
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
473
+ [0.2.12]: https://github.com/anpham6/squared/releases/tag/v0.2.12-ruby
474
+ [0.2.11]: https://github.com/anpham6/squared/releases/tag/v0.2.11-ruby
415
475
  [0.2.10]: https://github.com/anpham6/squared/releases/tag/v0.2.10-ruby
416
476
  [0.2.9]: https://github.com/anpham6/squared/releases/tag/v0.2.9-ruby
417
477
  [0.2.8]: https://github.com/anpham6/squared/releases/tag/v0.2.8-ruby
@@ -423,6 +483,8 @@
423
483
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
424
484
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
425
485
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
486
+ [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
487
+ [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
426
488
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
427
489
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
428
490
  [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
@@ -55,6 +55,7 @@ module Squared
55
55
  hash: %i[green black!],
56
56
  array: %i[blue black!],
57
57
  number: [:magenta],
58
+ boolean: [:magenta],
58
59
  undefined: %i[red italic]
59
60
  },
60
61
  logger: {
@@ -95,13 +96,15 @@ module Squared
95
96
  return [] if obj.nil?
96
97
 
97
98
  unless obj.is_a?(::Array)
98
- obj = if obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
99
+ obj = if obj.respond_to?(:to_ary)
100
+ obj.to_ary
101
+ elsif obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
99
102
  val
100
103
  else
101
104
  [obj]
102
105
  end
103
106
  end
104
- obj = obj.flatten(flat.is_a?(::Numeric) ? flat : nil) if flat
107
+ obj = flat.is_a?(::Numeric) ? obj.flatten(flat) : obj.flatten if flat
105
108
  obj = obj.compact if compact
106
109
  obj = obj.map(&meth) if meth
107
110
  block_given? ? obj.select(&blk) : obj
@@ -171,7 +171,7 @@ module Squared
171
171
  if args.size > 1
172
172
  title = log_title(level, color: false)
173
173
  sub = { pat: /^(#{title})(.+)$/, styles: __get__(:theme)[:logger][log_sym(level)] } if color
174
- emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub)
174
+ emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
175
175
  else
176
176
  msg = [log_title(level, color: color)]
177
177
  msg << (color ? sub_style(subject, :underline) : subject) if subject
@@ -257,6 +257,8 @@ module Squared
257
257
  yield out
258
258
  elsif pipe
259
259
  case pipe
260
+ when -1
261
+ return out
260
262
  when 0
261
263
  pipe = $stdin
262
264
  when 2
@@ -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 = 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
- 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?(::Array)
33
- pass.each { |val| exclude += Dir.glob(src.join(val)) }
41
+ Array(pass).each { |val| exclude += Dir.glob(src.join(val)) }
34
42
  end
35
- (glob.is_a?(::Array) ? glob : [glob]).each do |val|
43
+ Array(glob).each do |val|
36
44
  Dir.glob(src.join(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?(::Array)
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
@@ -250,6 +250,8 @@ module Squared
250
250
  { pat: /\A(.+ : ")(.+)("\s*)\z/m, styles: theme[:string], index: 2 },
251
251
  { pat: /\A(.+ : \{)(.+)(\}\s*)\z/m, styles: theme[:hash], index: 2 },
252
252
  { pat: /\A(.+ : \[)(.+)(\]\s*)\z/m, styles: theme[:array], index: 2 },
253
+ { pat: /\A(.+ : )(true|false)(\s*)\z/m, styles: theme[:boolean],
254
+ index: 2 },
253
255
  { pat: /\A(.+ : (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
254
256
  index: 2 }
255
257
  ]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.3.10'
4
+ VERSION = '0.3.12'
5
5
  end
@@ -296,7 +296,7 @@ module Squared
296
296
  index = 0
297
297
  while @project[name]
298
298
  index += 1
299
- name = "#{project}-#{index}"
299
+ name = task_name "#{project}-#{index}"
300
300
  end
301
301
  proj = ((if !ref.is_a?(Class)
302
302
  Application.find(ref, path: path)
@@ -455,7 +455,7 @@ module Squared
455
455
  tasks << key if obj.has?(key, baseref)
456
456
  elsif (batch = series.batch_get(key))
457
457
  obj.allref.each do |ref|
458
- next unless (data = batch[ref])
458
+ next unless obj.has?(key, ref) && (data = batch[ref])
459
459
 
460
460
  data.each do |val|
461
461
  if (items = task_resolve(obj, val)).empty?
@@ -474,7 +474,7 @@ module Squared
474
474
  return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
475
475
 
476
476
  obj.allref.each do |ref|
477
- next unless (alt = data[ref])
477
+ next unless obj.has?(key, ref) && (alt = data[ref])
478
478
 
479
479
  ret = task_resolve(obj, alt)
480
480
  break unless ret.empty?
@@ -587,6 +587,14 @@ module Squared
587
587
  Rake::Win32.windows?
588
588
  end
589
589
 
590
+ def jruby?
591
+ RUBY_ENGINE == 'jruby'
592
+ end
593
+
594
+ def jruby_win?
595
+ jruby? && windows?
596
+ end
597
+
590
598
  def rootpath(*args)
591
599
  root.join(*args)
592
600
  end
@@ -676,10 +676,8 @@ module Squared
676
676
 
677
677
  def run(cmd = @session, var = nil, exception: @exception, sync: true, banner: true, chdir: path, from: nil, **)
678
678
  unless cmd
679
- if warning?
680
- from &&= from.to_s
681
- warn log_message(Logger::WARN, from || 'unknown', subject: project, hint: 'no command given')
682
- end
679
+ from &&= from.to_s
680
+ warn log_message(Logger::WARN, from || 'unknown', subject: project, hint: 'no command given')
683
681
  return
684
682
  end
685
683
  cmd = session_done(cmd)
@@ -766,7 +764,7 @@ module Squared
766
764
 
767
765
  t = dedupe.(proj.name)
768
766
  j = if out
769
- if i == items.size - 1 || check.(post = items[i + 1..-1]).empty?
767
+ if i == items.size - 1 || check.(post = items[(i + 1)..-1]).empty?
770
768
  true
771
769
  elsif !t.empty? && depth > 0
772
770
  post.reject { |pr| t.include?(pr) }.empty?
@@ -804,7 +802,7 @@ module Squared
804
802
  k = 0
805
803
  final = data.keys.last
806
804
  while k < depth
807
- indent = k > 0 && ((last && !j) || (j && k == depth - 1) || single)
805
+ indent = k > 0 ? ((last && !j) || (j && k == depth - 1) || single) : j && last && depth == 1
808
806
  s += "#{indent || (last && data[final].last == context) ? ' ' : a} "
809
807
  k += 1
810
808
  end
@@ -992,7 +990,7 @@ module Squared
992
990
  end
993
991
 
994
992
  def print_item(*val)
995
- puts if @@print_order > 0 && verbose && !stdin?
993
+ puts if @@print_order > 0
996
994
  @@print_order += 1
997
995
  puts val unless val.empty? || (val.size == 1 && val.first.nil?)
998
996
  end
@@ -1273,15 +1271,17 @@ module Squared
1273
1271
  end
1274
1272
 
1275
1273
  def indexitem(val)
1276
- return unless val =~ /\A\^(\d+)(:.+)?\z/
1277
-
1278
- [$1.to_i, $2 && $2[1..-1]]
1274
+ [$1.to_i, $2 && $2[1..-1]] if val =~ /\A#{Regexp.escape(indexchar)}(\d+)(:.+)?\z/
1279
1275
  end
1280
1276
 
1281
1277
  def indexerror(val, list = nil)
1282
1278
  raise_error("requested index #{val}", hint: list && "of #{list.size}")
1283
1279
  end
1284
1280
 
1281
+ def indexchar
1282
+ workspace.windows? ? '+' : '^'
1283
+ end
1284
+
1285
1285
  def color(val)
1286
1286
  ret = theme[val]
1287
1287
  ret && !ret.empty? ? ret : [val]
@@ -1315,7 +1315,8 @@ module Squared
1315
1315
  pwd = Pathname.pwd
1316
1316
  if block_given?
1317
1317
  begin
1318
- if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
1318
+ pass = semscan(pass).join <= RUBY_VERSION if pass.is_a?(String)
1319
+ if (path == pwd || pass == true) && !workspace.jruby_win?
1319
1320
  ret = instance_eval(&blk)
1320
1321
  else
1321
1322
  Dir.chdir(path)
@@ -12,7 +12,11 @@ module Squared
12
12
  check = ->(proj) { proj.is_a?(Project::Git) && !proj.exclude?(Project::Git.ref) && git_clone?(proj.path) }
13
13
  if uri.is_a?(Array)
14
14
  base = name
15
- uri.each { |val| repo << proj if (proj = @project[val.to_s]) && check.(proj) }
15
+ uri.each do |val|
16
+ if (proj = @project[val.to_s]) && check.(proj)
17
+ repo << proj
18
+ end
19
+ end
16
20
  elsif uri
17
21
  data[name.to_s] = uri
18
22
  elsif name.is_a?(Enumerable)
@@ -585,7 +589,7 @@ module Squared
585
589
  source(sync: sync, sub: if verbose
586
590
  [
587
591
  { pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: :red, index: 4 },
588
- { pat: /^(.+)(\|\s+\d+\s+)(\++)(-*)(.*)$/, styles: :green, index: 3 }
592
+ { pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: :green, index: 3 }
589
593
  ]
590
594
  end, **threadargs)
591
595
  end
@@ -910,7 +914,8 @@ module Squared
910
914
  origin = nil
911
915
  source(git_output('fetch --no-tags --quiet'), io: true, banner: false, stdout: true)
912
916
  cmd = git_output("for-each-ref --format=\"#{format}\" refs/heads")
913
- source(cmd, io: true, banner: false).first.each do |line|
917
+ out = source(cmd, io: true, stdout: workspace.windows?, banner: false).first
918
+ (workspace.windows? ? out.lines : out).each do |line|
914
919
  next if (line = line.chomp).empty?
915
920
 
916
921
  branch, origin, hint = line.split('...')
@@ -924,8 +929,8 @@ module Squared
924
929
  break
925
930
  end
926
931
  i = origin.index('/')
927
- branch = "#{branch}:#{origin[i + 1..-1]}" unless origin.end_with?("/#{branch}")
928
- origin = origin[0..i - 1]
932
+ branch = "#{branch}:#{origin[(i + 1)..-1]}" unless origin.end_with?("/#{branch}")
933
+ origin = origin[0..(i - 1)]
929
934
  cmd = git_session('commit', option('dry-run') && '--dry-run', options: false)
930
935
  cmd << '--amend' if amend
931
936
  if message
@@ -1128,9 +1133,14 @@ module Squared
1128
1133
  format_banner((banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), ''), banner: true)
1129
1134
  end
1130
1135
  begin
1131
- return [stdout ? `#{cmd}` : IO.popen(cmd), banner, from] if io
1132
-
1133
- if stdin? ? sync : stdout
1136
+ if io
1137
+ ret = if stdout
1138
+ [`#{cmd}`]
1139
+ else
1140
+ [IO.popen(cmd), banner, from]
1141
+ end
1142
+ return ret
1143
+ elsif stdin? ? sync : stdout
1134
1144
  print_item banner unless multiple
1135
1145
  ret = `#{cmd}`
1136
1146
  if !ret.empty?
@@ -1138,7 +1148,7 @@ module Squared
1138
1148
  elsif banner && stdout && !stdin?
1139
1149
  puts 'Success'
1140
1150
  end
1141
- elsif sync || (!exception && !stderr)
1151
+ elsif !sub && (sync || (!exception && !stderr))
1142
1152
  print_item banner unless multiple
1143
1153
  shell(cmd, exception: exception)
1144
1154
  else
@@ -1198,20 +1208,18 @@ module Squared
1198
1208
  end
1199
1209
 
1200
1210
  def list_result(size, type, from: nil, action: 'found', grep: nil)
1201
- if verbose
1202
- if size > 0
1203
- styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1204
- styles << :bold if styles.size <= 1
1205
- puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
1206
- sub: { pat: /\A(\d+)(.+)\z/, styles: styles })
1207
- else
1208
- puts empty_status("No #{type} were #{action}", 'grep', grep.is_a?(Array) ? case grep.size
1209
- when 0
1210
- nil
1211
- else
1212
- grep.join(', ')
1213
- end : grep.to_s)
1214
- end
1211
+ if size == 0
1212
+ puts empty_status("No #{type} were #{action}", 'grep', grep.is_a?(Array) ? case grep.size
1213
+ when 0
1214
+ nil
1215
+ else
1216
+ grep.join(', ')
1217
+ end : grep.to_s)
1218
+ elsif verbose
1219
+ styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1220
+ styles << :bold if styles.size <= 1
1221
+ puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
1222
+ sub: { pat: /\A(\d+)(.+)\z/, styles: styles })
1215
1223
  end
1216
1224
  on :last, from
1217
1225
  end
@@ -127,7 +127,7 @@ module Squared
127
127
  end
128
128
  case save
129
129
  when 'prod', 'dev', 'optional', 'peer'
130
- packages = args.to_a.drop(1)
130
+ packages = args.extras
131
131
  else
132
132
  save = 'prod'
133
133
  packages = args.to_a
@@ -138,10 +138,10 @@ module Squared
138
138
  when 'run'
139
139
  next if (list = read_scripts).empty?
140
140
 
141
- format_desc action, nil, 'command+|^index|#,pattern*'
141
+ format_desc action, nil, "command+|#{indexchar}index|#,pattern*"
142
142
  task action, [:command] do |_, args|
143
143
  if args.command == '#'
144
- format_list(list, 'run[^N]', 'scripts', grep: args.extras, from: dependfile.to_s)
144
+ format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile.to_s)
145
145
  else
146
146
  cmd = param_guard(action, 'command', args: args.to_a)
147
147
  cmd.each do |val|
@@ -175,7 +175,7 @@ module Squared
175
175
  outdated flag, args.to_a
176
176
  end
177
177
  when 'package'
178
- format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : 'names*')
178
+ format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : 'name*')
179
179
  task flag do |_, args|
180
180
  package flag, args.to_a
181
181
  end
@@ -437,7 +437,7 @@ module Squared
437
437
  index = if a != c
438
438
  1
439
439
  elsif b != d
440
- 3
440
+ a == '0' ? 1 : 3
441
441
  else
442
442
  5
443
443
  end
@@ -471,7 +471,8 @@ module Squared
471
471
  col2 = size_col.(found, 1) + 4
472
472
  found.each_with_index do |item, i|
473
473
  a, b, c, d, e = item
474
- if inter && (rev != :major || e || semmajor?(item[5], item[6])) && !confirm_outdated(a, c, d, e)
474
+ f = inter && (rev != :major || e || semmajor?(item[5], item[6]))
475
+ if f && !confirm_outdated(a, c, d, e)
475
476
  cur = -1
476
477
  else
477
478
  cur = modified
@@ -535,49 +536,44 @@ module Squared
535
536
  end
536
537
 
537
538
  def update(*)
538
- package 'update'
539
+ package('update', from: :update)
539
540
  end
540
541
 
541
542
  def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, dryrun: nil, **)
542
- if read_packagemanager(:private)
543
- warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: 'private') if warning?
543
+ if !version || read_packagemanager(:private)
544
+ warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: version ? 'private' : nil)
544
545
  return
545
546
  end
546
- return unless version
547
-
548
547
  cmd = session 'npm', 'publish'
549
548
  otp = option('otp') if otp.nil?
550
549
  tag = option('tag') if tag.nil?
551
550
  dryrun = dryrun?('npm') if dryrun.nil?
552
551
  cmd << basic_option('otp', otp) if otp
553
552
  cmd << shell_option('tag', tag) if tag
554
- if verbose
555
- if dryrun
556
- cmd << '--dry-run'
557
- else
558
- log.info cmd.to_s
559
- end
560
- unless sync
561
- on :first, :publish unless dryrun
562
- pwd_set(from: :publish, dryrun: dryrun) do
563
- require 'open3'
564
- banner = format_banner(cmd.to_s)
565
- Open3.popen2e(cmd.done) do |_, out|
566
- write_lines(out, banner: banner, sub: npmnotice + [
567
- { pat: /^(.+)(Tarball .+)$/, styles: :blue, index: 2 }
568
- ])
569
- end
553
+ if dryrun
554
+ cmd << '--dry-run'
555
+ else
556
+ from = :publish
557
+ log.info cmd.to_s
558
+ end
559
+ if sync
560
+ run(from: from, sync: sync)
561
+ else
562
+ on :first, from
563
+ pwd_set(from: from, dryrun: dryrun) do
564
+ require 'open3'
565
+ banner = format_banner(cmd.to_s)
566
+ Open3.popen2e(cmd.done) do |_, out|
567
+ write_lines(out, banner: banner, sub: npmnotice + [
568
+ { pat: /^(.+)(Tarball .+)$/, styles: :blue, index: 2 }
569
+ ])
570
570
  end
571
- on :last, :publish unless dryrun
572
- return
573
571
  end
574
- elsif dryrun
575
- return
572
+ on :last, from
576
573
  end
577
- run(from: :publish, sync: sync)
578
574
  end
579
575
 
580
- def package(flag, opts = [])
576
+ def package(flag, opts = [], from: nil)
581
577
  if (yarn = dependtype(:yarn)) > 0
582
578
  cmd = session 'yarn', if flag == :update
583
579
  flag = yarn == 1 ? 'upgrade' : 'up'
@@ -618,6 +614,7 @@ module Squared
618
614
  out << opt
619
615
  end
620
616
  end
617
+ cmd << '--save=true' if option('save')
621
618
  append_nocolor
622
619
  append_loglevel
623
620
  if flag == :dedupe
@@ -627,7 +624,7 @@ module Squared
627
624
  end
628
625
  option_clear err
629
626
  end
630
- run(from: :"package:#{flag}")
627
+ run(from: from || :"package:#{flag}")
631
628
  end
632
629
 
633
630
  def bump(flag, val = nil)
@@ -739,6 +736,10 @@ module Squared
739
736
  outdated?
740
737
  end
741
738
 
739
+ def refresh?
740
+ !Node.prod?
741
+ end
742
+
742
743
  def yarn?
743
744
  (@pm[:yarn] ||= if basepath('yarn.lock', ascend: dependext).exist?
744
745
  if (rc = basepath('.yarnrc.yml', ascend: dependext)).exist?
@@ -831,9 +832,11 @@ module Squared
831
832
  @pm[:_] = false
832
833
  nil
833
834
  else
834
- return @pm[key] if key
835
-
836
- !(ret = @pm[:_]) || (version && ret[ret.index('@') + 1..-1] < version) ? nil : ret
835
+ if key
836
+ @pm[key]
837
+ elsif (ret = @pm[:_]) && !(version && ret[(ret.index('@') + 1)..-1] < version)
838
+ ret
839
+ end
837
840
  end
838
841
 
839
842
  def read_install
@@ -121,11 +121,11 @@ module Squared
121
121
  when 'rake'
122
122
  next unless rakefile
123
123
 
124
- format_desc action, nil, 'command*|^index,args*|#,pattern*'
124
+ format_desc action, nil, "command*|#{indexchar}index,args*|#,pattern*"
125
125
  task action, [:command] do |_, args|
126
126
  if args.command == '#'
127
- format_list(read_rakefile, 'rake[^N]', 'tasks', grep: args.extras, from: rakefile.to_s,
128
- each: ->(val) { val[0] + val[1].to_s })
127
+ format_list(read_rakefile, "rake[#{indexchar}N]", 'tasks', grep: args.extras, from: rakefile.to_s,
128
+ each: ->(val) { val[0] + val[1].to_s })
129
129
  elsif (data = indexitem(args.command))
130
130
  n, opts = data
131
131
  list = read_rakefile
@@ -155,7 +155,10 @@ module Squared
155
155
  when 'gem'
156
156
  case flag
157
157
  when :outdated, :build, :push, :exec
158
- format_desc(action, flag, 'opts*', before: flag == :exec ? 'command+' : nil)
158
+ format_desc(action, flag, 'opts*', before: case flag
159
+ when :exec then 'command+'
160
+ when :push then 'file'
161
+ end)
159
162
  task flag do |_, args|
160
163
  gemx flag, args.to_a
161
164
  end
@@ -358,7 +361,8 @@ module Squared
358
361
  end
359
362
  cmd << flag
360
363
  when :push
361
- cmd << flag << project
364
+ raise_error('gem not found', hint: flag) if opts.empty? || !(file = path + opts.shift).exist?
365
+ cmd << flag << shell_quote(file)
362
366
  when :'user-install'
363
367
  cmd << 'install' << '--user-install'
364
368
  else
@@ -379,7 +383,7 @@ module Squared
379
383
  if opt =~ pat
380
384
  case $1
381
385
  when 'g', 'gem'
382
- cmd << (flag == :exec ? shell_option($1, $2) : quote_option($1, basepath($2)))
386
+ cmd << (flag == :exec ? basic_option($1, $2) : quote_option($1, basepath($2)))
383
387
  end
384
388
  else
385
389
  out << opt
@@ -476,7 +480,8 @@ module Squared
476
480
  end
477
481
  when :exec
478
482
  raise_error('gem', flag, hint: 'no command given') if out.empty?
479
- cmd << project << out.join(' ')
483
+ cmd << basic_option('gem', project) unless session_arg?('g', 'gem')
484
+ cmd << '--' << out.join(' ')
480
485
  else
481
486
  if out.empty? && cmd.none? { |val| val =~ /^--system(?:=|$)/ }
482
487
  raise_error('gem', flag, hint: 'no gemname given')
@@ -492,7 +497,7 @@ module Squared
492
497
  version = name[1..-1]
493
498
  else
494
499
  cmd << shell_escape(name[0, n])
495
- version = name[n + 1..-1]
500
+ version = name[(n + 1)..-1]
496
501
  end
497
502
  cmd << shell_option('version', version)
498
503
  out.clear
@@ -175,7 +175,7 @@ module Squared
175
175
  parse_opts.(args)
176
176
  stage = 'init'
177
177
  puts if newline
178
- system("repo init -u #{manifest_url} -m #{args.manifest || target}.xml", chdir: root)
178
+ Common::System.shell("repo init -u #{manifest_url} -m #{args.manifest || target}.xml", chdir: root)
179
179
  repo['all'].invoke
180
180
  end
181
181
 
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.10
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.6.2
123
+ rubygems_version: 3.6.7
124
124
  specification_version: 4
125
125
  summary: Rake task generator for managing multi-language workspaces.
126
126
  test_files: []