squared 0.8.4 → 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
 
@@ -158,10 +157,10 @@ module Squared
158
157
  no-replace-objects noglob-pathspecs paginate attr-source=b config-env=q exec-path=p
159
158
  namespace=p].freeze,
160
159
  add: %w[A e|edit f|force ignore-errors ignore-missing i|interactive n|dry-run p|patch pathspec-file-nul
161
- refresh renormalize sparse u|update v|verbose chmod=b pathspec-from-file=p].freeze,
162
- branch: %w[a|all create-reflog i|ignore-case omit-empty q|quiet r|remotes v|verbose=+ abbrev=i color=b
163
- column=b contains=b format=q merged=b no-contains=b no-merged=b points-at=b u|set-upstream-to=b
164
- sort=q t|track=b].freeze,
160
+ refresh renormalize resolved sparse u|update v|verbose chmod=b pathspec-from-file=p].freeze,
161
+ branch: %w[a|all create-reflog dry-run i|ignore-case omit-empty q|quiet r|remotes v|verbose=+ abbrev=i color=b
162
+ column=b contains=b delete-merged=q forked=q format=q merged=b no-contains=b no-merged=b
163
+ points-at=b u|set-upstream-to=b sort=q t|track=b].freeze,
165
164
  checkout: %w[l d|detach f|force ignore-other-worktrees ignore-skip-worktree-bits m|merge p|patch
166
165
  pathspec-file-nul q|quiet ours theirs conflict=b orphan=b pathspec-from-file=p t|track=b].freeze,
167
166
  clone: %w[also-filter-submodules bare dissociate l|local mirror no-hardlinks n|no-checkout no-tags o|origin=b
@@ -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: {
@@ -214,8 +215,9 @@ module Squared
214
215
  i|regexp-ignore-case remove-empty reverse right-only simplify-by-decoration simplify-merges
215
216
  single-worktree show-pulls source sparse stdin topo-order g|walk-reflogs after=q ancestry-path=b?
216
217
  author=q before=q branches=q? committer=q decorate=b decorate-refs=q decorate-refs-exclude=q
217
- exclude=q exclude-hidden=b glob=q grep=q grep-reflog=q n|max-count=i max-parents=i min-parents=i
218
- no-walk=b? remotes=q? since=q since-as-filter=q skip=i tags=q? until=q].freeze,
218
+ exclude=q exclude-hidden=b glob=q grep=q grep-reflog=q n|max-count=i max-count-oldest=i
219
+ max-parents=i min-parents=i no-walk=b? remotes=q? since=q since-as-filter=q skip=i tags=q?
220
+ until=q].freeze,
219
221
  format: %w[t children combined-all-paths dd oneline left-right no-diff-merges parents relative-date
220
222
  show-notes-by-default show-signature date=q diff-merges=b encoding=b expand-tabs=i format=q
221
223
  notes=b pretty=q? show-linear-break=q?].freeze,
@@ -269,8 +271,6 @@ module Squared
269
271
  branches=q? default=q disambiguate=b exclude=q exclude-hidden=b git-path=p glob=q
270
272
  output-object-format=b path-format=b? prefix=q remotes=q? resolve-git-dir=p short=i?
271
273
  show-object-format=b? since=q tags=q? until=q].freeze,
272
- show: %w[t combined-all-paths no-diff-merges remerge-diff show-notes-by-default show-signature diff-merges=b
273
- encoding=b expand-tabs=i notes=q show-notes=q?].freeze,
274
274
  sparse_checkout: {
275
275
  add: %w[skip-checks].freeze,
276
276
  clean: %w[n f v].freeze
@@ -280,7 +280,7 @@ module Squared
280
280
  push: %w[a|all u|include-untracked k|keep-index no-keep-index no-include-untracked pathspec-file-nul p|patch
281
281
  S|staged m|message=q pathspec-from-file=p].freeze,
282
282
  pop: %w[index].freeze,
283
- apply: %w[index].freeze
283
+ apply: %w[index label-base=b label-ours=b label-theirs=b].freeze
284
284
  }.freeze,
285
285
  status: %w[z u=bm? b|branch long s|short show-stash v|verbose=+ column=b find-renames=i? ignore-submodules=b?
286
286
  ignored=b? porcelain=b? untracked-files=b?].freeze,
@@ -369,7 +369,7 @@ module Squared
369
369
  'range-diff' => %i[view between contain].freeze,
370
370
  'fetch' => %i[origin remote all].freeze,
371
371
  'files' => %i[cached modified deleted others].freeze,
372
- '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,
373
373
  'log' => %i[grep view between contain].freeze,
374
374
  'merge' => %i[commit no-commit send].freeze,
375
375
  'pull' => %i[origin remote all].freeze,
@@ -380,7 +380,6 @@ module Squared
380
380
  'reset' => %i[commit index patch mode undo].freeze,
381
381
  'restore' => %i[source staged worktree].freeze,
382
382
  'rev' => %i[commit branch build output].freeze,
383
- 'show' => %i[format oneline textconv].freeze,
384
383
  'sparse-checkout' => %i[add reapply list clean disable].freeze,
385
384
  'stash' => %i[push pop apply drop command].freeze,
386
385
  'submodule' => %i[status update branch url sync].freeze,
@@ -813,11 +812,6 @@ module Squared
813
812
  end
814
813
  branch(flag, refs: refs, remote: remote)
815
814
  end
816
- when :list
817
- format_desc action, flag, 'opts*,pattern*'
818
- task flag do |_, args|
819
- branch flag, args.to_a
820
- end
821
815
  when :move, :copy
822
816
  format_desc action, flag, 'branch,oldbranch?'
823
817
  task flag, [:branch, :oldbranch] do |_, args|
@@ -831,9 +825,9 @@ module Squared
831
825
  branch(flag, refs: [oldbranch, branch])
832
826
  end
833
827
  else
834
- format_desc action, flag
835
- task flag do
836
- branch flag
828
+ format_desc(action, flag, ('opts*,pattern*' if flag == :list))
829
+ task flag do |_, args|
830
+ branch flag, args.to_a
837
831
  end
838
832
  end
839
833
  when 'clone'
@@ -913,25 +907,6 @@ module Squared
913
907
  reset flag
914
908
  end
915
909
  end
916
- when 'show'
917
- case flag
918
- when :oneline
919
- format_desc action, flag, 'opts*,object*'
920
- task flag do |_, args|
921
- show flag, args.to_a
922
- end
923
- when :format
924
- format_desc action, flag, 'format?,opts*,object*'
925
- task flag, [:format] do |_, args|
926
- show(flag, args.extras, format: args.format)
927
- end
928
- when :textconv
929
- format_desc action, flag, 'files+'
930
- task flag do |_, args|
931
- files = param_guard(action, flag, args: args.to_a)
932
- show(flag, files: files)
933
- end
934
- end
935
910
  when 'rebase', 'merge'
936
911
  case flag
937
912
  when :branch
@@ -1003,7 +978,7 @@ module Squared
1003
978
  task flag, [:ref, :size] do |_, args|
1004
979
  ref = commithead args.ref
1005
980
  size = args.size
1006
- if !size && ref.to_i.between?(4, 40)
981
+ if !size && ref.to_i.between?(4, 64)
1007
982
  size = ref
1008
983
  ref = nil
1009
984
  end
@@ -1144,6 +1119,8 @@ module Squared
1144
1119
  'source+,destination'
1145
1120
  when :revert
1146
1121
  'commit+'
1122
+ when :show
1123
+ 'format?'
1147
1124
  end
1148
1125
  after = case flag
1149
1126
  when :add
@@ -1154,6 +1131,8 @@ module Squared
1154
1131
  'dir+'
1155
1132
  when :clean, :rm, :status
1156
1133
  'pathspec*'
1134
+ when :show
1135
+ 'object*'
1157
1136
  end
1158
1137
  format_desc(action, flag, 'opts*', before: before, after: after)
1159
1138
  task flag do |_, args|
@@ -1511,14 +1490,14 @@ module Squared
1511
1490
  else
1512
1491
  args = parse_env('GIT_OPTIONS')
1513
1492
  .grep(/\A--#{Regexp.union(*VAL_GIT[:revbuild])}/)
1514
- .concat(VAL_GIT[:revbuild].map { |key| option(key, prefix: 'git') { |val| basic_option(key, val) } })
1493
+ .concat(VAL_GIT[:revbuild].map { |key| option(key, prefix: 'git') { |val| basic_option key, val } })
1515
1494
  .compact
1516
1495
  OptionPartition.uniq!(args)
1517
1496
  end
1518
1497
  run_p(*Array(kwargs[:before]), sync: sync, from: symjoin(from, 'before')) if kwargs[:before]
1519
1498
  force = if (force = env('REVBUILD_FORCE', strict: true))
1520
1499
  force != '0' && force != 'false'
1521
- elsif (force = ENV['GIT_FORCE'] || ENV['REVBUILD_FORCE'])
1500
+ elsif (force = env('GIT_FORCE', suffix: false) || env('REVBUILD_FORCE', suffix: false))
1522
1501
  split_escape(force).any? { |val| val == '1' || val == 'true' || val == name }
1523
1502
  end
1524
1503
  if !force && (cur = workspace.rev_entry(name)) && cur['revision'] == sha
@@ -1532,7 +1511,7 @@ module Squared
1532
1511
  start = time_epoch
1533
1512
  ret = build(*@output, sync: sync, from: from)
1534
1513
  rescue => e
1535
- print_error(e, pass: true)
1514
+ print_error(e, subject: name, pass: true)
1536
1515
  else
1537
1516
  if ret == false && !kwargs[:pass]
1538
1517
  print_status('revbuild', subject: name, start: start, loglevel: Logger::WARN, from: :failed)
@@ -1861,8 +1840,7 @@ module Squared
1861
1840
  if adding.empty? && !cached.empty? && banner?
1862
1841
  puts(cached.lines(chomp: true).map { |val| "cached #{shell_quote(val)}" })
1863
1842
  end
1864
- source co
1865
- source pu
1843
+ ENV['COMMIT_PUSH'] = git_spawn 'rev-parse --verify HEAD' if source(co) && source(pu) && !dryrun?
1866
1844
  else
1867
1845
  if banner?
1868
1846
  puts 'Nothing to commit'
@@ -1962,6 +1940,7 @@ module Squared
1962
1940
  print_item banner
1963
1941
  ret = write_lines(out, sub: [
1964
1942
  opt_style(color(:green), /^(\*\s+)(\S+)(.*)$/, 2),
1943
+ opt_style(color(:blue), /^(.+)((?<=\[)[^\]]+(?=\]))(.*)$/, 2),
1965
1944
  opt_style(color(:red), %r{^(\s*)(remotes/\S+)(.*)$}, 2)
1966
1945
  ])
1967
1946
  list_result(ret, 'branches', banner: banner, from: from)
@@ -1995,7 +1974,7 @@ module Squared
1995
1974
  end
1996
1975
  on :last, from
1997
1976
  end
1998
- print_error(name, 'no ref found', subject: 'branch', hint: 'head', pass: true) if ret == 0
1977
+ print_error('no ref found', subject: name, hint: 'branch: head', pass: true) if ret == 0
1999
1978
  return
2000
1979
  end
2001
1980
  return unless success?(source(stdout: stdout), !ref && flag == :create) && !ref && remote && target
@@ -2052,35 +2031,6 @@ module Squared
2052
2031
  source(sync: false, stderr: true)
2053
2032
  end
2054
2033
 
2055
- def show(flag, opts = [], format: nil, files: [])
2056
- cmd, opts = git_session('show', opts: opts)
2057
- case flag
2058
- when :textconv
2059
- cmd << '--textconv'
2060
- append_value(files.flat_map { |val| Dir[val] }
2061
- .select { |val| projectpath?(val) }
2062
- .map { |val| shell_quote("HEAD:#{val}") })
2063
- source(banner: false)
2064
- return
2065
- when :oneline
2066
- format = flag.to_s
2067
- end
2068
- case format
2069
- when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
2070
- cmd << basic_option('format', format)
2071
- when /^t?format:|%/
2072
- cmd << quote_option('pretty', format)
2073
- else
2074
- opts << format if format
2075
- end
2076
- list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log][:diff] + OPT_GIT[:log][:diff_context]
2077
- op = OptionPartition.new(opts, list, cmd,
2078
- project: self, strict: strict?,
2079
- no: OPT_GIT[:no][:show] + collect_hash(OPT_GIT[:no][:log], pass: [:base]))
2080
- op.append(delim: true)
2081
- source(exception: false, banner: flag != :oneline)
2082
- end
2083
-
2084
2034
  def rev_parse(flag, opts = [], ref: nil, size: nil)
2085
2035
  cmd, opts = git_session('rev-parse', opts: opts)
2086
2036
  case flag
@@ -2144,19 +2094,28 @@ module Squared
2144
2094
 
2145
2095
  def git(flag, opts = [], extras: [])
2146
2096
  cmd, opts = git_session(flag, opts: opts)
2147
- 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, [])
2148
2099
  case flag
2149
2100
  when :add
2150
2101
  list.concat(OPT_GIT[:log][:diff_context])
2151
2102
  when :revert
2152
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
2153
2113
  when :'sparse-checkout'
2154
2114
  cmd << 'set'
2155
2115
  end
2156
- op = OptionPartition.new(opts, list, cmd, project: self, strict: strict?,
2157
- no: OPT_GIT[:no][flag], single: /\A\d+\z/,
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
@@ -2303,7 +2276,7 @@ module Squared
2303
2276
  run_e(cmd, stderr: stderr, banner: banner, **kwargs)
2304
2277
  end
2305
2278
  rescue Timeout::Error => e
2306
- print_error(Logger::ERROR, cmd, subject: name, hint: e)
2279
+ print_error(Logger::ERROR, e, subject: name, hint: cmd)
2307
2280
  exit 1 unless exception?(Logger::DEBUG, Logger::INFO)
2308
2281
  rescue => e
2309
2282
  on_error(e, pass: true)
@@ -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
@@ -394,7 +397,7 @@ module Squared
394
397
  elsif has_value!(args, 'p', 'public')
395
398
  'public'
396
399
  end
397
- dryrun = has_value!(args, 'd', 'dry-run')
400
+ dryrun = has_value! args, 'd', 'dry-run'
398
401
  end
399
402
  case flag
400
403
  when :stage
@@ -411,7 +414,7 @@ module Squared
411
414
  [ver, tag, item['id'], item['actor']]
412
415
  end
413
416
  if data.empty?
414
- print_error('no staged releases', loglevel: Logger::INFO, subject: npmname)
417
+ print_error(Logger::INFO, 'no staged releases', subject: npmname)
415
418
  exit 1
416
419
  end
417
420
  data.each do |item|
@@ -456,7 +459,7 @@ module Squared
456
459
  @tsfile
457
460
  end
458
461
  end
459
- watch = has_value!(args, 'w', 'watch')
462
+ watch = has_value! args, 'w', 'watch'
460
463
  tsc(*args, banner: true, project: project, build: flag == :build, watch: !watch.nil?)
461
464
  end
462
465
  end
@@ -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')
667
+ elsif ci? && exist?('yarn.lock')
666
668
  if yarn == 1
667
669
  cmd << '--frozen-lockfile'
668
670
  elsif !flag
@@ -698,13 +700,13 @@ module Squared
698
700
  '--force'
699
701
  elsif nolockfile?(prefix: 'pnpm')
700
702
  '--no-lockfile'
701
- elsif option('ci')
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
- cmd = session('npm', (ci = option('ci', prefix: 'npm')) ? 'ci' : 'install')
709
+ cmd = session('npm', ci = ci? && exist?('package-lock.json') ? 'ci' : 'install')
708
710
  option('approve-scripts') do |val|
709
711
  cmd = npm_output 'approve-scripts'
710
712
  cmd << case val
@@ -814,7 +816,7 @@ module Squared
814
816
  latest = val['latest']
815
817
  ch = file[0]
816
818
  if ch.match?(/[~^]/)
817
- file = file[1..-1]
819
+ file = file[1..]
818
820
  elsif ia && flag == :major
819
821
  major = true
820
822
  else
@@ -873,7 +875,7 @@ module Squared
873
875
  pending = 0
874
876
  modified = 0
875
877
  width = ->(a, i) { a.map { |aa| aa[i] }.max_by(&:size).size }
876
- pad = ->(val, ord) { val.succ.to_s.rjust([ord.size.to_s.size, 2].max) }
878
+ pad = ->(a, n) { n.succ.to_s.rjust([a.size.to_s.size, 2].max) }
877
879
  footer = lambda do |val, size|
878
880
  return unless verbose
879
881
 
@@ -889,7 +891,7 @@ module Squared
889
891
  if !found.empty?
890
892
  col1 = width.call(found, 0) + 4
891
893
  col2 = width.call(found, 1) + 4
892
- col3 = pad.call(found.size, found).size + 2 + col1 + col2 + width.call(found, 2)
894
+ col3 = pad.call(found, found.size).size + 2 + col1 + col2 + width.call(found, 2)
893
895
  packages = []
894
896
  pat = ->(a) { /("#{Regexp.escape(a[0])}"\s*:\s*)"([~^])#{'?' if a[4]}#{Regexp.escape(a[1])}"/ }
895
897
  edit = lambda do |a, pkg, mod|
@@ -911,21 +913,21 @@ module Squared
911
913
  end
912
914
  a = a.ljust(col1)
913
915
  b = b.ljust(col2)
914
- sub_style! b, theme[:current] if theme[:current] && !stdin?
916
+ b = sub_style b, theme[:current] if theme[:current] && !stdin?
915
917
  if cur == -1
916
918
  c = 'SKIP'
917
919
  elsif modified == cur
918
920
  c = 'FAIL'
919
921
  elsif !stdin?
920
922
  if d == 1
921
- sub_style! a, theme[:major]
922
- sub_style! c, :bold, color(:green)
923
+ a = sub_style a, theme[:major]
924
+ c = sub_style c, :bold, color(:green)
923
925
  else
924
- sub_style!(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
926
+ c = sub_style(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
925
927
  end
926
928
  g = item
927
929
  end
928
- s = "#{pad.call(i, found)}. #{a}#{b}#{c}"
930
+ s = "#{pad.call(found, i)}. #{a}#{b}#{c}"
929
931
  if se
930
932
  items << [s, g]
931
933
  next
@@ -959,7 +961,7 @@ module Squared
959
961
  (1..items.size)
960
962
  else
961
963
  choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
962
- border: true)
964
+ border: true, **parse_select)
963
965
  end.each do |n|
964
966
  item = items[n.pred].last
965
967
  doc.sub!(pat.call(item)) { edit.call(item, $1, $2) }
@@ -994,11 +996,11 @@ module Squared
994
996
  b = sub_style b.ljust(col2), color(d ? :red : :yellow)
995
997
  c = c.ljust(col3)
996
998
  unless d
997
- sub_style! a, theme[:active]
998
- sub_style! c, color(:green)
999
+ a = sub_style a, theme[:active]
1000
+ c = sub_style c, color(:green)
999
1001
  pending += 1
1000
1002
  end
1001
- puts "#{pad.call(i, avail)}. #{(a + c + b).subhint(d ? 'locked' : 'latest')}"
1003
+ puts "#{pad.call(avail, i)}. #{(a + c + b).subhint(d ? 'locked' : 'latest')}"
1002
1004
  end
1003
1005
  footer.call(0, avail.size)
1004
1006
  else
@@ -1038,7 +1040,7 @@ module Squared
1038
1040
  c = 0
1039
1041
  e = 0
1040
1042
  doc['files'].each do |item|
1041
- path = item['path'][n..-1]
1043
+ path = item['path'][n..]
1042
1044
  js = File.extname(path)
1043
1045
  next unless ext.empty? || ext.any? { |val| val == js }
1044
1046
 
@@ -1354,7 +1356,8 @@ module Squared
1354
1356
  b = kwargs[:build]
1355
1357
  w = kwargs[:watch]
1356
1358
  list = OPT_TSC[:base] + OPT_TSC[:compiler]
1357
- 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, []) })
1358
1361
  cmd = session 'tsc', if p
1359
1362
  quote_option 'p', basepath(p)
1360
1363
  elsif b
@@ -1517,7 +1520,7 @@ module Squared
1517
1520
  end
1518
1521
 
1519
1522
  def scripts
1520
- @scripts ||= read_package('scripts').yield_self { |ret| ret.is_a?(Hash) ? ret : {} }
1523
+ @scripts ||= read_package('scripts').then { |ret| ret.is_a?(Hash) ? ret : {} }
1521
1524
  end
1522
1525
 
1523
1526
  private
@@ -1621,10 +1624,10 @@ module Squared
1621
1624
  modules.rmtree
1622
1625
  rescue Timeout::Error => e
1623
1626
  puts
1624
- print_error(e, hint: modules, pass: true)
1627
+ print_error(e, subject: name, hint: modules, pass: true)
1625
1628
  exit 1
1626
1629
  rescue => e
1627
- print_error(e, pass: true)
1630
+ print_error(e, subject: name, pass: true)
1628
1631
  false
1629
1632
  else
1630
1633
  true