Remove always-auth configuration handling from action (#1436)

* Remove always-auth configuration handling from setup-node

* docs: update README to note always-auth removal

Update README to mention removal of always-auth input

* Clarify removal of 'always-auth' input in README

Updated the description of the 'always-auth' input removal for clarity.
This commit is contained in:
Priya Gupta
2025-11-26 23:07:55 +05:30
committed by GitHub
parent 633bb92bc0
commit b9b25d45f7
11 changed files with 34 additions and 85 deletions

View File

@@ -4,7 +4,7 @@ import * as path from 'path';
import * as core from '@actions/core';
import * as github from '@actions/github';
export function configAuthentication(registryUrl: string, alwaysAuth: string) {
export function configAuthentication(registryUrl: string) {
const npmrc: string = path.resolve(
process.env['RUNNER_TEMP'] || process.cwd(),
'.npmrc'
@@ -13,14 +13,10 @@ export function configAuthentication(registryUrl: string, alwaysAuth: string) {
registryUrl += '/';
}
writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
writeRegistryToFile(registryUrl, npmrc);
}
function writeRegistryToFile(
registryUrl: string,
fileLocation: string,
alwaysAuth: string
) {
function writeRegistryToFile(registryUrl: string, fileLocation: string) {
let scope: string = core.getInput('scope');
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
scope = github.context.repo.owner;
@@ -47,8 +43,7 @@ function writeRegistryToFile(
const authString: string =
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = `${scope}registry=${registryUrl}`;
const alwaysAuthString = `always-auth=${alwaysAuth}`;
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
newContents += `${authString}${os.EOL}${registryString}`;
fs.writeFileSync(fileLocation, newContents);
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

View File

@@ -62,9 +62,8 @@ export async function run() {
await printEnvDetailsAndSetOutput();
const registryUrl: string = core.getInput('registry-url');
const alwaysAuth: string = core.getInput('always-auth');
if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth);
auth.configAuthentication(registryUrl);
}
const cacheDependencyPath = core.getInput('cache-dependency-path');