mirror of
https://gitea.com/actions/setup-node.git
synced 2026-02-26 09:25:42 +08:00
Compare commits
1 Commits
dependabot
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
774c1d6296 |
15
.github/workflows/versions.yml
vendored
15
.github/workflows/versions.yml
vendored
@@ -168,6 +168,21 @@ jobs:
|
|||||||
- name: Verify node
|
- name: Verify node
|
||||||
run: __tests__/verify-node.sh 24
|
run: __tests__/verify-node.sh 24
|
||||||
|
|
||||||
|
version-file-dev-engines:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node from node version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version-file: '__tests__/data/package-dev-engines.json'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 20
|
||||||
|
|
||||||
version-file-volta:
|
version-file-volta:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
11
__tests__/data/package-dev-engines.json
Normal file
11
__tests__/data/package-dev-engines.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"engines": {
|
||||||
|
"node": "^19"
|
||||||
|
},
|
||||||
|
"devEngines": {
|
||||||
|
"runtime": {
|
||||||
|
"name": "node",
|
||||||
|
"version": "^20"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,10 +106,12 @@ describe('main tests', () => {
|
|||||||
${''} | ${''}
|
${''} | ${''}
|
||||||
${'unknown format'} | ${'unknown format'}
|
${'unknown format'} | ${'unknown format'}
|
||||||
${' 14.1.0 '} | ${'14.1.0'}
|
${' 14.1.0 '} | ${'14.1.0'}
|
||||||
|
${'{}'} | ${null}
|
||||||
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'} | ${'>=14.0.0 <=17.0.0'}
|
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'} | ${'>=14.0.0 <=17.0.0'}
|
||||||
${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
|
${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
|
||||||
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
||||||
${'{}'} | ${null}
|
${'{"devEngines": {"runtime": {"name": "node", "version": "22.0.0"}}}'} | ${'22.0.0'}
|
||||||
|
${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'}
|
||||||
`.it('parses "$contents"', ({contents, expected}) => {
|
`.it('parses "$contents"', ({contents, expected}) => {
|
||||||
const existsSpy = jest.spyOn(fs, 'existsSync');
|
const existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
existsSpy.mockImplementation(() => true);
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|||||||
11
dist/cache-save/index.js
vendored
11
dist/cache-save/index.js
vendored
@@ -71877,6 +71877,17 @@ function getNodeVersionFromFile(versionFilePath) {
|
|||||||
if (manifest.volta?.node) {
|
if (manifest.volta?.node) {
|
||||||
return manifest.volta.node;
|
return manifest.volta.node;
|
||||||
}
|
}
|
||||||
|
// support devEngines from npm 11
|
||||||
|
if (manifest.devEngines?.runtime) {
|
||||||
|
// find an entry with name set to node and having set a version.
|
||||||
|
// the devEngines.runtime can either be an object or an array of objects
|
||||||
|
const nodeEntry = [manifest.devEngines.runtime]
|
||||||
|
.flat()
|
||||||
|
.find(({ name, version }) => name?.toLowerCase() === 'node' && version);
|
||||||
|
if (nodeEntry) {
|
||||||
|
return nodeEntry.version;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (manifest.engines?.node) {
|
if (manifest.engines?.node) {
|
||||||
return manifest.engines.node;
|
return manifest.engines.node;
|
||||||
}
|
}
|
||||||
|
|||||||
11
dist/setup/index.js
vendored
11
dist/setup/index.js
vendored
@@ -82415,6 +82415,17 @@ function getNodeVersionFromFile(versionFilePath) {
|
|||||||
if (manifest.volta?.node) {
|
if (manifest.volta?.node) {
|
||||||
return manifest.volta.node;
|
return manifest.volta.node;
|
||||||
}
|
}
|
||||||
|
// support devEngines from npm 11
|
||||||
|
if (manifest.devEngines?.runtime) {
|
||||||
|
// find an entry with name set to node and having set a version.
|
||||||
|
// the devEngines.runtime can either be an object or an array of objects
|
||||||
|
const nodeEntry = [manifest.devEngines.runtime]
|
||||||
|
.flat()
|
||||||
|
.find(({ name, version }) => name?.toLowerCase() === 'node' && version);
|
||||||
|
if (nodeEntry) {
|
||||||
|
return nodeEntry.version;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (manifest.engines?.node) {
|
if (manifest.engines?.node) {
|
||||||
return manifest.engines.node;
|
return manifest.engines.node;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,21 +90,31 @@ steps:
|
|||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
When using the `package.json` input, the action will look for `volta.node` first. If `volta.node` isn't defined, then it will look for `engines.node`.
|
When using the `package.json` input, the action will look in the following fields for a specified Node version:
|
||||||
|
1. It checks `volta.node` first.
|
||||||
|
2. Then it checks `devEngines.runtime` for an entry with `"name": "node"`.
|
||||||
|
3. Then it will look for `engines.node`.
|
||||||
|
4. Otherwise it tries to resolve the file defined by [`volta.extends`](https://docs.volta.sh/advanced/workspaces)
|
||||||
|
and look for `volta.node`, `devEngines.runtime`, or `engines.node` recursively.
|
||||||
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.0.0"
|
"node": "^22 || ^24"
|
||||||
|
},
|
||||||
|
"devEngines": {
|
||||||
|
"runtime": {
|
||||||
|
"name": "node",
|
||||||
|
"version": "^24.3"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"volta": {
|
"volta": {
|
||||||
"node": "16.0.0"
|
"node": "24.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Otherwise, when [`volta.extends`](https://docs.volta.sh/advanced/workspaces) is defined, then it will resolve the corresponding file and look for `volta.node` or `engines.node` recursively.
|
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).
|
You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).
|
||||||
|
|||||||
12
src/util.ts
12
src/util.ts
@@ -26,6 +26,18 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
|||||||
return manifest.volta.node;
|
return manifest.volta.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// support devEngines from npm 11
|
||||||
|
if (manifest.devEngines?.runtime) {
|
||||||
|
// find an entry with name set to node and having set a version.
|
||||||
|
// the devEngines.runtime can either be an object or an array of objects
|
||||||
|
const nodeEntry = [manifest.devEngines.runtime]
|
||||||
|
.flat()
|
||||||
|
.find(({name, version}) => name?.toLowerCase() === 'node' && version);
|
||||||
|
if (nodeEntry) {
|
||||||
|
return nodeEntry.version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (manifest.engines?.node) {
|
if (manifest.engines?.node) {
|
||||||
return manifest.engines.node;
|
return manifest.engines.node;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user