squared 0.4.33 → 0.4.34

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: cc4c3610fd67d9cf3afa29add2ea865f0fbe13e075c384cb746f5074c473f7ef
4
- data.tar.gz: 6328ffe0d303b321d8663a53c6d0c59b3b758bfb881d693c2d7ac5b322961db4
3
+ metadata.gz: 0d59b575971efdb7998b924fa5ca7815c4aeaeeaeecb756197fbc79b11433743
4
+ data.tar.gz: 9cb428fb205f51803c0b7576b71d78165a8987925f90c04462c266bd03ca48b9
5
5
  SHA512:
6
- metadata.gz: 5e7c0fdee86fd208433ed3736383a1cd0bac10792fdbdb1e8e3c4829b9d77e78e02d603a79efe81b1b4c5944159bfd464aad9ccc834aeeea1431508554c0fc14
7
- data.tar.gz: cfb6cc7335731677c8643ef3667dcb03707c6d3f9c7c1285f1ecf89c7f75ec827083c687a57449bd94d75d5881bf542031d430325035f594ba3300caa21faf64
6
+ metadata.gz: 5504784e072989e9e4a25ee08aa2f8bc5b9b73d4476aa9ad5d4633b08b2546847b9945de201f964b04a52124b2e75bc2f9341321348f429e2dc9ea0c4bae3fd8
7
+ data.tar.gz: 73786a35bd4255024f235090cc8b11883b95efa8903e2034b8f5d13353fb7a7756ed8d8d335f42756232d595a00bf10cdafb099c3065906617575e3cd035bebf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.34] - 2025-12-26
4
+
5
+ ### Added
6
+
7
+ - Project public base method scope for nested tasks was created.
8
+ - Ruby task copy can autodetect "env" using [GEM_HOME|GEM_ROOT].
9
+
10
+ ### Changed
11
+
12
+ - Python virtual environment did not install poetry during initialization.
13
+
14
+ ### Fixed
15
+
16
+ - Workspace global banner never referenced the correct hash key.
17
+ - Python task depend without editable did not append context directory.
18
+ - Docker task build did not parse DOCKER_OPTIONS as command options.
19
+ - Project base method build did not call Method routines.
20
+ - Bundler autodetect did not check for valid gems directory.
21
+ - Ruby copy to version detection did not check for valid gemspec.
22
+
3
23
  ## [0.4.33] - 2025-12-07
4
24
 
5
25
  ### Added
@@ -1144,6 +1164,7 @@
1144
1164
 
1145
1165
  - Changelog was created.
1146
1166
 
1167
+ [0.4.34]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.34
1147
1168
  [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
1148
1169
  [0.4.32]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.32
1149
1170
  [0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
@@ -60,7 +60,7 @@ module Squared
60
60
  while (ch = Readline.readline(msg))
61
61
  unless (ch = ch.strip).empty?
62
62
  if multiple
63
- a = ch.split(/\s*,\s*/)
63
+ a = ch.split(',').map!(&:strip)
64
64
  b = a.select { |s| valid.call(s) }.map!(&:to_i).sort
65
65
  next unless a.size == b.size
66
66
  return items ? b.map! { |i| items[i - 1] } : b unless multiple.is_a?(::Numeric) && multiple != b.size
@@ -110,6 +110,7 @@ module Squared
110
110
  end
111
111
 
112
112
  def shell_bin(name, env: true)
113
+ require_relative 'base'
113
114
  key = name.to_s.upcase
114
115
  key = File.basename(key, '.*') if Rake::Win32.windows?
115
116
  shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.33'
4
+ VERSION = '0.4.34'
5
5
  end
@@ -274,9 +274,9 @@ module Squared
274
274
 
275
275
  def pass(name, group: @group, ref: @ref, &blk)
276
276
  data = if group
277
- @pass[:group][group]
277
+ @pass[:group][group.to_s]
278
278
  elsif ref
279
- @pass[:ref][ref]
279
+ @pass[:ref][ref.to_sym]
280
280
  else
281
281
  @pass[:global]
282
282
  end
@@ -573,7 +573,7 @@ module Squared
573
573
  return ret if group && (ret = @banner[:group][group.to_sym])
574
574
 
575
575
  ref.reverse_each { |val| return ret if (ret = @banner[:ref][val]) }
576
- @banner[:ref][:'']
576
+ @banner[:ref][:_]
577
577
  end
578
578
 
579
579
  def enabled?
@@ -460,8 +460,14 @@ module Squared
460
460
  cmd = []
461
461
  var = {}
462
462
  args.each do |val|
463
- next instance_exec(*val[1..-1], &val.first) if val.first.is_a?(Proc)
464
-
463
+ case val.first
464
+ when Proc
465
+ instance_exec(*val[1..-1], &val.first)
466
+ next
467
+ when Method
468
+ val.first.call(*val[1..-1])
469
+ next
470
+ end
465
471
  a, b, c, d, e = val
466
472
  case b
467
473
  when Hash
@@ -859,6 +865,12 @@ module Squared
859
865
  end
860
866
  end
861
867
 
868
+ def scope(*args, **kwargs, &blk)
869
+ namespace name do
870
+ task(*args, **kwargs, &blk)
871
+ end
872
+ end
873
+
862
874
  def variable_set(key, *args, **kwargs, &blk)
863
875
  if variables.include?(key) || blocks.include?(key)
864
876
  val = case args.size
@@ -891,7 +903,8 @@ module Squared
891
903
  when :env
892
904
  run_set(output[0], *args, **kwargs)
893
905
  when :dependfile
894
- @dependfile = basepath(*args)
906
+ @dependindex = nil
907
+ @dependfile = val.nil? ? nil : basepath(*args)
895
908
  else
896
909
  if block_given?
897
910
  if blocks.include?(key)
@@ -262,21 +262,20 @@ module Squared
262
262
  def compose(opts, flags = nil, script: false, args: nil, from: :run, **)
263
263
  return opts if script == false
264
264
 
265
- ret = docker_session
266
265
  if from == :run
267
266
  if bake?(n = filetype)
268
- ret << 'buildx bake'
267
+ ret = docker_session 'buildx bake'
269
268
  append_file n
270
269
  from = :bake
271
270
  elsif compose?(n)
272
- ret << 'compose build'
271
+ ret = docker_session 'compose build'
273
272
  append_file n
274
273
  from = :compose
275
274
  else
276
- ret << 'build'
275
+ ret = docker_session 'build'
277
276
  end
278
277
  else
279
- ret << from
278
+ ret = docker_session from
280
279
  end
281
280
  case opts
282
281
  when String
@@ -1835,7 +1835,7 @@ module Squared
1835
1835
  return args ? [IO.popen(cmd), banner || '', from] : IO.popen(cmd)
1836
1836
  elsif stdin? ? sync : stdout
1837
1837
  print_item banner unless multiple
1838
- ret = `#{cmd}`
1838
+ ret = `#{cmd}`.chomp
1839
1839
  if !ret.empty?
1840
1840
  puts ret
1841
1841
  elsif success?(!banner.nil?)
@@ -27,7 +27,8 @@ module Squared
27
27
  use-running-store-server use-store-server child-concurrency=i hoist-pattern=q lockfile-dir=p
28
28
  modules-dir=p network-concurrency=i package-import-method=b public-hoist-pattern=q
29
29
  reporter=b].freeze,
30
- install_base: %w[global-dir ignore-scripts offline prefer-offline store-dir=p virtual-store-dir=p].freeze,
30
+ install_base: %w[dangerously-allow-all-builds global-dir ignore-scripts offline prefer-offline store-dir=p
31
+ virtual-store-dir=p].freeze,
31
32
  install_no: %w[frozen-lockfile verify-store-integrity].freeze,
32
33
  install_as: %w[D|dev no-optional P|prod].freeze,
33
34
  update: %w[g|global i|interactive L|latest depth=i].freeze,
@@ -448,6 +449,7 @@ module Squared
448
449
  split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt) }
449
450
  end
450
451
  cmd << '--ignore-workspace' if env('NODE_WORKSPACES', equals: '0')
452
+ cmd << '--dangerously-allow-all-builds' if option('approve-builds')
451
453
  append_nocolor
452
454
  else
453
455
  cmd = session 'npm', 'install'
@@ -30,15 +30,15 @@ module Squared
30
30
  OPT_POETRY = {
31
31
  common: %w[ansi no-ansi no-cache n|no-interaction no-plugins q|quiet v|verbose P|project=p].freeze,
32
32
  build: %w[clean config-settings=qq f|format=b o|output=p].freeze,
33
- publish: %w[build dry-run skip-existing cert=p client-cert=p dist-dir=p p|password=b r|repository=b
34
- u|username=b].freeze
33
+ publish: %w[build dry-run skip-existing cert=p client-cert=p dist-dir=p p|password=q r|repository=b
34
+ u|username=qq].freeze
35
35
  }.freeze
36
36
  OPT_PDM = {
37
37
  common: %w[I|ignore-python no-cache n|non-interactive].freeze,
38
38
  build: %w[C=bm no-clean no-isolation no-sdist no-wheel quiet verbose config-setting=q d|dest=p p|project=p
39
39
  k|skip=b].freeze,
40
40
  publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
41
- i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
41
+ i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=qq].freeze
42
42
  }.freeze
43
43
  OPT_HATCH = {
44
44
  common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
@@ -50,7 +50,7 @@ module Squared
50
50
  OPT_TWINE = {
51
51
  publish: %w[attestations disable-progress-bar non-interactive s|sign skip-existing verbose cert=p
52
52
  client-cert=p c|comment=q config-file=p i|identity=b p|password=q r|repository=b repository-url=q
53
- sign-with=b u|username=q].freeze
53
+ sign-with=b u|username=qq].freeze
54
54
  }.freeze
55
55
  private_constant :DEP_PYTHON, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :OPT_POETRY, :OPT_PDM, :OPT_HATCH, :OPT_TWINE
56
56
 
@@ -343,6 +343,7 @@ module Squared
343
343
  cmd << '--no-root' if option('no-root')
344
344
  else
345
345
  cmd = pip_session 'install'
346
+ cmd << '--upgrade-strategy=eager' if env('PYTHON_UPDATE')
346
347
  if flag
347
348
  case flag
348
349
  when :user
@@ -497,7 +498,6 @@ module Squared
497
498
  if !ENV['HATCH_BUILD_LOCATION'] && (outdir ||= op.shift)
498
499
  op.add_path(outdir)
499
500
  end
500
- op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
501
501
  else
502
502
  unless op.empty?
503
503
  args = case flag
@@ -573,17 +573,21 @@ module Squared
573
573
  def variable_set(key, *val, **)
574
574
  case key
575
575
  when :dependfile
576
- req = basepath(*val)
577
- if (index = DEP_PYTHON.index(req.basename.to_s))
578
- @dependindex = index
579
- @dependfile = req
576
+ if val.first.nil?
577
+ super
580
578
  else
581
- log.warn "variable_set: @#{key}=#{req} (not supported)"
579
+ req = basepath(*val)
580
+ if (index = DEP_PYTHON.index(req.basename.to_s))
581
+ @dependindex = index
582
+ @dependfile = req
583
+ else
584
+ log.warn "variable_set: @#{key}=#{req} (not supported)"
585
+ end
582
586
  end
583
587
  when :editable
584
588
  editable_set val.first
585
589
  when :venv
586
- instance_variable_set(:"@#{key}", val.empty? ? nil : basepath(*val))
590
+ @venv = val.empty? || val.first.nil? ? nil : basepath(*val)
587
591
  else
588
592
  super
589
593
  end
@@ -604,10 +608,11 @@ module Squared
604
608
  end
605
609
 
606
610
  def python_session(*cmd, opts: nil)
607
- return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
611
+ pre = preopts(quiet: false)
612
+ return session('python', *pre, *cmd, path: venv.nil?) unless opts
608
613
 
609
614
  op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: singleopt(:python))
610
- ret = session('python', *op.to_a, *cmd, path: venv.nil?)
615
+ ret = session('python', *pre, *op.to_a, *cmd, path: venv.nil?)
611
616
  [ret, op.extras]
612
617
  end
613
618
 
@@ -630,8 +635,8 @@ module Squared
630
635
  def create_session(*cmd, name:, common:, opts: nil)
631
636
  return session(name, *preopts, *cmd, path: venv.nil?) unless opts
632
637
 
633
- op = OptionPartition.new(opts, common, project: self, single: singleopt)
634
- ret = session(name, *op.to_a, *cmd, path: venv.nil?)
638
+ op = OptionPartition.new(opts, common, project: self, single: singleopt(name.to_sym))
639
+ ret = session(name, *preopts, *op.to_a, *cmd, path: venv.nil?)
635
640
  [ret, op.extras]
636
641
  end
637
642
 
@@ -685,14 +690,16 @@ module Squared
685
690
  OptionPartition.delete_key(target, 'e', 'editable')
686
691
  case val
687
692
  when '0', 'false'
688
- return
693
+ return unless installable?
689
694
  else
690
695
  val = basepath val
691
696
  end
692
- elsif session_arg?('e', 'editable', target: target) || !(val = editable)
697
+ elsif session_arg?('e', 'editable', target: target) || !installable?
693
698
  return
699
+ else
700
+ val = editable
694
701
  end
695
- target << quote_option('e', basepath(val))
702
+ target << (val ? quote_option('e', basepath(val)) : '.')
696
703
  end
697
704
 
698
705
  def append_global(target: @session)
@@ -868,6 +875,7 @@ module Squared
868
875
  .clear(pass: false)
869
876
  status = op.arg?(/\A-v+\z/)
870
877
  run(op, env, exception: true, banner: banner)
878
+ install(:upgrade, ['poetry']) if poetry?
871
879
  puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
872
880
  end
873
881
 
@@ -868,8 +868,11 @@ module Squared
868
868
  when 'asdf'
869
869
  val = pwd_set { `asdf where ruby` }
870
870
  self.gemdir = File.join(val, 'lib/ruby/gems', "#{$1}.0") if val =~ /(\d\.\d)\.[^.]+$/
871
+ when 'env'
872
+ ENV['GEM_HOME'] || ENV['GEM_ROOT']
871
873
  when /bundler?/
872
- self.gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
874
+ path = pwd_set { `bundle env` }[/^\s+Gem Path\s+(.+)$/, 1]
875
+ self.gemdir = path.split(File::PATH_SEPARATOR).find { |val| Dir.exist?(val) }
873
876
  end
874
877
  rescue StandardError => e
875
878
  log.debug e
@@ -879,25 +882,25 @@ module Squared
879
882
  return false unless @autodetect
880
883
 
881
884
  set = lambda do |val, path|
882
- if (ver = version) && ver != val
883
- log.warn "using version #{val} (given #{ver})"
884
- end
885
+ base = Pathname.new(path.strip)
886
+ return false unless base.join(gempath(val, 'specification')).exist?
887
+
888
+ log.warn "using version #{val} (given #{version})" if version && version != val
885
889
  self.version = val
886
- self.gemdir = Pathname.new(path.strip) + gempath
890
+ self.gemdir = base + gempath
887
891
  end
888
892
  if version
889
893
  opt = gempwd
890
894
  pwd_set(pass: !opt.nil?) do
891
895
  out = `#{gem_output(opt, 'list --local -d', gemname)}`
892
- if out =~ /#{Regexp.escape(gemname)} \(([^)]+)\)/
896
+ if out =~ /#{Regexp.escape(gemname)}\s+\((.+)\)$/
893
897
  split_escape($1)
894
898
  .unshift(@version)
895
899
  .uniq
896
900
  .each do |val|
897
- next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
901
+ next unless out =~ /(?:\(#{Regexp.escape(val)}[^)]*\)|Installed at):\s+(.+)$/
898
902
 
899
- set.call(val, $1)
900
- return gemdir? if gemdir
903
+ return gemdir? if set.call(val, $1)
901
904
  end
902
905
  end
903
906
  end
@@ -1050,8 +1053,10 @@ module Squared
1050
1053
  end
1051
1054
  end
1052
1055
 
1053
- def gempath(val = version)
1054
- File.join('gems', "#{gemname}-#{val}")
1056
+ def gempath(val = version, dir = 'gems')
1057
+ ret = File.join(dir, "#{gemname}-#{val}")
1058
+ ret += '.gemspec' if dir == 'specifications'
1059
+ ret
1055
1060
  end
1056
1061
 
1057
1062
  def gemdir?
@@ -135,9 +135,9 @@ module Squared
135
135
 
136
136
  def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
137
137
  :merge, :compact, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
138
- def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
139
- :pop, :push, :concat, :index, :join, :map, :map!, :detect, :select, :select!, :reject, :size,
140
- :delete_at
138
+ def_delegators :@extras, :empty?, :member?, :each, :each_with_index, :each_with_object, :partition, :dup,
139
+ :first, :last, :shift, :unshift, :pop, :push, :concat, :index, :join, :map, :map!, :detect,
140
+ :select, :select!, :reject, :size
141
141
 
142
142
  def_delegator :@extras, :delete, :remove
143
143
  def_delegator :@extras, :delete_at, :remove_at
@@ -228,10 +228,10 @@ module Squared
228
228
  return false unless root.directory?
229
229
 
230
230
  path = sub_style(root, styles: theme[:inline])
231
+ timeout = env('REPO_TIMEOUT').to_i
232
+ timeout = 15 unless timeout > 0
231
233
  @repo_override = Common::Prompt.confirm(
232
- "#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation? [y/N] ",
233
- 'N',
234
- timeout: env('REPO_TIMEOUT', 15, ignore: '0')
234
+ "#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation? [y/N] ", 'N', timeout: timeout
235
235
  )
236
236
  end
237
237
 
@@ -31,7 +31,10 @@ module Squared
31
31
  end
32
32
  elsif (data = TASK_BATCH[obj])
33
33
  args.each { |ref| data.delete(ref) }
34
- TASK_KEYS.delete(obj) if data.empty?
34
+ if data.empty?
35
+ TASK_KEYS.delete(obj)
36
+ TASK_BATCH.delete(obj)
37
+ end
35
38
  end
36
39
  end
37
40
 
@@ -40,6 +43,7 @@ module Squared
40
43
  obj.each { |key, val| TASK_ALIAS[key][ref] = val }
41
44
  elsif TASK_ALIAS.key?(obj)
42
45
  TASK_ALIAS[obj].delete(ref)
46
+ TASK_ALIAS.delete(obj) if TASK_ALIAS[obj].empty?
43
47
  end
44
48
  end
45
49
 
@@ -191,7 +195,7 @@ module Squared
191
195
  TASK_EXTEND[key].each do |kind|
192
196
  next unless obj.is_a?(kind)
193
197
 
194
- if kind.instance_methods.include?(meth)
198
+ if kind.method_defined?(meth)
195
199
  out = obj.__send__(meth)
196
200
  return true if out == 1
197
201
  return out if obj.ref?(kind.ref)
@@ -232,7 +236,7 @@ module Squared
232
236
  end
233
237
 
234
238
  def exclude?(key, empty = false)
235
- @exclude.include?(key) || (empty && @data[key].empty?)
239
+ @exclude.include?(key) || (empty && (!@data.key?(key) || @data[key].empty?))
236
240
  end
237
241
 
238
242
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.33
4
+ version: 0.4.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham