diff --git a/Batali b/Batali index b153bad..b0f08e4 100644 --- a/Batali +++ b/Batali @@ -35,7 +35,7 @@ Batali.define do cookbook 'mysql2_chef_gem' cookbook 'omnibus_updater', '~> 1.0.4' cookbook 'timezone-ii' - cookbook 'nodejs', '~> 2.4.4' + cookbook 'nodejs', '~> 3.0.0' cookbook 'ark' cookbook 'logrotate' end diff --git a/batali.manifest b/batali.manifest index b0e8c5a..caada72 100644 --- a/batali.manifest +++ b/batali.manifest @@ -619,7 +619,7 @@ "version": "2.0.1", "source": { "url": "https://github.com/67p/application_nodejs.git", - "ref": "54f280eb627866f24901c79c86678e6218d976f0", + "ref": "0c3494b0cae87bd1e9cbf360e91f1a290b517a66", "type": "Batali::Source::Git", "subdirectory": null } @@ -641,18 +641,18 @@ ], [ "apt", - ">= 0.0.0" + ">= 2.9.1" ], [ "homebrew", ">= 0.0.0" ] ], - "version": "2.4.4", + "version": "3.0.0", "source": { "type": "Batali::Source::Site", - "url": "https://supermarket.chef.io:443/api/v1/cookbooks/nodejs/versions/2.4.4/download", - "version": "2.4.4" + "url": "https://supermarket.chef.io:443/api/v1/cookbooks/nodejs/versions/3.0.0/download", + "version": "3.0.0" } }, { diff --git a/cookbooks/application_nodejs/providers/nodejs.rb b/cookbooks/application_nodejs/providers/nodejs.rb index 73ab654..e426f37 100644 --- a/cookbooks/application_nodejs/providers/nodejs.rb +++ b/cookbooks/application_nodejs/providers/nodejs.rb @@ -22,8 +22,6 @@ include Chef::DSL::IncludeRecipe action :before_compile do - include_recipe 'nodejs::nodejs_from_package' - r = new_resource if new_resource.npm diff --git a/cookbooks/nodejs/.gitignore b/cookbooks/nodejs/.gitignore new file mode 100644 index 0000000..6c97e28 --- /dev/null +++ b/cookbooks/nodejs/.gitignore @@ -0,0 +1,49 @@ +*.rbc +.config +coverage +InstalledFiles +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp +_Store +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +*.tmp +*.bk +*.bkup + +# ruby/bundler files +.ruby-version +.ruby-gemset +.rvmrc +Gemfile.lock +.bundle +*.gem + +# YARD artifacts +.yardoc +_yardoc +doc/ +.idea + +# chef stuff +Berksfile.lock +.kitchen +.kitchen.local.yml +vendor/ +.coverage/ +.zero-knife.rb +Policyfile.lock.json + +# vagrant stuff +.vagrant/ +.vagrant.d/ +.kitchen/ diff --git a/cookbooks/nodejs/.kitchen.yml b/cookbooks/nodejs/.kitchen.yml new file mode 100644 index 0000000..dc5da76 --- /dev/null +++ b/cookbooks/nodejs/.kitchen.yml @@ -0,0 +1,105 @@ +driver: + name: vagrant + +provisioner: + name: chef_zero + +verifier: + name: inspec + +driver_config: + customize: + memory: 512 + cpus: 4 + +platforms: + - name: centos-5.11 + - name: centos-6.8 + - name: centos-7.2 + - name: debian-7.11 + run_list: apt::default + - name: debian-8.5 + run_list: apt::default + - name: fedora-24 + run_list: yum::dnf_yum_compat + - name: ubuntu-12.04 + run_list: apt::default + - name: ubuntu-14.04 + run_list: apt::default + - name: ubuntu-16.04 + run_list: apt::default + +suites: +- name: default + run_list: + - recipe[nodejs] +- name: package + run_list: + - recipe[nodejs] + attributes: + nodejs: + install_method: package +- name: binary + run_list: + - recipe[nodejs] + attributes: + nodejs: + install_method: binary +- name: source + run_list: + - recipe[nodejs] + attributes: + nodejs: + install_method: source + excludes: + - ubuntu-12.04 + - centos-5.11 + - centos-6.8 +- name: source-iojs + run_list: + - recipe[nodejs] + attributes: + nodejs: + engine: iojs + install_method: source + source: + checksum: 55e79cc4f4cde41f03c1e204d2af5ee4b6e4edcf14defc82e518436e939195fa + version: 2.2.1 + excludes: + - ubuntu-12.04 + - centos-5.11 + - centos-6.8 +- 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 + excludes: + - ubuntu-12.04 + - centos-5.11 + - centos-6.8 +- name: npm_packages + run_list: recipe[nodejs] + attributes: + nodejs: + npm_packages: + - name: express + - name: socket.io + version: 1.0.4 + - name: express + action: uninstall diff --git a/cookbooks/nodejs/.travis.yml b/cookbooks/nodejs/.travis.yml new file mode 100644 index 0000000..2c085f9 --- /dev/null +++ b/cookbooks/nodejs/.travis.yml @@ -0,0 +1,25 @@ +# Use Travis's cointainer based infrastructure +sudo: false +addons: + apt: + sources: + - chef-current-precise + packages: + - chefdk + +# Don't `bundle install` +install: echo "skip bundle install" + +branches: + only: + - master + +# Ensure we make ChefDK's Ruby the default +before_script: + - eval "$(/opt/chefdk/bin/chef shell-init bash)" + +script: + - /opt/chefdk/embedded/bin/chef --version + - /opt/chefdk/embedded/bin/cookstyle --version + - /opt/chefdk/embedded/bin/foodcritic --version + - /opt/chefdk/bin/chef exec rake diff --git a/cookbooks/nodejs/Berksfile b/cookbooks/nodejs/Berksfile new file mode 100644 index 0000000..8ba108f --- /dev/null +++ b/cookbooks/nodejs/Berksfile @@ -0,0 +1,9 @@ +source 'https://supermarket.chef.io' + +metadata + +group :integration do + cookbook 'yum' + cookbook 'apt' + cookbook 'nodejs_test', path: './test/cookbooks/nodejs_test' +end diff --git a/cookbooks/nodejs/CHANGELOG.md b/cookbooks/nodejs/CHANGELOG.md index 5623870..282bcd6 100644 --- a/cookbooks/nodejs/CHANGELOG.md +++ b/cookbooks/nodejs/CHANGELOG.md @@ -1,99 +1,134 @@ +# NodeJS Cookbook Changelog + +## 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 + +- 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 + +- 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 + +- 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 + +- Fix package recipe ## v2.3.0 - * Support io.js. Use node['nodejs']['engine']. - * Add MacOS support via homebrew + +- 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 + +- 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 +- 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][]) + +- 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][]) + +- 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][]) + +- 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 + +- 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][]) +- 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). + +- 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][]) + +- add support for binary installation method ([@JulesAU]) ## v1.0.3: - - unreleased + +- 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 + +- 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 +- 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][]) +- added packages installation support ([@smith]) -[@JulesAU]: https://github.com/JulesAU -[@sax]: https://github.com/sax -[@ChrisLundquist]: https://github.com/ChrisLundquist -[@markbirbeck]: https://github.com/markbirbeck -[@johannesbecker]: https://github.com/johannesbecker -[@smith]: https://github.com/smith [@bakins]: https://github.com/bakins -[@vaskas]: https://github.com/vaskas -[@robertkowalski]: https://github.com/robertkowalski -[@wanelo-pair]: https://github.com/wanelo-pair -[@predominant]: https://github.com/predominant -[@sjlu]: https://github.com/sjlu +[@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 diff --git a/cookbooks/nodejs/Gemfile b/cookbooks/nodejs/Gemfile new file mode 100644 index 0000000..367391d --- /dev/null +++ b/cookbooks/nodejs/Gemfile @@ -0,0 +1,20 @@ +source 'https://rubygems.org' + +gem 'rake' +gem 'stove' + +group :lint do + gem 'foodcritic', '~> 8.1' + gem 'cookstyle' +end + +group :unit do + gem 'berkshelf', '~> 5.1' + gem 'chefspec', '~> 5.2' +end + +group :kitchen do + gem 'test-kitchen', '~> 1.13' + gem 'kitchen-vagrant', '~> 0.20' + gem 'kitchen-inspec', '~> 0.15' +end diff --git a/cookbooks/nodejs/LICENSE b/cookbooks/nodejs/LICENSE new file mode 100644 index 0000000..8f71f43 --- /dev/null +++ b/cookbooks/nodejs/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. + diff --git a/cookbooks/nodejs/README.md b/cookbooks/nodejs/README.md index 45890b3..9c8813b 100644 --- a/cookbooks/nodejs/README.md +++ b/cookbooks/nodejs/README.md @@ -1,14 +1,34 @@ # [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) -[![Gitter chat](https://badges.gitter.im/redguide/nodejs.png)](https://gitter.im/redguide/nodejs) -## DESCRIPTION +[![CK Version](http://img.shields.io/cookbook/v/nodejs.svg?branch=master)](https://supermarket.getchef.com/cookbooks/nodejs) [![Build Status](https://img.shields.io/travis/redguide/nodejs.svg)](https://travis-ci.org/redguide/nodejs) [![Gitter chat](https://badges.gitter.im/redguide/nodejs.svg)](https://gitter.im/redguide/nodejs) -Installs node.js/io.js and manage npm +Installs node.js/io.js and manages npm -## USAGE +## Requirements + +### Platforms + +- Debian/Ubuntu +- RHEL/CentOS/Scientific/Amazon/Oracle + +Note: Source installs require GCC 4.8+, which is not included on older distro releases + +### Chef + +- Chef 11+ + +### Cookbooks + +- yum-epel +- build-essential +- ark +- apt +- homebrew + +## Usage Include the nodejs recipe to install node on your system based on the default installation method: + ```chef include_recipe "nodejs" ``` @@ -16,6 +36,7 @@ include_recipe "nodejs" ### Engine You can select different engine by setting `node['nodejs']['engine']` + ``` node['nodejs']['engine'] => 'node' # default node['nodejs']['engine'] => 'iojs' @@ -35,22 +56,28 @@ 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). + +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). #### 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' ``` #### Source Install node from sources: + ```chef node['nodejs']['install_method'] = 'source' include_recipe "nodejs" @@ -60,36 +87,43 @@ 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']` +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']`. -## LWRP +## Custom Resources (Providers) ### nodejs_npm `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 - + +- npm registry: + + - name: `attribute :package` + - version: `attribute :version` (optional) + +- url: `attribute :url` + + - for git use `git://{your_repo}` + +- from a json (package.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`) 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']` - +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 @@ -119,6 +153,7 @@ nodejs_npm "my_private_module" do 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): @@ -147,9 +182,22 @@ Or add packages via attributes (which accept the same attributes as the LWRP abo } ``` -## AUTHORS +## License & Authors -* Marius Ducea (marius@promethost.com) -* Nathan L Smith (nlloyds@gmail.com) -* Guilhem Lettron (guilhem@lettron.fr) -* Barthelemy Vessemont (bvessemont@gmail.com) +**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-2016, 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. +``` diff --git a/cookbooks/nodejs/Rakefile b/cookbooks/nodejs/Rakefile new file mode 100644 index 0000000..0513520 --- /dev/null +++ b/cookbooks/nodejs/Rakefile @@ -0,0 +1,67 @@ +#!/usr/bin/env rake + +# Style tests. cookstyle (rubocop) and Foodcritic +namespace :style do + begin + require 'cookstyle' + require 'rubocop/rake_task' + + desc 'Run Ruby style checks' + RuboCop::RakeTask.new(:ruby) + rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] + end + + begin + require 'foodcritic' + + desc 'Run Chef style checks' + FoodCritic::Rake::LintTask.new(:chef) do |t| + t.options = { + fail_tags: ['any'], + progress: true + } + end + rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] + end +end + +desc 'Run all style checks' +task style: ['style:chef', 'style:ruby'] + +# ChefSpec +begin + require 'rspec/core/rake_task' + + desc 'Run ChefSpec examples' + RSpec::Core::RakeTask.new(:spec) +rescue LoadError + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] +end + +# Integration tests. Kitchen.ci +namespace :integration do + begin + require 'kitchen/rake_tasks' + + desc 'Run kitchen integration tests' + Kitchen::RakeTasks.new + rescue StandardError => e + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] + end +end + +namespace :supermarket do + begin + require 'stove/rake_task' + + desc 'Publish cookbook to Supermarket with Stove' + Stove::RakeTask.new + rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] + end +end + +# Default +task default: %w(style spec) diff --git a/cookbooks/nodejs/attributes/default.rb b/cookbooks/nodejs/attributes/default.rb index e5d33f6..f5470de 100644 --- a/cookbooks/nodejs/attributes/default.rb +++ b/cookbooks/nodejs/attributes/default.rb @@ -26,17 +26,17 @@ end default['nodejs']['engine'] = 'node' # or iojs -default['nodejs']['version'] = '0.10.26' +default['nodejs']['version'] = '6.9.1' default['nodejs']['prefix_url']['node'] = 'https://nodejs.org/dist/' default['nodejs']['prefix_url']['iojs'] = 'https://iojs.org/dist/' default['nodejs']['source']['url'] = nil # Auto generated -default['nodejs']['source']['checksum'] = 'ef5e4ea6f2689ed7f781355012b942a2347e0299da0804a58de8e6281c4b1daa' +default['nodejs']['source']['checksum'] = '0bdd8d1305777cc8cd206129ea494d6c6ce56001868dd80147aff531d6df0729' 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_x64'] = 'd4eb161e4715e11bbef816a6c577974271e2bddae9cf008744627676ff00036a' +default['nodejs']['binary']['checksum']['linux_x86'] = 'f9b2ca03016e45bc35d2441a63a73db94d3e7b92350f15577d796467b9f7efb0' +default['nodejs']['binary']['checksum']['linux_arm64'] = '7aa69b6c8cff578d0d97d5bd4f76941b2fade5476f0408d53828666ee427dd4e' default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2 diff --git a/cookbooks/nodejs/attributes/packages.rb b/cookbooks/nodejs/attributes/packages.rb index 64442e8..aef591b 100644 --- a/cookbooks/nodejs/attributes/packages.rb +++ b/cookbooks/nodejs/attributes/packages.rb @@ -5,8 +5,9 @@ case node['nodejs']['engine'] when 'node' default['nodejs']['packages'] = value_for_platform_family( 'debian' => node['nodejs']['install_repo'] ? ['nodejs'] : ['nodejs', 'npm', 'nodejs-dev'], - ['rhel', 'fedora'] => ['nodejs', 'nodejs-devel', 'npm'], + %w(rhel fedora) => ['nodejs', 'nodejs-devel', 'npm'], 'mac_os_x' => ['node'], + 'freebsd' => %w(node npm), 'default' => ['nodejs'] ) when 'iojs' diff --git a/cookbooks/nodejs/chefignore b/cookbooks/nodejs/chefignore new file mode 100644 index 0000000..a976917 --- /dev/null +++ b/cookbooks/nodejs/chefignore @@ -0,0 +1,102 @@ +# Put files/directories that should be ignored in this file when uploading +# to a chef-server or supermarket. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +examples/* +Guardfile +Procfile +.kitchen* +.rubocop.yml +spec/* +Rakefile +.travis.yml +.foodcritic +.codeclimate.yml + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Cookbooks # +############# +CONTRIBUTING* +CHANGELOG* +TESTING* +MAINTAINERS.toml + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/cookbooks/nodejs/libraries/matchers.rb b/cookbooks/nodejs/libraries/matchers.rb index deaa654..32f4704 100644 --- a/cookbooks/nodejs/libraries/matchers.rb +++ b/cookbooks/nodejs/libraries/matchers.rb @@ -1,4 +1,6 @@ if defined?(ChefSpec) + ChefSpec.define_matcher :nodejs_npm + def install_nodejs_npm(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:nodejs_npm, :install, resource_name) end diff --git a/cookbooks/nodejs/libraries/nodejs_helper.rb b/cookbooks/nodejs/libraries/nodejs_helper.rb index 8848972..be84f5d 100644 --- a/cookbooks/nodejs/libraries/nodejs_helper.rb +++ b/cookbooks/nodejs/libraries/nodejs_helper.rb @@ -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, max_nesting: false) ret = { 'url' => result['dist']['tarball'], 'version' => result['_npmVersion'], 'shasum' => result['dist']['shasum'] } Chef::Log.debug("Npm dist #{ret}") return ret @@ -16,13 +16,13 @@ module NodeJs def npm_list(path = nil, environment = {}) require 'json' - if path - cmd = Mixlib::ShellOut.new('npm list -json', :cwd => path, :environment => environment) - else - cmd = Mixlib::ShellOut.new('npm list -global -json', :environment => environment) - end + cmd = if path + Mixlib::ShellOut.new('npm list -json', cwd: path, environment: environment) + else + Mixlib::ShellOut.new('npm list -global -json', environment: environment) + end - JSON.parse(cmd.run_command.stdout, :max_nesting => false) + JSON.parse(cmd.run_command.stdout, max_nesting: false) end def url_valid?(list, package) @@ -38,7 +38,7 @@ module NodeJs list = npm_list(path, environment)['dependencies'] # Return true if package installed and installed to good version - (!list.nil?) && list.key?(package) && version_valid?(list, package, version) && url_valid?(list, package) + !list.nil? && list.key?(package) && version_valid?(list, package, version) && url_valid?(list, package) end end end diff --git a/cookbooks/nodejs/metadata.json b/cookbooks/nodejs/metadata.json index 6cf03a4..38bc295 100644 --- a/cookbooks/nodejs/metadata.json +++ b/cookbooks/nodejs/metadata.json @@ -1 +1,65 @@ -{"name":"nodejs","version":"2.4.4","description":"Installs/Configures node.js & io.js","long_description":"# [nodejs-cookbook](https://github.com/redguide/nodejs)\n[![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)\n[![Gitter chat](https://badges.gitter.im/redguide/nodejs.png)](https://gitter.im/redguide/nodejs)\n\n## DESCRIPTION\n\nInstalls node.js/io.js and manage npm\n\n## USAGE\n\nInclude the nodejs recipe to install node on your system based on the default installation method:\n```chef\ninclude_recipe \"nodejs\"\n```\n\n### Engine\n\nYou can select different engine by setting `node['nodejs']['engine']`\n```\nnode['nodejs']['engine'] => 'node' # default\nnode['nodejs']['engine'] => 'iojs'\n```\n\nYou can also use recipes `nodejs::nodejs` or `nodejs::iojs`.\n\n### Install methods\n\n#### Package\n\nInstall node from packages:\n\n```chef\nnode['nodejs']['install_method'] = 'package' # Not necessary because it's the default\ninclude_recipe \"nodejs\"\n# Or\ninclude_recipe \"nodejs::nodejs_from_package\"\n```\nNote that only apt (Ubuntu, Debian) appears to have up to date packages available. \nCentos, RHEL, etc are non-functional (try `nodejs_from_binary` for those).\n\n#### Binary\n\nInstall node from official prebuilt binaries:\n```chef\nnode['nodejs']['install_method'] = 'binary'\ninclude_recipe \"nodejs\"\n# Or\ninclude_recipe \"nodejs::nodejs_from_binary\"\n```\n\n#### Source\n\nInstall node from sources:\n```chef\nnode['nodejs']['install_method'] = 'source'\ninclude_recipe \"nodejs\"\n# Or\ninclude_recipe \"nodejs::nodejs_from_source\"\n```\n\n## NPM\n\nNpm is included in nodejs installs by default.\nBy default, we are using it and call it `embedded`.\nAdding recipe `nodejs::npm` assure you to have npm installed and let you choose install method with `node['nodejs']['npm']['install_method']`\n```chef\ninclude_recipe \"nodejs::npm\"\n```\n_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']`.\n\n## LWRP\n\n### nodejs_npm\n\n`nodejs_npm` let you install npm packages from various sources:\n* npm registry:\n * name: `attribute :package`\n * version: `attribute :version` (optionnal)\n* url: `attribute :url`\n * for git use `git://{your_repo}`\n* from a json (packages.json by default): `attribute :json`\n * use `true` for default\n * use a `String` to specify json file\n \nPackages can be installed globally (by default) or in a directory (by using `attribute :path`)\n\nYou can specify an `NPM_TOKEN` environment variable for accessing [NPM private modules](https://docs.npmjs.com/private-modules/intro) by using `attribute :npm_token`\n\nYou can append more specific options to npm command with `attribute :options` array : \n * use an array of options (w/ dash), they will be added to npm call.\n * ex: `['--production','--force']` or `['--force-latest']`\n \nThis LWRP attempts to use vanilla npm as much as possible (no custom wrapper).\n\n### Packages\n\n```ruby\nnodejs_npm \"express\"\n\nnodejs_npm \"async\" do\n version \"0.6.2\"\nend\n\nnodejs_npm \"request\" do\n url \"github mikeal/request\"\nend\n\nnodejs_npm \"grunt\" do\n path \"/home/random/grunt\"\n json true\n user \"random\"\nend\n\nnodejs_npm \"my_private_module\" do\n path \"/home/random/myproject\" # The root path to your project, containing a package.json file\n json true\n npm_token \"12345-abcde-e5d4c3b2a1\"\n user \"random\"\n options ['--production'] # Only install dependencies. Skip devDependencies\nend\n```\n[Working Examples](test/cookbooks/nodejs_test/recipes/npm.rb)\n\nOr add packages via attributes (which accept the same attributes as the LWRP above):\n\n```json\n\"nodejs\": {\n \"npm_packages\": [\n {\n \"name\": \"express\"\n },\n {\n \"name\": \"async\",\n \"version\": \"0.6.2\"\n },\n {\n \"name\": \"request\",\n \"url\": \"github mikeal/request\"\n }\n {\n \"name\": \"grunt\",\n \"path\": \"/home/random/grunt\",\n \"json\": true,\n \"user\": \"random\"\n }\n ]\n}\n```\n\n## AUTHORS\n\n* Marius Ducea (marius@promethost.com)\n* Nathan L Smith (nlloyds@gmail.com)\n* Guilhem Lettron (guilhem@lettron.fr)\n* Barthelemy Vessemont (bvessemont@gmail.com)\n","maintainer":"redguide","maintainer_email":"guilhem@lettron.fr","license":"Apache 2.0","platforms":{"debian":">= 0.0.0","ubuntu":">= 0.0.0","centos":">= 0.0.0","redhat":">= 0.0.0","smartos":">= 0.0.0","mac_os_x":">= 0.0.0"},"dependencies":{"yum-epel":">= 0.0.0","build-essential":">= 0.0.0","ark":">= 0.0.0","apt":">= 0.0.0","homebrew":">= 0.0.0"},"recommendations":{},"suggestions":{"application_nodejs":">= 0.0.0"},"conflicting":{"node":">= 0.0.0"},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} \ No newline at end of file +{ + "name": "nodejs", + "description": "Installs/Configures node.js & io.js", + "long_description": "# [nodejs-cookbook](https://github.com/redguide/nodejs)\n\n[![CK Version](http://img.shields.io/cookbook/v/nodejs.svg?branch=master)](https://supermarket.getchef.com/cookbooks/nodejs) [![Build Status](https://img.shields.io/travis/redguide/nodejs.svg)](https://travis-ci.org/redguide/nodejs) [![Gitter chat](https://badges.gitter.im/redguide/nodejs.svg)](https://gitter.im/redguide/nodejs)\n\nInstalls node.js/io.js and manages npm\n\n## Requirements\n\n### Platforms\n\n- Debian/Ubuntu\n- RHEL/CentOS/Scientific/Amazon/Oracle\n\nNote: Source installs require GCC 4.8+, which is not included on older distro releases\n\n### Chef\n\n- Chef 11+\n\n### Cookbooks\n\n- yum-epel\n- build-essential\n- ark\n- apt\n- homebrew\n\n## Usage\n\nInclude the nodejs recipe to install node on your system based on the default installation method:\n\n```chef\ninclude_recipe \"nodejs\"\n```\n\n### Engine\n\nYou can select different engine by setting `node['nodejs']['engine']`\n\n```\nnode['nodejs']['engine'] => 'node' # default\nnode['nodejs']['engine'] => 'iojs'\n```\n\nYou can also use recipes `nodejs::nodejs` or `nodejs::iojs`.\n\n### Install methods\n\n#### Package\n\nInstall node from packages:\n\n```chef\nnode['nodejs']['install_method'] = 'package' # Not necessary because it's the default\ninclude_recipe \"nodejs\"\n# Or\ninclude_recipe \"nodejs::nodejs_from_package\"\n```\n\nNote 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).\n\n#### Binary\n\nInstall node from official prebuilt binaries:\n\n```chef\nnode['nodejs']['install_method'] = 'binary'\ninclude_recipe \"nodejs\"\n# Or\ninclude_recipe \"nodejs::nodejs_from_binary\"\n# Or set a specific version of nodejs to be installed\nnode.default['nodejs']['install_method'] = 'binary'\nnode.default['nodejs']['version'] = '5.9.0'\nnode.default['nodejs']['binary']['checksum'] = '99c4136cf61761fac5ac57f80544140a3793b63e00a65d4a0e528c9db328bf40'\n```\n\n#### Source\n\nInstall node from sources:\n\n```chef\nnode['nodejs']['install_method'] = 'source'\ninclude_recipe \"nodejs\"\n# Or\ninclude_recipe \"nodejs::nodejs_from_source\"\n```\n\n## NPM\n\nNpm 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']`\n\n```chef\ninclude_recipe \"nodejs::npm\"\n```\n\n_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']`.\n\n## Custom Resources (Providers)\n\n### nodejs_npm\n\n`nodejs_npm` let you install npm packages from various sources:\n\n- npm registry:\n\n - name: `attribute :package`\n - version: `attribute :version` (optional)\n\n- url: `attribute :url`\n\n - for git use `git://{your_repo}`\n\n- from a json (package.json by default): `attribute :json`\n\n - use `true` for default\n - use a `String` to specify json file\n\nPackages can be installed globally (by default) or in a directory (by using `attribute :path`)\n\nYou can specify an `NPM_TOKEN` environment variable for accessing [NPM private modules](https://docs.npmjs.com/private-modules/intro) by using `attribute :npm_token`\n\nYou can append more specific options to npm command with `attribute :options` array :\n\n- use an array of options (w/ dash), they will be added to npm call.\n- ex: `['--production','--force']` or `['--force-latest']`\n\nThis LWRP attempts to use vanilla npm as much as possible (no custom wrapper).\n\n### Packages\n\n```ruby\nnodejs_npm \"express\"\n\nnodejs_npm \"async\" do\n version \"0.6.2\"\nend\n\nnodejs_npm \"request\" do\n url \"github mikeal/request\"\nend\n\nnodejs_npm \"grunt\" do\n path \"/home/random/grunt\"\n json true\n user \"random\"\nend\n\nnodejs_npm \"my_private_module\" do\n path \"/home/random/myproject\" # The root path to your project, containing a package.json file\n json true\n npm_token \"12345-abcde-e5d4c3b2a1\"\n user \"random\"\n options ['--production'] # Only install dependencies. Skip devDependencies\nend\n```\n\n[Working Examples](test/cookbooks/nodejs_test/recipes/npm.rb)\n\nOr add packages via attributes (which accept the same attributes as the LWRP above):\n\n```json\n\"nodejs\": {\n \"npm_packages\": [\n {\n \"name\": \"express\"\n },\n {\n \"name\": \"async\",\n \"version\": \"0.6.2\"\n },\n {\n \"name\": \"request\",\n \"url\": \"github mikeal/request\"\n }\n {\n \"name\": \"grunt\",\n \"path\": \"/home/random/grunt\",\n \"json\": true,\n \"user\": \"random\"\n }\n ]\n}\n```\n\n## License & Authors\n\n**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)\n\n**Copyright:** 2008-2016, Chef Software, Inc.\n\n```\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n", + "maintainer": "redguide", + "maintainer_email": "guilhem@lettron.fr", + "license": "Apache 2.0", + "platforms": { + "debian": ">= 0.0.0", + "ubuntu": ">= 0.0.0", + "centos": ">= 0.0.0", + "redhat": ">= 0.0.0", + "scientific": ">= 0.0.0", + "oracle": ">= 0.0.0", + "amazon": ">= 0.0.0", + "smartos": ">= 0.0.0", + "mac_os_x": ">= 0.0.0" + }, + "dependencies": { + "yum-epel": ">= 0.0.0", + "build-essential": ">= 0.0.0", + "ark": ">= 0.0.0", + "apt": ">= 2.9.1", + "homebrew": ">= 0.0.0" + }, + "recommendations": { + + }, + "suggestions": { + + }, + "conflicting": { + + }, + "providing": { + + }, + "replacing": { + + }, + "attributes": { + + }, + "groupings": { + + }, + "recipes": { + + }, + "version": "3.0.0", + "source_url": "https://github.com/redguide/nodejs", + "issues_url": "https://github.com/redguide/nodejs/issues", + "privacy": false, + "chef_versions": [ + [ + ">= 11.0" + ] + ], + "ohai_versions": [ + + ], + "gems": [ + + ] +} diff --git a/cookbooks/nodejs/metadata.rb b/cookbooks/nodejs/metadata.rb new file mode 100644 index 0000000..083681e --- /dev/null +++ b/cookbooks/nodejs/metadata.rb @@ -0,0 +1,20 @@ +name 'nodejs' +maintainer 'redguide' +maintainer_email 'guilhem@lettron.fr' +license 'Apache 2.0' +description 'Installs/Configures node.js & io.js' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +source_url 'https://github.com/redguide/nodejs' if respond_to?(:source_url) +issues_url 'https://github.com/redguide/nodejs/issues' if respond_to?(:issues_url) +chef_version '>= 11.0' if respond_to?(:chef_version) +version '3.0.0' + +depends 'yum-epel' +depends 'build-essential' +depends 'ark' +depends 'apt', '>= 2.9.1' +depends 'homebrew' + +%w(debian ubuntu centos redhat scientific oracle amazon smartos mac_os_x).each do |os| + supports os +end diff --git a/cookbooks/nodejs/providers/npm.rb b/cookbooks/nodejs/providers/npm.rb index 02742a8..f8a407d 100644 --- a/cookbooks/nodejs/providers/npm.rb +++ b/cookbooks/nodejs/providers/npm.rb @@ -1,6 +1,6 @@ include NodeJs::Helper -use_inline_resources if defined?(use_inline_resources) +use_inline_resources action :install do execute "install NPM package #{new_resource.name}" do diff --git a/cookbooks/nodejs/recipes/nodejs_from_binary.rb b/cookbooks/nodejs/recipes/nodejs_from_binary.rb index 3ae5c50..decc9db 100644 --- a/cookbooks/nodejs/recipes/nodejs_from_binary.rb +++ b/cookbooks/nodejs/recipes/nodejs_from_binary.rb @@ -20,24 +20,24 @@ Chef::Recipe.send(:include, NodeJs::Helper) node.force_override['nodejs']['install_method'] = 'binary' # ~FC019 -# Shamelessly borrowed from http://docs.opscode.com/dsl_recipe_method_platform.html +# Shamelessly borrowed from http://docs.chef.io/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 +arch = if node['kernel']['machine'] =~ /armv6l/ + 'arm-pi' # assume a raspberry pi + else + node['kernel']['machine'] =~ /x86_64/ ? 'x64' : 'x86' + end -# package_stub is for example: "node-v0.8.20-linux-x64.tar.gz" +# package_stub is for example: "node-v6.9.1-linux-x64.tar.xz" version = "v#{node['nodejs']['version']}/" prefix = node['nodejs']['prefix_url'][node['nodejs']['engine']] if node['nodejs']['engine'] == 'iojs' - filename = "iojs-v#{node['nodejs']['version']}-linux-#{arch}.tar.gz" + filename = "iojs-v#{node['nodejs']['version']}-linux-#{arch}.tar.xz" archive_name = 'iojs-binary' binaries = ['bin/iojs', 'bin/node'] else - filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.gz" + filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.xz" archive_name = 'nodejs-binary' binaries = ['bin/node'] end diff --git a/cookbooks/nodejs/recipes/nodejs_from_source.rb b/cookbooks/nodejs/recipes/nodejs_from_source.rb index e8eb94d..4c75120 100644 --- a/cookbooks/nodejs/recipes/nodejs_from_source.rb +++ b/cookbooks/nodejs/recipes/nodejs_from_source.rb @@ -27,18 +27,20 @@ include_recipe 'build-essential' case node['platform_family'] when 'rhel', 'fedora' package 'openssl-devel' + package 'xz' when 'debian' package 'libssl-dev' + package 'xz-utils' end version = "v#{node['nodejs']['version']}/" prefix = node['nodejs']['prefix_url'][node['nodejs']['engine']] if node['nodejs']['engine'] == 'iojs' - filename = "iojs-v#{node['nodejs']['version']}.tar.gz" + filename = "iojs-v#{node['nodejs']['version']}.tar.xz" archive_name = 'iojs-source' else - filename = "node-v#{node['nodejs']['version']}.tar.gz" + filename = "node-v#{node['nodejs']['version']}.tar.xz" archive_name = 'nodejs-source' end diff --git a/cookbooks/nodejs/recipes/repo.rb b/cookbooks/nodejs/recipes/repo.rb index 7d4bc3f..56a22c0 100644 --- a/cookbooks/nodejs/recipes/repo.rb +++ b/cookbooks/nodejs/recipes/repo.rb @@ -2,8 +2,6 @@ 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'] diff --git a/cookbooks/nodejs/resources/npm.rb b/cookbooks/nodejs/resources/npm.rb index 3d5e034..d7a5ecb 100644 --- a/cookbooks/nodejs/resources/npm.rb +++ b/cookbooks/nodejs/resources/npm.rb @@ -22,13 +22,13 @@ 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 :npm_token, :kind_of => String -attribute :options, :kind_of => Array, :default => [] +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 :npm_token, kind_of: String +attribute :options, kind_of: Array, default: [] -attribute :user, :kind_of => String -attribute :group, :kind_of => String +attribute :user, kind_of: String +attribute :group, kind_of: String diff --git a/site-cookbooks/kosmos-nodejs/recipes/default.rb b/site-cookbooks/kosmos-nodejs/recipes/default.rb index b0fed72..3630bd6 100644 --- a/site-cookbooks/kosmos-nodejs/recipes/default.rb +++ b/site-cookbooks/kosmos-nodejs/recipes/default.rb @@ -7,12 +7,6 @@ # All rights reserved - Do Not Redistribute # -include_recipe 'build-essential' -node.override['nodejs']['repo'] = 'https://deb.nodesource.com/node_5.x' -include_recipe 'nodejs::nodejs_from_package' - -# Update npm -nodejs_npm "npm" do - version "3.5.3" -end - +node.override['nodejs']['version'] = '6.9.4' +node.override['nodejs']['source']['checksum'] = 'c51d7c61db40455d57428abcadc7eb0f0a08a8878cb1d8ea3c1e211c54532c35' +include_recipe 'nodejs::nodejs_from_source'