vagrant and chef install everything
This commit is contained in:
166
ops/cookbooks/vendor/nodejs/CHANGELOG.md
vendored
Normal file
166
ops/cookbooks/vendor/nodejs/CHANGELOG.md
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
# NodeJS Cookbook Changelog
|
||||
|
||||
## 6.0.0 (2018-10-11)
|
||||
|
||||
- Use the build_essential resource in the source install recipe instead of the build-essential::default recipe. This way we can use the new built-in build_essential resource in Chef 14+
|
||||
- Set default version to Node.js v8.12.0
|
||||
|
||||
## 5.0.0 (2017-11-15)
|
||||
|
||||
- nodejs_npm resource has been converted to a custom resource and renamed to npm_package. The existing resource name will continue to function, but over time code should be updated for the new name. This name change has been made so we can eventually merge this resource into the chef-client.
|
||||
- compat_resource cookbook dependency has been removed and this cookbook instead requires Chef 12.14 or later
|
||||
- Chef 13 compatibility has been resolved
|
||||
- The npm_package resource now properly installs packages when the 'package' property is setA
|
||||
- Speed up npm operations by only returning a list of the desired package instead of every npm package
|
||||
- Speed up source installation by using multipackage install for the dependencies
|
||||
- Remove the broken url_valid? helper which didn't work
|
||||
|
||||
## 4.0.0 (2017-07-11)
|
||||
|
||||
- Updated the cookbook to require Chef 12.1+ and the compat_resource cookbook
|
||||
- Removed support for io.js which has merged back into the node.js project
|
||||
- Removed the dependency on homebrew, yum-epel, and apt cookbooks
|
||||
- Added node['nodejs']['manage_node'] attribute to use only cookbook's LWRP (required to manage node by nvm)
|
||||
- Updated the default repository URLs to be the 6.X repos
|
||||
- Added initial support for Suse and Amazon Linux
|
||||
- Improved architecture detection to support aarch64
|
||||
- Improved readme with examples for fetching your own binaries
|
||||
- Added installation of openssl and xz utilities that are needed for the binary install recipe
|
||||
- Updated the cookbook license string to be an SPDX compliant string
|
||||
- Set the minimum version of the ark cookbook to 2.0.2 in order to support Suse
|
||||
- Updated the default version from 6.9.1 to 6.10.2
|
||||
- Switched to Delivery local mode for testing
|
||||
- Added Integration testing in Travis CI with kitchen-dokken and ChefDK
|
||||
|
||||
## 3.0.0 (2016-11-02)
|
||||
|
||||
- Updated the default release to the nodejs 6.9.1\. This requires C++11 extensions to compile, which are only present in GCC 4.8+. Due to this RHEL 5/6 and Ubuntu 12.04 are not supported if using this version.
|
||||
- Switched the download URLs to the .xz packages since the .tar.gz packages are no longer being created
|
||||
- Improvements to the readme examples and requirements sections
|
||||
- Removed installation of apt-transport-https and instead rely on an apt cookbook that will do the same
|
||||
- Fixed the ChefSpec matchers
|
||||
- Added Scientific, Oracle, and Amazon as supported distros in the metadata
|
||||
- Added chef_version metadata
|
||||
- Removed conflicts and suggests metadata which aren't implemented or recommended for use
|
||||
- Removed Chef 10 compatibility code
|
||||
- Switched Integration testing to Inspec from bats
|
||||
- Added the Apache 2.0 license file to the repo
|
||||
- Expanded Test Kitchen testing
|
||||
- Switched from Rubocop to Cookstyle and resolved all warnings
|
||||
- Switched Travis to testing using ChefDK
|
||||
|
||||
## 2.4.4
|
||||
|
||||
- Use HTTPS prefix URLs for node download #98
|
||||
- Update NPM symlink when installing from source #105
|
||||
- Add support for NPM private modules #107
|
||||
|
||||
## v2.4.2
|
||||
|
||||
- Fix check version
|
||||
- Support iojs package install
|
||||
|
||||
## v2.4.0
|
||||
|
||||
- Move `npm_packages` to his own recipe
|
||||
- Fix different race conditions when using direct recipe call
|
||||
- Fix npm recipe
|
||||
|
||||
## v2.3.2
|
||||
|
||||
- Fix package recipe
|
||||
|
||||
## v2.3.0
|
||||
|
||||
- Support io.js. Use node['nodejs']['engine'].
|
||||
- Add MacOS support via homebrew
|
||||
|
||||
## v2.2.0
|
||||
|
||||
- Add node['nodejs']['keyserver']
|
||||
- Update arm checksum
|
||||
- Fix `npm_packages` JSON
|
||||
|
||||
## v2.1.0
|
||||
|
||||
- Use official nodesource repository
|
||||
- Add node['nodejs']['npm_packages'] to install npm package with `default` recipe
|
||||
|
||||
## v2.0.0
|
||||
|
||||
- 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])
|
||||
- Add Raspberry pi support ([@robertkowalski])
|
||||
|
||||
## v1.2.0
|
||||
|
||||
- implement installation from package on RedHat - ([@vaskas])
|
||||
|
||||
## v1.1.3:
|
||||
|
||||
- update default version of node to 0.10.13 - and npm - v1.3.4 ([@jodosha][])
|
||||
|
||||
## v1.1.2:
|
||||
|
||||
- update default version of node to 0.10.2 - ([@bakins])
|
||||
- fully migrated to test-kitchen 1.alpha and vagrant 1.1.x/berkshelf 1.3.1
|
||||
|
||||
## v1.1.1:
|
||||
|
||||
- update default versions to the latest: node - v0.10.0 and npm - v1.2.14
|
||||
- `make_thread` is now a real attribute - ([@ChrisLundquist])
|
||||
|
||||
## v1.1.0:
|
||||
|
||||
- rewrite the package install; remove rpm support since there are no longer any packages available anywhere
|
||||
- add support to install `legacy_packages` from ubuntu repo as well as the latest 0.10.x branch (this is default).
|
||||
|
||||
## v1.0.4:
|
||||
|
||||
- add support for binary installation method ([@JulesAU])
|
||||
|
||||
## v1.0.3:
|
||||
|
||||
- unreleased
|
||||
|
||||
## v1.0.2:
|
||||
|
||||
- add smartos support for package install ([@sax])
|
||||
- support to compile with all processors available (default 2 if unknown) - ([@ChrisLundquist])
|
||||
- moved to `platform_family` syntax
|
||||
- ensure npm recipe honours the 'source' or 'package' setting - ([@markbirbeck])
|
||||
- updated the default versions to the latest stable node/npm
|
||||
|
||||
## v1.0.1:
|
||||
|
||||
- fixed bug that prevented overwritting the node/npm versions (moved the `src_url`s as local variables instead of attributes) - ([@johannesbecker])
|
||||
- updated the default versions to the latest node/npm
|
||||
|
||||
## v1.0.0:
|
||||
|
||||
- added packages installation support ([@smith])
|
||||
|
||||
[@bakins]: https://github.com/bakins
|
||||
[@chrislundquist]: https://github.com/ChrisLundquist
|
||||
[@gmccue]: https://github.com/gmccue
|
||||
[@johannesbecker]: https://github.com/johannesbecker
|
||||
[@julesau]: https://github.com/JulesAU
|
||||
[@markbirbeck]: https://github.com/markbirbeck
|
||||
[@predominant]: https://github.com/predominant
|
||||
[@robertkowalski]: https://github.com/robertkowalski
|
||||
[@sax]: https://github.com/sax
|
||||
[@sjlu]: https://github.com/sjlu
|
||||
[@smith]: https://github.com/smith
|
||||
[@vaskas]: https://github.com/vaskas
|
||||
[@wanelo-pair]: https://github.com/wanelo-pair
|
199
ops/cookbooks/vendor/nodejs/README.md
vendored
Normal file
199
ops/cookbooks/vendor/nodejs/README.md
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
# [nodejs-cookbook](https://github.com/redguide/nodejs)
|
||||
|
||||
[](https://supermarket.chef.io/cookbooks/nodejs) [](https://travis-ci.org/redguide/nodejs) [](https://gitter.im/redguide/nodejs)
|
||||
|
||||
Installs node.js/npm and includes a resource for managing npm packages
|
||||
|
||||
## Requirements
|
||||
|
||||
### Platforms
|
||||
|
||||
- Debian/Ubuntu
|
||||
- RHEL/CentOS/Scientific/Amazon/Oracle
|
||||
- openSUSE
|
||||
|
||||
Note: Source installs require GCC 4.8+, which is not included on older distro releases
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.14+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- build-essential
|
||||
- ark
|
||||
|
||||
## Usage
|
||||
|
||||
Include the nodejs recipe to install node on your system based on the default installation method:
|
||||
|
||||
```chef
|
||||
include_recipe "nodejs"
|
||||
```
|
||||
|
||||
### Install methods
|
||||
|
||||
#### Package
|
||||
|
||||
Install node from packages:
|
||||
|
||||
```chef
|
||||
node['nodejs']['install_method'] = 'package' # Not necessary because it's the default
|
||||
include_recipe "nodejs"
|
||||
# Or
|
||||
include_recipe "nodejs::nodejs_from_package"
|
||||
```
|
||||
|
||||
By default this will setup deb/rpm repositories from nodesource.com, which include up to date NodeJS packages. If you prefer to use distro provided package you can disable this behavior by setting `node['nodejs']['install_repo']` to `false`.
|
||||
|
||||
#### Binary
|
||||
|
||||
Install node from official prebuilt binaries:
|
||||
|
||||
```chef
|
||||
node['nodejs']['install_method'] = 'binary'
|
||||
include_recipe "nodejs"
|
||||
|
||||
# Or
|
||||
include_recipe "nodejs::nodejs_from_binary"
|
||||
|
||||
# Or set a specific version of nodejs to be installed
|
||||
node.default['nodejs']['install_method'] = 'binary'
|
||||
node.default['nodejs']['version'] = '5.9.0'
|
||||
node.default['nodejs']['binary']['checksum'] = '99c4136cf61761fac5ac57f80544140a3793b63e00a65d4a0e528c9db328bf40'
|
||||
|
||||
# Or fetch the binary from your own location
|
||||
node.default['nodejs']['install_method'] = 'binary'
|
||||
node.default['nodejs']['binary']['url'] = 'https://s3.amazonaws.com/my-bucket/node-v7.8.0-linux-x64.tar.gz'
|
||||
node.default['nodejs']['binary']['checksum'] = '0bd86f2a39221b532172c7d1acb57f0b0cba88c7b82ea74ba9d1208b9f6f9697'
|
||||
```
|
||||
|
||||
#### Source
|
||||
|
||||
Install node from sources:
|
||||
|
||||
```chef
|
||||
node['nodejs']['install_method'] = 'source'
|
||||
include_recipe "nodejs"
|
||||
# Or
|
||||
include_recipe "nodejs::nodejs_from_source"
|
||||
```
|
||||
|
||||
## 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']`.
|
||||
|
||||
## Resources
|
||||
|
||||
### npm_package
|
||||
|
||||
note: This resource was previously named nodejs_npm. Calls to that resource name will still function, but cookbooks should be updated for the new npm_package resource name.
|
||||
|
||||
`npm_package` let you install npm packages from various sources:
|
||||
|
||||
- npm registry:
|
||||
|
||||
- name: `property :package`
|
||||
- version: `property :version` (optional)
|
||||
|
||||
- url: `property :url`
|
||||
|
||||
- for git use `git://{your_repo}`
|
||||
|
||||
- from a json (package.json by default): `property :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`)
|
||||
|
||||
You can specify an `NPM_TOKEN` environment variable for accessing [NPM private modules](https://docs.npmjs.com/private-modules/intro) by using `attribute :npm_token`
|
||||
|
||||
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 attempts to use vanilla npm as much as possible (no custom wrapper).
|
||||
|
||||
### Packages
|
||||
|
||||
```ruby
|
||||
npm_package 'express'
|
||||
|
||||
npm_package 'async' do
|
||||
version '0.6.2'
|
||||
end
|
||||
|
||||
npm_package 'request' do
|
||||
url 'github mikeal/request'
|
||||
end
|
||||
|
||||
npm_package 'grunt' do
|
||||
path '/home/random/grunt'
|
||||
json true
|
||||
user 'random'
|
||||
end
|
||||
|
||||
npm_package 'my_private_module' do
|
||||
path '/home/random/myproject' # The root path to your project, containing a package.json file
|
||||
json true
|
||||
npm_token '12345-abcde-e5d4c3b2a1'
|
||||
user 'random'
|
||||
options ['--production'] # Only install dependencies. Skip devDependencies
|
||||
end
|
||||
```
|
||||
|
||||
[Working Examples](test/cookbooks/nodejs_test/recipes/npm.rb)
|
||||
|
||||
Or add packages via attributes (which accept the same attributes as the LWRP above):
|
||||
|
||||
```json
|
||||
"nodejs": {
|
||||
"npm_packages": [
|
||||
{
|
||||
"name": "express"
|
||||
},
|
||||
{
|
||||
"name": "async",
|
||||
"version": "0.6.2"
|
||||
},
|
||||
{
|
||||
"name": "request",
|
||||
"url": "github mikeal/request"
|
||||
}
|
||||
{
|
||||
"name": "grunt",
|
||||
"path": "/home/random/grunt",
|
||||
"json": true,
|
||||
"user": "random"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## License & Authors
|
||||
|
||||
**Author:** Marius Ducea (marius@promethost.com) **Author:** Nathan L Smith (nlloyds@gmail.com) **Author:** Guilhem Lettron (guilhem@lettron.fr) **Author:** Barthelemy Vessemont (bvessemont@gmail.com)
|
||||
|
||||
**Copyright:** 2008-2017, Chef Software, Inc.
|
||||
|
||||
```
|
||||
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.
|
||||
```
|
41
ops/cookbooks/vendor/nodejs/attributes/default.rb
vendored
Normal file
41
ops/cookbooks/vendor/nodejs/attributes/default.rb
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
#
|
||||
# Cookbook:: nodejs
|
||||
# Attributes:: nodejs
|
||||
#
|
||||
# Copyright:: 2010-2017, 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.
|
||||
#
|
||||
|
||||
case node['platform_family']
|
||||
when 'smartos', 'rhel', 'debian', 'fedora', 'mac_os_x', 'suse', 'amazon'
|
||||
default['nodejs']['install_method'] = 'package'
|
||||
else
|
||||
default['nodejs']['install_method'] = 'source'
|
||||
end
|
||||
|
||||
default['nodejs']['version'] = '8.12.0'
|
||||
|
||||
default['nodejs']['prefix_url']['node'] = 'https://nodejs.org/dist/'
|
||||
|
||||
default['nodejs']['source']['url'] = nil # Auto generated
|
||||
default['nodejs']['source']['checksum'] = 'b4797843136edd9195c28221a1680ae52c29d867fc5fc1c99f7d6e2f2126a67b'
|
||||
|
||||
default['nodejs']['binary']['url'] = nil # Auto generated
|
||||
default['nodejs']['binary']['checksum']['linux_x64'] = '3df19b748ee2b6dfe3a03448ebc6186a3a86aeab557018d77a0f7f3314594ef6'
|
||||
default['nodejs']['binary']['checksum']['linux_x86'] = '56ecffbd8a656991f71e4b53ab00af333c97453062cadc20a2103b933088d24d'
|
||||
default['nodejs']['binary']['checksum']['linux_arm64'] = '781ecf1ecb14b4c671ef0732988636282d6fb7071c4bd52567f663b008796bc9'
|
||||
|
||||
default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
|
||||
|
||||
default['nodejs']['manage_node'] = true
|
2
ops/cookbooks/vendor/nodejs/attributes/npm.rb
vendored
Normal file
2
ops/cookbooks/vendor/nodejs/attributes/npm.rb
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
default['nodejs']['npm']['install_method'] = 'embedded'
|
||||
default['nodejs']['npm']['version'] = 'latest'
|
11
ops/cookbooks/vendor/nodejs/attributes/packages.rb
vendored
Normal file
11
ops/cookbooks/vendor/nodejs/attributes/packages.rb
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
include_attribute 'nodejs::default'
|
||||
include_attribute 'nodejs::repo'
|
||||
|
||||
default['nodejs']['packages'] = value_for_platform_family(
|
||||
'debian' => node['nodejs']['install_repo'] ? ['nodejs'] : ['nodejs', 'npm', 'nodejs-dev'],
|
||||
%w(rhel fedora amazon) => node['nodejs']['install_repo'] ? ['nodejs', 'nodejs-devel'] : ['nodejs', 'npm', 'nodejs-dev'],
|
||||
'suse' => node['platform_version'].to_i < 42 ? ['nodejs', 'nodejs-devel'] : ['nodejs4', 'npm4', 'nodejs4-devel'],
|
||||
'mac_os_x' => ['node'],
|
||||
'freebsd' => %w(node npm),
|
||||
'default' => ['nodejs']
|
||||
)
|
12
ops/cookbooks/vendor/nodejs/attributes/repo.rb
vendored
Normal file
12
ops/cookbooks/vendor/nodejs/attributes/repo.rb
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
default['nodejs']['install_repo'] = true
|
||||
default['nodejs']['repo'] = 'https://deb.nodesource.com/node_6.x'
|
||||
default['nodejs']['keyserver'] = 'keyserver.ubuntu.com'
|
||||
default['nodejs']['key'] = '1655a0ab68576280'
|
||||
when 'rhel', 'amazon'
|
||||
default['nodejs']['install_repo'] = true
|
||||
release_ver = platform?('amazon') ? 6 : node['platform_version'].to_i
|
||||
default['nodejs']['repo'] = "https://rpm.nodesource.com/pub_6.x/el/#{release_ver}/$basearch"
|
||||
default['nodejs']['key'] = 'https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL'
|
||||
end
|
40
ops/cookbooks/vendor/nodejs/libraries/nodejs_helper.rb
vendored
Normal file
40
ops/cookbooks/vendor/nodejs/libraries/nodejs_helper.rb
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
module NodeJs
|
||||
module Helper
|
||||
def npm_dist
|
||||
if node['nodejs']['npm']['url']
|
||||
{ '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, max_nesting: false)
|
||||
ret = { 'url' => result['dist']['tarball'], 'version' => result['_npmVersion'], 'shasum' => result['dist']['shasum'] }
|
||||
Chef::Log.debug("Npm dist #{ret}")
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def npm_list(package, path = nil, environment = {})
|
||||
require 'json'
|
||||
cmd = if path
|
||||
Mixlib::ShellOut.new("npm list #{package} -json", cwd: path, environment: environment)
|
||||
else
|
||||
Mixlib::ShellOut.new("npm list #{package} -global -json", environment: environment)
|
||||
end
|
||||
|
||||
JSON.parse(cmd.run_command.stdout, max_nesting: false)
|
||||
end
|
||||
|
||||
def version_valid?(list, package, version)
|
||||
(version ? list[package]['version'] == version : true)
|
||||
end
|
||||
|
||||
def npm_package_installed?(package, version = nil, path = nil, npm_token = nil)
|
||||
environment = { 'NPM_TOKEN' => npm_token } if npm_token
|
||||
|
||||
list = npm_list(package, path, environment)['dependencies']
|
||||
# Return true if package installed and installed to good version
|
||||
!list.nil? && list.key?(package) && version_valid?(list, package, version)
|
||||
end
|
||||
end
|
||||
end
|
1
ops/cookbooks/vendor/nodejs/metadata.json
vendored
Normal file
1
ops/cookbooks/vendor/nodejs/metadata.json
vendored
Normal file
File diff suppressed because one or more lines are too long
23
ops/cookbooks/vendor/nodejs/recipes/default.rb
vendored
Normal file
23
ops/cookbooks/vendor/nodejs/recipes/default.rb
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2010-2017, 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::install' if node['nodejs']['manage_node']
|
||||
include_recipe 'nodejs::npm' if node['nodejs']['manage_node']
|
||||
include_recipe 'nodejs::npm_packages' if node['nodejs']['manage_node']
|
21
ops/cookbooks/vendor/nodejs/recipes/install.rb
vendored
Normal file
21
ops/cookbooks/vendor/nodejs/recipes/install.rb
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: install
|
||||
#
|
||||
# Copyright:: 2010-2017, 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']}"
|
1
ops/cookbooks/vendor/nodejs/recipes/iojs.rb
vendored
Normal file
1
ops/cookbooks/vendor/nodejs/recipes/iojs.rb
vendored
Normal file
@ -0,0 +1 @@
|
||||
Chef::Log.fatal('The nodejs::iojs recipe has been deprecated. If you need iojs installation pin to cookbook version 3.0.1.')
|
21
ops/cookbooks/vendor/nodejs/recipes/nodejs.rb
vendored
Normal file
21
ops/cookbooks/vendor/nodejs/recipes/nodejs.rb
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: nodejs
|
||||
#
|
||||
# Copyright:: 2010-2017, 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::Log.fatal('The nodejs::nodejs recipe is no longer used. Use nodejs::install to install nodejs instead.')
|
65
ops/cookbooks/vendor/nodejs/recipes/nodejs_from_binary.rb
vendored
Normal file
65
ops/cookbooks/vendor/nodejs/recipes/nodejs_from_binary.rb
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
#
|
||||
# Author:: Julian Wilde (jules@jules.com.au)
|
||||
# Cookbook:: 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::Recipe.send(:include, NodeJs::Helper)
|
||||
|
||||
# Shamelessly borrowed from http://docs.chef.io/dsl_recipe_method_platform.html
|
||||
# Surely there's a more canonical way to get arch?
|
||||
arch = if node['kernel']['machine'] =~ /armv6l/
|
||||
# FIXME: This should really check the version of node we're looking for
|
||||
# as it seems that they haven't build an `arm-pi` version in a while...
|
||||
# if it's old, return this, otherwise just return `node['kernel']['machine']`
|
||||
'arm-pi' # assume a raspberry pi
|
||||
elsif node['kernel']['machine'] =~ /aarch64/
|
||||
'arm64'
|
||||
elsif node['kernel']['machine'] =~ /x86_64/
|
||||
'x64'
|
||||
elsif node['kernel']['machine'] =~ /\d86/
|
||||
'x86'
|
||||
else
|
||||
node['kernel']['machine']
|
||||
end
|
||||
|
||||
# needed to uncompress the binary
|
||||
package 'tar' if platform_family?('rhel', 'fedora', 'amazon', 'suse')
|
||||
|
||||
# package_stub is for example: "node-v6.9.1-linux-x64.tar.gz"
|
||||
version = "v#{node['nodejs']['version']}/"
|
||||
prefix = node['nodejs']['prefix_url']['node']
|
||||
|
||||
filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.gz"
|
||||
archive_name = 'nodejs-binary'
|
||||
binaries = ['bin/node']
|
||||
|
||||
binaries.push('bin/npm') if node['nodejs']['npm']['install_method'] == 'embedded'
|
||||
|
||||
if node['nodejs']['binary']['url']
|
||||
nodejs_bin_url = node['nodejs']['binary']['url']
|
||||
checksum = node['nodejs']['binary']['checksum']
|
||||
else
|
||||
nodejs_bin_url = ::URI.join(prefix, version, filename).to_s
|
||||
checksum = node['nodejs']['binary']['checksum']["linux_#{arch}"]
|
||||
end
|
||||
|
||||
ark archive_name do
|
||||
url nodejs_bin_url
|
||||
version node['nodejs']['version']
|
||||
checksum checksum
|
||||
has_binaries binaries
|
||||
action :install
|
||||
end
|
33
ops/cookbooks/vendor/nodejs/recipes/nodejs_from_package.rb
vendored
Normal file
33
ops/cookbooks/vendor/nodejs/recipes/nodejs_from_package.rb
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
# Author:: Nathan L Smith (nlloyds@gmail.com)
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: package
|
||||
#
|
||||
# Copyright:: 2012-2017, Cramer Development, Inc.
|
||||
# Copyright:: 2013-2017, 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']
|
||||
|
||||
unless node['nodejs']['packages']
|
||||
Chef::Log.error 'No package for nodejs'
|
||||
Chef::Log.warn 'Please use the source or binary method to install node'
|
||||
return
|
||||
end
|
||||
|
||||
node['nodejs']['packages'].each do |node_pkg|
|
||||
package node_pkg
|
||||
end
|
45
ops/cookbooks/vendor/nodejs/recipes/nodejs_from_source.rb
vendored
Normal file
45
ops/cookbooks/vendor/nodejs/recipes/nodejs_from_source.rb
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: source
|
||||
#
|
||||
# Copyright:: 2010-2017, 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)
|
||||
|
||||
build_essential 'install build tools'
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel', 'fedora', 'amazon'
|
||||
package %w(openssl-devel tar)
|
||||
when 'debian'
|
||||
package 'libssl-dev'
|
||||
end
|
||||
|
||||
version = "v#{node['nodejs']['version']}/"
|
||||
prefix = node['nodejs']['prefix_url']['node']
|
||||
filename = "node-v#{node['nodejs']['version']}.tar.gz"
|
||||
archive_name = 'nodejs-source'
|
||||
|
||||
nodejs_src_url = node['nodejs']['source']['url'] || ::URI.join(prefix, version, filename).to_s
|
||||
|
||||
ark archive_name 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
|
28
ops/cookbooks/vendor/nodejs/recipes/npm.rb
vendored
Normal file
28
ops/cookbooks/vendor/nodejs/recipes/npm.rb
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: npm
|
||||
#
|
||||
# Copyright:: 2010-2017, 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.
|
||||
#
|
||||
|
||||
case node['nodejs']['npm']['install_method']
|
||||
when 'embedded'
|
||||
include_recipe 'nodejs::install'
|
||||
when 'source'
|
||||
include_recipe 'nodejs::npm_from_source'
|
||||
else
|
||||
Chef::Log.error('No install method found for npm')
|
||||
end
|
32
ops/cookbooks/vendor/nodejs/recipes/npm_from_source.rb
vendored
Normal file
32
ops/cookbooks/vendor/nodejs/recipes/npm_from_source.rb
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# Author:: Marius Ducea (marius@promethost.com)
|
||||
# Cookbook:: nodejs
|
||||
# Recipe:: npm
|
||||
#
|
||||
# Copyright:: 2010-2017, 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_from_source'
|
||||
|
||||
dist = npm_dist
|
||||
|
||||
ark 'npm' do
|
||||
url dist['url']
|
||||
checksum dist['checksum']
|
||||
version dist['version']
|
||||
action :install_with_make
|
||||
end
|
11
ops/cookbooks/vendor/nodejs/recipes/npm_packages.rb
vendored
Normal file
11
ops/cookbooks/vendor/nodejs/recipes/npm_packages.rb
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
node['nodejs']['npm_packages'].each do |pkg|
|
||||
pkg_action = pkg.key?('action') ? pkg['action'] : :install
|
||||
f = npm_package "nodejs_npm-#{pkg['name']}-#{pkg_action}" do
|
||||
action :nothing
|
||||
package pkg['name']
|
||||
end
|
||||
pkg.each do |key, value|
|
||||
f.send(key, value) unless key == 'name' || key == 'action'
|
||||
end
|
||||
f.action(pkg_action)
|
||||
end if node['nodejs'].key?('npm_packages')
|
20
ops/cookbooks/vendor/nodejs/recipes/repo.rb
vendored
Normal file
20
ops/cookbooks/vendor/nodejs/recipes/repo.rb
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
package 'nodejs-apt-transport-https' do
|
||||
package_name 'apt-transport-https'
|
||||
end
|
||||
|
||||
apt_repository 'node.js' do
|
||||
uri node['nodejs']['repo']
|
||||
distribution node['lsb']['codename']
|
||||
components ['main']
|
||||
keyserver node['nodejs']['keyserver']
|
||||
key node['nodejs']['key']
|
||||
end
|
||||
when 'rhel', 'amazon'
|
||||
yum_repository 'node.js' do
|
||||
description 'nodesource.com nodejs repository'
|
||||
baseurl node['nodejs']['repo']
|
||||
gpgkey node['nodejs']['key']
|
||||
end
|
||||
end
|
100
ops/cookbooks/vendor/nodejs/resources/npm_package.rb
vendored
Normal file
100
ops/cookbooks/vendor/nodejs/resources/npm_package.rb
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
#
|
||||
# Cookbook:: nodejs
|
||||
# Resource:: npm
|
||||
#
|
||||
# Author:: Sergey Balbeko <sergey@balbeko.com>
|
||||
#
|
||||
# Copyright:: 2012-2017, 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.
|
||||
#
|
||||
|
||||
resource_name :npm_package
|
||||
|
||||
# backwards compatibility for the old resource name
|
||||
provides :nodejs_npm
|
||||
|
||||
property :package, name_property: true
|
||||
property :version, String
|
||||
property :path, String
|
||||
property :url, String
|
||||
property :json, [String, true]
|
||||
property :npm_token, String
|
||||
property :options, Array, default: []
|
||||
property :user, String
|
||||
property :group, String
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
@run_context.include_recipe 'nodejs::npm' if node['nodejs']['manage_node']
|
||||
end
|
||||
|
||||
action :install do
|
||||
execute "install NPM package #{new_resource.package}" do
|
||||
cwd new_resource.path
|
||||
command "npm install #{npm_options}"
|
||||
user new_resource.user
|
||||
group new_resource.group
|
||||
environment npm_env_vars
|
||||
not_if { package_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 npm_env_vars
|
||||
only_if { package_installed? }
|
||||
end
|
||||
end
|
||||
|
||||
action_class do
|
||||
include NodeJs::Helper
|
||||
|
||||
def npm_env_vars
|
||||
env_vars = {}
|
||||
env_vars['HOME'] = ::Dir.home(new_resource.user) if new_resource.user
|
||||
env_vars['USER'] = new_resource.user if new_resource.user
|
||||
env_vars['NPM_TOKEN'] = new_resource.npm_token if new_resource.npm_token
|
||||
|
||||
env_vars
|
||||
end
|
||||
|
||||
def package_installed?
|
||||
new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, new_resource.npm_token)
|
||||
end
|
||||
|
||||
def npm_options
|
||||
options = ''
|
||||
options << ' -global' unless new_resource.path
|
||||
new_resource.options.each do |option|
|
||||
options << " #{option}"
|
||||
end
|
||||
options << " #{npm_package}"
|
||||
end
|
||||
|
||||
def npm_package
|
||||
if new_resource.json
|
||||
new_resource.json.is_a?(String) ? new_resource.json : nil
|
||||
elsif new_resource.url
|
||||
new_resource.url
|
||||
elsif new_resource.package
|
||||
new_resource.version ? "#{new_resource.package}@#{new_resource.version}" : new_resource.package
|
||||
else
|
||||
Chef::Log.error("No good options found to install #{new_resource.package}")
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user