squared 0.3.11 → 0.3.13

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: 249f3799dc2e8a511a03aec91e04dc84f707cf7b21eb194b89e53805321001c6
4
- data.tar.gz: 4906775ef2c64fae979a3b21a142a19b1f4d17ad4e659b577a41dc971e1c7b4d
3
+ metadata.gz: 52de0073b3487c74635741dc496973cfb3c0925e67c61df2a087fb15ced40045
4
+ data.tar.gz: d8d6cfd52e3575822d667aca3b7432545f1d4ab66a6d5bf02b86cb2d9ee46690
5
5
  SHA512:
6
- metadata.gz: a575c60ad790e1852dad7220d2783bd32e03bfd62d0a04326e5ee72a1868d89ed49b3a50f85504d097ba06d9bd673997770abd091fc0a6da661c7253186b861f
7
- data.tar.gz: fb026dc84454c92e2c09ee52d1fc3fddf0f6f33a071f389abbbc0de6ec584d696e1feed133e05502d5f431d2b67998133e6e5f79b98dd5d382c337e000469d98
6
+ metadata.gz: 8283a392f7cf4aa3c9f48f152e64d855062f12d7fcc130556e89887f73be82cbc10fe29dea45f274e7568399219a632fd6d6dccf63bccaed39bb2ffa2b8b8ca2
7
+ data.tar.gz: 2e437617d9ec8a4bb820bd066c8a7d93229dafb65e650a2aaacd533f9bd4b8e858422434fab0d0e31030721547cc372e13a541a46e8cef6a8a34c6e4971a332b
data/CHANGELOG.md CHANGED
@@ -1,7 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.13] - 2025-07-16
4
+
5
+ ### Fixed
6
+
7
+ - See `0.2.13`.
8
+
9
+ ## [0.2.13] - 2025-07-16
10
+
11
+ ### Fixed
12
+
13
+ - Project graph did not ignore circular references.
14
+
15
+ ## [0.1.10] - 2025-07-16
16
+
17
+ ### Fixed
18
+
19
+ - Module namespaces were not combined in the right order.
20
+ - Workspace group tasks were not registered.
21
+
22
+ ## [0.3.12] - 2025-07-05
23
+
24
+ ### Fixed
25
+
26
+ - Gem command exec did not include gem option flag.
27
+ - Project graph did not print first level border.
28
+ - Node command update did not use correct event name.
29
+ - Gem command push did not validate gem file to publish.
30
+ - Node command publish did not publish when silent.
31
+
32
+ ## [0.2.12] - 2025-07-05
33
+
34
+ ### Fixed
35
+
36
+ - See `0.1.9`.
37
+
38
+ ## [0.1.9] - 2025-07-05
39
+
40
+ ### Added
41
+
42
+ - Initial support for using JRuby.
43
+ - Config viewer theme color for boolean was implemented.
44
+
45
+ ### Fixed
46
+
47
+ - Workspace did not add prefix to duplicate project names.
48
+ - Project output divider was not printed when not verbose.
49
+ - Directory context was not threaded using JRuby.
50
+ - Index character was not captured on Windows.
51
+ - Common method is used for Kernel shell commands.
52
+ - Git did not highlight output for single commands.
53
+
3
54
  ## [0.3.11] - 2025-05-15
4
55
 
56
+ ### Fixed
57
+
5
58
  - See `0.2.11`.
6
59
 
7
60
  ## [0.2.11] - 2025-05-15
@@ -92,6 +145,8 @@
92
145
 
93
146
  ## [0.3.7] - 2025-04-08
94
147
 
148
+ ### Fixed
149
+
95
150
  - See `0.2.7`.
96
151
 
97
152
  ## [0.2.7] - 2025-04-08
@@ -421,6 +476,8 @@
421
476
 
422
477
  - Changelog was created.
423
478
 
479
+ [0.3.13]: https://github.com/anpham6/squared/releases/tag/v0.3.13-ruby
480
+ [0.3.12]: https://github.com/anpham6/squared/releases/tag/v0.3.12-ruby
424
481
  [0.3.11]: https://github.com/anpham6/squared/releases/tag/v0.3.11-ruby
425
482
  [0.3.10]: https://github.com/anpham6/squared/releases/tag/v0.3.10-ruby
426
483
  [0.3.9]: https://github.com/anpham6/squared/releases/tag/v0.3.9-ruby
@@ -433,6 +490,8 @@
433
490
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
434
491
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
435
492
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
493
+ [0.2.13]: https://github.com/anpham6/squared/releases/tag/v0.2.13-ruby
494
+ [0.2.12]: https://github.com/anpham6/squared/releases/tag/v0.2.12-ruby
436
495
  [0.2.11]: https://github.com/anpham6/squared/releases/tag/v0.2.11-ruby
437
496
  [0.2.10]: https://github.com/anpham6/squared/releases/tag/v0.2.10-ruby
438
497
  [0.2.9]: https://github.com/anpham6/squared/releases/tag/v0.2.9-ruby
@@ -445,6 +504,8 @@
445
504
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
446
505
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
447
506
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
507
+ [0.1.10]: https://github.com/anpham6/squared/releases/tag/v0.1.10-ruby
508
+ [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
448
509
  [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
449
510
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
450
511
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-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
@@ -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.11'
4
+ VERSION = '0.3.13'
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)
@@ -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
@@ -656,20 +664,19 @@ module Squared
656
664
  end
657
665
 
658
666
  def data_get(*args, group: nil, ref: nil, target: nil)
659
- if group
660
- target[:group][group.to_sym]
661
- elsif ref.is_a?(Array)
662
- ref = ref.each
663
- end
664
- if ref.instance_of?(Enumerator)
665
- ref.each do |key|
666
- next unless (ret = target[:ref][key])
667
+ if group && (ret = target[:group][group.to_sym])
668
+ ret
669
+ elsif ref
670
+ if ref.is_a?(Enumerable)
671
+ ref.each do |key|
672
+ next unless (ret = target[:ref][key])
667
673
 
668
- return ret if args.empty? || args.any? { |val| ret.key?(val) }
674
+ return ret if args.empty? || args.any? { |val| ret.key?(val) }
675
+ end
676
+ nil
677
+ else
678
+ target[:ref][ref]
669
679
  end
670
- nil
671
- elsif ref
672
- target[:ref][ref]
673
680
  end
674
681
  end
675
682
 
@@ -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
@@ -816,7 +814,7 @@ module Squared
816
814
  done
817
815
  end
818
816
 
819
- def graph_collect(target, start = [], data: {}, pass: [])
817
+ def graph_collect(target, start = [], data: {}, pass: [], root: [])
820
818
  deps = []
821
819
  (start.empty? ? target.instance_variable_get(:@graph) : start)&.each do |val|
822
820
  next if pass.include?(val)
@@ -828,18 +826,21 @@ module Squared
828
826
  else
829
827
  items = workspace.find(group: val, ref: val.to_sym)
830
828
  end
831
-
832
829
  items.each do |proj|
833
- next if pass.include?(proj.name)
830
+ next if pass.include?(name = proj.name)
834
831
 
835
- graph_collect(proj, data: data, pass: pass) if proj.graph? && !data.key?(proj.name)
836
- next if (objs = data.fetch(proj.name, [])).include?(target)
832
+ if proj.graph? && !data.key?(name) && !root.include?(name)
833
+ graph_collect(proj, data: data, pass: pass, root: root + [name, target.name])
834
+ end
835
+ next if (objs = data.fetch(name, [])).include?(target)
837
836
 
838
837
  deps << proj
839
- deps += objs
838
+ deps.concat(objs)
840
839
  end
841
840
  end
842
- data[target.name] = deps.uniq.reject { |proj| proj == target }
841
+ deps.uniq!
842
+ deps.delete(target)
843
+ data[target.name] = deps
843
844
  data
844
845
  end
845
846
 
@@ -992,7 +993,7 @@ module Squared
992
993
  end
993
994
 
994
995
  def print_item(*val)
995
- puts if @@print_order > 0 && verbose && !stdin?
996
+ puts if @@print_order > 0
996
997
  @@print_order += 1
997
998
  puts val unless val.empty? || (val.size == 1 && val.first.nil?)
998
999
  end
@@ -1273,15 +1274,17 @@ module Squared
1273
1274
  end
1274
1275
 
1275
1276
  def indexitem(val)
1276
- return unless val =~ /\A\^(\d+)(:.+)?\z/
1277
-
1278
- [$1.to_i, $2 && $2[1..-1]]
1277
+ [$1.to_i, $2 && $2[1..-1]] if val =~ /\A#{Regexp.escape(indexchar)}(\d+)(:.+)?\z/
1279
1278
  end
1280
1279
 
1281
1280
  def indexerror(val, list = nil)
1282
1281
  raise_error("requested index #{val}", hint: list && "of #{list.size}")
1283
1282
  end
1284
1283
 
1284
+ def indexchar
1285
+ workspace.windows? ? '+' : '^'
1286
+ end
1287
+
1285
1288
  def color(val)
1286
1289
  ret = theme[val]
1287
1290
  ret && !ret.empty? ? ret : [val]
@@ -1315,7 +1318,8 @@ module Squared
1315
1318
  pwd = Pathname.pwd
1316
1319
  if block_given?
1317
1320
  begin
1318
- if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
1321
+ pass = semscan(pass).join <= RUBY_VERSION if pass.is_a?(String)
1322
+ if (path == pwd || pass == true) && !workspace.jruby_win?
1319
1323
  ret = instance_eval(&blk)
1320
1324
  else
1321
1325
  Dir.chdir(path)
@@ -589,7 +589,7 @@ module Squared
589
589
  source(sync: sync, sub: if verbose
590
590
  [
591
591
  { pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: :red, index: 4 },
592
- { pat: /^(.+)(\|\s+\d+\s+)(\++)(-*)(.*)$/, styles: :green, index: 3 }
592
+ { pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: :green, index: 3 }
593
593
  ]
594
594
  end, **threadargs)
595
595
  end
@@ -914,7 +914,8 @@ module Squared
914
914
  origin = nil
915
915
  source(git_output('fetch --no-tags --quiet'), io: true, banner: false, stdout: true)
916
916
  cmd = git_output("for-each-ref --format=\"#{format}\" refs/heads")
917
- 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|
918
919
  next if (line = line.chomp).empty?
919
920
 
920
921
  branch, origin, hint = line.split('...')
@@ -928,8 +929,8 @@ module Squared
928
929
  break
929
930
  end
930
931
  i = origin.index('/')
931
- branch = "#{branch}:#{origin[i + 1..-1]}" unless origin.end_with?("/#{branch}")
932
- origin = origin[0..i - 1]
932
+ branch = "#{branch}:#{origin[(i + 1)..-1]}" unless origin.end_with?("/#{branch}")
933
+ origin = origin[0..(i - 1)]
933
934
  cmd = git_session('commit', option('dry-run') && '--dry-run', options: false)
934
935
  cmd << '--amend' if amend
935
936
  if message
@@ -1132,9 +1133,14 @@ module Squared
1132
1133
  format_banner((banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), ''), banner: true)
1133
1134
  end
1134
1135
  begin
1135
- return [stdout ? `#{cmd}` : IO.popen(cmd), banner, from] if io
1136
-
1137
- 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
1138
1144
  print_item banner unless multiple
1139
1145
  ret = `#{cmd}`
1140
1146
  if !ret.empty?
@@ -1142,7 +1148,7 @@ module Squared
1142
1148
  elsif banner && stdout && !stdin?
1143
1149
  puts 'Success'
1144
1150
  end
1145
- elsif sync || (!exception && !stderr)
1151
+ elsif !sub && (sync || (!exception && !stderr))
1146
1152
  print_item banner unless multiple
1147
1153
  shell(cmd, exception: exception)
1148
1154
  else
@@ -1202,20 +1208,18 @@ module Squared
1202
1208
  end
1203
1209
 
1204
1210
  def list_result(size, type, from: nil, action: 'found', grep: nil)
1205
- if verbose
1206
- if size > 0
1207
- styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1208
- styles << :bold if styles.size <= 1
1209
- puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
1210
- sub: { pat: /\A(\d+)(.+)\z/, styles: styles })
1211
- else
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
- 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 })
1219
1223
  end
1220
1224
  on :last, from
1221
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
@@ -536,49 +536,44 @@ module Squared
536
536
  end
537
537
 
538
538
  def update(*)
539
- package 'update'
539
+ package('update', from: :update)
540
540
  end
541
541
 
542
542
  def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, dryrun: nil, **)
543
- if read_packagemanager(:private)
544
- 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)
545
545
  return
546
546
  end
547
- return unless version
548
-
549
547
  cmd = session 'npm', 'publish'
550
548
  otp = option('otp') if otp.nil?
551
549
  tag = option('tag') if tag.nil?
552
550
  dryrun = dryrun?('npm') if dryrun.nil?
553
551
  cmd << basic_option('otp', otp) if otp
554
552
  cmd << shell_option('tag', tag) if tag
555
- if verbose
556
- if dryrun
557
- cmd << '--dry-run'
558
- else
559
- log.info cmd.to_s
560
- end
561
- unless sync
562
- on :first, :publish unless dryrun
563
- pwd_set(from: :publish, 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
- 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
+ ])
571
570
  end
572
- on :last, :publish unless dryrun
573
- return
574
571
  end
575
- elsif dryrun
576
- return
572
+ on :last, from
577
573
  end
578
- run(from: :publish, sync: sync)
579
574
  end
580
575
 
581
- def package(flag, opts = [])
576
+ def package(flag, opts = [], from: nil)
582
577
  if (yarn = dependtype(:yarn)) > 0
583
578
  cmd = session 'yarn', if flag == :update
584
579
  flag = yarn == 1 ? 'upgrade' : 'up'
@@ -619,6 +614,7 @@ module Squared
619
614
  out << opt
620
615
  end
621
616
  end
617
+ cmd << '--save=true' if option('save')
622
618
  append_nocolor
623
619
  append_loglevel
624
620
  if flag == :dedupe
@@ -628,7 +624,7 @@ module Squared
628
624
  end
629
625
  option_clear err
630
626
  end
631
- run(from: :"package:#{flag}")
627
+ run(from: from || :"package:#{flag}")
632
628
  end
633
629
 
634
630
  def bump(flag, val = nil)
@@ -836,9 +832,11 @@ module Squared
836
832
  @pm[:_] = false
837
833
  nil
838
834
  else
839
- return @pm[key] if key
840
-
841
- !(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
842
840
  end
843
841
 
844
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,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-05-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -107,7 +106,6 @@ metadata:
107
106
  homepage_uri: https://github.com/anpham6/squared
108
107
  source_code_uri: https://github.com/anpham6/squared
109
108
  documentation_uri: https://squared.readthedocs.io
110
- post_install_message:
111
109
  rdoc_options: []
112
110
  require_paths:
113
111
  - lib
@@ -122,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
120
  - !ruby/object:Gem::Version
123
121
  version: '0'
124
122
  requirements: []
125
- rubygems_version: 3.1.6
126
- signing_key:
123
+ rubygems_version: 3.6.7
127
124
  specification_version: 4
128
125
  summary: Rake task generator for managing multi-language workspaces.
129
126
  test_files: []