Class: Bundler::Interactive::UpdateInteractive

Inherits:
Plugin::API
  • Object
show all
Defined in:
lib/bundler/interactive/update_interactive.rb

Overview

The bundle update-interactive command.

Renders a navigable table of outdated gems: up/down move between gems, left/right cycle a gem's target version (current / in-range latest / absolute latest), space skips or restores a row, enter applies the selection, and q (or Ctrl-C) cancels.

Defined Under Namespace

Classes: ResolvedSpecs

Constant Summary collapse

KEY_UP =
["\e[A", "\eOA"].freeze
KEY_DOWN =
["\e[B", "\eOB"].freeze
KEY_RIGHT =
["\e[C", "\eOC"].freeze
KEY_LEFT =
["\e[D", "\eOD"].freeze
KEY_RETURN =
["\r", "\n"].freeze
KEY_SPACE =
[' '].freeze
KEY_QUIT =
['q', "\e"].freeze
ROLE_ORDER =

Fixed version columns, mirroring yarn upgrade-interactive.

%i[current in_range latest].freeze
COLUMN_LABELS =
{ current: 'Current', in_range: 'Range', latest: 'Latest' }.freeze
LEVEL_COLOR =

Semver bump levels, coloured like yarn upgrade-interactive.

{ major: '31', minor: '33', patch: '32' }.freeze

Instance Method Summary collapse

Instance Method Details

#exec(_command, _args) ⇒ Object

red / yellow / green



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/bundler/interactive/update_interactive.rb', line 61

def exec(_command, _args)
  if outdated_gems.empty?
    Bundler.ui.info('Bundle up to date!')
    return
  end

  selection = interactive_select
  return Bundler.ui.info('Canceling...') if selection.nil?

  chosen = selection.reject(&:skip?)
  return Bundler.ui.info('No gems selected.') if chosen.empty?

  Update.new(chosen).update!
# TTY::Reader raises InputInterrupt (a subclass of Interrupt) on Ctrl-C
# because the reader is created with `interrupt: :error`. Rescue Interrupt
# directly so exception handling never references the TTY constant, which
# keeps a clear error if the dependency ever fails to load.
rescue Interrupt
  show_cursor
  Bundler.ui.info("\nCanceling...")
end

#outdated_gemsObject



83
84
85
86
87
88
89
90
# File 'lib/bundler/interactive/update_interactive.rb', line 83

def outdated_gems
  @outdated_gems ||= VersionResolver.new(
    current_specs: current_gems,
    resolved_definition: definition,
    dependencies: dependencies,
    cooldown_days: cooldown_days
  ).outdated_gems
end