Comparar commits
37 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| f68d39c912 | |||
| 29f6efe61b | |||
| f626980477 | |||
| 2b304a98d0 | |||
| 4a6dcb6924 | |||
| 28c090663e | |||
| de46e331bb | |||
| e64a50f582 | |||
| f47a6ceed9 | |||
| 4069e3251d | |||
| caaaa6461c | |||
| 8521b09bfe | |||
| 3cc49c20ca | |||
| 047b67ade0 | |||
| 938d0ff67b | |||
| 1fc1b5656b | |||
| 80a2a78c1d | |||
| 3f899fe719 | |||
| 96c9ed925a | |||
| 4b79a85528 | |||
| b966808e40 | |||
| 99962ead57 | |||
| ccf0e0c07b | |||
| 741deb47b2 | |||
| 4f6970eb62 | |||
| 296a689e3a | |||
| 180b94ad7d | |||
| 66c2444af0 | |||
| c3ef83df4a | |||
| c0f858fb1c | |||
| a25504a16f | |||
| ddff6fce64 | |||
| e4c02c74bd | |||
| 4b859c08b6 | |||
| d7bdd2bd4a | |||
| 0348a2dda7 | |||
| 4da4976fce |
+26
-2
@@ -7,14 +7,27 @@ driver_config:
|
||||
cpus: 4
|
||||
|
||||
platforms:
|
||||
- name: ubuntu-14.04
|
||||
driver_config:
|
||||
box: chef/ubuntu-14.04
|
||||
run_list:
|
||||
- recipe[apt]
|
||||
- name: ubuntu-12.04
|
||||
driver_config:
|
||||
box: chef/ubuntu-12.04
|
||||
run_list:
|
||||
- recipe[apt]
|
||||
- name: ubuntu-10.04
|
||||
driver_config:
|
||||
box: chef/ubuntu-10.04
|
||||
run_list:
|
||||
- recipe[apt]
|
||||
- name: centos-6.3
|
||||
- name: centos-5.8
|
||||
- name: centos-6.5
|
||||
driver_config:
|
||||
box: chef/centos-6.5
|
||||
- name: centos-5.10
|
||||
driver_config:
|
||||
box: chef/centos-5.10
|
||||
|
||||
suites:
|
||||
- name: default
|
||||
@@ -58,3 +71,14 @@ 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
@@ -1,12 +1,12 @@
|
||||
AllCops:
|
||||
Include:
|
||||
- Berksfile
|
||||
- Gemfile
|
||||
- Rakefile
|
||||
- Thorfile
|
||||
- Guardfile
|
||||
- '**/Berksfile'
|
||||
- '**/Gemfile'
|
||||
- '**/Rakefile'
|
||||
- '**/Thorfile'
|
||||
- '**/Guardfile'
|
||||
Exclude:
|
||||
- vendor/**
|
||||
- 'vendor/**/*'
|
||||
|
||||
ClassLength:
|
||||
Enabled: false
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
site :opscode
|
||||
source 'https://supermarket.getchef.com'
|
||||
|
||||
metadata
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
## 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][])
|
||||
|
||||
+6
-5
@@ -1,14 +1,15 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
gem 'berkshelf', '~> 3.1.4'
|
||||
gem 'stove'
|
||||
|
||||
group :test do
|
||||
gem 'foodcritic', '~> 3.0'
|
||||
gem 'rubocop', '~> 0.20'
|
||||
gem 'foodcritic', '~> 4.0.0'
|
||||
gem 'rubocop', '~> 0.24.1'
|
||||
end
|
||||
|
||||
group :integration do
|
||||
gem 'berkshelf'
|
||||
gem 'test-kitchen', '~> 1.1'
|
||||
gem 'kitchen-vagrant', '~> 0.13'
|
||||
gem 'test-kitchen', '~> 1.2.1'
|
||||
gem 'kitchen-vagrant', '~> 0.15.0'
|
||||
end
|
||||
|
||||
+67
-54
@@ -1,76 +1,89 @@
|
||||
# nodejs-cookbook [](https://travis-ci.org/redguide/nodejs)
|
||||
# [nodejs-cookbook](https://github.com/redguide/nodejs) [](https://travis-ci.org/redguide/nodejs)
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
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
|
||||
Installs Node.js and manage npm
|
||||
|
||||
## 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']`
|
||||
|
||||
* include_recipe "nodejs"
|
||||
### Install methods
|
||||
|
||||
Include the install_from_source recipe to install node from sources:
|
||||
#### Package
|
||||
|
||||
* include_recipe "nodejs::install_from_source"
|
||||
Install node from packages:
|
||||
|
||||
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)
|
||||
```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_recipe "nodejs::install_from_package"
|
||||
#### Binary
|
||||
|
||||
Include the install_from_binary recipe to install node from official prebuilt binaries:
|
||||
(Currently Linux x86, x86_64, armv6l only)
|
||||
Install node from official prebuilt binaries:
|
||||
```chef
|
||||
node['nodejs']['install_method'] = 'binary'
|
||||
include_recipe "nodejs"
|
||||
# Or
|
||||
include_recipe "nodejs::nodejs_from_binary"
|
||||
```
|
||||
|
||||
* include_recipe "nodejs::install_from_binary"
|
||||
#### Source
|
||||
|
||||
Include the npm recipe to install npm:
|
||||
Install node from sources:
|
||||
```chef
|
||||
node['nodejs']['install_method'] = 'source'
|
||||
include_recipe "nodejs"
|
||||
# Or
|
||||
include_recipe "nodejs::nodejs_from_source"
|
||||
```
|
||||
|
||||
* include_recipe "nodejs::npm"
|
||||
## NPM
|
||||
|
||||
## LICENSE and AUTHOR
|
||||
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['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']`.
|
||||
|
||||
Author:: Marius Ducea (marius@promethost.com)
|
||||
Author:: Nathan L Smith (nlloyds@gmail.com)
|
||||
## LWRP
|
||||
|
||||
Copyright:: 2010-2012, Promet Solutions
|
||||
Copyright:: 2012, Cramer Development, Inc.
|
||||
### nodejs_npm
|
||||
|
||||
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
|
||||
`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`)
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
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).
|
||||
|
||||
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.
|
||||
#### [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)
|
||||
|
||||
+6
-1
@@ -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,6 +39,11 @@ 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']
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ end
|
||||
|
||||
default['nodejs']['version'] = '0.10.26'
|
||||
|
||||
default['nodejs']['prefix_url'] = ::URI.join('http://nodejs.org/dist', "v#{node['nodejs']['version']}").to_s
|
||||
default['nodejs']['prefix_url'] = 'http://nodejs.org/dist/'
|
||||
|
||||
default['nodejs']['install_repo'] = true
|
||||
|
||||
@@ -37,3 +37,5 @@ 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']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
include_attribute 'nodejs::default'
|
||||
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
default['nodejs']['repo'] = 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
|
||||
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)
|
||||
when 'rhel', 'fedora'
|
||||
default['nodejs']['packages'] = %w(nodejs nodejs-devel npm)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
@@ -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)
|
||||
result = JSON.parse(URI.parse("https://registry.npmjs.org/npm/#{node['nodejs']['npm']['version']}", :max_nesting => false).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)
|
||||
JSON.parse(cmd.run_command.stdout, :max_nesting => false)
|
||||
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)
|
||||
(!list.nil?) && list.key?(package) && (version ? list[package]['version'] == version : true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+5
-8
@@ -1,17 +1,12 @@
|
||||
name 'nodejs'
|
||||
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 '1.3.0'
|
||||
name 'nodejs'
|
||||
provides 'nodejs'
|
||||
version '2.0.1'
|
||||
|
||||
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::npm', 'Installs npm from source - a package manager for node'
|
||||
conflicts 'node'
|
||||
|
||||
depends 'yum-epel'
|
||||
depends 'build-essential'
|
||||
@@ -21,3 +16,5 @@ depends 'apt'
|
||||
%w(debian ubuntu centos redhat smartos).each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
suggests 'application_nodejs'
|
||||
|
||||
@@ -31,6 +31,9 @@ end
|
||||
def npm_options
|
||||
options = ''
|
||||
options << ' -global' unless new_resource.path
|
||||
new_resource.options.each do |option|
|
||||
options << " #{option}"
|
||||
end
|
||||
options << " #{npm_package}"
|
||||
end
|
||||
|
||||
@@ -45,3 +48,8 @@ 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
|
||||
|
||||
@@ -20,3 +20,14 @@
|
||||
|
||||
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')
|
||||
|
||||
@@ -27,18 +27,20 @@ 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'], filename).to_s
|
||||
checksum = node['nodejs']['binary']['checksums']["linux_#{arch}"]
|
||||
nodejs_bin_url = ::URI.join(node['nodejs']['prefix_url'], version, filename).to_s
|
||||
checksum = node['nodejs']['binary']['checksum']["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
|
||||
|
||||
@@ -29,11 +29,14 @@ 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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
+3
-1
@@ -2,12 +2,14 @@ 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 'C7917B12'
|
||||
key node['nodejs']['key']
|
||||
end
|
||||
when 'rhel'
|
||||
include_recipe 'yum-epel'
|
||||
|
||||
@@ -27,6 +27,7 @@ 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name 'nodejs_test'
|
||||
version '0.1.0'
|
||||
name 'nodejs_test'
|
||||
version '0.1.0'
|
||||
|
||||
depends 'git'
|
||||
|
||||
@@ -26,3 +26,7 @@ nodejs_npm 'grunt' do
|
||||
json true
|
||||
user 'random'
|
||||
end
|
||||
|
||||
nodejs_npm 'mocha' do
|
||||
options ['--force', '--production']
|
||||
end
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário