Method: PDK::Module::Update#run

Defined in:
lib/pdk/module/update.rb

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pdk/module/update.rb', line 8

def run
  template_uri.uri_fragment = new_template_version

  stage_changes!

  if current_version == new_version
    PDK.logger.debug _('This module is already up to date with version %{version} of the template.') % {
      version: new_version,
    }
  end

  unless update_manager.changes?
    PDK::Report.default_target.puts(_('No changes required.'))
    return
  end

  PDK.logger.info(update_message)

  print_summary
  full_report('update_report.txt') unless update_manager.changes[:modified].empty?

  return if noop?

  unless force?
    message = _('Do you want to continue and make these changes to your module?')
    return unless PDK::CLI::Util.prompt_for_yes(message)
  end

  # Remove these files straight away as these changes are not something
  # that the user needs to review.
  update_manager.unlink_file('Gemfile.lock')
  update_manager.unlink_file(File.join('.bundle', 'config'))

  update_manager.sync_changes!

  require 'pdk/util/bundler'
  PDK::Util::Bundler.ensure_bundle!

  print_result 'Update completed'
end