squared 0.7.13 → 0.8.0

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.
@@ -8,8 +8,8 @@ module Squared
8
8
  common: %w[dry-run=!? force=!? loglevel=b include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
9
9
  common_scripts: %w[dangerously-allow-all-scripts=!? strict-allow-scripts=!? allow-scripts=q].freeze,
10
10
  install: %w[package-lock-only=!? prefer-dedupe=!? E|save-exact=!? before=q cpu=b libc=b os=b].freeze,
11
- install_a: %w[audit=! bin-links=! engine-strict=!? foreground-scripts=!? fund=! ignore-scripts=!?
12
- install-links=!? package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
11
+ install_a: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
12
+ package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
13
13
  install_b: %w[no-save B|save-bundle D|save-dev O|save-optional save-peer P|save-prod g|global=!?
14
14
  S|save=!?].freeze,
15
15
  install_c: %w[allow-directory=b? allow-file=b? allow-git=b? allow-remote=b?].freeze,
@@ -18,7 +18,6 @@ module Squared
18
18
  pack: %w[ignore-scripts=!? json=!? pack-destination=p].freeze,
19
19
  rebuild: %w[bin-links=! foreground-scripts=!? global=!? ignore-scripts=!? install-links=!?].freeze,
20
20
  'approve-scripts': %w[a|all allow-scripts-pending allow-scripts-pin=!? no-allow-scripts-pin json].freeze,
21
- 'deny-scripts': %w[a|all json].freeze,
22
21
  no: {
23
22
  install: %w[audit bin-links fund package-lock].freeze
24
23
  }.freeze
@@ -160,13 +159,13 @@ module Squared
160
159
  subtasks({
161
160
  'package' => %i[install add update dedupe approve deny rebuild reinstall].freeze,
162
161
  'outdated' => %i[major minor patch].freeze,
163
- 'bump' => %i[version major minor patch].freeze,
164
- 'publish' => %i[latest tag verify].freeze,
162
+ 'publish' => %i[latest tag stage verify].freeze,
165
163
  'tsc' => %i[project build].freeze,
166
164
  'add' => nil,
167
165
  'run' => nil,
168
166
  'exec' => nil,
169
167
  'nvm' => nil,
168
+ 'bump' => nil,
170
169
  'pack' => nil
171
170
  })
172
171
 
@@ -286,7 +285,7 @@ module Squared
286
285
 
287
286
  format_desc action, nil, 'version?,args*'
288
287
  task action, [:version] do |_, args|
289
- path = ->(s) { shell_quote(File.join(ENV['NVM_DIR'], s)) }
288
+ path = ->(s) { File.join(ENV['NVM_DIR'], s) }
290
289
  unless (version = args.version)
291
290
  cmd = ". #{path.call('nvm.sh')} && nvm list --no-colors --no-alias"
292
291
  version = pwd_set(from: :nvm) do
@@ -298,6 +297,18 @@ module Squared
298
297
  args.unshift(path.call('nvm-exec'))
299
298
  run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
300
299
  end
300
+ when 'bump'
301
+ format_desc action, nil, 'version|pre?{major,minor,patch}|prerelease'
302
+ task action, [:version] do |_, args|
303
+ version = param_guard(action, 'to', args: args, key: :version)
304
+ if version.match?(/^((pre)?(major|minor|patch))|prerelease$/)
305
+ flag = version.to_sym
306
+ version = nil
307
+ else
308
+ flag = :version
309
+ end
310
+ bump flag, version
311
+ end
301
312
  when 'pack'
302
313
  format_desc action, nil, 'opts*'
303
314
  task action do |_, args|
@@ -314,56 +325,13 @@ module Squared
314
325
  outdated flag, args.to_a
315
326
  end
316
327
  when 'package'
317
- case flag
318
- when :approve, :deny
319
- format_desc action, flag, 'name*|:,opts*'
320
- task flag do |_, args|
321
- args = args.to_a
322
- if args.first == ':'
323
- args.shift
324
- pwd_set do
325
- pad = 0
326
- list = IO.popen(npm_output('approve-scripts --allow-scripts-pending').to_s)
327
- .each_with_object([]) do |line, out|
328
- next unless line =~ /^\s+([a-z\d@][^@]*)@(\S+)/
329
-
330
- pad = [pad, $1.size].max
331
- out << [$1, $2]
332
- end
333
- .map { |name, ver| name.ljust(pad + 4) + ver }
334
- if list.empty?
335
- puts log_message('no packages to review', subject: name, hint: "#{flag}-scripts")
336
- exit 0
337
- end
338
- args.concat(choice_index('Select packages', list, multiple: true, column: /^(\S+)/))
339
- end
340
- end
341
- package flag, args
342
- end
343
- else
344
- format_desc(action, flag, 'opts*', before: case flag
345
- when :dedupe, :rebuild then nil
346
- when :reinstall then 'f/orce?'
347
- else 'name*'
348
- end)
349
- task flag do |_, args|
350
- package flag, args.to_a
351
- end
352
- end
353
- when 'bump'
354
- break unless version
355
-
356
- if flag == :version
357
- format_desc action, flag, 'version'
358
- task flag, [:version] do |_, args|
359
- version = param_guard(action, flag, args: args, key: :version)
360
- bump flag, version
361
- end
362
- else
363
- format_desc action, flag
364
- task flag do
365
- bump flag
366
- end
328
+ format_desc(action, flag, 'opts*', before: case flag
329
+ when :dedupe, :rebuild then nil
330
+ when :reinstall then 'force?'
331
+ else 'name*'
332
+ end)
333
+ task flag do |_, args|
334
+ package flag, args.to_a
367
335
  end
368
336
  when 'publish'
369
337
  if flag == :verify
@@ -377,22 +345,70 @@ module Squared
377
345
  publish(flag, version: version, ext: ext)
378
346
  end
379
347
  else
380
- format_desc(action, flag, 'otp?,p/ublic|r/estricted?,d/ry-run?',
381
- before: ('tag' if flag == :tag))
348
+ format_desc(action, flag,
349
+ "otp?,#{'registry?,' if flag == :stage}p/ublic|r/estricted?,d/ry-run?",
350
+ before: case flag
351
+ when :tag then 'tag'
352
+ when :stage then '{select=view,approve,reject,download}|publish=tag?'
353
+ end)
382
354
  task flag do |_, args|
383
355
  args = args.to_a
384
- access = if has_value!(args, 'r', 'restricted')
385
- 'restricted'
386
- elsif has_value!(args, 'p', 'public')
387
- 'public'
388
- end
389
- dryrun = has_value!(args, 'd', 'dry-run')
390
- if flag == :latest
356
+ access = nil
357
+ dryrun = nil
358
+ stage = []
359
+ parse = lambda do
360
+ access = if has_value!(args, 'r', 'restricted')
361
+ 'restricted'
362
+ elsif has_value!(args, 'p', 'public')
363
+ 'public'
364
+ end
365
+ dryrun = has_value!(args, 'd', 'dry-run')
366
+ end
367
+ case flag
368
+ when :stage
369
+ case args.first
370
+ when 'view', 'approve', 'reject', 'download'
371
+ out = pwd_set { `#{npm_output("stage list #{npmname} --json --loglevel=error")}` }
372
+ pad0 = 0
373
+ pad1 = 0
374
+ data = Array(parse_json(out, kind: Array)).map do |item|
375
+ ver = item['version']
376
+ tag = item['tag']
377
+ pad0 = [pad0, ver.size].max
378
+ pad1 = [pad1, tag.size].max
379
+ [ver, tag, item['id'], item['actor']]
380
+ end
381
+ if data.empty?
382
+ print_error('no staged releases', loglevel: Logger::INFO, subject: npmname)
383
+ exit 1
384
+ end
385
+ data.each do |item|
386
+ item[0] = item[0].rjust(pad0)
387
+ item[1] = item[1].rjust(pad1)
388
+ end
389
+ stage << args.shift
390
+ stage << choice_index('Select a release', data.map { |item| item.join(' ') },
391
+ column: /^(?:\S+\s+){2}(\S+)/)
392
+ if %w[approve reject].include?(stage.first)
393
+ otp = args.shift if args.first&.match?(/^\d+$/)
394
+ registry = args.first
395
+ option('otp', prefix: 'npm') { |val| otp = val }
396
+ option('registry', prefix: 'npm') { |val| registry = val }
397
+ end
398
+ else
399
+ stage << 'publish'
400
+ parse.call
401
+ tag, otp = args
402
+ end
403
+ when :latest
404
+ parse.call
391
405
  otp = args.first
392
406
  else
407
+ parse.call
393
408
  tag, otp = param_guard(action, flag, args: args)
394
409
  end
395
- publish(flag, otp: otp, tag: tag, access: access, dryrun: dryrun)
410
+ publish(flag, otp: otp, tag: tag, access: access, stage: stage, registry: registry,
411
+ dryrun: dryrun)
396
412
  end
397
413
  end
398
414
  when 'tsc'
@@ -449,7 +465,7 @@ module Squared
449
465
  return if items.empty?
450
466
 
451
467
  on :first, :copy
452
- print_item unless @output[0] || silent? || task_invoked?(/^copy(?::#{Node.ref}|$)/)
468
+ print_item unless @output[0] || silent? || task_invoked?(/^copy(:#{Node.ref}|$)/)
453
469
  packed = false
454
470
  items.each do |dir|
455
471
  case dir
@@ -464,7 +480,7 @@ module Squared
464
480
  @workspace.rev_clear(proj.name, sync: sync)
465
481
  proj.path
466
482
  else
467
- log.warn message("copy project :#{dir}", hint: 'missing')
483
+ log.warn message('target not found', dir, hint: 'copy')
468
484
  nil
469
485
  end
470
486
  when Hash
@@ -484,7 +500,7 @@ module Squared
484
500
  dest = dir.path
485
501
  @workspace.rev_clear(dir.name, sync: sync)
486
502
  else
487
- raise_error TypeError, "unknown: #{dir}", hint: 'copy'
503
+ raise TypeError, message('unknown', dir, hint: 'copy')
488
504
  end
489
505
  next unless from && dest&.directory?
490
506
 
@@ -546,7 +562,7 @@ module Squared
546
562
  if sub
547
563
  target << [entry, dest.join(into, sub)]
548
564
  else
549
- log.debug message("#{dependname} in \"#{entry}\"", hint: 'missing')
565
+ log.debug message("missing #{dependname} in \"#{entry}\"", hint: 'copy')
550
566
  end
551
567
  end
552
568
  else
@@ -595,7 +611,7 @@ module Squared
595
611
  rm = lambda do |target|
596
612
  return if remove.empty?
597
613
 
598
- run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '), sync: sync, from: :remove)
614
+ run(target.temp(*remove).sub!(/ (add|install) /, ' remove '), sync: sync, from: :remove)
599
615
  end
600
616
  yarn = dependtype(:yarn)
601
617
  if yarn > 0
@@ -612,7 +628,7 @@ module Squared
612
628
  cmd << '--mode=skip-build' if option('ignore-scripts')
613
629
  cmd << '--check-cache' if !flag && option('force')
614
630
  end
615
- if nolockfile?('yarn')
631
+ if nolockfile?(prefix: 'yarn')
616
632
  cmd << '--no-lockfile'
617
633
  elsif option('ci')
618
634
  if yarn == 1
@@ -648,7 +664,7 @@ module Squared
648
664
  cmd << '--ignore-workspace' if ws
649
665
  cmd << if option('force')
650
666
  '--force'
651
- elsif nolockfile?('pnpm')
667
+ elsif nolockfile?(prefix: 'pnpm')
652
668
  '--no-lockfile'
653
669
  elsif option('ci')
654
670
  '--frozen-lockfile'
@@ -656,7 +672,8 @@ module Squared
656
672
  cmd << '--ignore-scripts' if option('ignore-scripts')
657
673
  cmd << '--dangerously-allow-all-builds' if option('approve-builds')
658
674
  else
659
- cmd = session('npm', (ci = option('ci', prefix: 'npm')) ? 'ci' : 'install')
675
+ cmd = session 'npm'
676
+ cmd << (ci = option('ci') ? 'ci' : 'install')
660
677
  option('approve-scripts') do |val|
661
678
  cmd = npm_output 'approve-scripts'
662
679
  cmd << case val
@@ -670,26 +687,6 @@ module Squared
670
687
  print_run cmd, silent?
671
688
  run(cmd, banner: false)
672
689
  end
673
- option('allow-scripts', ignore: false) do |val|
674
- cmd << case val
675
- when '0'
676
- '--ignore-scripts'
677
- when 'false'
678
- '--strict-allow-scripts'
679
- when '1', 'true'
680
- '--dangerously-allow-all-scripts'
681
- else
682
- quote_option 'allow-scripts', val
683
- end
684
- end
685
- option('engine-strict', ignore: false) do |val|
686
- cmd << case val
687
- when '0', 'false'
688
- '--engine-strict=false'
689
- else
690
- '--engine-strict'
691
- end
692
- end
693
690
  cmd << '--workspaces=false' if ws
694
691
  cmd << '--force' if option('force')
695
692
  append_nocolor
@@ -709,7 +706,7 @@ module Squared
709
706
  append_platform
710
707
  end
711
708
  end
712
- cmd << '--package-lock=false' << 'save=false' if nolockfile?('npm')
709
+ cmd << '--package-lock=false' << 'save=false' if nolockfile?(prefix: 'npm')
713
710
  cmd << '--ignore-scripts' if option('ignore-scripts')
714
711
  end
715
712
  if add
@@ -789,7 +786,7 @@ module Squared
789
786
  end
790
787
  next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
791
788
 
792
- f = semscan file
789
+ f = semscan(file, fill: !option('save-exact').nil?)
793
790
  w = semscan want
794
791
  a = f[0]
795
792
  b = f[2]
@@ -799,8 +796,12 @@ module Squared
799
796
  when :major
800
797
  a == '0' ? c == '0' || c == '1' : true
801
798
  when :minor
799
+ next unless f[4]
800
+
802
801
  ch == '^' && (a == '0' ? c == '0' && b == d : a == c)
803
802
  when :patch
803
+ next unless b && f[4]
804
+
804
805
  a == c && b == d && f[4] != w[4]
805
806
  end
806
807
  if upgrade && !w[6]
@@ -812,7 +813,7 @@ module Squared
812
813
  a == '0' ? 1 : 3
813
814
  else
814
815
  5
815
- end, major, f, w]
816
+ end, major, semscan(file), w]
816
817
  elsif !major
817
818
  avail << [key, file, latest, latest != current]
818
819
  end
@@ -859,17 +860,17 @@ module Squared
859
860
  end
860
861
  a = a.ljust(col1)
861
862
  b = b.ljust(col2)
862
- b = sub_style b, theme[:current] if theme[:current] && !stdin?
863
+ sub_style! b, theme[:current] if theme[:current] && !stdin?
863
864
  if cur == -1
864
865
  c = 'SKIP'
865
866
  elsif modified == cur
866
867
  c = 'FAIL'
867
868
  elsif !stdin?
868
869
  if d == 1
869
- a = sub_style a, theme[:major]
870
- c = sub_style c, :bold, color(:green)
870
+ sub_style! a, theme[:major]
871
+ sub_style! c, :bold, color(:green)
871
872
  else
872
- c = sub_style(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
873
+ sub_style!(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
873
874
  end
874
875
  g = item
875
876
  end
@@ -942,8 +943,8 @@ module Squared
942
943
  b = sub_style b.ljust(col2), color(d ? :red : :yellow)
943
944
  c = c.ljust(col3)
944
945
  unless d
945
- a = sub_style a, theme[:active]
946
- c = sub_style c, color(:green)
946
+ sub_style! a, theme[:active]
947
+ sub_style! c, color(:green)
947
948
  pending += 1
948
949
  end
949
950
  puts "#{pad.call(i, avail)}. #{(a + c + b).subhint(d ? 'locked' : 'latest')}"
@@ -960,18 +961,14 @@ module Squared
960
961
  end
961
962
 
962
963
  def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil,
963
- version: nil, ext: [], workspace: false)
964
+ version: nil, stage: [], registry: nil, ext: [], workspace: false)
964
965
  if read_package('private')
965
- return if workspace
966
+ return if workspace || !stage.empty?
966
967
 
967
- ws = children.select { |proj| proj.ref?(Node.ref) }
968
- if ws.empty?
969
- print_error('nothing to publish', subject: name, hint: 'private')
970
- elsif confirm_basic("#{flag == :verify ? 'Verify' : 'Publish'} workspace?", ws.map(&:name).join(', '), 'N')
971
- ws.each do |proj|
972
- proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun, version: version,
973
- ext: ext, workspace: true)
974
- end
968
+ from, accept = flag == :verify ? %w[verify Y] : %w[publish N]
969
+ each(accept: accept, ref: Node.ref, from: from) do |proj|
970
+ proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun, version: version,
971
+ ext: ext, workspace: true)
975
972
  end
976
973
  elsif version ||= self.version
977
974
  if flag == :verify
@@ -1042,24 +1039,35 @@ module Squared
1042
1039
  end
1043
1040
  end
1044
1041
  else
1045
- cmd = session 'npm', 'publish'
1046
- cmd << basic_option('otp', otp) if otp ||= option('otp')
1047
- cmd << basic_option('tag', tag.tr(' ', '-')) if tag ||= option('tag')
1048
- case access || option('access')
1049
- when 'p', 'public'
1050
- cmd << '--access=public'
1051
- when 'r', 'restricted'
1052
- cmd << '--access=restricted'
1042
+ args = ['npm']
1043
+ if stage.empty?
1044
+ args << 'publish'
1045
+ else
1046
+ args << 'stage' << stage.shift
1047
+ args.concat(stage)
1048
+ end
1049
+ cmd = session(*args)
1050
+ if stage.empty?
1051
+ otp ||= option('otp')
1052
+ cmd << basic_option('tag', tag.tr(' ', '-')) if tag ||= option('tag')
1053
+ case access || option('access')
1054
+ when 'p', 'public'
1055
+ cmd << '--access=public'
1056
+ when 'r', 'restricted'
1057
+ cmd << '--access=restricted'
1058
+ end
1059
+ dryrun ||= dryrun?(prefix: 'npm')
1053
1060
  end
1054
- dryrun ||= dryrun?('npm')
1061
+ cmd << basic_option('otp', otp) if otp
1062
+ cmd << quote_option('registry', registry) if registry
1055
1063
  if dryrun
1056
1064
  cmd << '--dry-run'
1057
1065
  else
1058
- from = :'npm:publish'
1059
1066
  log.info cmd.to_s
1067
+ from = symjoin args.take(3)
1060
1068
  end
1061
1069
  if sync
1062
- run(sync: sync, from: from, interactive: !dryrun && ['Publish', 'N', npmname])
1070
+ run(sync: sync, from: from, interactive: !dryrun && stage.empty? && ['Publish', 'N', npmname])
1063
1071
  else
1064
1072
  require 'open3'
1065
1073
  on :first, from
@@ -1074,13 +1082,12 @@ module Squared
1074
1082
  end
1075
1083
  end
1076
1084
  elsif !workspace
1077
- print_error("version: #{dependname}", subject: name, hint: 'not found')
1085
+ print_error('version not found', subject: name, hint: dependname)
1078
1086
  end
1079
1087
  end
1080
1088
 
1081
1089
  def package(flag, opts = [], packages: [], from: nil)
1082
1090
  workspace.rev_clear(name)
1083
- force = true if flag == :reinstall && has_value!(opts, 'f')
1084
1091
  yarn = dependtype(:yarn)
1085
1092
  if yarn > 0 && !(yarn == 1 && ((flag == :update && !packages.empty?) || %i[approve deny
1086
1093
  rebuild].include?(flag)))
@@ -1094,8 +1101,8 @@ module Squared
1094
1101
  end
1095
1102
  when :reinstall
1096
1103
  if yarn == 1
1097
- remove_modules 'yarn' if opts.include?('force') || force
1098
- elsif opts.delete('force') || force
1104
+ remove_modules(prefix: 'yarn') if opts.include?('force')
1105
+ elsif opts.delete('force')
1099
1106
  opts << 'check-cache'
1100
1107
  end
1101
1108
  opts << 'no-lockfile' if lockfile(true)
@@ -1115,7 +1122,7 @@ module Squared
1115
1122
  end
1116
1123
  end, cmd, project: self, strict: strict?)
1117
1124
  if yarn == 1 && flag != :reinstall
1118
- op << '--no-lockfile' if nolockfile?('yarn')
1125
+ op << '--no-lockfile' if nolockfile?(prefix: 'yarn')
1119
1126
  op << '--ignore-engines' if option('ignore-engines')
1120
1127
  end
1121
1128
  else
@@ -1128,7 +1135,7 @@ module Squared
1128
1135
  else
1129
1136
  case flag
1130
1137
  when :install, :update
1131
- opts << 'no-lockfile' if nolockfile?('pnpm')
1138
+ opts << 'no-lockfile' if nolockfile?(prefix: 'pnpm')
1132
1139
  spec = 0 if flag == :update
1133
1140
  when :add
1134
1141
  spec = 1
@@ -1158,13 +1165,13 @@ module Squared
1158
1165
  else
1159
1166
  case flag
1160
1167
  when :install, :update
1161
- opts.unshift('package-lock=false', 'save=false') if nolockfile?('npm')
1168
+ opts.unshift('package-lock=false', 'save=false') if nolockfile?(prefix: 'npm')
1162
1169
  spec = flag == :install ? 0 : 2
1163
1170
  when :add
1164
1171
  spec = 1
1165
1172
  flag = :install
1166
1173
  when :reinstall
1167
- remove_modules 'npm' if opts.delete('force') || force
1174
+ remove_modules(prefix: 'npm') if opts.delete('force')
1168
1175
  opts.unshift('package-lock=false') if lockfile(true)
1169
1176
  flag = :install
1170
1177
  end
@@ -1225,35 +1232,41 @@ module Squared
1225
1232
  run(from: from || symjoin('package', flag))
1226
1233
  end
1227
1234
 
1228
- def bump(flag, val = nil)
1229
- return unless val ||= sembump(version, flag)
1235
+ def bump(flag = :patch, val = nil, workspace: false)
1236
+ if read_package('private')
1237
+ return if workspace
1230
1238
 
1231
- doc = dependfile.read
1232
- if doc.sub!(/"version"\s*:\s*"#{version}"/, "\"version\": \"#{val}\"")
1233
- unless dryrun?
1234
- log.info "bump version #{version} to #{val.subhint(flag)}"
1235
- on :first, :bump
1236
- dependfile.write(doc)
1237
- end
1238
- if stdin?
1239
- puts val
1240
- elsif !silent?
1241
- major = flag == :major
1242
- emphasize("version: #{val}", title: name, border: borderstyle, sub: [
1243
- headerstyle,
1244
- opt_style(color(major ? :green : :yellow), /\A(version:)( )(\S+)(.*)\z/, 3),
1245
- opt_style(theme[major ? :major : :active], /\A(version:)(.*)\z/)
1246
- ])
1247
- end
1248
- unless dryrun?
1249
- commit(:add, [dependname], pass: true)
1250
- on :last, :bump
1239
+ each(accept: 'N', ref: Node.ref, from: 'bump') { |proj| proj.bump(flag, val, workspace: true) }
1240
+ elsif val ||= version && sembump(version, flag)
1241
+ begin
1242
+ doc = dependfile.read
1243
+ unless doc.sub!(/"version"\s*:\s*"#{version}"/, "\"version\": \"#{val}\"")
1244
+ raise message('version not found', hint: dependfile)
1245
+ end
1246
+
1247
+ unless dryrun?
1248
+ log.info "bump version #{version} to #{val.subhint(flag)}"
1249
+ on :first, :bump
1250
+ dependfile.write(doc)
1251
+ end
1252
+ if stdin?
1253
+ puts val
1254
+ elsif !silent?
1255
+ major = flag == :major
1256
+ emphasize("version: #{val}", title: name, border: borderstyle, sub: [
1257
+ headerstyle,
1258
+ opt_style(color(major ? :green : :yellow), /\A(version:)( )(\S+)(.*)\z/, 3),
1259
+ opt_style(theme[major ? :major : :active], /\A(version:)(.*)\z/)
1260
+ ])
1261
+ end
1262
+ unless dryrun?
1263
+ commit(:add, [dependname], pass: true)
1264
+ on :last, :bump
1265
+ end
1266
+ rescue => e
1267
+ on_error(e, dryrun: dryrun?)
1251
1268
  end
1252
- else
1253
- raise_error 'version not found', hint: dependfile
1254
1269
  end
1255
- rescue => e
1256
- on_error(e, dryrun: dryrun?)
1257
1270
  end
1258
1271
 
1259
1272
  def pack(opts = [])
@@ -1325,7 +1338,8 @@ module Squared
1325
1338
 
1326
1339
  if script
1327
1340
  ret = session dependbin, 'run'
1328
- raise_error "#{dependbin} run: #{target}", hint: from unless append_any(target, build: true)
1341
+ raise message(dependbin, 'run', target, hint: from) unless append_any(target, build: true)
1342
+
1329
1343
  append_any opts if opts
1330
1344
  append_loglevel
1331
1345
  append_any(args, delim: true) if args
@@ -1339,7 +1353,7 @@ module Squared
1339
1353
  when Enumerable
1340
1354
  target.to_a.join(' ')
1341
1355
  else
1342
- raise_error TypeError, "unknown: #{target}", hint: 'compose'
1356
+ raise TypeError, message('unknown', target, hint: 'compose')
1343
1357
  end
1344
1358
  end
1345
1359
  end
@@ -1439,11 +1453,7 @@ module Squared
1439
1453
  end
1440
1454
 
1441
1455
  def dependbin
1442
- if yarn?
1443
- 'yarn'
1444
- else
1445
- pnpm? ? 'pnpm' : 'npm'
1446
- end
1456
+ yarn? ? 'yarn' : pnpm? ? 'pnpm' : 'npm'
1447
1457
  end
1448
1458
 
1449
1459
  def version
@@ -1499,7 +1509,8 @@ module Squared
1499
1509
  next if yarntype(exist: true) == 0
1500
1510
  when /^pnpm/
1501
1511
  next if pnpmtype(exist: true) == 0
1502
- when /^npm/ then nil
1512
+ when /^npm/
1513
+ nil
1503
1514
  else
1504
1515
  next
1505
1516
  end
@@ -1552,9 +1563,9 @@ module Squared
1552
1563
  end
1553
1564
  end
1554
1565
 
1555
- def remove_modules(prefix = dependbin)
1556
- modules = basepath!('node_modules', type: 'd')
1557
- return false unless modules && confirm_basic('Remove?', modules, prefix: prefix)
1566
+ def remove_modules(prefix: dependbin)
1567
+ modules = basepath 'node_modules'
1568
+ return false unless modules.directory? && confirm_basic('Remove?', modules, prefix: prefix)
1558
1569
 
1559
1570
  modules.rmtree
1560
1571
  rescue Timeout::Error => e
@@ -1617,7 +1628,7 @@ module Squared
1617
1628
  end
1618
1629
 
1619
1630
  def dependroot
1620
- dependname if parent&.has?('outdated', Node.ref)
1631
+ dependname if parent&.has?('outdated', ref: Node.ref)
1621
1632
  end
1622
1633
 
1623
1634
  def npmname
@@ -1642,11 +1653,7 @@ module Squared
1642
1653
  end
1643
1654
 
1644
1655
  def lockfile(delete = false)
1645
- ret = basepath(if yarn?
1646
- 'yarn.lock'
1647
- else
1648
- pnpm? ? 'pnpm-lock.yaml' : 'package-lock.json'
1649
- end)
1656
+ ret = basepath(yarn? ? 'yarn.lock' : pnpm? ? 'pnpm-lock.yaml' : 'package-lock.json')
1650
1657
  if ret.exist?
1651
1658
  if delete
1652
1659
  ret.delete
@@ -1665,11 +1672,11 @@ module Squared
1665
1672
  @serve != false
1666
1673
  end
1667
1674
 
1668
- def nolockfile?(prefix = dependbin)
1675
+ def nolockfile?(prefix: dependbin)
1669
1676
  option('package-lock', 'lockfile', prefix: prefix, equals: '0') || !option('no-lockfile', prefix: prefix).nil?
1670
1677
  end
1671
1678
 
1672
- def dryrun?(prefix = dependbin)
1679
+ def dryrun?(prefix: dependbin)
1673
1680
  super(target: @session, prefix: prefix)
1674
1681
  end
1675
1682
  end