Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for node version codenames and keywords #58

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions __tests__/__snapshots__/authutil.test.ts.snap
@@ -1,30 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`installer tests Appends trailing slash to registry 1`] = `
exports[`auth tests Appends trailing slash to registry 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=false"
`;

exports[`installer tests Automatically configures GPR scope 1`] = `
exports[`auth tests Automatically configures GPR scope 1`] = `
"npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}
@ownername:registry=npm.pkg.github.com/
always-auth=false"
`;

exports[`installer tests Configures scoped npm registries 1`] = `
exports[`auth tests Configures scoped npm registries 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
@myscope:registry=https://registry.npmjs.org/
always-auth=false"
`;

exports[`installer tests Sets up npmrc for always-auth true 1`] = `
exports[`auth tests Sets up npmrc for always-auth true 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=true"
`;

exports[`installer tests Sets up npmrc for npmjs 1`] = `
exports[`auth tests Sets up npmrc for npmjs 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=false"
Expand Down
47 changes: 21 additions & 26 deletions __tests__/authutil.test.ts
@@ -1,25 +1,20 @@
import io = require('@actions/io');
import fs = require('fs');
import path = require('path');

const tempDir = path.join(
__dirname,
'runner',
path.join(
Math.random()
.toString(36)
.substring(7)
),
'temp'
);

import * as io from '@actions/io';
import * as fs from 'fs';
import * as path from'path';

const runnerDir = path.join(__dirname, 'runner');
const randomizer = () =>
Math.random()
.toString(36)
.substring(7);
const tempDir = path.join(runnerDir, randomizer(), 'temp');
const rcFile = path.join(tempDir, '.npmrc');

process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
process.env['RUNNER_TEMP'] = tempDir;
import * as auth from '../src/authutil';

describe('installer tests', () => {
describe('auth tests', () => {
beforeAll(async () => {
await io.rmRF(tempDir);
await io.mkdirP(tempDir);
Expand All @@ -32,36 +27,36 @@ describe('installer tests', () => {
process.env['INPUT_SCOPE'] = '';
});

it('Sets up npmrc for npmjs', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'false');
it('Sets up npmrc for npmjs', () => {
auth.configAuthentication('https://registry.npmjs.org/', 'false');
expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
});

it('Appends trailing slash to registry', async () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false');
it('Appends trailing slash to registry', () => {
auth.configAuthentication('https://registry.npmjs.org', 'false');

expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
});

it('Configures scoped npm registries', async () => {
it('Configures scoped npm registries', () => {
process.env['INPUT_SCOPE'] = 'myScope';
await auth.configAuthentication('https://registry.npmjs.org', 'false');
auth.configAuthentication('https://registry.npmjs.org', 'false');

expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
});

it('Automatically configures GPR scope', async () => {
await auth.configAuthentication('npm.pkg.github.com', 'false');
it('Automatically configures GPR scope', () => {
auth.configAuthentication('npm.pkg.github.com', 'false');

expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
});

it('Sets up npmrc for always-auth true', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
it('Sets up npmrc for always-auth true', () => {
auth.configAuthentication('https://registry.npmjs.org/', 'true');
expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
});
Expand Down