squared 0.8.2 → 0.8.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.
@@ -1529,8 +1529,7 @@ module Squared
1529
1529
  next if yarntype(exist: true) == 0
1530
1530
  when /^pnpm/
1531
1531
  next if pnpmtype(exist: true) == 0
1532
- when /^npm/
1533
- nil
1532
+ when /^npm/ then nil
1534
1533
  else
1535
1534
  next
1536
1535
  end
@@ -1584,8 +1583,8 @@ module Squared
1584
1583
  end
1585
1584
 
1586
1585
  def remove_modules(prefix: dependbin)
1587
- modules = basepath 'node_modules'
1588
- return false unless modules.directory? && confirm_basic('Remove?', modules, prefix: prefix)
1586
+ modules = basepath!('node_modules', type: 'd')
1587
+ return false unless modules && confirm_basic('Remove?', modules, prefix: prefix)
1589
1588
 
1590
1589
  modules.rmtree
1591
1590
  rescue Timeout::Error => e
@@ -36,9 +36,9 @@ module Squared
36
36
  root-user-action=b t|target=p upgrade-strategy=b].freeze,
37
37
  install_a: %w[no-index pre prefer-binary all-releases=b extra-index-url=q f|find-links=q i|index-url=q
38
38
  no-binary=q only-binary=q only-final=b].freeze,
39
- install_b: %w[build-constraint check-build-dependencies no-build-isolation no-clean no-deps require-hashes
40
- use-pep517 c|constraint=p group=q progress-bar=b r|requirement=p requirements-from-script=p
41
- src=p].freeze,
39
+ install_b: %w[check-build-dependencies no-build-isolation no-clean no-deps require-hashes use-pep517
40
+ build-constraint=p c|constraint=p group=q progress-bar=b r|requirement=p
41
+ requirements-from-script=p src=p].freeze,
42
42
  install_c: %w[C|config-settings=q e|editable=v].freeze,
43
43
  install_d: %w[ignore-requires-python uploaded-prior-to=q].freeze,
44
44
  hash: %w[a|algorithm].freeze,
@@ -181,8 +181,8 @@ module Squared
181
181
  format_desc action, nil, "script+|#{indexchar}index+|#,pattern*"
182
182
  task action, [:command] do |_, args|
183
183
  found = 0
184
- %w[tool.poetry.scripts tool.pdm.scripts project.scripts].each_with_index do |table, i|
185
- next if (list = read_pyproject(table)).empty?
184
+ %w[tool.poetry tool.pdm project].each_with_index do |table, i|
185
+ next if (list = read_pyproject("#{table}.scripts")).empty?
186
186
 
187
187
  if args.command == '#'
188
188
  format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: pyprojectfile)
@@ -208,7 +208,7 @@ module Squared
208
208
  log.warn "run script #{n} of #{list.size}".subhint('out of range')
209
209
  end
210
210
  else
211
- case i
211
+ case (i > 1 && poetry? ? 0 : i)
212
212
  when 0
213
213
  found |= 1
214
214
  run(session_output('poetry', 'run', val), from: :run)
@@ -297,7 +297,7 @@ module Squared
297
297
  install flag, ['upgrade', *args.to_a, 'pip']
298
298
  end
299
299
  when :freeze
300
- format_desc action, flag, "file?=#{DEP_PYTHON[4]},u/uninstall,opts*"
300
+ format_desc action, flag, "file?=#{DEP_PYTHON[4]},u/ninstall?,opts*"
301
301
  task flag do |_, args|
302
302
  opts = args.to_a
303
303
  if has_value!(opts, 'u', 'uninstall')
@@ -312,7 +312,7 @@ module Squared
312
312
  end
313
313
  file = pip(flag, opts: opts, banner: requirement.nil?, requirement: requirement)
314
314
  puts File.read(file) unless silent?
315
- if requirement && confirm_basic('Uninstall?', file)
315
+ if requirement && confirm_basic('Uninstall?', file, prefix: 'pip')
316
316
  pip(:uninstall, opts: ['y', "r=#{shell_quote(file)}"])
317
317
  end
318
318
  end
@@ -482,7 +482,7 @@ module Squared
482
482
  :patch
483
483
  end
484
484
  end
485
- '--not-required' if option('not-required', notequals: '0') && !env('PYTHON_DEFAULT')
485
+ '--not-required' if option('not-required', notequals: '0')
486
486
  end
487
487
  cmd << '--local' if option('l', 'local')
488
488
  append_global
@@ -607,18 +607,18 @@ module Squared
607
607
  project: self, strict: strict?, single: singleopt(flag))
608
608
  else
609
609
  op = append_pip(flag, opts, pipopts(:install), target: pip_session('install'))
610
- end
611
- case flag
612
- when :editable
613
- op << quote_option('e', op.pop || editable || '.')
614
- op.clear
615
- when :user, :upgrade
616
- op.concat(packages)
617
- raise ArgumentError, message('no packages listed', hint: flag) if op.empty?
610
+ case flag
611
+ when :editable
612
+ op << quote_option('e', op.pop || editable || '.')
613
+ op.clear
614
+ when :user, :upgrade
615
+ op.concat(packages)
616
+ raise ArgumentError, message('no packages listed', hint: flag) if op.empty?
618
617
 
619
- op << "--#{flag}"
620
- op.append
621
- python_session('-m pip', *op.to_a.drop(1)) if workspace.windows?
618
+ op << "--#{flag}"
619
+ op.append
620
+ python_session('-m pip', *op.to_a.drop(1)) if workspace.windows?
621
+ end
622
622
  end
623
623
  run(banner: banner, from: :install)
624
624
  end
@@ -723,7 +723,7 @@ module Squared
723
723
  op.clear(pass: false)
724
724
  else
725
725
  if op.empty?
726
- op << "#{dist.call}/*"
726
+ op.add_path(dist.call, '*')
727
727
  else
728
728
  op.add_path
729
729
  end
@@ -796,8 +796,7 @@ module Squared
796
796
 
797
797
  op << (action = op.shift)
798
798
  case action
799
- when 'dir', 'info', 'purge'
800
- nil
799
+ when 'dir', 'info', 'purge' then nil
801
800
  when 'list', 'remove'
802
801
  op.add_first(quote: true)
803
802
  else
@@ -811,8 +810,7 @@ module Squared
811
810
  action = op.shift
812
811
  op << action
813
812
  case action
814
- when 'list', 'edit', 'debug'
815
- nil
813
+ when 'list', 'edit', 'debug' then nil
816
814
  when 'get', 'unset', 'set'
817
815
  op.add_first
818
816
  op.add_first(quote: true, expect: true) if action == 'set'
@@ -923,6 +921,7 @@ module Squared
923
921
  if (target = append_nocolor('no-color', target: [], prefix: 'hatch'))
924
922
  (opts ||= []).concat(target)
925
923
  end
924
+ ENV['HATCH_ENV_TYPE_VIRTUAL_PATH'] ||= venv if venv?
926
925
  create_session('hatch', *cmd, common: OPT_HATCH[:common], opts: opts)
927
926
  end
928
927
 
@@ -1089,8 +1088,7 @@ module Squared
1089
1088
  /\A(?:v+|q+|b+|V+|O+)\z/
1090
1089
  when :pdm, :poetry
1091
1090
  /\Av+\z/
1092
- when :twine, :meson
1093
- nil
1091
+ when :twine, :meson then nil
1094
1092
  else
1095
1093
  /\A(?:v+|q+)\z/
1096
1094
  end
@@ -1214,7 +1212,22 @@ module Squared
1214
1212
  args << 'setuptools' << 'wheel'
1215
1213
  end
1216
1214
  pip(:install, *args, banner: false) unless args.empty?
1217
- success?(ret, banner, !status) { |out| puts(out && dir.directory? ? "Success: #{dir}" : 'Failed') }
1215
+ success?(ret, banner, !status) do |out|
1216
+ if out && dir.directory?
1217
+ if poetry?
1218
+ dir += (workspace.windows? ? 'Scripts/python.exe' : 'bin/python')
1219
+ cmd = poetry_session 'env use'
1220
+ else
1221
+ puts "Success: #{dir}"
1222
+ return
1223
+ end
1224
+ cmd << shell_quote(dir)
1225
+ print_run cmd, silent?
1226
+ run(banner: false)
1227
+ else
1228
+ puts 'Failed'
1229
+ end
1230
+ end
1218
1231
  end
1219
1232
 
1220
1233
  def venv_package?(val)
@@ -26,14 +26,14 @@ module Squared
26
26
  rbs: %w[I=pm r=bm no-collection no-stdlib collection=p log-level=b log-output=p repo=p].freeze,
27
27
  rubocop: %w[D P r=bm auto-gen-config a|autocorrect A|autocorrect-all d|debug disable-pending-cops
28
28
  display-only-correctable display-only-fail-level-offenses display-only-failed
29
- display-only-safe-correctable S|display-style-guide display-time editor-mode enable-pending-cops
30
- E|extra-details F|fail-fast force-default-config force-exclusion x|fix-layout
29
+ display-only-safe-correctable S|display-style-guide display-time disable-uncorrectable editor-mode
30
+ enable-pending-cops E|extra-details F|fail-fast force-default-config force-exclusion x|fix-layout
31
31
  ignore-disable-comments ignore-parent-exclusion ignore-unrecognized-cops init l|lint
32
- L|list-target-files lsp memory no-detach only-guide-cops only-recognized-file-types
33
- no-exclude-limit profile raise-cop-error regenerate-todo restart-server safe server-status
34
- start-server stderr stop-server C|cache=b cache-root=p config=p exclude-limit=i fail-level=b
35
- f|format=b except=q only=q o|out=p plugin=p require=p show-cops=q show-docs-url=q
36
- s|stdin=p].freeze,
32
+ list-enabled-cops-for=p L|list-target-files lsp memory no-detach only-guide-cops
33
+ only-recognized-file-types no-exclude-limit profile raise-cop-error regenerate-todo
34
+ restart-server safe server-status start-server stderr stop-server C|cache=b cache-root=p config=p
35
+ exclude-limit=i fail-level=b f|format=b except=q only=q o|out=p plugin=p require=p show-cops=q
36
+ show-docs-url=q s|stdin=p].freeze,
37
37
  pry: %w[f e=q I=pm no-color no-history no-multiline no-pager no-plugins simple-prompt c|context=q
38
38
  d|disable-plugin=q gem=b r|require=bm s|select-plugin=q].freeze,
39
39
  no: {
@@ -511,8 +511,7 @@ module Squared
511
511
  opts << 'redownload' if has_value!(opts, 'f', 'force')
512
512
  if (lock = basepath!('Gemfile.lock'))
513
513
  case (val = ENV['BUNDLE_FROZEN'])
514
- when '0', 'false'
515
- nil
514
+ when '0', 'false' then nil
516
515
  else
517
516
  if val
518
517
  print_error("BUNDLE_FROZEN: #{val}", loglevel: Logger::INFO, subject: name, hint: flag)
@@ -783,8 +782,7 @@ module Squared
783
782
  next if val == '0' || val == 'false'
784
783
 
785
784
  run(bundle_output('binstubs --all', case val
786
- when '1', 'true'
787
- nil
785
+ when '1', 'true' then nil
788
786
  else
789
787
  if val.start_with?('~')
790
788
  val = File.join(Dir.home, val == '~' ? '.bundle' : val[1..-1])
@@ -1076,6 +1074,7 @@ module Squared
1076
1074
  filter = kwargs.fetch(:filter, {})
1077
1075
  semver = filter[:semver]
1078
1076
  equals = filter[:equals]
1077
+ dryrun = filter[:dryrun] || dryrun?(prefix: 'gem')
1079
1078
  update = if sync && filter[:select]
1080
1079
  semver ||= 'major'
1081
1080
  items = []
@@ -1232,7 +1231,7 @@ module Squared
1232
1231
  'user-install'
1233
1232
  end
1234
1233
  end
1235
- if filter[:dryrun]
1234
+ if dryrun
1236
1235
  print_run gem_output('update -f', *update.quote!(escape: true)), false
1237
1236
  else
1238
1237
  gem(:update, *update, opts: opts)
@@ -1275,9 +1274,9 @@ module Squared
1275
1274
  .clear(pass: false)
1276
1275
  end
1277
1276
  when :push
1278
- target = gemname
1279
- if op.empty? || (n = op.index(':'))
1280
- file = basepath(if !n && (spec = gemspec)
1277
+ target = nil
1278
+ if op.empty? || ia
1279
+ file = basepath(if !ia && (spec = gemspec)
1281
1280
  "#{spec.name}-#{spec.version}.gem"
1282
1281
  else
1283
1282
  choice_index 'Select a file', Dir.glob('*.gem', base: path)
@@ -1296,7 +1295,7 @@ module Squared
1296
1295
 
1297
1296
  op.add_path(file)
1298
1297
  end
1299
- return run(from: from, interactive: ['Push', 'N', target]) unless with || !banner
1298
+ return run(from: from, interactive: ['Push', 'N', target || gemname]) unless with || !banner
1300
1299
  when :exec
1301
1300
  min = if op.arg?('g', 'gem')
1302
1301
  1
@@ -1939,8 +1938,7 @@ module Squared
1939
1938
  val = case (val = $2)
1940
1939
  when 'true'
1941
1940
  true
1942
- when '', '[]'
1943
- nil
1941
+ when '', '[]' then nil
1944
1942
  else
1945
1943
  if val =~ /\A\[:(.+)\]\z/
1946
1944
  $1.split(', :').map { |s| (s[/\A"(.+)"\z/, 1] || s).to_sym }
@@ -27,7 +27,15 @@ module Squared
27
27
  target << '--' if delim && !target.include?('--')
28
28
  if strip
29
29
  pat, s = Array(strip)
30
- ret.map! { |val| val.is_a?(String) ? val.gsub(pat, s || '') : val }
30
+ ret.map! do |val|
31
+ next val unless val.is_a?(String)
32
+
33
+ if pat.is_a?(String) && pat.size == 1 && s.nil?
34
+ val.delete_prefix(pat)
35
+ else
36
+ val.gsub(pat, s || '')
37
+ end
38
+ end
31
39
  end
32
40
  if filter
33
41
  ret, err = ret.partition { |val| filter.match?(val.to_s) }
@@ -162,8 +170,11 @@ module Squared
162
170
  end
163
171
 
164
172
  def pattern?(val)
173
+ Regexp.new(val)
165
174
  val.start_with?('\A', '^') || val.end_with?('\z', '$') ||
166
175
  val.match?(/[.)][*+?]|\(\?[:=!><]|\\[dsw\d]|\[.+\]|\{\d+,?\d*\}/i)
176
+ rescue RegexpError
177
+ false
167
178
  end
168
179
 
169
180
  private
@@ -582,7 +593,11 @@ module Squared
582
593
  val = val.delete_prefix(prefix) if prefix
583
594
  if strip
584
595
  pat, s = Array(strip)
585
- val = val.gsub(pat, s || '')
596
+ val = if pat.is_a?(String) && pat.size == 1 && s.nil?
597
+ val.delete_prefix(pat)
598
+ else
599
+ val.gsub(pat, s || '')
600
+ end
586
601
  end
587
602
  end
588
603
  unless block_given? && !(val = yield val).is_a?(String)
@@ -184,8 +184,7 @@ module Squared
184
184
  end
185
185
  env('REPO_GROUPS', **envargs) do |val|
186
186
  g = case val
187
- when '0', 'false'
188
- nil
187
+ when '0', 'false' then nil
189
188
  else
190
189
  val
191
190
  end
@@ -314,9 +313,7 @@ module Squared
314
313
  i = -1
315
314
  n = repo_scriptdata(proj, name).reduce(0) do |a, b|
316
315
  i += 1
317
- next a unless b
318
-
319
- a + (1 << i)
316
+ b ? a + (1 << i) : a
320
317
  end
321
318
  proj.global(n) && (pass || g.include?(proj.group) || r.any? { |val| proj.ref?(val) })
322
319
  end
@@ -362,7 +359,7 @@ module Squared
362
359
  def repo_install?(dir = root, parent: false)
363
360
  return true if root?(dir, pass: ['.repo']) || dir.join('.repo').directory?
364
361
 
365
- parent && root.children.none? { |ent| ent.directory? && ent.basename.to_s[0] != '.' && ent != home }
362
+ parent && root.children.none? { |ent| ent.directory? && ent != home }
366
363
  end
367
364
  end
368
365
 
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.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 4.0.15
128
+ rubygems_version: 4.0.18
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []