squared 0.8.5 → 0.9.0.pre1

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.
@@ -53,7 +53,7 @@ module Squared
53
53
  opts = options
54
54
  val.is_a?(String) ? val : key.to_s
55
55
  end
56
- unless uri.match?(GIT_PROTO) || Pathname.new(uri).absolute?
56
+ unless uri.match?(GIT_PROTO) || File.absolute_path?(uri)
57
57
  if uri.start_with?('.')
58
58
  uri = rootpath uri
59
59
  elsif base
@@ -135,8 +135,7 @@ module Squared
135
135
  def rev_write(name = nil, data = nil, sync: true, utc: nil)
136
136
  return unless @revfile
137
137
 
138
- sleep 0 while !sync && @revlock
139
- @revlock = true
138
+ (@revlock ||= Monitor.new).enter unless sync
140
139
  if name
141
140
  data&.each { |key, val| rev_entry(name, key, val: val) }
142
141
  rev_timeutc(name, utc) if utc
@@ -145,7 +144,7 @@ module Squared
145
144
  rescue => e
146
145
  warn log_warn(e, pass: true) if warning
147
146
  ensure
148
- @revlock = false
147
+ @revlock.exit unless sync
149
148
  end
150
149
  end
151
150
 
@@ -204,6 +203,8 @@ module Squared
204
203
  X|strategy-option=b].freeze,
205
204
  rm: %w[r cached f|force n|dry-run ignore-unmatch pathspec-file-nul q|quiet sparse
206
205
  pathspec-from-file=p].freeze,
206
+ show: %w[t combined-all-paths no-diff-merges remerge-diff show-notes-by-default show-signature diff-merges=b
207
+ encoding=b expand-tabs=i notes=q show-notes=q?].freeze,
207
208
  'sparse-checkout': %w[cone sparse-index no-cone no-sparse-index skip-checks].freeze
208
209
  }.freeze,
209
210
  log: {
@@ -270,8 +271,6 @@ module Squared
270
271
  branches=q? default=q disambiguate=b exclude=q exclude-hidden=b git-path=p glob=q
271
272
  output-object-format=b path-format=b? prefix=q remotes=q? resolve-git-dir=p short=i?
272
273
  show-object-format=b? since=q tags=q? until=q].freeze,
273
- show: %w[t combined-all-paths no-diff-merges remerge-diff show-notes-by-default show-signature diff-merges=b
274
- encoding=b expand-tabs=i notes=q show-notes=q?].freeze,
275
274
  sparse_checkout: {
276
275
  add: %w[skip-checks].freeze,
277
276
  clean: %w[n f v].freeze
@@ -370,7 +369,7 @@ module Squared
370
369
  'range-diff' => %i[view between contain].freeze,
371
370
  'fetch' => %i[origin remote all].freeze,
372
371
  'files' => %i[cached modified deleted others].freeze,
373
- 'git' => %i[add blame clean grep mv revert rm sparse-checkout status].freeze,
372
+ 'git' => %i[add blame clean grep mv revert rm show sparse-checkout status].freeze,
374
373
  'log' => %i[grep view between contain].freeze,
375
374
  'merge' => %i[commit no-commit send].freeze,
376
375
  'pull' => %i[origin remote all].freeze,
@@ -381,7 +380,6 @@ module Squared
381
380
  'reset' => %i[commit index patch mode undo].freeze,
382
381
  'restore' => %i[source staged worktree].freeze,
383
382
  'rev' => %i[commit branch build output].freeze,
384
- 'show' => %i[format oneline textconv].freeze,
385
383
  'sparse-checkout' => %i[add reapply list clean disable].freeze,
386
384
  'stash' => %i[push pop apply drop command].freeze,
387
385
  'submodule' => %i[status update branch url sync].freeze,
@@ -814,11 +812,6 @@ module Squared
814
812
  end
815
813
  branch(flag, refs: refs, remote: remote)
816
814
  end
817
- when :list
818
- format_desc action, flag, 'opts*,pattern*'
819
- task flag do |_, args|
820
- branch flag, args.to_a
821
- end
822
815
  when :move, :copy
823
816
  format_desc action, flag, 'branch,oldbranch?'
824
817
  task flag, [:branch, :oldbranch] do |_, args|
@@ -832,9 +825,9 @@ module Squared
832
825
  branch(flag, refs: [oldbranch, branch])
833
826
  end
834
827
  else
835
- format_desc action, flag
836
- task flag do
837
- branch flag
828
+ format_desc(action, flag, ('opts*,pattern*' if flag == :list))
829
+ task flag do |_, args|
830
+ branch flag, args.to_a
838
831
  end
839
832
  end
840
833
  when 'clone'
@@ -914,25 +907,6 @@ module Squared
914
907
  reset flag
915
908
  end
916
909
  end
917
- when 'show'
918
- case flag
919
- when :oneline
920
- format_desc action, flag, 'opts*,object*'
921
- task flag do |_, args|
922
- show flag, args.to_a
923
- end
924
- when :format
925
- format_desc action, flag, 'format?,opts*,object*'
926
- task flag, [:format] do |_, args|
927
- show(flag, args.extras, format: args.format)
928
- end
929
- when :textconv
930
- format_desc action, flag, 'files+'
931
- task flag do |_, args|
932
- files = param_guard(action, flag, args: args.to_a)
933
- show(flag, files: files)
934
- end
935
- end
936
910
  when 'rebase', 'merge'
937
911
  case flag
938
912
  when :branch
@@ -1004,7 +978,7 @@ module Squared
1004
978
  task flag, [:ref, :size] do |_, args|
1005
979
  ref = commithead args.ref
1006
980
  size = args.size
1007
- if !size && ref.to_i.between?(4, 40)
981
+ if !size && ref.to_i.between?(4, 64)
1008
982
  size = ref
1009
983
  ref = nil
1010
984
  end
@@ -1145,6 +1119,8 @@ module Squared
1145
1119
  'source+,destination'
1146
1120
  when :revert
1147
1121
  'commit+'
1122
+ when :show
1123
+ 'format?'
1148
1124
  end
1149
1125
  after = case flag
1150
1126
  when :add
@@ -1155,6 +1131,8 @@ module Squared
1155
1131
  'dir+'
1156
1132
  when :clean, :rm, :status
1157
1133
  'pathspec*'
1134
+ when :show
1135
+ 'object*'
1158
1136
  end
1159
1137
  format_desc(action, flag, 'opts*', before: before, after: after)
1160
1138
  task flag do |_, args|
@@ -1519,7 +1497,7 @@ module Squared
1519
1497
  run_p(*Array(kwargs[:before]), sync: sync, from: symjoin(from, 'before')) if kwargs[:before]
1520
1498
  force = if (force = env('REVBUILD_FORCE', strict: true))
1521
1499
  force != '0' && force != 'false'
1522
- elsif (force = ENV['GIT_FORCE'] || ENV['REVBUILD_FORCE'])
1500
+ elsif (force = env('GIT_FORCE', suffix: false) || env('REVBUILD_FORCE', suffix: false))
1523
1501
  split_escape(force).any? { |val| val == '1' || val == 'true' || val == name }
1524
1502
  end
1525
1503
  if !force && (cur = workspace.rev_entry(name)) && cur['revision'] == sha
@@ -1862,8 +1840,7 @@ module Squared
1862
1840
  if adding.empty? && !cached.empty? && banner?
1863
1841
  puts(cached.lines(chomp: true).map { |val| "cached #{shell_quote(val)}" })
1864
1842
  end
1865
- source co
1866
- source pu
1843
+ ENV['COMMIT_PUSH'] = git_spawn 'rev-parse --verify HEAD' if source(co) && source(pu) && !dryrun?
1867
1844
  else
1868
1845
  if banner?
1869
1846
  puts 'Nothing to commit'
@@ -1963,6 +1940,7 @@ module Squared
1963
1940
  print_item banner
1964
1941
  ret = write_lines(out, sub: [
1965
1942
  opt_style(color(:green), /^(\*\s+)(\S+)(.*)$/, 2),
1943
+ opt_style(color(:blue), /^(.+)((?<=\[)[^\]]+(?=\]))(.*)$/, 2),
1966
1944
  opt_style(color(:red), %r{^(\s*)(remotes/\S+)(.*)$}, 2)
1967
1945
  ])
1968
1946
  list_result(ret, 'branches', banner: banner, from: from)
@@ -2053,35 +2031,6 @@ module Squared
2053
2031
  source(sync: false, stderr: true)
2054
2032
  end
2055
2033
 
2056
- def show(flag, opts = [], format: nil, files: [])
2057
- cmd, opts = git_session('show', opts: opts)
2058
- case flag
2059
- when :textconv
2060
- cmd << '--textconv'
2061
- append_value(files.flat_map { |val| Dir[val] }
2062
- .select { |val| projectpath?(val) }
2063
- .map { |val| "HEAD:#{val}" })
2064
- source(banner: false)
2065
- return
2066
- when :oneline
2067
- format = flag.to_s
2068
- end
2069
- case format
2070
- when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
2071
- cmd << basic_option('format', format)
2072
- when /^t?format:|%/
2073
- cmd << quote_option('pretty', format)
2074
- else
2075
- opts << format if format
2076
- end
2077
- list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + collect_hash(OPT_GIT[:log], pass: [:base])
2078
- op = OptionPartition.new(opts, list, cmd,
2079
- project: self, strict: strict?,
2080
- no: OPT_GIT[:no][:show] + collect_hash(OPT_GIT[:no][:log], pass: [:base]))
2081
- op.append
2082
- source(exception: false, banner: flag != :oneline)
2083
- end
2084
-
2085
2034
  def rev_parse(flag, opts = [], ref: nil, size: nil)
2086
2035
  cmd, opts = git_session('rev-parse', opts: opts)
2087
2036
  case flag
@@ -2145,18 +2094,28 @@ module Squared
2145
2094
 
2146
2095
  def git(flag, opts = [], extras: [])
2147
2096
  cmd, opts = git_session(flag, opts: opts)
2148
- list = OPT_GIT[:git].fetch(flag, []) + OPT_GIT.fetch(flag, []).yield_self { |a| a.is_a?(Array) ? a : [] }
2097
+ list = OPT_GIT[:git].fetch(flag, []) + OPT_GIT.fetch(flag, []).then { |a| a.is_a?(Array) ? a : [] }
2098
+ no = OPT_GIT[:no].fetch(flag, [])
2149
2099
  case flag
2150
2100
  when :add
2151
2101
  list.concat(OPT_GIT[:log][:diff_context])
2152
2102
  when :revert
2153
2103
  list.concat(VAL_GIT[:rebase][:send])
2104
+ when :show
2105
+ list.concat(OPT_GIT[:diff][:show], collect_hash(OPT_GIT[:log], pass: [:base]))
2106
+ no += collect_hash(OPT_GIT[:no][:log], pass: [:base])
2107
+ case opts.first
2108
+ when 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
2109
+ cmd << basic_option('format', opts.shift)
2110
+ when /^t?format:|%/
2111
+ cmd << quote_option('pretty', opts.shift)
2112
+ end
2154
2113
  when :'sparse-checkout'
2155
2114
  cmd << 'set'
2156
2115
  end
2157
- op = OptionPartition.new(opts, list, cmd, project: self, strict: strict?, no: OPT_GIT[:no][flag],
2116
+ op = OptionPartition.new(opts, list, cmd, project: self, strict: strict?, no: no,
2158
2117
  first: case flag
2159
- when :blame, :revert, :'sparse-checkout' then nil
2118
+ when :blame, :revert, :show, :'sparse-checkout' then nil
2160
2119
  else matchpathspec
2161
2120
  end)
2162
2121
  case flag
@@ -2222,6 +2181,20 @@ module Squared
2222
2181
  op.add_quote(val)
2223
2182
  end
2224
2183
  end
2184
+ when :show
2185
+ if op.arg?('textconv')
2186
+ op.each do |val|
2187
+ files = Dir[val]
2188
+ if files.empty? || !files.all? { |path| projectpath?(path) }
2189
+ op.add_quote(val)
2190
+ else
2191
+ op.append(files.map { |path| "HEAD:#{path}" })
2192
+ end
2193
+ end
2194
+ else
2195
+ op.append
2196
+ end
2197
+ return source(exception: false, banner: !op.arg?('oneline', 'textconv'))
2225
2198
  end
2226
2199
  case flag
2227
2200
  when :revert, :mv, :rm
@@ -2337,7 +2310,9 @@ module Squared
2337
2310
  end
2338
2311
  args = []
2339
2312
  args << quote_option('sort', sort) if sort
2340
- args << basic_option('count', env('GIT_COUNT', ARG[:CHOICE])) if count
2313
+ if count && (count = env('GIT_COUNT') || ARG[:CHOICE]) && count != Float::INFINITY
2314
+ args << basic_option('count', count)
2315
+ end
2341
2316
  choice_index(msg, foreachref(type, *args, format: format), trim: trim, **kwargs)
2342
2317
  end
2343
2318
 
@@ -2345,7 +2320,9 @@ module Squared
2345
2320
  kwargs[:attempts] ||= 1 unless force
2346
2321
  cmd = git_output(reflog && env('GIT_REFLOG') ? 'reflog' : 'log', range)
2347
2322
  cmd << quote_option('format', "#{commitstyle('%h')} %s")
2348
- cmd << basic_option('max-count', env('GIT_COUNT', ARG[:CHOICE])) if count
2323
+ if count && (count = env('GIT_COUNT') || ARG[:CHOICE]) && count != Float::INFINITY
2324
+ cmd << basic_option('max-count', count)
2325
+ end
2349
2326
  ret = choice_index(msg, git_spawn(cmd, stdout: false), column: /^(\S+)/, force: force, **kwargs)
2350
2327
  case ret
2351
2328
  when Array
@@ -2570,8 +2547,8 @@ module Squared
2570
2547
  n = origin&.index('/')
2571
2548
  raise message("missing #{origin ? 'branch' : 'remote'} name", hint: origin) unless n && branch
2572
2549
 
2573
- branch = "#{branch}:#{origin[n.succ..-1]}" unless origin.end_with?("/#{branch}")
2574
- ret = [origin[0..n.pred], branch]
2550
+ branch = task_join branch, origin[n.succ..] unless origin.end_with?("/#{branch}")
2551
+ ret = [origin[...n], branch]
2575
2552
  ret.quote! if quote
2576
2553
  ret
2577
2554
  end
@@ -2581,7 +2558,7 @@ module Squared
2581
2558
  end
2582
2559
 
2583
2560
  def commithash(val)
2584
- val[/\A:(\h{5,40})\z/, 1]
2561
+ val[/\A:(\h{5,64})\z/, 1]
2585
2562
  end
2586
2563
 
2587
2564
  def commithead(val)
@@ -104,6 +104,9 @@ module Squared
104
104
  build: %w[clean=!? dry=!? force=!? v|verbose=!?].freeze,
105
105
  watch: %w[excludeDirectories=p excludeFiles=p fallbackPolling=b synchronousWatchDirectory=!? watchDirectory=b
106
106
  watchFile=b].freeze,
107
+ v7: {
108
+ compiler: %w[builders=i checkers=i singleThreaded=!?]
109
+ },
107
110
  v5: {
108
111
  compiler: %w[allowSyntheticDefaultImports=!? alwaysStrict=!? baseUrl=p downlevelIteration=!?
109
112
  esModuleInterop=!? outFile=p].freeze
@@ -545,8 +548,7 @@ module Squared
545
548
  Open3.capture2e(cmd.to_s)
546
549
  .first
547
550
  .scan(/^npm notice \d+(?:\.\d+)?[a-z]+ (.+)$/i)
548
- .map { |item| Pathname.new(item.first) }
549
- .select(&:exist?)
551
+ .filter_map { |item| item.first if File.exist?(item.first) }
550
552
  end.concat(Array(files))
551
553
  packed = true
552
554
  end
@@ -662,7 +664,7 @@ module Squared
662
664
  end
663
665
  if nolockfile?(prefix: 'yarn')
664
666
  cmd << '--no-lockfile'
665
- elsif option('ci') || (ci? && exist?('yarn.lock'))
667
+ elsif ci? && exist?('yarn.lock')
666
668
  if yarn == 1
667
669
  cmd << '--frozen-lockfile'
668
670
  elsif !flag
@@ -698,14 +700,13 @@ module Squared
698
700
  '--force'
699
701
  elsif nolockfile?(prefix: 'pnpm')
700
702
  '--no-lockfile'
701
- elsif option('ci') || (ci? && exist?('pnpm-lock.yaml'))
703
+ elsif ci? && exist?('pnpm-lock.yaml')
702
704
  '--frozen-lockfile'
703
705
  end
704
706
  cmd << '--ignore-scripts' if option('ignore-scripts')
705
707
  cmd << '--dangerously-allow-all-builds' if option('approve-builds')
706
708
  else
707
- ci = option('ci', prefix: 'npm') || (ci? && exist?('package-lock.json'))
708
- cmd = session('npm', ci ? 'ci' : 'install')
709
+ cmd = session('npm', ci = ci? && exist?('package-lock.json') ? 'ci' : 'install')
709
710
  option('approve-scripts') do |val|
710
711
  cmd = npm_output 'approve-scripts'
711
712
  cmd << case val
@@ -815,7 +816,7 @@ module Squared
815
816
  latest = val['latest']
816
817
  ch = file[0]
817
818
  if ch.match?(/[~^]/)
818
- file = file[1..-1]
819
+ file = file[1..]
819
820
  elsif ia && flag == :major
820
821
  major = true
821
822
  else
@@ -960,7 +961,7 @@ module Squared
960
961
  (1..items.size)
961
962
  else
962
963
  choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
963
- border: true)
964
+ border: true, **parse_select)
964
965
  end.each do |n|
965
966
  item = items[n.pred].last
966
967
  doc.sub!(pat.call(item)) { edit.call(item, $1, $2) }
@@ -1039,7 +1040,7 @@ module Squared
1039
1040
  c = 0
1040
1041
  e = 0
1041
1042
  doc['files'].each do |item|
1042
- path = item['path'][n..-1]
1043
+ path = item['path'][n..]
1043
1044
  js = File.extname(path)
1044
1045
  next unless ext.empty? || ext.any? { |val| val == js }
1045
1046
 
@@ -1355,7 +1356,8 @@ module Squared
1355
1356
  b = kwargs[:build]
1356
1357
  w = kwargs[:watch]
1357
1358
  list = OPT_TSC[:base] + OPT_TSC[:compiler]
1358
- list.concat(Array(kwargs.fetch(:legacy, 5)).flat_map { |n| OPT_TSC.fetch(:"v#{n}", {}).fetch(:compiler, []) })
1359
+ kwargs[:legacy] = semapp('npx', 'tsc', '--version', minor: false) if kwargs[:detect]
1360
+ list.concat(Array(kwargs[:legacy]).flat_map { |n| OPT_TSC.fetch(:"v#{n}", {}).fetch(:compiler, []) })
1359
1361
  cmd = session 'tsc', if p
1360
1362
  quote_option 'p', basepath(p)
1361
1363
  elsif b
@@ -1518,7 +1520,7 @@ module Squared
1518
1520
  end
1519
1521
 
1520
1522
  def scripts
1521
- @scripts ||= read_package('scripts').yield_self { |ret| ret.is_a?(Hash) ? ret : {} }
1523
+ @scripts ||= read_package('scripts').then { |ret| ret.is_a?(Hash) ? ret : {} }
1522
1524
  end
1523
1525
 
1524
1526
  private
@@ -4,7 +4,7 @@ module Squared
4
4
  module Workspace
5
5
  module Project
6
6
  class Python < Git
7
- DEP_PYTHON = %w[poetry.lock setup.cfg pyproject.toml setup.py requirements.txt].freeze
7
+ DEP_PYTHON = %w[poetry.lock pdm.lock pylock.toml setup.cfg pyproject.toml setup.py requirements.txt].freeze
8
8
  DIR_PYTHON = (DEP_PYTHON + %w[meson.build README.rst]).freeze
9
9
  OPT_PYTHON = {
10
10
  common: %w[b=+ B d E h i I O P q=+ s S u v=+ V=+ x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
@@ -58,8 +58,8 @@ module Squared
58
58
  u|username=qq].freeze
59
59
  }.freeze
60
60
  OPT_PDM = {
61
- common: %w[I|ignore-python no-cache n|non-interactive].freeze,
62
- build: %w[C=bm no-clean no-isolation no-sdist no-wheel q|quiet v|verbose=+ config-setting=q d|dest=p
61
+ common: %w[c|config I|ignore-python no-cache n|non-interactive].freeze,
62
+ build: %w[C=bm no-clean no-isolation no-sdist no-wheel q|quiet v|verbose=+ config-setting=qq d|dest=p
63
63
  p|project=p k|skip=b].freeze,
64
64
  publish: %w[no-build no-very-ssl q|quiet S|sign skip-existing v|verbose=+ ca-certs=p c|comment=q d|dest=p
65
65
  i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=qq].freeze
@@ -131,7 +131,7 @@ module Squared
131
131
  initialize_build(Python.ref, **kwargs)
132
132
  initialize_env(**kwargs)
133
133
  end
134
- dependfile_set(DEP_PYTHON, default: 2)
134
+ dependfile_set(DEP_PYTHON, default: 4)
135
135
  serve_set kwargs[:serve]
136
136
  editable_set editable
137
137
  venv_set kwargs[:venv]
@@ -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/ninstall?,opts*"
300
+ format_desc action, flag, "file?=#{DEP_PYTHON[6]},u/ninstall?,opts*"
301
301
  task flag do |_, args|
302
302
  opts = args.to_a
303
303
  if has_value!(opts, 'u', 'uninstall')
@@ -351,7 +351,7 @@ module Squared
351
351
  'eager'
352
352
  when /^only-if|needed$/
353
353
  'only-if-needed'
354
- end.yield_self do |val|
354
+ end.then do |val|
355
355
  if val
356
356
  args.extras << "upgrade-strategy=#{val}"
357
357
  else
@@ -430,7 +430,17 @@ module Squared
430
430
  workspace.rev_clear(name, sync: sync)
431
431
  if !flag && poetry?
432
432
  cmd = poetry_session 'install -n'
433
+ if prod?
434
+ cmd << '--only=main'
435
+ else
436
+ option('with') { |val| cmd << basic_option('with', val) }
437
+ option('without') { |val| cmd << basic_option('without', val) }
438
+ end
433
439
  cmd << '--no-root' if option('no-root')
440
+ elsif !flag && pdm?
441
+ cmd = pdm_session 'install'
442
+ cmd << '--prod' if prod?
443
+ option('G', 'group') { |val| cmd << basic_option('G', val) }
434
444
  else
435
445
  cmd = pip_session 'install'
436
446
  cmd << '--upgrade-strategy=eager' if env('UPDATE') || env('PYTHON_UPDATE')
@@ -447,9 +457,13 @@ module Squared
447
457
  else
448
458
  append_global
449
459
  end
450
- if exist?(DEP_PYTHON[4]) && !session_arg?('r', 'requirement')
451
- cmd << basic_option('r', DEP_PYTHON[4])
452
- cmd << basic_option('c', 'constraints.txt') if exist?('constraints.txt')
460
+ unless session_arg?('r', 'requirement')
461
+ if exist?(DEP_PYTHON[2])
462
+ cmd << basic_option('r', DEP_PYTHON[2])
463
+ elsif exist?(DEP_PYTHON[6])
464
+ cmd << basic_option('r', DEP_PYTHON[6])
465
+ cmd << basic_option('c', 'constraints.txt') if exist?('constraints.txt')
466
+ end
453
467
  end
454
468
  append_editable
455
469
  end
@@ -569,8 +583,9 @@ module Squared
569
583
  end
570
584
  if found > 0
571
585
  items = if se
572
- choice('Select a package', items.map(&:first),
573
- multiple: true, force: false, index: true, border: true).map { |n| items[n.pred].last }
586
+ choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
587
+ border: true, **parse_select)
588
+ .map { |n| items[n.pred].last }
574
589
  elsif ia
575
590
  items.map(&:last)
576
591
  else
@@ -786,7 +801,7 @@ module Squared
786
801
  ret = kwargs[:requirement] || begin
787
802
  file = op.detect { |val| op.exist?(val) }
788
803
  op.remove(file) if file
789
- basepath(file || DEP_PYTHON[4])
804
+ basepath(file || DEP_PYTHON[6])
790
805
  end
791
806
  op.add_quote(ret)
792
807
  .clear
@@ -832,7 +847,7 @@ module Squared
832
847
  end
833
848
  print_run(op, banner, **kwargs)
834
849
  run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception?), from: symjoin('pip', flag))
835
- .yield_self { |val| ret || val }
850
+ .then { |val| ret || val }
836
851
  end
837
852
 
838
853
  def serve(root, opts = [], bind: 'localhost', port: nil, **)
@@ -1039,7 +1054,15 @@ module Squared
1039
1054
  end
1040
1055
  end
1041
1056
  ret.last[1] += val
1042
- elsif line.strip =~ /^(\S+)\s*=\s*([+-]?[\d.]+|true|false|("""|'''|["'\[{])(.*))$/
1057
+ elsif line.strip =~ /^(\S+)\s*=\s*
1058
+ (
1059
+ [+-]?(?:[\d._]+(?:[eE].+)?|0x[\dA-Fa-f]+|0[ob]\d+|nan|inf)
1060
+ |true|false
1061
+ |\d{4}-\d{2}-\d{2}.*
1062
+ |\d{2}:\d{2}.*
1063
+ |("""|'''|["'\[{])(.*)
1064
+ )$/x
1065
+ name = $1
1043
1066
  if (val = $4)
1044
1067
  case (ch = $3)
1045
1068
  when '{', '['
@@ -1059,11 +1082,21 @@ module Squared
1059
1082
  true
1060
1083
  when 'false'
1061
1084
  false
1085
+ when /^\d{4}-/
1086
+ Time.parse(ch)
1087
+ when /^\d{2}:/
1088
+ Time.strptime(ch, '%T')
1089
+ when /nan$/
1090
+ Float::NAN
1091
+ when /inf$/
1092
+ Float::INFINITY * (ch[0] == '-' ? -1 : 1)
1093
+ when /^[+-]?0[xob]/
1094
+ eval ch
1062
1095
  else
1063
1096
  ch.include?('.') ? ch.to_f : ch.to_i
1064
1097
  end
1065
1098
  end
1066
- ret << [$1, val]
1099
+ ret << [name, val]
1067
1100
  end
1068
1101
  if !ch && (val = ret.last[1]).is_a?(String) && (val.match?(/\A\{.+\}\z/m) || val.match?(/\A\[.+\]\z/m))
1069
1102
  ret.last[1] = JSON.parse(val) rescue nil
@@ -1082,7 +1115,7 @@ module Squared
1082
1115
  end
1083
1116
 
1084
1117
  def pyprojectfile
1085
- @pyprojectfile = basepath!(DEP_PYTHON[2]) || false if @pyprojectfile.nil?
1118
+ @pyprojectfile = basepath!(DEP_PYTHON[4]) || false if @pyprojectfile.nil?
1086
1119
  @pyprojectfile || nil
1087
1120
  end
1088
1121
 
@@ -1139,7 +1172,7 @@ module Squared
1139
1172
  if windows?
1140
1173
  shell_quote(venvbin.join(powershell? ? 'Activate.ps1' : 'activate.bat'), option: false)
1141
1174
  else
1142
- { 'VIRTUAL_ENV' => venv.to_s, 'PATH' => "#{venvbin}:#{ENV['PATH']}" }
1175
+ { 'VIRTUAL_ENV' => venv.to_s, 'PATH' => task_join(venvbin, ENV['PATH']) }
1143
1176
  end
1144
1177
  end
1145
1178
 
@@ -1221,6 +1254,8 @@ module Squared
1221
1254
  if poetry?
1222
1255
  dir += (windows? ? 'Scripts/python.exe' : 'bin/python')
1223
1256
  cmd = poetry_session 'env use'
1257
+ elsif pdm?
1258
+ cmd = pdm_session 'use -f'
1224
1259
  else
1225
1260
  puts "Success: #{dir}"
1226
1261
  return
@@ -1264,13 +1299,17 @@ module Squared
1264
1299
  end
1265
1300
 
1266
1301
  def setuptools?
1267
- dependtype == 2 || dependtype == 4
1302
+ dependtype == 4 || dependtype == 6
1268
1303
  end
1269
1304
 
1270
1305
  def poetry?
1271
1306
  dependtype == 1
1272
1307
  end
1273
1308
 
1309
+ def pdm?
1310
+ dependtype == 2
1311
+ end
1312
+
1274
1313
  def twine?
1275
1314
  venv_package?('twine')
1276
1315
  end
@@ -1280,7 +1319,7 @@ module Squared
1280
1319
  end
1281
1320
 
1282
1321
  def requirements?
1283
- dependtype == 5
1322
+ dependtype == 7
1284
1323
  end
1285
1324
  end
1286
1325