Resolve merge conflicts

This commit is contained in:
Maryna S 2026-02-02 21:46:00 +02:00
commit 43959a440a
91 changed files with 1837 additions and 1803 deletions

View File

@ -21,7 +21,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Clean global cache - name: Clean global cache
run: npm cache clean --force run: npm cache clean --force
- name: Setup Node - name: Setup Node
@ -44,7 +44,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Install pnpm - name: Install pnpm
uses: pnpm/action-setup@v4 uses: pnpm/action-setup@v4
with: with:
@ -77,7 +77,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Yarn version - name: Yarn version
run: yarn --version run: yarn --version
- name: Generate yarn file - name: Generate yarn file
@ -109,7 +109,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Update yarn - name: Update yarn
run: yarn set version 3.6.4 run: yarn set version 3.6.4
- name: Yarn version - name: Yarn version
@ -143,7 +143,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: __tests__/prepare-yarn-subprojects.sh yarn1 run: __tests__/prepare-yarn-subprojects.sh yarn1
@ -170,7 +170,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
@ -197,7 +197,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: __tests__/prepare-yarn-subprojects.sh global run: __tests__/prepare-yarn-subprojects.sh global
@ -224,7 +224,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache
@ -253,7 +253,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Create package.json with packageManager field - name: Create package.json with packageManager field
run: | run: |
echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json
@ -278,7 +278,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Create package.json with devEngines field - name: Create package.json with devEngines field
run: | run: |
echo '{ echo '{

View File

@ -25,7 +25,7 @@ jobs:
env: env:
https_proxy: http://squid-proxy:3128 https_proxy: http://squid-proxy:3128
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Clear tool cache - name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/* run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup node 24 - name: Setup node 24
@ -41,7 +41,7 @@ jobs:
https_proxy: http://no-such-proxy:3128 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 no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Clear tool cache - name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/* run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup node 24 - name: Setup node 24

View File

@ -14,7 +14,7 @@ jobs:
steps: steps:
- name: Checking out - name: Checking out
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@v0.0.4 uses: actions/publish-immutable-action@v0.0.4

View File

@ -20,7 +20,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -37,7 +37,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest-large]
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1] node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -64,7 +64,7 @@ jobs:
'20.0.0-v8-canary20221101e50e45c9f8' '20.0.0-v8-canary20221101e50e45c9f8'
] ]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -84,7 +84,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20-nightly, 25-nightly, 24.0.0-nightly] node-version: [20-nightly, 25-nightly, 24.0.0-nightly]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -104,7 +104,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20.0.0-rc.1, 22.14.0-rc.1, 24.0.0-rc.4] node-version: [20.0.0-rc.1, 22.14.0-rc.1, 24.0.0-rc.4]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -124,7 +124,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20.10.0, 22.0.0, 24.9.0] node-version: [20.10.0, 22.0.0, 24.9.0]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -141,7 +141,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node and check latest - name: Setup Node and check latest
uses: ./ uses: ./
with: with:
@ -160,7 +160,7 @@ jobs:
node-version-file: node-version-file:
[.nvmrc, .tool-versions, .tool-versions-node, package.json] [.nvmrc, .tool-versions, .tool-versions-node, package.json]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -175,7 +175,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -190,7 +190,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -206,7 +206,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [17, 19] node-version: [17, 19]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node from dist - name: Setup Node from dist
uses: ./ uses: ./
with: with:
@ -222,7 +222,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
# test old versions which didn't have npm and layout different # test old versions which didn't have npm and layout different
- name: Setup node 0.12.18 from dist - name: Setup node 0.12.18 from dist
uses: ./ uses: ./
@ -235,7 +235,7 @@ jobs:
arch: arch:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node 20 x86 from dist - name: Setup node 20 x86 from dist
uses: ./ uses: ./
with: with:
@ -259,7 +259,7 @@ jobs:
echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT
id: version id: version
shell: bash shell: bash
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/@actions/io-2.0.0.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/debug.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/tslib.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,6 +16,8 @@ This action provides the following functionality for GitHub Actions users:
- Caching is now automatically enabled for npm projects when either the `devEngines.packageManager` field or the top-level `packageManager` field in `package.json` is set to `npm`. For other package managers, such as Yarn and pnpm, caching is disabled by default and must be configured manually using the `cache` input. - Caching is now automatically enabled for npm projects when either the `devEngines.packageManager` field or the top-level `packageManager` field in `package.json` is set to `npm`. For other package managers, such as Yarn and pnpm, caching is disabled by default and must be configured manually using the `cache` input.
- The `always-auth` input has been removed, as it is deprecated and will no longer be supported in future npm releases. To ensure your workflows continue to run without warnings or errors, please remove any references to `always-auth` from your configuration.
## Breaking changes in V5 ## Breaking changes in V5
- Enabled caching by default with package manager detection if no cache input is provided. - Enabled caching by default with package manager detection if no cache input is provided.
@ -92,14 +94,10 @@ See [action.yml](action.yml)
# Default: '' # Default: ''
scope: '' scope: ''
# Set always-auth option in npmrc file.
# Default: ''
always-auth: ''
# Optional mirror to download binaries from. # Optional mirror to download binaries from.
# Artifacts need to match the official Node.js # Artifacts need to match the official Node.js
# Example: # Example:
# V8 Canaray Build: <mirror_url>/download/v8-canary # V8 Canary Build: <mirror_url>/download/v8-canary
# RC Build: <mirror_url>/download/rc # RC Build: <mirror_url>/download/rc
# Official: Build <mirror_url>/dist # Official: Build <mirror_url>/dist
# Nightly build: <mirror_url>/download/nightly # Nightly build: <mirror_url>/download/nightly
@ -117,7 +115,7 @@ See [action.yml](action.yml)
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24 node-version: 24
@ -125,7 +123,7 @@ steps:
- run: npm test - run: npm test
``` ```
The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and don't rely on the system one. The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and not rely on the system one.
The action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). The action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
@ -150,7 +148,7 @@ Since it will not be cached always, there is possibility of hitting rate limit w
### Checking in lockfiles ### Checking in lockfiles
It's **always** recommended to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide. It's **strongly recommended** to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide.
## Caching global packages data ## Caching global packages data
@ -166,7 +164,7 @@ See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` in
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24 node-version: 24
@ -179,7 +177,7 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24 node-version: 24
@ -195,7 +193,7 @@ This behavior is controlled by the `package-manager-cache` input, which defaults
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
package-manager-cache: false package-manager-cache: false
@ -214,7 +212,7 @@ jobs:
node: [ 20, 22, 24 ] node: [ 20, 22, 24 ]
name: Node ${{ matrix.node }} sample name: Node ${{ matrix.node }} sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node - name: Setup node
uses: actions/setup-node@v6 uses: actions/setup-node@v6
with: with:
@ -251,6 +249,7 @@ If the runner is not able to access github.com, any Nodejs versions requested du
- [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm) - [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
- [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn) - [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
- [Using private packages](docs/advanced-usage.md#use-private-packages) - [Using private packages](docs/advanced-usage.md#use-private-packages)
- [Using private mirror](docs/advanced-usage.md#use-private-mirror)
## Recommended permissions ## Recommended permissions

View File

@ -76,115 +76,102 @@ describe('authutil tests', () => {
} }
it('Sets up npmrc for npmjs', async () => { it('Sets up npmrc for npmjs', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'false'); await auth.configAuthentication('https://registry.npmjs.org/');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
const rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/'); expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
}); });
it('Appends trailing slash to registry', async () => { it('Appends trailing slash to registry', async () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false'); await auth.configAuthentication('https://registry.npmjs.org');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/'); expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
}); });
it('Configures scoped npm registries', async () => { it('Configures scoped npm registries', async () => {
process.env['INPUT_SCOPE'] = 'myScope'; process.env['INPUT_SCOPE'] = 'myScope';
await auth.configAuthentication('https://registry.npmjs.org', 'false'); await auth.configAuthentication('https://registry.npmjs.org');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/'); expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
}); });
it('Automatically configures GPR scope', async () => { it('Automatically configures GPR scope', async () => {
await auth.configAuthentication('npm.pkg.github.com', 'false'); await auth.configAuthentication('npm.pkg.github.com');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false');
});
it('Sets up npmrc for always-auth true', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('true');
}); });
it('is already set the NODE_AUTH_TOKEN export it', async () => { it('is already set the NODE_AUTH_TOKEN export it', async () => {
process.env.NODE_AUTH_TOKEN = 'foobar'; process.env.NODE_AUTH_TOKEN = 'foobar';
await auth.configAuthentication('npm.pkg.github.com', 'false'); await auth.configAuthentication('npm.pkg.github.com');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false');
expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar'); expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar');
}); });
it('configAuthentication should overwrite non-scoped with non-scoped', async () => { it('configAuthentication should overwrite non-scoped with non-scoped', async () => {
fs.writeFileSync(rcFile, 'registry=NNN'); fs.writeFileSync(rcFile, 'registry=NNN');
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
); );
}); });
it('configAuthentication should overwrite only non-scoped', async () => { it('configAuthentication should overwrite only non-scoped', async () => {
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`); fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
); );
}); });
it('configAuthentication should add non-scoped to scoped', async () => { it('configAuthentication should add non-scoped to scoped', async () => {
fs.writeFileSync(rcFile, '@myscope:registry=NNN'); fs.writeFileSync(rcFile, '@myscope:registry=NNN');
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
); );
}); });
it('configAuthentication should overwrite scoped with scoped', async () => { it('configAuthentication should overwrite scoped with scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `@myscope:registry=NNN`); fs.writeFileSync(rcFile, `@myscope:registry=NNN`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
); );
}); });
it('configAuthentication should overwrite only scoped', async () => { it('configAuthentication should overwrite only scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`); fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
); );
}); });
it('configAuthentication should add scoped to non-scoped', async () => { it('configAuthentication should add scoped to non-scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `registry=MMM`); fs.writeFileSync(rcFile, `registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
); );
}); });
@ -194,20 +181,20 @@ describe('authutil tests', () => {
rcFile, rcFile,
`@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM` `@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM`
); );
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
); );
}); });
it('configAuthentication should add scoped to another scoped', async () => { it('configAuthentication should add scoped to another scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `@otherscope:registry=MMM`); fs.writeFileSync(rcFile, `@otherscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
); );
}); });
}); });

View File

@ -227,7 +227,6 @@ describe('setup-node', () => {
const versionSpec = '11.15.0'; const versionSpec = '11.15.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -283,7 +282,6 @@ describe('setup-node', () => {
const versionSpec = '19.0.0-v8-canary'; const versionSpec = '19.0.0-v8-canary';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -324,7 +322,6 @@ describe('setup-node', () => {
inputs['node-version'] = version; inputs['node-version'] = version;
inputs['architecture'] = arch; inputs['architecture'] = arch;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = `https://nodejs.org/download/v8-canary/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; const expectedUrl = `https://nodejs.org/download/v8-canary/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
@ -569,7 +566,6 @@ describe('setup-node', () => {
const versionSpec = 'v20-v8-canary'; const versionSpec = 'v20-v8-canary';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
os.platform = 'linux'; os.platform = 'linux';

View File

@ -255,7 +255,6 @@ describe('setup-node', () => {
const versionSpec = '13.13.1-nightly20200415947ddec091'; const versionSpec = '13.13.1-nightly20200415947ddec091';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -291,7 +290,6 @@ describe('setup-node', () => {
]; ];
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -333,7 +331,6 @@ describe('setup-node', () => {
]; ];
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -389,7 +386,6 @@ describe('setup-node', () => {
const versionSpec = '18.0.0-nightly202204180699150267'; const versionSpec = '18.0.0-nightly202204180699150267';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -427,7 +423,6 @@ describe('setup-node', () => {
inputs['node-version'] = version; inputs['node-version'] = version;
inputs['architecture'] = arch; inputs['architecture'] = arch;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = `https://nodejs.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; const expectedUrl = `https://nodejs.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
@ -473,7 +468,6 @@ describe('setup-node', () => {
inputs['node-version'] = version; inputs['node-version'] = version;
inputs['architecture'] = arch; inputs['architecture'] = arch;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
inputs['mirror'] = 'https://my-mirror.org'; inputs['mirror'] = 'https://my-mirror.org';
inputs['mirror-token'] = 'my-mirror-token'; inputs['mirror-token'] = 'my-mirror-token';

View File

@ -235,7 +235,6 @@ describe('setup-node', () => {
const resolvedVersion = versionSpec; const resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = const expectedUrl =
@ -290,7 +289,6 @@ describe('setup-node', () => {
const versionSpec = '11.15.0'; const versionSpec = '11.15.0';
const mirror = 'https://my_mirror_url'; const mirror = 'https://my_mirror_url';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
inputs['mirror'] = mirror; inputs['mirror'] = mirror;
inputs['mirror-token'] = 'faketoken'; inputs['mirror-token'] = 'faketoken';
@ -327,7 +325,6 @@ describe('setup-node', () => {
const versionSpec = '11.15.0'; const versionSpec = '11.15.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -385,7 +382,6 @@ describe('setup-node', () => {
const resolvedVersion = versionSpec; const resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -405,7 +401,6 @@ describe('setup-node', () => {
const versionSpec = '11.15.0'; const versionSpec = '11.15.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -448,7 +443,6 @@ describe('setup-node', () => {
inputs['node-version'] = version; inputs['node-version'] = version;
inputs['architecture'] = arch; inputs['architecture'] = arch;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = const expectedUrl =
@ -560,7 +554,6 @@ describe('setup-node', () => {
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['check-latest'] = 'true'; inputs['check-latest'] = 'true';
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -602,7 +595,6 @@ describe('setup-node', () => {
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['check-latest'] = 'true'; inputs['check-latest'] = 'true';
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -882,7 +874,6 @@ describe('setup-node', () => {
inputs['node-version'] = version; inputs['node-version'] = version;
inputs['architecture'] = arch; inputs['architecture'] = arch;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
inputs['mirror'] = 'https://my_mirror_url'; inputs['mirror'] = 'https://my_mirror_url';
inputs['mirror-token'] = 'faketoken'; inputs['mirror-token'] = 'faketoken';

View File

@ -194,7 +194,6 @@ describe('setup-node', () => {
const versionSpec = '13.0.0-rc.0'; const versionSpec = '13.0.0-rc.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
// ... but not in the local cache // ... but not in the local cache
@ -239,7 +238,6 @@ describe('setup-node', () => {
const versionSpec = '14.7.0-rc.1'; const versionSpec = '14.7.0-rc.1';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -268,7 +266,6 @@ describe('setup-node', () => {
inputs['node-version'] = version; inputs['node-version'] = version;
inputs['architecture'] = arch; inputs['architecture'] = arch;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; const expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;

View File

@ -2,9 +2,6 @@ name: 'Setup Node.js environment'
description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.' description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.'
author: 'GitHub' author: 'GitHub'
inputs: inputs:
always-auth:
description: 'Set always-auth in npmrc.'
default: 'false'
node-version: node-version:
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.' description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.'
node-version-file: node-version-file:
@ -29,7 +26,7 @@ inputs:
cache-dependency-path: 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.' 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: mirror:
description: 'Used to specify an alternative mirror to downlooad Node.js binaries from' description: 'Used to specify an alternative mirror to download Node.js binaries from'
mirror-token: mirror-token:
description: 'The token used as Authorization header when fetching from the mirror' description: 'The token used as Authorization header when fetching from the mirror'
# TODO: add input to control forcing to pull from cloud or dist. # TODO: add input to control forcing to pull from cloud or dist.

View File

@ -88986,15 +88986,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = void 0; exports.run = void 0;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
@ -89009,31 +89000,29 @@ process.on('uncaughtException', e => {
core.info(`${warningPrefix}${e.message}`); core.info(`${warningPrefix}${e.message}`);
}); });
// Added early exit to resolve issue with slow post action step: // Added early exit to resolve issue with slow post action step:
function run(earlyExit) { async function run(earlyExit) {
return __awaiter(this, void 0, void 0, function* () { try {
try { const cacheLock = core.getState(constants_1.State.CachePackageManager);
const cacheLock = core.getState(constants_1.State.CachePackageManager); if (cacheLock) {
if (cacheLock) { await cachePackages(cacheLock);
yield cachePackages(cacheLock); if (earlyExit) {
if (earlyExit) { process.exit(0);
process.exit(0);
}
}
else {
core.debug(`Caching for '${cacheLock}' is not supported`);
} }
} }
catch (error) { else {
core.setFailed(error.message); core.debug(`Caching for '${cacheLock}' is not supported`);
} }
}); }
catch (error) {
core.setFailed(error.message);
}
} }
exports.run = run; exports.run = run;
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const cachePackages = async (packageManager) => {
const state = core.getState(constants_1.State.CacheMatchedKey); const state = core.getState(constants_1.State.CacheMatchedKey);
const primaryKey = core.getState(constants_1.State.CachePrimaryKey); const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]'); const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
const packageManagerInfo = yield (0, cache_utils_1.getPackageManagerInfo)(packageManager); const packageManagerInfo = await (0, cache_utils_1.getPackageManagerInfo)(packageManager);
if (!packageManagerInfo) { if (!packageManagerInfo) {
core.debug(`Caching for '${packageManager}' is not supported`); core.debug(`Caching for '${packageManager}' is not supported`);
return; return;
@ -89048,12 +89037,12 @@ const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, func
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
return; return;
} }
const cacheId = yield cache.saveCache(cachePaths, primaryKey); const cacheId = await cache.saveCache(cachePaths, primaryKey);
if (cacheId == -1) { if (cacheId == -1) {
return; return;
} }
core.info(`Cache saved with the key: ${primaryKey}`); core.info(`Cache saved with the key: ${primaryKey}`);
}); };
run(true); run(true);
@ -89087,15 +89076,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -89122,21 +89102,21 @@ exports.supportedPackageManagers = {
yarn: { yarn: {
name: 'yarn', name: 'yarn',
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () { getCacheFolderPath: async (projectDir) => {
const yarnVersion = yield (0, exports.getCommandOutputNotEmpty)(`yarn --version`, 'Could not retrieve version of yarn', projectDir); const yarnVersion = await (0, exports.getCommandOutputNotEmpty)(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`); core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
const stdOut = yarnVersion.startsWith('1.') const stdOut = yarnVersion.startsWith('1.')
? yield (0, exports.getCommandOutput)('yarn cache dir', projectDir) ? await (0, exports.getCommandOutput)('yarn cache dir', projectDir)
: yield (0, exports.getCommandOutput)('yarn config get cacheFolder', projectDir); : await (0, exports.getCommandOutput)('yarn config get cacheFolder', projectDir);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not get yarn cache folder path for ${projectDir}`); throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
} }
return stdOut; return stdOut;
}) }
} }
}; };
const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutput = async (toolCommand, cwd) => {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign({ ignoreReturnCode: true }, (cwd && { cwd }))); let { stdout, stderr, exitCode } = await exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true, ...(cwd && { cwd }) });
if (exitCode) { if (exitCode) {
stderr = !stderr.trim() stderr = !stderr.trim()
? `The '${toolCommand}' command failed with exit code: ${exitCode}` ? `The '${toolCommand}' command failed with exit code: ${exitCode}`
@ -89144,17 +89124,17 @@ const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0,
throw new Error(stderr); throw new Error(stderr);
} }
return stdout.trim(); return stdout.trim();
}); };
exports.getCommandOutput = getCommandOutput; exports.getCommandOutput = getCommandOutput;
const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutputNotEmpty = async (toolCommand, error, cwd) => {
const stdOut = (0, exports.getCommandOutput)(toolCommand, cwd); const stdOut = (0, exports.getCommandOutput)(toolCommand, cwd);
if (!stdOut) { if (!stdOut) {
throw new Error(error); throw new Error(error);
} }
return stdOut; return stdOut;
}); };
exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty; exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerInfo = async (packageManager) => {
if (packageManager === 'npm') { if (packageManager === 'npm') {
return exports.supportedPackageManagers.npm; return exports.supportedPackageManagers.npm;
} }
@ -89167,7 +89147,7 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
else { else {
return null; return null;
} }
}); };
exports.getPackageManagerInfo = getPackageManagerInfo; exports.getPackageManagerInfo = getPackageManagerInfo;
/** /**
* getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache` * getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache`
@ -89189,12 +89169,12 @@ exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized;
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of directories and possible * @return list of directories and possible
*/ */
const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getProjectDirectoriesFromCacheDependencyPath = async (cacheDependencyPath) => {
if (projectDirectoriesMemoized !== null) { if (projectDirectoriesMemoized !== null) {
return projectDirectoriesMemoized; return projectDirectoriesMemoized;
} }
const globber = yield glob.create(cacheDependencyPath); const globber = await glob.create(cacheDependencyPath);
const cacheDependenciesPaths = yield globber.glob(); const cacheDependenciesPaths = await globber.glob();
const existingDirectories = cacheDependenciesPaths const existingDirectories = cacheDependenciesPaths
.map(path_1.default.dirname) .map(path_1.default.dirname)
.filter((0, util_1.unique)()) .filter((0, util_1.unique)())
@ -89204,7 +89184,7 @@ const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __
core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`); core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`);
projectDirectoriesMemoized = existingDirectories; projectDirectoriesMemoized = existingDirectories;
return existingDirectories; return existingDirectories;
}); };
/** /**
* Finds the cache directories configured for the repo if cache-dependency-path is not empty * Finds the cache directories configured for the repo if cache-dependency-path is not empty
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
@ -89212,26 +89192,26 @@ const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoriesFromCacheDependencyPath = async (packageManagerInfo, cacheDependencyPath) => {
const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath); const projectDirectories = await getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () { const cacheFoldersPaths = await Promise.all(projectDirectories.map(async (projectDirectory) => {
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory); const cacheFolderPath = await packageManagerInfo.getCacheFolderPath(projectDirectory);
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`); core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
return cacheFolderPath; return cacheFolderPath;
}))); }));
// uniq in order to do not cache the same directories twice // uniq in order to do not cache the same directories twice
return cacheFoldersPaths.filter((0, util_1.unique)()); return cacheFoldersPaths.filter((0, util_1.unique)());
}); };
/** /**
* Finds the cache directories configured for the repo ignoring cache-dependency-path * Finds the cache directories configured for the repo ignoring cache-dependency-path
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoriesForRootProject = async (packageManagerInfo) => {
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(); const cacheFolderPath = await packageManagerInfo.getCacheFolderPath();
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`); core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
return [cacheFolderPath]; return [cacheFolderPath];
}); };
/** /**
* A function to find the cache directories configured for the repo * A function to find the cache directories configured for the repo
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
@ -89240,14 +89220,14 @@ const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectories = async (packageManagerInfo, cacheDependencyPath) => {
// For yarn, if cacheDependencyPath is set, ask information about cache folders in each project // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
// folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488 // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) { if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath); return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
} }
return getCacheDirectoriesForRootProject(packageManagerInfo); return getCacheDirectoriesForRootProject(packageManagerInfo);
}); };
exports.getCacheDirectories = getCacheDirectories; exports.getCacheDirectories = getCacheDirectories;
/** /**
* A function to check if the directory is a yarn project configured to manage * A function to check if the directory is a yarn project configured to manage
@ -89259,7 +89239,7 @@ exports.getCacheDirectories = getCacheDirectories;
* - if local cache is not explicitly enabled (not yarn3), return false * - if local cache is not explicitly enabled (not yarn3), return false
* - return true otherwise * - return true otherwise
*/ */
const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () { const projectHasYarnBerryManagedDependencies = async (directory) => {
const workDir = directory || process.env.GITHUB_WORKSPACE || '.'; const workDir = directory || process.env.GITHUB_WORKSPACE || '.';
core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`); core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`);
// if .yarn/cache directory exists the cache is managed by version control system // if .yarn/cache directory exists the cache is managed by version control system
@ -89270,7 +89250,7 @@ const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0,
return Promise.resolve(false); return Promise.resolve(false);
} }
// NOTE: yarn1 returns 'undefined' with return code = 0 // NOTE: yarn1 returns 'undefined' with return code = 0
const enableGlobalCache = yield (0, exports.getCommandOutput)('yarn config get enableGlobalCache', workDir); const enableGlobalCache = await (0, exports.getCommandOutput)('yarn config get enableGlobalCache', workDir);
// only local cache is not managed by yarn // only local cache is not managed by yarn
const managed = enableGlobalCache.includes('false'); const managed = enableGlobalCache.includes('false');
if (managed) { if (managed) {
@ -89281,7 +89261,7 @@ const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0,
core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`); core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`);
return false; return false;
} }
}); };
/** /**
* A function to report the repo contains Yarn managed projects * A function to report the repo contains Yarn managed projects
* @param packageManagerInfo - used to make sure current package manager is yarn * @param packageManagerInfo - used to make sure current package manager is yarn
@ -89289,15 +89269,15 @@ const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0,
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return - true if all project directories configured to be Yarn managed * @return - true if all project directories configured to be Yarn managed
*/ */
const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const repoHasYarnBerryManagedDependencies = async (packageManagerInfo, cacheDependencyPath) => {
if (packageManagerInfo.name !== 'yarn') if (packageManagerInfo.name !== 'yarn')
return false; return false;
const yarnDirs = cacheDependencyPath const yarnDirs = cacheDependencyPath
? yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath) ? await getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath)
: ['']; : [''];
const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies)); const isManagedList = await Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies));
return isManagedList.every(Boolean); return isManagedList.every(Boolean);
}); };
exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies; exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies;
function isGhes() { function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
@ -89379,15 +89359,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -89399,7 +89370,6 @@ const io = __importStar(__nccwpck_require__(4994));
const fs_1 = __importDefault(__nccwpck_require__(9896)); const fs_1 = __importDefault(__nccwpck_require__(9896));
const path_1 = __importDefault(__nccwpck_require__(6928)); const path_1 = __importDefault(__nccwpck_require__(6928));
function getNodeVersionFromFile(versionFilePath) { function getNodeVersionFromFile(versionFilePath) {
var _a, _b, _c, _d, _e;
if (!fs_1.default.existsSync(versionFilePath)) { if (!fs_1.default.existsSync(versionFilePath)) {
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`); throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
} }
@ -89411,15 +89381,15 @@ function getNodeVersionFromFile(versionFilePath) {
if (typeof manifest === 'object' && !!manifest) { if (typeof manifest === 'object' && !!manifest) {
// Support Volta. // Support Volta.
// See https://docs.volta.sh/guide/understanding#managing-your-project // See https://docs.volta.sh/guide/understanding#managing-your-project
if ((_a = manifest.volta) === null || _a === void 0 ? void 0 : _a.node) { if (manifest.volta?.node) {
return manifest.volta.node; return manifest.volta.node;
} }
if ((_b = manifest.engines) === null || _b === void 0 ? void 0 : _b.node) { if (manifest.engines?.node) {
return manifest.engines.node; return manifest.engines.node;
} }
// Support Volta workspaces. // Support Volta workspaces.
// See https://docs.volta.sh/advanced/workspaces // See https://docs.volta.sh/advanced/workspaces
if ((_c = manifest.volta) === null || _c === void 0 ? void 0 : _c.extends) { if (manifest.volta?.extends) {
const extendedFilePath = path_1.default.resolve(path_1.default.dirname(versionFilePath), manifest.volta.extends); const extendedFilePath = path_1.default.resolve(path_1.default.dirname(versionFilePath), manifest.volta.extends);
core.info('Resolving node version from ' + extendedFilePath); core.info('Resolving node version from ' + extendedFilePath);
return getNodeVersionFromFile(extendedFilePath); return getNodeVersionFromFile(extendedFilePath);
@ -89436,49 +89406,45 @@ function getNodeVersionFromFile(versionFilePath) {
return null; return null;
} }
} }
catch (_f) { catch {
core.info('Node version file is not JSON file'); core.info('Node version file is not JSON file');
} }
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m); const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
return (_e = (_d = found === null || found === void 0 ? void 0 : found.groups) === null || _d === void 0 ? void 0 : _d.version) !== null && _e !== void 0 ? _e : contents.trim(); return found?.groups?.version ?? contents.trim();
} }
exports.getNodeVersionFromFile = getNodeVersionFromFile; exports.getNodeVersionFromFile = getNodeVersionFromFile;
function printEnvDetailsAndSetOutput() { async function printEnvDetailsAndSetOutput() {
return __awaiter(this, void 0, void 0, function* () { core.startGroup('Environment details');
core.startGroup('Environment details'); const promises = ['node', 'npm', 'yarn', 'pnpm'].map(async (tool) => {
const promises = ['node', 'npm', 'yarn', 'pnpm'].map((tool) => __awaiter(this, void 0, void 0, function* () { const pathTool = await io.which(tool, false);
const pathTool = yield io.which(tool, false); const output = pathTool ? await getToolVersion(tool, ['--version']) : '';
const output = pathTool ? yield getToolVersion(tool, ['--version']) : ''; return { tool, output };
return { tool, output };
}));
const tools = yield Promise.all(promises);
tools.forEach(({ tool, output }) => {
if (tool === 'node') {
core.setOutput(`${tool}-version`, output);
}
core.info(`${tool}: ${output}`);
});
core.endGroup();
}); });
const tools = await Promise.all(promises);
tools.forEach(({ tool, output }) => {
if (tool === 'node') {
core.setOutput(`${tool}-version`, output);
}
core.info(`${tool}: ${output}`);
});
core.endGroup();
} }
exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput; exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput;
function getToolVersion(tool, options) { async function getToolVersion(tool, options) {
return __awaiter(this, void 0, void 0, function* () { try {
try { const { stdout, stderr, exitCode } = await exec.getExecOutput(tool, options, {
const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, { ignoreReturnCode: true,
ignoreReturnCode: true, silent: true
silent: true });
}); if (exitCode > 0) {
if (exitCode > 0) { core.info(`[warning]${stderr}`);
core.info(`[warning]${stderr}`);
return '';
}
return stdout.trim();
}
catch (err) {
return ''; return '';
} }
}); return stdout.trim();
}
catch (err) {
return '';
}
} }
const unique = () => { const unique = () => {
const encountered = new Set(); const encountered = new Set();

855
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ Currently, `actions/setup-node` supports caching dependencies for Npm and Yarn p
For the first iteration, we have decided to not support cases where `package-lock.json` / `yarn.lock` are located outside of repository root. For the first iteration, we have decided to not support cases where `package-lock.json` / `yarn.lock` are located outside of repository root.
Current implementation searches the following file patterns in the repository root: `package-lock.json`, `yarn.lock` (in order of resolving priorities) Current implementation searches the following file patterns in the repository root: `package-lock.json`, `yarn.lock` (in order of resolving priorities)
Obviously, it made build-in caching unusable for mono-repos and repos with complex structure. Obviously, it made built-in caching unusable for mono-repos and repos with complex structure.
We would like to revisit this decision and add customization for dependencies lock file location. We would like to revisit this decision and add customization for dependencies lock file location.
## Proposal ## Proposal
@ -24,7 +24,7 @@ The second option looks more generic because it allows to:
## Decision ## Decision
Add `cache-dependency-path` input that will accept path (relative to repository root) to dependencies lock file. Add `cache-dependency-path` input that will accept path (relative to repository root) to dependencies lock file.
If provided path contains wildcards, the action will search all maching files and calculate common hash like `${{ hashFiles('**/package-lock.json') }}` YAML construction does. If provided path contains wildcards, the action will search all matching files and calculate common hash like `${{ hashFiles('**/package-lock.json') }}` YAML construction does.
The hash of provided matched files will be used as a part of cache key. The hash of provided matched files will be used as a part of cache key.
Yaml examples: Yaml examples:

View File

@ -1,6 +1,6 @@
## Working with lockfiles ## Working with lockfiles
All supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits: Most supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
- Enables faster installation for CI and production environments, due to being able to skip package resolution. - Enables faster installation for CI and production environments, due to being able to skip package resolution.
- Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies. - Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
@ -35,6 +35,25 @@ Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lock
- [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles) - [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles)
- [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile) - [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile)
### Running without a lockfile
If you choose not to use a lockfile, you must ensure that **caching is disabled**. The `cache` feature relies on the lockfile to generate a unique key for the cache entry.
To run without a lockfile:
1. Do not set the `cache` input.
2. If your `package.json` contains a `packageManager` field set to npm (or devEngines.packageManager), automatic caching is enabled by default. Override this by setting `package-manager-cache: false`.
```yaml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
package-manager-cache: false # Explicitly disable caching if you don't have a lockfile
- run: npm install
- run: npm test
```
## Check latest version ## Check latest version
The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used. The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used.
@ -45,7 +64,7 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24' node-version: '24'
@ -63,7 +82,7 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
@ -97,7 +116,7 @@ jobs:
runs-on: windows-latest runs-on: windows-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24' node-version: '24'
@ -118,7 +137,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.0.0-v8-canary' # it will install the latest v8 canary release for node 24.0.0 node-version: '24.0.0-v8-canary' # it will install the latest v8 canary release for node 24.0.0
@ -133,7 +152,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24-v8-canary' # it will install the latest v8 canary release for node 24 node-version: '24-v8-canary' # it will install the latest v8 canary release for node 24
@ -149,7 +168,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 'v24.0.0-v8-canary2025030537242e55ac' node-version: 'v24.0.0-v8-canary2025030537242e55ac'
@ -169,7 +188,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24-nightly' # it will install the latest nightly release for node 24 node-version: '24-nightly' # it will install the latest nightly release for node 24
@ -185,7 +204,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.0.0-nightly' # it will install the latest nightly release for node 24.0.0 node-version: '24.0.0-nightly' # it will install the latest nightly release for node 24.0.0
@ -201,7 +220,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.0.0-nightly202505066102159fa1' node-version: '24.0.0-nightly202505066102159fa1'
@ -219,7 +238,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Node sample name: Node sample
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.0.0-rc.4' node-version: '24.0.0-rc.4'
@ -237,7 +256,7 @@ Yarn caching handles both Yarn Classic (v1) and Yarn Berry (v2, v3, v4+).
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24' node-version: '24'
@ -256,7 +275,7 @@ steps:
# NOTE: pnpm caching support requires pnpm version >= 6.10.0 # NOTE: pnpm caching support requires pnpm version >= 6.10.0
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: pnpm/action-setup@v4 - uses: pnpm/action-setup@v4
with: with:
version: 10 version: 10
@ -275,7 +294,7 @@ steps:
**Using wildcard patterns to cache dependencies** **Using wildcard patterns to cache dependencies**
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24' node-version: '24'
@ -288,7 +307,7 @@ steps:
**Using a list of file paths to cache dependencies** **Using a list of file paths to cache dependencies**
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24' node-version: '24'
@ -308,10 +327,10 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
# Restore Node.js modules cache (restore-only) # Restore Node.js modules cache (restore-only)
- name: Restore Node modules cache - name: Restore Node modules cache
uses: actions/cache@v4 uses: actions/cache@v5
id: cache-node-modules id: cache-node-modules
with: with:
path: ~/.npm path: ~/.npm
@ -354,7 +373,7 @@ jobs:
architecture: x86 architecture: x86
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }} name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node - name: Setup node
uses: actions/setup-node@v6 uses: actions/setup-node@v6
with: with:
@ -367,7 +386,7 @@ jobs:
## Publish to npmjs and GPR with npm ## Publish to npmjs and GPR with npm
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.x' node-version: '24.x'
@ -387,7 +406,7 @@ steps:
## Publish to npmjs and GPR with yarn ## Publish to npmjs and GPR with yarn
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.x' node-version: '24.x'
@ -407,7 +426,7 @@ steps:
## Use private packages ## Use private packages
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.x' node-version: '24.x'
@ -427,7 +446,7 @@ Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: '24.x' node-version: '24.x'
@ -446,9 +465,6 @@ To access private GitHub Packages within the same organization, go to "Manage Ac
Please refer to the [Ensuring workflow access to your package - Configuring a package's access control and visibility](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility#ensuring-workflow-access-to-your-package) for more details. Please refer to the [Ensuring workflow access to your package - Configuring a package's access control and visibility](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility#ensuring-workflow-access-to-your-package) for more details.
### always-auth input
The always-auth input sets `always-auth=true` in .npmrc file. With this option set [npm](https://docs.npmjs.com/cli/v6/using-npm/config#always-auth)/yarn sends the authentication credentials when making a request to the registries.
## Use private mirror ## Use private mirror
It is possible to use a private mirror hosting Node.js binaries. This mirror must be a full mirror of the official Node.js distribution. It is possible to use a private mirror hosting Node.js binaries. This mirror must be a full mirror of the official Node.js distribution.

2306
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-node", "name": "setup-node",
"version": "6.0.0", "version": "6.2.0",
"private": true, "private": true,
"description": "setup node action", "description": "setup node action",
"main": "lib/setup-node.js", "main": "lib/setup-node.js",
@ -28,7 +28,7 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^4.0.3", "@actions/cache": "^5.0.1",
"@actions/core": "^1.11.1", "@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.1", "@actions/github": "^6.0.1",

View File

@ -4,7 +4,7 @@ import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as github from '@actions/github'; import * as github from '@actions/github';
export function configAuthentication(registryUrl: string, alwaysAuth: string) { export function configAuthentication(registryUrl: string) {
const npmrc: string = path.resolve( const npmrc: string = path.resolve(
process.env['RUNNER_TEMP'] || process.cwd(), process.env['RUNNER_TEMP'] || process.cwd(),
'.npmrc' '.npmrc'
@ -13,14 +13,10 @@ export function configAuthentication(registryUrl: string, alwaysAuth: string) {
registryUrl += '/'; registryUrl += '/';
} }
writeRegistryToFile(registryUrl, npmrc, alwaysAuth); writeRegistryToFile(registryUrl, npmrc);
} }
function writeRegistryToFile( function writeRegistryToFile(registryUrl: string, fileLocation: string) {
registryUrl: string,
fileLocation: string,
alwaysAuth: string
) {
let scope: string = core.getInput('scope'); let scope: string = core.getInput('scope');
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
scope = github.context.repo.owner; scope = github.context.repo.owner;
@ -47,8 +43,7 @@ function writeRegistryToFile(
const authString: string = const authString: string =
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = `${scope}registry=${registryUrl}`; const registryString = `${scope}registry=${registryUrl}`;
const alwaysAuthString = `always-auth=${alwaysAuth}`; newContents += `${authString}${os.EOL}${registryString}`;
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
fs.writeFileSync(fileLocation, newContents); fs.writeFileSync(fileLocation, newContents);
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
// Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it // Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it

View File

@ -62,9 +62,8 @@ export async function run() {
await printEnvDetailsAndSetOutput(); await printEnvDetailsAndSetOutput();
const registryUrl: string = core.getInput('registry-url'); const registryUrl: string = core.getInput('registry-url');
const alwaysAuth: string = core.getInput('always-auth');
if (registryUrl) { if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth); auth.configAuthentication(registryUrl);
} }
const cacheDependencyPath = core.getInput('cache-dependency-path'); const cacheDependencyPath = core.getInput('cache-dependency-path');

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */ "outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */