mirror of
https://github.com/actions/setup-node.git
synced 2026-03-10 07:01:46 +08:00
Compare commits
5 Commits
30da1dd3c1
...
769c1a07f2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
769c1a07f2 | ||
|
|
7e24a656e1 | ||
|
|
55b7d827be | ||
|
|
473cb1b506 | ||
|
|
574c6daa52 |
@ -1,8 +1,8 @@
|
||||
---
|
||||
name: uuid
|
||||
version: 9.0.1
|
||||
version: 11.1.0
|
||||
type: npm
|
||||
summary: RFC4122 (v1, v4, and v5) UUIDs
|
||||
summary: RFC9562 UUIDs
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
@ -7,6 +7,7 @@ import * as auth from '../src/authutil';
|
||||
import * as cacheUtils from '../src/cache-utils';
|
||||
|
||||
let rcFile: string;
|
||||
let pkgJson: string;
|
||||
|
||||
describe('authutil tests', () => {
|
||||
const _runnerDir = path.join(__dirname, 'runner');
|
||||
@ -25,10 +26,12 @@ describe('authutil tests', () => {
|
||||
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
rcFile = path.join(tempDir, '.npmrc');
|
||||
pkgJson = path.join(tempDir, 'package.json');
|
||||
}, 100000);
|
||||
|
||||
beforeEach(async () => {
|
||||
await io.rmRF(rcFile);
|
||||
await io.rmRF(pkgJson);
|
||||
// if (fs.existsSync(rcFile)) {
|
||||
// fs.unlinkSync(rcFile);
|
||||
// }
|
||||
@ -113,6 +116,15 @@ describe('authutil tests', () => {
|
||||
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 () => {
|
||||
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||
expect(fs.statSync(rcFile)).toBeDefined();
|
||||
|
||||
1300
dist/setup/index.js
vendored
1300
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
11
package-lock.json
generated
11
package-lock.json
generated
@ -18,7 +18,7 @@
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"semver": "^7.6.3",
|
||||
"uuid": "^9.0.1"
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@ -5433,15 +5433,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
|
||||
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz",
|
||||
"integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
"uuid": "dist/esm/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-to-istanbul": {
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"semver": "^7.6.3",
|
||||
"uuid": "^9.0.1"
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
|
||||
@ -25,6 +25,12 @@ function writeRegistryToFile(
|
||||
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
|
||||
scope = github.context.repo.owner;
|
||||
}
|
||||
if (!scope) {
|
||||
const namePrefix = packageJson('name')?.match(/^(@[^/]+)\//);
|
||||
if (namePrefix) {
|
||||
scope = namePrefix[1];
|
||||
}
|
||||
}
|
||||
if (scope && scope[0] != '@') {
|
||||
scope = '@' + scope;
|
||||
}
|
||||
@ -57,3 +63,14 @@ function writeRegistryToFile(
|
||||
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