Method: PDK::Module::Convert#run

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

#runObject



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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/pdk/module/convert.rb', line 23

def run
  stage_changes!

  unless update_manager.changes?
    if adding_tests?
      add_tests!
      print_result 'Convert completed'
    else
      require 'pdk/report'

      PDK::Report.default_target.puts(_('No changes required.'))
    end

    return
  end

  print_summary

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

  return if noop?

  unless force?
    require 'pdk/cli/util'

    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.
  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!

  add_tests! if adding_tests?

  print_result 'Convert completed'
end