mirror of
https://github.com/actions/setup-node.git
synced 2026-03-04 06:51:04 +08:00
Compare commits
5 Commits
9f4be578ca
...
e2766292fb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2766292fb | ||
|
|
48b90677b6 | ||
|
|
55b7d827be | ||
|
|
473cb1b506 | ||
|
|
574c6daa52 |
8
.github/workflows/e2e-cache.yml
vendored
8
.github/workflows/e2e-cache.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18, 20, 22]
|
node-version: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -41,7 +41,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18, 20, 22]
|
node-version: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -74,7 +74,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18, 20]
|
node-version: [18, 20]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -106,7 +106,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18, 20, 22]
|
node-version: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
@ -22,7 +22,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
uses: actions/publish-action@v0.2.2
|
uses: actions/publish-action@v0.3.0
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|||||||
22
.github/workflows/versions.yml
vendored
22
.github/workflows/versions.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18, 20, 22]
|
node-version: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -56,7 +56,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version:
|
node-version:
|
||||||
[
|
[
|
||||||
'20-v8-canary',
|
'20-v8-canary',
|
||||||
@ -81,7 +81,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version:
|
node-version:
|
||||||
[20.11.0-nightly202312211a0be537da, 21-nightly, 18.0.0-nightly]
|
[20.11.0-nightly202312211a0be537da, 21-nightly, 18.0.0-nightly]
|
||||||
steps:
|
steps:
|
||||||
@ -102,7 +102,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [20.0.0-rc.1, 18.0.0-rc.2, 19.0.0-rc.0]
|
node-version: [20.0.0-rc.1, 18.0.0-rc.2, 19.0.0-rc.0]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -122,7 +122,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18.20.0, 20.10.0, 22.0.0]
|
node-version: [18.20.0, 20.10.0, 22.0.0]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -139,7 +139,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [18, 20, 22]
|
node-version: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -157,7 +157,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version-file:
|
node-version-file:
|
||||||
[.nvmrc, .tool-versions, .tool-versions-node, package.json]
|
[.nvmrc, .tool-versions, .tool-versions-node, package.json]
|
||||||
steps:
|
steps:
|
||||||
@ -174,7 +174,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup node from node version file
|
- name: Setup node from node version file
|
||||||
@ -189,7 +189,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup node from node version file
|
- name: Setup node from node version file
|
||||||
@ -204,7 +204,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [17, 19]
|
node-version: [17, 19]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -251,7 +251,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
node-version: [current, latest, node]
|
node-version: [current, latest, node]
|
||||||
steps:
|
steps:
|
||||||
- name: Get node version
|
- name: Get node version
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import * as auth from '../src/authutil';
|
|||||||
import * as cacheUtils from '../src/cache-utils';
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
|
||||||
let rcFile: string;
|
let rcFile: string;
|
||||||
|
let pkgJson: string;
|
||||||
|
|
||||||
describe('authutil tests', () => {
|
describe('authutil tests', () => {
|
||||||
const _runnerDir = path.join(__dirname, 'runner');
|
const _runnerDir = path.join(__dirname, 'runner');
|
||||||
@ -25,10 +26,12 @@ describe('authutil tests', () => {
|
|||||||
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
|
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
|
||||||
process.env['RUNNER_TEMP'] = tempDir;
|
process.env['RUNNER_TEMP'] = tempDir;
|
||||||
rcFile = path.join(tempDir, '.npmrc');
|
rcFile = path.join(tempDir, '.npmrc');
|
||||||
|
pkgJson = path.join(tempDir, 'package.json');
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await io.rmRF(rcFile);
|
await io.rmRF(rcFile);
|
||||||
|
await io.rmRF(pkgJson);
|
||||||
// if (fs.existsSync(rcFile)) {
|
// if (fs.existsSync(rcFile)) {
|
||||||
// fs.unlinkSync(rcFile);
|
// fs.unlinkSync(rcFile);
|
||||||
// }
|
// }
|
||||||
@ -113,6 +116,15 @@ describe('authutil tests', () => {
|
|||||||
expect(rc['always-auth']).toBe('false');
|
expect(rc['always-auth']).toBe('false');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Automatically configures npm scope from package.json', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = '';
|
||||||
|
fs.writeFileSync(pkgJson, '{"name":"@myscope/mypackage"}');
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org', '');
|
||||||
|
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
|
||||||
|
});
|
||||||
|
|
||||||
it('Sets up npmrc for always-auth true', async () => {
|
it('Sets up npmrc for always-auth true', async () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
expect(fs.statSync(rcFile)).toBeDefined();
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@ -2588,9 +2588,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
|
|||||||
@ -25,6 +25,12 @@ function writeRegistryToFile(
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
if (!scope) {
|
||||||
|
const namePrefix = packageJson('name')?.match(/^(@[^/]+)\//);
|
||||||
|
if (namePrefix) {
|
||||||
|
scope = namePrefix[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
if (scope && scope[0] != '@') {
|
if (scope && scope[0] != '@') {
|
||||||
scope = '@' + scope;
|
scope = '@' + scope;
|
||||||
}
|
}
|
||||||
@ -57,3 +63,14 @@ function writeRegistryToFile(
|
|||||||
process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX'
|
process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function packageJson(prop: string){
|
||||||
|
const pkgPath: string = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), 'package.json');
|
||||||
|
try {
|
||||||
|
const json = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||||
|
|
||||||
|
return prop ? json[prop] : json;
|
||||||
|
} catch(e) {
|
||||||
|
core.debug(`Unable to read from package.json`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user