Class: Bolt::ProjectManager::ModuleMigrator

Inherits:
Migrator
  • Object
show all
Defined in:
lib/bolt/project_manager/module_migrator.rb

Instance Method Summary collapse

Methods inherited from Migrator

#initialize

Constructor Details

This class inherits a constructor from Bolt::ProjectManager::Migrator

Instance Method Details

#migrate(project, configured_modulepath) ⇒ Object



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
# File 'lib/bolt/project_manager/module_migrator.rb', line 8

def migrate(project, configured_modulepath)
  return true if project.managed_moduledir.exist?

  @outputter.print_message "Migrating project modules\n\n"

  config            = project.project_file
  puppetfile        = project.puppetfile
  managed_moduledir = project.managed_moduledir
  new_modulepath    = [(project.path + 'modules').to_s]
  old_modulepath    = [(project.path + 'modules').to_s,
                       (project.path + 'site-modules').to_s,
                       (project.path + 'site').to_s]

  # Notify user to manually migrate modules if using non-default modulepath
  if configured_modulepath != new_modulepath && configured_modulepath != old_modulepath
    @outputter.print_action_step(
      "Project has a non-default configured modulepath, unable to automatically "\
      "migrate project modules. To migrate project modules manually, see "\
      "http://pup.pt/bolt-modules"
    )
    true
  # Migrate modules from Puppetfile
  elsif File.exist?(puppetfile)
    migrate_modules_from_puppetfile(config, puppetfile, managed_moduledir, old_modulepath)
  # Migrate modules to updated modulepath
  else
    consolidate_modules(old_modulepath)
    update_project_config([], config)
  end
end