Comparar commits
22 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| ea88bfaa67 | |||
| 9a0ef56a79 | |||
| 8b0e3629ca | |||
| a1c94e6dae | |||
| 50839ca168 | |||
| 5d41523585 | |||
| 156c804dd4 | |||
| ce43bb2471 | |||
| 162c90bfcc | |||
| 3ba898244a | |||
| 68ad7e4f40 | |||
| 78f6b4c626 | |||
| 844d795a35 | |||
| 79e528c93a | |||
| ee2714015e | |||
| ded1b794ec | |||
| 964b2696c6 | |||
| 71aadb793d | |||
| e621a1a6cb | |||
| e73e56ac4a | |||
| 55b9a6ab81 | |||
| c916593496 |
@@ -41,3 +41,20 @@ suites:
|
||||
- name: npm
|
||||
run_list:
|
||||
- recipe[nodejs::npm]
|
||||
- recipe[nodejs_test::npm]
|
||||
- name: npm_embedded
|
||||
run_list:
|
||||
- recipe[nodejs::npm]
|
||||
- recipe[nodejs_test::npm]
|
||||
attributes:
|
||||
nodejs:
|
||||
npm:
|
||||
install_method: embedded
|
||||
- name: npm_source
|
||||
run_list:
|
||||
- recipe[nodejs::npm]
|
||||
- recipe[nodejs_test::npm]
|
||||
attributes:
|
||||
nodejs:
|
||||
npm:
|
||||
install_method: source
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
AllCops:
|
||||
Includes:
|
||||
Include:
|
||||
- Berksfile
|
||||
- Gemfile
|
||||
- Rakefile
|
||||
- Thorfile
|
||||
- Guardfile
|
||||
Excludes:
|
||||
Exclude:
|
||||
- vendor/**
|
||||
|
||||
ClassLength:
|
||||
|
||||
@@ -4,4 +4,5 @@ metadata
|
||||
|
||||
group :integration do
|
||||
cookbook 'apt'
|
||||
cookbook 'nodejs_test', :path => './test/cookbooks/nodejs_test'
|
||||
end
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ gem 'rake'
|
||||
|
||||
group :test do
|
||||
gem 'foodcritic', '~> 3.0'
|
||||
gem 'rubocop', '~> 0.18'
|
||||
gem 'rubocop', '~> 0.20'
|
||||
end
|
||||
|
||||
group :integration do
|
||||
|
||||
+14
-12
@@ -18,22 +18,24 @@
|
||||
#
|
||||
|
||||
case node['platform_family']
|
||||
when 'smartos', 'rhel', 'debian', 'fedora'
|
||||
when 'smartos', 'rhel', 'debian', 'fedora', 'mac_os_x'
|
||||
default['nodejs']['install_method'] = 'package'
|
||||
else
|
||||
default['nodejs']['install_method'] = 'source'
|
||||
end
|
||||
|
||||
default['nodejs']['version'] = '0.10.26'
|
||||
default['nodejs']['checksum'] = 'ef5e4ea6f2689ed7f781355012b942a2347e0299da0804a58de8e6281c4b1daa'
|
||||
default['nodejs']['checksum_linux_x64'] = '305bf2983c65edea6dd2c9f3669b956251af03523d31cf0a0471504fd5920aac'
|
||||
default['nodejs']['checksum_linux_x86'] = '8fa2d952556c8b5aa37c077e2735c972c522510facaa4df76d4244be88f4dc0f'
|
||||
default['nodejs']['checksum_linux_arm-pi'] = '561ec2ebfe963be8d6129f82a7d1bc112fb8fbfc0a1323ebe38ef55850f25517'
|
||||
default['nodejs']['dir'] = '/usr/local'
|
||||
default['nodejs']['npm'] = '1.4.4'
|
||||
default['nodejs']['src_url'] = 'http://nodejs.org/dist'
|
||||
default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
|
||||
default['nodejs']['check_sha'] = true
|
||||
|
||||
# Set this to true to install the legacy packages (0.8.x) from ubuntu/debian repositories; default is false (using the latest stable 0.10.x)
|
||||
default['nodejs']['legacy_packages'] = false
|
||||
default['nodejs']['prefix_url'] = ::URI.join('http://nodejs.org/dist', "v#{node['nodejs']['version']}").to_s
|
||||
|
||||
default['nodejs']['install_repo'] = true # Only if available, ie rhel / debian
|
||||
|
||||
default['nodejs']['source']['url'] = nil # Auto generated
|
||||
default['nodejs']['source']['checksum'] = 'ef5e4ea6f2689ed7f781355012b942a2347e0299da0804a58de8e6281c4b1daa'
|
||||
|
||||
default['nodejs']['binary']['url'] = nil # Auto generated
|
||||
default['nodejs']['binary']['checksum']['linux_x64'] = '305bf2983c65edea6dd2c9f3669b956251af03523d31cf0a0471504fd5920aac'
|
||||
default['nodejs']['binary']['checksum']['linux_x86'] = '8fa2d952556c8b5aa37c077e2735c972c522510facaa4df76d4244be88f4dc0f'
|
||||
default['nodejs']['binary']['checksum']['linux_arm-pi'] = '561ec2ebfe963be8d6129f82a7d1bc112fb8fbfc0a1323ebe38ef55850f25517'
|
||||
|
||||
default['nodejs']['mac_pkg']['checksum'] = '99b718692a77195e3aafab819b42ad7dba7e90e05a9b6f078bc5171c041331f8'
|
||||
|
||||
+3
-1
@@ -1 +1,3 @@
|
||||
default['nodejs']['npm'] = 'latest'
|
||||
default['nodejs']['npm']['install_method'] = 'embedded'
|
||||
|
||||
default['nodejs']['npm']['version'] = 'latest'
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
default['nodejs']['repo'] = 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
|
||||
default['nodejs']['packages'] = node['nodejs']['install_repo'] ? 'nodejs' : %w(nodejs npm nodejs-dev)
|
||||
when 'rhel', 'fedora'
|
||||
default['nodejs']['packages'] = %w(nodejs nodejs-devel npm)
|
||||
when 'smartos'
|
||||
default['nodejs']['packages'] = 'nodejs'
|
||||
when 'mac_os_x'
|
||||
default['nodejs']['packages'] = 'node'
|
||||
else
|
||||
Chef::Log.info 'There are no nodejs packages for this platform; please use the source or binary method to install node'
|
||||
end
|
||||
@@ -2,12 +2,13 @@ module NodeJs
|
||||
module Helper
|
||||
def npm_dist
|
||||
if node['nodejs']['npm']['url']
|
||||
return { 'url' => node['nodejs']['npm']['url'], 'version' => nil }
|
||||
return { 'url' => node['nodejs']['npm']['url'] }
|
||||
else
|
||||
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
result = JSON.parse(URI.parse("https://registry.npmjs.org/npm/#{node['nodejs']['npm']['version']}").read)
|
||||
ret = { 'url' => result['dist']['tarball'], 'npm_version' => result['_npmVersion'] }
|
||||
ret = { 'url' => result['dist']['tarball'], 'version' => result['_npmVersion'], 'shasum' => result['dist']['shasum'] }
|
||||
Chef::Log.debug("Npm dist #{ret}")
|
||||
return ret
|
||||
end
|
||||
@@ -16,7 +17,23 @@ module NodeJs
|
||||
def install_not_needed?
|
||||
cmd = Mixlib::ShellOut.new("#{node['nodejs']['node_bin']} --version")
|
||||
version = cmd.run_command.stdout.chomp
|
||||
::File.exists?("#{node['nodejs']['dir']}/bin/node") && version == "v#{node['nodejs']['version']}"
|
||||
::File.exist?("#{node['nodejs']['dir']}/bin/node") && version == "v#{node['nodejs']['version']}"
|
||||
end
|
||||
|
||||
def npm_list(path = nil)
|
||||
require 'json'
|
||||
if path
|
||||
cmd = Mixlib::ShellOut.new('npm list -json', :cwd => path)
|
||||
else
|
||||
cmd = Mixlib::ShellOut.new('npm list -global -json')
|
||||
end
|
||||
JSON.parse(cmd.run_command.stdout)
|
||||
end
|
||||
|
||||
def npm_package_installed?(package, version = nil, path = nil)
|
||||
list = npm_list(path)['dependencies']
|
||||
# Return true if package installed and installed to good version
|
||||
list.key?(package) && (version ? list[package]['version'] == version : true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+9
-7
@@ -1,23 +1,25 @@
|
||||
maintainer 'Promet Solutions'
|
||||
maintainer 'Promet Solutions'
|
||||
maintainer_email 'marius@promethost.com'
|
||||
license 'Apache 2.0'
|
||||
description 'Installs/Configures nodejs'
|
||||
license 'Apache 2.0'
|
||||
description 'Installs/Configures nodejs'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '1.3.0'
|
||||
name 'nodejs'
|
||||
provides 'nodejs'
|
||||
version '1.3.0'
|
||||
name 'nodejs'
|
||||
provides 'nodejs'
|
||||
|
||||
recipe 'nodejs', 'Installs Node.JS based on the default installation method'
|
||||
recipe 'nodejs::install_from_source', 'Installs Node.JS from source'
|
||||
recipe 'nodejs::install_from_binary', 'Installs Node.JS from official binaries'
|
||||
recipe 'nodejs::install_from_package', 'Installs Node.JS from packages'
|
||||
recipe 'nodejs::install_from_mac_pkg', 'Installs Node.JS from MacOs X .pkg file'
|
||||
recipe 'nodejs::npm', 'Installs npm from source - a package manager for node'
|
||||
|
||||
depends 'yum-epel'
|
||||
depends 'build-essential'
|
||||
depends 'ark'
|
||||
depends 'apt'
|
||||
depends 'homebrew', '~> 1.5.5'
|
||||
|
||||
%w(debian ubuntu centos redhat smartos).each do |os|
|
||||
%w(debian ubuntu centos redhat smartos mac_os_x).each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
include NodeJs::Helper
|
||||
|
||||
use_inline_resources if defined?(use_inline_resources)
|
||||
|
||||
action :install do
|
||||
execute "install NPM package #{new_resource.name}" do
|
||||
cwd new_resource.path
|
||||
command "npm install #{npm_options}"
|
||||
user new_resource.user
|
||||
group new_resource.group
|
||||
environment 'HOME' => ::Dir.home(new_resource.user), 'USER' => new_resource.user if new_resource.user
|
||||
not_if { installed? }
|
||||
end
|
||||
end
|
||||
|
||||
action :uninstall do
|
||||
execute "uninstall NPM package #{new_resource.package}" do
|
||||
cwd new_resource.path
|
||||
command "npm uninstall #{npm_options}"
|
||||
user new_resource.user
|
||||
group new_resource.group
|
||||
environment 'HOME' => ::Dir.home(new_resource.user), 'USER' => new_resource.user if new_resource.user
|
||||
only_if { installed? }
|
||||
end
|
||||
end
|
||||
|
||||
def installed?
|
||||
new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path)
|
||||
end
|
||||
|
||||
def npm_options
|
||||
options = ''
|
||||
options << ' -global' unless new_resource.path
|
||||
options << " #{npm_package}"
|
||||
end
|
||||
|
||||
def npm_package
|
||||
if new_resource.json
|
||||
return new_resource.json.is_a?(String) ? new_resource.json : nil
|
||||
elsif new_resource.url
|
||||
return new_resource.url
|
||||
elsif new_resource.package
|
||||
return new_resource.version ? "#{new_resource.package}@#{new_resource.version}" : new_resource.package
|
||||
else
|
||||
Chef::Log.error("No good options found to install #{new_resource.name}")
|
||||
end
|
||||
end
|
||||
@@ -18,4 +18,5 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "nodejs::install_from_#{node['nodejs']['install_method']}"
|
||||
include_recipe 'nodejs::nodejs'
|
||||
include_recipe 'nodejs::npm'
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#
|
||||
# Author:: Julian Wilde (jules@jules.com.au)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: install_from_binary
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
Chef::Resource::User.send(:include, NodeJs::Helper)
|
||||
|
||||
# Shamelessly borrowed from http://docs.opscode.com/dsl_recipe_method_platform.html
|
||||
# Surely there's a more canonical way to get arch?
|
||||
if node['kernel']['machine'] =~ /armv6l/
|
||||
arch = 'arm-pi' # assume a raspberry pi
|
||||
else
|
||||
arch = node['kernel']['machine'] =~ /x86_64/ ? 'x64' : 'x86'
|
||||
end
|
||||
|
||||
distro_suffix = "-linux-#{arch}"
|
||||
|
||||
# package_stub is for example: "node-v0.8.20-linux-x64"
|
||||
package_stub = "node-v#{node['nodejs']['version']}#{distro_suffix}"
|
||||
nodejs_tar = "#{package_stub}.tar.gz"
|
||||
expected_checksum = node['nodejs']["checksum_linux_#{arch}"]
|
||||
|
||||
nodejs_tar_path = nodejs_tar
|
||||
if node['nodejs']['version'].split('.')[1].to_i >= 5
|
||||
nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}"
|
||||
end
|
||||
|
||||
# Let the user override the source url in the attributes
|
||||
nodejs_bin_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}"
|
||||
|
||||
# Download it:
|
||||
remote_file "/usr/local/src/#{nodejs_tar}" do
|
||||
source nodejs_bin_url
|
||||
checksum expected_checksum
|
||||
mode 0644
|
||||
action :create_if_missing
|
||||
end
|
||||
|
||||
# Where we will install the binaries and libs to (normally /usr/local):
|
||||
destination_dir = node['nodejs']['dir']
|
||||
|
||||
# Verify the SHA sum of the downloaded file:
|
||||
ruby_block 'verify_sha_sum' do
|
||||
block do
|
||||
require 'digest/sha1'
|
||||
calculated_sha256_hash = Digest::SHA256.file("/usr/local/src/#{nodejs_tar}")
|
||||
if calculated_sha256_hash != expected_checksum
|
||||
raise "SHA256 Hash of #{nodejs_tar} did not match! Expected #{expected_checksum} found #{calculated_sha256_hash}"
|
||||
end
|
||||
end
|
||||
not_if { !node['nodejs']['check_sha'] || install_not_needed? }
|
||||
end
|
||||
|
||||
# One hopes that we can trust the contents of the node tarball not to overwrite anything it shouldn't!
|
||||
execute 'install package to system' do
|
||||
command <<-EOF
|
||||
tar xf /usr/local/src/#{nodejs_tar} \
|
||||
--strip-components=1 --no-same-owner \
|
||||
-C #{destination_dir} \
|
||||
#{package_stub}/bin \
|
||||
#{package_stub}/lib \
|
||||
#{package_stub}/share
|
||||
EOF
|
||||
not_if { install_not_needed? }
|
||||
end
|
||||
@@ -1,55 +0,0 @@
|
||||
#
|
||||
# Author:: Nathan L Smith (nlloyds@gmail.com)
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: package
|
||||
#
|
||||
# Copyright 2012, Cramer Development, Inc.
|
||||
# Copyright 2013, Opscale
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
include_recipe 'apt'
|
||||
if node['nodejs']['legacy_packages'] == true
|
||||
repo = 'http://ppa.launchpad.net/chris-lea/node.js-legacy/ubuntu'
|
||||
packages = %w(nodejs npm)
|
||||
else
|
||||
repo = 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
|
||||
packages = %w(nodejs)
|
||||
end
|
||||
apt_repository 'node.js' do
|
||||
uri repo
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver 'hkp://keyserver.ubuntu.com:80'
|
||||
key 'C7917B12'
|
||||
action :add
|
||||
end
|
||||
when 'rhel'
|
||||
include_recipe 'yum-epel'
|
||||
packages = %w(nodejs nodejs-devel npm)
|
||||
when 'fedora'
|
||||
packages = %w(nodejs nodejs-devel npm)
|
||||
when 'smartos'
|
||||
packages = %w(nodejs)
|
||||
else
|
||||
Chef::Log.error 'There are no nodejs packages for this platform; please use the source or binary method to install node'
|
||||
return
|
||||
end
|
||||
|
||||
packages.each do |node_pkg|
|
||||
package node_pkg
|
||||
end
|
||||
@@ -1,70 +0,0 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: source
|
||||
#
|
||||
# Copyright 2010-2012, Promet Solutions
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
Chef::Resource::User.send(:include, NodeJs::Helper)
|
||||
|
||||
include_recipe 'build-essential'
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel', 'fedora'
|
||||
package 'openssl-devel'
|
||||
when 'debian'
|
||||
package 'libssl-dev'
|
||||
end
|
||||
|
||||
nodejs_tar = "node-v#{node['nodejs']['version']}.tar.gz"
|
||||
nodejs_tar_path = nodejs_tar
|
||||
if node['nodejs']['version'].split('.')[1].to_i >= 5
|
||||
nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}"
|
||||
end
|
||||
# Let the user override the source url in the attributes
|
||||
nodejs_src_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}"
|
||||
|
||||
remote_file "/usr/local/src/#{nodejs_tar}" do
|
||||
source nodejs_src_url
|
||||
checksum node['nodejs']['checksum']
|
||||
mode 0644
|
||||
action :create_if_missing
|
||||
end
|
||||
|
||||
# --no-same-owner required overcome "Cannot change ownership" bug
|
||||
# on NFS-mounted filesystem
|
||||
execute "tar --no-same-owner -zxf #{nodejs_tar}" do
|
||||
cwd '/usr/local/src'
|
||||
creates "/usr/local/src/node-v#{node['nodejs']['version']}"
|
||||
end
|
||||
|
||||
bash "compile node.js (on #{node['nodejs']['make_threads']} cpu)" do
|
||||
# OSX doesn't have the attribute so arbitrarily default 2
|
||||
cwd "/usr/local/src/node-v#{node['nodejs']['version']}"
|
||||
code <<-EOH
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
./configure --prefix=#{node['nodejs']['dir']} && \
|
||||
make -j #{node['nodejs']['make_threads']}
|
||||
EOH
|
||||
creates "/usr/local/src/node-v#{node['nodejs']['version']}/node"
|
||||
end
|
||||
|
||||
execute 'nodejs make install' do
|
||||
environment('PATH' => '/usr/local/bin:/usr/bin:/bin:$PATH ')
|
||||
command 'make install'
|
||||
cwd "/usr/local/src/node-v#{node['nodejs']['version']}"
|
||||
not_if { install_not_needed? }
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2010-2012, Promet Solutions
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "nodejs::nodejs_from_#{node['nodejs']['install_method']}"
|
||||
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Author:: Julian Wilde (jules@jules.com.au)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: install_from_binary
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
Chef::Resource::User.send(:include, NodeJs::Helper)
|
||||
|
||||
# Shamelessly borrowed from http://docs.opscode.com/dsl_recipe_method_platform.html
|
||||
# Surely there's a more canonical way to get arch?
|
||||
if node['kernel']['machine'] =~ /armv6l/
|
||||
arch = 'arm-pi' # assume a raspberry pi
|
||||
else
|
||||
arch = node['kernel']['machine'] =~ /x86_64/ ? 'x64' : 'x86'
|
||||
end
|
||||
|
||||
# package_stub is for example: "node-v0.8.20-linux-x64.tar.gz"
|
||||
filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.gz"
|
||||
if node['nodejs']['binary']['url']
|
||||
nodejs_bin_url = node['nodejs']['binary']['url']
|
||||
checksum = node['nodejs']['binary']['checksum']
|
||||
else
|
||||
nodejs_bin_url = ::URI.join(node['nodejs']['prefix_url'], filename).to_s
|
||||
checksum = node['nodejs']['binary']['checksums']["linux_#{arch}"]
|
||||
end
|
||||
|
||||
ark 'nodejs-binary' do
|
||||
url nodejs_bin_url
|
||||
version node['nodejs']['version']
|
||||
checksum checksum
|
||||
action :install
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Author:: Angel Abad <angelabad@gmail.com>
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: install_from_mac_pkg
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
filename = "node-v#{node['nodejs']['version']}.pkg"
|
||||
url = node['nodejs']['mac_os_x']['url']
|
||||
nodejs_mac_os_x_url = url ? url : ::URI.join(node['nodejs']['prefix_url'], filename).to_s
|
||||
|
||||
remote_file ::File.join(Chef::Config[:file_cache_path], 'node.pkg') do
|
||||
source nodejs_mac_os_x_url
|
||||
checksum node['nodejs']['mac_pkg']['checksum']
|
||||
notifies :run, 'execute[install nodejs on mac]', :immediately
|
||||
end
|
||||
|
||||
execute 'install nodejs with mac_pkg' do
|
||||
command "installer -pkg #{Chef::Config[:file_cache_path]}/node.pkg -target /"
|
||||
action :nothing
|
||||
not_if "node --version | grep v#{node['nodejs']['version']}"
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Author:: Nathan L Smith (nlloyds@gmail.com)
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: package
|
||||
#
|
||||
# Copyright 2012, Cramer Development, Inc.
|
||||
# Copyright 2013, Opscale
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe 'nodejs::repo' if node['nodejs']['install_repo']
|
||||
|
||||
node['nodejs']['packages'].each do |node_pkg|
|
||||
package node_pkg
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: source
|
||||
#
|
||||
# Copyright 2010-2012, Promet Solutions
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
Chef::Resource::User.send(:include, NodeJs::Helper)
|
||||
|
||||
include_recipe 'build-essential'
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel', 'fedora'
|
||||
package 'openssl-devel'
|
||||
when 'debian'
|
||||
package 'libssl-dev'
|
||||
end
|
||||
|
||||
nodejs_src_url = node['nodejs']['source']['url'] || ::URI.join(node['nodejs']['prefix_url'], "node-v#{node['nodejs']['version']}.tar.gz").to_s
|
||||
|
||||
ark 'nodejs-source' do
|
||||
url nodejs_src_url
|
||||
version node['nodejs']['version']
|
||||
checksum node['nodejs']['source']['checksum']
|
||||
action :install_with_make
|
||||
end
|
||||
+7
-8
@@ -18,12 +18,11 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
Chef::Recipe.send(:include, NodeJs::Helper)
|
||||
|
||||
include_recipe 'nodejs'
|
||||
|
||||
ark 'npm' do
|
||||
url npm_dist['url']
|
||||
version npm_dist['version']
|
||||
action :install_with_make
|
||||
case node['nodejs']['npm']['install_method']
|
||||
when 'embedded'
|
||||
include_recipe 'nodejs::nodejs'
|
||||
when 'source'
|
||||
include_recipe 'nodejs::npm_from_source'
|
||||
else
|
||||
Chef::Log.error('No install method found for npm')
|
||||
end
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook Name:: nodejs
|
||||
# Recipe:: npm
|
||||
#
|
||||
# Copyright 2010-2012, Promet Solutions
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
Chef::Recipe.send(:include, NodeJs::Helper)
|
||||
|
||||
include_recipe 'nodejs::nodejs'
|
||||
|
||||
dist = npm_dist
|
||||
|
||||
ark 'npm' do
|
||||
url dist['url']
|
||||
checksum dist['checksum']
|
||||
version dist['version']
|
||||
action :install_with_make
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
include_recipe 'apt'
|
||||
|
||||
apt_repository 'node.js' do
|
||||
uri node['nodejs']['repo']
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver 'keyserver.ubuntu.com'
|
||||
key 'C7917B12'
|
||||
end
|
||||
when 'rhel'
|
||||
include_recipe 'yum-epel'
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Cookbook Name:: nodejs
|
||||
# Resource:: npm
|
||||
#
|
||||
# Author:: Sergey Balbeko <sergey@balbeko.com>
|
||||
#
|
||||
# Copyright 2012, Sergey Balbeko
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :install, :uninstall
|
||||
default_action :install
|
||||
|
||||
attribute :package, :name_attribute => true
|
||||
attribute :version, :kind_of => String
|
||||
attribute :path, :kind_of => String
|
||||
attribute :url, :kind_of => String
|
||||
attribute :json, :kind_of => [String, TrueClass]
|
||||
|
||||
attribute :user, :kind_of => String
|
||||
attribute :group, :kind_of => String
|
||||
@@ -0,0 +1,4 @@
|
||||
name 'nodejs_test'
|
||||
version '0.1.0'
|
||||
|
||||
depends 'git'
|
||||
@@ -0,0 +1,28 @@
|
||||
include_recipe 'git'
|
||||
|
||||
user 'random' do
|
||||
supports :manage_home => true
|
||||
home '/home/random'
|
||||
end
|
||||
|
||||
# global "express"
|
||||
nodejs_npm 'express'
|
||||
|
||||
nodejs_npm 'async' do
|
||||
version '0.6.2'
|
||||
end
|
||||
|
||||
nodejs_npm 'request' do
|
||||
url 'github mikeal/request'
|
||||
end
|
||||
|
||||
git '/home/random/grunt' do
|
||||
repository 'https://github.com/gruntjs/grunt'
|
||||
user 'random'
|
||||
end
|
||||
|
||||
nodejs_npm 'grunt' do
|
||||
path '/home/random/grunt'
|
||||
json true
|
||||
user 'random'
|
||||
end
|
||||
Referência em uma Nova Issue
Bloquear um usuário