Method: PDK::Module::Convert#run

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

#runObject



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
48
49
50
51
52
53
54
# File 'lib/pdk/module/convert.rb', line 19

def run
  stage_changes!

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

  print_summary

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

  return if noop?

  unless force?
    PDK.logger.info _(
      'Module conversion is a potentially destructive action. ' \
      'Ensure that you have committed your module to a version control ' \
      'system or have a backup, and review the changes above before continuing.',
    )
    continue = PDK::CLI::Util.prompt_for_yes(_('Do you want to continue and make these changes to your module?'))
    return unless continue
  end

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

  update_manager.sync_changes!

  PDK::Util::Bundler.ensure_bundle! if needs_bundle_update?

  print_result 'Convert completed'
end