5 Commits

Autor SHA1 Mensagem Data
Guilhem Lettron ea88bfaa67 Use homebrew by default 2014-04-10 15:42:25 +02:00
Guilhem Lettron 9a0ef56a79 Refactor some mac_pkg parts 2014-04-10 15:32:09 +02:00
Angel Abad 8b0e3629ca Install nodejs pkg from official repository in MacOs X 2014-04-10 15:18:17 +02:00
Angel Abad a1c94e6dae Add mac_os_x platform to metadata 2014-04-10 15:15:44 +02:00
Angel Abad 50839ca168 Add recipe description in metadata 2014-04-10 15:15:03 +02:00
21 arquivos alterados com 138 adições e 186 exclusões
+2 -16
Ver Arquivo
@@ -7,17 +7,14 @@ driver_config:
cpus: 4
platforms:
- name: ubuntu-14.04
run_list:
- recipe[apt]
- name: ubuntu-12.04
run_list:
- recipe[apt]
- name: ubuntu-10.04
run_list:
- recipe[apt]
- name: centos-6.5
- name: centos-5.10
- name: centos-6.3
- name: centos-5.8
suites:
- name: default
@@ -61,14 +58,3 @@ suites:
nodejs:
npm:
install_method: source
- name: npm_packages
run_list: recipe[nodejs]
attributes:
nodejs:
npm_packages:
- name: express
- name: socket.io
version: 1.0.4
- name: express
action: uninstall
+6 -6
Ver Arquivo
@@ -1,12 +1,12 @@
AllCops:
Include:
- '**/Berksfile'
- '**/Gemfile'
- '**/Rakefile'
- '**/Thorfile'
- '**/Guardfile'
- Berksfile
- Gemfile
- Rakefile
- Thorfile
- Guardfile
Exclude:
- 'vendor/**/*'
- vendor/**
ClassLength:
Enabled: false
+1 -1
Ver Arquivo
@@ -1,4 +1,4 @@
source 'https://supermarket.getchef.com'
site :opscode
metadata
-10
Ver Arquivo
@@ -1,13 +1,3 @@
## v2.0.0 (unreleased)
* Travis integration
* Gems updated
* Rewrite cookbook dependencies
* Added complete test-kitchen integration : Rake, rubocop, foodcritic, vagrant, bats testing ...
* Added NodeJS ```install_method``` option (sources, bins or packages)
* Added NPM ```install_method``` option (sources or packages)
* NPM version can now be chosen independently from nodejs' embedded version
* Added a ```nodejs_npm``` LWRP to manage, install and resolve NPM packages
## v1.3.0
* update default versions to the latest: node - v0.10.15 and npm - v1.3.5
* default to package installation of nodejs on smartos ([@wanelo-pair][])
+5 -6
Ver Arquivo
@@ -1,15 +1,14 @@
source 'https://rubygems.org'
gem 'rake'
gem 'berkshelf', '~> 3.1.4'
gem 'stove'
group :test do
gem 'foodcritic', '~> 4.0.0'
gem 'rubocop', '~> 0.24.1'
gem 'foodcritic', '~> 3.0'
gem 'rubocop', '~> 0.20'
end
group :integration do
gem 'test-kitchen', '~> 1.2.1'
gem 'kitchen-vagrant', '~> 0.15.0'
gem 'berkshelf'
gem 'test-kitchen', '~> 1.1'
gem 'kitchen-vagrant', '~> 0.13'
end
+54 -68
Ver Arquivo
@@ -1,90 +1,76 @@
# [nodejs-cookbook](https://github.com/redguide/nodejs)
[![CK Version](http://img.shields.io/cookbook/v/nodejs.svg)](https://supermarket.getchef.com/cookbooks/nodejs) [![Build Status](https://img.shields.io/travis/redguide/nodejs.svg)](https://travis-ci.org/redguide/nodejs)
# nodejs-cookbook [![Build Status](https://travis-ci.org/redguide/nodejs.svg)](https://travis-ci.org/redguide/nodejs)
## DESCRIPTION
Installs Node.js and manage npm
Installs Node.JS
## REQUIREMENTS
### Platform
* Tested on Debian 6 and Ubuntu 10.04
* Should work fine on Centos, RHEL, etc.
### Cookbooks:
* [build-essential](https://github.com/opscode-cookbooks/build-essential)
* [apt](https://github.com/cookbooks/apt)
* [yum](https://github.com/cookbooks/yum)
Opscode cookbooks (http://github.com/opscode/cookbooks/tree/master)
## ATTRIBUTES
* nodejs['install_method'] = source or package
* nodejs['version'] - release version of node to install
* nodejs['src_url'] - download location for node source tarball
* nodejs['dir'] - location where node will be installed, default /usr/local
* nodejs['npm'] - version of npm to install
* nodejs['npm_src_url'] - download location for npm source tarball
* nodejs['check_sha'] - test for valid sha_sum, default: true
## USAGE
Include the nodejs recipe to install node on your system based on the default installation method:
```chef
include_recipe "nodejs"
```
Installation method can be customized with attribute `node['nodejs']['install_method']`
### Install methods
* include_recipe "nodejs"
#### Package
Include the install_from_source recipe to install node from sources:
Install node from packages:
* include_recipe "nodejs::install_from_source"
```chef
node['nodejs']['install_method'] = 'package' # Not necessary because it's the default
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_package"
```
Note that only apt (Ubuntu, Debian) appears to have up to date packages available.
Centos, RHEL, etc are non-functional (try `nodejs_from_binary` for those).
Include the install_from_package recipe to install node from packages:
Note that only apt (Ubuntu, Debian) appears to have up to date packages available.
Centos, RHEL, etc are non-functional. (Try install_from_binary for those)
#### Binary
* include_recipe "nodejs::install_from_package"
Install node from official prebuilt binaries:
```chef
node['nodejs']['install_method'] = 'binary'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_binary"
```
Include the install_from_binary recipe to install node from official prebuilt binaries:
(Currently Linux x86, x86_64, armv6l only)
#### Source
* include_recipe "nodejs::install_from_binary"
Install node from sources:
```chef
node['nodejs']['install_method'] = 'source'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_source"
```
Include the npm recipe to install npm:
## NPM
* include_recipe "nodejs::npm"
Npm is included in nodejs installs by default.
By default, we are using it and call it `embedded`.
Adding recipe `nodejs::npm` assure you to have npm installed and let you choose install method with `node['nodejs']['npm']['install_method']`
```chef
include_recipe "nodejs::npm"
```
_Warning:_ This recipe will include the `nodejs` recipe, which by default includes `nodejs::nodejs_from_package` if you did not set `node['nodejs']['install_method']`.
## LICENSE and AUTHOR
## LWRP
Author:: Marius Ducea (marius@promethost.com)
Author:: Nathan L Smith (nlloyds@gmail.com)
### nodejs_npm
Copyright:: 2010-2012, Promet Solutions
Copyright:: 2012, Cramer Development, Inc.
`nodejs_npm` let you install npm packages from various sources:
* npm registry:
* name: `attribute :package`
* version: `attribute :version` (optionnal)
* url: `attribute :url`
* for git use `git://{your_repo}`
* from a json (packages.json by default): `attribute :json`
* use `true` for default
* use a `String` to specify json file
Packages can be installed globally (by default) or in a directory (by using `attribute :path`)
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
You can append more specific options to npm command with `attribute :options` array :
* use an array of options (w/ dash), they will be added to npm call.
* ex: `['--production','--force']` or `['--force-latest']`
This LWRP try to use npm bare as much as possible (no custom wrapper).
http://www.apache.org/licenses/LICENSE-2.0
#### [Examples](test/cookbooks/nodejs_test/recipes/npm.rb)
## AUTHORS
* Marius Ducea (marius@promethost.com)
* Nathan L Smith (nlloyds@gmail.com)
* Guilhem Lettron (guilhem@lettron.fr)
* Barthelemy Vessemont (bvessemont@gmail.com)
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.
+1 -6
Ver Arquivo
@@ -5,7 +5,7 @@ namespace :style do
begin
require 'rubocop/rake_task'
desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby)
Rubocop::RakeTask.new(:ruby)
rescue LoadError
puts '>>>>> Rubocop gem not loaded, omitting tasks' unless ENV['CI']
end
@@ -39,11 +39,6 @@ namespace :integration do
end
end
namespace :maintain do
require 'stove/rake_task'
Stove::RakeTask.new
end
desc 'Run all tests on Travis'
task travis: ['style']
+5 -5
Ver Arquivo
@@ -18,7 +18,7 @@
#
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'
@@ -26,9 +26,9 @@ end
default['nodejs']['version'] = '0.10.26'
default['nodejs']['prefix_url'] = 'http://nodejs.org/dist/'
default['nodejs']['prefix_url'] = ::URI.join('http://nodejs.org/dist', "v#{node['nodejs']['version']}").to_s
default['nodejs']['install_repo'] = true
default['nodejs']['install_repo'] = true # Only if available, ie rhel / debian
default['nodejs']['source']['url'] = nil # Auto generated
default['nodejs']['source']['checksum'] = 'ef5e4ea6f2689ed7f781355012b942a2347e0299da0804a58de8e6281c4b1daa'
@@ -36,6 +36,6 @@ default['nodejs']['source']['checksum'] = 'ef5e4ea6f2689ed7f781355012b942a2347e0
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'] = '52a0f6ed9c0be1ea5f79de6527c481c1b803edbea6413a4fdc65a45ad401565d'
default['nodejs']['binary']['checksum']['linux_arm-pi'] = '561ec2ebfe963be8d6129f82a7d1bc112fb8fbfc0a1323ebe38ef55850f25517'
default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
default['nodejs']['mac_pkg']['checksum'] = '99b718692a77195e3aafab819b42ad7dba7e90e05a9b6f078bc5171c041331f8'
+6 -8
Ver Arquivo
@@ -1,15 +1,13 @@
include_attribute 'nodejs::default'
case node['platform_family']
when 'debian'
default['nodejs']['repo'] = 'https://deb.nodesource.com/node'
default['nodejs']['key'] = '1655a0ab68576280'
default['nodejs']['packages'] = node['nodejs']['install_repo'] ? %w(nodejs) : %w(nodejs npm nodejs-dev)
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'] = %w(nodejs)
default['nodejs']['packages'] = 'nodejs'
when 'mac_os_x'
default['nodejs']['packages'] = 'node'
else
Chef::Log.error 'There are no nodejs packages for this platform; please use the source or binary method to install node'
return
Chef::Log.info 'There are no nodejs packages for this platform; please use the source or binary method to install node'
end
-9
Ver Arquivo
@@ -1,9 +0,0 @@
if defined?(ChefSpec)
def install_nodejs_npm(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:nodejs_npm, :install, resource_name)
end
def uninstall_nodejs_npm(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:nodejs_npm, :uninstall, resource_name)
end
end
+3 -3
Ver Arquivo
@@ -7,7 +7,7 @@ module NodeJs
require 'open-uri'
require 'json'
result = JSON.parse(URI.parse("https://registry.npmjs.org/npm/#{node['nodejs']['npm']['version']}").read, :max_nesting => false)
result = JSON.parse(URI.parse("https://registry.npmjs.org/npm/#{node['nodejs']['npm']['version']}").read)
ret = { 'url' => result['dist']['tarball'], 'version' => result['_npmVersion'], 'shasum' => result['dist']['shasum'] }
Chef::Log.debug("Npm dist #{ret}")
return ret
@@ -27,13 +27,13 @@ module NodeJs
else
cmd = Mixlib::ShellOut.new('npm list -global -json')
end
JSON.parse(cmd.run_command.stdout, :max_nesting => false)
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.nil?) && list.key?(package) && (version ? list[package]['version'] == version : true)
list.key?(package) && (version ? list[package]['version'] == version : true)
end
end
end
+13 -8
Ver Arquivo
@@ -1,20 +1,25 @@
name 'nodejs'
maintainer 'redguide'
maintainer_email 'guilhem@lettron.fr'
maintainer 'Promet Solutions'
maintainer_email 'marius@promethost.com'
license 'Apache 2.0'
description 'Installs/Configures nodejs'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.1.1'
version '1.3.0'
name 'nodejs'
provides 'nodejs'
conflicts 'node'
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
suggests 'application_nodejs'
+3 -11
Ver Arquivo
@@ -9,7 +9,7 @@ action :install do
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 { package_installed? }
not_if { installed? }
end
end
@@ -20,20 +20,17 @@ action :uninstall do
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 { package_installed? }
only_if { installed? }
end
end
def package_installed?
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
new_resource.options.each do |option|
options << " #{option}"
end
options << " #{npm_package}"
end
@@ -48,8 +45,3 @@ def npm_package
Chef::Log.error("No good options found to install #{new_resource.name}")
end
end
def initialize(*args)
super
@run_context.include_recipe 'nodejs::npm'
end
-11
Ver Arquivo
@@ -20,14 +20,3 @@
include_recipe 'nodejs::nodejs'
include_recipe 'nodejs::npm'
node['nodejs']['npm_packages'].each do |pkg|
f = nodejs_npm pkg['name'] do
action :nothing
end
pkg.reject { |k, _v| k == 'name' || k == 'action' }.each do |key, value|
f.send(key, value)
end
action = pkg.key?('action') ? pkg['action'] : :install
f.action(action)
end if node['nodejs'].key?('npm_packages')
+2 -4
Ver Arquivo
@@ -27,20 +27,18 @@ else
end
# package_stub is for example: "node-v0.8.20-linux-x64.tar.gz"
version = "v#{node['nodejs']['version']}/"
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'], version, filename).to_s
checksum = node['nodejs']['binary']['checksum']["linux_#{arch}"]
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
has_binaries ['bin/node', 'bin/npm']
action :install
end
+33
Ver Arquivo
@@ -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
+1 -4
Ver Arquivo
@@ -29,14 +29,11 @@ when 'debian'
package 'libssl-dev'
end
version = "v#{node['nodejs']['version']}/"
filename = "node-v#{node['nodejs']['version']}.tar.gz"
nodejs_src_url = node['nodejs']['source']['url'] || ::URI.join(node['nodejs']['prefix_url'], version, filename).to_s
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']
make_opts ["-j #{node['nodejs']['make_threads']}"]
action :install_with_make
end
+1 -3
Ver Arquivo
@@ -2,14 +2,12 @@ case node['platform_family']
when 'debian'
include_recipe 'apt'
package 'apt-transport-https'
apt_repository 'node.js' do
uri node['nodejs']['repo']
distribution node['lsb']['codename']
components ['main']
keyserver 'keyserver.ubuntu.com'
key node['nodejs']['key']
key 'C7917B12'
end
when 'rhel'
include_recipe 'yum-epel'
-1
Ver Arquivo
@@ -27,7 +27,6 @@ attribute :version, :kind_of => String
attribute :path, :kind_of => String
attribute :url, :kind_of => String
attribute :json, :kind_of => [String, TrueClass]
attribute :options, :kind_of => Array, :default => []
attribute :user, :kind_of => String
attribute :group, :kind_of => String
+2 -2
Ver Arquivo
@@ -1,4 +1,4 @@
name 'nodejs_test'
version '0.1.0'
name 'nodejs_test'
version '0.1.0'
depends 'git'
-4
Ver Arquivo
@@ -26,7 +26,3 @@ nodejs_npm 'grunt' do
json true
user 'random'
end
nodejs_npm 'mocha' do
options ['--force', '--production']
end