Module: DocOpsLab::Dev::Initializer

Defined in:
lib/docopslab/dev/initializer.rb

Class Method Summary collapse

Class Method Details

.bootstrap_project(context = nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/docopslab/dev/initializer.rb', line 74

def bootstrap_project context = nil
  puts '🚀 Bootstrapping DocOps Lab project...'
  puts ''

  created = []

  # Core project files
  created << 'Git repository' if init_git_repository
  created << '.gitignore' if create_gitignore_stub
  # Skip Gemfile; not needed for Docker workflow, template available if needed
  created << 'Rakefile' if create_rakefile_stub

  # DocOpsLab-specific
  create_project_manifest
  created << '.config/docopslab-dev.yml' unless File.exist?(MANIFEST_PATH)

  puts ''
  if created.any?
    puts "✅ Bootstrap complete! Created: #{created.join(', ')}"
  else
    puts '✅ Bootstrap files already exist'
  end

  # Initialize templates from manifest (if context provided, use it; else use Dev context)
  context ||= Dev
  puts ''
  puts '🎨 Initializing templates from manifest...'
  template_results = CastOps.init_cast_targets(context)

  if template_results.any?
    puts "✅ Initialized #{template_results.size} template(s)"
  else
    puts '✅ Templates already initialized'
  end

  puts ''
  puts 'Next steps:'
  puts '  1. bundle exec rake labdev:sync:all  # or: docker run ... labdev:sync:all'
  puts '  2. Review and customize the generated files'
  puts '  3. Start using labdev tasks: bundle exec rake labdev:check:env'
end

.create_gemfile_stubObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/docopslab/dev/initializer.rb', line 35

def create_gemfile_stub
  if File.exist?('Gemfile')
    puts '⏭️  Gemfile already exists, skipping'
    return false
  end

  Library.ensure_available!
  stub = Library.resolve('templates/Gemfile') ||
         raise('Library templates/Gemfile not found; run `labdev:sync:library`.')
  FileUtils.cp(stub, 'Gemfile')
  puts '✅ Created Gemfile'
  true
end

.create_gitignore_stubObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/docopslab/dev/initializer.rb', line 21

def create_gitignore_stub
  if File.exist?('.gitignore')
    puts '⏭️  .gitignore already exists, skipping'
    return false
  end

  Library.ensure_available!
  stub = Library.resolve('templates/gitignore') ||
         raise('Library templates/gitignore not found; run `labdev:sync:library`.')
  FileUtils.cp(stub, '.gitignore')
  puts '✅ Created .gitignore file'
  true
end

.create_project_manifestObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/docopslab/dev/initializer.rb', line 9

def create_project_manifest
  return if File.exist?(MANIFEST_PATH)

  puts '📋 Creating docopslab-dev.yml...'

  FileUtils.mkdir_p('.config')

  # Copy template from gem
  FileUtils.cp(Dev.manifest_def_path, MANIFEST_PATH)
  puts "✅ Created #{MANIFEST_PATH}"
end

.create_rakefile_stubObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/docopslab/dev/initializer.rb', line 49

def create_rakefile_stub
  if File.exist?('Rakefile')
    puts '⏭️  Rakefile already exists, skipping'
    return false
  end

  Library.ensure_available!
  stub = Library.resolve('templates/Rakefile') ||
         raise('Library templates/Rakefile not found; run `labdev:sync:library`.')
  FileUtils.cp(stub, 'Rakefile')
  puts '✅ Created Rakefile'
  true
end

.init_git_repositoryObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/docopslab/dev/initializer.rb', line 63

def init_git_repository
  if Dir.exist?('.git')
    puts '⏭️  Git repository already initialized, skipping'
    return false
  end

  system('git', 'init')
  puts '✅ Initialized Git repository'
  true
end