mirror of
https://github.com/actions/setup-node.git
synced 2026-03-07 06:51:46 +08:00
Compare commits
5 Commits
033d271d2d
...
3c2af66999
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c2af66999 | ||
|
|
395ad32622 | ||
|
|
a4d2e2bbca | ||
|
|
b9b25d45f7 | ||
|
|
fc2e41dd00 |
20
.github/workflows/e2e-cache.yml
vendored
20
.github/workflows/e2e-cache.yml
vendored
@ -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 '{
|
||||||
|
|||||||
4
.github/workflows/proxy.yml
vendored
4
.github/workflows/proxy.yml
vendored
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
28
.github/workflows/versions.yml
vendored
28
.github/workflows/versions.yml
vendored
@ -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:
|
||||||
|
|||||||
@ -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,10 +94,6 @@ 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:
|
||||||
|
|||||||
@ -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/`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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';
|
||||||
|
|||||||
@ -133,10 +133,11 @@ describe('main tests', () => {
|
|||||||
|
|
||||||
describe('printEnvDetailsAndSetOutput', () => {
|
describe('printEnvDetailsAndSetOutput', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[{node: '12.0.2', npm: '6.3.3', yarn: '1.22.11'}],
|
[{node: '12.0.2', npm: '6.3.3', yarn: '1.22.11', pnpm: ''}],
|
||||||
[{node: '16.0.2', npm: '7.3.3', yarn: '2.22.11'}],
|
[{node: '16.0.2', npm: '7.3.3', yarn: '2.22.11', pnpm: ''}],
|
||||||
[{node: '14.0.1', npm: '8.1.0', yarn: '3.2.1'}],
|
[{node: '14.0.1', npm: '8.1.0', yarn: '3.2.1', pnpm: ''}],
|
||||||
[{node: '17.0.2', npm: '6.3.3', yarn: ''}]
|
[{node: '17.0.2', npm: '6.3.3', yarn: '', pnpm: ''}],
|
||||||
|
[{node: '24.10.0', npm: '11.6.1', yarn: '', pnpm: '10.18.3'}]
|
||||||
])('Tools versions %p', async obj => {
|
])('Tools versions %p', async obj => {
|
||||||
getExecOutputSpy.mockImplementation(async command => {
|
getExecOutputSpy.mockImplementation(async command => {
|
||||||
if (Reflect.has(obj, command) && !obj[command]) {
|
if (Reflect.has(obj, command) && !obj[command]) {
|
||||||
|
|||||||
@ -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';
|
||||||
|
|||||||
@ -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';
|
||||||
|
|||||||
@ -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}`;
|
||||||
|
|||||||
@ -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:
|
||||||
|
|||||||
2
dist/cache-save/index.js
vendored
2
dist/cache-save/index.js
vendored
@ -89521,7 +89521,7 @@ exports.getNodeVersionFromFile = getNodeVersionFromFile;
|
|||||||
function printEnvDetailsAndSetOutput() {
|
function printEnvDetailsAndSetOutput() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.startGroup('Environment details');
|
core.startGroup('Environment details');
|
||||||
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
const promises = ['node', 'npm', 'yarn', 'pnpm'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
||||||
const pathTool = yield io.which(tool, false);
|
const pathTool = yield io.which(tool, false);
|
||||||
const output = pathTool ? yield getToolVersion(tool, ['--version']) : '';
|
const output = pathTool ? yield getToolVersion(tool, ['--version']) : '';
|
||||||
return { tool, output };
|
return { tool, output };
|
||||||
|
|||||||
14
dist/setup/index.js
vendored
14
dist/setup/index.js
vendored
@ -98589,15 +98589,15 @@ const os = __importStar(__nccwpck_require__(70857));
|
|||||||
const path = __importStar(__nccwpck_require__(16928));
|
const path = __importStar(__nccwpck_require__(16928));
|
||||||
const core = __importStar(__nccwpck_require__(37484));
|
const core = __importStar(__nccwpck_require__(37484));
|
||||||
const github = __importStar(__nccwpck_require__(93228));
|
const github = __importStar(__nccwpck_require__(93228));
|
||||||
function configAuthentication(registryUrl, alwaysAuth) {
|
function configAuthentication(registryUrl) {
|
||||||
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
|
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
|
||||||
if (!registryUrl.endsWith('/')) {
|
if (!registryUrl.endsWith('/')) {
|
||||||
registryUrl += '/';
|
registryUrl += '/';
|
||||||
}
|
}
|
||||||
writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
|
writeRegistryToFile(registryUrl, npmrc);
|
||||||
}
|
}
|
||||||
exports.configAuthentication = configAuthentication;
|
exports.configAuthentication = configAuthentication;
|
||||||
function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
|
function writeRegistryToFile(registryUrl, fileLocation) {
|
||||||
let scope = core.getInput('scope');
|
let scope = 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;
|
||||||
@ -98622,8 +98622,7 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
|
|||||||
// Remove http: or https: from front of registry.
|
// Remove http: or https: from front of registry.
|
||||||
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
const authString = 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
|
||||||
@ -99857,9 +99856,8 @@ function run() {
|
|||||||
}
|
}
|
||||||
yield (0, util_1.printEnvDetailsAndSetOutput)();
|
yield (0, util_1.printEnvDetailsAndSetOutput)();
|
||||||
const registryUrl = core.getInput('registry-url');
|
const registryUrl = core.getInput('registry-url');
|
||||||
const alwaysAuth = 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');
|
||||||
if ((0, cache_utils_1.isCacheFeatureAvailable)()) {
|
if ((0, cache_utils_1.isCacheFeatureAvailable)()) {
|
||||||
@ -100036,7 +100034,7 @@ exports.getNodeVersionFromFile = getNodeVersionFromFile;
|
|||||||
function printEnvDetailsAndSetOutput() {
|
function printEnvDetailsAndSetOutput() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.startGroup('Environment details');
|
core.startGroup('Environment details');
|
||||||
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
const promises = ['node', 'npm', 'yarn', 'pnpm'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
||||||
const pathTool = yield io.which(tool, false);
|
const pathTool = yield io.which(tool, false);
|
||||||
const output = pathTool ? yield getToolVersion(tool, ['--version']) : '';
|
const output = pathTool ? yield getToolVersion(tool, ['--version']) : '';
|
||||||
return { tool, output };
|
return { tool, output };
|
||||||
|
|||||||
@ -446,9 +446,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.
|
||||||
|
|||||||
14
package-lock.json
generated
14
package-lock.json
generated
@ -994,10 +994,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
|
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
|
||||||
"version": "3.14.1",
|
"version": "3.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
|
||||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
"integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^1.0.7",
|
"argparse": "^1.0.7",
|
||||||
"esprima": "^4.0.0"
|
"esprima": "^4.0.0"
|
||||||
@ -4315,10 +4316,11 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/js-yaml": {
|
"node_modules/js-yaml": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
||||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^2.0.1"
|
"argparse": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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');
|
||||||
|
|||||||
@ -62,7 +62,7 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
|||||||
|
|
||||||
export async function printEnvDetailsAndSetOutput() {
|
export async function printEnvDetailsAndSetOutput() {
|
||||||
core.startGroup('Environment details');
|
core.startGroup('Environment details');
|
||||||
const promises = ['node', 'npm', 'yarn'].map(async tool => {
|
const promises = ['node', 'npm', 'yarn', 'pnpm'].map(async tool => {
|
||||||
const pathTool = await io.which(tool, false);
|
const pathTool = await io.which(tool, false);
|
||||||
const output = pathTool ? await getToolVersion(tool, ['--version']) : '';
|
const output = pathTool ? await getToolVersion(tool, ['--version']) : '';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user