mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2024-11-24 02:51:01 -05:00
Feedback
This commit is contained in:
parent
8e12aec29e
commit
920661f1be
5 changed files with 15 additions and 18 deletions
|
@ -61,7 +61,8 @@ steps:
|
|||
with:
|
||||
version: '10.x'
|
||||
registry-url: <registry url>
|
||||
- run: npm install
|
||||
- run: npm install -g yarn
|
||||
- run: yarn install
|
||||
- run: yarn publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
||||
|
|
|
@ -11,13 +11,11 @@ const fs = __importStar(require("fs"));
|
|||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
function configAuth(registryUrl) {
|
||||
let npmrc = path.resolve(process.cwd(), '.npmrc');
|
||||
let yarnrc = path.resolve(process.cwd(), '.yarnrc');
|
||||
function configAuthentication(registryUrl) {
|
||||
const npmrc = path.resolve(process.cwd(), '.npmrc');
|
||||
writeRegistryToFile(registryUrl, npmrc);
|
||||
writeRegistryToFile(registryUrl, yarnrc);
|
||||
}
|
||||
exports.configAuth = configAuth;
|
||||
exports.configAuthentication = configAuthentication;
|
||||
function writeRegistryToFile(registryUrl, fileLocation) {
|
||||
core.debug(`Setting auth in ${fileLocation}`);
|
||||
let newContents = '';
|
||||
|
@ -25,7 +23,7 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
|||
const curContents = fs.readFileSync(fileLocation, 'utf8');
|
||||
curContents.split(os.EOL).forEach((line) => {
|
||||
// Add current contents unless they are setting the registry
|
||||
if (!line.startsWith('registry')) {
|
||||
if (!line.toLowerCase().startsWith('registry')) {
|
||||
newContents += line + os.EOL;
|
||||
}
|
||||
});
|
||||
|
@ -36,7 +34,7 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
|||
os.EOL +
|
||||
'always-auth=true' +
|
||||
os.EOL +
|
||||
registryUrl.replace(/(^\w+:|^)/, '') +
|
||||
registryUrl.replace(/(^\w+:|^)/, '') + // Remove http: or https: from front of registry.
|
||||
':_authToken=${NODE_AUTH_TOKEN}';
|
||||
fs.writeFileSync(fileLocation, newContents);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ function run() {
|
|||
}
|
||||
const registryUrl = core.getInput('registry-url');
|
||||
if (registryUrl) {
|
||||
auth.configAuth(registryUrl);
|
||||
auth.configAuthentication(registryUrl);
|
||||
}
|
||||
// TODO: setup proxy from runner proxy config
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
|
|
|
@ -3,22 +3,20 @@ import * as os from 'os';
|
|||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export function configAuth(registryUrl: string) {
|
||||
let npmrc: string = path.resolve(process.cwd(), '.npmrc');
|
||||
let yarnrc: string = path.resolve(process.cwd(), '.yarnrc');
|
||||
export function configAuthentication(registryUrl: string) {
|
||||
const npmrc: string = path.resolve(process.cwd(), '.npmrc');
|
||||
|
||||
writeRegistryToFile(registryUrl, npmrc);
|
||||
writeRegistryToFile(registryUrl, yarnrc);
|
||||
}
|
||||
|
||||
function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
||||
core.debug(`Setting auth in ${fileLocation}`);
|
||||
let newContents = '';
|
||||
if (fs.existsSync(fileLocation)) {
|
||||
const curContents = fs.readFileSync(fileLocation, 'utf8');
|
||||
const curContents: string = fs.readFileSync(fileLocation, 'utf8');
|
||||
curContents.split(os.EOL).forEach((line: string) => {
|
||||
// Add current contents unless they are setting the registry
|
||||
if (!line.startsWith('registry')) {
|
||||
if (!line.toLowerCase().startsWith('registry')) {
|
||||
newContents += line + os.EOL;
|
||||
}
|
||||
});
|
||||
|
@ -29,7 +27,7 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
|||
os.EOL +
|
||||
'always-auth=true' +
|
||||
os.EOL +
|
||||
registryUrl.replace(/(^\w+:|^)/, '') +
|
||||
registryUrl.replace(/(^\w+:|^)/, '') + // Remove http: or https: from front of registry.
|
||||
':_authToken=${NODE_AUTH_TOKEN}';
|
||||
fs.writeFileSync(fileLocation, newContents);
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ async function run() {
|
|||
await installer.getNode(version);
|
||||
}
|
||||
|
||||
const registryUrl = core.getInput('registry-url');
|
||||
const registryUrl: string = core.getInput('registry-url');
|
||||
if (registryUrl) {
|
||||
auth.configAuth(registryUrl);
|
||||
auth.configAuthentication(registryUrl);
|
||||
}
|
||||
|
||||
// TODO: setup proxy from runner proxy config
|
||||
|
|
Loading…
Reference in a new issue