squared 0.2.1 → 0.2.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: ae7095bd3b6c80ac081ead2d7416fddd1f36b43ebcd94231058b1d8e172506b0
4
- data.tar.gz: '0296f829c74cee76bcf72bf90c1b47e0d63747adf8cd790b7c3964795d4806ad'
3
+ metadata.gz: 3bc7bf1e798295581f3dcbd052d367f159a91bff55bc4bbcbe3862a6d4c39739
4
+ data.tar.gz: '03919adb276a1ed4b25b217776e28d4525c90e4ffe5af508b883d3480f4fbf23'
5
5
  SHA512:
6
- metadata.gz: 3a4831abda159ce464a8ba38e3e2f16b232d6a95f84139f7ee21c6317917837eb5bed85177ab0f47131e749b63d5ee8662bcff5a48a96388e2c55c46df32b235
7
- data.tar.gz: 25be7c05ccacd04b11daed4ce393c4a882535939c060aa2b5a24b7e515a2f3b984467e4e3f58ab5ee8b76876107bf1f04cbf7de4d7c0625eb8c690a31045e052
6
+ metadata.gz: 4ad94be493ad60c59ed738d59884bbfd815cddd8ddbe31ad6be4fd6f0e7ddf70b6b7bd6b70d65ab4b14caa99d1480f7cb985f02d39351d5a4554f6f6a91cb6a3
7
+ data.tar.gz: 98783c78e94aa41d5f331110129f329cfe2c80e87e008a8d453cc0f4851701cc538524b7fe924ae19e58689641a9be2b131e354386566ee4344b7b831539cd42
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3] - 2025-02-05
4
+
5
+ ### Fixed
6
+
7
+ - Project hash options duplicated dash prefix.
8
+ - Pip upgrade did not append package names.
9
+
10
+ ## [0.2.2] - 2025-01-19
11
+
12
+ ### Fixed
13
+
14
+ - Ruby version detection did not parse currently installed gem.
15
+ - Build options with array args were not recognized.
16
+ - Base clean command did not enumerate non-string values.
17
+ - Git pull did not append origin without option separator.
18
+ - Command options from a hash did not parse single character flags.
19
+ - Git command refs did not include ref option.
20
+ - Base copy command did not accept array parameters.
21
+ - Shell option escape did not detect quotes for Windows.
22
+ - Git command reset did not include mode argument.
23
+ - Git command show format argument was not optional.
24
+ - Clean directory did not set verbose flag.
25
+ - Git clone was not enabled when all project folders were missing.
26
+ - Git commit does not parse global ENV options.
27
+
3
28
  ## [0.2.1] - 2025-01-08
4
29
 
5
30
  ### Fixed
@@ -151,6 +176,8 @@
151
176
 
152
177
  - Changelog was created.
153
178
 
179
+ [0.2.3]: https://github.com/anpham6/squared/releases/tag/v0.2.3-ruby
180
+ [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
154
181
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
155
182
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
156
183
  [0.1.3]: https://github.com/anpham6/squared/releases/tag/v0.1.3-ruby
data/README.ruby.md CHANGED
@@ -335,16 +335,16 @@ Common::PATH.merge!({
335
335
  # :env :run :opts
336
336
  # LD_LIBRARY_PATH="path/to/lib" CFLAGS="-Wall" gcc a.c -o a.o -c
337
337
  BUILD_${NAME} # gcc a.c -o a.o
338
- BUILD_OPTS_${NAME} # -c
339
- BUILD_ENV_${NAME} # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
338
+ BUILD_${NAME}_OPTS # -c
339
+ BUILD_${NAME}_ENV # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
340
340
 
341
341
  # :env :opts :script
342
342
  # NODE_ENV="production" NO_COLOR="1" npm run --loglevel=error --workspaces=false build:dev
343
343
  BUILD_${NAME} # build:dev
344
- BUILD_OPTS_${NAME} # --loglevel=error --workspaces=false
345
- BUILD_ENV_${NAME} # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
346
- BUILD_DEV_${NAME} # pattern,0,1 (:dev)
347
- BUILD_PROD_${NAME} # pattern,0,1 (:prod)
344
+ BUILD_${NAME}_OPTS # --loglevel=error --workspaces=false
345
+ BUILD_${NAME}_ENV # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
346
+ BUILD_${NAME}_DEV # pattern,0,1 (:dev)
347
+ BUILD_${NAME}_PROD # pattern,0,1 (:prod)
348
348
 
349
349
  BUILD_${NAME}=0 # skip project
350
350
  ```
@@ -39,8 +39,13 @@ module Squared
39
39
  val.join(join.is_a?(::String) ? join : ' ')
40
40
  end
41
41
 
42
- def shell_option(flag, val = nil, quote: false, escape: true)
43
- a, b = flag.size == 1 ? ['-', ' '] : ['--', '=']
42
+ def shell_option(flag, val = nil, escape: true, quote: true)
43
+ flag = flag.to_s
44
+ if flag[0] == '-'
45
+ b = flag[1] == '-' ? '=' : ' '
46
+ else
47
+ a, b = flag.size == 1 ? ['-', ' '] : ['--', '=']
48
+ end
44
49
  "#{a}#{flag}#{if val
45
50
  "#{b}#{if escape
46
51
  shell_escape(val, quote: quote)
@@ -57,11 +62,11 @@ module Squared
57
62
  end
58
63
 
59
64
  def quote_option(flag, val)
60
- shell_option(flag, val, escape: false, quote: true)
65
+ shell_option(flag, val, escape: false)
61
66
  end
62
67
 
63
68
  def basic_option(flag, val)
64
- shell_option(flag, val, escape: false)
69
+ shell_option(flag, val, escape: false, quote: false)
65
70
  end
66
71
 
67
72
  def single_quote(val)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.3'
5
5
  end
@@ -513,7 +513,7 @@ module Squared
513
513
  end
514
514
 
515
515
  def enabled?
516
- !@extensions.empty? || @project.values.any?(&:enabled?)
516
+ !@extensions.empty? || @project.values.any? { |proj| proj.enabled?(base: false) }
517
517
  end
518
518
 
519
519
  def task_base?(key)
@@ -348,20 +348,22 @@ module Squared
348
348
  end
349
349
 
350
350
  def build(*args, from: :build, sync: invoked_sync?('build'), **)
351
+ banner = verbose
351
352
  if args.empty?
353
+ return unless from == :build
354
+
352
355
  cmd, opts, var, flags = @output
353
- banner = verbose == 1
356
+ banner = verbose == 1 if task_invoked?('build', 'build:sync')
354
357
  else
355
358
  cmd = args.shift
356
359
  opts = args.map { |val| shell_quote(val, force: false) }.join(' ')
357
- banner = verbose
358
360
  end
359
361
  if cmd
360
362
  case opts
361
363
  when String
362
364
  cmd = "#{cmd} #{opts}"
363
365
  when Array
364
- cmd = cmd.join(' && ')
366
+ cmd = as_a(cmd).concat(opts).join(' && ')
365
367
  else
366
368
  cmd = [cmd, compose(opts, script: false)].compact.join(' ') unless opts == false || !respond_to?(:compose)
367
369
  end
@@ -388,13 +390,13 @@ module Squared
388
390
  def doc(*, sync: invoked_sync?('doc'), **)
389
391
  return unless @doc
390
392
 
391
- build(@doc, from: :doc, sync: sync)
393
+ build(*as_a(@doc), from: :doc, sync: sync)
392
394
  end
393
395
 
394
396
  def test(*, sync: invoked_sync?('test'), **)
395
397
  return unless @test
396
398
 
397
- build(@test, from: :test, sync: sync)
399
+ build(*as_a(@test), from: :test, sync: sync)
398
400
  end
399
401
 
400
402
  def clean(*, sync: invoked_sync?('clean'), **)
@@ -403,21 +405,21 @@ module Squared
403
405
  on :first, :clean
404
406
  case @clean
405
407
  when String
406
- run_s(@clean, from: :clean, sync: sync)
408
+ run(@clean, from: :clean, sync: sync)
407
409
  when Enumerable
408
- as_a(@clean).each do |val|
409
- if val =~ %r{[\\/]$}
410
- dir = Pathname.new(val.to_s)
411
- dir = basepath(dir) unless dir.absolute?
412
- next unless dir.directory?
413
-
414
- log.warn "rm -rf #{dir}"
415
- dir.rmtree
410
+ (@clean.is_a?(Hash) ? @clean.values : as_a(@clean)).each do |val|
411
+ val = val.to_s
412
+ path = basepath(val)
413
+ if path.directory? && val =~ %r{[\\/]\z}
414
+ log.warn "rm -rf #{path}"
415
+ path.rmtree(verbose: true)
416
416
  else
417
- files = val.include?('*') ? Dir[basepath(val)] : [basepath(val)]
418
- files.each do |file|
417
+ log.warn "rm #{path}"
418
+ (val.include?('*') ? Dir[path] : [path]).each do |file|
419
+ next unless File.file?(file)
420
+
419
421
  begin
420
- File.delete(file) if File.file?(file)
422
+ File.delete(file)
421
423
  rescue StandardError => e
422
424
  log.error e
423
425
  end
@@ -558,6 +560,12 @@ module Squared
558
560
  @prod != false && workspace.prod?(pat: @prod, **scriptargs)
559
561
  end
560
562
 
563
+ def exclude?(*refs)
564
+ return false if @exclude.empty?
565
+
566
+ refs.flatten.any? { |ref| @exclude.include?(ref) }
567
+ end
568
+
561
569
  def task_include?(key, ref = nil)
562
570
  workspace.task_include?(self, key, ref) && !@pass.include?(key.to_s)
563
571
  end
@@ -639,7 +647,7 @@ module Squared
639
647
  def run_s(*cmd, env: nil, sync: true, banner: verbose != false, from: nil, **kwargs)
640
648
  on :first, from if from
641
649
  begin
642
- cmd.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
650
+ cmd.flatten.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
643
651
  rescue StandardError => e
644
652
  ret = on(:error, from, e) if from
645
653
  raise unless ret == true
@@ -971,34 +979,30 @@ module Squared
971
979
  end
972
980
 
973
981
  def append_repeat(flag, opts, target: @session)
974
- opts.each { |val| target << shell_option(flag, val, quote: true) }
982
+ opts.each { |val| target << shell_option(flag, val) }
975
983
  end
976
984
 
977
- def append_value(opts, target: @session, delim: false, escape: true)
978
- return if opts.empty?
985
+ def append_value(*opts, target: @session, delim: false, escape: true, quote: false)
986
+ return if (opts = opts.flatten).empty?
979
987
 
980
988
  target << '--' if delim
981
- opts.each { |val| target << (escape ? shell_escape(val) : shell_quote(val)) }
989
+ opts.each { |val| target << (escape ? shell_escape(val, quote: quote) : shell_quote(val)) }
982
990
  end
983
991
 
984
992
  def append_hash(opts, target: @session)
985
993
  out = target.to_s
986
994
  opts.each do |key, val|
987
- key = key.to_s
988
- key = "--#{key}" unless key[0] == '-'
989
- next if out =~ Regexp.new(" #{key}(?: |=|$)")
995
+ next if out =~ / #{Regexp.escape(shell_option(key))}(?: |=|$)/
990
996
 
991
997
  case val
992
- when String
993
- append_repeat(key, [val], target: target)
994
998
  when Array
995
999
  append_repeat(key, val, target: target)
996
1000
  when Numeric
997
- target << (key + (key.start_with?('--') ? '=' : '') + val)
1001
+ target << basic_option(key, val)
998
1002
  when false
999
- target << key.sub(/^--(?!no-)/, '--no-')
1003
+ target << shell_option(key).sub(/^--(?!no-)/, '--no-')
1000
1004
  else
1001
- target << key
1005
+ target << shell_option(key, val.is_a?(String) ? val : nil)
1002
1006
  end
1003
1007
  end
1004
1008
  end
@@ -1013,6 +1017,7 @@ module Squared
1013
1017
  shell_quote(val)
1014
1018
  end)
1015
1019
  end
1020
+ nil
1016
1021
  end
1017
1022
 
1018
1023
  def append_option(list, target: @session, equals: false, quote: false, escape: true, **kwargs)
@@ -1097,7 +1102,7 @@ module Squared
1097
1102
  when Proc, Method
1098
1103
  cmd.call(*args, **opts)
1099
1104
  when String
1100
- run_s(cmd, **opts)
1105
+ run(cmd, **opts)
1101
1106
  end
1102
1107
  end
1103
1108
  end
@@ -9,7 +9,7 @@ module Squared
9
9
 
10
10
  def git(name, uri = nil, base: nil, repo: [], options: {})
11
11
  data = {}
12
- check = ->(proj) { proj.is_a?(Project::Git) && git_clone?(proj.path) }
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
15
  uri.each { |val| repo << proj if (proj = @project[val.to_s]) && check.(proj) }
@@ -569,7 +569,7 @@ module Squared
569
569
  list_result(ret, 'files', from: from, action: 'modified')
570
570
  end
571
571
 
572
- def reset(flag, files = [], ref: nil)
572
+ def reset(flag, files = nil, mode: nil, ref: nil)
573
573
  cmd = git_session 'reset'
574
574
  case flag
575
575
  when :mode
@@ -591,7 +591,7 @@ module Squared
591
591
  cmd << '--patch'
592
592
  end
593
593
  append_commit ref
594
- append_pathspec files unless files.empty?
594
+ append_pathspec files if files
595
595
  source
596
596
  end
597
597
 
@@ -746,7 +746,7 @@ module Squared
746
746
  break
747
747
  end
748
748
  raise_error('commit', 'work tree is not usable') unless origin && branch
749
- cmd = git_session 'commit', option('dry-run') && '--dry-run'
749
+ cmd = git_session('commit', option('dry-run') && '--dry-run', options: false)
750
750
  if amend
751
751
  cmd << '--amend'
752
752
  else
@@ -865,12 +865,16 @@ module Squared
865
865
  def show(objs, format: nil, opts: nil)
866
866
  cmd = git_session 'show'
867
867
  if format
868
- cmd << case (val = format.downcase)
869
- when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
870
- basic_option('format', val)
871
- else
872
- quote_option('pretty', format)
873
- end
868
+ case (val = format.downcase)
869
+ when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
870
+ cmd << basic_option('format', val)
871
+ else
872
+ if format =~ /^t?format:/ || format.include?('%')
873
+ cmd << quote_option('pretty', format)
874
+ else
875
+ objs << format
876
+ end
877
+ end
874
878
  end
875
879
  if opts
876
880
  append_hash opts
@@ -879,7 +883,7 @@ module Squared
879
883
  cmd << basic_option('abbrev', val) if (val = option('abbrev')) && val.to_i > 0
880
884
  banner = true
881
885
  end
882
- append_value objs
886
+ append_value(objs, delim: true)
883
887
  source(exception: false, banner: banner)
884
888
  end
885
889
 
@@ -894,7 +898,7 @@ module Squared
894
898
  end
895
899
 
896
900
  def ls_remote(flag, grep: nil)
897
- git_session 'ls-remote', " --#{flag}"
901
+ git_session 'ls-remote', "--#{flag}", '--refs'
898
902
  out, banner, from = source(io: true)
899
903
  print_item banner
900
904
  ret = write_lines(out, grep: grep)
@@ -902,7 +906,7 @@ module Squared
902
906
  end
903
907
 
904
908
  def ls_files(flag, grep: nil)
905
- git_session 'ls-files', " --#{flag}"
909
+ git_session 'ls-files', "--#{flag}"
906
910
  out, banner, from = source(io: true)
907
911
  print_item banner
908
912
  ret = write_lines(out, grep: grep)
@@ -1029,7 +1033,7 @@ module Squared
1029
1033
 
1030
1034
  target << quote_option($1, val.strftime('%F %T'))
1031
1035
  when 'recurse-submodules'
1032
- target << shell_option($1, $2, quote: false) unless modules
1036
+ target << basic_option($1, $2) unless modules
1033
1037
  when 'shallow-exclude', 'gpg-sign', 'signoff', 'strategy', 'strategy-option'
1034
1038
  target << shell_option($1, $2)
1035
1039
  when 'refmap', 'negotiation-tip'
@@ -1044,9 +1048,9 @@ module Squared
1044
1048
  end
1045
1049
  end
1046
1050
  if remote
1047
- target << shell_escape(remote, quote: true)
1051
+ append_value(remote, target: target, delim: true, quote: true)
1048
1052
  if (val = option('refspec', strict: true))
1049
- append_value(split_escape(val), escape: false)
1053
+ append_value(split_escape(val), target: target, escape: false)
1050
1054
  else
1051
1055
  target.merge(refspec)
1052
1056
  end
@@ -1060,7 +1064,7 @@ module Squared
1060
1064
 
1061
1065
  def append_commit(val, target: @session)
1062
1066
  val = val.to_s.strip
1063
- target << (val.empty? ? 'HEAD' : val)
1067
+ target << (val.empty? ? append_head(target: target) || 'HEAD' : val)
1064
1068
  end
1065
1069
 
1066
1070
  def append_pathspec(files = [], target: @session, expect: false, parent: false)
@@ -294,7 +294,7 @@ module Squared
294
294
  end
295
295
  cmd << '--prod' if flag && prod?
296
296
  if (val = option('public-hoist-pattern', ignore: false))
297
- split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt, quote: true) }
297
+ split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt) }
298
298
  end
299
299
  cmd << '--ignore-workspace' if env('NODE_WORKSPACES', equals: '0')
300
300
  append_nocolor
@@ -4,11 +4,11 @@ module Squared
4
4
  module Workspace
5
5
  module Project
6
6
  class Python < Git
7
- REQUIREMENTS = %w[requirements.txt pyproject.toml setup.py].freeze
7
+ REQUIREMENTS = %w[requirements.txt pyproject.toml].freeze
8
8
  OPT_INSTALL = %w[I U break-system-packages check-build-dependencies compile dry-run force-reinstall
9
9
  ignore-installed ignore-requires-python no-build-isolation no-clean no-compile no-deps
10
10
  no-index no-warn-conflicts no-warn-script-location pre prefer-binary require-hashes upgrade
11
- use-pep517 user abi=s config-settings=s c=s constraint=s e=s editable=s extra-index-url=s
11
+ use-pep517 user abi=s config-settings=s c=s constraint=s e=s? editable=s? extra-index-url=s
12
12
  f=s find-links=s global-option=s implementation=s i=s index-url=s no-binary=s only-binary=s
13
13
  platform=s prefix=s progress-bar=s python-version=s report=s r=s requirement=s
14
14
  root-user-action=s root=s src=s t=s target=s upgrade-strategy=s].freeze
@@ -37,7 +37,7 @@ module Squared
37
37
  def config?(val)
38
38
  return false unless (val = as_path(val))
39
39
 
40
- REQUIREMENTS.any? { |file| val.join(file).exist? }
40
+ (REQUIREMENTS + ['setup.py']).any? { |file| val.join(file).exist? }
41
41
  end
42
42
  end
43
43
 
@@ -79,7 +79,7 @@ module Squared
79
79
  when :target
80
80
  'dir'
81
81
  when :upgrade
82
- 'strategy'
82
+ 'strategy?,packages+'
83
83
  end)
84
84
  end
85
85
  case flag
@@ -104,47 +104,32 @@ module Squared
104
104
  if @depend && !flag
105
105
  super
106
106
  elsif outdated?
107
- case (type = dependtype)
108
- when 1, 2
109
- cmd = pip_session 'install'
110
- case flag
111
- when :user
112
- cmd << '--user'
113
- when :upgrade
114
- cmd << '--upgrade'
115
- case param
116
- when 'eager', 'only-if-needed'
117
- cmd << basic_option('upgrade-strategy', param)
118
- else
119
- opts << param
120
- end
121
- when :force
122
- cmd << '--force-reinstall'
123
- when :target
124
- cmd << shell_option('target', basepath(param), quote: true)
107
+ cmd = pip_session 'install'
108
+ case flag
109
+ when :user
110
+ cmd << '--user'
111
+ when :upgrade
112
+ cmd << '--upgrade'
113
+ case param
114
+ when 'eager', 'only-if-needed'
115
+ cmd << basic_option('upgrade-strategy', param)
125
116
  else
126
- append_global
117
+ opts << param
127
118
  end
128
- append_pip opts if flag
129
- if type == 2
119
+ when :force
120
+ cmd << '--force-reinstall'
121
+ when :target
122
+ cmd << quote_option('target', basepath(param))
123
+ else
124
+ append_global
125
+ end
126
+ append_pip flag, opts if flag
127
+ unless flag == :upgrade
128
+ if dependtype == 2 || cmd.find { |val| val =~ /^(?:-e|--editable)$/ }
130
129
  cmd << '.'
131
- elsif !cmd.find { |val| val =~ /^(?:-r|--requirement)/ }
130
+ elsif !cmd.find { |val| val =~ /^(?:-r|--requirement|-e|--editable)/ }
132
131
  cmd << '-r requirements.txt'
133
132
  end
134
- when 3
135
- cmd = python_session 'setup.py', 'install'
136
- case flag
137
- when :user
138
- cmd << '--user'
139
- when :target
140
- cmd << quote_option('build-base', basepath(dir))
141
- end
142
- if option('user')
143
- cmd << '--user'
144
- else
145
- append_first(%w[home prefix], equals: true, escape: false, quote: true, ignore: false)
146
- end
147
- cmd.delete('--user') if workspace.windows?
148
133
  end
149
134
  run(from: :depend, sync: sync)
150
135
  end
@@ -256,12 +241,12 @@ module Squared
256
241
  session('python', *cmd)
257
242
  end
258
243
 
259
- def append_pip(opts, list = nil, target: @session)
244
+ def append_pip(flag, opts, target: @session)
260
245
  append_nocolor(target: target)
261
246
  return if opts.empty?
262
247
 
263
248
  out = []
264
- opts, pat = option_partition(opts, list || (OPT_INSTALL + OPT_GENERAL), target: target)
249
+ opts, pat = option_partition(opts, OPT_INSTALL + OPT_GENERAL, target: target)
265
250
  opts.each do |opt|
266
251
  if opt =~ /^(v+|q+)$/
267
252
  cmd << "-#{$1}"
@@ -272,10 +257,10 @@ module Squared
272
257
  target << quote_option($1, basepath($2))
273
258
  when 'e', 'editable'
274
259
  val = $2
275
- target << quote_option($1, val =~ %r{^[a-z]+\+[a-z]+://} ? val : basepath(val))
260
+ target << quote_option($1, val =~ %r{^[a-z]+(?:\+[a-z]+)?://}i ? val : basepath(val))
276
261
  when 'proxy', 'config-settings', 'global-option', 'extra-index-url',
277
262
  'f', 'find-links', 'i', 'index-url'
278
- target << shell_option($1, $2, quote: true)
263
+ target << quote_option($1, $2)
279
264
  when 'retries', 'timeout'
280
265
  target << basic_option($1, $2) if $2.to_i > 0
281
266
  else
@@ -285,7 +270,11 @@ module Squared
285
270
  out << opt
286
271
  end
287
272
  end
288
- option_clear(out, target: target)
273
+ if flag == :upgrade
274
+ append_value(out, delim: true)
275
+ else
276
+ option_clear(out, target: target)
277
+ end
289
278
  end
290
279
 
291
280
  def append_global
@@ -297,7 +286,7 @@ module Squared
297
286
  quote_option('cache-dir', basepath(val))
298
287
  end
299
288
  end
300
- cmd << shell_option('proxy', val, quote: true) if (val = option('proxy'))
289
+ cmd << quote_option('proxy', val) if (val = option('proxy'))
301
290
  cmd << quote_option('python', basepath(val)) if (val = option('python'))
302
291
  append_nocolor
303
292
  end
@@ -482,6 +482,7 @@ module Squared
482
482
  end
483
483
 
484
484
  def bundle(cmd, *args)
485
+ args = args.flatten
485
486
  run_s(bundle_session(cmd, *args), from: :bundle)
486
487
  end
487
488
 
@@ -489,7 +490,8 @@ module Squared
489
490
  if cmd.empty?
490
491
  run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd)
491
492
  else
492
- run_s(*cmd.map { |val| rake_output(rakeapp, val) }, from: :rake, chdir: workspace.pwd, banner: false)
493
+ cmd = cmd.flatten.map { |val| rake_output(rakeapp, val) }
494
+ run_s(cmd, from: :rake, chdir: workspace.pwd, banner: false)
493
495
  end
494
496
  end
495
497
 
@@ -511,22 +513,24 @@ module Squared
511
513
  log.warn "using version #{val} (given #{@version})" if @version && @version != val
512
514
  @version = val
513
515
  end
514
- out = pwd_set { `#{gem_output('list', '--local', '-d', shell_escape(project, quote: true))}` }
515
- if (data = /#{Regexp.escape(project)} \(([^)]+)\)/.match(out))
516
- ver = data[1].split(/\s*,\s*/)
517
- ver.unshift(@version).uniq! if @version
518
- ver.each do |val|
519
- next unless (data = /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/.match(out))
520
-
521
- set.(val)
522
- break
516
+ if @version
517
+ out = pwd_set { `#{gem_output('list', '--local', '-d', shell_escape(project, quote: true))}` }
518
+ if (data = /#{Regexp.escape(project)} \(([^)]+)\)/.match(out))
519
+ ver = data[1].split(/\s*,\s*/)
520
+ ver.unshift(@version).uniq!
521
+ ver.each do |val|
522
+ next unless (data = /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/.match(out))
523
+
524
+ set.(val)
525
+ break
526
+ end
523
527
  end
524
528
  end
525
529
  unless data || RUBY_VERSION < '2.6'
526
530
  target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
527
531
  if (path = target.resolve_feature_path(project)&.last)
528
532
  gems = ['', 'gems', "#{project}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR)
529
- if (ver = Regexp.new(gems).match(path)) && (data = /\A(.+)#{gempath}/.match(path))
533
+ if (ver = Regexp.new(gems).match(path)) && (data = /\A(.+)#{gempath(ver[1])}/.match(path))
530
534
  set.(ver[1])
531
535
  end
532
536
  end
@@ -634,8 +638,8 @@ module Squared
634
638
  quote_option 'rakefile', Rake.application.rakefile
635
639
  end
636
640
 
637
- def gempath
638
- File.join('gems', "#{project}-#{@version}")
641
+ def gempath(val = @version)
642
+ File.join('gems', "#{project}-#{val}")
639
643
  end
640
644
 
641
645
  def gemoption(flag)
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.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-09 00:00:00.000000000 Z
10
+ date: 2025-02-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 3.6.2
109
+ rubygems_version: 3.6.3
110
110
  specification_version: 4
111
111
  summary: Rake task generator for managing multi-language workspaces.
112
112
  test_files: []