squared 0.4.17 → 0.4.18

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.
@@ -74,7 +74,7 @@ module Squared
74
74
  @revdoc = JSON.parse(@revfile.read) if @revfile.exist?
75
75
  rescue StandardError => e
76
76
  @revfile = nil
77
- warn log_message(Logger::WARN, e, pass: true) if @warning
77
+ warn log_message(Logger::WARN, e, pass: true)
78
78
  self
79
79
  else
80
80
  @revdoc = {} unless @revdoc.is_a?(Hash)
@@ -301,9 +301,9 @@ module Squared
301
301
  include Rake::DSL
302
302
 
303
303
  def populate(ws, **)
304
- return if ws.series.exclude?(:pull, true)
304
+ return if ws.series.exclude?(:pull, true) || ws.size == 1
305
305
 
306
- namespace(ws.task_name('git')) do |ns|
306
+ namespace ws.task_name('git') do |ns|
307
307
  ws.format_desc(all = ws.task_join(ns.scope.path, 'all'), 'stash|rebase|autostash?,depend?')
308
308
  task 'all' do |_, args|
309
309
  args = args.to_a
@@ -623,12 +623,12 @@ module Squared
623
623
  format_desc action, flag, 'ref,opts*'
624
624
  task flag, [:commit] do |_, args|
625
625
  commit = commithead args.commit
626
- if commit
627
- args = args.extras
628
- else
629
- commit, opts = choice_commit(values: ['Options'])
630
- args = OptionPartition.strip(opts)
631
- end
626
+ args = if commit
627
+ args.extras
628
+ else
629
+ commit, opts = choice_commit(values: ['Options'])
630
+ OptionPartition.strip(opts)
631
+ end
632
632
  checkout(flag, args, commit: commit)
633
633
  end
634
634
  when :detach
@@ -804,28 +804,28 @@ module Squared
804
804
  when :branch
805
805
  format_desc action, flag, 'upstream,branch?=HEAD,opts*'
806
806
  task flag, [:upstream] do |_, args|
807
- if (upstream = args.upstream)
808
- args = args.extras
809
- else
810
- upstream, opts = choice_refs('Choose upstream branch', values: ['Options'])
811
- args = OptionPartition.strip(opts)
812
- end
807
+ args = if (upstream = args.upstream)
808
+ args.extras
809
+ else
810
+ upstream, opts = choice_refs('Choose upstream branch', values: ['Options'])
811
+ OptionPartition.strip(opts)
812
+ end
813
813
  rebase(flag, args, upstream: upstream)
814
814
  end
815
815
  when :onto
816
816
  format_desc action, flag, 'ref,upstream,branch?=HEAD'
817
817
  task flag, [:commit, :upstream, :branch] do |_, args|
818
818
  commit = commithead args.commit
819
- if commit
820
- upstream = param_guard(action, flag, args: args, key: :upstream)
821
- branch = args.branch
822
- args = []
823
- else
824
- commit = choice_refs 'Choose "onto" branch'
825
- target, opts = choice_commit(multiple: 2, values: ['Options'], reflog: false)
826
- branch, upstream = target
827
- args = OptionPartition.strip(opts)
828
- end
819
+ args = if commit
820
+ upstream = param_guard(action, flag, args: args, key: :upstream)
821
+ branch = args.branch
822
+ []
823
+ else
824
+ commit = choice_refs 'Choose "onto" branch'
825
+ target, opts = choice_commit(multiple: 2, values: ['Options'], reflog: false)
826
+ branch, upstream = target
827
+ OptionPartition.strip(opts)
828
+ end
829
829
  rebase(flag, args, commit: commit, upstream: upstream, branch: branch)
830
830
  end
831
831
  when :commit, :'no-commit'
@@ -889,13 +889,13 @@ module Squared
889
889
  format_desc action, flag, 'ref,opts*,pathspec*'
890
890
  task flag, [:commit] do |_, args|
891
891
  commit = commithead args.commit
892
- if commit
893
- args = args.extras
894
- else
895
- commit, opts, files = choice_commit(values: ['Options', ['Pathspec', true]])
896
- args = OptionPartition.strip(opts)
897
- files = files&.shellsplit
898
- end
892
+ args = if commit
893
+ args.extras
894
+ else
895
+ commit, opts, files = choice_commit(values: ['Options', ['Pathspec', true]])
896
+ files = files&.shellsplit
897
+ OptionPartition.strip(opts)
898
+ end
899
899
  restore(flag, args, commit: commit, files: files)
900
900
  end
901
901
  when :staged, :worktree
@@ -956,43 +956,9 @@ module Squared
956
956
  def pull(flag = nil, opts = [], sync: invoked_sync?('pull', flag), remote: nil, hint: nil)
957
957
  cmd, opts = git_session('pull', opts: opts)
958
958
  cmd << '--autostash' if option('autostash')
959
- case flag
960
- when :rebase
959
+ if flag == :rebase
961
960
  cmd << '--rebase'
962
- when :all
963
- unless git_spawn('status -s -z --untracked-files=all').empty?
964
- if confirm('Stash local changes? [Y/n] ', 'Y')
965
- git_spawn 'stash push --keep-index --quiet'
966
- elsif !(force = confirm('Force checkout? [y/N] ', 'N'))
967
- return
968
- end
969
- end
970
- op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
971
- reg = if op.empty?
972
- []
973
- else
974
- opts = opts.reject { |val| op.extras.include?(val) }
975
- matchmap op
976
- end
977
- session_done op.target
978
- heads = []
979
- cur = nil
980
- foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
981
- line.chomp!
982
- cur ||= line.delete_prefix!('* ')
983
- heads << line if matchany?(line, reg)
984
- end
985
- raise_error('head not found', hint: 'for-each-ref') unless cur
986
- opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
987
- (heads.dup << cur).each_with_index do |branch, index|
988
- next unless (index < heads.size && cur != branch) || index == heads.size
989
-
990
- git_spawn 'switch --quiet', force && '--force', shell_quote(branch)
991
- pull(nil, opts, sync: false, hint: branch) if heads.include?(branch)
992
- end
993
- return
994
961
  else
995
- cmd << '--autostash' if flag == :autostash
996
962
  if (val = option('rebase', ignore: false))
997
963
  cmd << case val
998
964
  when '0', 'false'
@@ -1001,10 +967,46 @@ module Squared
1001
967
  VAL_GIT[:rebase][:value].include?(val) ? basic_option('rebase', val) : '--rebase'
1002
968
  end
1003
969
  end
970
+ case flag
971
+ when :all
972
+ unless git_spawn('status -s -z --untracked-files=all').empty?
973
+ if confirm('Stash local changes? [Y/n] ', 'Y')
974
+ git_spawn 'stash push --keep-index --quiet'
975
+ elsif !(force = confirm('Force checkout? [y/N] ', 'N'))
976
+ return
977
+ end
978
+ end
979
+ op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
980
+ reg = if op.empty?
981
+ []
982
+ else
983
+ opts = op.uniq(opts)
984
+ matchmap op
985
+ end
986
+ session_done op.target
987
+ heads = []
988
+ cur = nil
989
+ foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
990
+ line.chomp!
991
+ cur ||= line.delete_prefix!('* ')
992
+ heads << line if matchany?(line, reg)
993
+ end
994
+ raise_error('head not found', hint: 'for-each-ref') unless cur
995
+ opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
996
+ (heads.dup << cur).each_with_index do |branch, index|
997
+ next unless (index < heads.size && cur != branch) || index == heads.size
998
+
999
+ git_spawn 'switch --quiet', force && '--force', shell_quote(branch)
1000
+ pull(nil, opts, sync: false, hint: branch) if heads.include?(branch)
1001
+ end
1002
+ return
1003
+ when :autostash
1004
+ cmd << '--autostash'
1005
+ end
1004
1006
  end
1005
1007
  append_pull(opts, OPT_GIT[:pull] + OPT_GIT[:fetch][:pull],
1006
1008
  no: OPT_GIT[:no][:pull] + OPT_GIT[:no][:fetch][:pull], remote: remote, flag: flag, from: :pull)
1007
- source(sync: sync, sub: if verbose
1009
+ source(sync: sync, sub: if stdout?
1008
1010
  [
1009
1011
  { pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: color(:red), index: 4 },
1010
1012
  { pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: color(:green), index: 3 }
@@ -1033,6 +1035,10 @@ module Squared
1033
1035
  cmd << upstream
1034
1036
  append_head branch
1035
1037
  else
1038
+ unless gitpath('REBASE_HEAD').exist?
1039
+ puts log_message(Logger::INFO, name, 'no rebase in progress', hint: command) if stdout?
1040
+ return
1041
+ end
1036
1042
  return unless VAL_GIT[:rebase][:send].include?(command)
1037
1043
 
1038
1044
  cmd << "--#{command}"
@@ -1157,7 +1163,7 @@ module Squared
1157
1163
  end
1158
1164
  append_pathspec
1159
1165
  end
1160
- if verbose
1166
+ if stdout?
1161
1167
  r = color(:red)
1162
1168
  g = color(:green)
1163
1169
  sub = if session_arg?('short')
@@ -1210,7 +1216,7 @@ module Squared
1210
1216
  if (cur = workspace.rev_entry(name)) && cur['revision'] == sha && !env('REVBUILD_FORCE')
1211
1217
  files = status_digest(*args, **kwargs)
1212
1218
  if cur['files'].size == files.size && cur['files'].find { |key, val| files[key] != val }.nil?
1213
- if verbose
1219
+ if stdout?
1214
1220
  if (since = workspace.rev_timesince(name, 'build'))
1215
1221
  puts log_message(Logger::INFO, name, 'no changes', subject: 'revbuild', hint: "#{since} ago")
1216
1222
  else
@@ -1364,15 +1370,14 @@ module Squared
1364
1370
  op << '--no-index'
1365
1371
  append_pathspec(refs, parent: true)
1366
1372
  else
1373
+ op << '--merge-base' if option('merge-base')
1367
1374
  case flag
1368
1375
  when :view
1369
- op << '--merge-base' if option('merge-base')
1370
1376
  op.merge(range)
1371
1377
  when :between, :contain
1372
1378
  op.delete('--merge-base')
1373
1379
  op.add_quote(range.join(flag == :between ? '..' : '...'))
1374
1380
  else
1375
- op << '--merge-base' if option('merge-base')
1376
1381
  op.add_quote(branch) if branch
1377
1382
  if !index.empty?
1378
1383
  if op.arg?('cached')
@@ -1428,16 +1433,16 @@ module Squared
1428
1433
  branch, origin, hint = line.split('...')
1429
1434
  if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
1430
1435
  raise_error('work tree is not usable', hint: hint[1..-2])
1431
- elsif origin.empty?
1436
+ elsif !origin || origin.empty?
1432
1437
  return nil if pass
1433
1438
  break if dryrun
1434
1439
 
1435
1440
  unless (origin = option('upstream', prefix: 'git', ignore: false))
1436
1441
  if (origin = choice_refs('Choose an upstream', 'remotes', attempts: 1, force: false))
1437
1442
  git_spawn 'branch', quote_option('set-upstream-to', origin)
1438
- else
1439
- origin = readline('Enter an upstream', force: true)
1443
+ break
1440
1444
  end
1445
+ origin = readline('Enter an upstream', force: true)
1441
1446
  end
1442
1447
  raise_error('missing remote name', hint: origin) unless origin.include?('/')
1443
1448
  upstream = true
@@ -1484,6 +1489,10 @@ module Squared
1484
1489
  append_commit(*op.extras)
1485
1490
  end
1486
1491
  else
1492
+ unless gitpath('MERGE_HEAD').exist?
1493
+ puts log_message(Logger::INFO, name, 'no merge in progress', hint: command) if stdout?
1494
+ return
1495
+ end
1487
1496
  return unless VAL_GIT[:merge][:send].include?(command)
1488
1497
 
1489
1498
  cmd << "--#{command}"
@@ -1525,10 +1534,8 @@ module Squared
1525
1534
  end
1526
1535
  force, list = refs.partition { |val| val.match?(/^[~^]/) }
1527
1536
  force.each do |val|
1528
- dr = val[0, 2]
1529
- d = dr.include?('^') ? '-D' : '-d'
1530
- r = '-r' if dr.include?('~')
1531
- source git_output('branch', d, r, shell_quote(val.sub(/^[~^]+/, '')))
1537
+ r = '-r' if val.delete!('~')
1538
+ source git_output('branch', val.delete!('^') ? '-D' : '-d', r, shell_quote(val))
1532
1539
  end
1533
1540
  return if list.empty?
1534
1541
 
@@ -1536,8 +1543,9 @@ module Squared
1536
1543
  append_value list
1537
1544
  remote = nil
1538
1545
  when :move, :copy
1539
- flag = "-#{flag.to_s[0]}"
1540
- cmd << (option('force', 'f') ? flag.upcase : flag)
1546
+ s = "-#{flag.to_s[0]}"
1547
+ s.upcase! if option('force', 'f')
1548
+ cmd << s
1541
1549
  refs.compact.each { |val| cmd << shell_quote(val) }
1542
1550
  stdout = true
1543
1551
  when :current
@@ -1557,12 +1565,12 @@ module Squared
1557
1565
  list_result(ret, 'branches', from: from)
1558
1566
  return
1559
1567
  else
1560
- head = git_spawn('rev-parse --abbrev-ref HEAD').chomp
1561
- if head.empty?
1568
+ if (head = git_spawn('rev-parse --abbrev-ref HEAD').chomp).empty?
1562
1569
  ret = 0
1563
1570
  else
1564
1571
  git_spawn 'fetch --all --prune --quiet' if option('sync')
1565
- out, banner, from = source(cmd << '-vv --no-abbrev --list', io: true)
1572
+ cmd << '-vv --no-abbrev --list'
1573
+ out, banner, from = source(io: true)
1566
1574
  ret = write_lines(out, grep: [/^\*\s+#{Regexp.escape(head)}\s/], banner: banner, first: true) do |line|
1567
1575
  next line if stdin?
1568
1576
 
@@ -1633,10 +1641,13 @@ module Squared
1633
1641
  op = OptionPartition.new(opts, OPT_GIT[:submodule].fetch(flag, []), cmd, project: self)
1634
1642
  case flag
1635
1643
  when :branch, :url
1644
+ op.adjoin("set-#{flag}")
1636
1645
  op << '--'
1637
1646
  op.add_path(path) if path
1638
1647
  op.add_quote(url) if url
1639
1648
  else
1649
+ op.adjoin(flag)
1650
+ op << '--recursive' if option('recursive', 'r')
1640
1651
  op.splice(path: true)
1641
1652
  end
1642
1653
  source
@@ -1661,19 +1672,15 @@ module Squared
1661
1672
  source(banner: false)
1662
1673
  return
1663
1674
  when :oneline
1664
- format = 'oneline'
1675
+ format = flag.to_s
1665
1676
  end
1666
- if format
1667
- case (val = format.downcase)
1668
- when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
1669
- cmd << basic_option('format', val)
1670
- else
1671
- if format.match?(/^t?format:/) || format.include?('%')
1672
- cmd << quote_option('pretty', format)
1673
- else
1674
- opts << format
1675
- end
1676
- end
1677
+ case format
1678
+ when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
1679
+ cmd << basic_option('format', format)
1680
+ when /(?:^t?format:|%)/
1681
+ cmd << quote_option('pretty', format)
1682
+ else
1683
+ opts << format if format
1677
1684
  end
1678
1685
  op = OptionPartition.new(opts, OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log][:diff], cmd,
1679
1686
  project: self,
@@ -1793,7 +1800,7 @@ module Squared
1793
1800
  private
1794
1801
 
1795
1802
  def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
1796
- multiple: false, hint: nil, from: nil, **kwargs)
1803
+ multiple: false, hint: nil, from: nil, send: :system, **kwargs)
1797
1804
  cmd = cmd.target if cmd.is_a?(OptionPartition)
1798
1805
  if io && banner == false
1799
1806
  from = nil
@@ -1833,7 +1840,7 @@ module Squared
1833
1840
  end
1834
1841
  elsif !kwargs[:sub] && (sync || (!exception && !stderr))
1835
1842
  print_item banner unless multiple
1836
- ret = shell(cmd, exception: exception)
1843
+ ret = shell(cmd, name: send, exception: exception)
1837
1844
  else
1838
1845
  require 'open3'
1839
1846
  if stderr
@@ -1891,7 +1898,7 @@ module Squared
1891
1898
  def list_result(size, type, grep: [], action: 'found', from: nil)
1892
1899
  if size == 0
1893
1900
  puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
1894
- elsif verbose
1901
+ elsif stdout?
1895
1902
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1896
1903
  styles << :bold if styles.size <= 1
1897
1904
  puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
@@ -1966,11 +1973,9 @@ module Squared
1966
1973
  when 'rebase'
1967
1974
  op << basic_option($1, $2) if VAL_GIT[:rebase][:value].include?($2)
1968
1975
  when 'shallow-since'
1969
- next unless (val = Date.parse($2))
1970
-
1971
- op << quote_option($1, val.strftime('%F %T'))
1976
+ op.append?($1) { Date.parse($2)&.strftime('%F %T') }
1972
1977
  when 'recurse-submodules'
1973
- op << basic_option($1, $2) unless op.arg?('recurse-submodules')
1978
+ op.append?($1, $2, type: :basic)
1974
1979
  when 'refspec'
1975
1980
  refspec << shell_escape($2, quote: true)
1976
1981
  end
@@ -1980,7 +1985,7 @@ module Squared
1980
1985
  op.errors << opt
1981
1986
  end
1982
1987
  end
1983
- op << '--verbose' if (flag || from == :fetch) && verbose && !op.arg?('quiet')
1988
+ op << '--verbose' if (flag || from == :fetch) && stdout? && !op.arg?('quiet')
1984
1989
  if remote
1985
1990
  op.append(remote, delim: true)
1986
1991
  if (val = option('refspec', target: target, strict: true))
@@ -1993,7 +1998,7 @@ module Squared
1993
1998
  op.swap.merge(op.map! { |opt| shell_escape(opt, quote: true) })
1994
1999
  return
1995
2000
  elsif option('all')
1996
- cmd << '--all'
2001
+ op << '--all'
1997
2002
  end
1998
2003
  op.clear(errors: true, subject: flag.to_s) if flag
1999
2004
  end
@@ -2083,8 +2088,17 @@ module Squared
2083
2088
  git_session(*cmd, main: false, options: false, **kwargs)
2084
2089
  end
2085
2090
 
2086
- def git_spawn(*cmd, stdout: true)
2087
- source(cmd.first.is_a?(Set) ? cmd.first : git_output(*cmd), io: true, banner: false, stdout: stdout)
2091
+ def git_spawn(*cmd, exception: true, io: true, sync: true, stdout: true, banner: false, **kwargs)
2092
+ kwargs[:send] = if sync
2093
+ :system
2094
+ else
2095
+ exception = false
2096
+ io = false
2097
+ stdout = false
2098
+ :spawn
2099
+ end
2100
+ source(cmd.first.is_a?(Set) ? cmd.first : git_output(*cmd), exception: exception, io: io, sync: sync,
2101
+ stdout: stdout, banner: banner, **kwargs)
2088
2102
  end
2089
2103
 
2090
2104
  def dryrun?(*, target: @session, **)
@@ -2099,8 +2113,8 @@ module Squared
2099
2113
  target.include?('--quiet') || (target.include?('-q') && stripext(target.first) == 'git')
2100
2114
  end
2101
2115
 
2102
- def gitpath
2103
- path + '.git'
2116
+ def gitpath(*args)
2117
+ path.join('.git', *args)
2104
2118
  end
2105
2119
 
2106
2120
  def repotrack(origin, branch, quote: true)
@@ -657,10 +657,10 @@ module Squared
657
657
  return
658
658
  end
659
659
  cmd = session 'npm', 'publish'
660
- cmd << basic_option('otp', otp) if otp &&= option('otp')
661
- cmd << basic_option('tag', tag) if tag &&= option('tag')
662
- cmd << basic_option('access', access) if access &&= option('access')
663
- dryrun &&= dryrun?('npm')
660
+ cmd << basic_option('otp', otp) if otp ||= option('otp')
661
+ cmd << basic_option('tag', tag) if tag ||= option('tag')
662
+ cmd << basic_option('access', access) if access ||= option('access')
663
+ dryrun ||= dryrun?('npm')
664
664
  if dryrun
665
665
  cmd << '--dry-run'
666
666
  else
@@ -671,13 +671,12 @@ module Squared
671
671
  run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
672
672
  else
673
673
  on :first, from
674
- pwd_set(from: :publish, dryrun: dryrun) do
674
+ pwd_set(from: from, dryrun: dryrun) do
675
675
  require 'open3'
676
- banner = format_banner(cmd.to_s)
676
+ banner = format_banner cmd.to_s
677
677
  Open3.popen2e(cmd.done) do |_, out|
678
- write_lines(out, banner: banner, sub: npmnotice + [
679
- { pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2 }
680
- ])
678
+ write_lines(out, sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2],
679
+ banner: banner)
681
680
  end
682
681
  end
683
682
  on :last, from
@@ -775,15 +774,15 @@ module Squared
775
774
  log.info "bump version #{cur} to #{val} (#{flag})"
776
775
  on :first, :bump
777
776
  end
778
- if verbose
777
+ if stdin?
778
+ puts val
779
+ elsif verbose
779
780
  major = flag == :major
780
781
  emphasize("version: #{val}", title: name, border: borderstyle, sub: [
781
782
  headerstyle,
782
783
  { pat: /\A(version:)( )(\S+)(.*)\z/, styles: color(major ? :green : :yellow), index: 3 },
783
784
  { pat: /\A(version:)(.*)\z/, styles: theme[major ? :major : :active] }
784
785
  ])
785
- elsif stdin?
786
- puts val
787
786
  end
788
787
  on :last, :bump unless dryrun?
789
788
  else
@@ -800,7 +799,7 @@ module Squared
800
799
  cmd = session dependbin, 'pack'
801
800
  if dependtype(:yarn) > 1
802
801
  op = OptionPartition.new(opts, OPT_BERRY[:pack], cmd, project: self)
803
- op << quote_option('out', Pathname.pwd + "#{project}-#{version}.tgz") unless op.arg?('out')
802
+ op.append?('out', Pathname.pwd + "#{project}-#{version}.tgz")
804
803
  else
805
804
  op = OptionPartition.new(opts, pnpm? ? OPT_PNPM[:pack] : OPT_NPM[:pack] + OPT_NPM[:common], cmd,
806
805
  project: self)
@@ -815,7 +814,7 @@ module Squared
815
814
  end
816
815
  end
817
816
  end
818
- op << quote_option('pack-destination', Dir.pwd) unless op.arg?('pack-destination')
817
+ op.append?('pack-destination', Dir.pwd)
819
818
  end
820
819
  op.clear
821
820
  run(from: :pack)
@@ -929,13 +928,17 @@ module Squared
929
928
  end
930
929
 
931
930
  def version
932
- @version ||= read_packagemanager(:version)
931
+ self.version ||= read_packagemanager(:version)
933
932
  end
934
933
 
935
934
  def packagename
936
935
  read_packagemanager :name
937
936
  end
938
937
 
938
+ def scripts
939
+ @scripts ||= read_scripts.to_h
940
+ end
941
+
939
942
  private
940
943
 
941
944
  def read_packagemanager(key = nil, version: nil, update: false)
@@ -1004,10 +1007,6 @@ module Squared
1004
1007
  end
1005
1008
  end
1006
1009
 
1007
- def dryrun?(prefix = dependbin, **)
1008
- super || !option('dry-run', prefix: prefix).nil?
1009
- end
1010
-
1011
1010
  def dependbin
1012
1011
  if yarn?
1013
1012
  'yarn'
@@ -1032,6 +1031,10 @@ module Squared
1032
1031
  { pat: /^(npm )(.+)$/, styles: :bold }
1033
1032
  ]
1034
1033
  end
1034
+
1035
+ def dryrun?(prefix = dependbin, **)
1036
+ super || !option('dry-run', prefix: prefix).nil?
1037
+ end
1035
1038
  end
1036
1039
 
1037
1040
  Application.implement Node
@@ -132,7 +132,7 @@ module Squared
132
132
  format_desc action, nil, "script+|#{indexchar}index+|#,pattern*"
133
133
  task action, [:command] do |_, args|
134
134
  found = 0
135
- ['tool.poetry.scripts', 'tool.pdm.scripts', 'project.scripts'].each_with_index do |table, index|
135
+ %w[tool.poetry.scripts tool.pdm.scripts project.scripts].each_with_index do |table, index|
136
136
  next if (list = read_pyproject(table)).empty?
137
137
 
138
138
  if args.command == '#'
@@ -786,7 +786,7 @@ module Squared
786
786
  end
787
787
  @pyproject[table] = ret
788
788
  end
789
- return ret.find { |val| val[0] == key }&.last if key
789
+ return ret.find { |val| val.first == key }&.last if key
790
790
 
791
791
  ret
792
792
  end