https://github.com/nextcloud-libraries/parse-package-engines-action
GitHub action for parsing the engine and package manager from a package.json
https://github.com/nextcloud-libraries/parse-package-engines-action
Last synced: 15 days ago
JSON representation
GitHub action for parsing the engine and package manager from a package.json
- Host: GitHub
- URL: https://github.com/nextcloud-libraries/parse-package-engines-action
- Owner: nextcloud-libraries
- License: mit
- Created: 2025-10-20T10:30:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-11-06T17:11:51.000Z (6 months ago)
- Last Synced: 2025-11-06T19:10:52.259Z (6 months ago)
- Language: JavaScript
- Size: 1.19 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-package-engines

[](https://github.com/actions/javascript-action/actions/workflows/check-dist.yml)
[](https://github.com/actions/javascript-action/actions/workflows/codeql-analysis.yml)
[](./badges/coverage.svg)
This is a GitHub action to parse the node version and the package manager (name and version) from a `package.json`.
The idea is that with the `setup-node` action currently `devEngines` is not supported, but it also does not to setup a specific package manager.
So this action is capable of parsing `engines`, `devEngines` as well as `packageManager` entries from a `package.json`.
## Inputs & Outputs
Inputs:
* `path`: The path to the `package.json` relative to `working-directory`, defaults to `./package.json`
* `working-directory`: The current working directory - used for reading the `package.json` and defaults to the `GITHUB_WORKSPACE`.
Outputs:
* `node-version`: The detected Node.js version
* `package-manager-name`: The name of the detected package manager, like `npm` or `yarn`
* `package-manager-version`: The version of the detected package manager, like `^10.5.1`
## Usage
When for example building a workflow to compile assets the usage could look like this:
```yaml
name: Node build
on: pull_request
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
name: NPM build
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Read package.json
uses: nextcloud-libraries/parse-package-engines-action@main # please pin this version to an actual tag for security
id: versions
- name: Set up node ${{ steps.versions.outputs.node-version }}
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: ${{ steps.versions.outputs.node-version }}
# Here we know we use npm
- name: Set up npm ${{ steps.versions.outputs.package-manager-version }}
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
- name: Install dependencies & build
run: |
npm ci
npm run build --if-present
```