Repository: redguide/nodejs
Branch: main
Commit: 283279b066fd
Files: 74
Total size: 87.4 KB
Directory structure:
gitextract_rwkb2jzg/
├── .editorconfig
├── .envrc
├── .gitattributes
├── .github/
│ ├── CODEOWNERS
│ ├── copilot-instructions.md
│ └── workflows/
│ ├── ci.yml
│ ├── conventional-commits.yml
│ ├── copilot-setup-steps.yml
│ ├── prevent-file-change.yml
│ ├── release.yml
│ └── stale.yml
├── .gitignore
├── .markdownlint-cli2.yaml
├── .mdlrc
├── .overcommit.yml
├── .release-please-manifest.json
├── .rubocop.yml
├── .vscode/
│ └── extensions.json
├── .yamllint
├── Berksfile
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Dangerfile
├── LICENSE
├── README.md
├── TESTING.md
├── attributes/
│ ├── default.rb
│ ├── npm.rb
│ ├── packages.rb
│ └── repo.rb
├── chefignore
├── documentation/
│ └── .gitkeep
├── kitchen.dokken.yml
├── kitchen.exec.yml
├── kitchen.global.yml
├── kitchen.yml
├── libraries/
│ └── nodejs_helper.rb
├── metadata.rb
├── recipes/
│ ├── default.rb
│ ├── install.rb
│ ├── iojs.rb
│ ├── nodejs.rb
│ ├── nodejs_from_binary.rb
│ ├── nodejs_from_chocolatey.rb
│ ├── nodejs_from_package.rb
│ ├── nodejs_from_source.rb
│ ├── npm.rb
│ ├── npm_from_source.rb
│ ├── npm_packages.rb
│ └── repo.rb
├── release-please-config.json
├── renovate.json
├── resources/
│ └── npm_package.rb
├── spec/
│ ├── rspec_helper.rb
│ ├── spec_helper.rb
│ └── unit/
│ ├── library/
│ │ └── helper_spec.rb
│ └── recipes/
│ └── default_spec.rb
└── test/
├── cookbooks/
│ └── test/
│ ├── metadata.rb
│ ├── recipes/
│ │ ├── chocolatey.rb
│ │ ├── default.rb
│ │ ├── package.rb
│ │ ├── resource.rb
│ │ ├── resource_win.rb
│ │ ├── source.rb
│ │ └── source_iojs.rb
│ └── templates/
│ └── package.json
└── integration/
├── chocolatey/
│ └── default.rb
├── default/
│ └── default_spec.rb
├── npm_embedded/
│ └── default_spec.rb
├── npm_source/
│ └── default_spec.rb
├── options/
│ └── default_spec.rb
├── package/
│ └── default.rb
└── source/
└── default.rb
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
# https://EditorConfig.org
# top-most EditorConfig file
root=true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 2 space indentation
indent_style = space
indent_size = 2
# Avoid issues parsing cookbook files later
charset = utf-8
# Avoid cookstyle warnings
trim_trailing_whitespace = true
================================================
FILE: .envrc
================================================
use chefworkstation
export KITCHEN_GLOBAL_YAML=kitchen.global.yml
================================================
FILE: .gitattributes
================================================
* text=auto eol=lf
================================================
FILE: .github/CODEOWNERS
================================================
* @sous-chefs/maintainers
================================================
FILE: .github/copilot-instructions.md
================================================
# Copilot Instructions for Sous Chefs Cookbooks
## Repository Overview
**Chef cookbook** for managing software installation and configuration. Part of the Sous Chefs cookbook ecosystem.
**Key Facts:** Ruby-based, Chef >= 16 required, supports various OS platforms (check metadata.rb, kitchen.yml and .github/workflows/ci.yml for which platforms to specifically test)
## Project Structure
**Critical Paths:**
- `recipes/` - Chef recipes for cookbook functionality (if this is a recipe-driven cookbook)
- `resources/` - Custom Chef resources with properties and actions (if this is a resource-driven cookbook)
- `spec/` - ChefSpec unit tests
- `test/integration/` - InSpec integration tests (tests all platforms supported)
- `test/cookbooks/` or `test/fixtures/` - Example cookbooks used during testing that show good examples of custom resource usage
- `attributes/` - Configuration for recipe driven cookbooks (not applicable to resource cookbooks)
- `libraries/` - Library helpers to assist with the cookbook. May contain multiple files depending on complexity of the cookbook.
- `templates/` - ERB templates that may be used in the cookbook
- `files/` - files that may be used in the cookbook
- `metadata.rb`, `Berksfile` - Cookbook metadata and dependencies
## Build and Test System
### Environment Setup
**MANDATORY:** Install Chef Workstation first - provides chef, berks, cookstyle, kitchen tools.
### Essential Commands (strict order)
```bash
berks install # Install dependencies (always first)
cookstyle # Ruby/Chef linting
yamllint . # YAML linting
markdownlint-cli2 '**/*.md' # Markdown linting
chef exec rspec # Unit tests (ChefSpec)
# Integration tests will be done via the ci.yml action. Do not run these. Only check the action logs for issues after CI is done running.
```
### Critical Testing Details
- **Kitchen Matrix:** Multiple OS platforms × software versions (check kitchen.yml for specific combinations)
- **Docker Required:** Integration tests use Dokken driver
- **CI Environment:** Set `CHEF_LICENSE=accept-no-persist`
- **Full CI Runtime:** 30+ minutes for complete matrix
### Common Issues and Solutions
- **Always run `berks install` first** - most failures are dependency-related
- **Docker must be running** for kitchen tests
- **Chef Workstation required** - no workarounds, no alternatives
- **Test data bags needed** (optional for some cookbooks) in `test/integration/data_bags/` for convergence
## Development Workflow
### Making Changes
1. Edit recipes/resources/attributes/templates/libraries
2. Update corresponding ChefSpec tests in `spec/`
3. Also update any InSpec tests under test/integration
4. Ensure cookstyle and rspec passes at least. You may run `cookstyle -a` to automatically fix issues if needed.
5. Also always update all documentation found in README.md and any files under documentation/*
6. **Always update CHANGELOG.md** (required by Dangerfile) - Make sure this conforms with the Sous Chefs changelog standards.
### Pull Request Requirements
- **PR description >10 chars** (Danger enforced)
- **CHANGELOG.md entry** for all code changes
- **Version labels** (major/minor/patch) required
- **All linters must pass** (cookstyle, yamllint, markdownlint)
- **Test updates** needed for code changes >5 lines and parameter changes that affect the code logic
## Chef Cookbook Patterns
### Resource Development
- Custom resources in `resources/` with properties and actions
- Include comprehensive ChefSpec tests for all actions
- Follow Chef resource DSL patterns
### Recipe Conventions
- Use `include_recipe` for modularity
- Handle platforms with `platform_family?` conditionals
- Use encrypted data bags for secrets (passwords, SSL certs)
- Leverage attributes for configuration with defaults
### Testing Approach
- **ChefSpec (Unit):** Mock dependencies, test recipe logic in `spec/`
- **InSpec (Integration):** Verify actual system state in `test/integration/inspec/` - InSpec files should contain proper inspec.yml and controls directories so that it could be used by other suites more easily.
- One test file per recipe, use standard Chef testing patterns
## Trust These Instructions
These instructions are validated for Sous Chefs cookbooks. **Do not search for build instructions** unless information here fails.
**Error Resolution Checklist:**
1. Verify Chef Workstation installation
2. Confirm `berks install` completed successfully
3. Ensure Docker is running for integration tests
4. Check for missing test data dependencies
The CI system uses these exact commands - following them matches CI behavior precisely.
================================================
FILE: .github/workflows/ci.yml
================================================
---
name: ci
"on":
pull_request:
push:
branches: [main]
jobs:
lint-unit:
uses: sous-chefs/.github/.github/workflows/lint-unit.yml@6.0.0
permissions:
actions: write
checks: write
pull-requests: write
statuses: write
issues: write
integration:
needs: lint-unit
runs-on: ubuntu-latest
strategy:
matrix:
os:
- "almalinux-9"
- "rockylinux-9"
- "amazonlinux-2023"
- "centos-stream-9"
- "centos-stream-10"
- "debian-11"
- "debian-12"
- "ubuntu-2204"
- "ubuntu-2404"
suite:
- "default"
- "npm-embedded"
- "package"
- "source"
exclude:
- os: "amazonlinux-2023"
suite: "source"
- os: "fedora-latest"
suite: "source"
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Install Chef
uses: actionshub/chef-install@6.0.0
- name: Dokken
uses: actionshub/test-kitchen@3.0.0
env:
CHEF_LICENSE: accept-no-persist
KITCHEN_LOCAL_YAML: kitchen.dokken.yml
with:
suite: ${{ matrix.suite }}
os: ${{ matrix.os }}
success:
if: ${{ always() }}
needs: ["integration"]
name: Integration Successful
runs-on: ubuntu-latest
steps:
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
name: Check matrix status
run: exit 1
================================================
FILE: .github/workflows/conventional-commits.yml
================================================
---
name: conventional-commits
"on":
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
conventional-commits:
uses: sous-chefs/.github/.github/workflows/conventional-commits.yml@6.0.0
================================================
FILE: .github/workflows/copilot-setup-steps.yml
================================================
---
name: 'Copilot Setup Steps'
"on":
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Install Chef
uses: actionshub/chef-install@main
- name: Install cookbooks
run: berks install
================================================
FILE: .github/workflows/prevent-file-change.yml
================================================
---
name: prevent-file-change
"on":
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
prevent-file-change:
uses: sous-chefs/.github/.github/workflows/prevent-file-change.yml@6.0.0
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/release.yml
================================================
---
name: release
"on":
push:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
packages: write
attestations: write
id-token: write
jobs:
release:
uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@6.0.0
secrets:
token: ${{ secrets.PORTER_GITHUB_TOKEN }}
supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }}
supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }}
================================================
FILE: .github/workflows/stale.yml
================================================
---
name: Mark stale issues and pull requests
"on":
schedule: [cron: "0 0 * * *"]
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
close-issue-message: >
Closing due to inactivity.
If this is still an issue please reopen or open another issue.
Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help!
Thanks, Sous-Chefs.
days-before-close: 7
days-before-stale: 365
stale-issue-message: >
Marking stale due to inactivity.
Remove stale label or comment or this will be closed in 7 days.
Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help!
Thanks, Sous-Chefs.
================================================
FILE: .gitignore
================================================
*.rbc
.config
InstalledFiles
pkg
test/tmp
test/version_tmp
tmp
_Store
*~
*#
.#*
\#*#
*.un~
*.tmp
*.bk
*.bkup
# editor files
.idea
.*.sw[a-z]
# ruby/bundler/rspec files
.ruby-version
.ruby-gemset
.rvmrc
Gemfile.lock
.bundle
*.gem
coverage
spec/reports
# YARD / rdoc artifacts
.yardoc
_yardoc
doc/
rdoc
# chef infra stuff
Berksfile.lock
.kitchen
kitchen.local.yml
vendor/
.coverage/
.zero-knife.rb
Policyfile.lock.json
# vagrant stuff
.vagrant/
.vagrant.d/
================================================
FILE: .markdownlint-cli2.yaml
================================================
config:
ul-indent: false # MD007
line-length: false # MD013
no-duplicate-heading: false # MD024
reference-links-images: false # MD052
no-multiple-blanks:
maximum: 2
ignores:
- .github/copilot-instructions.md
================================================
FILE: .mdlrc
================================================
rules "~MD013"
================================================
FILE: .overcommit.yml
================================================
---
PreCommit:
TrailingWhitespace:
enabled: true
YamlLint:
enabled: true
required_executable: "yamllint"
ChefSpec:
enabled: true
required_executable: "chef"
command: ["chef", "exec", "rspec"]
Cookstyle:
enabled: true
required_executable: "cookstyle"
command: ["cookstyle"]
MarkdownLint:
enabled: false
required_executable: "npx"
command: ["npx", "markdownlint-cli2", "'**/*.md'"]
include: ["**/*.md"]
CommitMsg:
HardTabs:
enabled: true
================================================
FILE: .release-please-manifest.json
================================================
{
".": "10.2.3"
}
================================================
FILE: .rubocop.yml
================================================
require:
- cookstyle
================================================
FILE: .vscode/extensions.json
================================================
{
"recommendations": [
"chef-software.chef",
"Shopify.ruby-lsp",
"editorconfig.editorconfig",
"DavidAnson.vscode-markdownlint"
]
}
================================================
FILE: .yamllint
================================================
---
extends: default
rules:
line-length:
max: 256
level: warning
document-start: disable
braces:
forbid: false
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
comments:
min-spaces-from-content: 1
================================================
FILE: Berksfile
================================================
source 'https://supermarket.chef.io'
metadata
group :integration do
cookbook 'test', path: './test/cookbooks/test'
end
================================================
FILE: CHANGELOG.md
================================================
# NodeJS Cookbook Changelog
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
## [10.2.3](https://github.com/sous-chefs/nodejs/compare/10.2.2...v10.2.3) (2025-10-15)
### Bug Fixes
* **ci:** Update workflows to use release pipeline ([#300](https://github.com/sous-chefs/nodejs/issues/300)) ([ef16e2c](https://github.com/sous-chefs/nodejs/commit/ef16e2ce7d32be9d50822926a8d09e30d4a54bad))
## 10.2.1 - *2025-06-08*
Standardise files with files in sous-chefs/repo-management
## 10.2.0 - *2024-11-20*
* Add support for new NodeSource repository (Thanks to @stissot)
* Rework source install packages
* Update SUSE packages
## 10.1.22 - *2024-11-19*
* Update default version to current LTS
## 10.1.21 - *2024-11-19*
* Update CI platforms
## 10.1.20 - *2024-11-18*
* Update test matrix check success of the integration stage
## 10.1.19 - *2024-11-18*
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
## 10.1.16 - *2024-05-03*
Standardise files with files in sous-chefs/repo-management
## 10.1.10 - *2023-04-07*
Standardise files with files in sous-chefs/repo-management
## 10.1.7 - *2023-04-01*
Standardise files with files in sous-chefs/repo-management
## 10.1.6 - *2023-03-20*
Standardise files with files in sous-chefs/repo-management
## 10.1.5 - *2023-03-15*
Standardise files with files in sous-chefs/repo-management
## 10.1.4 - *2023-02-20*
Standardise files with files in sous-chefs/repo-management
## 10.1.2 - *2023-02-14*
Standardise files with files in sous-chefs/repo-management
## 10.1.1 - *2022-12-08*
Standardise files with files in sous-chefs/repo-management
## 10.1.0 - *2022-08-08*
* To ensure consistent environment between `npm install` and `npm list`, pass same environment variables.
## 10.0.1 - *2022-08-07*
* Standardise files with files in sous-chefs/repo-management
* Default to using EL 9 repo for Fedora
* CI: Remove Fedora from source suite
## 10.0.0 - *2022-04-21*
* Update to NodeJS 17.x
* Remove delivery and move to calling RSpec directly via a reusable workflow
* Update tested platforms
* Disable upstream DNF module on EL8 based systems
## 9.0.2 - *2022-02-17*
* Standardise files with files in sous-chefs/repo-management
## 9.0.1 - *2022-02-08*
* Remove delivery folder
## 9.0.0 - *2021-09-13*
* Update the default version to 14 LTS
* Remove testing for EOL platforms
* Add Debian 11 testing
* Fix release version to use for Amazon Linux
## 8.0.0 - *2021-09-02*
* Update metadata and README to Sous Chef
* Enable unified_mode by default and require at least Chef Infra Client 15.3
* Cookstyle fixes
## 7.3.3 - *2021-08-30*
* Standardise files with files in sous-chefs/repo-management
## 7.3.2 - *2021-06-01*
* Standardise files with files in sous-chefs/repo-management
## 7.3.1 - *2020-12-31*
* resolved cookstyle error: attributes/packages.rb:15:55 convention: `Layout/TrailingEmptyLines`
* resolved cookstyle error: test/cookbooks/test/recipes/resource.rb:118:1 convention: `Layout/TrailingEmptyLines`
* Enable builds for opensuse-leap-15
* Add a library method test
## 7.3.0 (2020-10-21)
* Add rspec tests for the library methods
* Update the url_invalid? method to return false if it detects an invalid uri
* Add the auto_update option to the npm_package resource. Allows turning off auto_update of npm packages.
* Allow actions and options for OS package installation to be specified as attributes
* Add the live_stream parameter to the npm_package execution to get better installation diagnostics
* Add the auto_update option to the npm_package resource. Allows turning off auto_update of npm packages.
* Update testing
## 7.2.0 (2020-10-07)
* Verify the URI of installed packages to help determine if a good URI has been installed
* Add tests that verify npm-package installed packages
* Get the example test cookbook working
* Add support for installing node on windows
## 7.1.0 (2020-10-01)
* resolved cookstyle error: recipes/nodejs_from_binary.rb:19:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
* resolved cookstyle error: recipes/nodejs_from_source.rb:21:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
* resolved cookstyle error: recipes/npm_from_source.rb:21:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
* Have ark setup node and npm binaries into PATH
* Add `node_env` to `npm_package` in order to set `NODE_ENV` (useful for some packages)
* Include `npx` as a binary in addition to `npm`, it has been [included since `npm` v5.2.0](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b)
## 7.0.1 (2020-06-04)
* Minor readme fix
## 7.0.0 (2020-06-04)
* Require Chef Infra Client 14+ and remove the build-essential dependency
* Updated the default to Node.js v10.16.3
* Added compatibility with Chef Infra Client 16.2+
* Removed Foodcritic testing
* Updated ChefSpec and Kitchen platforms
* Resolved multiple minor cookstyle issues in the cookbook
* Added a vscode editor config
## 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
* 7.3.1 - *2020-12-31*
## 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
[@johannesbecker]: https://github.com/johannesbecker
[@julesau]: https://github.com/JulesAU
[@markbirbeck]: https://github.com/markbirbeck
[@robertkowalski]: https://github.com/robertkowalski
[@sax]: https://github.com/sax
[@smith]: https://github.com/smith
[@vaskas]: https://github.com/vaskas
[@wanelo-pair]: https://github.com/wanelo-pair
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Community Guidelines
This project follows the Chef Community Guidelines <https://docs.chef.io/community_guidelines.html>
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Please refer to
[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/CONTRIBUTING.MD)
================================================
FILE: Dangerfile
================================================
# Reference: http://danger.systems/reference.html
# A pull request summary is required. Add a description of the pull request purpose.
# Changelog must be updated for each pull request that changes code.
# Warnings will be issued for:
# Pull request with more than 400 lines of code changed
# Pull reqest that change more than 5 lines without test changes
# Failures will be issued for:
# Pull request without summary
# Pull requests with code changes without changelog entry
def code_changes?
code = %w(libraries attributes recipes resources files templates)
code.each do |location|
return true unless git.modified_files.grep(/#{location}/).empty?
end
false
end
def test_changes?
tests = %w(spec test kitchen.yml kitchen.dokken.yml)
tests.each do |location|
return true unless git.modified_files.grep(/#{location}/).empty?
end
false
end
failure 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10
warn 'This is a big Pull Request.' if git.lines_of_code > 400
warn 'This is a Table Flip.' if git.lines_of_code > 2000
# Require a CHANGELOG entry for non-test changes.
if !git.modified_files.include?('CHANGELOG.md') && code_changes?
failure 'Please include a CHANGELOG entry.'
end
# Require Major Minor Patch version labels
unless github.pr_labels.grep /minor|major|patch/i
warn 'Please add a release label to this pull request'
end
# A sanity check for tests.
if git.lines_of_code > 5 && code_changes? && !test_changes?
warn 'This Pull Request is probably missing tests.'
end
================================================
FILE: LICENSE
================================================
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.
================================================
FILE: README.md
================================================
# [nodejs-cookbook](https://github.com/redguide/nodejs)
[](https://supermarket.chef.io/cookbooks/nodejs)
[](https://github.com/sous-chefs/nodejs/actions?query=workflow%3Aci)
[](#backers)
[](#sponsors)
[](https://opensource.org/licenses/Apache-2.0)
Installs node.js/npm and includes a resource for managing npm packages
## Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).
## Requirements
### Platforms
- Debian/Ubuntu
- RHEL/CentOS/Scientific/Amazon/Oracle
- openSUSE
- Windows
Note: Source installs require GCC 4.8+, which is not included on older distro releases
### Chef
- Chef Infra Client 15.3+
### Cookbooks
- ark
## Usage
Include the nodejs recipe to install node on your system based on the default installation method:
```ruby
include_recipe "nodejs"
```
### Install methods
#### Package
Install node from packages:
```ruby
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:
```ruby
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:
```ruby
node['nodejs']['install_method'] = 'source'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_source"
```
#### Chocolatey
Install node from chocolatey:
```chef
node['nodejs']['install_method'] = 'chocolatey'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_chocolatey"
```
## 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']`
```ruby
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` lets 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 specify a `NODE_ENV` environment variable, in the case that some element of your installation depends on this by using `attribute :node_env`. E.g., using [`node-config`](https://www.npmjs.com/package/config) as part of your postinstall script. Please note that adding the `--production` option will override this to `NODE_ENV=production`.
You can append more specific options to npm command with `attribute :options` array :
You can specify auto_update as false to stop the npm install command from running and updating an installed package. Running the command will update packages within restrictions imposed by a package.json file. The default behavior is to update automatically.
- use an array of options (w/ dash), they will be added to npm call.
- ex: `['--production','--force']` or `['--force-latest']`
You can specify live_stream true for the resource to have the package install information included in the chef-client log outout for better npm package diagnostics and trouble shooting.
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'
node_env 'staging'
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"
}
]
}
```
## Contributors
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
### Backers
Thank you to all our backers!

### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.










================================================
FILE: TESTING.md
================================================
# Testing
Please refer to [the community cookbook documentation on testing](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/TESTING.MD).
================================================
FILE: attributes/default.rb
================================================
#
# 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.
#
default['nodejs']['install_method'] = case node['platform_family']
when 'smartos', 'rhel', 'debian', 'fedora', 'mac_os_x', 'suse', 'amazon'
'package'
when 'windows'
'chocolatey'
else
'source'
end
default['nodejs']['version'] = '22.11.0'
default['nodejs']['prefix_url']['node'] = 'https://nodejs.org/dist/'
default['nodejs']['tmpdir'] = '/tmp'
default['nodejs']['source']['url'] = nil # Auto generated
default['nodejs']['source']['checksum'] = '24e5130fa7bc1eaab218a0c9cb05e03168fa381bb9e3babddc6a11f655799222'
default['nodejs']['binary']['url'] = nil # Auto generated
default['nodejs']['binary']['checksum']['linux_x64'] = '8c9f4c95c254336fcb2c768e746f4316b8176adc0fb599cbbb460d0933991d12'
default['nodejs']['binary']['checksum']['linux_arm64'] = 'd4acf5c0380c96c867428d0232666d3327dc5fa83a694d7b63f728a76ece84b2'
default['nodejs']['binary']['append_env_path'] = true
default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
default['nodejs']['manage_node'] = true
================================================
FILE: attributes/npm.rb
================================================
default['nodejs']['npm']['install_method'] = 'embedded'
default['nodejs']['npm']['version'] = 'latest'
================================================
FILE: attributes/packages.rb
================================================
include_attribute 'nodejs::default'
include_attribute 'nodejs::repo'
default['nodejs']['packages'] = value_for_platform_family(
'debian' => node['nodejs']['install_repo'] ? ['nodejs'] : %w(nodejs npm nodejs-dev),
%w(rhel fedora amazon) => node['nodejs']['install_repo'] ? %w(nodejs nodejs-devel) : %w(nodejs npm nodejs-dev),
'suse' => %w(nodejs npm nodejs-devel),
'mac_os_x' => ['node'],
'freebsd' => %w(node npm),
'default' => ['nodejs']
)
# Add options and actions by package name
default['nodejs']['package_action'] = { default: :install }
default['nodejs']['package_options'] = { default: '' }
# Disable upstream DNF module on EL8 based systems
default['nodejs']['dnf_module'] = false
================================================
FILE: attributes/repo.rb
================================================
case node['platform_family']
when 'debian'
default['nodejs']['install_repo'] = true
default['nodejs']['repo'] = 'https://deb.nodesource.com/node_20.x'
default['nodejs']['distribution'] = 'nodistro'
default['nodejs']['key'] = 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key'
when 'rhel', 'amazon', 'fedora'
default['nodejs']['install_repo'] = true
node_version = platform?('amazon') ? '17.x' : '20.x'
default['nodejs']['repo'] = "https://rpm.nodesource.com/pub_#{node_version}/nodistro/nodejs/$basearch"
default['nodejs']['key'] = 'https://rpm.nodesource.com/gpgkey/ns-operations-public.key'
end
================================================
FILE: chefignore
================================================
# Put files/directories that should be ignored in this file when uploading
# to a Chef Infra Server or Supermarket.
# Lines that start with '# ' are comments.
# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon?
nohup.out
Thumbs.db
.envrc
# EDITORS #
###########
.#*
.project
.settings
*_flymake
*_flymake.*
*.bak
*.sw[a-z]
*.tmproj
*~
\#*
REVISION
TAGS*
tmtags
.vscode
.editorconfig
## COMPILED ##
##############
*.class
*.com
*.dll
*.exe
*.o
*.pyc
*.so
*/rdoc/
a.out
mkmf.log
# Testing #
###########
.circleci/*
.codeclimate.yml
.delivery/*
.foodcritic
.kitchen*
.mdlrc
.overcommit.yml
.rspec
.rubocop.yml
.travis.yml
.watchr
.yamllint
azure-pipelines.yml
Dangerfile
examples/*
features/*
Guardfile
kitchen*.yml
mlc_config.json
Procfile
Rakefile
spec/*
test/*
# SCM #
#######
.git
.gitattributes
.gitconfig
.github/*
.gitignore
.gitkeep
.gitmodules
.svn
*/.bzr/*
*/.git
*/.hg/*
*/.svn/*
# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp
# Bundler #
###########
vendor/*
Gemfile
Gemfile.lock
# Policyfile #
##############
Policyfile.rb
Policyfile.lock.json
# Documentation #
#############
CODE_OF_CONDUCT*
CONTRIBUTING*
documentation/*
TESTING*
UPGRADING*
# Vagrant #
###########
.vagrant
Vagrantfile
================================================
FILE: documentation/.gitkeep
================================================
================================================
FILE: kitchen.dokken.yml
================================================
driver:
name: dokken
privileged: true
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>
transport: { name: dokken }
provisioner: { name: dokken }
platforms:
- name: almalinux-8
driver:
image: dokken/almalinux-8
pid_one_command: /usr/lib/systemd/systemd
- name: almalinux-9
driver:
image: dokken/almalinux-9
pid_one_command: /usr/lib/systemd/systemd
- name: almalinux-10
driver:
image: dokken/almalinux-10
pid_one_command: /usr/lib/systemd/systemd
- name: amazonlinux-2023
driver:
image: dokken/amazonlinux-2023
pid_one_command: /usr/lib/systemd/systemd
- name: centos-stream-9
driver:
image: dokken/centos-stream-9
pid_one_command: /usr/lib/systemd/systemd
- name: centos-stream-10
driver:
image: dokken/centos-stream-10
pid_one_command: /usr/lib/systemd/systemd
- name: debian-12
driver:
image: dokken/debian-12
pid_one_command: /bin/systemd
- name: debian-13
driver:
image: dokken/debian-13
pid_one_command: /usr/lib/systemd/systemd
- name: fedora-latest
driver:
image: dokken/fedora-latest
pid_one_command: /usr/lib/systemd/systemd
- name: opensuse-leap-15
driver:
image: dokken/opensuse-leap-15
pid_one_command: /usr/lib/systemd/systemd
- name: oraclelinux-8
driver:
image: dokken/oraclelinux-8
pid_one_command: /usr/lib/systemd/systemd
- name: oraclelinux-9
driver:
image: dokken/oraclelinux-9
pid_one_command: /usr/lib/systemd/systemd
- name: rockylinux-8
driver:
image: dokken/rockylinux-8
pid_one_command: /usr/lib/systemd/systemd
- name: rockylinux-9
driver:
image: dokken/rockylinux-9
pid_one_command: /usr/lib/systemd/systemd
- name: rockylinux-10
driver:
image: dokken/rockylinux-10
pid_one_command: /usr/lib/systemd/systemd
- name: ubuntu-20.04
driver:
image: dokken/ubuntu-20.04
pid_one_command: /bin/systemd
- name: ubuntu-22.04
driver:
image: dokken/ubuntu-22.04
pid_one_command: /bin/systemd
- name: ubuntu-24.04
driver:
image: dokken/ubuntu-24.04
pid_one_command: /bin/systemd
================================================
FILE: kitchen.exec.yml
================================================
---
driver: { name: exec }
transport: { name: exec }
platforms:
- name: macos-latest
- name: windows-latest
================================================
FILE: kitchen.global.yml
================================================
---
provisioner:
name: chef_infra
product_name: chef
product_version: <%= ENV['CHEF_VERSION'] || 'latest' %>
channel: stable
install_strategy: once
chef_license: accept
enforce_idempotency: <%= ENV['ENFORCE_IDEMPOTENCY'] || true %>
multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %>
deprecations_as_errors: true
log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %>
verifier:
name: inspec
platforms:
- name: almalinux-8
- name: almalinux-9
- name: amazonlinux-2023
- name: centos-stream-9
- name: debian-11
- name: debian-12
- name: fedora-latest
- name: opensuse-leap-15
- name: oraclelinux-8
- name: oraclelinux-9
- name: rockylinux-8
- name: rockylinux-9
- name: ubuntu-20.04
- name: ubuntu-22.04
- name: ubuntu-24.04
================================================
FILE: kitchen.yml
================================================
---
driver:
name: vagrant
suites:
- name: default
run_list:
- recipe[nodejs::default]
attributes:
nodejs:
manage_node: true
npm:
install_method: embedded
npm_packages:
- name: express
- name: socket.io
version: 1.0.4
- name: express
action: :uninstall
- name: npm_embedded
run_list:
- recipe[nodejs::npm]
attributes:
nodejs:
npm:
install_method: embedded
- name: npm_source
run_list:
- recipe[nodejs::npm]
attributes:
nodejs:
npm:
install_method: source
- name: package
run_list:
- recipe[test::default]
- name: source
run_list:
- recipe[test::source]
- name: options
run_list:
- recipe[nodejs]
attributes:
nodejs:
packages:
- nodejs
- acpid
- adcli
package_options:
acpid: "--force-yes"
package_action:
adcli: :nothing
================================================
FILE: libraries/nodejs_helper.rb
================================================
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
begin
JSON.parse(cmd.run_command.stdout, max_nesting: false)
rescue JSON::ParserError => e
Chef::Log.error("nodejs::library::nodejs_helper::npm_list exception #{e}")
{}
end
end
def url_valid?(list, package)
require 'open-uri'
begin
URI.parse(list.fetch(package, {}).fetch('resolved'))
rescue KeyError
# the package may have been installed without using a url
true
rescue URI::InvalidURIError
false
end
end
def version_valid?(list, package, version)
(version ? list[package]['version'] == version : true)
end
def npm_package_installed?(package, version = nil, path = nil, environment = {})
list = npm_list(package, path, environment)['dependencies']
# Return true if package installed and installed to good version
# see if we really want to add the url check
!list.nil? && list.key?(package) && version_valid?(list, package, version) && url_valid?(list, package)
end
end
end
================================================
FILE: metadata.rb
================================================
name 'nodejs'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Installs/Configures node.js'
version '10.2.3'
source_url 'https://github.com/sous-chefs/nodejs'
issues_url 'https://github.com/sous-chefs/nodejs/issues'
chef_version '>= 15.3'
supports 'amazon'
supports 'centos'
supports 'debian'
supports 'mac_os_x'
supports 'opensuseleap'
supports 'oracle'
supports 'redhat'
supports 'scientific'
supports 'smartos'
supports 'suse'
supports 'ubuntu'
supports 'windows'
depends 'ark', '>= 2.0.2'
depends 'chocolatey', '>= 3.0'
depends 'yum', '>= 7.2'
================================================
FILE: recipes/default.rb
================================================
# 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']
================================================
FILE: recipes/install.rb
================================================
#
# 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']}"
================================================
FILE: recipes/iojs.rb
================================================
Chef::Log.fatal('The nodejs::iojs recipe has been deprecated. If you need iojs installation pin to cookbook version 3.0.1.')
================================================
FILE: recipes/nodejs.rb
================================================
#
# 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.')
================================================
FILE: recipes/nodejs_from_binary.rb
================================================
#
# 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::DSL::Recipe.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'
binaries.push('bin/npx') 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
append_env_path node['nodejs']['binary']['append_env_path']
action :install
end
================================================
FILE: recipes/nodejs_from_chocolatey.rb
================================================
#
# Author:: Hossein Margani (hossein@margani.dev)
# Cookbook:: nodejs
# Recipe:: install_from_chocolatey
#
# 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 'chocolatey'
chocolatey_package 'nodejs-lts' do
version node['nodejs']['version'] if node['nodejs']['version']
action :upgrade
end
================================================
FILE: recipes/nodejs_from_package.rb
================================================
#
# 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
if platform_family?('rhel', 'fedora') && node['platform_version'].to_i >= 8 && !node['nodejs']['dnf_module']
dnf_module 'nodejs' do
action :disable
only_if 'dnf module list nodejs'
end
end
node['nodejs']['packages'].each do |node_pkg|
package node_pkg do
action node['nodejs']['package_action'][node_pkg] if node['nodejs']['package_action'][node_pkg]
options node['nodejs']['package_options'][node_pkg] if node['nodejs']['package_options'][node_pkg]
end
end
================================================
FILE: recipes/nodejs_from_source.rb
================================================
#
# 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::DSL::Recipe.include NodeJs::Helper
build_essential 'install build tools'
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
package %w(openssl-devel python3 tar)
when 'debian'
package %w(libssl-dev python3)
else
package %w(python3)
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
environment(PYTHON: 'python3')
end
================================================
FILE: recipes/npm.rb
================================================
#
# 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
================================================
FILE: recipes/npm_from_source.rb
================================================
#
# 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::DSL::Recipe.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
================================================
FILE: recipes/npm_packages.rb
================================================
if node['nodejs'].key?('npm_packages')
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
end
================================================
FILE: recipes/repo.rb
================================================
case node['platform_family']
when 'debian'
# Install necessary packages for downloading and verifying new repository information
package %w(ca-certificates curl gnupg apt-transport-https)
# Create a directory for the new repository's keyring, if it doesn't exist
directory '/etc/apt/keyrings'
# Download the new repository's GPG key and save it in the keyring directory
execute 'add nodejs gpg key' do
command "curl -fsSL #{node['nodejs']['key']} | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg"
not_if { ::File.exist? '/etc/apt/keyrings/nodesource.gpg' }
end
# Prefer nodesource over Ubuntu universe packages by giving a higher priority (default 500)
apt_preference 'nodesource' do
glob '*'
pin 'origin deb.nodesource.com'
pin_priority '600'
end
if Gem::Version.new('18.3.0') <= Chef::VERSION
apt_repository 'nodesource' do
uri node['nodejs']['repo']
components ['main']
options ['signed-by=/etc/apt/keyrings/nodesource.gpg']
distribution node['nodejs']['distribution']
end
else
# Chef Infra < 18.3 doesn't support options attribute, fallback to (deprecated) apt-key method
apt_repository 'nodesource' do
uri node['nodejs']['repo']
components ['main']
key '2F59B5F99B1BE0B4'
keyserver 'keyserver.ubuntu.com'
distribution node['nodejs']['distribution']
end
end
when 'rhel', 'fedora', 'amazon'
yum_repository 'nodesource-nodejs' do
description 'nodesource.com nodejs repository'
baseurl node['nodejs']['repo']
gpgkey node['nodejs']['key']
priority '9'
options(module_hotfixes: 1)
end
end
================================================
FILE: release-please-config.json
================================================
{
"packages": {
".": {
"package-name": "nodejs",
"changelog-path": "CHANGELOG.md",
"release-type": "ruby",
"include-component-in-tag": false,
"version-file": "metadata.rb"
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
================================================
FILE: renovate.json
================================================
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"packageRules": [
{
"groupName": "Actions",
"matchUpdateTypes": ["minor", "patch", "pin"],
"automerge": true,
"addLabels": ["Release: Patch", "Skip: Announcements"]
},
{
"groupName": "Actions",
"matchUpdateTypes": ["major"],
"automerge": false,
"addLabels": ["Release: Patch", "Skip: Announcements"]
}
]
}
================================================
FILE: resources/npm_package.rb
================================================
#
# 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
provides :npm_package
unified_mode true
# backwards compatibility for the old resource name
provides :nodejs_npm
property :package, String, name_property: true
property :version, String
property :path, String
property :url, String
property :json, [String, true, false]
property :npm_token, String
property :options, Array, default: []
property :user, String
property :group, String
property :live_stream, [false, true], default: false
property :node_env, String
property :auto_update, [true, false], default: true
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
live_stream new_resource.live_stream
not_if { package_installed? && no_auto_update? }
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
live_stream new_resource.live_stream
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['NODE_ENV'] = new_resource.node_env if new_resource.node_env
env_vars
end
def package_installed?
new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, npm_env_vars)
end
def no_auto_update?
new_resource.package && !new_resource.auto_update
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
================================================
FILE: spec/rspec_helper.rb
================================================
Dir.glob('libraries/*.rb').each do |lib|
require_relative "../#{lib}"
end
RSpec.configure do |config|
config.expose_dsl_globally = true
config.mock_with :rspec do |mocks|
mocks.allow_message_expectations_on_nil = true
end
end
================================================
FILE: spec/spec_helper.rb
================================================
require 'chefspec'
require 'chefspec/berkshelf'
RSpec.configure do |config|
config.color = true # Use color in STDOUT
config.formatter = :documentation # Use the specified formatter
config.log_level = :error # Avoid deprecation notice SPAM
end
================================================
FILE: spec/unit/library/helper_spec.rb
================================================
require 'rspec_helper'
require 'mixlib/shellout'
require 'ostruct'
describe 'helper methods' do
before(:each) do
@mt = MT.new
end
describe 'npm_dist' do
it 'should return a url if specified in the node attributes' do
n = { 'nodejs': { 'npm': { 'url': 'get it' } } }
n = Mash.new(n)
allow(@mt).to receive(:node).and_return(n)
expect(@mt.npm_dist['url']).to eq('get it')
end
it 'should return a url based on the version' do
n = { 'nodejs': { 'npm': { 'url': nil, 'version': '6.14.8' } } }
n = Mash.new(n)
allow(@mt).to receive(:node).and_return(n)
expect(@mt.npm_dist['url']).to eq('https://registry.npmjs.org/npm/-/npm-6.14.8.tgz')
end
end
describe 'npm_list' do
it 'should list information for a package' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
expect(@mt.npm_list('xss')).to eq({ 'dependencies' => { 'xss' => { 'from' => 'xss', 'resolved' => 'https://registry.npmjs.org/xss/-/xss-1.0.8.tgz', 'version' => '1.0.8' } } })
end
it 'should handle bad output fomr the npm list command' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npminvalid)
expect(@mt.npm_list('other')).to eq({})
end
end
describe 'url_valid?' do
it 'should return true the url of an installed package for a valid value' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
list = @mt.npm_list('xss')['dependencies']
expect(@mt.url_valid?(list, 'xss')).to be_truthy
end
it 'should return true an installed package that does not have a url' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmcssfilter)
list = @mt.npm_list('cssfilter')['dependencies']
expect(@mt.url_valid?(list, 'cssfilter')).to eq(true)
end
it 'should return false for an installed package that has an invalid url' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmglobal)
list = @mt.npm_list('security')['dependencies']
expect(@mt.url_valid?(list, 'security')).to eq(false)
end
end
describe 'version_valid?' do
it 'should check that the installed version of a package matches the expected' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
list = @mt.npm_list('xss')['dependencies']
expect(@mt.version_valid?(list, 'xss', '1.0.8')).to be_truthy
end
it 'should return false if the version a package does not match the expected' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
list = @mt.npm_list('xss')['dependencies']
expect(@mt.version_valid?(list, 'xss', '1.1.1')).to be_falsy
end
end
describe 'npm_package_installed?' do
it 'should return false if any of the checks fail - wrong version' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
expect(@mt.npm_package_installed?('xss', '1.1.1')).to be_falsy
end
it 'should return false if any of the checks fail - nothing found' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmempty)
expect(@mt.npm_package_installed?('xss')).to be_falsy
end
it 'should return true checking package and version' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
expect(@mt.npm_package_installed?('xss', '1.0.8')).to be_truthy
end
it 'should return true checking package installed' do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(npmxss)
expect(@mt.npm_package_installed?('xss')).to be_truthy
end
end
end
class MT
include NodeJs::Helper
end
def npmempty
os = OpenStruct.new
os.stdout =
'{}'
os
end
def npmglobal
os = OpenStruct.new
os.stdout =
'{
"dependencies": {
"dtrace": {
"version": "0.0.0",
"from": "dtrace",
"resolved": "https://registry.npmjs.org/dtrace/-/dtrace-0.0.0.tgz"
},
"dtrace-provider": {
"version": "0.8.8",
"from": "dtrace-provider",
"resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.8.tgz",
"dependencies": {
"nan": {
"version": "2.14.1",
"from": "nan@^2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz"
}
}
},
"sax": {
"version": "1.2.4",
"from": "sax",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz"
},
"security": {
"version": "1.0.0",
"from": "security",
"resolved": "http://invalid##registry.npmjs.org/security/-/security-1.0.0.tgz"
},
"xss": {
"version": "1.0.8",
"from": "xss",
"resolved": "https://registry.npmjs.org/xss/-/xss-1.0.8.tgz",
"dependencies": {
"commander": {
"version": "2.20.3",
"from": "commander@^2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
},
"cssfilter": {
"version": "0.0.10",
"from": "cssfilter@0.0.10"
}
}
}
}
}'
os
end
def npminvalid
os = OpenStruct.new
os.stdout =
'Invalid return'
os
end
def npmxss
os = OpenStruct.new
os.stdout =
'{
"dependencies": {
"xss": {
"version": "1.0.8",
"from": "xss",
"resolved": "https://registry.npmjs.org/xss/-/xss-1.0.8.tgz"
}
}
}'
os
end
def npmcssfilter
os = OpenStruct.new
os.stdout =
'{
"dependencies": {
"xss": {
"version": "1.0.8",
"from": "xss",
"resolved": "https://registry.npmjs.org/xss/-/xss-1.0.8.tgz",
"dependencies": {
"cssfilter": {
"version": "0.0.10",
"from": "cssfilter@0.0.10",
"resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz"
}
}
}
}
}'
os
end
================================================
FILE: spec/unit/recipes/default_spec.rb
================================================
require 'spec_helper'
describe 'default recipe on ubuntu 22.04' do
let(:runner) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '22.04') }
let(:chef_run) { runner.converge('nodejs::default') }
it 'includes the package install recipes' do
expect(chef_run).to include_recipe('nodejs::nodejs_from_package')
expect(chef_run).to include_recipe('nodejs::npm_packages')
end
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
end
end
describe 'default recipe on centos 8' do
let(:runner) { ChefSpec::ServerRunner.new(platform: 'centos', version: '8') }
let(:chef_run) { runner.converge('nodejs::default') }
it 'includes the package install recipes' do
stub_command('dnf module list nodejs').and_return(0)
expect(chef_run).to include_recipe('nodejs::nodejs_from_package')
expect(chef_run).to include_recipe('nodejs::npm_packages')
end
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
end
end
describe 'default recipe on debian 12' do
let(:runner) { ChefSpec::ServerRunner.new(platform: 'debian', version: '12') }
let(:chef_run) { runner.converge('nodejs::default') }
it 'includes the package install recipes' do
expect(chef_run).to include_recipe('nodejs::nodejs_from_package')
expect(chef_run).to include_recipe('nodejs::npm_packages')
end
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
end
end
describe 'default recipe on mac_os_x' do
let(:runner) { ChefSpec::ServerRunner.new(platform: 'mac_os_x') }
let(:chef_run) { runner.converge('nodejs::default') }
it 'includes the package install recipes' do
expect(chef_run).to include_recipe('nodejs::nodejs_from_package')
expect(chef_run).to include_recipe('nodejs::npm_packages')
end
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
end
end
describe 'default recipe on fedora' do
let(:runner) { ChefSpec::ServerRunner.new(platform: 'fedora') }
let(:chef_run) do
stub_command('dnf module list nodejs').and_return(0)
runner.converge('nodejs::default')
end
it 'includes the package install recipes' do
expect(chef_run).to include_recipe('nodejs::nodejs_from_package')
expect(chef_run).to include_recipe('nodejs::npm_packages')
end
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
end
end
================================================
FILE: test/cookbooks/test/metadata.rb
================================================
name 'test'
version '0.1.0'
depends 'git'
depends 'nodejs'
================================================
FILE: test/cookbooks/test/recipes/chocolatey.rb
================================================
node.default['nodejs']['install_method'] = 'chocolatey'
include_recipe 'nodejs::default'
include_recipe 'test::resource_win'
================================================
FILE: test/cookbooks/test/recipes/default.rb
================================================
apt_update 'update'
include_recipe 'nodejs::default'
include_recipe 'test::resource'
================================================
FILE: test/cookbooks/test/recipes/package.rb
================================================
apt_update 'update'
node.default['nodejs']['install_method'] = 'package'
include_recipe 'nodejs::default'
================================================
FILE: test/cookbooks/test/recipes/resource.rb
================================================
apt_update 'update'
include_recipe 'nodejs::npm'
include_recipe 'git'
user 'random' do
manage_home true
home '/home/random'
end
user 'random1' do
manage_home true
home '/home/random1'
end
user 'random2' do
manage_home true
home '/home/random2'
end
# global "express" using the old resource name
nodejs_npm 'express'
npm_package 'async' do
version '0.6.2'
end
npm_package 'xss' do
version '1.0.7'
end
npm_package 'xss noupgrade' do
package 'xss'
auto_update false
end
npm_package 'minify' do
version '5.2.0'
end
npm_package 'minify upgrade' do
package 'minify'
live_stream true
end
npm_package 'request' do
url 'github mikeal/request'
live_stream true
end
npm_package 'mocha' do
options ['--force', '--production']
end
git '/home/random2/grunt' do
repository 'https://github.com/gruntjs/grunt'
user 'random2'
end
directory '/home/random2/.npm' do
owner 'random2'
end
npm_package 'Install the grunt package' do
path '/home/random2'
package 'grunt'
json '/home/random2/grunt'
user 'random2'
end
npm_package 'Install the vary package from a tgz url' do
path '/home/random2'
package 'vary'
json 'https://registry.npmjs.org/vary/-/vary-1.1.2.tgz'
user 'random2'
end
directory '/home/random/.npm' do
owner 'random'
end
# Create a package.json file for the test user
template '/home/random/package.json' do
source 'package.json'
owner 'random'
user 'random'
end
# Create an .npmrc file for the test user
file '/home/random/.npmrc' do
content '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'
owner 'random'
user 'random'
end
# Test npm_token usage (for NPM private repositories)
npm_package 'from_package_json' do
path '/home/random'
json true
user 'random'
npm_token '123-abcde'
node_env 'staging' # Test node_env usage
end
directory '/home/random1/.npm' do
owner 'random1'
end
# Create an .npmrc file for the test user
file '/home/random1/.npmrc' do
content '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'
owner 'random1'
user 'random1'
end
# Create a package.json file for the test user
template '/home/random1/package.json' do
source 'package.json'
owner 'random1'
user 'random1'
end
# Test npm_token usage (for NPM private repositories)
npm_package 'from_package_json_private' do
path '/home/random1'
json true
npm_token '123-abcde'
options ['--development']
node_env 'development'
end
================================================
FILE: test/cookbooks/test/recipes/resource_win.rb
================================================
include_recipe 'nodejs::npm'
include_recipe 'git'
user 'random' do
manage_home true
home '/home/random'
end
user 'random1' do
manage_home true
home '/home/random1'
end
user 'random2' do
manage_home true
home '/home/random2'
end
# global "express" using the old resource name
nodejs_npm 'express'
npm_package 'async' do
version '0.6.2'
end
npm_package 'mocha' do
options ['--force', '--production']
end
================================================
FILE: test/cookbooks/test/recipes/source.rb
================================================
apt_update 'update'
# Source install puts the npm symlink in /usr/local/bin
ENV['PATH'] = '/usr/local/bin:' + ENV['PATH']
node.default['nodejs']['install_method'] = 'source'
include_recipe 'nodejs::default'
include_recipe 'test::resource'
================================================
FILE: test/cookbooks/test/recipes/source_iojs.rb
================================================
apt_update 'update'
node.default['nodejs']['engine'] = 'iojs'
node.default['nodejs']['install_method'] = 'source'
node.default['nodejs']['source']['checksum'] = '55e79cc4f4cde41f03c1e204d2af5ee4b6e4edcf14defc82e518436e939195fa'
node.default['nodejs']['version'] = '2.2.1'
include_recipe 'nodejs::default'
================================================
FILE: test/cookbooks/test/templates/package.json
================================================
{
"name": "random-test",
"version": "0.1.0",
"description": "Just some random test",
"license": "MIT",
"author": {
"name": "Random"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"config": "^3.3.7",
"koa": "^2.13.4"
},
"devDependencies": {
"gulp": "^4.0.2"
},
"scripts": {
"postinstall": "touch $NODE_ENV"
}
}
================================================
FILE: test/integration/chocolatey/default.rb
================================================
control 'commands should exist' do
describe command('node -v') do
its('exit_status') { should eq 0 }
end
describe command('npm -v') do
its('exit_status') { should eq 0 }
end
describe command('npm list -json -global') do
its('stdout') { should match(/express/) }
its('stdout') { should match(/async@0.6.2/) }
its('stdout') { should match(/request/) }
its('stdout') { should match(/mocha/) }
end
end
================================================
FILE: test/integration/default/default_spec.rb
================================================
os_family = os.family
control 'commands should exist' do
describe command('node -v') do
its('exit_status') { should eq 0 }
# No upstream repository so it installs the OS version
unless os_family == 'suse'
its('stdout') { should match /^v17\.*/ }
end
end
describe command('npm -v') do
its('exit_status') { should eq 0 }
# No upstream repository so it installs the OS version
unless os_family == 'suse'
its('stdout') { should match /^8\.*/ }
end
end
describe command('npx -v') do
its('exit_status') { should eq 0 }
# No upstream repository so it installs the OS version
unless os_family == 'suse'
its('stdout') { should match /^8\.*/ }
end
end
describe command('npm list -json -global') do
its('stdout') { should_not match(/"express"/) }
its('stdout') { should match(/"socket.io"/) }
end
end
================================================
FILE: test/integration/npm_embedded/default_spec.rb
================================================
control 'commands should exist' do
describe command('node -v') do
its('exit_status') { should eq 0 }
end
describe command('npm -v') do
its('exit_status') { should eq 0 }
end
describe command('npx -v') do
its('exit_status') { should eq 0 }
end
end
================================================
FILE: test/integration/npm_source/default_spec.rb
================================================
control 'commands should exist' do
describe command('node -v') do
its('exit_status') { should eq 0 }
end
describe command('npm -v') do
its('exit_status') { should eq 0 }
end
describe command('npx -v') do
its('exit_status') { should eq 0 }
end
describe file('/usr/local/bin/npm') do
it { should exist }
end
describe file('/usr/local/bin/npx') do
it { should exist }
end
end
================================================
FILE: test/integration/options/default_spec.rb
================================================
control 'packages should install' do
describe package('nodejs') do
it { should be_installed }
end
describe package('acpid') do
it { should be_installed }
end
describe package('adcli') do
it { should_not be_installed }
end
end
================================================
FILE: test/integration/package/default.rb
================================================
control 'commands should exist' do
describe command('node -v') do
its('exit_status') { should eq 0 }
end
describe command('npm -v') do
its('exit_status') { should eq 0 }
end
describe file '/home/random/staging' do
it { should exist }
end
describe command('npm list -json -global') do
its('stdout') { should match(/express/) }
its('stdout') { should match(/"async": {\n\s*"version": "0.6.2"/) }
its('stdout') { should match(/request/) }
its('stdout') { should match(/mocha/) }
end
describe command('npm list xss -json -global') do
its('stdout') { should match(/"version":\s*"1.0.7"/) }
end
describe command('npm list minify -json -global') do
its('stdout') { should_not match(/"version":\s*"5.2.0"/) }
end
describe command('export NPM_TOKEN="123-abcde" && cd /home/random && npm list -json') do
its('stdout') { should match(/koa/) }
its('stdout') { should match(/gulp/) }
end
describe command('export NPM_TOKEN="123-abcde" && cd /home/random1 && npm list -json') do
its('stdout') { should match(/koa/) }
its('stdout') { should match(/gulp/) }
end
describe command('export NPM_TOKEN="123-abcde" && cd /home/random2 && npm list -json') do
its('stdout') { should match(/grunt/) }
its('stdout') { should match(/vary/) }
end
end
================================================
FILE: test/integration/source/default.rb
================================================
control 'commands should exist' do
describe command('node -v') do
its('exit_status') { should eq 0 }
end
describe command('npm -v') do
its('exit_status') { should eq 0 }
end
describe file '/home/random/staging' do
it { should exist }
end
describe command('npx -v') do
its('exit_status') { should eq 0 }
end
describe file('/usr/local/bin/npm') do
it { should exist }
end
describe file('/usr/local/bin/npx') do
it { should exist }
end
end
gitextract_rwkb2jzg/
├── .editorconfig
├── .envrc
├── .gitattributes
├── .github/
│ ├── CODEOWNERS
│ ├── copilot-instructions.md
│ └── workflows/
│ ├── ci.yml
│ ├── conventional-commits.yml
│ ├── copilot-setup-steps.yml
│ ├── prevent-file-change.yml
│ ├── release.yml
│ └── stale.yml
├── .gitignore
├── .markdownlint-cli2.yaml
├── .mdlrc
├── .overcommit.yml
├── .release-please-manifest.json
├── .rubocop.yml
├── .vscode/
│ └── extensions.json
├── .yamllint
├── Berksfile
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Dangerfile
├── LICENSE
├── README.md
├── TESTING.md
├── attributes/
│ ├── default.rb
│ ├── npm.rb
│ ├── packages.rb
│ └── repo.rb
├── chefignore
├── documentation/
│ └── .gitkeep
├── kitchen.dokken.yml
├── kitchen.exec.yml
├── kitchen.global.yml
├── kitchen.yml
├── libraries/
│ └── nodejs_helper.rb
├── metadata.rb
├── recipes/
│ ├── default.rb
│ ├── install.rb
│ ├── iojs.rb
│ ├── nodejs.rb
│ ├── nodejs_from_binary.rb
│ ├── nodejs_from_chocolatey.rb
│ ├── nodejs_from_package.rb
│ ├── nodejs_from_source.rb
│ ├── npm.rb
│ ├── npm_from_source.rb
│ ├── npm_packages.rb
│ └── repo.rb
├── release-please-config.json
├── renovate.json
├── resources/
│ └── npm_package.rb
├── spec/
│ ├── rspec_helper.rb
│ ├── spec_helper.rb
│ └── unit/
│ ├── library/
│ │ └── helper_spec.rb
│ └── recipes/
│ └── default_spec.rb
└── test/
├── cookbooks/
│ └── test/
│ ├── metadata.rb
│ ├── recipes/
│ │ ├── chocolatey.rb
│ │ ├── default.rb
│ │ ├── package.rb
│ │ ├── resource.rb
│ │ ├── resource_win.rb
│ │ ├── source.rb
│ │ └── source_iojs.rb
│ └── templates/
│ └── package.json
└── integration/
├── chocolatey/
│ └── default.rb
├── default/
│ └── default_spec.rb
├── npm_embedded/
│ └── default_spec.rb
├── npm_source/
│ └── default_spec.rb
├── options/
│ └── default_spec.rb
├── package/
│ └── default.rb
└── source/
└── default.rb
SYMBOL INDEX (19 symbols across 3 files)
FILE: libraries/nodejs_helper.rb
type NodeJs (line 1) | module NodeJs
type Helper (line 2) | module Helper
function npm_dist (line 3) | def npm_dist
function npm_list (line 17) | def npm_list(package, path = nil, environment = {})
function url_valid? (line 33) | def url_valid?(list, package)
function version_valid? (line 46) | def version_valid?(list, package, version)
function npm_package_installed? (line 50) | def npm_package_installed?(package, version = nil, path = nil, envir...
FILE: resources/npm_package.rb
function initialize (line 42) | def initialize(*args)
function npm_env_vars (line 74) | def npm_env_vars
function package_installed? (line 84) | def package_installed?
function no_auto_update? (line 88) | def no_auto_update?
function npm_options (line 92) | def npm_options
function npm_package (line 101) | def npm_package
FILE: spec/unit/library/helper_spec.rb
class MT (line 88) | class MT
function npmempty (line 92) | def npmempty
function npmglobal (line 99) | def npmglobal
function npminvalid (line 152) | def npminvalid
function npmxss (line 159) | def npmxss
function npmcssfilter (line 174) | def npmcssfilter
Condensed preview — 74 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (97K chars).
[
{
"path": ".editorconfig",
"chars": 353,
"preview": "# https://EditorConfig.org\n\n# top-most EditorConfig file\nroot=true\n\n# Unix-style newlines with a newline ending every fi"
},
{
"path": ".envrc",
"chars": 66,
"preview": "use chefworkstation\nexport KITCHEN_GLOBAL_YAML=kitchen.global.yml\n"
},
{
"path": ".gitattributes",
"chars": 19,
"preview": "* text=auto eol=lf\n"
},
{
"path": ".github/CODEOWNERS",
"chars": 26,
"preview": "* @sous-chefs/maintainers\n"
},
{
"path": ".github/copilot-instructions.md",
"chars": 4677,
"preview": "# Copilot Instructions for Sous Chefs Cookbooks\n\n## Repository Overview\n\n**Chef cookbook** for managing software install"
},
{
"path": ".github/workflows/ci.yml",
"chars": 1579,
"preview": "---\nname: ci\n\n\"on\":\n pull_request:\n push:\n branches: [main]\n\njobs:\n lint-unit:\n uses: sous-chefs/.github/.githu"
},
{
"path": ".github/workflows/conventional-commits.yml",
"chars": 241,
"preview": "---\nname: conventional-commits\n\n\"on\":\n pull_request:\n types:\n - opened\n - reopened\n - edited\n - "
},
{
"path": ".github/workflows/copilot-setup-steps.yml",
"chars": 504,
"preview": "---\nname: 'Copilot Setup Steps'\n\n\"on\":\n workflow_dispatch:\n push:\n paths:\n - .github/workflows/copilot-setup-s"
},
{
"path": ".github/workflows/prevent-file-change.yml",
"chars": 292,
"preview": "---\nname: prevent-file-change\n\n\"on\":\n pull_request:\n types:\n - opened\n - reopened\n - edited\n - s"
},
{
"path": ".github/workflows/release.yml",
"chars": 462,
"preview": "---\nname: release\n\n\"on\":\n push:\n branches:\n - main\n\npermissions:\n contents: write\n issues: write\n pull-reque"
},
{
"path": ".github/workflows/stale.yml",
"chars": 962,
"preview": "---\nname: Mark stale issues and pull requests\n\n\"on\":\n schedule: [cron: \"0 0 * * *\"]\n\njobs:\n stale:\n runs-on: ubuntu"
},
{
"path": ".gitignore",
"chars": 460,
"preview": "*.rbc\n.config\nInstalledFiles\npkg\ntest/tmp\ntest/version_tmp\ntmp\n_Store\n*~\n*#\n.#*\n\\#*#\n*.un~\n*.tmp\n*.bk\n*.bkup\n\n# editor f"
},
{
"path": ".markdownlint-cli2.yaml",
"chars": 224,
"preview": "config:\n ul-indent: false # MD007\n line-length: false # MD013\n no-duplicate-heading: false # MD024\n reference-links-"
},
{
"path": ".mdlrc",
"chars": 15,
"preview": "rules \"~MD013\"\n"
},
{
"path": ".overcommit.yml",
"chars": 505,
"preview": "---\nPreCommit:\n TrailingWhitespace:\n enabled: true\n YamlLint:\n enabled: true\n required_executable: \"yamllint\""
},
{
"path": ".release-please-manifest.json",
"chars": 20,
"preview": "{\n \".\": \"10.2.3\"\n}\n"
},
{
"path": ".rubocop.yml",
"chars": 23,
"preview": "require:\n - cookstyle\n"
},
{
"path": ".vscode/extensions.json",
"chars": 151,
"preview": "{\n \"recommendations\": [\n \"chef-software.chef\",\n \"Shopify.ruby-lsp\",\n \"editorconfig.editorconfig\",\n \"DavidAn"
},
{
"path": ".yamllint",
"chars": 286,
"preview": "---\nextends: default\nrules:\n line-length:\n max: 256\n level: warning\n document-start: disable\n braces:\n forbi"
},
{
"path": "Berksfile",
"chars": 123,
"preview": "source 'https://supermarket.chef.io'\n\nmetadata\n\ngroup :integration do\n cookbook 'test', path: './test/cookbooks/test'\ne"
},
{
"path": "CHANGELOG.md",
"chars": 11560,
"preview": "# NodeJS Cookbook Changelog\n\nStandardise files with files in sous-chefs/repo-management\nStandardise files with files in "
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 124,
"preview": "# Community Guidelines\n\nThis project follows the Chef Community Guidelines <https://docs.chef.io/community_guidelines.ht"
},
{
"path": "CONTRIBUTING.md",
"chars": 221,
"preview": "# Contributing\n\nPlease refer to\n[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/main/CONTRIBUTI"
},
{
"path": "Dangerfile",
"chars": 1554,
"preview": "# Reference: http://danger.systems/reference.html\n\n# A pull request summary is required. Add a description of the pull r"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 8268,
"preview": "# [nodejs-cookbook](https://github.com/redguide/nodejs)\n\n[\n# Cookbook:: nodejs\n# Recipe:: default\n#\n# Copyright:: 2010-2017, Prome"
},
{
"path": "recipes/install.rb",
"chars": 755,
"preview": "#\n# Author:: Marius Ducea (marius@promethost.com)\n# Cookbook:: nodejs\n# Recipe:: install\n#\n# Copyright:: 2010-2017, Prom"
},
{
"path": "recipes/iojs.rb",
"chars": 125,
"preview": "Chef::Log.fatal('The nodejs::iojs recipe has been deprecated. If you need iojs installation pin to cookbook version 3.0."
},
{
"path": "recipes/nodejs.rb",
"chars": 792,
"preview": "#\n# Author:: Marius Ducea (marius@promethost.com)\n# Cookbook:: nodejs\n# Recipe:: nodejs\n#\n# Copyright:: 2010-2017, Prome"
},
{
"path": "recipes/nodejs_from_binary.rb",
"chars": 2444,
"preview": "#\n# Author:: Julian Wilde (jules@jules.com.au)\n# Cookbook:: nodejs\n# Recipe:: install_from_binary\n#\n# Licensed under the"
},
{
"path": "recipes/nodejs_from_chocolatey.rb",
"chars": 806,
"preview": "#\n# Author:: Hossein Margani (hossein@margani.dev)\n# Cookbook:: nodejs\n# Recipe:: install_from_chocolatey\n#\n# Licensed u"
},
{
"path": "recipes/nodejs_from_package.rb",
"chars": 1481,
"preview": "#\n# Author:: Nathan L Smith (nlloyds@gmail.com)\n# Author:: Marius Ducea (marius@promethost.com)\n# Cookbook:: nodejs\n# Re"
},
{
"path": "recipes/nodejs_from_source.rb",
"chars": 1457,
"preview": "#\n# Author:: Marius Ducea (marius@promethost.com)\n# Cookbook:: nodejs\n# Recipe:: source\n#\n# Copyright:: 2010-2017, Prome"
},
{
"path": "recipes/npm.rb",
"chars": 893,
"preview": "#\n# Author:: Marius Ducea (marius@promethost.com)\n# Cookbook:: nodejs\n# Recipe:: npm\n#\n# Copyright:: 2010-2017, Promet S"
},
{
"path": "recipes/npm_from_source.rb",
"chars": 899,
"preview": "#\n# Author:: Marius Ducea (marius@promethost.com)\n# Cookbook:: nodejs\n# Recipe:: npm\n#\n# Copyright:: 2010-2017, Promet S"
},
{
"path": "recipes/npm_packages.rb",
"chars": 407,
"preview": "if node['nodejs'].key?('npm_packages')\n node['nodejs']['npm_packages'].each do |pkg|\n pkg_action = pkg.key?('action'"
},
{
"path": "recipes/repo.rb",
"chars": 1645,
"preview": "case node['platform_family']\nwhen 'debian'\n # Install necessary packages for downloading and verifying new repository i"
},
{
"path": "release-please-config.json",
"chars": 321,
"preview": "{\n \"packages\": {\n \".\": {\n \"package-name\": \"nodejs\",\n \"changelog-path\": \"CHANGELOG.md\",\n \"release-type"
},
{
"path": "renovate.json",
"chars": 472,
"preview": "{\n \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n \"extends\": [\"config:base\"],\n \"packageRules\": [\n "
},
{
"path": "resources/npm_package.rb",
"chars": 3228,
"preview": "#\n# Cookbook:: nodejs\n# Resource:: npm\n#\n# Author:: Sergey Balbeko <sergey@balbeko.com>\n#\n# Copyright:: 2012-2017, Serge"
},
{
"path": "spec/rspec_helper.rb",
"chars": 239,
"preview": "Dir.glob('libraries/*.rb').each do |lib|\n require_relative \"../#{lib}\"\nend\n\nRSpec.configure do |config|\n config.expose"
},
{
"path": "spec/spec_helper.rb",
"chars": 273,
"preview": "require 'chefspec'\nrequire 'chefspec/berkshelf'\n\nRSpec.configure do |config|\n config.color = true # Use c"
},
{
"path": "spec/unit/library/helper_spec.rb",
"chars": 6176,
"preview": "\nrequire 'rspec_helper'\nrequire 'mixlib/shellout'\nrequire 'ostruct'\n\ndescribe 'helper methods' do\n before(:each) do\n "
},
{
"path": "spec/unit/recipes/default_spec.rb",
"chars": 2392,
"preview": "require 'spec_helper'\n\ndescribe 'default recipe on ubuntu 22.04' do\n let(:runner) { ChefSpec::ServerRunner.new(platform"
},
{
"path": "test/cookbooks/test/metadata.rb",
"chars": 60,
"preview": "name 'test'\nversion '0.1.0'\n\ndepends 'git'\ndepends 'nodejs'\n"
},
{
"path": "test/cookbooks/test/recipes/chocolatey.rb",
"chars": 125,
"preview": "node.default['nodejs']['install_method'] = 'chocolatey'\ninclude_recipe 'nodejs::default'\ninclude_recipe 'test::resource_"
},
{
"path": "test/cookbooks/test/recipes/default.rb",
"chars": 86,
"preview": "apt_update 'update'\n\ninclude_recipe 'nodejs::default'\ninclude_recipe 'test::resource'\n"
},
{
"path": "test/cookbooks/test/recipes/package.rb",
"chars": 108,
"preview": "apt_update 'update'\n\nnode.default['nodejs']['install_method'] = 'package'\n\ninclude_recipe 'nodejs::default'\n"
},
{
"path": "test/cookbooks/test/recipes/resource.rb",
"chars": 2407,
"preview": "apt_update 'update'\n\ninclude_recipe 'nodejs::npm'\ninclude_recipe 'git'\n\nuser 'random' do\n manage_home true\n home '/hom"
},
{
"path": "test/cookbooks/test/recipes/resource_win.rb",
"chars": 424,
"preview": "include_recipe 'nodejs::npm'\ninclude_recipe 'git'\n\nuser 'random' do\n manage_home true\n home '/home/random'\nend\n\nuser '"
},
{
"path": "test/cookbooks/test/recipes/source.rb",
"chars": 241,
"preview": "apt_update 'update'\n\n# Source install puts the npm symlink in /usr/local/bin\nENV['PATH'] = '/usr/local/bin:' + ENV['PATH"
},
{
"path": "test/cookbooks/test/recipes/source_iojs.rb",
"chars": 307,
"preview": "apt_update 'update'\n\nnode.default['nodejs']['engine'] = 'iojs'\nnode.default['nodejs']['install_method'] = 'source'\nnode."
},
{
"path": "test/cookbooks/test/templates/package.json",
"chars": 371,
"preview": "{\n \"name\": \"random-test\",\n \"version\": \"0.1.0\",\n \"description\": \"Just some random test\",\n \"license\": \"MIT\",\n \"author"
},
{
"path": "test/integration/chocolatey/default.rb",
"chars": 436,
"preview": "control 'commands should exist' do\n describe command('node -v') do\n its('exit_status') { should eq 0 }\n end\n\n desc"
},
{
"path": "test/integration/default/default_spec.rb",
"chars": 884,
"preview": "os_family = os.family\n\ncontrol 'commands should exist' do\n describe command('node -v') do\n its('exit_status') { shou"
},
{
"path": "test/integration/npm_embedded/default_spec.rb",
"chars": 274,
"preview": "\ncontrol 'commands should exist' do\n describe command('node -v') do\n its('exit_status') { should eq 0 }\n end\n\n des"
},
{
"path": "test/integration/npm_source/default_spec.rb",
"chars": 418,
"preview": "\ncontrol 'commands should exist' do\n describe command('node -v') do\n its('exit_status') { should eq 0 }\n end\n\n des"
},
{
"path": "test/integration/options/default_spec.rb",
"chars": 252,
"preview": "control 'packages should install' do\n describe package('nodejs') do\n it { should be_installed }\n end\n\n describe pa"
},
{
"path": "test/integration/package/default.rb",
"chars": 1327,
"preview": "control 'commands should exist' do\n describe command('node -v') do\n its('exit_status') { should eq 0 }\n end\n\n desc"
},
{
"path": "test/integration/source/default.rb",
"chars": 490,
"preview": "control 'commands should exist' do\n describe command('node -v') do\n its('exit_status') { should eq 0 }\n end\n\n desc"
}
]
About this extraction
This page contains the full source code of the redguide/nodejs GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 74 files (87.4 KB), approximately 25.4k tokens, and a symbol index with 19 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.