Compare commits

...

5 Commits

Author SHA1 Message Date
Jason Karns
769c1a07f2
Merge 55b7d827be into 7e24a656e1 2025-07-15 13:28:49 -04:00
dependabot[bot]
7e24a656e1
Bump uuid from 9.0.1 to 11.1.0 (#1273)
* Bump uuid from 9.0.1 to 11.1.0

Bumps [uuid](https://github.com/uuidjs/uuid) from 9.0.1 to 11.1.0.
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v9.0.1...v11.1.0)

---
updated-dependencies:
- dependency-name: uuid
  dependency-version: 11.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump uuid from 9.0.1 to 11.1.0

Bumps [uuid](https://github.com/uuidjs/uuid) from 9.0.1 to 11.1.0.
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v9.0.1...v11.1.0)

---
updated-dependencies:
- dependency-name: uuid
  dependency-version: 11.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix failures

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: HarithaVattikuti <73516759+HarithaVattikuti@users.noreply.github.com>
2025-07-15 12:28:04 -05:00
Jason Karns
55b7d827be
Refactor and test 2024-05-29 08:52:52 -04:00
Jason Karns
473cb1b506
Make linter happy 2024-05-28 16:13:11 -04:00
Jason Karns
574c6daa52
Spike to default the scope from package.json 2024-05-28 16:13:08 -04:00
6 changed files with 657 additions and 691 deletions

View File

@ -1,9 +1,9 @@
--- ---
name: uuid name: uuid
version: 9.0.1 version: 11.1.0
type: npm type: npm
summary: RFC4122 (v1, v4, and v5) UUIDs summary: RFC9562 UUIDs
homepage: homepage:
license: mit license: mit
licenses: licenses:
- sources: LICENSE.md - sources: LICENSE.md

View File

@ -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();

1300
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

11
package-lock.json generated
View File

@ -18,7 +18,7 @@
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.2", "@actions/tool-cache": "^2.0.2",
"semver": "^7.6.3", "semver": "^7.6.3",
"uuid": "^9.0.1" "uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.14", "@types/jest": "^29.5.14",
@ -5433,15 +5433,16 @@
} }
}, },
"node_modules/uuid": { "node_modules/uuid": {
"version": "9.0.1", "version": "11.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz",
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
"funding": [ "funding": [
"https://github.com/sponsors/broofa", "https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan" "https://github.com/sponsors/ctavan"
], ],
"license": "MIT",
"bin": { "bin": {
"uuid": "dist/bin/uuid" "uuid": "dist/esm/bin/uuid"
} }
}, },
"node_modules/v8-to-istanbul": { "node_modules/v8-to-istanbul": {

View File

@ -34,7 +34,7 @@
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.2", "@actions/tool-cache": "^2.0.2",
"semver": "^7.6.3", "semver": "^7.6.3",
"uuid": "^9.0.1" "uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.14", "@types/jest": "^29.5.14",

View File

@ -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`);
}
}