mirror of
https://github.com/actions/setup-node.git
synced 2026-03-07 06:51:46 +08:00
Compare commits
3 Commits
8f3db0819a
...
23362d7cc2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23362d7cc2 | ||
|
|
367970386b | ||
|
|
d721415790 |
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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
# 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@v6
|
- uses: actions/checkout@v5
|
||||||
- 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@v6
|
- uses: actions/checkout@v5
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
|||||||
11
README.md
11
README.md
@ -16,8 +16,6 @@ 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.
|
||||||
@ -94,6 +92,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:
|
||||||
@ -148,7 +150,7 @@ Since it will not be cached always, there is possibility of hitting rate limit w
|
|||||||
|
|
||||||
### Checking in lockfiles
|
### Checking in lockfiles
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
## Caching global packages data
|
## Caching global packages data
|
||||||
|
|
||||||
@ -249,7 +251,6 @@ 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
|
||||||
|
|
||||||
@ -270,4 +271,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
|||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
||||||
@ -76,102 +76,115 @@ describe('authutil tests', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('Sets up npmrc for npmjs', async () => {
|
it('Sets up npmrc for npmjs', async () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'false');
|
||||||
|
|
||||||
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');
|
await auth.configAuthentication('https://registry.npmjs.org', 'false');
|
||||||
|
|
||||||
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');
|
await auth.configAuthentication('https://registry.npmjs.org', 'false');
|
||||||
|
|
||||||
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');
|
await auth.configAuthentication('npm.pkg.github.com', 'false');
|
||||||
|
|
||||||
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');
|
await auth.configAuthentication('npm.pkg.github.com', 'false');
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -181,20 +194,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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`@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`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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/');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
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/`
|
`@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`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -227,6 +227,7 @@ 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
|
||||||
@ -282,6 +283,7 @@ 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(() => '');
|
||||||
@ -322,6 +324,7 @@ 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}`;
|
||||||
@ -566,6 +569,7 @@ 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';
|
||||||
|
|||||||
@ -255,6 +255,7 @@ 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
|
||||||
@ -290,6 +291,7 @@ 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
|
||||||
@ -331,6 +333,7 @@ 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
|
||||||
@ -386,6 +389,7 @@ 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(() => '');
|
||||||
@ -423,6 +427,7 @@ 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}`;
|
||||||
@ -468,6 +473,7 @@ 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,6 +235,7 @@ 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 =
|
||||||
@ -289,6 +290,7 @@ 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';
|
||||||
@ -325,6 +327,7 @@ 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
|
||||||
@ -382,6 +385,7 @@ 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(() => '');
|
||||||
@ -401,6 +405,7 @@ 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
|
||||||
@ -443,6 +448,7 @@ 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 =
|
||||||
@ -554,6 +560,7 @@ 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
|
||||||
@ -595,6 +602,7 @@ 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
|
||||||
@ -874,6 +882,7 @@ 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,6 +194,7 @@ 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
|
||||||
@ -238,6 +239,7 @@ 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(() => '');
|
||||||
@ -266,6 +268,7 @@ 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,6 +2,9 @@ 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:
|
||||||
|
|||||||
12
dist/setup/index.js
vendored
12
dist/setup/index.js
vendored
@ -102407,15 +102407,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) {
|
function configAuthentication(registryUrl, alwaysAuth) {
|
||||||
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);
|
writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
|
||||||
}
|
}
|
||||||
exports.configAuthentication = configAuthentication;
|
exports.configAuthentication = configAuthentication;
|
||||||
function writeRegistryToFile(registryUrl, fileLocation) {
|
function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
|
||||||
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;
|
||||||
@ -102440,7 +102440,8 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
|||||||
// 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}`;
|
||||||
newContents += `${authString}${os.EOL}${registryString}`;
|
const alwaysAuthString = `always-auth=${alwaysAuth}`;
|
||||||
|
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
|
||||||
@ -103674,8 +103675,9 @@ 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);
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
}
|
}
|
||||||
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)()) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
## Working with lockfiles
|
## Working with lockfiles
|
||||||
|
|
||||||
Most supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
|
All 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,25 +35,6 @@ 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.
|
||||||
@ -465,6 +446,9 @@ 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.
|
||||||
|
|||||||
16
package-lock.json
generated
16
package-lock.json
generated
@ -17,7 +17,7 @@
|
|||||||
"@actions/http-client": "^2.2.1",
|
"@actions/http-client": "^2.2.1",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^2.0.2",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"js-toml": "^1.0.2",
|
"js-toml": "1.0.2",
|
||||||
"semver": "^7.6.3",
|
"semver": "^7.6.3",
|
||||||
"uuid": "^11.1.0"
|
"uuid": "^11.1.0"
|
||||||
},
|
},
|
||||||
@ -1046,11 +1046,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
|
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
|
||||||
"version": "3.14.2",
|
"version": "3.14.1",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||||
"integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
|
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^1.0.7",
|
"argparse": "^1.0.7",
|
||||||
"esprima": "^4.0.0"
|
"esprima": "^4.0.0"
|
||||||
@ -4403,11 +4402,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/js-yaml": {
|
"node_modules/js-yaml": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^2.0.1"
|
"argparse": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
"@actions/http-client": "^2.2.1",
|
"@actions/http-client": "^2.2.1",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^2.0.2",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"js-toml": "^1.0.2",
|
"js-toml": "1.0.2",
|
||||||
"semver": "^7.6.3",
|
"semver": "^7.6.3",
|
||||||
"uuid": "^11.1.0"
|
"uuid": "^11.1.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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) {
|
export function configAuthentication(registryUrl: string, alwaysAuth: 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,10 +13,14 @@ export function configAuthentication(registryUrl: string) {
|
|||||||
registryUrl += '/';
|
registryUrl += '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
writeRegistryToFile(registryUrl, npmrc);
|
writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
function writeRegistryToFile(
|
||||||
|
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;
|
||||||
@ -43,7 +47,8 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
|||||||
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}`;
|
||||||
newContents += `${authString}${os.EOL}${registryString}`;
|
const alwaysAuthString = `always-auth=${alwaysAuth}`;
|
||||||
|
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,8 +62,9 @@ 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);
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user