class ChefCLI::PolicyfileServices::Install

def generate_lock_and_install

def generate_lock_and_install
  policyfile_compiler.error!
  ui.msg "Building policy #{policyfile_compiler.name}"
  ui.msg "Expanded run list: " + expanded_run_list + "\n"
  ui.msg "Caching Cookbooks..."
  policyfile_compiler.install
  lock_data = policyfile_compiler.lock.to_lock
  with_file(policyfile_lock_expanded_path) do |f|
    f.print(FFI_Yajl::Encoder.encode(lock_data, pretty: true ))
  end
  ui.msg ""
  ui.msg "Lockfile written to #{policyfile_lock_expanded_path}"
  ui.msg "Policy revision id: #{policyfile_lock.revision_id}"
rescue => error
  raise PolicyfileInstallError.new("Failed to generate Policyfile.lock", error)
end