Vendor the external cookbooks
Knife-Zero doesn't include Berkshelf support, so vendoring everything in the repo is convenient again
This commit is contained in:
12
cookbooks/composer/recipes/default.rb
Normal file
12
cookbooks/composer/recipes/default.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Cookbook Name:: composer
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright (c) 2016, David Joos
|
||||
#
|
||||
|
||||
include_recipe 'composer::install'
|
||||
|
||||
if node['composer']['install_globally']
|
||||
include_recipe 'composer::global_configs'
|
||||
end
|
||||
45
cookbooks/composer/recipes/global_configs.rb
Normal file
45
cookbooks/composer/recipes/global_configs.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Cookbook Name:: composer
|
||||
# Recipe:: global_configs
|
||||
#
|
||||
# Copyright (c) 2016, David Joos
|
||||
#
|
||||
|
||||
configs = node['composer']['global_configs']
|
||||
|
||||
unless configs.nil?
|
||||
configs.each_pair do |user, user_configs|
|
||||
user_composer_dir = "#{Dir.home(user)}/.composer"
|
||||
|
||||
directory user_composer_dir do
|
||||
owner user
|
||||
group user
|
||||
mode '0755'
|
||||
action :create
|
||||
end
|
||||
|
||||
user_configs.nil? && next
|
||||
|
||||
user_configs.each_pair do |option, value|
|
||||
if value.respond_to?(:each_pair)
|
||||
value.each_pair do |value_k, value_v|
|
||||
execute "composer-config-for-#{user}" do
|
||||
command "composer config --global #{option}.#{value_k} #{value_v}"
|
||||
environment 'COMPOSER_HOME' => user_composer_dir
|
||||
user user
|
||||
group user
|
||||
action :run
|
||||
end
|
||||
end
|
||||
else
|
||||
execute "composer-config-for-#{user}" do
|
||||
command "composer config --global #{option} #{value}"
|
||||
environment 'COMPOSER_HOME' => user_composer_dir
|
||||
user user
|
||||
group user
|
||||
action :run
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
36
cookbooks/composer/recipes/install.rb
Executable file
36
cookbooks/composer/recipes/install.rb
Executable file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# Cookbook Name:: composer
|
||||
# Recipe:: install
|
||||
#
|
||||
# Copyright (c) 2016, David Joos
|
||||
#
|
||||
|
||||
include_recipe node['composer']['php_recipe']
|
||||
|
||||
if node['platform'] == 'windows'
|
||||
windows_package 'Composer - PHP Dependency Manager' do
|
||||
source node['composer']['url']
|
||||
options %w(
|
||||
/VERYSILENT
|
||||
).join(' ')
|
||||
end
|
||||
|
||||
install_dir = "#{node['composer']['install_dir'].tr('/', '\\')}\\bin"
|
||||
|
||||
ENV['PATH'] += ";#{install_dir}"
|
||||
windows_path install_dir
|
||||
else
|
||||
log '[composer] phar (PHP archive) not supported' do
|
||||
level :warn
|
||||
not_if "php -m | grep 'Phar'"
|
||||
end
|
||||
|
||||
file = node['composer']['install_globally'] ? "#{node['composer']['install_dir']}/composer" : "#{node['composer']['install_dir']}/composer.phar"
|
||||
|
||||
remote_file file do
|
||||
source node['composer']['url']
|
||||
mode node['composer']['mask']
|
||||
action :create
|
||||
not_if { ::File.exist?(file) }
|
||||
end
|
||||
end
|
||||
16
cookbooks/composer/recipes/self_update.rb
Normal file
16
cookbooks/composer/recipes/self_update.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Cookbook Name:: composer
|
||||
# Recipe:: self_update
|
||||
#
|
||||
# Copyright (c) 2016, David Joos
|
||||
#
|
||||
|
||||
include_recipe 'composer::install'
|
||||
|
||||
execute 'composer-self_update' do
|
||||
cwd node['composer']['install_dir']
|
||||
command 'composer self-update'
|
||||
environment 'COMPOSER_HOME' => Composer.home_dir(node)
|
||||
action :run
|
||||
ignore_failure true
|
||||
end
|
||||
Reference in New Issue
Block a user