Sha256: 6b767d8d1f7f6ca5ef9add6bc46bf2a6797119db31c60b0cdd0547ea73dd4bb7

Contents?: true

Size: 1.99 KB

Versions: 8

Compression:

Stored size: 1.99 KB

Contents

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)

# cookbook root dir
directory cookbook_dir

# metadata.rb
template "#{cookbook_dir}/metadata.rb" do
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# README
template "#{cookbook_dir}/README.md" do
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# chefignore
cookbook_file "#{cookbook_dir}/chefignore"

# Berks
cookbook_file "#{cookbook_dir}/Berksfile" do
  action :create_if_missing
end

# TK & Serverspec
template "#{cookbook_dir}/.kitchen.yml" do
  source 'kitchen.yml.erb'
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

directory "#{cookbook_dir}/test/integration/default/serverspec" do
  recursive true
end

directory "#{cookbook_dir}/test/integration/helpers/serverspec" do
  recursive true
end

cookbook_file "#{cookbook_dir}/test/integration/helpers/serverspec/spec_helper.rb" do
  source 'serverspec_spec_helper.rb'
  action :create_if_missing
end

template "#{cookbook_dir}/test/integration/default/serverspec/default_spec.rb" do
  source 'serverspec_default_spec.rb.erb'
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# Chefspec
directory "#{cookbook_dir}/spec/unit/recipes" do
  recursive true
end

cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
  action :create_if_missing
end

template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
  source "recipe_spec.rb.erb"
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# Recipes

directory "#{cookbook_dir}/recipes"

template "#{cookbook_dir}/recipes/default.rb" do
  source "recipe.rb.erb"
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# git
if context.have_git
  if !context.skip_git_init

    execute("initialize-git") do
      command("git init .")
      cwd cookbook_dir
    end
  end

  cookbook_file "#{cookbook_dir}/.gitignore" do
    source "gitignore"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
chef-dk-0.8.0 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.7.0 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.6.2 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.6.1 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.6.0 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.5.1 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.5.0 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
chef-dk-0.5.0.rc.1 lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb