mirror of
https://github.com/actions/setup-node.git
synced 2025-09-10 03:11:34 +08:00
Compare commits
5 Commits
dependabot
...
bc7aeeecab
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bc7aeeecab | ||
![]() |
cd2651c462 | ||
![]() |
a0853c2454 | ||
![]() |
b7234cc9fe | ||
![]() |
d7a11313b5 |
2
.github/workflows/basic-validation.yml
vendored
2
.github/workflows/basic-validation.yml
vendored
@@ -16,4 +16,4 @@ jobs:
|
||||
name: Basic validation
|
||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||
with:
|
||||
node-version: '20.x'
|
||||
node-version: '24.x'
|
||||
|
59
.github/workflows/e2e-cache.yml
vendored
59
.github/workflows/e2e-cache.yml
vendored
@@ -19,9 +19,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Clean global cache
|
||||
run: npm cache clean --force
|
||||
- name: Setup Node
|
||||
@@ -42,9 +42,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
@@ -75,13 +75,13 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20]
|
||||
node-version: [18, 20, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Yarn version
|
||||
run: yarn --version
|
||||
- name: Generate yarn file
|
||||
run: yarn install
|
||||
run: yarn install --ignore-engines
|
||||
- name: Remove dependencies
|
||||
shell: pwsh
|
||||
run: Remove-Item node_modules -Force -Recurse
|
||||
@@ -107,9 +107,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Update yarn
|
||||
run: yarn set version 3.6.4
|
||||
- name: Yarn version
|
||||
@@ -139,11 +139,11 @@ jobs:
|
||||
name: Test yarn subprojects
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: prepare sub-projects
|
||||
run: __tests__/prepare-yarn-subprojects.sh yarn1
|
||||
@@ -166,11 +166,11 @@ jobs:
|
||||
name: Test yarn subprojects all locally managed
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: prepare sub-projects
|
||||
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
|
||||
@@ -193,11 +193,11 @@ jobs:
|
||||
name: Test yarn subprojects some locally managed
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: prepare sub-projects
|
||||
run: __tests__/prepare-yarn-subprojects.sh global
|
||||
@@ -220,11 +220,11 @@ jobs:
|
||||
name: Test yarn subprojects managed by git
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: prepare sub-projects
|
||||
run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache
|
||||
@@ -243,3 +243,28 @@ jobs:
|
||||
cache-dependency-path: |
|
||||
sub2/*.lock
|
||||
sub3/*.lock
|
||||
|
||||
node-npm-package-manager-cache:
|
||||
name: Test enabling cache if package manager field is present (Node ${{ matrix.node-version }}, ${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Create package.json with packageManager field
|
||||
run: |
|
||||
echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json
|
||||
- name: Clean global cache
|
||||
run: npm cache clean --force
|
||||
- name: Setup Node with caching enabled
|
||||
uses: ./
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Verify node and npm
|
||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||
shell: bash
|
||||
|
4
.github/workflows/proxy.yml
vendored
4
.github/workflows/proxy.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
env:
|
||||
https_proxy: http://squid-proxy:3128
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Clear tool cache
|
||||
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||
- name: Setup node 14
|
||||
@@ -41,7 +41,7 @@ jobs:
|
||||
https_proxy: http://no-such-proxy:3128
|
||||
no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Clear tool cache
|
||||
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||
- name: Setup node 11
|
||||
|
@@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checking out
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
- name: Publish
|
||||
id: publish
|
||||
uses: actions/publish-immutable-action@v0.0.4
|
||||
|
38
.github/workflows/versions.yml
vendored
38
.github/workflows/versions.yml
vendored
@@ -18,9 +18,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-13]
|
||||
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
'20.0.0-v8-canary20221101e50e45c9f8'
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -84,7 +84,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [20-nightly, 21-nightly, 18.0.0-nightly]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [20.0.0-rc.1, 18.0.0-rc.2, 19.0.0-rc.0]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -124,7 +124,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18.20.0, 20.10.0, 22.0.0]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -139,9 +139,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@@ -160,13 +160,13 @@ jobs:
|
||||
node-version-file:
|
||||
[.nvmrc, .tool-versions, .tool-versions-node, package.json]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node from node version file
|
||||
uses: ./
|
||||
with:
|
||||
node-version-file: '__tests__/data/${{ matrix.node-version-file }}'
|
||||
- name: Verify node
|
||||
run: __tests__/verify-node.sh 20
|
||||
run: __tests__/verify-node.sh 24
|
||||
|
||||
version-file-volta:
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -175,13 +175,13 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node from node version file
|
||||
uses: ./
|
||||
with:
|
||||
node-version-file: '__tests__/data/package-volta.json'
|
||||
- name: Verify node
|
||||
run: __tests__/verify-node.sh 20
|
||||
run: __tests__/verify-node.sh 24
|
||||
|
||||
version-file-volta-extends:
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -190,13 +190,13 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node from node version file
|
||||
uses: ./
|
||||
with:
|
||||
node-version-file: '__tests__/data/package-volta-extends.json'
|
||||
- name: Verify node
|
||||
run: __tests__/verify-node.sh 20
|
||||
run: __tests__/verify-node.sh 24
|
||||
|
||||
node-dist:
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -206,7 +206,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [17, 19]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node from dist
|
||||
uses: ./
|
||||
with:
|
||||
@@ -222,7 +222,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
# test old versions which didn't have npm and layout different
|
||||
- name: Setup node 0.12.18 from dist
|
||||
uses: ./
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
arch:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node 20 x86 from dist
|
||||
uses: ./
|
||||
with:
|
||||
@@ -259,7 +259,7 @@ jobs:
|
||||
echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
shell: bash
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
|
2
.licenses/npm/@types/node.dep.yml
generated
2
.licenses/npm/@types/node.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@types/node"
|
||||
version: 20.11.25
|
||||
version: 24.1.0
|
||||
type: npm
|
||||
summary: TypeScript definitions for node
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: semver
|
||||
version: 7.6.3
|
||||
version: 7.7.2
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage:
|
6
.licenses/npm/undici-types.dep.yml
generated
6
.licenses/npm/undici-types.dep.yml
generated
@@ -1,15 +1,17 @@
|
||||
---
|
||||
name: undici-types
|
||||
version: 5.26.5
|
||||
version: 7.8.0
|
||||
type: npm
|
||||
summary: A stand-alone types package for Undici
|
||||
homepage: https://undici.nodejs.org
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: Auto-generated MIT license text
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
|
50
README.md
50
README.md
@@ -12,13 +12,23 @@ This action provides the following functionality for GitHub Actions users:
|
||||
- Registering problem matchers for error output
|
||||
- Configuring authentication for GPR or npm
|
||||
|
||||
## Breaking changes in V5
|
||||
|
||||
- Enabled caching by default with package manager detection if no cache input is provided.
|
||||
> For workflows with elevated privileges or access to sensitive information, we recommend disabling automatic caching by setting `package-manager-cache: false` when caching is not needed for secure operation.
|
||||
|
||||
- Upgraded action from node20 to node24.
|
||||
> Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. [See Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
|
||||
|
||||
For more details, see the full release notes on the [releases page](https://github.com/actions/setup-node/releases/v5.0.0)
|
||||
|
||||
## Usage
|
||||
|
||||
See [action.yml](action.yml)
|
||||
|
||||
<!-- start usage -->
|
||||
```yaml
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
# Version Spec of the version to use in SemVer notation.
|
||||
# It also admits such aliases as lts/*, latest, nightly and canary builds
|
||||
@@ -57,6 +67,10 @@ See [action.yml](action.yml)
|
||||
# Default: ''
|
||||
cache: ''
|
||||
|
||||
# Used to disable automatic caching based on the package manager field in package.json. By default, caching is enabled if the package manager field is present and no cache input is provided'
|
||||
# default: true
|
||||
package-manager-cache: true
|
||||
|
||||
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
|
||||
# It will generate hash from the target file for primary key. It works only If cache is specified.
|
||||
# Supports wildcards or a list of file names for caching multiple dependencies.
|
||||
@@ -98,8 +112,8 @@ See [action.yml](action.yml)
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 18
|
||||
- run: npm ci
|
||||
@@ -135,7 +149,19 @@ It's **always** recommended to commit the lockfile of your package manager for s
|
||||
|
||||
## Caching global packages data
|
||||
|
||||
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default.
|
||||
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional.
|
||||
|
||||
Caching is turned on by default when a `packageManager` field is detected in the `package.json` file and no `cache` input is provided. The `package-manager-cache` input provides control over this automatic caching behavior. By default, `package-manager-cache` is set to `true`, which enables caching when a valid package manager field is detected in the `package.json` file. To disable this automatic caching, set the `package-manager-cache` input to `false`.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
package-manager-cache: false
|
||||
- run: npm ci
|
||||
```
|
||||
> If no valid `packageManager` field is detected in the `package.json` file, caching will remain disabled unless explicitly configured. For workflows with elevated privileges or access to sensitive information, we recommend disabling automatic caching by setting `package-manager-cache: false` when caching is not needed for secure operation.
|
||||
|
||||
The action defaults to search for the dependency file (`package-lock.json`, `npm-shrinkwrap.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories.
|
||||
|
||||
@@ -147,8 +173,8 @@ See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` in
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
@@ -160,8 +186,8 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
@@ -181,9 +207,9 @@ jobs:
|
||||
node: [ 14, 16, 18 ]
|
||||
name: Node ${{ matrix.node }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: npm ci
|
||||
@@ -197,7 +223,7 @@ jobs:
|
||||
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action:
|
||||
|
||||
```yaml
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
||||
node-version: 20
|
||||
@@ -238,4 +264,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
||||
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
@@ -1 +1 @@
|
||||
v20
|
||||
v24
|
||||
|
@@ -1 +1 @@
|
||||
nodejs 20.0.0
|
||||
nodejs 24.0.0
|
||||
|
@@ -1 +1 @@
|
||||
node 20.0.0
|
||||
node 24.0.0
|
||||
|
@@ -3,6 +3,6 @@
|
||||
"node": "^14.0.0"
|
||||
},
|
||||
"volta": {
|
||||
"node": "20.0.0"
|
||||
"node": "24.0.0"
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"engines": {
|
||||
"node": "^20.0.0"
|
||||
"node": "^24.0.0"
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ describe('main tests', () => {
|
||||
|
||||
let infoSpy: jest.SpyInstance;
|
||||
let warningSpy: jest.SpyInstance;
|
||||
let saveStateSpy: jest.SpyInstance;
|
||||
let inSpy: jest.SpyInstance;
|
||||
let setOutputSpy: jest.SpyInstance;
|
||||
let startGroupSpy: jest.SpyInstance;
|
||||
@@ -53,6 +54,8 @@ describe('main tests', () => {
|
||||
setOutputSpy.mockImplementation(() => {});
|
||||
warningSpy = jest.spyOn(core, 'warning');
|
||||
warningSpy.mockImplementation(() => {});
|
||||
saveStateSpy = jest.spyOn(core, 'saveState');
|
||||
saveStateSpy.mockImplementation(() => {});
|
||||
startGroupSpy = jest.spyOn(core, 'startGroup');
|
||||
startGroupSpy.mockImplementation(() => {});
|
||||
endGroupSpy = jest.spyOn(core, 'endGroup');
|
||||
@@ -280,4 +283,65 @@ describe('main tests', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('cache feature tests', () => {
|
||||
it('Should enable caching with the resolved package manager from packageManager field in package.json when the cache input is not provided', async () => {
|
||||
inputs['package-manager-cache'] = 'true';
|
||||
inputs['cache'] = ''; // No cache input is provided
|
||||
|
||||
inSpy.mockImplementation(name => inputs[name]);
|
||||
|
||||
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||
readFileSpy.mockImplementation(() =>
|
||||
JSON.stringify({
|
||||
packageManager: 'yarn@3.2.0'
|
||||
})
|
||||
);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'yarn');
|
||||
});
|
||||
|
||||
it('Should not enable caching if the packageManager field is missing in package.json and the cache input is not provided', async () => {
|
||||
inputs['package-manager-cache'] = 'true';
|
||||
inputs['cache'] = ''; // No cache input is provided
|
||||
|
||||
inSpy.mockImplementation(name => inputs[name]);
|
||||
|
||||
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||
readFileSpy.mockImplementation(() =>
|
||||
JSON.stringify({
|
||||
//packageManager field is not present
|
||||
})
|
||||
);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('Should skip caching when package-manager-cache is false', async () => {
|
||||
inputs['package-manager-cache'] = 'false';
|
||||
inputs['cache'] = ''; // No cache input is provided
|
||||
|
||||
inSpy.mockImplementation(name => inputs[name]);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('Should enable caching with cache input explicitly provided', async () => {
|
||||
inputs['package-manager-cache'] = 'true';
|
||||
inputs['cache'] = 'npm'; // Explicit cache input provided
|
||||
|
||||
inSpy.mockImplementation(name => inputs[name]);
|
||||
isCacheActionAvailable.mockReturnValue(true);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'npm');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -7,8 +7,13 @@ fi
|
||||
|
||||
node_version="$(node --version)"
|
||||
echo "Found node version '$node_version'"
|
||||
if [ -z "$(echo $node_version | grep --fixed-strings v$1)" ]; then
|
||||
echo "Unexpected version"
|
||||
|
||||
# Extract the major version from the node version (remove the 'v' prefix)
|
||||
actual_major_version=$(echo $node_version | sed -E 's/^v([0-9]+)\..*/\1/')
|
||||
expected_major_version=$(echo $1 | sed -E 's/^([0-9]+)\..*/\1/') # Extract major version from argument
|
||||
|
||||
if [ "$actual_major_version" != "$expected_major_version" ]; then
|
||||
echo "Expected Node.js $expected_major_version.x.x but found $node_version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@@ -23,6 +23,9 @@ inputs:
|
||||
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||
cache:
|
||||
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
|
||||
package-manager-cache:
|
||||
description: 'Set to false to disable automatic caching based on the package manager field in package.json. By default, caching is enabled if the package manager field is present.'
|
||||
default: true
|
||||
cache-dependency-path:
|
||||
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
|
||||
mirror:
|
||||
@@ -37,7 +40,7 @@ outputs:
|
||||
node-version:
|
||||
description: 'The installed node version.'
|
||||
runs:
|
||||
using: 'node20'
|
||||
using: 'node24'
|
||||
main: 'dist/setup/index.js'
|
||||
post: 'dist/cache-save/index.js'
|
||||
post-if: success()
|
||||
|
222
dist/setup/index.js
vendored
222
dist/setup/index.js
vendored
@@ -65675,6 +65675,9 @@ function onceStrict (fn) {
|
||||
/***/ 89379:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const ANY = Symbol('SemVer ANY')
|
||||
// hoisted class for cyclic dependency
|
||||
class Comparator {
|
||||
@@ -65823,6 +65826,9 @@ const Range = __nccwpck_require__(96782)
|
||||
/***/ 96782:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SPACE_CHARACTERS = /\s+/g
|
||||
|
||||
// hoisted class for cyclic dependency
|
||||
@@ -66384,6 +66390,9 @@ const testSet = (set, version, options) => {
|
||||
/***/ 7163:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const debug = __nccwpck_require__(1159)
|
||||
const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(45101)
|
||||
const { safeRe: re, t } = __nccwpck_require__(95471)
|
||||
@@ -66396,7 +66405,7 @@ class SemVer {
|
||||
|
||||
if (version instanceof SemVer) {
|
||||
if (version.loose === !!options.loose &&
|
||||
version.includePrerelease === !!options.includePrerelease) {
|
||||
version.includePrerelease === !!options.includePrerelease) {
|
||||
return version
|
||||
} else {
|
||||
version = version.version
|
||||
@@ -66562,6 +66571,19 @@ class SemVer {
|
||||
// preminor will bump the version up to the next minor release, and immediately
|
||||
// down to pre-release. premajor and prepatch work the same way.
|
||||
inc (release, identifier, identifierBase) {
|
||||
if (release.startsWith('pre')) {
|
||||
if (!identifier && identifierBase === false) {
|
||||
throw new Error('invalid increment argument: identifier is empty')
|
||||
}
|
||||
// Avoid an invalid semver results
|
||||
if (identifier) {
|
||||
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
|
||||
if (!match || match[1] !== identifier) {
|
||||
throw new Error(`invalid identifier: ${identifier}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (release) {
|
||||
case 'premajor':
|
||||
this.prerelease.length = 0
|
||||
@@ -66592,6 +66614,12 @@ class SemVer {
|
||||
}
|
||||
this.inc('pre', identifier, identifierBase)
|
||||
break
|
||||
case 'release':
|
||||
if (this.prerelease.length === 0) {
|
||||
throw new Error(`version ${this.raw} is not a prerelease`)
|
||||
}
|
||||
this.prerelease.length = 0
|
||||
break
|
||||
|
||||
case 'major':
|
||||
// If this is a pre-major version, bump up to the same major version.
|
||||
@@ -66635,10 +66663,6 @@ class SemVer {
|
||||
case 'pre': {
|
||||
const base = Number(identifierBase) ? 1 : 0
|
||||
|
||||
if (!identifier && identifierBase === false) {
|
||||
throw new Error('invalid increment argument: identifier is empty')
|
||||
}
|
||||
|
||||
if (this.prerelease.length === 0) {
|
||||
this.prerelease = [base]
|
||||
} else {
|
||||
@@ -66693,6 +66717,9 @@ module.exports = SemVer
|
||||
/***/ 1799:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const parse = __nccwpck_require__(16353)
|
||||
const clean = (version, options) => {
|
||||
const s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
||||
@@ -66706,6 +66733,9 @@ module.exports = clean
|
||||
/***/ 28646:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const eq = __nccwpck_require__(55082)
|
||||
const neq = __nccwpck_require__(4974)
|
||||
const gt = __nccwpck_require__(16599)
|
||||
@@ -66765,6 +66795,9 @@ module.exports = cmp
|
||||
/***/ 35385:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const parse = __nccwpck_require__(16353)
|
||||
const { safeRe: re, t } = __nccwpck_require__(95471)
|
||||
@@ -66832,6 +66865,9 @@ module.exports = coerce
|
||||
/***/ 37648:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const compareBuild = (a, b, loose) => {
|
||||
const versionA = new SemVer(a, loose)
|
||||
@@ -66846,6 +66882,9 @@ module.exports = compareBuild
|
||||
/***/ 56874:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const compareLoose = (a, b) => compare(a, b, true)
|
||||
module.exports = compareLoose
|
||||
@@ -66856,6 +66895,9 @@ module.exports = compareLoose
|
||||
/***/ 78469:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const compare = (a, b, loose) =>
|
||||
new SemVer(a, loose).compare(new SemVer(b, loose))
|
||||
@@ -66868,6 +66910,9 @@ module.exports = compare
|
||||
/***/ 70711:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const parse = __nccwpck_require__(16353)
|
||||
|
||||
const diff = (version1, version2) => {
|
||||
@@ -66897,20 +66942,13 @@ const diff = (version1, version2) => {
|
||||
return 'major'
|
||||
}
|
||||
|
||||
// Otherwise it can be determined by checking the high version
|
||||
|
||||
if (highVersion.patch) {
|
||||
// anything higher than a patch bump would result in the wrong version
|
||||
// If the main part has no difference
|
||||
if (lowVersion.compareMain(highVersion) === 0) {
|
||||
if (lowVersion.minor && !lowVersion.patch) {
|
||||
return 'minor'
|
||||
}
|
||||
return 'patch'
|
||||
}
|
||||
|
||||
if (highVersion.minor) {
|
||||
// anything higher than a minor bump would result in the wrong version
|
||||
return 'minor'
|
||||
}
|
||||
|
||||
// bumping major/minor/patch all have same result
|
||||
return 'major'
|
||||
}
|
||||
|
||||
// add the `pre` prefix if we are going to a prerelease version
|
||||
@@ -66940,6 +66978,9 @@ module.exports = diff
|
||||
/***/ 55082:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const eq = (a, b, loose) => compare(a, b, loose) === 0
|
||||
module.exports = eq
|
||||
@@ -66950,6 +66991,9 @@ module.exports = eq
|
||||
/***/ 16599:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const gt = (a, b, loose) => compare(a, b, loose) > 0
|
||||
module.exports = gt
|
||||
@@ -66960,6 +67004,9 @@ module.exports = gt
|
||||
/***/ 41236:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const gte = (a, b, loose) => compare(a, b, loose) >= 0
|
||||
module.exports = gte
|
||||
@@ -66970,6 +67017,9 @@ module.exports = gte
|
||||
/***/ 62338:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
|
||||
const inc = (version, release, options, identifier, identifierBase) => {
|
||||
@@ -66996,6 +67046,9 @@ module.exports = inc
|
||||
/***/ 3872:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const lt = (a, b, loose) => compare(a, b, loose) < 0
|
||||
module.exports = lt
|
||||
@@ -67006,6 +67059,9 @@ module.exports = lt
|
||||
/***/ 56717:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const lte = (a, b, loose) => compare(a, b, loose) <= 0
|
||||
module.exports = lte
|
||||
@@ -67016,6 +67072,9 @@ module.exports = lte
|
||||
/***/ 68511:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const major = (a, loose) => new SemVer(a, loose).major
|
||||
module.exports = major
|
||||
@@ -67026,6 +67085,9 @@ module.exports = major
|
||||
/***/ 32603:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const minor = (a, loose) => new SemVer(a, loose).minor
|
||||
module.exports = minor
|
||||
@@ -67036,6 +67098,9 @@ module.exports = minor
|
||||
/***/ 4974:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const neq = (a, b, loose) => compare(a, b, loose) !== 0
|
||||
module.exports = neq
|
||||
@@ -67046,6 +67111,9 @@ module.exports = neq
|
||||
/***/ 16353:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const parse = (version, options, throwErrors = false) => {
|
||||
if (version instanceof SemVer) {
|
||||
@@ -67069,6 +67137,9 @@ module.exports = parse
|
||||
/***/ 48756:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const patch = (a, loose) => new SemVer(a, loose).patch
|
||||
module.exports = patch
|
||||
@@ -67079,6 +67150,9 @@ module.exports = patch
|
||||
/***/ 15714:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const parse = __nccwpck_require__(16353)
|
||||
const prerelease = (version, options) => {
|
||||
const parsed = parse(version, options)
|
||||
@@ -67092,6 +67166,9 @@ module.exports = prerelease
|
||||
/***/ 32173:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compare = __nccwpck_require__(78469)
|
||||
const rcompare = (a, b, loose) => compare(b, a, loose)
|
||||
module.exports = rcompare
|
||||
@@ -67102,6 +67179,9 @@ module.exports = rcompare
|
||||
/***/ 87192:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compareBuild = __nccwpck_require__(37648)
|
||||
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
|
||||
module.exports = rsort
|
||||
@@ -67112,6 +67192,9 @@ module.exports = rsort
|
||||
/***/ 68011:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const Range = __nccwpck_require__(96782)
|
||||
const satisfies = (version, range, options) => {
|
||||
try {
|
||||
@@ -67129,6 +67212,9 @@ module.exports = satisfies
|
||||
/***/ 29872:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const compareBuild = __nccwpck_require__(37648)
|
||||
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
|
||||
module.exports = sort
|
||||
@@ -67139,6 +67225,9 @@ module.exports = sort
|
||||
/***/ 58780:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const parse = __nccwpck_require__(16353)
|
||||
const valid = (version, options) => {
|
||||
const v = parse(version, options)
|
||||
@@ -67152,6 +67241,9 @@ module.exports = valid
|
||||
/***/ 62088:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
// just pre-load all the stuff that index.js lazily exports
|
||||
const internalRe = __nccwpck_require__(95471)
|
||||
const constants = __nccwpck_require__(45101)
|
||||
@@ -67248,6 +67340,9 @@ module.exports = {
|
||||
/***/ 45101:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
// Note: this is the semver.org version of the spec that it implements
|
||||
// Not necessarily the package version of this code.
|
||||
const SEMVER_SPEC_VERSION = '2.0.0'
|
||||
@@ -67290,6 +67385,9 @@ module.exports = {
|
||||
/***/ 1159:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const debug = (
|
||||
typeof process === 'object' &&
|
||||
process.env &&
|
||||
@@ -67306,6 +67404,9 @@ module.exports = debug
|
||||
/***/ 73348:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const numeric = /^[0-9]+$/
|
||||
const compareIdentifiers = (a, b) => {
|
||||
const anum = numeric.test(a)
|
||||
@@ -67336,6 +67437,9 @@ module.exports = {
|
||||
/***/ 61383:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
class LRUCache {
|
||||
constructor () {
|
||||
this.max = 1000
|
||||
@@ -67383,6 +67487,9 @@ module.exports = LRUCache
|
||||
/***/ 70356:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
// parse out just the options we care about
|
||||
const looseOption = Object.freeze({ loose: true })
|
||||
const emptyOpts = Object.freeze({ })
|
||||
@@ -67405,6 +67512,9 @@ module.exports = parseOptions
|
||||
/***/ 95471:
|
||||
/***/ ((module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const {
|
||||
MAX_SAFE_COMPONENT_LENGTH,
|
||||
MAX_SAFE_BUILD_LENGTH,
|
||||
@@ -67417,6 +67527,7 @@ exports = module.exports = {}
|
||||
const re = exports.re = []
|
||||
const safeRe = exports.safeRe = []
|
||||
const src = exports.src = []
|
||||
const safeSrc = exports.safeSrc = []
|
||||
const t = exports.t = {}
|
||||
let R = 0
|
||||
|
||||
@@ -67449,6 +67560,7 @@ const createToken = (name, value, isGlobal) => {
|
||||
debug(name, index, value)
|
||||
t[name] = index
|
||||
src[index] = value
|
||||
safeSrc[index] = safe
|
||||
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
|
||||
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
|
||||
}
|
||||
@@ -67481,12 +67593,14 @@ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
||||
|
||||
// ## Pre-release Version Identifier
|
||||
// A numeric identifier, or a non-numeric identifier.
|
||||
// Non-numberic identifiers include numberic identifiers but can be longer.
|
||||
// Therefore non-numberic identifiers must go first.
|
||||
|
||||
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
||||
}|${src[t.NONNUMERICIDENTIFIER]})`)
|
||||
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
|
||||
}|${src[t.NUMERICIDENTIFIER]})`)
|
||||
|
||||
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
||||
}|${src[t.NONNUMERICIDENTIFIER]})`)
|
||||
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
|
||||
}|${src[t.NUMERICIDENTIFIERLOOSE]})`)
|
||||
|
||||
// ## Pre-release Version
|
||||
// Hyphen, followed by one or more dot-separated pre-release version
|
||||
@@ -67629,6 +67743,9 @@ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
|
||||
/***/ 12276:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
// Determine if version is greater than all the versions possible in the range.
|
||||
const outside = __nccwpck_require__(10280)
|
||||
const gtr = (version, range, options) => outside(version, range, '>', options)
|
||||
@@ -67640,6 +67757,9 @@ module.exports = gtr
|
||||
/***/ 23465:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const Range = __nccwpck_require__(96782)
|
||||
const intersects = (r1, r2, options) => {
|
||||
r1 = new Range(r1, options)
|
||||
@@ -67654,6 +67774,9 @@ module.exports = intersects
|
||||
/***/ 15213:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const outside = __nccwpck_require__(10280)
|
||||
// Determine if version is less than all the versions possible in the range
|
||||
const ltr = (version, range, options) => outside(version, range, '<', options)
|
||||
@@ -67665,6 +67788,9 @@ module.exports = ltr
|
||||
/***/ 73193:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const Range = __nccwpck_require__(96782)
|
||||
|
||||
@@ -67697,6 +67823,9 @@ module.exports = maxSatisfying
|
||||
/***/ 68595:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const Range = __nccwpck_require__(96782)
|
||||
const minSatisfying = (versions, range, options) => {
|
||||
@@ -67728,6 +67857,9 @@ module.exports = minSatisfying
|
||||
/***/ 51866:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const Range = __nccwpck_require__(96782)
|
||||
const gt = __nccwpck_require__(16599)
|
||||
@@ -67796,6 +67928,9 @@ module.exports = minVersion
|
||||
/***/ 10280:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const SemVer = __nccwpck_require__(7163)
|
||||
const Comparator = __nccwpck_require__(89379)
|
||||
const { ANY } = Comparator
|
||||
@@ -67883,6 +68018,9 @@ module.exports = outside
|
||||
/***/ 82028:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
// given a set of versions and a range, create a "simplified" range
|
||||
// that includes the same versions that the original range does
|
||||
// If the original range is shorter than the simplified one, return that.
|
||||
@@ -67937,6 +68075,9 @@ module.exports = (versions, range, options) => {
|
||||
/***/ 61489:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const Range = __nccwpck_require__(96782)
|
||||
const Comparator = __nccwpck_require__(89379)
|
||||
const { ANY } = Comparator
|
||||
@@ -68191,6 +68332,9 @@ module.exports = subset
|
||||
/***/ 54750:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const Range = __nccwpck_require__(96782)
|
||||
|
||||
// Mostly just for testing and legacy API reasons
|
||||
@@ -68206,6 +68350,9 @@ module.exports = toComparators
|
||||
/***/ 64737:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
const Range = __nccwpck_require__(96782)
|
||||
const validRange = (range, options) => {
|
||||
try {
|
||||
@@ -99583,9 +99730,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.run = void 0;
|
||||
exports.getNameFromPackageManagerField = exports.run = void 0;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const os_1 = __importDefault(__nccwpck_require__(70857));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
||||
const auth = __importStar(__nccwpck_require__(98789));
|
||||
const path = __importStar(__nccwpck_require__(16928));
|
||||
const cache_restore_1 = __nccwpck_require__(44326);
|
||||
@@ -99603,6 +99751,8 @@ function run() {
|
||||
const version = resolveVersionInput();
|
||||
let arch = core.getInput('architecture');
|
||||
const cache = core.getInput('cache');
|
||||
const packagemanagercache = (core.getInput('package-manager-cache') || 'true').toUpperCase() ===
|
||||
'TRUE';
|
||||
// if architecture supplied but node-version is not
|
||||
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
||||
if (arch && !version) {
|
||||
@@ -99636,11 +99786,19 @@ function run() {
|
||||
if (registryUrl) {
|
||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||
}
|
||||
const resolvedPackageManager = getNameFromPackageManagerField();
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
if (cache && (0, cache_utils_1.isCacheFeatureAvailable)()) {
|
||||
core.saveState(constants_1.State.CachePackageManager, cache);
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
yield (0, cache_restore_1.restoreCache)(cache, cacheDependencyPath);
|
||||
}
|
||||
else if (resolvedPackageManager && packagemanagercache) {
|
||||
core.info("Detected package manager from package.json's packageManager field: " +
|
||||
resolvedPackageManager +
|
||||
'. Auto caching has been enabled for it. If you want to disable it, set package-manager-cache input to false');
|
||||
core.saveState(constants_1.State.CachePackageManager, resolvedPackageManager);
|
||||
yield (0, cache_restore_1.restoreCache)(resolvedPackageManager, cacheDependencyPath);
|
||||
}
|
||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
|
||||
@@ -99674,6 +99832,24 @@ function resolveVersionInput() {
|
||||
}
|
||||
return version;
|
||||
}
|
||||
function getNameFromPackageManagerField() {
|
||||
// Check packageManager field in package.json
|
||||
const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
|
||||
try {
|
||||
const packageJson = JSON.parse(fs_1.default.readFileSync(path.join(process.env.GITHUB_WORKSPACE, 'package.json'), 'utf-8'));
|
||||
const pm = packageJson.packageManager;
|
||||
if (typeof pm === 'string') {
|
||||
const regex = new RegExp(`^(?:\\^)?(${SUPPORTED_PACKAGE_MANAGERS.join('|')})@`);
|
||||
const match = pm.match(regex);
|
||||
return match ? match[1] : undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.getNameFromPackageManagerField = getNameFromPackageManagerField;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@@ -45,8 +45,8 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '16'
|
||||
check-latest: true
|
||||
@@ -63,8 +63,8 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
- run: npm ci
|
||||
@@ -97,8 +97,8 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14'
|
||||
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
|
||||
@@ -118,8 +118,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '20.0.0-v8-canary' # it will install the latest v8 canary release for node 20.0.0
|
||||
- run: npm ci
|
||||
@@ -133,8 +133,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '20-v8-canary' # it will install the latest v8 canary release for node 20
|
||||
- run: npm ci
|
||||
@@ -149,8 +149,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 'v20.1.1-v8-canary20221103f7e2421e91'
|
||||
- run: npm ci
|
||||
@@ -169,8 +169,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '16-nightly' # it will install the latest nightly release for node 16
|
||||
- run: npm ci
|
||||
@@ -185,8 +185,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '16.0.0-nightly' # it will install the latest nightly release for node 16.0.0
|
||||
- run: npm ci
|
||||
@@ -201,8 +201,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '16.0.0-nightly20210420a0261d231c'
|
||||
- run: npm ci
|
||||
@@ -219,8 +219,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '16.0.0-rc.1'
|
||||
- run: npm ci
|
||||
@@ -236,8 +236,8 @@ The action follows [actions/cache](https://github.com/actions/cache/blob/main/ex
|
||||
Yarn caching handles both yarn versions: 1 or 2.
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14'
|
||||
cache: 'yarn'
|
||||
@@ -255,11 +255,11 @@ steps:
|
||||
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 6.32.9
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14'
|
||||
cache: 'pnpm'
|
||||
@@ -274,8 +274,8 @@ steps:
|
||||
**Using wildcard patterns to cache dependencies**
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14'
|
||||
cache: 'npm'
|
||||
@@ -287,8 +287,8 @@ steps:
|
||||
**Using a list of file paths to cache dependencies**
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14'
|
||||
cache: 'npm'
|
||||
@@ -324,9 +324,9 @@ jobs:
|
||||
architecture: x86
|
||||
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
@@ -337,8 +337,8 @@ jobs:
|
||||
## Publish to npmjs and GPR with npm
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
@@ -346,7 +346,7 @@ steps:
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
- run: npm publish
|
||||
@@ -357,8 +357,8 @@ steps:
|
||||
## Publish to npmjs and GPR with yarn
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14.x'
|
||||
registry-url: <registry url>
|
||||
@@ -366,7 +366,7 @@ steps:
|
||||
- run: yarn publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
- run: yarn publish
|
||||
@@ -377,8 +377,8 @@ steps:
|
||||
## Use private packages
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
@@ -397,8 +397,8 @@ Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14.x'
|
||||
- name: Setup .yarnrc.yml
|
||||
@@ -427,7 +427,7 @@ It is possible to specify a token to authenticate with the mirror using the `mir
|
||||
The token will be passed as a bearer token in the `Authorization` header.
|
||||
|
||||
```yaml
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: '14.x'
|
||||
mirror: 'https://nodejs.org/dist'
|
||||
|
2249
package-lock.json
generated
2249
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "setup-node",
|
||||
"version": "4.0.0",
|
||||
"version": "5.0.0",
|
||||
"private": true,
|
||||
"description": "setup node action",
|
||||
"main": "lib/setup-node.js",
|
||||
"engines": {
|
||||
"node": ">=24.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ncc build -o dist/setup src/setup-node.ts && ncc build -o dist/cache-save src/cache-save.ts",
|
||||
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
|
||||
@@ -38,7 +41,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.11.25",
|
||||
"@types/node": "^24.1.0",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
@@ -48,10 +51,10 @@
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"jest-circus": "^30.1.3",
|
||||
"jest-each": "^29.7.0",
|
||||
"prettier": "^2.8.4",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-jest": "^29.4.1",
|
||||
"typescript": "^5.4.2"
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import {getPackageManagerInfo} from './cache-utils';
|
||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||
|
||||
process.on('uncaughtException', e => {
|
||||
const warningPrefix = '[warning]';
|
||||
core.info(`${warningPrefix}${e.message}`);
|
||||
|
39
src/main.ts
39
src/main.ts
@@ -1,6 +1,7 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import os from 'os';
|
||||
import fs from 'fs';
|
||||
|
||||
import * as auth from './authutil';
|
||||
import * as path from 'path';
|
||||
@@ -20,6 +21,9 @@ export async function run() {
|
||||
|
||||
let arch = core.getInput('architecture');
|
||||
const cache = core.getInput('cache');
|
||||
const packagemanagercache =
|
||||
(core.getInput('package-manager-cache') || 'true').toUpperCase() ===
|
||||
'TRUE';
|
||||
|
||||
// if architecture supplied but node-version is not
|
||||
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
||||
@@ -63,10 +67,19 @@ export async function run() {
|
||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||
}
|
||||
|
||||
const resolvedPackageManager = getNameFromPackageManagerField();
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
if (cache && isCacheFeatureAvailable()) {
|
||||
core.saveState(State.CachePackageManager, cache);
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
await restoreCache(cache, cacheDependencyPath);
|
||||
} else if (resolvedPackageManager && packagemanagercache) {
|
||||
core.info(
|
||||
"Detected package manager from package.json's packageManager field: " +
|
||||
resolvedPackageManager +
|
||||
'. Auto caching has been enabled for it. If you want to disable it, set package-manager-cache input to false'
|
||||
);
|
||||
core.saveState(State.CachePackageManager, resolvedPackageManager);
|
||||
await restoreCache(resolvedPackageManager, cacheDependencyPath);
|
||||
}
|
||||
|
||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||
@@ -117,3 +130,27 @@ function resolveVersionInput(): string {
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
export function getNameFromPackageManagerField(): string | undefined {
|
||||
// Check packageManager field in package.json
|
||||
const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
|
||||
try {
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(
|
||||
path.join(process.env.GITHUB_WORKSPACE!, 'package.json'),
|
||||
'utf-8'
|
||||
)
|
||||
);
|
||||
const pm = packageJson.packageManager;
|
||||
if (typeof pm === 'string') {
|
||||
const regex = new RegExp(
|
||||
`^(?:\\^)?(${SUPPORTED_PACKAGE_MANAGERS.join('|')})@`
|
||||
);
|
||||
const match = pm.match(regex);
|
||||
return match ? match[1] : undefined;
|
||||
}
|
||||
return undefined;
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user